1
0
Fork 0

(svn r2037) uint -> TileIndex, remove pointless casts, const, misc.

release/0.4.5
tron 2005-03-23 11:54:20 +00:00
parent 04087c9ac9
commit 22c4924040
1 changed files with 9 additions and 15 deletions

View File

@ -161,14 +161,14 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 value; int32 value;
Vehicle *vl[3], *v, *u, *w; Vehicle *vl[3], *v, *u, *w;
UnitID unit_num; UnitID unit_num;
uint tile = TILE_FROM_XY(x,y); TileIndex tile = TILE_FROM_XY(x,y);
const AircraftVehicleInfo *avi = AircraftVehInfo(p1); const AircraftVehicleInfo *avi = AircraftVehInfo(p1);
Engine *e; Engine *e;
if (!IsEngineBuildable(p1, VEH_Aircraft)) return CMD_ERROR; if (!IsEngineBuildable(p1, VEH_Aircraft)) return CMD_ERROR;
// Workaround: TODO: make AI players try to build planes in a hangar instead of just an airport tile. // Workaround: TODO: make AI players try to build planes in a hangar instead of just an airport tile.
if (!IsAircraftHangarTile((TileIndex)tile) && IS_HUMAN_PLAYER(_current_player)) return CMD_ERROR; if (!IsAircraftHangarTile(tile) && IS_HUMAN_PLAYER(_current_player)) return CMD_ERROR;
if (_map_owner[tile] != _current_player && IS_HUMAN_PLAYER(_current_player)) return CMD_ERROR; if (_map_owner[tile] != _current_player && IS_HUMAN_PLAYER(_current_player)) return CMD_ERROR;
@ -265,19 +265,16 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
->layout for #th position of depot. Since layout must start with depots, it is simple ->layout for #th position of depot. Since layout must start with depots, it is simple
*/ */
{ {
Station *st; const Station* st = GetStation(_map2[tile]);
const AirportFTAClass *Airport; const AirportFTAClass* Airport = GetAirport(st->airport_type);
const TileIndexDiffC *cur_depot; uint i;
byte i = 0;
st = GetStation(_map2[tile]); for (i = 0; i < Airport->nof_depots; i++) {
Airport = GetAirport(st->airport_type); if (st->airport_tile + ToTileIndexDiff(Airport->airport_depots[i]) == tile) {
for (cur_depot = Airport->airport_depots; i != Airport->nof_depots; cur_depot++) {
if ((uint)(st->airport_tile + ToTileIndexDiff(*cur_depot)) == tile) {
assert(Airport->layout[i].heading == HANGAR); assert(Airport->layout[i].heading == HANGAR);
v->u.air.pos = Airport->layout[i].position; v->u.air.pos = Airport->layout[i].position;
break; break;
} }
i++;
} }
// to ensure v->u.air.pos has been given a value // to ensure v->u.air.pos has been given a value
assert(v->u.air.pos != MAX_ELEMENTS); assert(v->u.air.pos != MAX_ELEMENTS);
@ -340,8 +337,7 @@ bool IsAircraftHangarTile(TileIndex tile)
static bool CheckStoppedInHangar(Vehicle *v) static bool CheckStoppedInHangar(Vehicle *v)
{ {
if (!(v->vehstatus&VS_STOPPED) || if (!(v->vehstatus & VS_STOPPED) || !IsAircraftHangarTile(v->tile)) {
!IsAircraftHangarTile(v->tile)) {
_error_message = STR_A01B_AIRCRAFT_MUST_BE_STOPPED; _error_message = STR_A01B_AIRCRAFT_MUST_BE_STOPPED;
return false; return false;
} }
@ -376,9 +372,7 @@ int32 CmdSellAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
// Invalidate depot // Invalidate depot
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
DoDeleteAircraft(v); DoDeleteAircraft(v);
} }
InvalidateWindow(WC_REPLACE_VEHICLE, VEH_Aircraft); // updates the replace Aircraft window InvalidateWindow(WC_REPLACE_VEHICLE, VEH_Aircraft); // updates the replace Aircraft window