Changeset - r18855:53b988159599
[Not reviewed]
master
0 6 0
truebrain - 12 years ago 2012-01-02 13:44:37
truebrain@openttd.org
(svn r23714) -Codechange: don't mix Viewport with non-viewport code
6 files changed with 26 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -480,6 +480,7 @@ void SetAircraftPosition(Aircraft *v, in
 
	v->y_pos = y;
 
	v->z_pos = z;
 

	
 
	VehicleUpdatePosition(v);
 
	v->UpdateViewport(true, false);
 
	if (v->subtype == AIR_HELICOPTER) v->Next()->Next()->cur_image = GetRotorImage(v, EIT_ON_MAP);
 

	
src/ground_vehicle.hpp
Show inline comments
 
@@ -226,10 +226,10 @@ struct GroundVehicle : public Specialize
 
	/**
 
	 * Checks if the vehicle is in a slope and sets the required flags in that case.
 
	 * @param new_tile True if the vehicle reached a new tile.
 
	 * @param turned Indicates if the vehicle has turned.
 
	 * @param update_delta Indicates to also update the delta.
 
	 * @return Old height of the vehicle.
 
	 */
 
	inline byte UpdateInclination(bool new_tile, bool turned)
 
	inline byte UpdateInclination(bool new_tile, bool update_delta)
 
	{
 
		byte old_z = this->z_pos;
 

	
 
@@ -239,7 +239,7 @@ struct GroundVehicle : public Specialize
 
			this->UpdateZPosition();
 
		}
 

	
 
		this->UpdateViewport(true, turned);
 
		this->UpdateViewport(true, update_delta);
 
		return old_z;
 
	}
 

	
src/roadveh_cmd.cpp
Show inline comments
 
@@ -987,6 +987,7 @@ static bool RoadVehLeaveDepot(RoadVehicl
 

	
 
	v->x_pos = x;
 
	v->y_pos = y;
 
	VehicleUpdatePosition(v);
 
	v->UpdateInclination(true, true);
 

	
 
	InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
@@ -1121,6 +1122,7 @@ static bool IndividualRoadVehicleControl
 
			/* Vehicle has just entered a bridge or tunnel */
 
			v->x_pos = gp.x;
 
			v->y_pos = gp.y;
 
			VehicleUpdatePosition(v);
 
			v->UpdateInclination(true, true);
 
			return true;
 
		}
 
@@ -1277,6 +1279,7 @@ again:
 
		}
 
		v->x_pos = x;
 
		v->y_pos = y;
 
		VehicleUpdatePosition(v);
 
		RoadZPosAffectSpeed(v, v->UpdateInclination(true, true));
 
		return true;
 
	}
 
@@ -1342,6 +1345,7 @@ again:
 

	
 
		v->x_pos = x;
 
		v->y_pos = y;
 
		VehicleUpdatePosition(v);
 
		RoadZPosAffectSpeed(v, v->UpdateInclination(true, true));
 
		return true;
 
	}
 
@@ -1430,6 +1434,7 @@ again:
 
					v->frame++;
 
					v->x_pos = x;
 
					v->y_pos = y;
 
					VehicleUpdatePosition(v);
 
					RoadZPosAffectSpeed(v, v->UpdateInclination(true, false));
 
					return true;
 
				}
 
@@ -1478,6 +1483,7 @@ again:
 
	if (!HasBit(r, VETS_ENTERED_WORMHOLE)) v->frame++;
 
	v->x_pos = x;
 
	v->y_pos = y;
 
	VehicleUpdatePosition(v);
 
	RoadZPosAffectSpeed(v, v->UpdateInclination(false, true));
 
	return true;
 
}
src/ship_cmd.cpp
Show inline comments
 
@@ -326,7 +326,7 @@ static bool CheckShipLeaveDepot(Ship *v)
 
	v->vehstatus &= ~VS_HIDDEN;
 

	
 
	v->cur_speed = 0;
 
	v->UpdateViewport(false, true);
 
	v->UpdateViewport(true, true);
 
	SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 

	
 
	PlayShipSound(v);
 
@@ -601,6 +601,7 @@ static void ShipController(Ship *v)
 
	v->z_pos = GetSlopePixelZ(gp.x, gp.y);
 

	
 
getout:
 
	VehicleUpdatePosition(v);
 
	v->UpdateViewport(true, true);
 
	return;
 

	
src/train_cmd.cpp
Show inline comments
 
@@ -1542,12 +1542,14 @@ static void UpdateStatusAfterSwap(Train 
 
				/* We have just left the wormhole, possibly set the
 
				 * "goingdown" bit. UpdateInclination() can be used
 
				 * because we are at the border of the tile. */
 
				VehicleUpdatePosition(v);
 
				v->UpdateInclination(true, true);
 
				return;
 
			}
 
		}
 
	}
 

	
 
	VehicleUpdatePosition(v);
 
	v->UpdateViewport(true, true);
 
}
 

	
 
@@ -2155,10 +2157,8 @@ static bool CheckTrainStayInDepot(Train 
 
	v->vehstatus &= ~VS_HIDDEN;
 
	v->cur_speed = 0;
 

	
 
	v->UpdateDeltaXY(v->direction);
 
	v->cur_image = v->GetImage(v->direction, EIT_ON_MAP);
 
	v->UpdateViewport(true, true);
 
	VehicleUpdatePosition(v);
 
	VehicleUpdateViewport(v, false);
 
	UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner);
 
	v->UpdateAcceleration();
 
	InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
@@ -3321,6 +3321,7 @@ bool TrainController(Train *v, Vehicle *
 

	
 
		v->x_pos = gp.x;
 
		v->y_pos = gp.y;
 
		VehicleUpdatePosition(v);
 

	
 
		/* update the Z position of the vehicle */
 
		int old_z = v->UpdateInclination(gp.new_tile != gp.old_tile, false);
 
@@ -3488,7 +3489,10 @@ static void ChangeTrainDirRandomly(Train
 
			/* Refrain from updating the z position of the vehicle when on
 
			 * a bridge, because UpdateInclination() will put the vehicle under
 
			 * the bridge in that case */
 
			if (v->track != TRACK_BIT_WORMHOLE) v->UpdateInclination(false, false);
 
			if (v->track != TRACK_BIT_WORMHOLE) {
 
				VehicleUpdatePosition(v);
 
				v->UpdateInclination(false, false);
 
			}
 
		}
 
	} while ((v = v->Next()) != NULL);
 
}
src/vehicle_base.h
Show inline comments
 
@@ -986,19 +986,19 @@ struct SpecializedVehicle : public Vehic
 

	
 
	/**
 
	 * Update vehicle sprite- and position caches
 
	 * @param moved Was the vehicle moved?
 
	 * @param turned Did the vehicle direction change?
 
	 * @param force_update Force updating the vehicle on the viewport.
 
	 * @param update_delta Also update the delta?
 
	 */
 
	inline void UpdateViewport(bool moved, bool turned)
 
	inline void UpdateViewport(bool force_update, bool update_delta)
 
	{
 
		extern void VehicleUpdatePositionAndViewport(Vehicle *v);
 
		extern void VehicleUpdateViewport(Vehicle *v, bool dirty);
 

	
 
		/* Explicitly choose method to call to prevent vtable dereference -
 
		 * it gives ~3% runtime improvements in games with many vehicles */
 
		if (turned) ((T *)this)->T::UpdateDeltaXY(this->direction);
 
		if (update_delta) ((T *)this)->T::UpdateDeltaXY(this->direction);
 
		SpriteID old_image = this->cur_image;
 
		this->cur_image = ((T *)this)->T::GetImage(this->direction, EIT_ON_MAP);
 
		if (moved || this->cur_image != old_image) VehicleUpdatePositionAndViewport(this);
 
		if (force_update || this->cur_image != old_image) VehicleUpdateViewport(this, true);
 
	}
 
};
 

	
0 comments (0 inline, 0 general)