diff --git a/ai.c b/ai.c --- a/ai.c +++ b/ai.c @@ -281,7 +281,6 @@ static void AiHandleReplaceTrain(Player Vehicle *v = p->ai.cur_veh; BackuppedOrders orderbak[1]; int veh; - uint tile; // wait until the vehicle reaches the depot. if (!IsTileDepotType(v->tile, TRANSPORT_RAIL) || v->u.rail.track != 0x80 || !(v->vehstatus&VS_STOPPED)) { @@ -291,6 +290,8 @@ static void AiHandleReplaceTrain(Player veh = AiChooseTrainToReplaceWith(p, v); if (veh != -1) { + TileIndex tile; + BackupVehicleOrders(v, orderbak); tile = v->tile; @@ -310,7 +311,6 @@ static void AiHandleReplaceRoadVeh(Playe Vehicle *v = p->ai.cur_veh; BackuppedOrders orderbak[1]; int veh; - uint tile; if (!IsTileDepotType(v->tile, TRANSPORT_ROAD) || v->u.road.state != 254 || !(v->vehstatus&VS_STOPPED)) { AiHandleGotoDepot(p, CMD_SEND_ROADVEH_TO_DEPOT); @@ -319,6 +319,8 @@ static void AiHandleReplaceRoadVeh(Playe veh = AiChooseRoadVehToReplaceWith(p, v); if (veh != -1) { + TileIndex tile; + BackupVehicleOrders(v, orderbak); tile = v->tile; @@ -338,7 +340,6 @@ static void AiHandleReplaceAircraft(Play Vehicle *v = p->ai.cur_veh; int veh; BackuppedOrders orderbak[1]; - uint tile; if (!IsAircraftHangarTile(v->tile) && !(v->vehstatus&VS_STOPPED)) { AiHandleGotoDepot(p, CMD_SEND_AIRCRAFT_TO_HANGAR); @@ -347,6 +348,8 @@ static void AiHandleReplaceAircraft(Play veh = AiChooseAircraftToReplaceWith(p, v); if (veh != -1) { + TileIndex tile; + BackupVehicleOrders(v, orderbak); tile = v->tile; @@ -1532,11 +1535,10 @@ static bool AiCheckTrackResources(TileIn { uint values[NUM_CARGO]; int w,h; - uint tile2; int rad; for(;p->mode != 4;p++) if (p->mode == 1) { - tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)); + TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)); w = ((p->attr>>1) & 7); h = ((p->attr>>4) & 7); @@ -1833,7 +1835,7 @@ typedef struct AiRailPathFindData { bool flag; } AiRailPathFindData; -static bool AiEnumFollowTrack(uint tile, AiRailPathFindData *a, int track, uint length, byte *state) +static bool AiEnumFollowTrack(TileIndex tile, AiRailPathFindData *a, int track, uint length, byte *state) { if (a->flag) return true; @@ -2175,7 +2177,7 @@ static bool AiRemoveTileAndGoForward(Pla byte b; int bit; const byte *ptr; - uint tile = p->ai.cur_tile_a; + TileIndex tile = p->ai.cur_tile_a; int offs; TileIndex tilenew; @@ -2494,7 +2496,8 @@ static bool AiCheckRoadResources(TileInd if (p->mode == 4) { return true; } else if (p->mode == 1) { - uint tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)); + TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)); + if (cargo & 0x80) { GetProductionAroundTiles(values, tile2, 1, 1, rad); return values[cargo & 0x7F] != 0; @@ -2765,13 +2768,13 @@ static bool AiCheckRoadPathBetter(AiRoad } -static bool AiEnumFollowRoad(uint tile, AiRoadEnum *a, int track, uint length, byte *state) +static bool AiEnumFollowRoad(TileIndex tile, AiRoadEnum *a, int track, uint length, byte *state) { uint dist = DistanceManhattan(tile, a->dest); - uint tile2; if (dist <= a->best_dist) { - tile2 = TILE_MASK(tile + TileOffsByDir(_dir_by_track[track])); + TileIndex tile2 = TILE_MASK(tile + TileOffsByDir(_dir_by_track[track])); + if (IsTileType(tile2, MP_STREET) && (_map5[tile2]&0xF0) == 0) { a->best_dist = dist; @@ -2793,7 +2796,7 @@ static const uint16 _ai_road_table_and[4 static bool AiCheckRoadFinished(Player *p) { AiRoadEnum are; - uint tile; + TileIndex tile; int dir = p->ai.cur_dir_a; uint32 bits; int i; @@ -2824,7 +2827,7 @@ static bool AiCheckRoadFinished(Player * } -static bool AiBuildRoadHelper(uint tile, int flags, int type) +static bool AiBuildRoadHelper(TileIndex tile, int flags, int type) { static const byte _road_bits[] = { 8+2, @@ -2962,7 +2965,7 @@ static void AiBuildRoadConstruct(Player { AiRoadFinder arf; int i; - uint tile; + TileIndex tile; // Reached destination? if (AiCheckRoadFinished(p)) { @@ -3164,7 +3167,8 @@ static int AiGetStationIdFromRoadBlock(T static void AiStateBuildRoadVehicles(Player *p) { const AiDefaultBlockData *ptr; - uint tile,loco_id; + TileIndex tile; + uint loco_id; int veh, i; ptr = _road_default_block_data[p->ai.src.cur_building_rule]->data; @@ -3236,7 +3240,8 @@ static void AiStateDeleteRoadBlocks(Play static bool AiCheckIfHangar(Station *st) { - uint tile = st->airport_tile; + TileIndex tile = st->airport_tile; + // HANGAR of airports // 0x20 - hangar large airport (32) // 0x41 - hangar small airport (65) @@ -3348,7 +3353,6 @@ static bool AiCheckAirportResources(Tile { uint values[NUM_CARGO]; int w,h; - uint tile2; int rad; if (_patches.modified_catchment) { @@ -3358,7 +3362,8 @@ static bool AiCheckAirportResources(Tile } for(;p->mode==0;p++) { - tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)); + TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)); + w = _airport_size_x[p->attr]; h = _airport_size_y[p->attr]; if (cargo & 0x80) { @@ -3481,7 +3486,7 @@ static int AiGetStationIdFromAircraftBlo static void AiStateBuildAircraftVehicles(Player *p) { const AiDefaultBlockData *ptr; - uint tile; + TileIndex tile; int veh; int i; uint loco_id; diff --git a/ai.h b/ai.h --- a/ai.h +++ b/ai.h @@ -240,20 +240,20 @@ AyStar *new_AyStar_AiPathFinder(int max_ void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo); // ai_shared.c -int AiNew_GetRailDirection(uint tile_a, uint tile_b, uint tile_c); -int AiNew_GetRoadDirection(uint tile_a, uint tile_b, uint tile_c); -int AiNew_GetDirection(uint tile_a, uint tile_b); +int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c); +int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c); +int AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b); bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag); uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v); // ai_build.c -bool AiNew_Build_CompanyHQ(Player *p, uint tile); -int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag); -int AiNew_Build_Bridge(Player *p, uint tile_a, uint tile_b, byte flag); +bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile); +int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag); +int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag); int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag); int AiNew_PickVehicle(Player *p); -int AiNew_Build_Vehicle(Player *p, uint tile, byte flag); -int AiNew_Build_Depot(Player *p, uint tile, byte direction, byte flag); +int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag); +int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag); #endif diff --git a/ai_build.c b/ai_build.c --- a/ai_build.c +++ b/ai_build.c @@ -11,7 +11,8 @@ // Build HQ // Params: // tile : tile where HQ is going to be build -bool AiNew_Build_CompanyHQ(Player *p, uint tile) { +bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile) +{ if (CmdFailed(DoCommandByTile(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ))) return false; DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ); @@ -26,7 +27,8 @@ bool AiNew_Build_CompanyHQ(Player *p, ui // numtracks : in case of AI_TRAIN: tracks of station // direction : the direction of the station // flag : flag passed to DoCommand (normally 0 to get the cost or DC_EXEC to build it) -int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag) { +int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag) +{ if (type == AI_TRAIN) return DoCommandByTile(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION); @@ -41,7 +43,8 @@ int AiNew_Build_Station(Player *p, byte // tile_a : starting point // tile_b : end point // flag : flag passed to DoCommand -int AiNew_Build_Bridge(Player *p, uint tile_a, uint tile_b, byte flag) { +int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag) +{ int bridge_type, bridge_len, type, type2; // Find a good bridgetype (the best money can buy) @@ -233,7 +236,8 @@ int AiNew_PickVehicle(Player *p) { } // Builds the best vehicle possible -int AiNew_Build_Vehicle(Player *p, uint tile, byte flag) { +int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag) +{ int i = AiNew_PickVehicle(p); if (i == -1) return CMD_ERROR; @@ -243,7 +247,7 @@ int AiNew_Build_Vehicle(Player *p, uint return DoCommandByTile(tile, i, 0, flag, CMD_BUILD_ROAD_VEH); } -int AiNew_Build_Depot(Player *p, uint tile, byte direction, byte flag) +int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag) { static const byte _roadbits_by_dir[4] = {2,1,8,4}; int ret, ret2; diff --git a/ai_pathfinder.c b/ai_pathfinder.c --- a/ai_pathfinder.c +++ b/ai_pathfinder.c @@ -11,7 +11,7 @@ // Tests if a station can be build on the given spot // TODO: make it train compatible -static bool TestCanBuildStationHere(uint tile, byte dir) +static bool TestCanBuildStationHere(TileIndex tile, byte dir) { Player *p = GetPlayer(_current_player); diff --git a/ai_shared.c b/ai_shared.c --- a/ai_shared.c +++ b/ai_shared.c @@ -5,7 +5,8 @@ #include "ai.h" #include "vehicle.h" -int AiNew_GetRailDirection(uint tile_a, uint tile_b, uint tile_c) { +int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c) +{ // 0 = vert // 1 = horz // 2 = dig up-left @@ -46,7 +47,8 @@ int AiNew_GetRailDirection(uint tile_a, return 0; } -int AiNew_GetRoadDirection(uint tile_a, uint tile_b, uint tile_c) { +int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c) +{ int x1, x2, x3; int y1, y2, y3; int r; @@ -75,7 +77,8 @@ int AiNew_GetRoadDirection(uint tile_a, } // Get's the direction between 2 tiles seen from tile_a -int AiNew_GetDirection(uint tile_a, uint tile_b) { +int AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b) +{ if (TileY(tile_a) < TileY(tile_b)) return 1; if (TileY(tile_a) > TileY(tile_b)) return 3; if (TileX(tile_a) < TileX(tile_b)) return 2; diff --git a/aircraft_cmd.c b/aircraft_cmd.c --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -844,7 +844,8 @@ static bool AircraftController(Vehicle * // prevent going to 0,0 if airport is deleted. { - uint tile = st->airport_tile; + TileIndex tile = st->airport_tile; + if (tile == 0) tile = st->xy; // xy of destination x = TileX(tile) * 16; diff --git a/aircraft_gui.c b/aircraft_gui.c --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -71,7 +71,7 @@ static void DrawAircraftImage(const Vehi } } -void CcBuildAircraft(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2) { Vehicle *v; @@ -206,7 +206,7 @@ static const WindowDesc _new_aircraft_de NewAircraftWndProc }; -static void ShowBuildAircraftWindow(uint tile) +static void ShowBuildAircraftWindow(TileIndex tile) { Window *w; @@ -506,7 +506,8 @@ static void AircraftViewWndProc(Window * StringID str; { - uint tile = v->tile; + TileIndex tile = v->tile; + if (IsTileType(tile, MP_STATION) && (_map5[tile] == 32 || _map5[tile] == 65) && v->vehstatus&VS_STOPPED) @@ -626,7 +627,7 @@ void ShowAircraftViewWindow(Vehicle *v) static void DrawAircraftDepotWindow(Window *w) { - uint tile; + TileIndex tile; Vehicle *v; int num,x,y; @@ -677,7 +678,7 @@ static void DrawAircraftDepotWindow(Wind static int GetVehicleFromAircraftDepotWndPt(Window *w, int x, int y, Vehicle **veh) { uint xt,row,xm,ym; Vehicle *v; - uint tile; + TileIndex tile; int pos; xt = x / 74; @@ -844,7 +845,7 @@ static const WindowDesc _aircraft_depot_ }; -void ShowAircraftDepotWindow(uint tile) +void ShowAircraftDepotWindow(TileIndex tile) { Window *w; @@ -1028,7 +1029,7 @@ static void PlayerAircraftWndProc(Window } break; case 9: { /* Build new Vehicle */ - uint tile; + TileIndex tile; if (!IsWindowOfPrototype(w, _player_aircraft_widgets)) break; diff --git a/airport_gui.c b/airport_gui.c --- a/airport_gui.c +++ b/airport_gui.c @@ -19,7 +19,7 @@ static byte _selected_airport_type; static void ShowBuildAirportPicker(void); -void CcBuildAirport(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_1F_SPLAT, tile); @@ -27,12 +27,12 @@ void CcBuildAirport(bool success, uint t } } -static void PlaceAirport(uint tile) +static void PlaceAirport(TileIndex tile) { DoCommandP(tile, _selected_airport_type, 0, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE)); } -static void PlaceAir_DemolishArea(uint tile) +static void PlaceAir_DemolishArea(TileIndex tile) { VpStartPlaceSizing(tile, 4); } diff --git a/aystar.h b/aystar.h --- a/aystar.h +++ b/aystar.h @@ -27,7 +27,7 @@ enum{ typedef struct AyStarNode AyStarNode; struct AyStarNode { - uint tile; + TileIndex tile; uint direction; uint user_data[2]; }; diff --git a/bridge_gui.c b/bridge_gui.c --- a/bridge_gui.c +++ b/bridge_gui.c @@ -24,7 +24,7 @@ extern const PalSpriteID _bridge_sprites extern const uint16 _bridge_speeds[MAX_BRIDGES]; extern const StringID _bridge_material[MAX_BRIDGES]; -void CcBuildBridge(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, tile); } @@ -110,7 +110,7 @@ static const WindowDesc _build_road_brid }; -void ShowBuildBridgeWindow(uint start, uint end, byte bridge_type) +void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type) { int j = 0; int32 ret; diff --git a/clear_cmd.c b/clear_cmd.c --- a/clear_cmd.c +++ b/clear_cmd.c @@ -82,7 +82,7 @@ static void TerraformAddDirtyTileAround( TerraformAddDirtyTile(ts, tile); } -static int TerraformProc(TerraformerState *ts, uint tile, int mode) +static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode) { int r; int32 ret; @@ -130,7 +130,7 @@ static int TerraformProc(TerraformerStat return 0; } -static bool TerraformTileHeight(TerraformerState *ts, uint tile, int height) +static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height) { int nh; TerraformerHeightMod *mod; @@ -272,7 +272,7 @@ int32 CmdTerraformLand(int x, int y, uin for (count = ts.tile_table_count; count != 0; count--, ti++) { uint z, t; - uint tile = *ti; + TileIndex tile = *ti; z = TerraformGetHeightOfTile(&ts, tile + TILE_XY(0,0)); t = TerraformGetHeightOfTile(&ts, tile + TILE_XY(1,0)); @@ -417,7 +417,7 @@ int32 CmdPurchaseLandArea(int x, int y, } -static int32 ClearTile_Clear(uint tile, byte flags) +static int32 ClearTile_Clear(TileIndex tile, byte flags) { static const int32 * _clear_price_table[] = { NULL, @@ -544,12 +544,12 @@ static uint GetSlopeTileh_Clear(TileInfo return ti->tileh; } -static void GetAcceptedCargo_Clear(uint tile, AcceptedCargo ac) +static void GetAcceptedCargo_Clear(TileIndex tile, AcceptedCargo ac) { /* unused */ } -static void AnimateTile_Clear(uint tile) +static void AnimateTile_Clear(TileIndex tile) { /* unused */ } @@ -642,7 +642,7 @@ void TileLoopClearHelper(TileIndex tile) /* convert into snowy tiles */ -static void TileLoopClearAlps(uint tile) +static void TileLoopClearAlps(TileIndex tile) { int k; byte m5,tmp; @@ -703,7 +703,7 @@ static void TileLoopClearAlps(uint tile) MarkTileDirtyByTile(tile); } -static void TileLoopClearDesert(uint tile) +static void TileLoopClearDesert(TileIndex tile) { if ( (_map5[tile] & 0x1C) == 0x14) return; @@ -722,7 +722,7 @@ static void TileLoopClearDesert(uint til MarkTileDirtyByTile(tile); } -static void TileLoop_Clear(uint tile) +static void TileLoop_Clear(TileIndex tile) { byte m5,m3; @@ -777,7 +777,7 @@ static void TileLoop_Clear(uint tile) void GenerateClearTile(void) { int i,j; - uint tile,tile_new; + TileIndex tile; uint32 r; /* add hills */ @@ -796,6 +796,8 @@ void GenerateClearTile(void) if (IsTileType(tile, MP_CLEAR)) { j = ((r >> 16) & 0xF) + 5; for(;;) { + TileIndex tile_new; + _map5[tile] = (byte)((_map5[tile] & ~(3<<2)) | (2<<2)); do { if (--j == 0) goto get_out; @@ -808,12 +810,12 @@ get_out:; } while (--i); } -static void ClickTile_Clear(uint tile) +static void ClickTile_Clear(TileIndex tile) { /* not used */ } -static uint32 GetTileTrackStatus_Clear(uint tile, TransportType mode) +static uint32 GetTileTrackStatus_Clear(TileIndex tile, TransportType mode) { return 0; } @@ -832,7 +834,7 @@ static const StringID _clear_land_str[4+ STR_080D_GRASS, }; -static void GetTileDesc_Clear(uint tile, TileDesc *td) +static void GetTileDesc_Clear(TileIndex tile, TileDesc *td) { int i = (_map5[tile]>>2) & 7; if (i == 0) @@ -841,7 +843,7 @@ static void GetTileDesc_Clear(uint tile, td->owner = GetTileOwner(tile); } -static void ChangeTileOwner_Clear(uint tile, byte old_player, byte new_player) +static void ChangeTileOwner_Clear(TileIndex tile, byte old_player, byte new_player) { return; } diff --git a/depot.c b/depot.c --- a/depot.c +++ b/depot.c @@ -33,7 +33,7 @@ MemoryPool _depot_pool = { "Depots", DEP * * @return Returns the depot if the tile had a depot, else it returns NULL */ -Depot *GetDepotByTile(uint tile) +Depot *GetDepotByTile(TileIndex tile) { Depot *depot; @@ -73,7 +73,7 @@ Depot *AllocateDepot(void) /** * Delete a depot */ -void DoDeleteDepot(uint tile) +void DoDeleteDepot(TileIndex tile) { Order order; Depot *depot; diff --git a/depot.h b/depot.h --- a/depot.h +++ b/depot.h @@ -112,9 +112,9 @@ static inline DiagDirection GetDepotDire } } -Depot *GetDepotByTile(uint tile); +Depot *GetDepotByTile(TileIndex tile); void InitializeDepot(void); Depot *AllocateDepot(void); -void DoDeleteDepot(uint tile); +void DoDeleteDepot(TileIndex tile); #endif /* DEPOT_H */ diff --git a/disaster_cmd.c b/disaster_cmd.c --- a/disaster_cmd.c +++ b/disaster_cmd.c @@ -147,7 +147,7 @@ static void DisasterTick_Zeppeliner(Vehi Station *st; int x,y; byte z; - uint tile; + TileIndex tile; ++v->tick_counter; @@ -330,7 +330,7 @@ static void DisasterTick_UFO(Vehicle *v) static void DestructIndustry(Industry *i) { - uint tile; + TileIndex tile; for(tile=0; tile != MapSize(); tile++) { if (IsTileType(tile, MP_INDUSTRY) && _map2[tile] == i->index) { @@ -389,7 +389,7 @@ static void DisasterTick_2(Vehicle *v) } } else if (v->current_order.station == 0) { int x,y; - uint tile; + TileIndex tile; int ind; x = v->x_pos - 15*16; @@ -460,7 +460,7 @@ static void DisasterTick_3(Vehicle *v) } } else if (v->current_order.station == 0) { int x,y; - uint tile; + TileIndex tile; int ind; x = v->x_pos - 15*16; @@ -504,7 +504,8 @@ static void DisasterTick_4(Vehicle *v) byte z; Vehicle *u,*w; Town *t; - uint tile,tile_org; + TileIndex tile; + TileIndex tile_org; v->tick_counter++; @@ -638,7 +639,7 @@ static void DisasterTick_5_and_6(Vehicle { uint32 r; GetNewVehiclePosResult gp; - uint tile; + TileIndex tile; v->tick_counter++; @@ -914,8 +915,9 @@ static void Disaster7_Init(void) NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy + TILE_XY(1,1), 0); { - uint tile = i->xy; + TileIndex tile = i->xy; TileIndexDiff step = TileOffsByDir(Random() & 3); + int count = 30; do { DisasterClearSquare(tile); diff --git a/dock_gui.c b/dock_gui.c --- a/dock_gui.c +++ b/dock_gui.c @@ -16,7 +16,7 @@ static void ShowBuildDocksDepotPicker(vo static byte _ship_depot_direction; -void CcBuildDocks(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_02_SPLAT, tile); @@ -24,38 +24,38 @@ void CcBuildDocks(bool success, uint til } } -void CcBuildCanal(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) SndPlayTileFx(SND_02_SPLAT, tile); } -static void PlaceDocks_Dock(uint tile) +static void PlaceDocks_Dock(TileIndex tile) { DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_AUTO | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE)); } -static void PlaceDocks_Depot(uint tile) +static void PlaceDocks_Depot(TileIndex tile) { DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_AUTO | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT)); } -static void PlaceDocks_Buoy(uint tile) +static void PlaceDocks_Buoy(TileIndex tile) { DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_AUTO | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE)); } -static void PlaceDocks_DemolishArea(uint tile) +static void PlaceDocks_DemolishArea(TileIndex tile) { VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea); } -static void PlaceDocks_BuildCanal(uint tile) +static void PlaceDocks_BuildCanal(TileIndex tile) { VpStartPlaceSizing(tile, VPM_X_OR_Y); } -static void PlaceDocks_BuildLock(uint tile) +static void PlaceDocks_BuildLock(TileIndex tile) { DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_LOCKS)); } @@ -164,7 +164,8 @@ static void BuildDocksToolbWndProc(Windo break; case WE_PLACE_PRESIZE: { - uint tile_from, tile_to; + TileIndex tile_from; + TileIndex tile_to; tile_from = tile_to = e->place.tile; switch(GetTileSlope(tile_from, NULL)) { diff --git a/dummy_land.c b/dummy_land.c --- a/dummy_land.c +++ b/dummy_land.c @@ -18,43 +18,44 @@ static uint GetSlopeTileh_Dummy(TileInfo return ti->tileh; } -static int32 ClearTile_Dummy(uint tile, byte flags) { +static int32 ClearTile_Dummy(TileIndex tile, byte flags) +{ return_cmd_error(STR_0001_OFF_EDGE_OF_MAP); } -static void GetAcceptedCargo_Dummy(uint tile, AcceptedCargo ac) +static void GetAcceptedCargo_Dummy(TileIndex tile, AcceptedCargo ac) { /* not used */ } -static void GetTileDesc_Dummy(uint tile, TileDesc *td) +static void GetTileDesc_Dummy(TileIndex tile, TileDesc *td) { td->str = STR_EMPTY; td->owner = OWNER_NONE; } -static void AnimateTile_Dummy(uint tile) +static void AnimateTile_Dummy(TileIndex tile) { /* not used */ } -static void TileLoop_Dummy(uint tile) +static void TileLoop_Dummy(TileIndex tile) { /* not used */ } -static void ClickTile_Dummy(uint tile) +static void ClickTile_Dummy(TileIndex tile) { /* not used */ } -static void ChangeTileOwner_Dummy(uint tile, byte old_player, byte new_player) +static void ChangeTileOwner_Dummy(TileIndex tile, byte old_player, byte new_player) { /* not used */ } -static uint32 GetTileTrackStatus_Dummy(uint tile, TransportType mode) +static uint32 GetTileTrackStatus_Dummy(TileIndex tile, TransportType mode) { return 0; } diff --git a/economy.c b/economy.c --- a/economy.c +++ b/economy.c @@ -47,7 +47,7 @@ void CheckSwitchToEuro(void) void UpdatePlayerHouse(Player *p, uint score) { byte val; - uint tile = p->location_of_house; + TileIndex tile = p->location_of_house; if (tile == 0) return; @@ -792,7 +792,8 @@ void StartupEconomy(void) Pair SetupSubsidyDecodeParam(Subsidy *s, bool mode) { - int tile, tile2; + TileIndex tile; + TileIndex tile2; Industry *i; Town *t; Station *st; diff --git a/economy.h b/economy.h --- a/economy.h +++ b/economy.h @@ -73,6 +73,6 @@ void DeleteSubsidyWithStation(uint16 ind void RemoteSubsidyAdd(Subsidy *s_new); int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, byte cargo_type); -uint MoveGoodsToStation(uint tile, int w, int h, int type, uint amount); +uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount); #endif /* ECONOMY_H */ diff --git a/functions.h b/functions.h --- a/functions.h +++ b/functions.h @@ -64,14 +64,14 @@ void DrawRoadDepotSprite(int x, int y, i /* water_land.c */ void DrawShipDepotSprite(int x, int y, int image); -void TileLoop_Water(uint tile); +void TileLoop_Water(TileIndex tile); /* players.c */ bool CheckPlayerHasMoney(int32 cost); void SubtractMoneyFromPlayer(int32 cost); void SubtractMoneyFromPlayerFract(byte player, int32 cost); bool CheckOwnership(byte owner); -bool CheckTileOwnership(uint tile); +bool CheckTileOwnership(TileIndex tile); StringID GetPlayerNameString(byte player, byte index); /* standard */ @@ -124,18 +124,18 @@ void CDECL AddTextMessage(uint16 color, void UndrawTextMessage(void); void TextMessageDailyLoop(void); -bool AddAnimatedTile(uint tile); -void DeleteAnimatedTile(uint tile); +bool AddAnimatedTile(TileIndex tile); +void DeleteAnimatedTile(TileIndex tile); void AnimateAnimatedTiles(void); void InitializeAnimatedTiles(void); /* tunnelbridge_cmd.c */ -bool CheckTunnelInWay(uint tile, int z); +bool CheckTunnelInWay(TileIndex tile, int z); bool CheckBridge_Stuff(byte bridge_type, int bridge_len); uint32 GetBridgeLength(TileIndex begin, TileIndex end); int CalcBridgeLenCostFactor(int x); -typedef void CommandCallback(bool success, uint tile, uint32 p1, uint32 p2); +typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2); bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd); /* network.c */ @@ -148,7 +148,7 @@ bool NetworkServerStart(void); bool NetworkClientConnectGame(const char* host, unsigned short port); void NetworkReboot(void); void NetworkDisconnect(void); -void NetworkSend_Command(uint32 tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback); +void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback); /* misc_cmd.c */ void PlaceTreesRandomly(void); @@ -197,12 +197,12 @@ void ShowFeederIncomeAnimation(int x, in void DrawFoundation(TileInfo *ti, uint f); -bool CheckIfAuthorityAllows(uint tile); -Town *ClosestTownFromTile(uint tile, uint threshold); +bool CheckIfAuthorityAllows(TileIndex tile); +Town *ClosestTownFromTile(TileIndex tile, uint threshold); void ChangeTownRating(Town *t, int add, int max); uint GetRoadBitsByTile(TileIndex tile); -int GetTownRadiusGroup(Town *t, uint tile); +int GetTownRadiusGroup(Town *t, TileIndex tile); void ShowNetworkChatQueryWindow(byte desttype, byte dest); void ShowNetworkGiveMoneyWindow(byte player); void ShowNetworkNeedGamePassword(void); diff --git a/gui.h b/gui.h --- a/gui.h +++ b/gui.h @@ -5,9 +5,9 @@ /* main_gui.c */ void SetupColorsAndInitialWindow(void); -void CcPlaySound10(bool success, uint tile, uint32 p1, uint32 p2); -void CcBuildCanal(bool success, uint tile, uint32 p1, uint32 p2); -void CcTerraform(bool success, uint tile, uint32 p1, uint32 p2); +void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2); +void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2); +void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2); /* settings_gui.c */ void ShowGameOptions(void); @@ -33,7 +33,7 @@ void ShowMessageHistory(void); /* traintoolb_gui.c */ void ShowBuildRailToolbar(int index, int button); -void PlaceProc_BuyLand(uint tile); +void PlaceProc_BuyLand(TileIndex tile); /* train_gui.c */ void ShowPlayerTrains(int player, int station); @@ -61,10 +61,10 @@ void ShowPlayerAircraft(int player, int /* terraform_gui.c */ void ShowTerraformToolbar(void); -void PlaceProc_DemolishArea(uint tile); -void PlaceProc_LowerLand(uint tile); -void PlaceProc_RaiseLand(uint tile); -void PlaceProc_LevelLand(uint tile); +void PlaceProc_DemolishArea(TileIndex tile); +void PlaceProc_LowerLand(TileIndex tile); +void PlaceProc_RaiseLand(TileIndex tile); +void PlaceProc_LevelLand(TileIndex tile); bool GUIPlaceProcDragXY(const WindowEvent *we); enum { // max 32 - 4 = 28 types diff --git a/industry_cmd.c b/industry_cmd.c --- a/industry_cmd.c +++ b/industry_cmd.c @@ -37,8 +37,8 @@ byte _industry_sound_ctr; TileIndex _industry_sound_tile; void ShowIndustryViewWindow(int industry); -void BuildOilRig(uint tile); -void DeleteOilRig(uint tile); +void BuildOilRig(TileIndex tile); +void DeleteOilRig(TileIndex tile); typedef struct DrawIndustryTileStruct { uint32 sprite_1; @@ -401,7 +401,7 @@ static uint GetSlopeTileh_Industry(TileI return 0; } -static void GetAcceptedCargo_Industry(uint tile, AcceptedCargo ac) +static void GetAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac) { int m5 = _map5[tile]; int a; @@ -416,7 +416,7 @@ static void GetAcceptedCargo_Industry(ui if (a >= 0) ac[a] = 8; } -static void GetTileDesc_Industry(uint tile, TileDesc *td) +static void GetTileDesc_Industry(TileIndex tile, TileDesc *td) { Industry *i = GetIndustry(_map2[tile]); @@ -428,7 +428,7 @@ static void GetTileDesc_Industry(uint ti } } -static int32 ClearTile_Industry(uint tile, byte flags) +static int32 ClearTile_Industry(TileIndex tile, byte flags) { Industry *i = GetIndustry(_map2[tile]); @@ -459,7 +459,7 @@ static const byte _industry_min_cargo[] 5, 5, 5, 5, 5, }; -static void TransportIndustryGoods(uint tile) +static void TransportIndustryGoods(TileIndex tile) { Industry *i; int type; @@ -502,7 +502,7 @@ static void TransportIndustryGoods(uint } -static void AnimateTile_Industry(uint tile) +static void AnimateTile_Industry(TileIndex tile) { byte m,n; @@ -661,14 +661,14 @@ static void AnimateTile_Industry(uint ti } } -static void MakeIndustryTileBiggerCase8(uint tile) +static void MakeIndustryTileBiggerCase8(TileIndex tile) { TileInfo ti; FindLandscapeHeight(&ti, TileX(tile) * 16, TileY(tile) * 16); CreateEffectVehicle(ti.x + 15, ti.y + 14, ti.z + 59 + (ti.tileh != 0 ? 8 : 0), EV_CHIMNEY_SMOKE); } -static void MakeIndustryTileBigger(uint tile, byte size) +static void MakeIndustryTileBigger(TileIndex tile, byte size) { byte b = (byte)((size + (1<<2)) & (3<<2)); @@ -713,7 +713,7 @@ static void MakeIndustryTileBigger(uint -static void TileLoopIndustryCase161(uint tile) +static void TileLoopIndustryCase161(TileIndex tile) { int dir; Vehicle *v; @@ -738,7 +738,7 @@ static void TileLoopIndustryCase161(uint v->u.special.unk2 = dir; } -static void TileLoop_Industry(uint tile) +static void TileLoop_Industry(TileIndex tile) { byte n; @@ -847,24 +847,24 @@ static void TileLoop_Industry(uint tile) } -static void ClickTile_Industry(uint tile) +static void ClickTile_Industry(TileIndex tile) { ShowIndustryViewWindow(_map2[tile]); } -static uint32 GetTileTrackStatus_Industry(uint tile, TransportType mode) +static uint32 GetTileTrackStatus_Industry(TileIndex tile, TransportType mode) { return 0; } -static void GetProducedCargo_Industry(uint tile, byte *b) +static void GetProducedCargo_Industry(TileIndex tile, byte *b) { Industry *i = GetIndustry(_map2[tile]); b[0] = i->produced_cargo[0]; b[1] = i->produced_cargo[1]; } -static void ChangeTileOwner_Industry(uint tile, byte old_player, byte new_player) +static void ChangeTileOwner_Industry(TileIndex tile, byte old_player, byte new_player) { /* not used */ } @@ -922,7 +922,7 @@ static bool IsBadFarmFieldTile2(TileInde } } -static void SetupFarmFieldFence(uint tile, int size, byte type, int direction) +static void SetupFarmFieldFence(TileIndex tile, int size, byte type, int direction) { byte or, and; @@ -947,7 +947,7 @@ static void SetupFarmFieldFence(uint til } while (--size); } -static void PlantFarmField(uint tile) +static void PlantFarmField(TileIndex tile) { uint size_x, size_y; uint32 r; @@ -1008,7 +1008,8 @@ static void PlantFarmField(uint tile) static void MaybePlantFarmField(Industry *i) { - uint tile; + TileIndex tile; + if (CHANCE16(1,8)) { int x = (i->width>>1) + Random() % 31 - 16; int y = (i->height>>1) + Random() % 31 - 16; @@ -1027,7 +1028,7 @@ static void ChopLumberMillTrees(Industry {-1, 0} }; - uint tile = i->xy; + TileIndex tile = i->xy; int dir, a, j; if ((_map_owner[tile] & 0x80) == 0) @@ -1157,12 +1158,12 @@ void OnTick_Industry(void) } -static bool CheckNewIndustry_NULL(uint tile, int type) +static bool CheckNewIndustry_NULL(TileIndex tile, int type) { return true; } -static bool CheckNewIndustry_Forest(uint tile, int type) +static bool CheckNewIndustry_Forest(TileIndex tile, int type) { if (_opt.landscape == LT_HILLY) { if (GetTileZ(tile) < _opt.snow_line + 16U) { @@ -1176,7 +1177,7 @@ static bool CheckNewIndustry_Forest(uint extern bool _ignore_restrictions; /* Oil Rig and Oil Refinery */ -static bool CheckNewIndustry_Oil(uint tile, int type) +static bool CheckNewIndustry_Oil(TileIndex tile, int type) { if(_ignore_restrictions && _game_mode == GM_EDITOR) return true; @@ -1191,7 +1192,7 @@ static bool CheckNewIndustry_Oil(uint ti return false; } -static bool CheckNewIndustry_Farm(uint tile, int type) +static bool CheckNewIndustry_Farm(TileIndex tile, int type) { if (_opt.landscape == LT_HILLY) { if (GetTileZ(tile) + 16 >= _opt.snow_line) { @@ -1202,7 +1203,7 @@ static bool CheckNewIndustry_Farm(uint t return true; } -static bool CheckNewIndustry_Plantation(uint tile, int type) +static bool CheckNewIndustry_Plantation(TileIndex tile, int type) { if (GetMapExtraBits(tile) == 1) { _error_message = STR_0239_SITE_UNSUITABLE; @@ -1212,7 +1213,7 @@ static bool CheckNewIndustry_Plantation( return true; } -static bool CheckNewIndustry_Water(uint tile, int type) +static bool CheckNewIndustry_Water(TileIndex tile, int type) { if (GetMapExtraBits(tile) != 1) { _error_message = STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT; @@ -1222,7 +1223,7 @@ static bool CheckNewIndustry_Water(uint return true; } -static bool CheckNewIndustry_Lumbermill(uint tile, int type) +static bool CheckNewIndustry_Lumbermill(TileIndex tile, int type) { if (GetMapExtraBits(tile) != 2) { _error_message = STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST; @@ -1231,7 +1232,7 @@ static bool CheckNewIndustry_Lumbermill( return true; } -static bool CheckNewIndustry_BubbleGen(uint tile, int type) +static bool CheckNewIndustry_BubbleGen(TileIndex tile, int type) { if (GetTileZ(tile) > 32) { return false; @@ -1239,7 +1240,7 @@ static bool CheckNewIndustry_BubbleGen(u return true; } -typedef bool CheckNewIndustryProc(uint tile, int type); +typedef bool CheckNewIndustryProc(TileIndex tile, int type); static CheckNewIndustryProc * const _check_new_industry_procs[] = { CheckNewIndustry_NULL, CheckNewIndustry_Forest, @@ -1251,7 +1252,7 @@ static CheckNewIndustryProc * const _che CheckNewIndustry_BubbleGen, }; -static bool CheckSuitableIndustryPos(uint tile) +static bool CheckSuitableIndustryPos(TileIndex tile) { uint x = TileX(tile); uint y = TileY(tile); @@ -1264,7 +1265,7 @@ static bool CheckSuitableIndustryPos(uin return true; } -static Town *CheckMultipleIndustryInTown(uint tile, int type) +static Town *CheckMultipleIndustryInTown(TileIndex tile, int type) { Town *t; Industry *i; @@ -1311,15 +1312,15 @@ static const byte _industry_map5_bits[] 16, 16, 16, 16, 16, 16, 16, }; -static bool CheckIfIndustryTilesAreFree(uint tile, const IndustryTileTable *it, int type, Town *t) +static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, int type, Town *t) { TileInfo ti; - uint cur_tile; _error_message = STR_0239_SITE_UNSUITABLE; do { - cur_tile = tile + ToTileIndexDiff(it->ti); + TileIndex cur_tile = tile + ToTileIndexDiff(it->ti); + if (!IsValidTile(cur_tile)) { if (it->map5 == 0xff) continue; @@ -1397,7 +1398,7 @@ do_clear: return true; } -static bool CheckIfTooCloseToIndustry(uint tile, int type) +static bool CheckIfTooCloseToIndustry(TileIndex tile, int type) { Industry *i; const IndustrySpec *spec; @@ -1456,11 +1457,10 @@ static Industry *AllocateIndustry(void) return NULL; } -static void DoCreateNewIndustry(Industry *i, uint tile, int type, const IndustryTileTable *it, Town *t, byte owner) +static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const IndustryTileTable *it, Town *t, byte owner) { const IndustrySpec *spec; uint32 r; - uint cur_tile; int j; i->xy = tile; @@ -1509,7 +1509,7 @@ static void DoCreateNewIndustry(Industry i->prod_level = 0x10; do { - cur_tile = tile + ToTileIndexDiff(it->ti); + TileIndex cur_tile = tile + ToTileIndexDiff(it->ti); if (it->map5 != 0xFF) { byte size; @@ -1536,7 +1536,8 @@ static void DoCreateNewIndustry(Industry for(j=0; j!=50; j++) { int x = Random() % 31 - 16; int y = Random() % 31 - 16; - uint new_tile = TileAddWrap(tile, x, y); + TileIndex new_tile = TileAddWrap(tile, x, y); + if (new_tile != INVALID_TILE) PlantFarmField(new_tile); } @@ -1604,7 +1605,7 @@ int32 CmdBuildIndustry(int x, int y, uin } -Industry *CreateNewIndustry(uint tile, int type) +Industry *CreateNewIndustry(TileIndex tile, int type) { Town *t; const IndustryTileTable *it; diff --git a/main_gui.c b/main_gui.c --- a/main_gui.c +++ b/main_gui.c @@ -144,7 +144,7 @@ bool HandlePlacePushButton(Window *w, in } -void CcPlaySound10(bool success, uint tile, uint32 p1, uint32 p2) +void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) SndPlayTileFx(SND_12_EXPLOSION, tile); } @@ -1149,7 +1149,7 @@ static void AskResetLandscape(uint mode) * @param tile The top-left tile where the terraforming will start * @param mode 1 for raising, 0 for lowering land */ -static void CommonRaiseLowerBigLand(uint tile, int mode) +static void CommonRaiseLowerBigLand(TileIndex tile, int mode) { int sizex, sizey; byte h; @@ -1194,17 +1194,17 @@ static void CommonRaiseLowerBigLand(uint _generating_world = false; } -static void PlaceProc_RaiseBigLand(uint tile) +static void PlaceProc_RaiseBigLand(TileIndex tile) { CommonRaiseLowerBigLand(tile, 1); } -static void PlaceProc_LowerBigLand(uint tile) +static void PlaceProc_LowerBigLand(TileIndex tile) { CommonRaiseLowerBigLand(tile, 0); } -static void PlaceProc_RockyArea(uint tile) +static void PlaceProc_RockyArea(TileIndex tile) { if (!IsTileType(tile, MP_CLEAR) && !IsTileType(tile, MP_TREES)) return; @@ -1213,7 +1213,7 @@ static void PlaceProc_RockyArea(uint til SndPlayTileFx(SND_1F_SPLAT, tile); } -static void PlaceProc_LightHouse(uint tile) +static void PlaceProc_LightHouse(TileIndex tile) { TileInfo ti; @@ -1225,7 +1225,7 @@ static void PlaceProc_LightHouse(uint ti SndPlayTileFx(SND_1F_SPLAT, tile); } -static void PlaceProc_Transmitter(uint tile) +static void PlaceProc_Transmitter(TileIndex tile) { TileInfo ti; @@ -1455,7 +1455,7 @@ static void ToolbarScenGenLand(Window *w ShowEditorTerraformToolBar(); } -void CcBuildTown(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildTown(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_1F_SPLAT, tile); @@ -1463,7 +1463,7 @@ void CcBuildTown(bool success, uint tile } } -static void PlaceProc_Town(uint tile) +static void PlaceProc_Town(TileIndex tile) { DoCommandP(tile, 0, 0, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE)); } @@ -1655,7 +1655,7 @@ static bool AnyTownExists(void) return false; } -extern Industry *CreateNewIndustry(uint tile, int type); +extern Industry *CreateNewIndustry(TileIndex tile, int type); static bool TryBuildIndustry(TileIndex tile, int type) { diff --git a/map.h b/map.h --- a/map.h +++ b/map.h @@ -45,7 +45,7 @@ typedef enum { } Owner; enum { - INVALID_TILE = (uint32) -1 + INVALID_TILE = (TileIndex)-1 }; enum { diff --git a/misc_gui.c b/misc_gui.c --- a/misc_gui.c +++ b/misc_gui.c @@ -30,7 +30,7 @@ typedef struct LandInfoData { Town *town; int32 costclear; AcceptedCargo ac; - uint tile; + TileIndex tile; TileDesc td; } LandInfoData; @@ -115,7 +115,7 @@ static const WindowDesc _land_info_desc LandInfoWndProc }; -static void Place_LandInfo(uint tile) +static void Place_LandInfo(TileIndex tile) { Player *p; static LandInfoData lid; diff --git a/network_data.c b/network_data.c --- a/network_data.c +++ b/network_data.c @@ -396,7 +396,7 @@ void NetworkAddCommandQueue(NetworkClien } // Prepare a DoCommand to be send over the network -void NetworkSend_Command(uint32 tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback) +void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback) { CommandPacket *c = malloc(sizeof(CommandPacket)); byte temp_callback; diff --git a/network_data.h b/network_data.h --- a/network_data.h +++ b/network_data.h @@ -37,7 +37,7 @@ typedef struct CommandPacket { uint32 cmd; /// command being executed uint32 p1; /// parameter p1 uint32 p2; /// parameter p2 - uint32 tile; /// tile command being executed on ; always make it uint32, so it is bigmap compatible (TileIndex) + TileIndex tile; /// tile command being executed on char text[80]; uint32 frame; /// the frame in which this packet is executed byte callback; /// any callback function executed upon successful completion of the command diff --git a/openttd.c b/openttd.c --- a/openttd.c +++ b/openttd.c @@ -1181,7 +1181,7 @@ void BeforeSaveGame(void) static void ConvertTownOwner(void) { - uint tile; + TileIndex tile; for (tile = 0; tile != MapSize(); tile++) { if (IsTileType(tile, MP_STREET)) { diff --git a/openttd.h b/openttd.h --- a/openttd.h +++ b/openttd.h @@ -116,7 +116,7 @@ typedef struct TileInfo { uint tileh; uint type; uint map5; - uint tile; + TileIndex tile; uint z; } TileInfo; @@ -288,9 +288,9 @@ typedef int32 CommandProc(int x, int y, typedef void DrawTileProc(TileInfo *ti); typedef uint GetSlopeZProc(TileInfo *ti); -typedef int32 ClearTileProc(uint tile, byte flags); -typedef void GetAcceptedCargoProc(uint tile, AcceptedCargo res); -typedef void GetTileDescProc(uint tile, TileDesc *td); +typedef int32 ClearTileProc(TileIndex tile, byte flags); +typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res); +typedef void GetTileDescProc(TileIndex tile, TileDesc *td); /* GetTileTrackStatusProcs return a value that contains the possible tracks * that can be taken on a given tile by a given transport. The return value is * composed as follows: 0xaabbccdd. ccdd and aabb are bitmasks of trackdirs, @@ -310,18 +310,18 @@ typedef void GetTileDescProc(uint tile, * possible options: 0-5 and 8-13, so we need 14 bits for a trackdir bitmask * above. */ -typedef uint32 GetTileTrackStatusProc(uint tile, TransportType mode); -typedef void GetProducedCargoProc(uint tile, byte *b); -typedef void ClickTileProc(uint tile); -typedef void AnimateTileProc(uint tile); -typedef void TileLoopProc(uint tile); -typedef void ChangeTileOwnerProc(uint tile, byte old_player, byte new_player); +typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode); +typedef void GetProducedCargoProc(TileIndex tile, byte *b); +typedef void ClickTileProc(TileIndex tile); +typedef void AnimateTileProc(TileIndex tile); +typedef void TileLoopProc(TileIndex tile); +typedef void ChangeTileOwnerProc(TileIndex tile, byte old_player, byte new_player); /* Return value has bit 0x2 set, when the vehicle enters a station. Then, * result << 8 contains the id of the station entered. If the return value has * bit 0x8 set, the vehicle could not and did not enter the tile. Are there * other bits that can be set? */ -typedef uint32 VehicleEnterTileProc(Vehicle *v, uint tile, int x, int y); -typedef void VehicleLeaveTileProc(Vehicle *v, uint tile, int x, int y); +typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y); +typedef void VehicleLeaveTileProc(Vehicle *v, TileIndex tile, int x, int y); typedef uint GetSlopeTilehProc(TileInfo *ti); typedef struct { @@ -521,7 +521,7 @@ enum SpecialStrings { STR_SPEC_USERSTRING = 0xF801, }; -typedef void PlaceProc(uint tile); +typedef void PlaceProc(TileIndex tile); VARDEF byte _savegame_sort_order; diff --git a/order_gui.c b/order_gui.c --- a/order_gui.c +++ b/order_gui.c @@ -183,7 +183,7 @@ static void DrawOrdersWindow(Window *w) } } -static Order GetOrderCmdFromTile(Vehicle *v, uint tile) +static Order GetOrderCmdFromTile(Vehicle *v, TileIndex tile) { Order order; Station *st; @@ -301,7 +301,7 @@ static bool HandleOrderVehClick(Vehicle return true; } -static void OrdersPlaceObj(Vehicle *v, uint tile, Window *w) +static void OrdersPlaceObj(Vehicle *v, TileIndex tile, Window *w) { Order cmd; Vehicle *u; diff --git a/pathfind.c b/pathfind.c --- a/pathfind.c +++ b/pathfind.c @@ -5,7 +5,7 @@ #include "pathfind.h" // remember which tiles we have already visited so we don't visit them again. -static bool TPFSetTileBit(TrackPathFinder *tpf, uint tile, int dir) +static bool TPFSetTileBit(TrackPathFinder *tpf, TileIndex tile, int dir) { uint hash, val, offs; TrackPathFinderLink *link, *new_link; @@ -120,11 +120,11 @@ static const byte _otherdir_mask[4] = { }; #ifdef DEBUG_TILE_PUSH -extern void dbg_push_tile(uint tile, int track); +extern void dbg_push_tile(TileIndex tile, int track); extern void dbg_pop_tile(); #endif -static void TPFMode2(TrackPathFinder *tpf, uint tile, int direction) +static void TPFMode2(TrackPathFinder *tpf, TileIndex tile, int direction) { uint bits; int i; @@ -211,7 +211,7 @@ static const int8 _get_tunlen_inc[5] = { /* Returns the end tile and the length of a tunnel. The length does not * include the starting tile (entry), it does include the end tile (exit). */ -FindLengthOfTunnelResult FindLengthOfTunnel(uint tile, int direction) +FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, int direction) { FindLengthOfTunnelResult flotr; int x,y; @@ -246,7 +246,8 @@ FindLengthOfTunnelResult FindLengthOfTun static const uint16 _tpfmode1_and[4] = { 0x1009, 0x16, 0x520, 0x2A00 }; -static uint SkipToEndOfTunnel(TrackPathFinder *tpf, uint tile, int direction) { +static uint SkipToEndOfTunnel(TrackPathFinder *tpf, TileIndex tile, int direction) +{ FindLengthOfTunnelResult flotr; TPFSetTileBit(tpf, tile, 14); flotr = FindLengthOfTunnel(tile, direction); @@ -275,12 +276,12 @@ 32,48,48,50,48,52,52,54, 48,56,56,58,56,60,60,62, }; -static void TPFMode1(TrackPathFinder *tpf, uint tile, int direction) +static void TPFMode1(TrackPathFinder *tpf, TileIndex tile, int direction) { uint bits; int i; RememberData rd; - uint tile_org = tile; + TileIndex tile_org = tile; if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0) == 0) { if ((_map5[tile] & 3) != direction || ((_map5[tile]>>2)&3) != tpf->tracktype) @@ -370,7 +371,7 @@ static void TPFMode1(TrackPathFinder *tp } while (bits != 0); } -void FollowTrack(uint tile, uint16 flags, byte direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data) +void FollowTrack(TileIndex tile, uint16 flags, byte direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data) { TrackPathFinder tpf; @@ -513,7 +514,7 @@ static inline void HeapifyDown(NewTrackP // mark a tile as visited and store the length of the path. // if we already had a better path to this tile, return false. // otherwise return true. -static bool NtpVisit(NewTrackPathFinder *tpf, uint tile, uint dir, uint length) +static bool NtpVisit(NewTrackPathFinder *tpf, TileIndex tile, uint dir, uint length) { uint hash,head; HashLink *link, *new_link; @@ -587,7 +588,7 @@ static bool NtpVisit(NewTrackPathFinder return true; } -static bool NtpCheck(NewTrackPathFinder *tpf, uint tile, uint dir, uint length) +static bool NtpCheck(NewTrackPathFinder *tpf, TileIndex tile, uint dir, uint length) { uint hash,head,offs; HashLink *link; @@ -617,7 +618,7 @@ static bool NtpCheck(NewTrackPathFinder // new more optimized pathfinder for trains... -static void NTPEnum(NewTrackPathFinder *tpf, uint tile, uint direction) +static void NTPEnum(NewTrackPathFinder *tpf, TileIndex tile, uint direction) { uint bits, tile_org; int i; @@ -744,7 +745,7 @@ popnext: // new pathfinder for trains. better and faster. -void NewTrainPathfind(uint tile, byte direction, TPFEnumProc *enum_proc, void *data, byte *cache) +void NewTrainPathfind(TileIndex tile, byte direction, TPFEnumProc *enum_proc, void *data, byte *cache) { if (!_patches.new_pathfinding) { FollowTrack(tile, 0x3000 | TRANSPORT_RAIL, direction, enum_proc, NULL, data); diff --git a/pathfind.h b/pathfind.h --- a/pathfind.h +++ b/pathfind.h @@ -5,7 +5,7 @@ //supported on all archs) typedef struct TrackPathFinder TrackPathFinder; -typedef bool TPFEnumProc(uint tile, void *data, int track, uint length, byte *state); +typedef bool TPFEnumProc(TileIndex tile, void *data, int track, uint length, byte *state); typedef void TPFAfterProc(TrackPathFinder *tpf); @@ -55,14 +55,14 @@ struct TrackPathFinder { TrackPathFinderLink links[0x400]; /* hopefully, this is enough. */ }; -void FollowTrack(uint tile, uint16 flags, byte direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data); +void FollowTrack(TileIndex tile, uint16 flags, byte direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data); typedef struct { - uint tile; + TileIndex tile; int length; } FindLengthOfTunnelResult; -FindLengthOfTunnelResult FindLengthOfTunnel(uint tile, int direction); +FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, int direction); -void NewTrainPathfind(uint tile, byte direction, TPFEnumProc *enum_proc, void *data, byte *cache); +void NewTrainPathfind(TileIndex tile, byte direction, TPFEnumProc *enum_proc, void *data, byte *cache); #endif /* PATHFIND_H */ diff --git a/player.h b/player.h --- a/player.h +++ b/player.h @@ -187,7 +187,7 @@ typedef struct Player { } Player; void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player); -void GetNameOfOwner(byte owner, uint tile); +void GetNameOfOwner(byte owner, TileIndex tile); int64 CalculateCompanyValue(Player *p); void InvalidatePlayerWindows(Player *p); void AiDoGameLoop(Player *p); diff --git a/players.c b/players.c --- a/players.c +++ b/players.c @@ -248,7 +248,7 @@ void UpdatePlayerMoney32(Player *p) p->player_money = (int32)p->money64; } -void GetNameOfOwner(byte owner, uint tile) +void GetNameOfOwner(byte owner, TileIndex tile) { SetDParam(2, owner); @@ -279,7 +279,7 @@ bool CheckOwnership(byte owner) return false; } -bool CheckTileOwnership(uint tile) +bool CheckTileOwnership(TileIndex tile) { byte owner = GetTileOwner(tile); @@ -297,7 +297,7 @@ bool CheckTileOwnership(uint tile) static void GenerateCompanyName(Player *p) { - uint tile; + TileIndex tile; Town *t; StringID str; Player *pp; diff --git a/rail_cmd.c b/rail_cmd.c --- a/rail_cmd.c +++ b/rail_cmd.c @@ -21,7 +21,7 @@ extern uint16 _custom_sprites_base; -void ShowTrainDepotWindow(uint tile); +void ShowTrainDepotWindow(TileIndex tile); /* Format of rail map5 byte. * 00 abcdef => Normal rail @@ -952,9 +952,9 @@ int32 CmdRemoveSignalTrack(int x, int y, return CmdSignalTrackHelper(x, y, flags, p1, SETBIT(p2, 0)); } -typedef int32 DoConvertRailProc(uint tile, uint totype, bool exec); +typedef int32 DoConvertRailProc(TileIndex tile, uint totype, bool exec); -static int32 DoConvertRail(uint tile, uint totype, bool exec) +static int32 DoConvertRail(TileIndex tile, uint totype, bool exec) { if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR; @@ -972,9 +972,9 @@ static int32 DoConvertRail(uint tile, ui return _price.build_rail / 2; } -extern int32 DoConvertStationRail(uint tile, uint totype, bool exec); -extern int32 DoConvertStreetRail(uint tile, uint totype, bool exec); -extern int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec); +extern int32 DoConvertStationRail(TileIndex tile, uint totype, bool exec); +extern int32 DoConvertStreetRail(TileIndex tile, uint totype, bool exec); +extern int32 DoConvertTunnelBridgeRail(TileIndex tile, uint totype, bool exec); /** Convert one rail type to the other. You can convert normal rail to * monorail/maglev easily or vice-versa. @@ -1026,7 +1026,7 @@ int32 CmdConvertRail(int ex, int ey, uin return (cost == 0) ? CMD_ERROR : cost; } -static int32 RemoveTrainDepot(uint tile, uint32 flags) +static int32 RemoveTrainDepot(TileIndex tile, uint32 flags) { if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR; @@ -1537,7 +1537,7 @@ typedef struct SetSignalsData { } SetSignalsData; -static bool SetSignalsEnumProc(uint tile, SetSignalsData *ssd, int track, uint length, byte *state) +static bool SetSignalsEnumProc(TileIndex tile, SetSignalsData *ssd, int track, uint length, byte *state) { // the tile has signals? if (IsTileType(tile, MP_RAILWAY)) { @@ -1697,7 +1697,7 @@ static void ChangeSignalStates(SetSignal // then mark the signals in the segment accordingly for(i=0; i!=ssd->cur; i++) { - uint tile = ssd->tile[i]; + TileIndex tile = ssd->tile[i]; byte bit = _signals_table[ssd->bit[i]]; uint16 m2 = _map2[tile]; @@ -1745,7 +1745,7 @@ make_red: } -bool UpdateSignalsOnSegment(uint tile, byte direction) +bool UpdateSignalsOnSegment(TileIndex tile, byte direction) { SetSignalsData ssd; int result = -1; @@ -1776,7 +1776,7 @@ bool UpdateSignalsOnSegment(uint tile, b return (bool)result; } -void SetSignalsOnBothDir(uint tile, byte track) +void SetSignalsOnBothDir(TileIndex tile, byte track) { static const byte _search_dir_1[6] = {1, 3, 1, 3, 5, 3}; static const byte _search_dir_2[6] = {5, 7, 7, 5, 7, 1}; @@ -1833,17 +1833,17 @@ static uint GetSlopeTileh_Track(TileInfo return ti->tileh; } -static void GetAcceptedCargo_Track(uint tile, AcceptedCargo ac) +static void GetAcceptedCargo_Track(TileIndex tile, AcceptedCargo ac) { /* not used */ } -static void AnimateTile_Track(uint tile) +static void AnimateTile_Track(TileIndex tile) { /* not used */ } -static void TileLoop_Track(uint tile) +static void TileLoop_Track(TileIndex tile) { byte a2; byte rail; @@ -1929,7 +1929,8 @@ modify_me:; } -static uint32 GetTileTrackStatus_Track(uint tile, TransportType mode) { +static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode) +{ byte m5, a; uint16 b; uint32 ret; @@ -1974,7 +1975,7 @@ static uint32 GetTileTrackStatus_Track(u return ret; } -static void ClickTile_Track(uint tile) +static void ClickTile_Track(TileIndex tile) { if (IsTileDepotType(tile, TRANSPORT_RAIL)) ShowTrainDepotWindow(tile); @@ -2011,7 +2012,7 @@ static void GetTileDesc_Track(TileIndex } } -static void ChangeTileOwner_Track(uint tile, byte old_player, byte new_player) +static void ChangeTileOwner_Track(TileIndex tile, byte old_player, byte new_player) { if (!IsTileOwner(tile, old_player)) return; @@ -2032,7 +2033,7 @@ static const byte _enter_directions[4] = static const byte _leave_directions[4] = {1, 3, 5, 7}; static const byte _depot_track_mask[4] = {1, 2, 1, 2}; -static uint32 VehicleEnter_Track(Vehicle *v, uint tile, int x, int y) +static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y) { byte fract_coord; byte fract_coord_leave; diff --git a/rail_gui.c b/rail_gui.c --- a/rail_gui.c +++ b/rail_gui.c @@ -29,19 +29,19 @@ struct { } _railstation; -static void HandleStationPlacement(uint start, uint end); +static void HandleStationPlacement(TileIndex start, TileIndex end); static void ShowBuildTrainDepotPicker(void); static void ShowBuildWaypointPicker(void); static void ShowStationBuilder(void); typedef void OnButtonClick(Window *w); -void CcPlaySound1E(bool success, uint tile, uint32 p1, uint32 p2) +void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) SndPlayTileFx(SND_20_SPLAT_2, tile); } -static void GenericPlaceRail(uint tile, int cmd) +static void GenericPlaceRail(TileIndex tile, int cmd) { DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E, _remove_button_clicked ? @@ -50,34 +50,34 @@ static void GenericPlaceRail(uint tile, ); } -static void PlaceRail_N(uint tile) +static void PlaceRail_N(TileIndex tile) { int cmd = _tile_fract_coords.x > _tile_fract_coords.y ? 4 : 5; GenericPlaceRail(tile, cmd); } -static void PlaceRail_NE(uint tile) +static void PlaceRail_NE(TileIndex tile) { VpStartPlaceSizing(tile, VPM_FIX_Y); } -static void PlaceRail_E(uint tile) +static void PlaceRail_E(TileIndex tile) { int cmd = _tile_fract_coords.x + _tile_fract_coords.y <= 15 ? 2 : 3; GenericPlaceRail(tile, cmd); } -static void PlaceRail_NW(uint tile) +static void PlaceRail_NW(TileIndex tile) { VpStartPlaceSizing(tile, VPM_FIX_X); } -static void PlaceRail_AutoRail(uint tile) +static void PlaceRail_AutoRail(TileIndex tile) { VpStartPlaceSizing(tile, VPM_RAILDIRS); } -static void PlaceExtraDepotRail(uint tile, uint16 extra) +static void PlaceExtraDepotRail(TileIndex tile, uint16 extra) { byte b = _map5[tile]; @@ -94,7 +94,7 @@ static const uint16 _place_depot_extra[1 }; -void CcRailDepot(bool success, uint tile, uint32 p1, uint32 p2) +void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { int dir = p2; @@ -112,13 +112,13 @@ void CcRailDepot(bool success, uint tile } } -static void PlaceRail_Depot(uint tile) +static void PlaceRail_Depot(TileIndex tile) { DoCommandP(tile, _cur_railtype, _build_depot_direction, CcRailDepot, CMD_BUILD_TRAIN_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT)); } -static void PlaceRail_Waypoint(uint tile) +static void PlaceRail_Waypoint(TileIndex tile) { if (!_remove_button_clicked) { DoCommandP(tile, (_waypoint_count > 0) ? (0x100 + _cur_waypoint_type) : 0, 0, CcPlaySound1E, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT)); @@ -127,7 +127,7 @@ static void PlaceRail_Waypoint(uint tile } } -void CcStation(bool success, uint tile, uint32 p1, uint32 p2) +void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_20_SPLAT_2, tile); @@ -135,7 +135,7 @@ void CcStation(bool success, uint tile, } } -static void PlaceRail_Station(uint tile) +static void PlaceRail_Station(TileIndex tile) { if(_remove_button_clicked) DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION)); @@ -150,7 +150,7 @@ static void PlaceRail_Station(uint tile) } } -static void GenericPlaceSignals(uint tile) +static void GenericPlaceSignals(TileIndex tile) { uint trackstat; int i; @@ -176,12 +176,12 @@ static void GenericPlaceSignals(uint til } } -static void PlaceRail_Bridge(uint tile) +static void PlaceRail_Bridge(TileIndex tile) { VpStartPlaceSizing(tile, VPM_X_OR_Y); } -void CcBuildRailTunnel(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_20_SPLAT_2, tile); @@ -191,23 +191,23 @@ void CcBuildRailTunnel(bool success, uin } } -static void PlaceRail_Tunnel(uint tile) +static void PlaceRail_Tunnel(TileIndex tile) { DoCommandP(tile, _cur_railtype, 0, CcBuildRailTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE)); } -void PlaceProc_BuyLand(uint tile) +void PlaceProc_BuyLand(TileIndex tile) { DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_PURCHASE_LAND_AREA | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND)); } -static void PlaceRail_ConvertRail(uint tile) +static void PlaceRail_ConvertRail(TileIndex tile) { VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_ConvertRailArea); } -static void PlaceRail_AutoSignals(uint tile) +static void PlaceRail_AutoSignals(TileIndex tile) { VpStartPlaceSizing(tile, VPM_SIGNALDIRS); } @@ -473,7 +473,8 @@ static void BuildRailToolbWndProc(Window break; case WE_PLACE_PRESIZE: { - uint tile = e->place.tile; + TileIndex tile = e->place.tile; + DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL); VpSetPresizeRange(tile, _build_tunnel_endtile==0?tile:_build_tunnel_endtile); } break; @@ -619,7 +620,7 @@ void ShowBuildRailToolbar(int index, int /* TODO: For custom stations, respect their allowed platforms/lengths bitmasks! * --pasky */ -static void HandleStationPlacement(uint start, uint end) +static void HandleStationPlacement(TileIndex start, TileIndex end) { uint sx = TileX(start); uint sy = TileY(start); diff --git a/road_cmd.c b/road_cmd.c --- a/road_cmd.c +++ b/road_cmd.c @@ -21,7 +21,7 @@ static bool _road_special_gettrackstatus void RoadVehEnterDepot(Vehicle *v); -static bool HasTileRoadAt(uint tile, int i) +static bool HasTileRoadAt(TileIndex tile, int i) { int mask; byte b; @@ -58,7 +58,7 @@ static bool HasTileRoadAt(uint tile, int return HASBIT(b, i); } -static bool CheckAllowRemoveRoad(uint tile, uint br, bool *edge_road) +static bool CheckAllowRemoveRoad(TileIndex tile, uint br, bool *edge_road) { int blocks; byte owner; @@ -479,7 +479,7 @@ do_clear:; return cost; } -int32 DoConvertStreetRail(uint tile, uint totype, bool exec) +int32 DoConvertStreetRail(TileIndex tile, uint totype, bool exec) { // not a railroad crossing? if (!IsLevelCrossing(tile)) return CMD_ERROR; @@ -677,7 +677,8 @@ static int32 RemoveRoadDepot(uint tile, #define M(x) (1<<(x)) -static int32 ClearTile_Road(uint tile, byte flags) { +static int32 ClearTile_Road(TileIndex tile, byte flags) +{ int32 ret; byte m5 = _map5[tile]; @@ -929,12 +930,12 @@ static uint GetSlopeTileh_Road(TileInfo return ti->tileh; } -static void GetAcceptedCargo_Road(uint tile, AcceptedCargo ac) +static void GetAcceptedCargo_Road(TileIndex tile, AcceptedCargo ac) { /* not used */ } -static void AnimateTile_Road(uint tile) +static void AnimateTile_Road(TileIndex tile) { if (IsLevelCrossing(tile)) { MarkTileDirtyByTile(tile); @@ -958,7 +959,7 @@ static const byte _town_road_types_2[5][ }; -static void TileLoop_Road(uint tile) +static void TileLoop_Road(TileIndex tile) { Town *t; int grp; @@ -1041,9 +1042,9 @@ static void TileLoop_Road(uint tile) } } -void ShowRoadDepotWindow(uint tile); +void ShowRoadDepotWindow(TileIndex tile); -static void ClickTile_Road(uint tile) +static void ClickTile_Road(TileIndex tile) { if ((_map5[tile] & 0xF0) == 0x20) { ShowRoadDepotWindow(tile); @@ -1054,7 +1055,8 @@ static const byte _road_trackbits[16] = 0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F, }; -static uint32 GetTileTrackStatus_Road(uint tile, TransportType mode) { +static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode) +{ if (mode == TRANSPORT_RAIL) { if (!IsLevelCrossing(tile)) return 0; @@ -1094,7 +1096,7 @@ static const StringID _road_tile_strings STR_1814_ROAD, }; -static void GetTileDesc_Road(uint tile, TileDesc *td) +static void GetTileDesc_Road(TileIndex tile, TileDesc *td) { int i = (_map5[tile] >> 4); if (i == 0) @@ -1107,7 +1109,7 @@ static const byte _roadveh_enter_depot_u 8, 9, 0, 1 }; -static uint32 VehicleEnter_Road(Vehicle *v, uint tile, int x, int y) +static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y) { if (IsLevelCrossing(tile)) { if (v->type == VEH_Train && (_map5[tile] & 4) == 0) { @@ -1127,7 +1129,7 @@ static uint32 VehicleEnter_Road(Vehicle return 0; } -static void VehicleLeave_Road(Vehicle *v, uint tile, int x, int y) +static void VehicleLeave_Road(Vehicle *v, TileIndex tile, int x, int y) { if (IsLevelCrossing(tile) && v->type == VEH_Train && v->next == NULL) { // Turn off level crossing lights @@ -1136,7 +1138,7 @@ static void VehicleLeave_Road(Vehicle *v } } -static void ChangeTileOwner_Road(uint tile, byte old_player, byte new_player) +static void ChangeTileOwner_Road(TileIndex tile, byte old_player, byte new_player) { byte b; diff --git a/road_gui.c b/road_gui.c --- a/road_gui.c +++ b/road_gui.c @@ -26,30 +26,30 @@ static byte _place_road_flag; static byte _road_depot_orientation; static byte _road_station_picker_orientation; -void CcPlaySound1D(bool success, uint tile, uint32 p1, uint32 p2) +void CcPlaySound1D(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) SndPlayTileFx(SND_1F_SPLAT, tile); } -static void PlaceRoad_NE(uint tile) +static void PlaceRoad_NE(TileIndex tile) { _place_road_flag = (_tile_fract_coords.y >= 8) + 4; VpStartPlaceSizing(tile, VPM_FIX_X); } -static void PlaceRoad_NW(uint tile) +static void PlaceRoad_NW(TileIndex tile) { _place_road_flag = (_tile_fract_coords.x >= 8) + 0; VpStartPlaceSizing(tile, VPM_FIX_Y); } -static void PlaceRoad_Bridge(uint tile) +static void PlaceRoad_Bridge(TileIndex tile) { VpStartPlaceSizing(tile, VPM_X_OR_Y); } -void CcBuildRoadTunnel(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildRoadTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_20_SPLAT_2, tile); @@ -59,12 +59,12 @@ void CcBuildRoadTunnel(bool success, uin } } -static void PlaceRoad_Tunnel(uint tile) +static void PlaceRoad_Tunnel(TileIndex tile) { DoCommandP(tile, 0x200, 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE)); } -static void BuildRoadOutsideStation(uint tile, int direction) +static void BuildRoadOutsideStation(TileIndex tile, int direction) { static const byte _roadbits_by_dir[4] = {2,1,8,4}; tile += TileOffsByDir(direction); @@ -74,7 +74,7 @@ static void BuildRoadOutsideStation(uint } } -void CcRoadDepot(bool success, uint tile, uint32 p1, uint32 p2) +void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_1F_SPLAT, tile); @@ -83,22 +83,22 @@ void CcRoadDepot(bool success, uint tile } } -static void PlaceRoad_Depot(uint tile) +static void PlaceRoad_Depot(TileIndex tile) { DoCommandP(tile, _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1807_CAN_T_BUILD_ROAD_VEHICLE)); } -static void PlaceRoad_BusStation(uint tile) +static void PlaceRoad_BusStation(TileIndex tile) { DoCommandP(tile, _road_station_picker_orientation, RS_BUS, CcRoadDepot, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1808_CAN_T_BUILD_BUS_STATION)); } -static void PlaceRoad_TruckStation(uint tile) +static void PlaceRoad_TruckStation(TileIndex tile) { DoCommandP(tile, _road_station_picker_orientation, RS_TRUCK, CcRoadDepot, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1809_CAN_T_BUILD_TRUCK_STATION)); } -static void PlaceRoad_DemolishArea(uint tile) +static void PlaceRoad_DemolishArea(TileIndex tile) { VpStartPlaceSizing(tile, 4); } @@ -253,8 +253,9 @@ static void BuildRoadToolbWndProc(Window case WE_PLACE_MOUSEUP: if (e->place.pt.x != -1) { - uint start_tile = e->place.starttile; - uint end_tile = e->place.tile; + TileIndex start_tile = e->place.starttile; + TileIndex end_tile = e->place.tile; + if (e->place.userdata == 0) { ResetObjectToPlace(); ShowBuildBridgeWindow(start_tile, end_tile, 0x80); @@ -270,7 +271,8 @@ static void BuildRoadToolbWndProc(Window break; case WE_PLACE_PRESIZE: { - uint tile = e->place.tile; + TileIndex tile = e->place.tile; + DoCommandByTile(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL); VpSetPresizeRange(tile, _build_tunnel_endtile==0?tile:_build_tunnel_endtile); break; diff --git a/roadveh_cmd.c b/roadveh_cmd.c --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -282,7 +282,7 @@ int32 CmdSellRoadVeh(int x, int y, uint3 typedef struct RoadFindDepotData { uint best_length; - uint tile; + TileIndex tile; byte owner; } RoadFindDepotData; @@ -291,7 +291,7 @@ static const byte _road_pf_directions[16 2, 3, 3, 2, 3, 0, 255, 255, }; -static bool EnumRoadSignalFindDepot(uint tile, RoadFindDepotData *rfdd, int track, uint length, byte *state) +static bool EnumRoadSignalFindDepot(TileIndex tile, RoadFindDepotData *rfdd, int track, uint length, byte *state) { tile += TileOffsByDir(_road_pf_directions[track]); @@ -309,7 +309,7 @@ static bool EnumRoadSignalFindDepot(uint static Depot *FindClosestRoadDepot(Vehicle *v) { - uint tile = v->tile; + TileIndex tile = v->tile; int i; if (v->u.road.state == 255) { tile = GetVehicleOutOfTunnelTile(v); } @@ -472,7 +472,7 @@ static void UpdateRoadVehDeltaXY(Vehicle static void ClearCrashedStation(Vehicle *v) { - uint tile = v->tile; + TileIndex tile = v->tile; byte *b, bb; RoadStop *rs = GetRoadStopByTile(tile, GetRoadStopType(tile)); @@ -584,7 +584,7 @@ static void RoadVehCrash(Vehicle *v) static void RoadVehCheckTrainCrash(Vehicle *v) { - uint tile; + TileIndex tile; if (v->u.road.state == 255) return; @@ -901,7 +901,7 @@ static byte RoadVehGetSlidingDirection(V typedef struct OvertakeData { Vehicle *u, *v; - uint tile; + TileIndex tile; byte tilebits; } OvertakeData; @@ -1012,7 +1012,7 @@ typedef struct { uint mindist; } FindRoadToChooseData; -static bool EnumRoadTrackFindDist(uint tile, FindRoadToChooseData *frd, int track, uint length, byte *state) +static bool EnumRoadTrackFindDist(TileIndex tile, FindRoadToChooseData *frd, int track, uint length, byte *state) { uint dist = DistanceManhattan(tile, frd->dest); if (dist <= frd->mindist) { @@ -1026,13 +1026,13 @@ static bool EnumRoadTrackFindDist(uint t // Returns direction to choose // or -1 if the direction is currently blocked -static int RoadFindPathToDest(Vehicle *v, uint tile, int enterdir) +static int RoadFindPathToDest(Vehicle *v, TileIndex tile, int enterdir) { #define return_track(x) {best_track = x; goto found_best_track; } uint16 signal; uint bitmask; - uint desttile; + TileIndex desttile; FindRoadToChooseData frd; int best_track; uint best_dist, best_maxlen; @@ -1317,7 +1317,7 @@ static void RoadVehController(Vehicle *v // switch to another tile if (rd.x & 0x80) { - uint tile = v->tile + TileOffsByDir(rd.x & 3); + TileIndex tile = v->tile + TileOffsByDir(rd.x & 3); int dir = RoadFindPathToDest(v, tile, rd.x&3); int tmp; uint32 r; diff --git a/roadveh_gui.c b/roadveh_gui.c --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -410,7 +410,7 @@ static void DrawNewRoadVehWindow(Window } } -void CcBuildRoadVeh(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2) { Vehicle *v; @@ -526,7 +526,7 @@ static void ShowBuildRoadVehWindow(TileI static void DrawRoadDepotWindow(Window *w) { - uint tile; + TileIndex tile; Vehicle *v; int num,x,y; Depot *depot; @@ -753,7 +753,7 @@ static const WindowDesc _road_depot_desc RoadDepotWndProc }; -void ShowRoadDepotWindow(uint tile) +void ShowRoadDepotWindow(TileIndex tile) { Window *w; @@ -909,7 +909,7 @@ static void PlayerRoadVehWndProc(Window } break; case 9: { /* Build new Vehicle */ - uint tile; + TileIndex tile; if (!IsWindowOfPrototype(w, _player_roadveh_widgets)) break; diff --git a/ship_cmd.c b/ship_cmd.c --- a/ship_cmd.c +++ b/ship_cmd.c @@ -19,7 +19,8 @@ static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D}; static const byte _ship_sometracks[4] = {0x19, 0x16, 0x25, 0x2A}; -static byte GetTileShipTrackStatus(uint tile) { +static byte GetTileShipTrackStatus(TileIndex tile) +{ uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER); return r | r >> 8; } @@ -68,8 +69,10 @@ static Depot *FindClosestShipDepot(Vehic { Depot *depot; Depot *best_depot = NULL; - uint tile, dist, best_dist = (uint)-1; - uint tile2 = v->tile; + uint dist; + uint best_dist = (uint)-1; + TileIndex tile; + TileIndex tile2 = v->tile; if (_patches.new_pathfinding_all) { NPFFoundTargetData ftd; @@ -342,7 +345,7 @@ static const TileIndexDiffC _ship_leave_ static void CheckShipLeaveDepot(Vehicle *v) { - uint tile; + TileIndex tile; int d; uint m; @@ -466,15 +469,15 @@ static void ShipArrivesAt(Vehicle *v, St } typedef struct { - uint skiptile; - uint dest_coords; + TileIndex skiptile; + TileIndex dest_coords; uint best_bird_dist; uint best_length; } PathFindShip; //extern void dbg_store_path(); -static bool ShipTrackFollower(uint tile, PathFindShip *pfs, int track, uint length, byte *state) +static bool ShipTrackFollower(TileIndex tile, PathFindShip *pfs, int track, uint length, byte *state) { // Found dest? if (tile == pfs->dest_coords) { @@ -506,7 +509,7 @@ static const byte _ship_search_direction static const byte _pick_shiptrack_table[6] = {1, 3, 2, 2, 0, 0}; -static uint FindShipTrack(Vehicle *v, uint tile, int dir, uint bits, uint skiptile, int *track) +static uint FindShipTrack(Vehicle *v, TileIndex tile, int dir, uint bits, TileIndex skiptile, int *track) { PathFindShip pfs; int i, best_track; @@ -561,14 +564,14 @@ bad:; /* returns the track to choose on the next tile, or -1 when it's better to * reverse. The tile given is the tile we are about to enter, enterdir is the * direction in which we are entering the tile */ -static int ChooseShipTrack(Vehicle *v, uint tile, int enterdir, uint tracks) +static int ChooseShipTrack(Vehicle *v, TileIndex tile, int enterdir, uint tracks) { assert(enterdir>=0 && enterdir<=3); if (_patches.new_pathfinding_all) { NPFFindStationOrTileData fstd; NPFFoundTargetData ftd; - uint src_tile = TILE_ADD(tile, TileOffsByDir(ReverseDiagdir(enterdir))); + TileIndex src_tile = TILE_ADD(tile, TileOffsByDir(ReverseDiagdir(enterdir))); byte trackdir = GetVehicleTrackdir(v); assert (trackdir != 0xFF); /* Check that we are not in a depot */ @@ -588,7 +591,7 @@ static int ChooseShipTrack(Vehicle *v, u uint b; uint tot_dist, dist; int track; - uint tile2; + TileIndex tile2; tile2 = TILE_ADD(tile, -TileOffsByDir(enterdir)); tot_dist = (uint)-1; @@ -615,7 +618,7 @@ static const byte _new_vehicle_direction 2, 3, 4, }; -static int ShipGetNewDirectionFromTiles(uint new_tile, uint old_tile) +static int ShipGetNewDirectionFromTiles(TileIndex new_tile, TileIndex old_tile) { uint offs = (TileY(new_tile) - TileY(old_tile) + 1) * 4 + TileX(new_tile) - TileX(old_tile) + 1; @@ -630,7 +633,7 @@ static int ShipGetNewDirection(Vehicle * return _new_vehicle_direction_table[offs]; } -static int GetAvailShipTracks(uint tile, int dir) +static int GetAvailShipTracks(TileIndex tile, int dir) { uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER); return (byte) ((r | r >> 8)) & _ship_sometracks[dir]; diff --git a/ship_gui.c b/ship_gui.c --- a/ship_gui.c +++ b/ship_gui.c @@ -302,7 +302,7 @@ static void ShowShipDetailsWindow(Vehicl w->caption_color = v->owner; } -void CcBuildShip(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2) { Vehicle *v; if (!success) return; @@ -602,7 +602,7 @@ void ShowShipViewWindow(Vehicle *v) static void DrawShipDepotWindow(Window *w) { - uint tile; + TileIndex tile; Vehicle *v; int num,x,y; Depot *depot; @@ -825,7 +825,7 @@ static const WindowDesc _ship_depot_desc ShipDepotWndProc }; -void ShowShipDepotWindow(uint tile) +void ShowShipDepotWindow(TileIndex tile) { Window *w; @@ -1010,7 +1010,7 @@ static void PlayerShipsWndProc(Window *w } break; case 9: { /* Build new Vehicle */ - uint tile; + TileIndex tile; if (!IsWindowOfPrototype(w, _player_ships_widgets)) break; diff --git a/signs.c b/signs.c --- a/signs.c +++ b/signs.c @@ -186,7 +186,7 @@ int32 CmdRenameSign(int x, int y, uint32 * Callback function that is called after a sign is placed * */ -void CcPlaceSign(bool success, uint tile, uint32 p1, uint32 p2) +void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { ShowRenameSignWindow(_new_sign_struct); @@ -200,7 +200,7 @@ void CcPlaceSign(bool success, uint tile * sign-tool is selected * */ -void PlaceProc_Sign(uint tile) +void PlaceProc_Sign(TileIndex tile) { DoCommandP(tile, _current_player, 0, CcPlaceSign, CMD_PLACE_SIGN | CMD_MSG(STR_2809_CAN_T_PLACE_SIGN_HERE)); } diff --git a/signs.h b/signs.h --- a/signs.h +++ b/signs.h @@ -55,7 +55,7 @@ VARDEF bool _sign_sort_dirty; VARDEF uint16 *_sign_sort; void UpdateAllSignVirtCoords(void); -void PlaceProc_Sign(uint tile); +void PlaceProc_Sign(TileIndex tile); /* misc.c */ void ShowRenameSignWindow(SignStruct *ss); diff --git a/station.h b/station.h --- a/station.h +++ b/station.h @@ -187,7 +187,7 @@ VARDEF bool _global_station_sort_dirty; void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad); void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad); -uint GetStationPlatforms(Station *st, uint tile); +uint GetStationPlatforms(Station *st, TileIndex tile); /* Station layout for given dimensions - it is a two-dimensional array @@ -278,7 +278,8 @@ RoadStop * GetPrimaryRoadStop(const Stat RoadStop * AllocateRoadStop( void ); void ClearSlot(Vehicle *v, RoadStop *rs); -static inline bool IsTrainStationTile(uint tile) { +static inline bool IsTrainStationTile(TileIndex tile) +{ return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8); } @@ -314,7 +315,8 @@ static inline bool IsBuoyTile(TileIndex /* Get's the direction the station exit points towards. Ie, returns 0 for a * station with the exit NE. */ -static inline byte GetRoadStationDir(uint tile) { +static inline byte GetRoadStationDir(TileIndex tile) +{ assert(IsRoadStationTile(tile)); return (_map5[tile] - 0x43) & 3; } diff --git a/station_cmd.c b/station_cmd.c --- a/station_cmd.c +++ b/station_cmd.c @@ -62,7 +62,7 @@ MemoryPool _roadstop_pool = { "RoadStop" const byte _airport_size_x[] = {4, 6, 1, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; const byte _airport_size_y[] = {3, 6, 1, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; -void ShowAircraftDepotWindow(uint tile); +void ShowAircraftDepotWindow(TileIndex tile); extern void UpdateAirplanesOnNewStation(Station *st); static void MarkStationDirty(Station *st) @@ -172,7 +172,7 @@ static byte FindCatchmentRadius(Station #define CHECK_STATIONS_ERR ((Station*)-1) -static Station *GetStationAround(uint tile, int w, int h, int closest_station) +static Station *GetStationAround(TileIndex tile, int w, int h, int closest_station) { // check around to see if there's any stations there BEGIN_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TILE_XY(1,1)) @@ -221,7 +221,7 @@ TileIndex GetStationTileForVehicle(const } } -static bool CheckStationSpreadOut(Station *st, uint tile, int w, int h) +static bool CheckStationSpreadOut(Station *st, TileIndex tile, int w, int h) { StationID station_index = st->index; uint i; @@ -275,7 +275,8 @@ static Station *AllocateStation(void) } -static int CountMapSquareAround(uint tile, byte type, byte min, byte max) { +static int CountMapSquareAround(TileIndex tile, byte type, byte min, byte max) +{ static const TileIndexDiffC _count_square_table[] = { {-3, -3}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {-6, 1}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, @@ -300,7 +301,7 @@ static int CountMapSquareAround(uint til #define M(x) ((x) - STR_SV_STNAME) -static bool GenerateStationName(Station *st, uint tile, int flag) +static bool GenerateStationName(Station *st, TileIndex tile, int flag) { static const uint32 _gen_station_name_bits[] = { 0, /* 0 */ @@ -743,11 +744,11 @@ static void DeleteStationIfEmpty(Station } } -static int32 ClearTile_Station(uint tile, byte flags); +static int32 ClearTile_Station(TileIndex tile, byte flags); // Tries to clear the given area. Returns the cost in case of success. // Or an error code if it failed. -int32 CheckFlatLandBelow(uint tile, uint w, uint h, uint flags, uint invalid_dirs, int *station) +int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *station) { int32 cost = 0, ret; @@ -820,7 +821,7 @@ int32 CheckFlatLandBelow(uint tile, uint static bool CanExpandRailroadStation(Station *st, uint *fin, int direction) { uint curw = st->trainst_w, curh = st->trainst_h; - uint tile = fin[0]; + TileIndex tile = fin[0]; uint w = fin[1]; uint h = fin[2]; @@ -1019,7 +1020,7 @@ int32 CmdBuildRailroadStation(int x, int } if (flags & DC_EXEC) { - int tile_delta; + TileIndexDiff tile_delta; byte *layout_ptr; StationID station_index = st->index; StationSpec *statspec; @@ -1072,7 +1073,7 @@ int32 CmdBuildRailroadStation(int x, int return cost; } -static bool TileBelongsToRailStation(Station *st, uint tile) +static bool TileBelongsToRailStation(Station *st, TileIndex tile) { return IsTileType(tile, MP_STATION) && _map2[tile] == st->index && _map5[tile] < 8; } @@ -1081,7 +1082,7 @@ static void MakeRailwayStationAreaSmalle { uint w = st->trainst_w; uint h = st->trainst_h; - uint tile = st->train_tile; + TileIndex tile = st->train_tile; uint i; restart: @@ -1152,7 +1153,7 @@ int32 CmdRemoveFromRailroadStation(int x } // determine the number of platforms for the station -uint GetStationPlatforms(Station *st, uint tile) +uint GetStationPlatforms(Station *st, TileIndex tile) { uint t; int dir,delta; @@ -1389,7 +1390,7 @@ static int32 RemoveRailroadStation(Stati return cost; } -int32 DoConvertStationRail(uint tile, uint totype, bool exec) +int32 DoConvertStationRail(TileIndex tile, uint totype, bool exec) { const Station *st = GetStation(_map2[tile]); if (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile)) return CMD_ERROR; @@ -1786,7 +1787,7 @@ END_TILE_LOOP(tile_cur,w,h,tile) static int32 RemoveAirport(Station *st, uint32 flags) { - uint tile; + TileIndex tile; int w,h; int32 cost; @@ -1901,7 +1902,7 @@ static bool CheckShipsOnBuoy(Station *st static int32 RemoveBuoy(Station *st, uint32 flags) { - uint tile; + TileIndex tile; if (_current_player >= MAX_PLAYERS) { /* XXX: strange stuff */ @@ -2058,7 +2059,8 @@ int32 CmdBuildDock(int x, int y, uint32 static int32 RemoveDock(Station *st, uint32 flags) { - uint tile1, tile2; + TileIndex tile1; + TileIndex tile2; if (!CheckOwnership(st->owner)) return CMD_ERROR; @@ -2194,12 +2196,12 @@ static uint GetSlopeTileh_Station(TileIn return 0; } -static void GetAcceptedCargo_Station(uint tile, AcceptedCargo ac) +static void GetAcceptedCargo_Station(TileIndex tile, AcceptedCargo ac) { /* not used */ } -static void GetTileDesc_Station(uint tile, TileDesc *td) +static void GetTileDesc_Station(TileIndex tile, TileDesc *td) { byte m5; StringID str; @@ -2220,7 +2222,8 @@ static void GetTileDesc_Station(uint til } -static uint32 GetTileTrackStatus_Station(uint tile, TransportType mode) { +static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode) +{ uint i = _map5[tile]; uint j = 0; @@ -2247,7 +2250,7 @@ static uint32 GetTileTrackStatus_Station return j; } -static void TileLoop_Station(uint tile) +static void TileLoop_Station(TileIndex tile) { //FIXME -- GetTileTrackStatus_Station -> animated stationtiles // hardcoded.....not good @@ -2269,7 +2272,7 @@ static void TileLoop_Station(uint tile) } -static void AnimateTile_Station(uint tile) +static void AnimateTile_Station(TileIndex tile) { byte m5 = _map5[tile]; //FIXME -- AnimateTile_Station -> not nice code, lots of things double @@ -2310,7 +2313,7 @@ static void AnimateTile_Station(uint til } } -static void ClickTile_Station(uint tile) +static void ClickTile_Station(TileIndex tile) { // 0x20 - hangar large airport (32) // 0x41 - hangar small airport (65) @@ -2325,7 +2328,7 @@ static const byte _enter_station_speedta 215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0 }; -static uint32 VehicleEnter_Station(Vehicle *v, uint tile, int x, int y) +static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y) { StationID station_id; byte dir; @@ -2676,7 +2679,7 @@ int32 CmdRenameStation(int x, int y, uin } -uint MoveGoodsToStation(uint tile, int w, int h, int type, uint amount) +uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount) { Station *around_ptr[8]; StationID around[8]; @@ -2813,7 +2816,7 @@ uint MoveGoodsToStation(uint tile, int w return moved; } -void BuildOilRig(uint tile) +void BuildOilRig(TileIndex tile) { Station *st; int j; @@ -2864,7 +2867,7 @@ void BuildOilRig(uint tile) } } -void DeleteOilRig(uint tile) +void DeleteOilRig(TileIndex tile) { Station *st = GetStation(_map2[tile]); @@ -2878,7 +2881,7 @@ void DeleteOilRig(uint tile) DeleteStation(st); } -static void ChangeTileOwner_Station(uint tile, byte old_player, byte new_player) +static void ChangeTileOwner_Station(TileIndex tile, byte old_player, byte new_player) { if (!IsTileOwner(tile, old_player)) return; @@ -2893,7 +2896,8 @@ static void ChangeTileOwner_Station(uint } } -static int32 ClearTile_Station(uint tile, byte flags) { +static int32 ClearTile_Station(TileIndex tile, byte flags) +{ byte m5 = _map5[tile]; Station *st; diff --git a/terraform_gui.c b/terraform_gui.c --- a/terraform_gui.c +++ b/terraform_gui.c @@ -12,7 +12,7 @@ #include "vehicle.h" #include "signs.h" -void CcTerraform(bool success, uint tile, uint32 p1, uint32 p2) +void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_1F_SPLAT, tile); @@ -21,7 +21,7 @@ void CcTerraform(bool success, uint tile } } -static void GenericRaiseLowerLand(uint tile, int mode) +static void GenericRaiseLowerLand(TileIndex tile, int mode) { if (mode) { DoCommandP(tile, 8, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE)); @@ -101,27 +101,27 @@ static const uint16 _terraform_keycodes[ 'O', }; -void PlaceProc_DemolishArea(uint tile) +void PlaceProc_DemolishArea(TileIndex tile) { VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea); } -void PlaceProc_RaiseLand(uint tile) +void PlaceProc_RaiseLand(TileIndex tile) { GenericRaiseLowerLand(tile, 1); } -void PlaceProc_LowerLand(uint tile) +void PlaceProc_LowerLand(TileIndex tile) { GenericRaiseLowerLand(tile, 0); } -void PlaceProc_LevelLand(uint tile) +void PlaceProc_LevelLand(TileIndex tile) { VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_LevelArea); } -static void PlaceProc_PlantTree(uint tile) {} +static void PlaceProc_PlantTree(TileIndex tile) {} static void TerraformClick_Lower(Window *w) { diff --git a/texteff.c b/texteff.c --- a/texteff.c +++ b/texteff.c @@ -320,12 +320,12 @@ void DrawTextEffects(DrawPixelInfo *dpi) } } -void DeleteAnimatedTile(uint tile) +void DeleteAnimatedTile(TileIndex tile) { TileIndex *ti; for(ti=_animated_tile_list; ti!=endof(_animated_tile_list); ti++) { - if ( (TileIndex)tile == *ti) { + if (tile == *ti) { /* remove the hole */ memmove(ti, ti+1, endof(_animated_tile_list) - 1 - ti); /* and clear last item */ @@ -336,12 +336,12 @@ void DeleteAnimatedTile(uint tile) } } -bool AddAnimatedTile(uint tile) +bool AddAnimatedTile(TileIndex tile) { TileIndex *ti; for(ti=_animated_tile_list; ti!=endof(_animated_tile_list); ti++) { - if ( (TileIndex)tile == *ti || *ti == 0) { + if (tile == *ti || *ti == 0) { *ti = tile; MarkTileDirtyByTile(tile); return true; @@ -354,7 +354,7 @@ bool AddAnimatedTile(uint tile) void AnimateAnimatedTiles(void) { TileIndex *ti; - uint tile; + TileIndex tile; for(ti=_animated_tile_list; ti!=endof(_animated_tile_list) && (tile=*ti) != 0; ti++) { AnimateTile(tile); diff --git a/town.h b/town.h --- a/town.h +++ b/town.h @@ -127,7 +127,7 @@ enum { RATING_BRIBE_DOWN_TO = -50 // XXX SHOULD BE SOMETHING LOWER? }; -bool CheckforTownRating(uint tile, uint32 flags, Town *t, byte type); +bool CheckforTownRating(TileIndex tile, uint32 flags, Town *t, byte type); VARDEF uint16 *_town_sort; diff --git a/town_cmd.c b/town_cmd.c --- a/town_cmd.c +++ b/town_cmd.c @@ -52,9 +52,9 @@ enum { // Local static int _grow_town_result; -static bool BuildTownHouse(Town *t, uint tile); -static void ClearTownHouse(Town *t, uint tile); -static void DoBuildTownHouse(Town *t, uint tile); +static bool BuildTownHouse(Town *t, TileIndex tile); +static void ClearTownHouse(Town *t, TileIndex tile); +static void DoBuildTownHouse(Town *t, TileIndex tile); typedef struct DrawTownTileStruct { uint32 sprite_1; @@ -150,7 +150,7 @@ static uint GetSlopeTileh_Town(TileInfo return ti->tileh; } -static void AnimateTile_Town(uint tile) +static void AnimateTile_Town(TileIndex tile) { int old; int i; @@ -188,7 +188,7 @@ static void AnimateTile_Town(uint tile) static void UpdateTownRadius(Town *t); -static bool IsCloseToTown(uint tile, uint dist) +static bool IsCloseToTown(TileIndex tile, uint dist) { Town *t; @@ -242,7 +242,7 @@ uint32 GetWorldPopulation(void) return pop; } -static void MakeSingleHouseBigger(uint tile) +static void MakeSingleHouseBigger(TileIndex tile) { byte b; @@ -265,7 +265,7 @@ static void MakeSingleHouseBigger(uint t MarkTileDirtyByTile(tile); } -static void MakeTownHouseBigger(uint tile) +static void MakeTownHouseBigger(TileIndex tile) { uint flags = _house_more_flags[_map3_hi[tile]]; if (flags & 8) MakeSingleHouseBigger(TILE_ADDXY(tile, 0, 0)); @@ -274,7 +274,7 @@ static void MakeTownHouseBigger(uint til if (flags & 1) MakeSingleHouseBigger(TILE_ADDXY(tile, 1, 1)); } -static void TileLoop_Town(uint tile) +static void TileLoop_Town(TileIndex tile) { int house; Town *t; @@ -330,12 +330,12 @@ static void TileLoop_Town(uint tile) } } -static void ClickTile_Town(uint tile) +static void ClickTile_Town(TileIndex tile) { /* not used */ } -static int32 ClearTile_Town(uint tile, byte flags) +static int32 ClearTile_Town(TileIndex tile, byte flags) { int house, rating; int32 cost; @@ -367,7 +367,7 @@ static int32 ClearTile_Town(uint tile, b return cost; } -static void GetAcceptedCargo_Town(uint tile, AcceptedCargo ac) +static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac) { int type = _map3_hi[tile]; @@ -377,7 +377,7 @@ static void GetAcceptedCargo_Town(uint t ac[CT_FOOD] = _housetype_cargo_food[type]; } -static void GetTileDesc_Town(uint tile, TileDesc *td) +static void GetTileDesc_Town(TileIndex tile, TileDesc *td) { td->str = _town_tile_names[_map3_hi[tile]]; if ((_map3_lo[tile] & 0xC0) != 0xC0) { @@ -388,13 +388,13 @@ static void GetTileDesc_Town(uint tile, td->owner = OWNER_TOWN; } -static uint32 GetTileTrackStatus_Town(uint tile, TransportType mode) +static uint32 GetTileTrackStatus_Town(TileIndex tile, TransportType mode) { /* not used */ return 0; } -static void ChangeTileOwner_Town(uint tile, byte old_player, byte new_player) +static void ChangeTileOwner_Town(TileIndex tile, byte old_player, byte new_player) { /* not used */ } @@ -466,7 +466,7 @@ static byte GetTownRoadMask(TileIndex ti return r; } -static bool IsRoadAllowedHere(uint tile, int dir) +static bool IsRoadAllowedHere(TileIndex tile, int dir) { uint k; uint slope; @@ -528,7 +528,7 @@ no_slope: } } -static bool TerraformTownTile(uint tile, int edges, int dir) +static bool TerraformTownTile(TileIndex tile, int edges, int dir) { int32 r; @@ -541,7 +541,7 @@ static bool TerraformTownTile(uint tile, return true; } -static void LevelTownLand(uint tile) +static void LevelTownLand(TileIndex tile) { TileInfo ti; @@ -560,15 +560,15 @@ static void LevelTownLand(uint tile) #define IS_WATER_TILE(t) (IsTileType((t), MP_WATER) && _map5[(t)] == 0) -static void GrowTownInTile(uint *tile_ptr, uint mask, int block, Town *t1) +static void GrowTownInTile(TileIndex *tile_ptr, uint mask, int block, Town *t1) { uint16 r; int a,b,rcmd; - uint tmptile; + TileIndex tmptile; TileInfo ti; int i; int j; - uint tile = *tile_ptr; + TileIndex tile = *tile_ptr; TILE_ASSERT(tile); @@ -711,7 +711,7 @@ build_road_and_exit: // Returns true if a house was built, or no if the build failed. -static int GrowTownAtRoad(Town *t, uint tile) +static int GrowTownAtRoad(Town *t, TileIndex tile) { uint mask; int block = 5; // special case @@ -772,7 +772,7 @@ static int GenRandomRoadBits(void) // Returns true if a house was built, or no if the build failed. bool GrowTown(Town *t) { - uint tile; + TileIndex tile; const TileIndexDiffC *ptr; TileInfo ti; byte old_player; @@ -1065,7 +1065,7 @@ int32 CmdBuildTown(int x, int y, uint32 Town *CreateRandomTown(uint attempts) { - uint tile; + TileIndex tile; TileInfo ti; Town *t; uint32 townnameparts; @@ -1121,7 +1121,8 @@ void GenerateTowns(void) } } -static bool CheckBuildHouseMode(Town *t1, uint tile, uint tileh, int mode) { +static bool CheckBuildHouseMode(Town *t1, TileIndex tile, uint tileh, int mode) +{ int b; uint slope; @@ -1143,7 +1144,7 @@ static bool CheckBuildHouseMode(Town *t1 return DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR) != CMD_ERROR; } -int GetTownRadiusGroup(Town *t, uint tile) +int GetTownRadiusGroup(Town *t, TileIndex tile) { uint dist; int i,smallest; @@ -1161,7 +1162,7 @@ int GetTownRadiusGroup(Town *t, uint til return smallest; } -static bool CheckFree2x2Area(Town *t1, uint tile) +static bool CheckFree2x2Area(Town *t1, TileIndex tile) { int i; @@ -1185,7 +1186,7 @@ static bool CheckFree2x2Area(Town *t1, u return true; } -static void DoBuildTownHouse(Town *t, uint tile) +static void DoBuildTownHouse(Town *t, TileIndex tile) { int i; uint bitmask; @@ -1358,7 +1359,7 @@ static void DoBuildTownHouse(Town *t, ui // ENDING } -static bool BuildTownHouse(Town *t, uint tile) +static bool BuildTownHouse(Town *t, TileIndex tile) { int32 r; @@ -1374,14 +1375,15 @@ static bool BuildTownHouse(Town *t, uint } -static void DoClearTownHouseHelper(uint tile) +static void DoClearTownHouseHelper(TileIndex tile) { assert(IsTileType(tile, MP_HOUSE)); DoClearSquare(tile); DeleteAnimatedTile(tile); } -static void ClearTownHouse(Town *t, uint tile) { +static void ClearTownHouse(Town *t, TileIndex tile) +{ uint house = _map3_hi[tile]; uint eflags; @@ -1564,7 +1566,7 @@ static void TownActionRoadRebuild(Town * NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_GENERAL, 0), t->xy, 0); } -static bool DoBuildStatueOfCompany(uint tile) +static bool DoBuildStatueOfCompany(TileIndex tile) { TileInfo ti; byte old; @@ -1616,7 +1618,7 @@ static void TownActionBuildStatue(Town * {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, { 0, 0} }; - uint tile = t->xy; + TileIndex tile = t->xy; const TileIndexDiffC *p; SETBIT(t->statues, _current_player); @@ -1811,7 +1813,7 @@ static void UpdateTownUnwanted(Town *t) } } -bool CheckIfAuthorityAllows(uint tile) +bool CheckIfAuthorityAllows(TileIndex tile) { Town *t; @@ -1832,7 +1834,7 @@ bool CheckIfAuthorityAllows(uint tile) } -Town *ClosestTownFromTile(uint tile, uint threshold) +Town *ClosestTownFromTile(TileIndex tile, uint threshold) { Town *t; uint dist, best = threshold; @@ -1892,7 +1894,7 @@ static const int _default_rating_setting { 96, 384, 768}, // Hostile }; -bool CheckforTownRating(uint tile, uint32 flags, Town *t, byte type) +bool CheckforTownRating(TileIndex tile, uint32 flags, Town *t, byte type) { int modemod; diff --git a/train_cmd.c b/train_cmd.c --- a/train_cmd.c +++ b/train_cmd.c @@ -415,7 +415,7 @@ void DrawTrainEngineInfo(int engine, int } -static int32 CmdBuildRailWagon(uint engine, uint tile, uint32 flags) +static int32 CmdBuildRailWagon(uint engine, TileIndex tile, uint32 flags) { int32 value; Vehicle *v; @@ -1506,7 +1506,7 @@ int32 CmdRefitRailVehicle(int x, int y, typedef struct TrainFindDepotData { uint best_length; - uint tile; + TileIndex tile; byte owner; /** * true if reversing is necesarry for the train to get to this depot This @@ -1515,7 +1515,7 @@ typedef struct TrainFindDepotData { bool reverse; } TrainFindDepotData; -static bool TrainFindDepotEnumProc(uint tile, TrainFindDepotData *tfdd, int track, uint length, byte *state) +static bool TrainFindDepotEnumProc(TileIndex tile, TrainFindDepotData *tfdd, int track, uint length, byte *state) { if (IsTileType(tile, MP_RAILWAY) && IsTileOwner(tile, tfdd->owner)) { if ((_map5[tile] & ~0x3) == 0xC0) { @@ -1543,7 +1543,7 @@ static TrainFindDepotData FindClosestTra { int i; TrainFindDepotData tfdd; - uint tile = v->tile; + TileIndex tile = v->tile; assert(!(v->vehstatus & VS_CRASHED)); @@ -1807,7 +1807,8 @@ typedef struct TrainTrackFollowerData { byte best_track; } TrainTrackFollowerData; -static bool TrainTrackFollower(uint tile, TrainTrackFollowerData *ttfd, int track, uint length, byte *state){ +static bool TrainTrackFollower(TileIndex tile, TrainTrackFollowerData *ttfd, int track, uint length, byte *state) +{ if (IsTileType(tile, MP_RAILWAY) && (_map5[tile]&0xC0) == 0x40) { // the tile has a signal byte m3 = _map3_lo[tile]; @@ -1907,7 +1908,7 @@ unsigned int rdtsc() /* choose a track */ -static byte ChooseTrainTrack(Vehicle *v, uint tile, int enterdir, TrackdirBits trackdirbits) +static byte ChooseTrainTrack(Vehicle *v, TileIndex tile, int enterdir, TrackdirBits trackdirbits) { TrainTrackFollowerData fd; uint best_track; @@ -2384,7 +2385,7 @@ static const byte _new_vehicle_direction 2, 3, 4, }; -static int GetNewVehicleDirectionByTile(uint new_tile, uint old_tile) +static int GetNewVehicleDirectionByTile(TileIndex new_tile, TileIndex old_tile) { uint offs = (TileY(new_tile) - TileY(old_tile) + 1) * 4 + TileX(new_tile) - TileX(old_tile) + 1; @@ -2506,7 +2507,7 @@ static const byte _otherside_signal_dire 5, 7, 7, 5, 7, 1, }; -static void TrainMovedChangeSignals(uint tile, int dir) +static void TrainMovedChangeSignals(TileIndex tile, int dir) { int i; if (IsTileType(tile, MP_RAILWAY) && (_map5[tile] & 0xC0) == 0x40) { @@ -3005,7 +3006,7 @@ static const byte _breakdown_speeds[16] static bool TrainCheckIfLineEnds(Vehicle *v) { - uint tile; + TileIndex tile; uint x,y; int t; uint32 ts; @@ -3208,7 +3209,7 @@ static bool ValidateTrainInDepot( uint d return (v->u.rail.track == 0x80 && (v->vehstatus | VS_STOPPED)); } -void TrainEnterDepot(Vehicle *v, uint tile) +void TrainEnterDepot(Vehicle *v, TileIndex tile) { SetSignalsOnBothDir(tile, _depot_track_ind[_map5[tile]&3]); diff --git a/train_gui.c b/train_gui.c --- a/train_gui.c +++ b/train_gui.c @@ -108,7 +108,7 @@ void DrawTrainWagonPurchaseInfo(int x, i y += 10; } -void CcBuildWagon(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2) { Vehicle *v,*found; @@ -136,7 +136,7 @@ void CcBuildWagon(bool success, uint til } } -void CcBuildLoco(bool success, uint tile, uint32 p1, uint32 p2) +void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2) { Vehicle *v; @@ -304,7 +304,7 @@ static const WindowDesc _new_rail_vehicl NewRailVehicleWndProc }; -static void ShowBuildTrainWindow(uint tile) +static void ShowBuildTrainWindow(TileIndex tile) { Window *w; @@ -354,7 +354,7 @@ static void DrawTrainImage(const Vehicle static void DrawTrainDepotWindow(Window *w) { - uint tile; + TileIndex tile; Vehicle *v, *u; int num,x,y,i, hnum; Depot *depot; @@ -701,7 +701,7 @@ static const WindowDesc _train_depot_des }; -void ShowTrainDepotWindow(uint tile) +void ShowTrainDepotWindow(TileIndex tile) { Window *w; @@ -1391,7 +1391,7 @@ static void PlayerTrainsWndProc(Window * } break; case 9: { /* Build new Vehicle */ - uint tile; + TileIndex tile; if (!IsWindowOfPrototype(w, _player_trains_widgets)) break; diff --git a/tree_cmd.c b/tree_cmd.c --- a/tree_cmd.c +++ b/tree_cmd.c @@ -35,7 +35,7 @@ static int GetRandomTreeType(TileIndex t } } -static void PlaceTree(uint tile, uint32 r, byte m5_or) +static void PlaceTree(TileIndex tile, uint32 r, byte m5_or) { int tree = GetRandomTreeType(tile, (r >> 24)); byte m5; @@ -66,15 +66,16 @@ static void PlaceTree(uint tile, uint32 } } -static void DoPlaceMoreTrees(uint tile) +static void DoPlaceMoreTrees(TileIndex tile) { int i = 1000; int x,y; - uint cur_tile; int dist; do { uint32 r = Random(); + TileIndex cur_tile; + x = (r & 0x1F) - 16; y = ((r>>8) & 0x1F) - 16; @@ -103,7 +104,7 @@ void PlaceTreesRandomly(void) { int i; uint32 r; - uint tile; + TileIndex tile; i = ScaleByMapSize(1000); do { @@ -367,7 +368,8 @@ static uint GetSlopeTileh_Trees(TileInfo return ti->tileh; } -static int32 ClearTile_Trees(uint tile, byte flags) { +static int32 ClearTile_Trees(TileIndex tile, byte flags) +{ int num; if (flags & DC_EXEC && _current_player < MAX_PLAYERS) { @@ -386,12 +388,12 @@ static int32 ClearTile_Trees(uint tile, return num * _price.remove_trees; } -static void GetAcceptedCargo_Trees(uint tile, AcceptedCargo ac) +static void GetAcceptedCargo_Trees(TileIndex tile, AcceptedCargo ac) { /* not used */ } -static void GetTileDesc_Trees(uint tile, TileDesc *td) +static void GetTileDesc_Trees(TileIndex tile, TileDesc *td) { byte b; StringID str; @@ -405,7 +407,7 @@ static void GetTileDesc_Trees(uint tile, td->str = str; } -static void AnimateTile_Trees(uint tile) +static void AnimateTile_Trees(TileIndex tile) { /* not used */ } @@ -417,7 +419,7 @@ static SoundFx _desert_sounds[] = { SND_48_DISTANT_BIRD }; -static void TileLoopTreesDesert(uint tile) +static void TileLoopTreesDesert(TileIndex tile) { byte b; @@ -436,7 +438,7 @@ static void TileLoopTreesDesert(uint til } } -static void TileLoopTreesAlps(uint tile) +static void TileLoopTreesAlps(TileIndex tile) { byte tmp, m2; int k; @@ -484,7 +486,7 @@ static void TileLoopTreesAlps(uint tile) MarkTileDirtyByTile(tile); } -static void TileLoop_Trees(uint tile) +static void TileLoop_Trees(TileIndex tile) { byte m5; uint16 m2; @@ -594,7 +596,7 @@ static void TileLoop_Trees(uint tile) void OnTick_Trees(void) { uint32 r; - uint tile; + TileIndex tile; byte m; int tree; @@ -646,17 +648,17 @@ void OnTick_Trees(void) } } -static void ClickTile_Trees(uint tile) +static void ClickTile_Trees(TileIndex tile) { /* not used */ } -static uint32 GetTileTrackStatus_Trees(uint tile, TransportType mode) +static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode) { return 0; } -static void ChangeTileOwner_Trees(uint tile, byte old_player, byte new_player) +static void ChangeTileOwner_Trees(TileIndex tile, byte old_player, byte new_player) { /* not used */ } diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -11,7 +11,7 @@ #include "town.h" #include "sound.h" -extern void DrawCanalWater(uint tile); +extern void DrawCanalWater(TileIndex tile); static const byte _bridge_available_year[MAX_BRIDGES] = { 0, 0, 10, 0, 10, 10, 10, 10, 10, 10, 75, 85, 90 @@ -400,12 +400,10 @@ not_valid_below:; return cost; } -static bool DoCheckTunnelInWay(uint tile, uint z, uint dir) +static bool DoCheckTunnelInWay(TileIndex tile, uint z, uint dir) { + TileIndexDiff delta = TileOffsByDir(dir); TileInfo ti; - int delta; - - delta = TileOffsByDir(dir); do { tile -= delta; @@ -420,7 +418,7 @@ static bool DoCheckTunnelInWay(uint tile return true; } -bool CheckTunnelInWay(uint tile, int z) +bool CheckTunnelInWay(TileIndex tile, int z) { return DoCheckTunnelInWay(tile,z,0) && DoCheckTunnelInWay(tile,z,1) && @@ -593,7 +591,7 @@ TileIndex CheckTunnelBusy(TileIndex tile byte m5 = _map5[tile]; int delta = TileOffsByDir(m5 & 3); uint len = 0; - uint starttile = tile; + TileIndex starttile = tile; Vehicle *v; do { @@ -617,7 +615,7 @@ TileIndex CheckTunnelBusy(TileIndex tile return tile; } -static int32 DoClearTunnel(uint tile, uint32 flags) +static int32 DoClearTunnel(TileIndex tile, uint32 flags) { Town *t; TileIndex endtile; @@ -662,10 +660,10 @@ static int32 DoClearTunnel(uint tile, ui return _price.clear_tunnel * (length + 1); } -static uint FindEdgesOfBridge(uint tile, uint *endtile) +static TileIndex FindEdgesOfBridge(TileIndex tile, TileIndex *endtile) { int direction = _map5[tile] & 1; - uint start; + TileIndex start; // find start of bridge for(;;) { @@ -688,9 +686,9 @@ static uint FindEdgesOfBridge(uint tile, return start; } -static int32 DoClearBridge(uint tile, uint32 flags) +static int32 DoClearBridge(TileIndex tile, uint32 flags) { - uint endtile; + TileIndex endtile; Vehicle *v; Town *t; int direction; @@ -811,7 +809,8 @@ clear_it:; return ((((endtile - tile) >> (direction?8:0))&0xFF)+1) * _price.clear_bridge; } -static int32 ClearTile_TunnelBridge(uint tile, byte flags) { +static int32 ClearTile_TunnelBridge(TileIndex tile, byte flags) +{ byte m5 = _map5[tile]; if ((m5 & 0xF0) == 0) { @@ -829,7 +828,7 @@ static int32 ClearTile_TunnelBridge(uint return CMD_ERROR; } -int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec) +int32 DoConvertTunnelBridgeRail(TileIndex tile, uint totype, bool exec) { TileIndex endtile; uint length; @@ -1229,7 +1228,7 @@ static uint GetSlopeTileh_TunnelBridge(T } -static void GetAcceptedCargo_TunnelBridge(uint tile, AcceptedCargo ac) +static void GetAcceptedCargo_TunnelBridge(TileIndex tile, AcceptedCargo ac) { /* not used */ } @@ -1266,7 +1265,7 @@ static const StringID _bridge_tile_str[( 0,0,0, }; -static void GetTileDesc_TunnelBridge(uint tile, TileDesc *td) +static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td) { int delta; @@ -1285,12 +1284,12 @@ static void GetTileDesc_TunnelBridge(uin } -static void AnimateTile_TunnelBridge(uint tile) +static void AnimateTile_TunnelBridge(TileIndex tile) { /* not used */ } -static void TileLoop_TunnelBridge(uint tile) +static void TileLoop_TunnelBridge(TileIndex tile) { if (_opt.landscape == LT_HILLY) { if ( GetTileZ(tile) > _opt.snow_line) { @@ -1315,13 +1314,13 @@ static void TileLoop_TunnelBridge(uint t if ((_map5[tile] & 0xF8) == 0xC8) TileLoop_Water(tile); } -static void ClickTile_TunnelBridge(uint tile) +static void ClickTile_TunnelBridge(TileIndex tile) { /* not used */ } -static uint32 GetTileTrackStatus_TunnelBridge(uint tile, TransportType mode) +static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode) { uint32 result; byte m5 = _map5[tile]; @@ -1368,7 +1367,7 @@ static uint32 GetTileTrackStatus_TunnelB return 0; } -static void ChangeTileOwner_TunnelBridge(uint tile, byte old_player, byte new_player) +static void ChangeTileOwner_TunnelBridge(TileIndex tile, byte old_player, byte new_player) { if (!IsTileOwner(tile, old_player)) return; @@ -1404,7 +1403,7 @@ static const byte _tunnel_fractcoord_5[4 static const byte _tunnel_fractcoord_6[4] = {0x92, 0x89, 0x56, 0x45}; static const byte _tunnel_fractcoord_7[4] = {0x52, 0x85, 0x96, 0x49}; -static uint32 VehicleEnter_TunnelBridge(Vehicle *v, uint tile, int x, int y) +static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y) { int z; int dir, vdir; diff --git a/unmovable_cmd.c b/unmovable_cmd.c --- a/unmovable_cmd.c +++ b/unmovable_cmd.c @@ -58,7 +58,7 @@ int32 DestroyCompanyHQ(TileIndex tile, u * @param p1 relocate HQ (set to some value, usually 1 or true) * @param p2 unused */ - extern int32 CheckFlatLandBelow(uint tile, uint w, uint h, uint flags, uint invalid_dirs, int *); +extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *); int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2) { TileIndex tile = TILE_FROM_XY(x,y); @@ -193,7 +193,7 @@ static uint GetSlopeTileh_Unmovable(Tile return 0; } -static int32 ClearTile_Unmovable(uint tile, byte flags) +static int32 ClearTile_Unmovable(TileIndex tile, byte flags) { byte m5 = _map5[tile]; @@ -216,7 +216,7 @@ static int32 ClearTile_Unmovable(uint ti return 0; } -static void GetAcceptedCargo_Unmovable(uint tile, AcceptedCargo ac) +static void GetAcceptedCargo_Unmovable(TileIndex tile, AcceptedCargo ac) { byte m5 = _map5[tile]; uint level; // HQ level (depends on company performance) in the range 1..5. @@ -250,7 +250,7 @@ static const StringID _unmovable_tile_st STR_5805_COMPANY_OWNED_LAND, }; -static void GetTileDesc_Unmovable(uint tile, TileDesc *td) +static void GetTileDesc_Unmovable(TileIndex tile, TileDesc *td) { int i = _map5[tile]; if (i & 0x80) i = -1; @@ -258,12 +258,12 @@ static void GetTileDesc_Unmovable(uint t td->owner = GetTileOwner(tile); } -static void AnimateTile_Unmovable(uint tile) +static void AnimateTile_Unmovable(TileIndex tile) { /* not used */ } -static void TileLoop_Unmovable(uint tile) +static void TileLoop_Unmovable(TileIndex tile) { byte m5 = _map5[tile]; byte level; // HQ level (depends on company performance) in the range 1..5. @@ -300,12 +300,12 @@ static void TileLoop_Unmovable(uint tile } -static uint32 GetTileTrackStatus_Unmovable(uint tile, TransportType mode) +static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode) { return 0; } -static void ClickTile_Unmovable(uint tile) +static void ClickTile_Unmovable(TileIndex tile) { if (_map5[tile] & 0x80) { ShowPlayerCompany(GetTileOwner(tile)); @@ -320,9 +320,9 @@ static const TileIndexDiffC _tile_add[] }; /* checks, if a radio tower is within a 9x9 tile square around tile */ -static bool checkRadioTowerNearby(uint tile) +static bool checkRadioTowerNearby(TileIndex tile) { - uint tile_s; + TileIndex tile_s; tile_s = TILE_XY(TileX(tile) - 4, TileY(tile) - 4); @@ -337,7 +337,7 @@ static bool checkRadioTowerNearby(uint t void GenerateUnmovables(void) { int i,j; - uint tile; + TileIndex tile; uint32 r; int dir; uint h; @@ -394,7 +394,7 @@ restart: } while (--i); } -static void ChangeTileOwner_Unmovable(uint tile, byte old_player, byte new_player) +static void ChangeTileOwner_Unmovable(TileIndex tile, byte old_player, byte new_player) { if (!IsTileOwner(tile, old_player)) return; diff --git a/variables.h b/variables.h --- a/variables.h +++ b/variables.h @@ -313,7 +313,7 @@ VARDEF bool _rightclick_emulate; // IN/OUT parameters to commands VARDEF byte _yearly_expenses_type; VARDEF TileIndex _terraform_err_tile; -VARDEF uint _build_tunnel_endtile; +VARDEF TileIndex _build_tunnel_endtile; VARDEF bool _generating_world; VARDEF int _new_town_size; VARDEF uint _returned_refit_amount; diff --git a/vehicle.c b/vehicle.c --- a/vehicle.c +++ b/vehicle.c @@ -1775,9 +1775,9 @@ Trackdir GetVehicleTrackdir(const Vehicl * result << 8 contains the id of the station entered. If the return value has * bit 0x8 set, the vehicle could not and did not enter the tile. Are there * other bits that can be set? */ -uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y) +uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y) { - uint old_tile = v->tile; + TileIndex old_tile = v->tile; uint32 result = _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y); /* When vehicle_enter_tile_proc returns 8, that apparently means that diff --git a/vehicle.h b/vehicle.h --- a/vehicle.h +++ b/vehicle.h @@ -275,7 +275,7 @@ bool CanRefitTo(const Vehicle *v, CargoI void ViewportAddVehicles(DrawPixelInfo *dpi); -void TrainEnterDepot(Vehicle *v, uint tile); +void TrainEnterDepot(Vehicle *v, TileIndex tile); void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool building) ; @@ -289,14 +289,14 @@ Vehicle *CreateEffectVehicle(int x, int Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type); Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicle type); -uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y); +uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y); void VehicleInTheWayErrMsg(Vehicle *v); Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z); TileIndex GetVehicleOutOfTunnelTile(const Vehicle *v); -bool UpdateSignalsOnSegment(uint tile, byte direction); -void SetSignalsOnBothDir(uint tile, byte track); +bool UpdateSignalsOnSegment(TileIndex tile, byte direction); +void SetSignalsOnBothDir(TileIndex tile, byte track); Vehicle *CheckClickOnVehicle(ViewPort *vp, int x, int y); //uint GetVehicleWeight(Vehicle *v); @@ -326,8 +326,8 @@ bool VehicleNeedsService(const Vehicle * typedef struct GetNewVehiclePosResult { int x,y; - uint old_tile; - uint new_tile; + TileIndex old_tile; + TileIndex new_tile; } GetNewVehiclePosResult; /** diff --git a/viewport.c b/viewport.c --- a/viewport.c +++ b/viewport.c @@ -549,10 +549,10 @@ void *AddStringToDraw(int x, int y, Stri #ifdef DEBUG_TILE_PUSH static int _num_push; -static uint _pushed_tile[200]; +static TileIndex _pushed_tile[200]; static int _pushed_track[200]; -static uint _stored_tile[200]; +static TileIndex _stored_tile[200]; static int _stored_track[200]; static int _num_stored; @@ -564,7 +564,7 @@ void dbg_store_path(void) MarkWholeScreenDirty(); } -void dbg_push_tile(uint tile, int track) +void dbg_push_tile(TileIndex tile, int track) { _pushed_tile[_num_push] = tile; _pushed_track[_num_push++] = track; @@ -684,7 +684,7 @@ static void DrawTileSelection(const Tile } else if (IsPartOfAutoLine(ti->x, ti->y)) { // autorail highlighting long line int dir = _thd.drawstyle & ~0xF0; - uint start = TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y); + TileIndex start = TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y); int diffx, diffy; int side; @@ -1698,10 +1698,8 @@ static bool CheckClickOnWaypoint(ViewPor static void CheckClickOnLandscape(ViewPort *vp, int x, int y) { Point pt = TranslateXYToTileCoord(vp,x,y); - if (pt.x != -1) { - uint tile = TILE_FROM_XY(pt.x, pt.y); - ClickTile(tile); - } + + if (pt.x != -1) ClickTile(TILE_FROM_XY(pt.x, pt.y)); } void HandleClickOnTrain(Vehicle *v); @@ -1942,7 +1940,7 @@ void UpdateTileSelection(void) } // highlighting tiles while only going over them with the mouse -void VpStartPlaceSizing(uint tile, int user) +void VpStartPlaceSizing(TileIndex tile, int user) { _thd.userdata = user; _thd.selend.x = TileX(tile) * 16; diff --git a/viewport.h b/viewport.h --- a/viewport.h +++ b/viewport.h @@ -40,7 +40,7 @@ void SetRedErrorSquare(TileIndex tile); void SetTileSelectSize(int w, int h); void SetTileSelectBigSize(int ox, int oy, int sx, int sy); -void VpStartPlaceSizing(uint tile, int user); +void VpStartPlaceSizing(TileIndex tile, int user); void VpStartPreSizing(void); void VpSetPresizeRange(uint from, uint to); void VpSetPlaceSizingLimit(int limit); diff --git a/water_cmd.c b/water_cmd.c --- a/water_cmd.c +++ b/water_cmd.c @@ -15,7 +15,7 @@ static void FloodVehicle(Vehicle *v); -static bool IsClearWaterTile(uint tile) +static bool IsClearWaterTile(TileIndex tile) { TileInfo ti; FindLandscapeHeightByTile(&ti, tile); @@ -77,9 +77,9 @@ int32 CmdBuildShipDepot(int x, int y, ui return cost + _price.build_ship_depot; } -static int32 RemoveShipDepot(uint tile, uint32 flags) +static int32 RemoveShipDepot(TileIndex tile, uint32 flags) { - uint tile2; + TileIndex tile2; if (!CheckTileOwnership(tile)) return CMD_ERROR; @@ -105,7 +105,7 @@ static int32 RemoveShipDepot(uint tile, } // build a shiplift -static int32 DoBuildShiplift(uint tile, int dir, uint32 flags) +static int32 DoBuildShiplift(TileIndex tile, int dir, uint32 flags) { int32 ret; int delta; @@ -134,7 +134,7 @@ static int32 DoBuildShiplift(uint tile, return _price.clear_water * 22 >> 3; } -static int32 RemoveShiplift(uint tile, uint32 flags) +static int32 RemoveShiplift(TileIndex tile, uint32 flags) { TileIndexDiff delta = TileOffsByDir(_map5[tile] & 3); @@ -151,7 +151,7 @@ static int32 RemoveShiplift(uint tile, u return _price.clear_water * 2; } -static void MarkTilesAroundDirty(uint tile) +static void MarkTilesAroundDirty(TileIndex tile) { MarkTileDirtyByTile(TILE_ADDXY(tile, 0, 1)); MarkTileDirtyByTile(TILE_ADDXY(tile, 0, -1)); @@ -251,7 +251,8 @@ int32 CmdBuildCanal(int x, int y, uint32 return (cost == 0) ? CMD_ERROR : cost; } -static int32 ClearTile_Water(uint tile, byte flags) { +static int32 ClearTile_Water(TileIndex tile, byte flags) +{ byte m5 = _map5[tile]; uint slope; @@ -339,7 +340,7 @@ static bool IsWateredTile(TileIndex tile } // draw a canal styled water tile with dikes around -void DrawCanalWater(uint tile) +void DrawCanalWater(TileIndex tile) { uint wa; @@ -447,12 +448,12 @@ static uint GetSlopeTileh_Water(TileInfo return ti->tileh; } -static void GetAcceptedCargo_Water(uint tile, AcceptedCargo ac) +static void GetAcceptedCargo_Water(TileIndex tile, AcceptedCargo ac) { /* not used */ } -static void GetTileDesc_Water(uint tile, TileDesc *td) +static void GetTileDesc_Water(TileIndex tile, TileDesc *td) { if (_map5[tile] == 0 && TilePixelHeight(tile) == 0) td->str = STR_3804_WATER; @@ -468,7 +469,7 @@ static void GetTileDesc_Water(uint tile, td->owner = GetTileOwner(tile); } -static void AnimateTile_Water(uint tile) +static void AnimateTile_Water(TileIndex tile) { /* not used */ } @@ -602,7 +603,7 @@ static void FloodVehicle(Vehicle *v) } // called from tunnelbridge_cmd -void TileLoop_Water(uint tile) +void TileLoop_Water(TileIndex tile) { int i; static const TileIndexDiffC _tile_loop_offs_array[][5] = { @@ -641,7 +642,7 @@ void TileLoop_Water(uint tile) static const byte _coast_tracks[16] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0}; static const byte _shipdepot_tracks[4] = {1,1,2,2}; static const byte _shiplift_tracks[12] = {1,2,1,2,1,2,1,2,1,2,1,2}; -static uint32 GetTileTrackStatus_Water(uint tile, TransportType mode) +static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode) { uint m5; uint b; @@ -671,9 +672,9 @@ static uint32 GetTileTrackStatus_Water(u return b + (b<<8); } -extern void ShowShipDepotWindow(uint tile); +extern void ShowShipDepotWindow(TileIndex tile); -static void ClickTile_Water(uint tile) +static void ClickTile_Water(TileIndex tile) { byte m5 = _map5[tile] - 0x80; @@ -684,7 +685,7 @@ static void ClickTile_Water(uint tile) } } -static void ChangeTileOwner_Water(uint tile, byte old_player, byte new_player) +static void ChangeTileOwner_Water(TileIndex tile, byte old_player, byte new_player) { if (!IsTileOwner(tile, old_player)) return; @@ -695,7 +696,7 @@ static void ChangeTileOwner_Water(uint t } } -static uint32 VehicleEnter_Water(Vehicle *v, uint tile, int x, int y) +static uint32 VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y) { return 0; } diff --git a/waypoint.c b/waypoint.c --- a/waypoint.c +++ b/waypoint.c @@ -129,7 +129,7 @@ void MakeDefaultWaypointName(Waypoint *w } /* Find a deleted waypoint close to a tile. */ -static Waypoint *FindDeletedWaypointCloseTo(uint tile) +static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile) { Waypoint *wp, *best = NULL; uint thres = 8, cur_dist; @@ -243,7 +243,7 @@ void WaypointsDailyLoop(void) } /* Remove a waypoint */ -int32 RemoveTrainWaypoint(uint tile, uint32 flags, bool justremove) +int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove) { Waypoint *wp; @@ -335,7 +335,7 @@ int32 CmdRenameWaypoint(int x, int y, ui } /* This hacks together some dummy one-shot Station structure for a waypoint. */ -Station *ComposeWaypointStation(uint tile) +Station *ComposeWaypointStation(TileIndex tile) { Waypoint *wp = GetWaypointByTile(tile); static Station stat; diff --git a/waypoint.h b/waypoint.h --- a/waypoint.h +++ b/waypoint.h @@ -53,8 +53,8 @@ static inline bool IsRailWaypoint(byte m return (m5 & 0xFC) == 0xC4; } -int32 RemoveTrainWaypoint(uint tile, uint32 flags, bool justremove); -Station *ComposeWaypointStation(uint tile); +int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove); +Station *ComposeWaypointStation(TileIndex tile); Waypoint *GetWaypointByTile(TileIndex tile); void ShowRenameWaypointWindow(Waypoint *cp); void DrawWaypointSprite(int x, int y, int image, int railtype); diff --git a/window.h b/window.h --- a/window.h +++ b/window.h @@ -84,8 +84,8 @@ union WindowEvent { struct { byte event; Point pt; - uint tile; - uint starttile; + TileIndex tile; + TileIndex starttile; int userdata; } place;