From 2fd3553d78d6b93fb85d97ae8e98beef5418a9c4 Mon Sep 17 00:00:00 2001 From: bjarni Date: Wed, 19 Jan 2005 19:15:03 +0000 Subject: [PATCH] (svn r1568) made an enum of train subtypes to make the code more readable --- economy.c | 8 ++--- main_gui.c | 2 +- network_server.c | 2 +- order_gui.c | 4 +-- player_gui.c | 2 +- station_cmd.c | 2 +- train_cmd.c | 80 +++++++++++++++++++++++----------------------- train_gui.c | 24 +++++++------- tunnelbridge_cmd.c | 4 +-- vehicle.c | 4 +-- vehicle.h | 7 +++- vehicle_gui.c | 2 +- 12 files changed, 73 insertions(+), 68 deletions(-) diff --git a/economy.c b/economy.c index f98d3f4878..d5ad30114a 100644 --- a/economy.c +++ b/economy.c @@ -128,7 +128,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update) FOR_ALL_VEHICLES(v) { if (v->owner != owner) continue; - if ((v->type == VEH_Train && v->subtype == 0) || + if ((v->type == VEH_Train && v->subtype == TS_Front_Engine) || v->type == VEH_Road || (v->type == VEH_Aircraft && v->subtype<=2) || v->type == VEH_Ship) { @@ -310,7 +310,7 @@ void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player) // Determine Ids for the new vehicles FOR_ALL_VEHICLES(v) { if (v->owner == new_player) { - if (v->type == VEH_Train && v->subtype == 0) + if (v->type == VEH_Train && v->subtype == TS_Front_Engine) num_train++; else if (v->type == VEH_Road) num_road++; @@ -330,7 +330,7 @@ void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player) DeleteVehicle(v); } else { v->owner = new_player; - if (v->type == VEH_Train && v->subtype == 0) + if (v->type == VEH_Train && v->subtype == TS_Front_Engine) v->unitnumber = ++num_train; else if (v->type == VEH_Road) v->unitnumber = ++num_road; @@ -1297,7 +1297,7 @@ static bool LoadWait(const Vehicle *v, const Vehicle *u) { } FOR_ALL_VEHICLES(x) { - if ((x->type != VEH_Train || x->subtype == 0) && // for all locs + if ((x->type != VEH_Train || x->subtype == TS_Front_Engine) && // for all locs u->last_station_visited == x->last_station_visited && // at the same station !(x->vehstatus & VS_STOPPED) && // not stopped x->current_order.type == OT_LOADING && // loading diff --git a/main_gui.c b/main_gui.c index 00452e109c..7fb3f0df45 100644 --- a/main_gui.c +++ b/main_gui.c @@ -810,7 +810,7 @@ static void ToolbarTrainClick(Window *w) Vehicle *v; int dis = -1; FOR_ALL_VEHICLES(v) - if (v->type == VEH_Train && v->subtype == 0) CLRBIT(dis, v->owner); + if (v->type == VEH_Train && v->subtype == TS_Front_Engine) CLRBIT(dis, v->owner); PopupMainPlayerToolbMenu(w, 310, 13, dis); } diff --git a/network_server.c b/network_server.c index 2108ee0840..eccf911141 100644 --- a/network_server.c +++ b/network_server.c @@ -1249,7 +1249,7 @@ void NetworkPopulateCompanyInfo(void) if (v->owner < MAX_PLAYERS) switch (v->type) { case VEH_Train: - if (v->subtype == 0) + if (v->subtype == TS_Front_Engine) _network_player_info[v->owner].num_vehicle[0]++; break; case VEH_Road: diff --git a/order_gui.c b/order_gui.c index 5c99bb5570..0c9692929b 100644 --- a/order_gui.c +++ b/order_gui.c @@ -271,9 +271,9 @@ static bool HandleOrderVehClick(Vehicle *v, Vehicle *u, Window *w) if (u->type != v->type) return false; - if (u->type == VEH_Train && u->subtype != 0) { + if (u->type == VEH_Train && u->subtype != TS_Front_Engine) { u = GetFirstVehicleInChain(u); - if (u->subtype != 0) + if (u->subtype != TS_Front_Engine) return false; } diff --git a/player_gui.c b/player_gui.c index 109e3e80c9..d3ef4fadca 100644 --- a/player_gui.c +++ b/player_gui.c @@ -424,7 +424,7 @@ static void DrawPlayerVehiclesAmount(int player) FOR_ALL_VEHICLES(v) { if (v->owner == player) { if (v->type == VEH_Train) { - if (v->subtype == 0) + if (v->subtype == TS_Front_Engine) train++; } else if (v->type == VEH_Road) { road++; diff --git a/station_cmd.c b/station_cmd.c index cde11f1e9d..fe990857a0 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -2188,7 +2188,7 @@ static uint32 VehicleEnter_Station(Vehicle *v, uint tile, int x, int y) uint16 spd; if (v->type == VEH_Train) { - if (IS_BYTE_INSIDE(_map5[tile], 0, 8) && v->subtype == 0 && + if (IS_BYTE_INSIDE(_map5[tile], 0, 8) && v->subtype == TS_Front_Engine && !IsTrainStationTile(tile + TileOffsByDir(v->direction >> 1))) { station_id = _map2[tile]; diff --git a/train_cmd.c b/train_cmd.c index 9bf9d210c2..1239117883 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -39,7 +39,7 @@ void UpdateTrainAcceleration(Vehicle *v) uint acc, power=0, max_speed=5000, weight=0; Vehicle *u = v; - assert(v->subtype == 0); + assert(v->subtype == TS_Front_Engine); // compute stuff like max speed, power, and weight. do { @@ -92,7 +92,7 @@ static int GetRealisticAcceleration(Vehicle *v) float f = 0.0f, spd; int curves = 0; - assert(v->subtype == 0); + assert(v->subtype == TS_Front_Engine); // compute inclination force and number of curves. do { @@ -251,7 +251,7 @@ static int32 CmdBuildRailWagon(uint engine, uint tile, uint32 flags) FOR_ALL_VEHICLES(w) { if (w->type == VEH_Train && w->tile == (TileIndex)tile && - w->subtype == 4 && w->engine_type == engine) { + w->subtype == TS_Free_Car && w->engine_type == engine) { u = GetLastVehicleInChain(w); break; } @@ -275,12 +275,12 @@ static int32 CmdBuildRailWagon(uint engine, uint tile, uint32 flags) v->u.rail.track = 0x80; v->vehstatus = VS_HIDDEN | VS_DEFPAL; - v->subtype = 4; + v->subtype = TS_Free_Car; if (u != NULL) { u->next = v; - v->subtype = 2; + v->subtype = TS_Not_First; v->u.rail.first_engine = u->u.rail.first_engine; - if (v->u.rail.first_engine == 0xffff && u->subtype == 0) + if (v->u.rail.first_engine == 0xffff && u->subtype == TS_Front_Engine ) v->u.rail.first_engine = u->engine_type; } else { v->u.rail.first_engine = 0xffff; @@ -314,7 +314,7 @@ static void NormalizeTrainVehInDepot(Vehicle *u) { Vehicle *v; FOR_ALL_VEHICLES(v) { - if (v->type == VEH_Train && v->subtype==4 && + if (v->type == VEH_Train && v->subtype == TS_Free_Car && v->tile == u->tile && v->u.rail.track == 0x80) { if (DoCommandByTile(0,v->index | (u->index<<16), 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE) == CMD_ERROR) @@ -377,7 +377,7 @@ void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool building) u->u.rail.track = 0x80; v->u.rail.first_engine = 0xffff; u->vehstatus = v->vehstatus & ~VS_STOPPED; - u->subtype = 2; + u->subtype = TS_Not_First; u->spritenum = v->spritenum + 1; u->cargo_type = v->cargo_type; u->cargo_cap = v->cargo_cap; @@ -517,7 +517,7 @@ errmsg: do { count++; if (v->u.rail.track != 0x80 || v->tile != (TileIndex)tile || - (v->subtype==0 && !(v->vehstatus&VS_STOPPED))) + (v->subtype == TS_Front_Engine && !(v->vehstatus&VS_STOPPED))) goto errmsg; } while ( (v=v->next) != NULL); @@ -534,7 +534,7 @@ static Vehicle *UnlinkWagon(Vehicle *v, Vehicle *first) Vehicle *u; if ((v=v->next) == NULL) return NULL; for (u=v; u; u=u->next) u->u.rail.first_engine = v->engine_type; - v->subtype = 4; + v->subtype = TS_Free_Car; return v; } else { Vehicle *u; @@ -551,7 +551,7 @@ static Vehicle *FindGoodVehiclePos(Vehicle *src) TileIndex tile = src->tile; FOR_ALL_VEHICLES(dst) { - if (dst->type==VEH_Train && dst->subtype==4 && dst->tile==tile) { + if (dst->type == VEH_Train && dst->subtype == TS_Free_Car && dst->tile==tile) { // check so all vehicles in the line have the same engine. Vehicle *v = dst; while (v->engine_type == eng) { @@ -611,7 +611,7 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (num < 0) return CMD_ERROR; - if (num > (_patches.mammoth_trains ? 100 : 9) && dst_head->subtype==0) + if (num > (_patches.mammoth_trains ? 100 : 9) && dst_head->subtype == TS_Front_Engine ) return_cmd_error(STR_8819_TRAIN_TOO_LONG); // if it's a multiheaded vehicle we're dragging to, drag to the vehicle before.. @@ -630,7 +630,7 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) return 0; // moving a loco to a new line?, then we need to assign a unitnumber. - if (dst == NULL && src->subtype != 0 && is_loco) { + if (dst == NULL && src->subtype != TS_Front_Engine && is_loco) { uint unit_num = GetFreeUnitNumber(VEH_Train); if (unit_num > _patches.max_trains) return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); @@ -658,30 +658,30 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (dst == NULL) { // move the train to an empty line. for locomotives, we set the type to 0. for wagons, 4. if (is_loco) { - if (src->subtype != 0) { + if (src->subtype != TS_Front_Engine) { // setting the type to 0 also involves setting up the orders field. - src->subtype = 0; + src->subtype = TS_Front_Engine; assert(src->orders == NULL); src->num_orders = 0; } dst_head = src; } else { - src->subtype = 4; + src->subtype = TS_Free_Car; } src->u.rail.first_engine = 0xffff; } else { - if (src->subtype == 0) { + if (src->subtype == TS_Front_Engine) { // the vehicle was previously a loco. need to free the order list and delete vehicle windows etc. DeleteWindowById(WC_VEHICLE_VIEW, src->index); DeleteVehicleOrders(src); } - src->subtype = 2; + src->subtype = TS_Not_First; src->unitnumber = 0; // doesn't occupy a unitnumber anymore. // setup first_engine src->u.rail.first_engine = dst->u.rail.first_engine; - if (src->u.rail.first_engine == 0xffff && dst->subtype == 0) + if (src->u.rail.first_engine == 0xffff && dst->subtype == TS_Front_Engine) src->u.rail.first_engine = dst->engine_type; // link in the wagon(s) in the chain. @@ -696,12 +696,12 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) dst->next = src; } - if (src_head->subtype == 0) + if (src_head->subtype == TS_Front_Engine) UpdateTrainAcceleration(src_head); InvalidateWindow(WC_VEHICLE_DETAILS, src_head->index); if (dst_head) { - if (dst_head->subtype == 0) + if (dst_head->subtype == TS_Front_Engine) UpdateTrainAcceleration(dst_head); InvalidateWindow(WC_VEHICLE_DETAILS, dst_head->index); } @@ -751,7 +751,7 @@ int32 CmdSellRailWagon(int x, int y, uint32 flags, uint32 p1, uint32 p2) // get first vehicle in chain first = v; - if (first->subtype != 0) { + if (first->subtype != TS_Front_Engine) { first = GetFirstVehicleInChain(first); last = GetLastVehicleInChain(first); //now if: @@ -761,7 +761,7 @@ int32 CmdSellRailWagon(int x, int y, uint32 flags, uint32 p1, uint32 p2) // 4) the first and the last vehicle of the chain are not identical // 5) and of "engine" type (i.e. not a carriage) // then let the last vehicle live - if ( (p2 == 1) && (v != last) && ( last->engine_type == first->engine_type ) && (last != first) && (first->subtype == 0) ) + if ( (p2 == 1) && (v != last) && ( last->engine_type == first->engine_type ) && (last != first) && (first->subtype == TS_Front_Engine) ) last = GetPrevVehicleInChain(last); else last = NULL; @@ -785,11 +785,11 @@ int32 CmdSellRailWagon(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (flags & DC_EXEC) { // always redraw the depot. maybe redraw train list InvalidateWindow(WC_VEHICLE_DEPOT, first->tile); - if (first->subtype == 0) { + if (first->subtype == TS_Front_Engine) { RebuildVehicleLists(); } // when selling an attached locomotive. we need to delete its window. - if (v->subtype == 0) { + if (v->subtype == TS_Front_Engine) { DeleteWindowById(WC_VEHICLE_VIEW, v->index); // rearrange all vehicles that follow to separate lines. @@ -829,7 +829,7 @@ int32 CmdSellRailWagon(int x, int y, uint32 flags, uint32 p1, uint32 p2) } // an attached train changed? - if (first && first->subtype == 0) { + if (first && first->subtype == TS_Front_Engine) { UpdateTrainAcceleration(first); InvalidateWindow(WC_VEHICLE_DETAILS, first->index); } @@ -1920,7 +1920,7 @@ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile) // tracks over roads, do owner check of tracks (_map_owner[tile]) return _map_owner[tile] == v->owner && - (v->subtype != 0 || (_map3_hi[tile] & 0xF) == v->u.rail.railtype); + (v->subtype != TS_Front_Engine || (_map3_hi[tile] & 0xF) == v->u.rail.railtype); default: return true; @@ -1928,7 +1928,7 @@ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile) return _map_owner[tile] == v->owner && - (v->subtype != 0 || (_map3_lo[tile] & 0xF) == v->u.rail.railtype); + (v->subtype != TS_Front_Engine || (_map3_lo[tile] & 0xF) == v->u.rail.railtype); } typedef struct { @@ -2028,14 +2028,14 @@ static int CountPassengersInTrain(Vehicle *v) { int num = 0; BEGIN_ENUM_WAGONS(v) - if (v->cargo_type == 0) num += v->cargo_count; + if (v->cargo_type == CT_PASSENGERS) num += v->cargo_count; END_ENUM_WAGONS(v) return num; } /* * Checks whether the specified tried has a collision with another vehicle. If - * so, destroys this vehicle, and the other vehicle if its subtype is 0 (?). + * so, destroys this vehicle, and the other vehicle if its subtype is 0 (TS_Front_Engine). * Reports the incident in a flashy news item, modifies station ratings and * plays a sound. */ @@ -2074,7 +2074,7 @@ static void CheckTrainCollision(Vehicle *v) num += 2 + CountPassengersInTrain(coll); SetVehicleCrashed(v); - if (coll->subtype == 0) + if (coll->subtype == TS_Front_Engine) SetVehicleCrashed(coll); @@ -2093,7 +2093,7 @@ static void *CheckVehicleAtSignal(Vehicle *v, void *data) { uint32 d = (uint32)data; - if (v->type == VEH_Train && v->subtype == 0 && v->tile == (TileIndex)(d >> 8)) { + if (v->type == VEH_Train && v->subtype == TS_Front_Engine && v->tile == (TileIndex)(d >> 8)) { byte diff = (v->direction - (byte)d + 2) & 7; if (diff == 2 || (v->cur_speed <= 5 && diff <= 4)) return (void*)1; @@ -2196,14 +2196,14 @@ static void TrainController(Vehicle *v) if (r&0x8) goto invalid_rail; - if (v->subtype == 0) v->load_unload_time_rem = 0; + if (v->subtype == TS_Front_Engine) v->load_unload_time_rem = 0; if (!(r&0x4)) { v->tile = gp.new_tile; v->u.rail.track = chosen_track; } - if (v->subtype == 0) + if (v->subtype == TS_Front_Engine) TrainMovedChangeSignals(gp.new_tile, dir>>1); /* Signals can only change when the first @@ -2606,11 +2606,11 @@ void Train_Tick(Vehicle *v) v->tick_counter++; - if (v->subtype == 0) { + if (v->subtype == TS_Front_Engine) { TrainLocoHandler(v, false); // make sure vehicle wasn't deleted. - if (v->type == VEH_Train && v->subtype == 0) + if (v->type == VEH_Train && v->subtype == TS_Front_Engine) TrainLocoHandler(v, true); } } @@ -2629,7 +2629,7 @@ void TrainEnterDepot(Vehicle *v, uint tile) { SetSignalsOnBothDir(tile, _depot_track_ind[_map5[tile]&3]); - if (v->subtype != 0) + if (v->subtype != TS_Front_Engine) v = GetFirstVehicleInChain(v); VehicleServiceInDepot(v); @@ -2741,7 +2741,7 @@ void OnNewDay_Train(Vehicle *v) if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v); - if (v->subtype == 0) { + if (v->subtype == TS_Front_Engine) { CheckVehicleBreakdown(v); AgeVehicle(v); @@ -2785,7 +2785,7 @@ void TrainsYearlyLoop() Vehicle *v; FOR_ALL_VEHICLES(v) { - if (v->type == VEH_Train && v->subtype == 0) { + if (v->type == VEH_Train && v->subtype == TS_Front_Engine) { // show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) if (_patches.train_income_warn && v->owner == _local_player && v->age >= 730 && v->profit_this_year < 0) { @@ -2809,7 +2809,7 @@ extern void ShowTrainViewWindow(Vehicle *v); void HandleClickOnTrain(Vehicle *v) { - if (v->subtype != 0) v = GetFirstVehicleInChain(v); + if (v->subtype != TS_Front_Engine) v = GetFirstVehicleInChain(v); ShowTrainViewWindow(v); } diff --git a/train_gui.c b/train_gui.c index 7447fb5585..0acb273a63 100644 --- a/train_gui.c +++ b/train_gui.c @@ -65,7 +65,7 @@ void CcBuildWagon(bool success, uint tile, uint32 p1, uint32 p2) // find a locomotive in the depot. found = NULL; FOR_ALL_VEHICLES(v) { - if (v->type == VEH_Train && v->subtype==0 && + if (v->type == VEH_Train && v->subtype == TS_Front_Engine && v->tile == tile && v->u.rail.track == 0x80) { if (found != NULL) // must be exactly one. @@ -314,12 +314,12 @@ static void DrawTrainDepotWindow(Window *w) hnum = 1; FOR_ALL_VEHICLES(v) { if (v->type == VEH_Train && - (v->subtype == 0 || v->subtype == 4) && + (v->subtype == TS_Front_Engine || v->subtype == TS_Free_Car) && v->tile == (TileIndex)tile && v->u.rail.track == 0x80) { num++; // determine number of items in the X direction. - if (v->subtype == 0) { + if (v->subtype == TS_Front_Engine) { i = 0; u = v; do i++; while ( (u=u->next) != NULL); @@ -349,7 +349,7 @@ static void DrawTrainDepotWindow(Window *w) // draw all trains FOR_ALL_VEHICLES(v) { if (v->type == VEH_Train && - v->subtype == 0 && + v->subtype == TS_Front_Engine && v->tile == (TileIndex)tile && v->u.rail.track == 0x80 && --num < 0 && num >= -w->vscroll.cap) { @@ -377,7 +377,7 @@ static void DrawTrainDepotWindow(Window *w) // draw all remaining vehicles FOR_ALL_VEHICLES(v) { if (v->type == VEH_Train && - v->subtype == 4 && + v->subtype == TS_Free_Car && v->tile == (TileIndex)tile && v->u.rail.track == 0x80 && --num < 0 && num >= -w->vscroll.cap) { @@ -424,7 +424,7 @@ static int GetVehicleFromTrainDepotWndPt(Window *w, int x, int y, GetDepotVehicl /* go through all the locomotives */ FOR_ALL_VEHICLES(v) { if (v->type == VEH_Train && - v->subtype == 0 && + v->subtype == TS_Front_Engine && v->tile == w->window_number && v->u.rail.track == 0x80 && --row < 0) { @@ -438,7 +438,7 @@ static int GetVehicleFromTrainDepotWndPt(Window *w, int x, int y, GetDepotVehicl /* and then the list of free wagons */ FOR_ALL_VEHICLES(v) { if (v->type == VEH_Train && - v->subtype == 4 && + v->subtype == TS_Free_Car && v->tile == w->window_number && v->u.rail.track == 0x80 && --row < 0) @@ -455,7 +455,7 @@ found_it: d->head = d->wagon = v; /* either pressed the flag or the number, but only when it's a loco */ - if (area_x < 0 && v->subtype==0) + if (area_x < 0 && v->subtype == TS_Front_Engine) return area_x; /* find the vehicle in this row that was clicked */ @@ -475,7 +475,7 @@ static void TrainDepotMoveVehicle(Vehicle *wagon, int sel, Vehicle *head) v = GetVehicle(sel); - if (/*v->subtype == 0 ||*/ v == wagon) + if (/*v->subtype == TS_Front_Engine ||*/ v == wagon) return; if (wagon == NULL) { @@ -576,7 +576,7 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e) sell_cmd = (e->click.widget == 5 || _ctrl_pressed) ? 1 : 0; - if (v->subtype != 0) { + if (v->subtype != TS_Front_Engine) { DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE)); } else { _backup_orders_tile = v->tile; @@ -597,7 +597,7 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e) sel != INVALID_VEHICLE) { if (gdvp.wagon == NULL || gdvp.wagon->index != sel) { TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); - } else if (gdvp.head != NULL && gdvp.head->subtype==0) { + } else if (gdvp.head != NULL && gdvp.head->subtype == TS_Front_Engine) { ShowTrainViewWindow(gdvp.head); } } @@ -1365,7 +1365,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e) v = GetVehicle(vl->sort_list[id_v].index); - assert(v->type == VEH_Train && v->subtype == 0 && v->owner == owner); + assert(v->type == VEH_Train && v->subtype == TS_Front_Engine && v->owner == owner); ShowTrainViewWindow(v); } diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index 72df2304ff..307ab5aeec 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -1413,7 +1413,7 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, uint tile, int x, int y) vdir = v->direction >> 1; if (v->u.rail.track != 0x40 && dir == vdir) { - if (v->subtype == 0 && fc == _tunnel_fractcoord_1[dir]) { + if (v->subtype == TS_Front_Engine && fc == _tunnel_fractcoord_1[dir]) { if (v->spritenum < 4) SndPlayVehicleFx(SND_05_TRAIN_THROUGH_TUNNEL, v); return 0; @@ -1465,7 +1465,7 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, uint tile, int x, int y) } } } else if (_map5[tile] & 0x80) { - if (v->type == VEH_Road || (v->type == VEH_Train && v->subtype == 0)) { + if (v->type == VEH_Road || (v->type == VEH_Train && v->subtype == TS_Front_Engine)) { if (GetTileSlope(tile, &h) != 0) h += 8; // Compensate for possible foundation if (!(_map5[tile] & 0x40) || // start/end tile of bridge diff --git a/vehicle.c b/vehicle.c index 688e78aa95..ef086d7b07 100644 --- a/vehicle.c +++ b/vehicle.c @@ -159,7 +159,7 @@ void AfterLoadVehicles() VehiclePositionChanged(v); if (v->type == VEH_Train) { - if (v->subtype == 0) + if (v->subtype == TS_Front_Engine) UpdateTrainAcceleration(v); } } @@ -2012,7 +2012,7 @@ static void Load_VEHS() FOR_ALL_VEHICLES(v) { Vehicle *w; - if (v->type != VEH_Train || v->subtype != 0) + if (v->type != VEH_Train || v->subtype != TS_Front_Engine) continue; for (w = v->next; w; w = w->next) diff --git a/vehicle.h b/vehicle.h index a5803750c1..de60d063da 100644 --- a/vehicle.h +++ b/vehicle.h @@ -229,7 +229,12 @@ enum VehStatus { VS_CRASHED = 0x80, }; - +// 1 and 3 do not appear to be used +enum TrainSubtype { + TS_Front_Engine = 0, + TS_Not_First = 2, + TS_Free_Car = 4, +}; /* Effect vehicle types */ enum { diff --git a/vehicle_gui.c b/vehicle_gui.c index 601e7730c9..efaee53069 100644 --- a/vehicle_gui.c +++ b/vehicle_gui.c @@ -72,7 +72,7 @@ void ResortVehicleLists(void) void BuildVehicleList(vehiclelist_d *vl, int type, int owner, int station) { - int subtype = (type != VEH_Aircraft) ? 0 : 2; + int subtype = (type != VEH_Aircraft) ? TS_Front_Engine : 2; int n = 0; int i;