1
0
Fork 0

(svn r15269) -Codechange: reduced indentation in CmdBuildRail*

release/0.7
glx 2009-01-25 15:35:21 +00:00
parent ca10c5c6e3
commit fc965a75dc
1 changed files with 181 additions and 182 deletions

View File

@ -607,18 +607,20 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 fla
const RailVehicleInfo *rvi = RailVehInfo(engine);
CommandCost value(EXPENSES_NEW_VEHICLES, GetEngine(engine)->GetCost());
uint num_vehicles = 1 + CountArticulatedParts(engine, false);
if (flags & DC_QUERY_COST) return value;
if (!(flags & DC_QUERY_COST)) {
/* Check that the wagon can drive on the track in question */
if (!IsCompatibleRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
uint num_vehicles = 1 + CountArticulatedParts(engine, false);
/* Allow for the wagon and the articulated parts, plus one to "terminate" the list. */
Vehicle **vl = AllocaM(Vehicle*, num_vehicles + 1);
memset(vl, 0, sizeof(*vl) * (num_vehicles + 1));
if (!Vehicle::AllocateList(vl, num_vehicles))
if (!Vehicle::AllocateList(vl, num_vehicles)) {
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
}
if (flags & DC_EXEC) {
Vehicle *v = vl[0];
@ -692,7 +694,6 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 fla
}
GetCompany(_current_company)->num_engines[engine]++;
}
}
return value;
}
@ -752,25 +753,23 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
/* Check if the engine-type is valid (for the company) */
if (!IsEngineBuildable(p1, VEH_TRAIN, _current_company)) return_cmd_error(STR_RAIL_VEHICLE_NOT_AVAILABLE);
/* Check if the train is actually being built in a depot belonging
* to the company. Doesn't matter if only the cost is queried */
if (!(flags & DC_QUERY_COST)) {
if (!IsRailDepotTile(tile)) return CMD_ERROR;
if (!IsTileOwner(tile, _current_company)) return CMD_ERROR;
}
const RailVehicleInfo *rvi = RailVehInfo(p1);
if (rvi->railveh_type == RAILVEH_WAGON) return CmdBuildRailWagon(p1, tile, flags);
const Engine *e = GetEngine(p1);
CommandCost value(EXPENSES_NEW_VEHICLES, e->GetCost());
if (flags & DC_QUERY_COST) return value;
/* Check if the train is actually being built in a depot belonging
* to the company. Doesn't matter if only the cost is queried */
if (!IsRailDepotTile(tile)) return CMD_ERROR;
if (!IsTileOwner(tile, _current_company)) return CMD_ERROR;
const RailVehicleInfo *rvi = RailVehInfo(p1);
if (rvi->railveh_type == RAILVEH_WAGON) return CmdBuildRailWagon(p1, tile, flags);
uint num_vehicles =
(rvi->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1) +
CountArticulatedParts(p1, false);
if (!(flags & DC_QUERY_COST)) {
/* Check if depot and new engine uses the same kind of tracks *
* We need to see if the engine got power on the tile to avoid eletric engines in non-electric depots */
if (!HasPowerOnRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
@ -786,8 +785,9 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
Vehicle *v = vl[0];
UnitID unit_num = (flags & DC_AUTOREPLACE) ? 0 : GetFreeUnitNumber(VEH_TRAIN);
if (unit_num > _settings_game.vehicle.max_trains)
if (unit_num > _settings_game.vehicle.max_trains) {
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
}
if (flags & DC_EXEC) {
DiagDirection dir = GetRailDepotDirection(tile);
@ -870,7 +870,6 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
GetCompany(_current_company)->num_engines[p1]++;
}
}
return value;
}