diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/api/ai_tilelist.cpp | 2 | ||||
-rw-r--r-- | src/disaster_cmd.cpp | 2 | ||||
-rw-r--r-- | src/economy.cpp | 2 | ||||
-rw-r--r-- | src/effectvehicle.cpp | 2 | ||||
-rw-r--r-- | src/industry.h | 15 | ||||
-rw-r--r-- | src/industry_cmd.cpp | 26 | ||||
-rw-r--r-- | src/industry_map.h | 13 | ||||
-rw-r--r-- | src/newgrf_industries.cpp | 6 | ||||
-rw-r--r-- | src/newgrf_industrytiles.cpp | 16 | ||||
-rw-r--r-- | src/saveload/afterload.cpp | 2 | ||||
-rw-r--r-- | src/smallmap_gui.cpp | 8 | ||||
-rw-r--r-- | src/station.cpp | 5 | ||||
-rw-r--r-- | src/station_cmd.cpp | 6 | ||||
-rw-r--r-- | src/water_cmd.cpp | 2 |
14 files changed, 52 insertions, 55 deletions
diff --git a/src/ai/api/ai_tilelist.cpp b/src/ai/api/ai_tilelist.cpp index d7b644f86..d77dcd827 100644 --- a/src/ai/api/ai_tilelist.cpp +++ b/src/ai/api/ai_tilelist.cpp @@ -12,7 +12,7 @@ #include "ai_tilelist.hpp" #include "ai_industry.hpp" #include "../../tile_map.h" -#include "../../industry_map.h" +#include "../../industry.h" #include "../../station_base.h" #include "../../settings_type.h" diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index ebc10d7be..b1fed1ee9 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -26,7 +26,7 @@ #include "stdafx.h" #include "landscape.h" -#include "industry_map.h" +#include "industry.h" #include "station_base.h" #include "command_func.h" #include "news_func.h" diff --git a/src/economy.cpp b/src/economy.cpp index 5dc93a5d1..c7c7f4bca 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -14,7 +14,7 @@ #include "tile_cmd.h" #include "company_func.h" #include "command_func.h" -#include "industry_map.h" +#include "industry.h" #include "town.h" #include "news_func.h" #include "network/network.h" diff --git a/src/effectvehicle.cpp b/src/effectvehicle.cpp index 111b2dc2d..94d729297 100644 --- a/src/effectvehicle.cpp +++ b/src/effectvehicle.cpp @@ -11,7 +11,7 @@ #include "stdafx.h" #include "landscape.h" -#include "industry_map.h" +#include "industry.h" #include "vehicle_func.h" #include "sound_func.h" #include "animated_tile_func.h" diff --git a/src/industry.h b/src/industry.h index 0dbbb5e03..32f403f96 100644 --- a/src/industry.h +++ b/src/industry.h @@ -19,11 +19,9 @@ #include "economy_type.h" #include "map_type.h" #include "industry_type.h" -#include "industrytype.h" #include "tile_type.h" #include "subsidy_type.h" -#include "town_type.h" -#include "date_type.h" +#include "industry_map.h" typedef Pool<Industry, IndustryID, 64, 64000> IndustryPool; @@ -74,6 +72,17 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { Industry(TileIndex tile = INVALID_TILE) : xy(tile) {} ~Industry(); + /** + * Get the industry of the given tile + * @param t the tile to get the industry from + * @pre IsTileType(t, MP_INDUSTRY) + * @return the industry + */ + static FORCEINLINE Industry *GetByTile(TileIndex tile) + { + return Industry::Get(GetIndustryIndex(tile)); + } + static Industry *GetRandom(); }; diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 514e5f5c2..6a8ba32b7 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -12,7 +12,7 @@ #include "stdafx.h" #include "openttd.h" #include "clear_map.h" -#include "industry_map.h" +#include "industry.h" #include "station_base.h" #include "train.h" #include "landscape.h" @@ -102,7 +102,7 @@ IndustryType GetIndustryType(TileIndex tile) { assert(IsTileType(tile, MP_INDUSTRY)); - const Industry *ind = GetIndustryByTile(tile); + const Industry *ind = Industry::GetByTile(tile); assert(ind != NULL); return ind->type; } @@ -297,7 +297,7 @@ static IndustryDrawTileProc * const _industry_draw_tile_procs[5] = { static void DrawTile_Industry(TileInfo *ti) { IndustryGfx gfx = GetIndustryGfx(ti->tile); - Industry *ind = GetIndustryByTile(ti->tile); + Industry *ind = Industry::GetByTile(ti->tile); const IndustryTileSpec *indts = GetIndustryTileSpec(gfx); const DrawBuildingsTileStruct *dits; SpriteID image; @@ -385,7 +385,7 @@ static Foundation GetFoundation_Industry(TileIndex tile, Slope tileh) if (gfx >= NEW_INDUSTRYTILEOFFSET) { const IndustryTileSpec *indts = GetIndustryTileSpec(gfx); if (indts->grf_prop.spritegroup != NULL && HasBit(indts->callback_flags, CBM_INDT_DRAW_FOUNDATIONS)) { - uint32 callback_res = GetIndustryTileCallback(CBID_INDUSTRY_DRAW_FOUNDATIONS, 0, 0, gfx, GetIndustryByTile(tile), tile); + uint32 callback_res = GetIndustryTileCallback(CBID_INDUSTRY_DRAW_FOUNDATIONS, 0, 0, gfx, Industry::GetByTile(tile), tile); if (callback_res == 0) return FOUNDATION_NONE; } } @@ -406,7 +406,7 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance) const uint8 *cargo_acceptance = itspec->acceptance; if (HasBit(itspec->callback_flags, CBM_INDT_ACCEPT_CARGO)) { - uint16 res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, GetIndustryByTile(tile), tile); + uint16 res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, Industry::GetByTile(tile), tile); if (res != CALLBACK_FAILED) { accepts_cargo = raw_accepts_cargo; for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_accepts_cargo[i] = GetCargoTranslation(GB(res, i * 5, 5), itspec->grf_prop.grffile); @@ -414,7 +414,7 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance) } if (HasBit(itspec->callback_flags, CBM_INDT_CARGO_ACCEPTANCE)) { - uint16 res = GetIndustryTileCallback(CBID_INDTILE_CARGO_ACCEPTANCE, 0, 0, gfx, GetIndustryByTile(tile), tile); + uint16 res = GetIndustryTileCallback(CBID_INDTILE_CARGO_ACCEPTANCE, 0, 0, gfx, Industry::GetByTile(tile), tile); if (res != CALLBACK_FAILED) { cargo_acceptance = raw_cargo_acceptance; for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_cargo_acceptance[i] = GB(res, i * 4, 4); @@ -429,7 +429,7 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance) static void GetTileDesc_Industry(TileIndex tile, TileDesc *td) { - const Industry *i = GetIndustryByTile(tile); + const Industry *i = Industry::GetByTile(tile); const IndustrySpec *is = GetIndustrySpec(i->type); td->owner[0] = i->owner; @@ -446,7 +446,7 @@ static void GetTileDesc_Industry(TileIndex tile, TileDesc *td) static CommandCost ClearTile_Industry(TileIndex tile, DoCommandFlag flags) { - Industry *i = GetIndustryByTile(tile); + Industry *i = Industry::GetByTile(tile); const IndustrySpec *indspec = GetIndustrySpec(i->type); /* water can destroy industries @@ -473,7 +473,7 @@ static CommandCost ClearTile_Industry(TileIndex tile, DoCommandFlag flags) static void TransportIndustryGoods(TileIndex tile) { - Industry *i = GetIndustryByTile(tile); + Industry *i = Industry::GetByTile(tile); const IndustrySpec *indspec = GetIndustrySpec(i->type); bool moved_cargo = false; @@ -846,7 +846,7 @@ static void TileLoop_Industry(TileIndex tile) case GFX_TOY_FACTORY: { - Industry *i = GetIndustryByTile(tile); + Industry *i = Industry::GetByTile(tile); if (i->was_cargo_delivered) { i->was_cargo_delivered = false; SetIndustryAnimationLoop(tile, 0); @@ -882,7 +882,7 @@ static TrackStatus GetTileTrackStatus_Industry(TileIndex tile, TransportType mod static void AddProducedCargo_Industry(TileIndex tile, CargoArray &produced) { - const Industry *i = GetIndustryByTile(tile); + const Industry *i = Industry::GetByTile(tile); for (uint j = 0; j < lengthof(i->produced_cargo); j++) { CargoID cargo = i->produced_cargo[j]; @@ -893,7 +893,7 @@ static void AddProducedCargo_Industry(TileIndex tile, CargoArray &produced) static void ChangeTileOwner_Industry(TileIndex tile, Owner old_owner, Owner new_owner) { /* If the founder merges, the industry was created by the merged company */ - Industry *i = GetIndustryByTile(tile); + Industry *i = Industry::GetByTile(tile); if (i->founder == old_owner) i->founder = (new_owner == INVALID_OWNER) ? OWNER_NONE : new_owner; } @@ -2409,7 +2409,7 @@ static CommandCost TerraformTile_Industry(TileIndex tile, DoCommandFlag flags, u /* Call callback 3C 'disable autosloping for industry tiles'. */ if (HasBit(itspec->callback_flags, CBM_INDT_AUTOSLOPE)) { /* If the callback fails, allow autoslope. */ - uint16 res = GetIndustryTileCallback(CBID_INDUSTRY_AUTOSLOPE, 0, 0, gfx, GetIndustryByTile(tile), tile); + uint16 res = GetIndustryTileCallback(CBID_INDUSTRY_AUTOSLOPE, 0, 0, gfx, Industry::GetByTile(tile), tile); if ((res == 0) || (res == CALLBACK_FAILED)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); } else { /* allow autoslope */ diff --git a/src/industry_map.h b/src/industry_map.h index c6824ae54..2112b4285 100644 --- a/src/industry_map.h +++ b/src/industry_map.h @@ -12,7 +12,7 @@ #ifndef INDUSTRY_MAP_H #define INDUSTRY_MAP_H -#include "industry.h" +#include "industrytype.h" #include "tile_map.h" #include "water_map.h" @@ -70,17 +70,6 @@ static inline IndustryID GetIndustryIndex(TileIndex t) } /** - * Get the industry of the given tile - * @param t the tile to get the industry from - * @pre IsTileType(t, MP_INDUSTRY) - * @return the industry - */ -static inline Industry *GetIndustryByTile(TileIndex t) -{ - return Industry::Get(GetIndustryIndex(t)); -} - -/** * Is this industry tile fully built? * @param t the tile to analyze * @pre IsTileType(t, MP_INDUSTRY) diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 42ffbab40..e2916d00d 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -14,7 +14,7 @@ #include "tile_type.h" #include "strings_type.h" #include "company_type.h" -#include "industry_map.h" +#include "industry.h" #include "newgrf.h" #include "newgrf_industries.h" #include "newgrf_commons.h" @@ -242,7 +242,7 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par /* Get random tile bits at offset param */ case 0x61: tile = GetNearbyTile(parameter, tile); - return (IsTileType(tile, MP_INDUSTRY) && GetIndustryByTile(tile) == industry) ? GetIndustryRandomBits(tile) : 0; + return (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) ? GetIndustryRandomBits(tile) : 0; /* Land info of nearby tiles */ case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY); @@ -250,7 +250,7 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par /* Animation stage of nearby tiles */ case 0x63: tile = GetNearbyTile(parameter, tile); - if (IsTileType(tile, MP_INDUSTRY) && GetIndustryByTile(tile) == industry) { + if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) { return GetIndustryAnimationState(tile); } return 0xFFFFFFFF; diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index 53878edaa..dd4737e3b 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -22,7 +22,7 @@ #include "newgrf_industrytiles.h" #include "newgrf_sound.h" #include "newgrf_text.h" -#include "industry_map.h" +#include "industry.h" #include "sprite.h" #include "transparency.h" #include "functions.h" @@ -97,7 +97,7 @@ static uint32 IndustryTileGetVariable(const ResolverObject *object, byte variabl /* Animation stage of nearby tiles */ case 0x61: tile = GetNearbyTile(parameter, tile); - if (IsTileType(tile, MP_INDUSTRY) && GetIndustryByTile(tile) == inds) { + if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == inds) { return GetIndustryAnimationState(tile); } return UINT_MAX; @@ -122,14 +122,14 @@ static uint32 IndustryTileGetRandomBits(const ResolverObject *object) { const TileIndex tile = object->u.industry.tile; if (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) return 0; - return (object->scope == VSG_SCOPE_SELF) ? GetIndustryRandomBits(tile) : GetIndustryByTile(tile)->random; + return (object->scope == VSG_SCOPE_SELF) ? GetIndustryRandomBits(tile) : Industry::GetByTile(tile)->random; } static uint32 IndustryTileGetTriggers(const ResolverObject *object) { const TileIndex tile = object->u.industry.tile; if (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) return 0; - return (object->scope == VSG_SCOPE_SELF) ? GetIndustryTriggers(tile) : GetIndustryByTile(tile)->random_triggers; + return (object->scope == VSG_SCOPE_SELF) ? GetIndustryTriggers(tile) : Industry::GetByTile(tile)->random_triggers; } static void IndustryTileSetTriggers(const ResolverObject *object, int triggers) @@ -140,7 +140,7 @@ static void IndustryTileSetTriggers(const ResolverObject *object, int triggers) if (object->scope == VSG_SCOPE_SELF) { SetIndustryTriggers(tile, triggers); } else { - GetIndustryByTile(tile)->random_triggers = triggers; + Industry::GetByTile(tile)->random_triggers = triggers; } } @@ -299,7 +299,7 @@ bool PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, void AnimateNewIndustryTile(TileIndex tile) { - Industry *ind = GetIndustryByTile(tile); + Industry *ind = Industry::GetByTile(tile); IndustryGfx gfx = GetIndustryGfx(tile); const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx); byte animation_speed = itspec->animation_speed; @@ -387,7 +387,7 @@ bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat if (!HasBit(itspec->animation_triggers, iat)) return false; - Industry *ind = GetIndustryByTile(tile); + Industry *ind = Industry::GetByTile(tile); ChangeIndustryTileAnimationFrame(itspec, tile, iat, random, gfx, ind); return true; } @@ -436,7 +436,7 @@ static void DoTriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger, I void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger) { - DoTriggerIndustryTile(tile, trigger, GetIndustryByTile(tile)); + DoTriggerIndustryTile(tile, trigger, Industry::GetByTile(tile)); } void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger) diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 43c375777..d76638183 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -22,7 +22,7 @@ #include "../network/network.h" #include "../gfxinit.h" #include "../functions.h" -#include "../industry_map.h" +#include "../industry.h" #include "../town_map.h" #include "../clear_map.h" #include "../vehicle_func.h" diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index c9eb2dd13..ae360fea2 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -11,7 +11,7 @@ #include "stdafx.h" #include "clear_map.h" -#include "industry_map.h" +#include "industry.h" #include "station_map.h" #include "landscape.h" #include "window_gui.h" @@ -408,8 +408,8 @@ static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile) if (t == MP_INDUSTRY) { /* If industry is allowed to be seen, use its colour on the map */ - if (_legend_from_industries[_industry_to_list_pos[GetIndustryByTile(tile)->type]].show_on_map) { - return GetIndustrySpec(GetIndustryByTile(tile)->type)->map_colour * 0x01010101; + if (_legend_from_industries[_industry_to_list_pos[Industry::GetByTile(tile)->type]].show_on_map) { + return GetIndustrySpec(Industry::GetByTile(tile)->type)->map_colour * 0x01010101; } else { /* otherwise, return the colour of the clear tiles, which will make it disappear */ return ApplyMask(MKCOLOUR(0x54545454), &_smallmap_vehicles_andor[MP_CLEAR]); @@ -465,7 +465,7 @@ static inline uint32 GetSmallMapVegetationPixels(TileIndex tile) return (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) < 3) ? MKCOLOUR(0x37373737) : _vegetation_clear_bits[GetClearGround(tile)]; case MP_INDUSTRY: - return GetIndustrySpec(GetIndustryByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOUR(0xD0D0D0D0) : MKCOLOUR(0xB5B5B5B5); + return GetIndustrySpec(Industry::GetByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOUR(0xD0D0D0D0) : MKCOLOUR(0xB5B5B5B5); case MP_TREES: if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT) { diff --git a/src/station.cpp b/src/station.cpp index 5ff0f280c..a8a89171f 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -11,7 +11,6 @@ #include "stdafx.h" #include "company_func.h" -#include "industry.h" #include "newgrf_cargo.h" #include "yapf/yapf.h" #include "cargotype.h" @@ -31,7 +30,7 @@ #include "core/pool_func.hpp" #include "station_base.h" #include "roadstop_base.h" -#include "industry_map.h" +#include "industry.h" #include "table/strings.h" @@ -284,7 +283,7 @@ static bool FindIndustryToDeliver(TileIndex ind_tile, void *user_data) if (!IsTileType(ind_tile, MP_INDUSTRY)) return false; RectAndIndustryVector *riv = (RectAndIndustryVector *)user_data; - Industry *ind = GetIndustryByTile(ind_tile); + Industry *ind = Industry::GetByTile(ind_tile); /* Don't check further if this industry is already in the list */ if (riv->industries_near->Contains(ind)) return false; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 9b4da98a8..5264be8ae 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -21,7 +21,7 @@ #include "news_func.h" #include "train.h" #include "roadveh.h" -#include "industry_map.h" +#include "industry.h" #include "newgrf_station.h" #include "newgrf_commons.h" #include "yapf/yapf.h" @@ -143,7 +143,7 @@ static bool CMSAMine(TileIndex tile) /* No industry */ if (!IsTileType(tile, MP_INDUSTRY)) return false; - const Industry *ind = GetIndustryByTile(tile); + const Industry *ind = Industry::GetByTile(tile); /* No extractive industry */ if ((GetIndustrySpec(ind->type)->life_type & INDUSTRYLIFE_EXTRACTIVE) == 0) return false; @@ -190,7 +190,7 @@ static bool CMSAForest(TileIndex tile) /* No industry */ if (!IsTileType(tile, MP_INDUSTRY)) return false; - const Industry *ind = GetIndustryByTile(tile); + const Industry *ind = Industry::GetByTile(tile); /* No extractive industry */ if ((GetIndustrySpec(ind->type)->life_type & INDUSTRYLIFE_ORGANIC) == 0) return false; diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index fba5e2704..f3f60c52c 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -23,7 +23,7 @@ #include "train.h" #include "roadveh.h" #include "water.h" -#include "industry_map.h" +#include "industry.h" #include "cargotype.h" #include "newgrf_canal.h" #include "transparency.h" |