equal
deleted
inserted
replaced
209 |
209 |
210 /* update the 'first engine' */ |
210 /* update the 'first engine' */ |
211 u->u.rail.first_engine = v == u ? INVALID_ENGINE : first_engine; |
211 u->u.rail.first_engine = v == u ? INVALID_ENGINE : first_engine; |
212 u->u.rail.railtype = rvi_u->railtype; |
212 u->u.rail.railtype = rvi_u->railtype; |
213 |
213 |
|
214 if (IsTrainEngine(u)) first_engine = u->engine_type; |
|
215 |
214 /* Set user defined data to its default value */ |
216 /* Set user defined data to its default value */ |
215 u->u.rail.user_def_data = rvi_u->user_def_data; |
217 u->u.rail.user_def_data = rvi_u->user_def_data; |
216 } |
218 } |
217 |
219 |
218 for (Vehicle *u = v; u != NULL; u = u->Next()) { |
220 for (Vehicle *u = v; u != NULL; u = u->Next()) { |
222 |
224 |
223 for (Vehicle *u = v; u != NULL; u = u->Next()) { |
225 for (Vehicle *u = v; u != NULL; u = u->Next()) { |
224 const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type); |
226 const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type); |
225 |
227 |
226 if (!HasBit(EngInfo(u->engine_type)->misc_flags, EF_RAIL_TILTS)) train_can_tilt = false; |
228 if (!HasBit(EngInfo(u->engine_type)->misc_flags, EF_RAIL_TILTS)) train_can_tilt = false; |
227 |
|
228 if (IsTrainEngine(u)) first_engine = u->engine_type; |
|
229 |
229 |
230 /* Cache wagon override sprite group. NULL is returned if there is none */ |
230 /* Cache wagon override sprite group. NULL is returned if there is none */ |
231 u->u.rail.cached_override = GetWagonOverrideSpriteSet(u->engine_type, u->cargo_type, u->u.rail.first_engine); |
231 u->u.rail.cached_override = GetWagonOverrideSpriteSet(u->engine_type, u->cargo_type, u->u.rail.first_engine); |
232 |
232 |
233 /* Reset color map */ |
233 /* Reset color map */ |
547 if (!(flags & DC_QUERY_COST)) { |
547 if (!(flags & DC_QUERY_COST)) { |
548 /* Check that the wagon can drive on the track in question */ |
548 /* Check that the wagon can drive on the track in question */ |
549 if (!IsCompatibleRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR; |
549 if (!IsCompatibleRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR; |
550 |
550 |
551 /* Allow for the wagon and the articulated parts, plus one to "terminate" the list. */ |
551 /* Allow for the wagon and the articulated parts, plus one to "terminate" the list. */ |
552 Vehicle **vl = (Vehicle**)alloca(sizeof(*vl) * (num_vehicles + 1)); |
552 Vehicle **vl = AllocaM(Vehicle*, num_vehicles + 1); |
553 memset(vl, 0, sizeof(*vl) * (num_vehicles + 1)); |
553 memset(vl, 0, sizeof(*vl) * (num_vehicles + 1)); |
554 |
554 |
555 if (!Vehicle::AllocateList(vl, num_vehicles)) |
555 if (!Vehicle::AllocateList(vl, num_vehicles)) |
556 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
556 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
557 |
557 |
714 /* Check if depot and new engine uses the same kind of tracks * |
714 /* Check if depot and new engine uses the same kind of tracks * |
715 * We need to see if the engine got power on the tile to avoid eletric engines in non-electric depots */ |
715 * We need to see if the engine got power on the tile to avoid eletric engines in non-electric depots */ |
716 if (!HasPowerOnRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR; |
716 if (!HasPowerOnRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR; |
717 |
717 |
718 /* Allow for the dual-heads and the articulated parts, plus one to "terminate" the list. */ |
718 /* Allow for the dual-heads and the articulated parts, plus one to "terminate" the list. */ |
719 Vehicle **vl = (Vehicle**)alloca(sizeof(*vl) * (num_vehicles + 1)); |
719 Vehicle **vl = AllocaM(Vehicle*, num_vehicles + 1); |
720 memset(vl, 0, sizeof(*vl) * (num_vehicles + 1)); |
720 memset(vl, 0, sizeof(*vl) * (num_vehicles + 1)); |
721 |
721 |
722 if (!Vehicle::AllocateList(vl, num_vehicles)) { |
722 if (!Vehicle::AllocateList(vl, num_vehicles)) { |
723 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
723 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
724 } |
724 } |