1
0
Fork 0

(svn r13388) -Codechange: Remove "my invented flag for something that is a wagon"

release/0.7
peter1138 2008-06-05 12:08:20 +00:00
parent 94718ae0de
commit 261018fc8c
4 changed files with 25 additions and 30 deletions

View File

@ -184,6 +184,13 @@ void LoadCustomEngineNames()
DEBUG(misc, 1, "LoadCustomEngineNames: not done"); 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) static void CalcEngineReliability(Engine *e)
{ {
uint age = e->age; 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_2 = GB(r, 5, 4) + ei->base_life * 12 - 96;
e->duration_phase_3 = GB(r, 9, 7) + 120; 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 (IsWagon(e->index)) {
if (ei->unk2 & 0x80) {
e->age = 0xFFFF; e->age = 0xFFFF;
} else { } else {
CalcEngineReliability(e); CalcEngineReliability(e);
@ -377,13 +383,6 @@ CommandCost CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32
return CommandCost(); 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); StringID GetEngineCategoryName(EngineID engine);
static void NewVehicleAvailable(Engine *e) static void NewVehicleAvailable(Engine *e)

View File

@ -109,7 +109,7 @@ struct EngineInfo {
Date base_intro; Date base_intro;
Year lifelength; Year lifelength;
Year base_life; Year base_life;
byte unk2; ///< flag for carriage(bit 7) and decay speed(bits0..6) byte decay_speed;
byte load_amount; byte load_amount;
byte climates; byte climates;
uint32 refit_mask; uint32 refit_mask;

View File

@ -417,18 +417,6 @@ static void MapSpriteMappingRecolour(PalSpriteID *grf_sprite)
typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); 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) static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len)
{ {
byte *buf = *bufp; byte *buf = *bufp;
@ -468,7 +456,15 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
case 0x0B: // Power case 0x0B: // Power
rvi->power = grf_load_word(&buf); 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; break;
case 0x0D: // Running cost factor case 0x0D: // Running cost factor
@ -2300,7 +2296,7 @@ static void FeatureChangeInfo(byte *buf, size_t len)
break; break;
case 0x02: // Decay speed case 0x02: // Decay speed
SB(ei->unk2, 0, 7, grf_load_byte(&buf) & 0x7F); ei->decay_speed = grf_load_byte(&buf);
break; break;
case 0x03: // Vehicle life case 0x03: // Vehicle life

View File

@ -18,7 +18,7 @@ enum {
/** Writes the properties of a train or road vehicle into the EngineInfo struct. /** Writes the properties of a train or road vehicle into the EngineInfo struct.
* @see EngineInfo * @see EngineInfo
* @param a Introduction date * @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 c life length
* @param d base life * @param d base life
* @param e Bitmask of the climates * @param e Bitmask of the climates
@ -29,18 +29,18 @@ enum {
/** Writes the properties of a train carriage into the EngineInfo struct. /** Writes the properties of a train carriage into the EngineInfo struct.
* @param a Introduction date * @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 c life length
* @param d base life * @param d base life
* @param e Bitmask of the climates * @param e Bitmask of the climates
* @see MK * @see MK
* @note the 5 between d and e is the load amount * @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. /** Writes the properties of a ship into the EngineInfo struct.
* @param a Introduction date * @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 c life length
* @param d base life * @param d base life
* @param e Bitmask of the climates * @param e Bitmask of the climates
@ -51,7 +51,7 @@ enum {
/** Writes the properties of an aeroplane into the EngineInfo struct. /** Writes the properties of an aeroplane into the EngineInfo struct.
* @param a Introduction date * @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 c life length
* @param d base life * @param d base life
* @param e Bitmask of the climates * @param e Bitmask of the climates