Changeset - r9468:a092e2eb1209
[Not reviewed]
master
0 4 0
peter1138 - 16 years ago 2008-06-05 12:08:20
peter1138@openttd.org
(svn r13388) -Codechange: Remove "my invented flag for something that is a wagon"
4 files changed with 25 insertions and 30 deletions:
0 comments (0 inline, 0 general)
src/engine.cpp
Show inline comments
 
@@ -184,6 +184,13 @@ void LoadCustomEngineNames()
 
	DEBUG(misc, 1, "LoadCustomEngineNames: not done");
 
}
 

	
 
/* Determine if an engine type is a wagon (and not a loco) */
 
static bool IsWagon(EngineID index)
 
{
 
	const Engine *e = GetEngine(index);
 
	return e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON;
 
}
 

	
 
static void CalcEngineReliability(Engine *e)
 
{
 
	uint age = e->age;
 
@@ -256,10 +263,9 @@ void StartupEngines()
 
		e->duration_phase_2 = GB(r, 5, 4) + ei->base_life * 12 - 96;
 
		e->duration_phase_3 = GB(r, 9, 7) + 120;
 

	
 
		e->reliability_spd_dec = (ei->unk2&0x7F) << 2;
 
		e->reliability_spd_dec = ei->decay_speed << 2;
 

	
 
		/* my invented flag for something that is a wagon */
 
		if (ei->unk2 & 0x80) {
 
		if (IsWagon(e->index)) {
 
			e->age = 0xFFFF;
 
		} else {
 
			CalcEngineReliability(e);
 
@@ -377,13 +383,6 @@ CommandCost CmdWantEnginePreview(TileInd
 
	return CommandCost();
 
}
 

	
 
/* Determine if an engine type is a wagon (and not a loco) */
 
static bool IsWagon(EngineID index)
 
{
 
	const Engine *e = GetEngine(index);
 
	return e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON;
 
}
 

	
 
StringID GetEngineCategoryName(EngineID engine);
 

	
 
static void NewVehicleAvailable(Engine *e)
src/engine_type.h
Show inline comments
 
@@ -109,7 +109,7 @@ struct EngineInfo {
 
	Date base_intro;
 
	Year lifelength;
 
	Year base_life;
 
	byte unk2;         ///< flag for carriage(bit 7) and decay speed(bits0..6)
 
	byte decay_speed;
 
	byte load_amount;
 
	byte climates;
 
	uint32 refit_mask;
src/newgrf.cpp
Show inline comments
 
@@ -417,18 +417,6 @@ static void MapSpriteMappingRecolour(Pal
 

	
 
typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len);
 

	
 
static void dewagonize(int condition, Engine *e)
 
{
 
	if (condition != 0) {
 
		e->info.unk2 &= ~0x80;
 
		if (e->u.rail.railveh_type == RAILVEH_WAGON)
 
			e->u.rail.railveh_type = RAILVEH_SINGLEHEAD;
 
	} else {
 
		e->info.unk2 |= 0x80;
 
		e->u.rail.railveh_type = RAILVEH_WAGON;
 
	}
 
}
 

	
 
static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len)
 
{
 
	byte *buf = *bufp;
 
@@ -468,7 +456,15 @@ static bool RailVehicleChangeInfo(uint e
 

	
 
			case 0x0B: // Power
 
				rvi->power = grf_load_word(&buf);
 
				dewagonize(rvi->power, e);
 

	
 
				/* Set engine / wagon state based on power */
 
				if (rvi->power != 0) {
 
					if (rvi->railveh_type == RAILVEH_WAGON) {
 
						rvi->railveh_type = RAILVEH_SINGLEHEAD;
 
					}
 
				} else {
 
					rvi->railveh_type = RAILVEH_WAGON;
 
				}
 
				break;
 

	
 
			case 0x0D: // Running cost factor
 
@@ -2300,7 +2296,7 @@ static void FeatureChangeInfo(byte *buf,
 
							break;
 

	
 
						case 0x02: // Decay speed
 
							SB(ei->unk2, 0, 7, grf_load_byte(&buf) & 0x7F);
 
							ei->decay_speed = grf_load_byte(&buf);
 
							break;
 

	
 
						case 0x03: // Vehicle life
src/table/engines.h
Show inline comments
 
@@ -18,7 +18,7 @@ enum {
 
/** Writes the properties of a train or road vehicle into the EngineInfo struct.
 
 * @see EngineInfo
 
 * @param a Introduction date
 
 * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6)
 
 * @param b decay speed
 
 * @param c life length
 
 * @param d base life
 
 * @param e Bitmask of the climates
 
@@ -29,18 +29,18 @@ enum {
 

	
 
/** Writes the properties of a train carriage into the EngineInfo struct.
 
 * @param a Introduction date
 
 * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6)
 
 * @param b decay speed
 
 * @param c life length
 
 * @param d base life
 
 * @param e Bitmask of the climates
 
 * @see MK
 
 * @note the 5 between d and e is the load amount
 
 */
 
#define MW(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b | 0x80, 5, e, 0, 8, 0, 0, 0, STR_EMPTY }
 
#define MW(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, e, 0, 8, 0, 0, 0, STR_EMPTY }
 

	
 
/** Writes the properties of a ship into the EngineInfo struct.
 
 * @param a Introduction date
 
 * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6)
 
 * @param b decay speed
 
 * @param c life length
 
 * @param d base life
 
 * @param e Bitmask of the climates
 
@@ -51,7 +51,7 @@ enum {
 

	
 
/** Writes the properties of an aeroplane into the EngineInfo struct.
 
 * @param a Introduction date
 
 * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6)
 
 * @param b decay speed
 
 * @param c life length
 
 * @param d base life
 
 * @param e Bitmask of the climates
0 comments (0 inline, 0 general)