Changeset - r8666:a02ccc4ff4e1
[Not reviewed]
master
0 4 0
glx - 16 years ago 2008-03-03 20:56:30
glx@openttd.org
(svn r12331) -Feature: [NewGRF] vehicle variable FE bit 8
4 files changed with 12 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/newgrf_engine.cpp
Show inline comments
 
@@ -627,16 +627,15 @@ static uint32 VehicleGetVariable(const R
 
			uint16 modflags = 0;
 

	
 
			if (v->type == VEH_TRAIN) {
 
				/* @todo: There are some other bits that should be implemented:
 
				 *   bit 8: (Maybe?) Toggled whenever the train reverses.
 
				 */
 
				const Vehicle *u = IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON) ? v->First() : v;
 
				RailType railtype = GetRailType(v->tile);
 
				bool powered = IsTrainEngine(v) || (IsTrainWagon(v) && HasBit(v->vehicle_flags, VRF_POWEREDWAGON));
 
				bool has_power = powered && HasPowerOnRail(u->u.rail.railtype, railtype);
 
				bool is_electric = powered && u->u.rail.railtype == RAILTYPE_ELECTRIC;
 

	
 
				if (has_power) SetBit(modflags, 5);
 
				if (is_electric && !has_power) SetBit(modflags, 6);
 
				if (HasBit(v->u.rail.flags, VRF_TOGGLE_REVERSE)) SetBit(modflags, 8);
 
			}
 
			if (HasBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE)) SetBit(modflags, 10);
 

	
src/train_cmd.cpp
Show inline comments
 
@@ -1787,7 +1787,10 @@ static void ReverseTrainDirection(Vehicl
 
	}
 

	
 
	/* update all images */
 
	for (Vehicle *u = v; u != NULL; u = u->Next()) { u->cur_image = u->GetImage(u->direction); }
 
	for (Vehicle *u = v; u != NULL; u = u->Next()) {
 
		ToggleBit(u->u.rail.flags, VRF_TOGGLE_REVERSE);
 
		u->cur_image = u->GetImage(u->direction);
 
	}
 

	
 
	ClrBit(v->u.rail.flags, VRF_REVERSING);
 

	
src/vehicle.cpp
Show inline comments
 
@@ -2199,6 +2199,8 @@ void VehicleEnterDepot(Vehicle *v)
 
			if (!IsFrontEngine(v)) v = v->First();
 
			UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner);
 
			v->load_unload_time_rem = 0;
 
			/* Reset reversed flag */
 
			for (Vehicle *u = v; u != NULL; u = u->Next()) ClrBit(u->u.rail.flags, VRF_TOGGLE_REVERSE);
 
			break;
 

	
 
		case VEH_ROAD:
src/vehicle_base.h
Show inline comments
 
@@ -118,7 +118,7 @@ struct VehicleRail {
 
	const struct SpriteGroup *cached_override;
 
};
 

	
 
enum {
 
enum VehicleRailFlags {
 
	VRF_REVERSING         = 0,
 

	
 
	/* used to calculate if train is going up or down */
 
@@ -136,6 +136,9 @@ enum {
 

	
 
	/* used to mark that electric train engine is allowed to run on normal rail */
 
	VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6,
 

	
 
	/* used for vehicle var 0xFE bit 8 (toggled each time the train is reversed) */
 
	VRF_TOGGLE_REVERSE = 7,
 
};
 

	
 
struct VehicleAir {
0 comments (0 inline, 0 general)