Changeset - r6621:c0fe19bbb51d
[Not reviewed]
master
0 7 0
rubidium - 17 years ago 2007-05-15 11:28:22
rubidium@openttd.org
(svn r9841) -Codechange: add a little more type strictness to the vehicle types.
7 files changed with 15 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/depot_gui.cpp
Show inline comments
 
@@ -134,12 +134,13 @@ void CcCloneVehicle(bool success, TileIn
 
	if (!success) return;
 
	switch(GetVehicle(p1)->type) {
 
		case VEH_TRAIN:    CcCloneTrain(   true, tile, p1, p2); break;
 
		case VEH_ROAD:     CcCloneRoadVeh( true, tile, p1, p2); break;
 
		case VEH_SHIP:     CcCloneShip(    true, tile, p1, p2); break;
 
		case VEH_AIRCRAFT: CcCloneAircraft(true, tile, p1, p2); break;
 
		default: NOT_REACHED();
 
	}
 
}
 

	
 
static inline void ShowVehicleViewWindow(const Vehicle *v)
 
{
 
	switch (v->type) {
src/economy.cpp
Show inline comments
 
@@ -362,12 +362,13 @@ void ChangeOwnershipOfPlayerItems(Player
 
					if (IsEngineCountable(v)) GetPlayer(new_player)->num_engines[v->engine_type]++;
 
					switch (v->type) {
 
						case VEH_TRAIN:    if (IsFrontEngine(v)) v->unitnumber = ++num_train; break;
 
						case VEH_ROAD:     v->unitnumber = ++num_road; break;
 
						case VEH_SHIP:     v->unitnumber = ++num_ship; break;
 
						case VEH_AIRCRAFT: if (IsNormalAircraft(v)) v->unitnumber = ++num_aircraft; break;
 
						default: NOT_REACHED();
 
					}
 
				}
 
			}
 
		}
 
	}
 

	
src/network/network_server.cpp
Show inline comments
 
@@ -1298,15 +1298,13 @@ void NetworkPopulateCompanyInfo()
 
				break;
 

	
 
			case VEH_SHIP:
 
				_network_player_info[v->owner].num_vehicle[4]++;
 
				break;
 

	
 
			case VEH_SPECIAL:
 
			case VEH_DISASTER:
 
				break;
 
			default: break;
 
		}
 
	}
 

	
 
	// Go through all stations and count the types of stations
 
	FOR_ALL_STATIONS(s) {
 
		if (IsValidPlayer(s->owner)) {
src/newgrf_engine.cpp
Show inline comments
 
@@ -767,12 +767,14 @@ static uint32 VehicleGetVariable(const R
 
			switch (variable - 0x80) {
 
				case 0x62: return MapAircraftMovementState(v);  // Current movement state
 
				case 0x63: return v->u.air.targetairport;       // Airport to which the action refers
 
				case 0x66: return MapAircraftMovementAction(v); // Current movement action
 
			}
 
			break;
 

	
 
		default: break;
 
	}
 

	
 
	DEBUG(grf, 1, "Unhandled vehicle property 0x%X, type 0x%X", variable, v->type);
 

	
 
	*available = false;
 
	return UINT_MAX;
src/vehicle.cpp
Show inline comments
 
@@ -674,12 +674,14 @@ void CallVehicleTicks()
 

	
 
	Vehicle *v;
 
	FOR_ALL_VEHICLES(v) {
 
		_vehicle_tick_procs[v->type](v);
 

	
 
		switch (v->type) {
 
			default: break;
 

	
 
			case VEH_TRAIN:
 
			case VEH_ROAD:
 
			case VEH_AIRCRAFT:
 
			case VEH_SHIP:
 
				if (v->type == VEH_TRAIN && IsTrainWagon(v)) continue;
 
				if (v->type == VEH_AIRCRAFT && v->subtype != AIR_HELICOPTER) continue;
 
@@ -2847,12 +2849,13 @@ static void Load_VEHS()
 
			case VEH_ROAD:     v = new (v) RoadVehicle();     break;
 
			case VEH_SHIP:     v = new (v) Ship();            break;
 
			case VEH_AIRCRAFT: v = new (v) Aircraft();        break;
 
			case VEH_SPECIAL:  v = new (v) SpecialVehicle();  break;
 
			case VEH_DISASTER: v = new (v) DisasterVehicle(); break;
 
			case VEH_INVALID:  v = new (v) InvalidVehicle();  break;
 
			default: NOT_REACHED();
 
		}
 

	
 
		/* Old savegames used 'last_station_visited = 0xFF' */
 
		if (CheckSavegameVersion(5) && v->last_station_visited == 0xFF)
 
			v->last_station_visited = INVALID_STATION;
 

	
src/vehicle.h
Show inline comments
 
@@ -61,21 +61,24 @@ enum RoadVehicleStates {
 
	RVSB_IN_DT_ROAD_STOP_END     = RVSB_IN_DT_ROAD_STOP + TRACKDIR_END,
 

	
 
	RVSB_TRACKDIR_MASK           = 0x0F,                      ///< The mask used to extract track dirs
 
	RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09                       ///< Only bits 0 and 3 are used to encode the trackdir for road stops
 
};
 

	
 
enum {
 
enum VehicleType {
 
	VEH_TRAIN,
 
	VEH_ROAD,
 
	VEH_SHIP,
 
	VEH_AIRCRAFT,
 
	VEH_SPECIAL,
 
	VEH_DISASTER,
 
	VEH_END,
 
	VEH_INVALID = 0xFF,
 
} ;
 
};
 
template <> struct EnumPropsT<VehicleType> : MakeEnumPropsT<VehicleType, byte, VEH_TRAIN, VEH_END, VEH_INVALID> {};
 
typedef TinyEnumT<VehicleType> VehicleTypeByte;
 

	
 
enum VehStatus {
 
	VS_HIDDEN          = 0x01,
 
	VS_STOPPED         = 0x02,
 
	VS_UNCLICKABLE     = 0x04,
 
	VS_DEFPAL          = 0x08,
 
@@ -200,13 +203,13 @@ struct VehicleDisaster {
 
struct VehicleShip {
 
	TrackBitsByte state;
 
};
 

	
 

	
 
struct Vehicle {
 
	byte type;               // type, ie roadven,train,ship,aircraft,special
 
	VehicleTypeByte type;    ///< Type of vehicle
 
	byte subtype;            // subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes)
 

	
 
	VehicleID index;         // NOSAVE: Index in vehicle array
 

	
 
	Vehicle *next;           // next
 
	Vehicle *first;          // NOSAVE: pointer to the first vehicle in the chain
src/vehicle_gui.cpp
Show inline comments
 
@@ -374,12 +374,13 @@ static void VehicleRefitWndProc(Window *
 
						const Vehicle *v = GetVehicle(w->window_number);
 

	
 
						if (WP(w, refit_d).order == INVALID_VEH_ORDER_ID) {
 
							int command = 0;
 

	
 
							switch (v->type) {
 
								default: NOT_REACHED();
 
								case VEH_TRAIN:    command = CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE);  break;
 
								case VEH_ROAD:     command = CMD_REFIT_ROAD_VEH     | CMD_MSG(STR_REFIT_ROAD_VEHICLE_CAN_T);  break;
 
								case VEH_SHIP:     command = CMD_REFIT_SHIP         | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP);     break;
 
								case VEH_AIRCRAFT: command = CMD_REFIT_AIRCRAFT     | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT); break;
 
							}
 
							if (DoCommandP(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8, NULL, command)) DeleteWindow(w);
0 comments (0 inline, 0 general)