diff options
author | rubidium <rubidium@openttd.org> | 2010-01-04 18:21:07 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-01-04 18:21:07 +0000 |
commit | 87466a4ed091035b758ef981e6600e2b03cbfe30 (patch) | |
tree | b5a79792fb0f12f7f3a96e400091c1fda26de9c5 /src | |
parent | 71f2789270ca091af14ab4cfd64a4f17234cf007 (diff) | |
download | openttd-87466a4ed091035b758ef981e6600e2b03cbfe30.tar.xz |
(svn r18717) -Codechange: use TileArea in industry instead of three separate variables. Also make use of TileArea functions for determining the 'width' and 'height' of an industry.
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/api/ai_industry.cpp | 8 | ||||
-rw-r--r-- | src/ai/api/ai_tilelist.cpp | 4 | ||||
-rw-r--r-- | src/disaster_cmd.cpp | 14 | ||||
-rw-r--r-- | src/economy.cpp | 2 | ||||
-rw-r--r-- | src/industry.h | 7 | ||||
-rw-r--r-- | src/industry_cmd.cpp | 45 | ||||
-rw-r--r-- | src/industry_gui.cpp | 14 | ||||
-rw-r--r-- | src/newgrf_industries.cpp | 22 | ||||
-rw-r--r-- | src/newgrf_industrytiles.cpp | 10 | ||||
-rw-r--r-- | src/news_gui.cpp | 2 | ||||
-rw-r--r-- | src/saveload/industry_sl.cpp | 8 | ||||
-rw-r--r-- | src/saveload/oldloader_sl.cpp | 8 | ||||
-rw-r--r-- | src/subsidy.cpp | 4 | ||||
-rw-r--r-- | src/subsidy_gui.cpp | 4 |
14 files changed, 71 insertions, 81 deletions
diff --git a/src/ai/api/ai_industry.cpp b/src/ai/api/ai_industry.cpp index d9fcf36eb..cf715d34e 100644 --- a/src/ai/api/ai_industry.cpp +++ b/src/ai/api/ai_industry.cpp @@ -115,7 +115,7 @@ { if (!IsValidIndustry(industry_id)) return INVALID_TILE; - return ::Industry::Get(industry_id)->xy; + return ::Industry::Get(industry_id)->location.tile; } /* static */ int32 AIIndustry::GetAmountOfStationsAround(IndustryID industry_id) @@ -124,7 +124,7 @@ Industry *ind = ::Industry::Get(industry_id); StationList stations; - ::FindStationsAroundTiles(TileArea(ind->xy, ind->width, ind->height), &stations); + ::FindStationsAroundTiles(ind->location, &stations); return (int32)stations.Length(); } @@ -162,7 +162,7 @@ if (!HasHeliport(industry_id)) return INVALID_TILE; const Industry *ind = ::Industry::Get(industry_id); - TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy) { + TILE_LOOP(tile_cur, ind->location.w, ind->location.h, ind->location.tile) { if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) { return tile_cur; } @@ -184,7 +184,7 @@ if (!HasDock(industry_id)) return INVALID_TILE; const Industry *ind = ::Industry::Get(industry_id); - TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy) { + TILE_LOOP(tile_cur, ind->location.w, ind->location.h, ind->location.tile) { if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) { return tile_cur; } diff --git a/src/ai/api/ai_tilelist.cpp b/src/ai/api/ai_tilelist.cpp index 22ce7968d..2cf5ca661 100644 --- a/src/ai/api/ai_tilelist.cpp +++ b/src/ai/api/ai_tilelist.cpp @@ -86,7 +86,7 @@ AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_i if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED; - TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) { + TILE_LOOP(cur_tile, i->location.w + radius * 2, i->location.h+ radius * 2, i->location.tile - ::TileDiffXY(radius, radius)) { if (!::IsValidTile(cur_tile)) continue; /* Exclude all tiles that belong to this industry */ if (::IsTileType(cur_tile, MP_INDUSTRY) && ::GetIndustryIndex(cur_tile) == industry_id) continue; @@ -123,7 +123,7 @@ AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_i if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED; - TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) { + TILE_LOOP(cur_tile, i->location.w + radius * 2, i->location.h+ radius * 2, i->location.tile - ::TileDiffXY(radius, radius)) { if (!::IsValidTile(cur_tile)) continue; /* Exclude all tiles that belong to this industry */ if (::IsTileType(cur_tile, MP_INDUSTRY) && ::GetIndustryIndex(cur_tile) == industry_id) continue; diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index f2b9badec..3dec6e5e0 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -401,8 +401,8 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, boo if (v->current_order.GetDestination() == 2) { if (GB(v->tick_counter, 0, 2) == 0) { Industry *i = Industry::Get(v->dest_tile); // Industry destructor calls ReleaseDisastersTargetingIndustry, so this is valid - int x = TileX(i->xy) * TILE_SIZE; - int y = TileY(i->xy) * TILE_SIZE; + int x = TileX(i->location.tile) * TILE_SIZE; + int y = TileY(i->location.tile) * TILE_SIZE; uint32 r = Random(); CreateEffectVehicleAbove( @@ -423,7 +423,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, boo SetDParam(0, i->town->index); AddIndustryNewsItem(news_message, NS_ACCIDENT, i->index); // delete the news, when the industry closes - SndPlayTileFx(SND_12_EXPLOSION, i->xy); + SndPlayTileFx(SND_12_EXPLOSION, i->location.tile); } } else if (v->current_order.GetDestination() == 0) { int x = v->x_pos - (15 * TILE_SIZE); @@ -742,7 +742,7 @@ static void Disaster_Airplane_Init() /* Start from the bottom (south side) of the map */ int x = (MapSizeX() + 9) * TILE_SIZE - 1; - int y = TileY(found->xy) * TILE_SIZE + 37; + int y = TileY(found->location.tile) * TILE_SIZE + 37; InitializeDisasterVehicle(v, x, y, 135, DIR_NE, ST_AIRPLANE); @@ -772,7 +772,7 @@ static void Disaster_Helicopter_Init() DisasterVehicle *v = new DisasterVehicle(); int x = -16 * TILE_SIZE; - int y = TileY(found->xy) * TILE_SIZE + 37; + int y = TileY(found->location.tile) * TILE_SIZE + 37; InitializeDisasterVehicle(v, x, y, 135, DIR_SW, ST_HELICOPTER); @@ -861,10 +861,10 @@ static void Disaster_CoalMine_Init() if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) { SetDParam(0, i->town->index); AddNewsItem(STR_NEWS_DISASTER_COAL_MINE_SUBSIDENCE, - NS_ACCIDENT, NR_TILE, i->xy + TileDiffXY(1, 1)); // keep the news, even when the mine closes + NS_ACCIDENT, NR_TILE, i->location.tile + TileDiffXY(1, 1)); // keep the news, even when the mine closes { - TileIndex tile = i->xy; + TileIndex tile = i->location.tile; TileIndexDiff step = TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2)); for (uint n = 0; n < 30; n++) { diff --git a/src/economy.cpp b/src/economy.cpp index 50eb31775..187b97b5d 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -896,7 +896,7 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint n /* Check if industry temporarily refuses acceptance */ if (HasBit(indspec->callback_mask, CBM_IND_REFUSE_CARGO)) { - uint16 res = GetIndustryCallback(CBID_INDUSTRY_REFUSE_CARGO, 0, GetReverseCargoTranslation(cargo_type, indspec->grf_prop.grffile), ind, ind->type, ind->xy); + uint16 res = GetIndustryCallback(CBID_INDUSTRY_REFUSE_CARGO, 0, GetReverseCargoTranslation(cargo_type, indspec->grf_prop.grffile), ind, ind->type, ind->location.tile); if (res == 0) continue; } diff --git a/src/industry.h b/src/industry.h index 38d78a215..dd81cba72 100644 --- a/src/industry.h +++ b/src/industry.h @@ -22,6 +22,7 @@ #include "tile_type.h" #include "subsidy_type.h" #include "industry_map.h" +#include "tilearea_type.h" typedef Pool<Industry, IndustryID, 64, 64000> IndustryPool; @@ -33,9 +34,7 @@ extern IndustryPool _industry_pool; struct Industry : IndustryPool::PoolItem<&_industry_pool> { typedef PersistentStorageArray<uint32, 16> PersistentStorage; - TileIndex xy; ///< coordinates of the primary tile the industry is built one - byte width; - byte height; + TileArea location; ///< Location of the industry const Town *town; ///< Nearest town CargoID produced_cargo[2]; ///< 2 production cargo slots uint16 produced_cargo_waiting[2]; ///< amount of cargo produced per cargo @@ -69,7 +68,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { PersistentStorage psa; ///< Persistent storage for NewGRF industries. - Industry(TileIndex tile = INVALID_TILE) : xy(tile) {} + Industry(TileIndex tile = INVALID_TILE) : location(tile, 0, 0) {} ~Industry(); /** diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index d67f0c031..8527cd3fd 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -142,9 +142,9 @@ Industry::~Industry() /* Industry can also be destroyed when not fully initialized. * This means that we do not have to clear tiles either. */ - if (this->width == 0) return; + if (this->location.w == 0) return; - TILE_LOOP(tile_cur, this->width, this->height, this->xy) { + TILE_LOOP(tile_cur, this->location.w, this->location.h, this->location.tile) { if (IsTileType(tile_cur, MP_INDUSTRY)) { if (GetIndustryIndex(tile_cur) == this->index) { /* MakeWaterKeepingClass() can also handle 'land' */ @@ -163,7 +163,7 @@ Industry::~Industry() if (GetIndustrySpec(this->type)->behaviour & INDUSTRYBEH_PLANT_FIELDS) { /* Remove the farmland and convert it to regular tiles over time. */ - TILE_LOOP(tile_cur, 42, 42, this->xy - TileDiffXY(21, 21)) { + TILE_LOOP(tile_cur, 42, 42, this->location.tile - TileDiffXY(21, 21)) { tile_cur = TILE_MASK(tile_cur); if (IsTileType(tile_cur, MP_CLEAR) && IsClearGround(tile_cur, CLEAR_FIELDS) && GetIndustryIndexOfField(tile_cur) == this->index) { @@ -509,7 +509,7 @@ static void TransportIndustryGoods(TileIndex tile) const IndustrySpec *indspec = GetIndustrySpec(i->type); bool moved_cargo = false; - StationFinder stations(TileArea(i->xy, i->width, i->height)); + StationFinder stations(i->location); for (uint j = 0; j < lengthof(i->produced_cargo_waiting); j++) { uint cw = min(i->produced_cargo_waiting[j], 255); @@ -1043,10 +1043,10 @@ static void PlantFarmField(TileIndex tile, IndustryID industry) void PlantRandomFarmField(const Industry *i) { - int x = i->width / 2 + Random() % 31 - 16; - int y = i->height / 2 + Random() % 31 - 16; + int x = i->location.w / 2 + Random() % 31 - 16; + int y = i->location.h / 2 + Random() % 31 - 16; - TileIndex tile = TileAddWrap(i->xy, x, y); + TileIndex tile = TileAddWrap(i->location.tile, x, y); if (tile != INVALID_TILE) PlantFarmField(tile, i->index); } @@ -1082,7 +1082,7 @@ static bool SearchLumberMillTrees(TileIndex tile, void *user_data) */ static void ChopLumberMillTrees(Industry *i) { - TileIndex tile = i->xy; + TileIndex tile = i->location.tile; if (!IsIndustryCompleted(tile)) return; ///< Can't proceed if not completed @@ -1101,7 +1101,7 @@ static void ProduceIndustryGoods(Industry *i) if (Chance16R(1, 14, r) && (num = indsp->number_of_sounds) != 0) { SndPlayTileFx( (SoundFx)(indsp->random_sounds[((r >> 16) * num) >> 16]), - i->xy); + i->location.tile); } } @@ -1118,7 +1118,7 @@ static void ProduceIndustryGoods(Industry *i) if ((indbehav & INDUSTRYBEH_PLANT_FIELDS) != 0) { bool plant; if (HasBit(indsp->callback_mask, CBM_IND_SPECIAL_EFFECT)) { - plant = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, Random(), 0, i, i->type, i->xy) != 0); + plant = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, Random(), 0, i, i->type, i->location.tile) != 0); } else { plant = Chance16(1, 8); } @@ -1128,7 +1128,7 @@ static void ProduceIndustryGoods(Industry *i) if ((indbehav & INDUSTRYBEH_CUT_TREES) != 0) { bool cut = ((i->counter & 0x1FF) == 0); if (HasBit(indsp->callback_mask, CBM_IND_SPECIAL_EFFECT)) { - cut = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, 0, 1, i, i->type, i->xy) != 0); + cut = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, 0, 1, i, i->type, i->location.tile) != 0); } if (cut) ChopLumberMillTrees(i); @@ -1499,7 +1499,7 @@ static bool CheckIfFarEnoughFromIndustry(TileIndex tile, int type) FOR_ALL_INDUSTRIES(i) { /* Within 14 tiles from another industry is considered close */ - bool in_low_distance = DistanceMax(tile, i->xy) <= 14; + bool in_low_distance = DistanceMax(tile, i->location.tile) <= 14; /* check if an industry that accepts the same goods is nearby */ if (in_low_distance && @@ -1541,8 +1541,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind uint32 r; uint j; - i->xy = tile; - i->width = i->height = 0; + i->location = TileArea(tile, 1, 1); i->type = type; IncIndustryTypeCount(type); @@ -1629,12 +1628,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind TileIndex cur_tile = tile + ToTileIndexDiff(it->ti); if (it->gfx != GFX_WATERTILE_SPECIALCHECK) { - byte size; - - size = it->ti.x; - if (size > i->width) i->width = size; - size = it->ti.y; - if (size > i->height)i->height = size; + i->location.Add(cur_tile); WaterClass wc = (IsWaterTile(cur_tile) ? GetWaterClass(cur_tile) : WATER_CLASS_INVALID); @@ -1654,9 +1648,6 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind } } while ((++it)->ti.x != -0x80); - i->width++; - i->height++; - if (GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_PLANT_ON_BUILT) { for (j = 0; j != 50; j++) PlantRandomFarmField(i); } @@ -2031,7 +2022,7 @@ static void CanCargoServiceIndustry(CargoID cargo, Industry *ind, bool *c_accept if (HasBit(indspec->callback_mask, CBM_IND_REFUSE_CARGO)) { uint16 res = GetIndustryCallback(CBID_INDUSTRY_REFUSE_CARGO, 0, GetReverseCargoTranslation(cargo, indspec->grf_prop.grffile), - ind, ind->type, ind->xy); + ind, ind->type, ind->location.tile); if (res == 0) continue; } *c_accepts = true; @@ -2066,7 +2057,7 @@ static int WhoCanServiceIndustry(Industry *ind) { /* Find all stations within reach of the industry */ StationList stations; - FindStationsAroundTiles(TileArea(ind->xy, ind->width, ind->height), &stations); + FindStationsAroundTiles(ind->location, &stations); if (stations.Length() == 0) return 0; // No stations found at all => nobody services @@ -2168,7 +2159,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) bool callback_enabled = HasBit(indspec->callback_mask, monthly ? CBM_IND_MONTHLYPROD_CHANGE : CBM_IND_PRODUCTION_CHANGE); if (callback_enabled) { - uint16 res = GetIndustryCallback(monthly ? CBID_INDUSTRY_MONTHLYPROD_CHANGE : CBID_INDUSTRY_PRODUCTION_CHANGE, 0, Random(), i, i->type, i->xy); + uint16 res = GetIndustryCallback(monthly ? CBID_INDUSTRY_MONTHLYPROD_CHANGE : CBID_INDUSTRY_PRODUCTION_CHANGE, 0, Random(), i, i->type, i->location.tile); if (res != CALLBACK_FAILED) { // failed callback means "do nothing" suppress_message = HasBit(res, 7); /* Get the custom message if any */ @@ -2343,7 +2334,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) AddNewsItem(str, ns, closeit ? NR_TILE : NR_INDUSTRY, - closeit ? i->xy + TileDiffXY(1, 1) : i->index); + closeit ? i->location.tile + TileDiffXY(1, 1) : i->index); } } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index e7cd41884..9749ae756 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -63,7 +63,7 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind, { suffix[0] = '\0'; if (HasBit(indspec->callback_mask, CBM_IND_CARGO_SUFFIX)) { - uint16 callback = GetIndustryCallback(CBID_INDUSTRY_CARGO_SUFFIX, 0, (cst << 8) | cargo, const_cast<Industry *>(ind), ind_type, (cst != CST_FUND) ? ind->xy : INVALID_TILE); + uint16 callback = GetIndustryCallback(CBID_INDUSTRY_CARGO_SUFFIX, 0, (cst << 8) | cargo, const_cast<Industry *>(ind), ind_type, (cst != CST_FUND) ? ind->location.tile : INVALID_TILE); if (GB(callback, 0, 8) != 0xFF) { PrepareTextRefStackUsage(6); GetString(suffix, GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + callback), suffix_last); @@ -580,7 +580,7 @@ public: this->InitNested(desc, window_number); NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(IVW_VIEWPORT); - nvp->InitializeViewport(this, Industry::Get(window_number)->xy + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY); + nvp->InitializeViewport(this, Industry::Get(window_number)->location.tile + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY); } virtual void OnPaint() @@ -674,7 +674,7 @@ public: /* Get the extra message for the GUI */ if (HasBit(ind->callback_mask, CBM_IND_WINDOW_MORE_TEXT)) { - uint16 callback_res = GetIndustryCallback(CBID_INDUSTRY_WINDOW_MORE_TEXT, 0, 0, i, i->type, i->xy); + uint16 callback_res = GetIndustryCallback(CBID_INDUSTRY_WINDOW_MORE_TEXT, 0, 0, i, i->type, i->location.tile); if (callback_res != CALLBACK_FAILED) { StringID message = GetGRFStringID(ind->grf_prop.grffile->grfid, 0xD000 + callback_res); if (message != STR_NULL && message != STR_UNDEFINED) { @@ -747,9 +747,9 @@ public: case IVW_GOTO: i = Industry::Get(this->window_number); if (_ctrl_pressed) { - ShowExtraViewPortWindow(i->xy + TileDiffXY(1, 1)); + ShowExtraViewPortWindow(i->location.tile + TileDiffXY(1, 1)); } else { - ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1)); + ScrollMainWindowToTile(i->location.tile + TileDiffXY(1, 1)); } break; } @@ -1124,9 +1124,9 @@ public: p = y + this->vscroll.GetPosition(); if (p < this->industries.Length()) { if (_ctrl_pressed) { - ShowExtraViewPortWindow(this->industries[p]->xy); + ShowExtraViewPortWindow(this->industries[p]->location.tile); } else { - ScrollMainWindowToTile(this->industries[p]->xy); + ScrollMainWindowToTile(this->industries[p]->location.tile); } } } break; diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 04b1a47ad..9a8ff580c 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -92,7 +92,7 @@ static uint32 GetClosestIndustry(TileIndex tile, IndustryType type, const Indust FOR_ALL_INDUSTRIES(i) { if (i->type != type || i == current) continue; - best_dist = min(best_dist, DistanceManhattan(tile, i->xy)); + best_dist = min(best_dist, DistanceManhattan(tile, i->location.tile)); } return best_dist; @@ -132,7 +132,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout if (layout_filter == 0) { /* If the filter is 0, it could be because none was specified as well as being really a 0. * In either case, just do the regular var67 */ - closest_dist = GetClosestIndustry(current->xy, ind_index, current); + closest_dist = GetClosestIndustry(current->location.tile, ind_index, current); count = GetIndustryTypeCount(ind_index); } else { /* Count only those who match the same industry type and layout filter @@ -140,7 +140,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout const Industry *i; FOR_ALL_INDUSTRIES(i) { if (i->type == ind_index && i != current && i->selected_layout == layout_filter) { - closest_dist = min(closest_dist, DistanceManhattan(current->xy, i->xy)); + closest_dist = min(closest_dist, DistanceManhattan(current->location.tile, i->location.tile)); count++; } } @@ -235,7 +235,7 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par case 0x46: return industry->construction_date; // Date when built - long format - (in days) /* Get industry ID at offset param */ - case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, industry->xy), industry); + case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, industry->location.tile), industry); /* Get random tile bits at offset param */ case 0x61: @@ -269,15 +269,15 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par case 0x7C: return industry->psa.Get(parameter); /* Industry structure access*/ - case 0x80: return industry->xy; - case 0x81: return GB(industry->xy, 8, 8); + case 0x80: return industry->location.tile; + case 0x81: return GB(industry->location.tile, 8, 8); /* Pointer to the town the industry is associated with */ case 0x82: return industry->town->index; case 0x83: case 0x84: case 0x85: DEBUG(grf, 0, "NewGRFs shouldn't be doing pointer magic"); break; // not supported - case 0x86: return industry->width; - case 0x87: return industry->height;// xy dimensions + case 0x86: return industry->location.w; + case 0x87: return industry->location.h;// xy dimensions case 0x88: case 0x89: return industry->produced_cargo[variable - 0x88]; @@ -455,8 +455,8 @@ bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspe Industry ind; ind.index = INVALID_INDUSTRY; - ind.xy = tile; - ind.width = 0; + ind.location.tile = tile; + ind.location.w = 0; ind.type = type; ind.selected_layout = itspec_index; ind.town = ClosestTownFromTile(tile, UINT_MAX); @@ -516,7 +516,7 @@ void IndustryProductionCallback(Industry *ind, int reason) { const IndustrySpec *spec = GetIndustrySpec(ind->type); ResolverObject object; - NewIndustryResolver(&object, ind->xy, ind, ind->type); + NewIndustryResolver(&object, ind->location.tile, ind, ind->type); if ((spec->behaviour & INDUSTRYBEH_PRODCALLBACK_RANDOM) != 0) object.callback_param1 = Random(); int multiplier = 1; if ((spec->behaviour & INDUSTRYBEH_PROD_MULTI_HNDLING) != 0) multiplier = ind->prod_level; diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index 5da0fbd05..e0e883b27 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -86,7 +86,7 @@ static uint32 IndustryTileGetVariable(const ResolverObject *object, byte variabl case 0x42: return GetTownRadiusGroup(ClosestTownFromTile(tile, UINT_MAX), tile); /* Relative position */ - case 0x43: return GetRelativePosition(tile, inds->xy); + case 0x43: return GetRelativePosition(tile, inds->location.tile); /* Animation frame. Like house variable 46 but can contain anything 0..FF. */ case 0x44: return (IsTileType(tile, MP_INDUSTRY)) ? GetIndustryAnimationState(tile) : 0; @@ -271,8 +271,8 @@ bool PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, { Industry ind; ind.index = INVALID_INDUSTRY; - ind.xy = ind_base_tile; - ind.width = 0; + ind.location.tile = ind_base_tile; + ind.location.w = 0; ind.type = type; uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_SHAPE_CHECK, 0, itspec_index, gfx, &ind, ind_tile); @@ -396,7 +396,7 @@ bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigge { bool ret = true; uint32 random = Random(); - TILE_LOOP(tile, ind->width, ind->height, ind->xy) { + TILE_LOOP(tile, ind->location.w, ind->location.h, ind->location.tile) { if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) { if (StartStopIndustryTileAnimation(tile, iat, random)) { SB(random, 0, 16, Random()); @@ -441,7 +441,7 @@ void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger) void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger) { - TILE_LOOP(tile, ind->width, ind->height, ind->xy) { + TILE_LOOP(tile, ind->location.w, ind->location.h, ind->location.tile) { if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) { DoTriggerIndustryTile(tile, trigger, ind); } diff --git a/src/news_gui.cpp b/src/news_gui.cpp index d4ea2ee5d..3814626f5 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -63,7 +63,7 @@ static TileIndex GetReferenceTile(NewsReferenceType reftype, uint32 ref) switch (reftype) { case NR_TILE: return (TileIndex)ref; case NR_STATION: return Station::Get((StationID)ref)->xy; - case NR_INDUSTRY: return Industry::Get((IndustryID)ref)->xy + TileDiffXY(1, 1); + case NR_INDUSTRY: return Industry::Get((IndustryID)ref)->location.tile + TileDiffXY(1, 1); case NR_TOWN: return Town::Get((TownID)ref)->xy; default: return INVALID_TILE; } diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp index 40b170c04..ab2b24f31 100644 --- a/src/saveload/industry_sl.cpp +++ b/src/saveload/industry_sl.cpp @@ -17,10 +17,10 @@ #include "saveload.h" static const SaveLoad _industry_desc[] = { - SLE_CONDVAR(Industry, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), - SLE_CONDVAR(Industry, xy, SLE_UINT32, 6, SL_MAX_VERSION), - SLE_VAR(Industry, width, SLE_UINT8), - SLE_VAR(Industry, height, SLE_UINT8), + SLE_CONDVAR(Industry, location.tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), + SLE_CONDVAR(Industry, location.tile, SLE_UINT32, 6, SL_MAX_VERSION), + SLE_VAR(Industry, location.w, SLE_UINT8), + SLE_VAR(Industry, location.h, SLE_UINT8), SLE_REF(Industry, town, REF_TOWN), SLE_CONDNULL( 2, 0, 60), ///< used to be industry's produced_cargo SLE_CONDARR(Industry, produced_cargo, SLE_UINT8, 2, 78, SL_MAX_VERSION), diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index d97038f8e..d24991b9e 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -776,10 +776,10 @@ static bool LoadOldStation(LoadgameState *ls, int num) } static const OldChunks industry_chunk[] = { - OCL_SVAR( OC_TILE, Industry, xy ), + OCL_SVAR( OC_TILE, Industry, location.tile ), OCL_VAR ( OC_UINT32, 1, &_old_town_index ), - OCL_SVAR( OC_UINT8, Industry, width ), - OCL_SVAR( OC_UINT8, Industry, height ), + OCL_SVAR( OC_UINT8, Industry, location.w ), + OCL_SVAR( OC_UINT8, Industry, location.h ), OCL_NULL( 2 ), ///< used to be industry's produced_cargo OCL_SVAR( OC_TTD | OC_UINT16, Industry, produced_cargo_waiting[0] ), @@ -825,7 +825,7 @@ static bool LoadOldIndustry(LoadgameState *ls, int num) Industry *i = new (num) Industry(); if (!LoadChunk(ls, i, industry_chunk)) return false; - if (i->xy != 0) { + if (i->location.tile != 0) { i->town = Town::Get(RemapTownIndex(_old_town_index)); if (_savegame_type == SGT_TTO) { diff --git a/src/subsidy.cpp b/src/subsidy.cpp index 605be8411..631d80e81 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -236,7 +236,7 @@ static Subsidy *FindSubsidyCargoRoute() /* Only want big towns */ if (t->population < SUBSIDY_CARGO_MIN_POPULATION) return NULL; - if (DistanceManhattan(i->xy, t->xy) > SUBSIDY_MAX_DISTANCE) return NULL; + if (DistanceManhattan(i->location.tile, t->xy) > SUBSIDY_MAX_DISTANCE) return NULL; dst = t->index; } else { @@ -252,7 +252,7 @@ static Subsidy *FindSubsidyCargoRoute() return NULL; } - if (DistanceManhattan(i->xy, i2->xy) > SUBSIDY_MAX_DISTANCE) return NULL; + if (DistanceManhattan(i->location.tile, i2->location.tile) > SUBSIDY_MAX_DISTANCE) return NULL; dst = i2->index; } diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index cba1f992e..0903394c7 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -83,7 +83,7 @@ struct SubsidyListWindow : Window { /* determine src coordinate for subsidy and try to scroll to it */ TileIndex xy; switch (s->src_type) { - case ST_INDUSTRY: xy = Industry::Get(s->src)->xy; break; + case ST_INDUSTRY: xy = Industry::Get(s->src)->location.tile; break; case ST_TOWN: xy = Town::Get(s->src)->xy; break; default: NOT_REACHED(); } @@ -93,7 +93,7 @@ struct SubsidyListWindow : Window { /* otherwise determine dst coordinate for subsidy and scroll to it */ switch (s->dst_type) { - case ST_INDUSTRY: xy = Industry::Get(s->dst)->xy; break; + case ST_INDUSTRY: xy = Industry::Get(s->dst)->location.tile; break; case ST_TOWN: xy = Town::Get(s->dst)->xy; break; default: NOT_REACHED(); } |