Changeset - r1770:37dc08d96840
[Not reviewed]
master
0 3 0
Darkvater - 20 years ago 2005-05-06 16:13:44
darkvater@openttd.org
(svn r2274) - Codechange: some comments, parentheses and EngineID typedef for engine_type
3 files changed with 8 insertions and 7 deletions:
0 comments (0 inline, 0 general)
train_cmd.c
Show inline comments
 
@@ -952,13 +952,13 @@ int32 CmdSellRailWagon(int x, int y, uin
 
					DeleteVehicle(rear);
 
				}
 
			}
 

	
 
			/* 2. We are selling the first engine, some special action might be required
 
				* here, so take attention */
 
			if (flags & DC_EXEC && v == first) {
 
			if ((flags & DC_EXEC) && v == first) {
 
				Vehicle *new_f = first->next;
 

	
 
				/* 2.1 If the first wagon is sold, update the first-> pointers to NULL */
 
				for (tmp = first; tmp != NULL; tmp = tmp->next) tmp->first = NULL;
 

	
 
				/* 2.2 If there are wagons present after the deleted front engine, check
 
@@ -1040,13 +1040,13 @@ int32 CmdSellRailWagon(int x, int y, uin
 
					first = UnlinkWagon(v, first);
 
					DeleteVehicle(v);
 
				}
 
			}
 

	
 
			/* 3. If it is still a valid train after selling, update its acceleration */
 
			if (flags & DC_EXEC && first != NULL && first->subtype == TS_Front_Engine) UpdateTrainAcceleration(first);
 
			if ((flags & DC_EXEC) && first != NULL && first->subtype == TS_Front_Engine) UpdateTrainAcceleration(first);
 
		} break;
 
	}
 
	return cost;
 
}
 

	
 
static void UpdateTrainDeltaXY(Vehicle *v, int direction)
variables.h
Show inline comments
 
@@ -6,12 +6,13 @@
 
// ********* START OF SAVE REGION
 
#if !defined(MAX_PATH)
 
# define MAX_PATH 260
 
#endif
 

	
 
typedef uint16 UnitID;   //! All unitnumber stuff is of this type (or anyway, should be)
 
typedef uint16 EngineID; //! All enginenumbers should be of this type
 

	
 
// Prices and also the fractional part.
 
VARDEF Prices _price;
 
VARDEF uint16 _price_frac[NUM_PRICES];
 

	
 
VARDEF uint32 _cargo_payment_rates[NUM_CARGO];
vehicle.h
Show inline comments
 
@@ -23,15 +23,15 @@ enum VehStatus {
 
	VS_AIRCRAFT_BROKEN = 0x40,
 
	VS_CRASHED = 0x80,
 
};
 

	
 
// 1 and 3 do not appear to be used
 
typedef enum TrainSubtypes {
 
	TS_Front_Engine = 0,
 
	TS_Not_First = 2,
 
	TS_Free_Car = 4,
 
	TS_Front_Engine = 0, // Leading engine of a train
 
	TS_Not_First = 2,    // Wagon or additional engine
 
	TS_Free_Car = 4,     // First in a wagon chain (in depot)
 
} TrainSubtype;
 

	
 
/* Effect vehicle types */
 
typedef enum EffectVehicle {
 
	EV_CHIMNEY_SMOKE   = 0,
 
	EV_STEAM_SMOKE     = 1,
 
@@ -158,13 +158,13 @@ struct Vehicle {
 
	uint16 cur_image; // sprite number for this vehicle
 
	byte sprite_width;// width of vehicle sprite
 
	byte sprite_height;// height of vehicle sprite
 
	byte z_height;		// z-height of vehicle sprite
 
	int8 x_offs;			// x offset for vehicle sprite
 
	int8 y_offs;			// y offset for vehicle sprite
 
	uint16 engine_type;
 
	EngineID engine_type;
 

	
 
	// for randomized variational spritegroups
 
	// bitmask used to resolve them; parts of it get reseeded when triggers
 
	// of corresponding spritegroups get matched
 
	byte random_bits;
 
	byte waiting_triggers; // triggers to be yet matched
 
@@ -363,13 +363,13 @@ static inline uint16 GetVehiclePoolSize(
 
#define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1 < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL)
 
#define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0)
 

	
 
/**
 
 * Check if a Vehicle really exists.
 
 */
 
static inline bool IsValidVehicle(Vehicle* v)
 
static inline bool IsValidVehicle(const Vehicle *v)
 
{
 
	return v->type != 0;
 
}
 

	
 
/**
 
 * Check if an index is a vehicle-index (so between 0 and max-vehicles)
0 comments (0 inline, 0 general)