mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-06-18 19:19:29 +01:00
Codechange: Use TypedIndexContainer for typed index containers
Instead of ReferenceThroughBaseContainer
This commit is contained in:
parent
d0e49a297f
commit
63f1c2aa3a
@ -52,7 +52,7 @@ void UpdateObjectColours(const Company *c);
|
|||||||
|
|
||||||
CompanyID _local_company; ///< Company controlled by the human player at this client. Can also be #COMPANY_SPECTATOR.
|
CompanyID _local_company; ///< Company controlled by the human player at this client. Can also be #COMPANY_SPECTATOR.
|
||||||
CompanyID _current_company; ///< Company currently doing an action.
|
CompanyID _current_company; ///< Company currently doing an action.
|
||||||
ReferenceThroughBaseContainer<std::array<Colours, MAX_COMPANIES>> _company_colours; ///< NOSAVE: can be determined from company structs.
|
TypedIndexContainer<std::array<Colours, MAX_COMPANIES>, CompanyID> _company_colours; ///< NOSAVE: can be determined from company structs.
|
||||||
CompanyManagerFace _company_manager_face; ///< for company manager face storage in openttd.cfg
|
CompanyManagerFace _company_manager_face; ///< for company manager face storage in openttd.cfg
|
||||||
uint _cur_company_tick_index; ///< used to generate a name for one company that doesn't have a name yet per tick
|
uint _cur_company_tick_index; ///< used to generate a name for one company that doesn't have a name yet per tick
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ CommandCost CheckTileOwnership(TileIndex tile);
|
|||||||
extern CompanyID _local_company;
|
extern CompanyID _local_company;
|
||||||
extern CompanyID _current_company;
|
extern CompanyID _current_company;
|
||||||
|
|
||||||
extern ReferenceThroughBaseContainer<std::array<Colours, MAX_COMPANIES>> _company_colours;
|
extern TypedIndexContainer<std::array<Colours, MAX_COMPANIES>, CompanyID> _company_colours;
|
||||||
extern CompanyManagerFace _company_manager_face;
|
extern CompanyManagerFace _company_manager_face;
|
||||||
PaletteID GetCompanyPalette(CompanyID company);
|
PaletteID GetCompanyPalette(CompanyID company);
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ const ScoreInfo _score_info[] = {
|
|||||||
{ 0, 0} // SCORE_TOTAL
|
{ 0, 0} // SCORE_TOTAL
|
||||||
};
|
};
|
||||||
|
|
||||||
ReferenceThroughBaseContainer<std::array<std::array<int64_t, SCORE_END>, MAX_COMPANIES>> _score_part;
|
TypedIndexContainer<std::array<std::array<int64_t, SCORE_END>, MAX_COMPANIES>, CompanyID> _score_part;
|
||||||
Economy _economy;
|
Economy _economy;
|
||||||
Prices _price;
|
Prices _price;
|
||||||
static PriceMultipliers _price_base_multiplier;
|
static PriceMultipliers _price_base_multiplier;
|
||||||
|
@ -23,7 +23,7 @@ void ResetPriceBaseMultipliers();
|
|||||||
void SetPriceBaseMultiplier(Price price, int factor);
|
void SetPriceBaseMultiplier(Price price, int factor);
|
||||||
|
|
||||||
extern const ScoreInfo _score_info[];
|
extern const ScoreInfo _score_info[];
|
||||||
extern ReferenceThroughBaseContainer<std::array<std::array<int64_t, SCORE_END>, MAX_COMPANIES>> _score_part;
|
extern TypedIndexContainer<std::array<std::array<int64_t, SCORE_END>, MAX_COMPANIES>, CompanyID> _score_part;
|
||||||
extern Economy _economy;
|
extern Economy _economy;
|
||||||
/* Prices and also the fractional part. */
|
/* Prices and also the fractional part. */
|
||||||
extern Prices _price;
|
extern Prices _price;
|
||||||
|
@ -39,7 +39,7 @@ void ReconsiderGameScriptLanguage();
|
|||||||
/** Container for the raw (unencoded) language strings of a language. */
|
/** Container for the raw (unencoded) language strings of a language. */
|
||||||
struct LanguageStrings {
|
struct LanguageStrings {
|
||||||
std::string language; ///< Name of the language (base filename). Empty string if invalid.
|
std::string language; ///< Name of the language (base filename). Empty string if invalid.
|
||||||
ReferenceThroughBaseContainer<StringList> lines; ///< The lines of the file to pass into the parser/encoder.
|
TypedIndexContainer<StringList, StringIndexInTab> lines; ///< The lines of the file to pass into the parser/encoder.
|
||||||
|
|
||||||
LanguageStrings() {}
|
LanguageStrings() {}
|
||||||
LanguageStrings(const std::string &lang) : language(lang) {}
|
LanguageStrings(const std::string &lang) : language(lang) {}
|
||||||
@ -56,8 +56,8 @@ struct GameStrings {
|
|||||||
|
|
||||||
std::vector<LanguageStrings> raw_strings; ///< The raw strings per language, first must be English/the master language!.
|
std::vector<LanguageStrings> raw_strings; ///< The raw strings per language, first must be English/the master language!.
|
||||||
std::vector<LanguageStrings> compiled_strings; ///< The compiled strings per language, first must be English/the master language!.
|
std::vector<LanguageStrings> compiled_strings; ///< The compiled strings per language, first must be English/the master language!.
|
||||||
ReferenceThroughBaseContainer<StringList> string_names; ///< The names of the compiled strings.
|
TypedIndexContainer<StringList, StringIndexInTab> string_names; ///< The names of the compiled strings.
|
||||||
ReferenceThroughBaseContainer<StringParamsList> string_params; ///< The parameters for the strings.
|
TypedIndexContainer<StringParamsList, StringIndexInTab> string_params; ///< The parameters for the strings.
|
||||||
|
|
||||||
void Compile();
|
void Compile();
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ private:
|
|||||||
LinkGraphJob &job; ///< Link graph job we're working with.
|
LinkGraphJob &job; ///< Link graph job we're working with.
|
||||||
|
|
||||||
/** Lookup table for getting NodeIDs from StationIDs. */
|
/** Lookup table for getting NodeIDs from StationIDs. */
|
||||||
ReferenceThroughBaseContainer<std::vector<NodeID>> station_to_node;
|
TypedIndexContainer<std::vector<NodeID>, StationID> station_to_node;
|
||||||
|
|
||||||
/** Current iterator in the shares map. */
|
/** Current iterator in the shares map. */
|
||||||
FlowStat::SharesMap::const_iterator it;
|
FlowStat::SharesMap::const_iterator it;
|
||||||
|
@ -45,7 +45,7 @@ void NetworkDisconnect(bool close_admins = true);
|
|||||||
void NetworkGameLoop();
|
void NetworkGameLoop();
|
||||||
void NetworkBackgroundLoop();
|
void NetworkBackgroundLoop();
|
||||||
std::string_view ParseFullConnectionString(std::string_view connection_string, uint16_t &port, CompanyID *company_id = nullptr);
|
std::string_view ParseFullConnectionString(std::string_view connection_string, uint16_t &port, CompanyID *company_id = nullptr);
|
||||||
using NetworkCompanyStatsArray = ReferenceThroughBaseContainer<std::array<NetworkCompanyStats, MAX_COMPANIES>>;
|
using NetworkCompanyStatsArray = TypedIndexContainer<std::array<NetworkCompanyStats, MAX_COMPANIES>, CompanyID>;
|
||||||
NetworkCompanyStatsArray NetworkGetCompanyStats();
|
NetworkCompanyStatsArray NetworkGetCompanyStats();
|
||||||
|
|
||||||
void NetworkUpdateClientInfo(ClientID client_id);
|
void NetworkUpdateClientInfo(ClientID client_id);
|
||||||
|
@ -74,7 +74,7 @@ GRFLoadedFeatures _loaded_newgrf_features;
|
|||||||
|
|
||||||
GrfProcessingState _cur_gps;
|
GrfProcessingState _cur_gps;
|
||||||
|
|
||||||
ReferenceThroughBaseContainer<std::vector<GRFTempEngineData>> _gted; ///< Temporary engine data used during NewGRF loading
|
TypedIndexContainer<std::vector<GRFTempEngineData>, EngineID> _gted; ///< Temporary engine data used during NewGRF loading
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug() function dedicated to newGRF debugging messages
|
* Debug() function dedicated to newGRF debugging messages
|
||||||
|
@ -49,7 +49,7 @@ struct GRFTempEngineData {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ReferenceThroughBaseContainer<std::vector<GRFTempEngineData>> _gted; ///< Temporary engine data used during NewGRF loading
|
extern TypedIndexContainer<std::vector<GRFTempEngineData>, EngineID> _gted; ///< Temporary engine data used during NewGRF loading
|
||||||
|
|
||||||
Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16_t internal_id, bool static_access = false);
|
Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16_t internal_id, bool static_access = false);
|
||||||
void ConvertTTDBasePrice(uint32_t base_pointer, std::string_view error_location, Price *index);
|
void ConvertTTDBasePrice(uint32_t base_pointer, std::string_view error_location, Price *index);
|
||||||
|
@ -74,7 +74,7 @@ struct GRFTextEntry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static ReferenceThroughBaseContainer<std::vector<GRFTextEntry>> _grf_text;
|
static TypedIndexContainer<std::vector<GRFTextEntry>, StringIndexInTab> _grf_text;
|
||||||
static uint8_t _current_lang_id = GRFLX_ENGLISH; ///< by default, english is used.
|
static uint8_t _current_lang_id = GRFLX_ENGLISH; ///< by default, english is used.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -222,8 +222,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ReferenceThroughBaseContainer<std::vector<WaterRegionData>> _water_region_data;
|
TypedIndexContainer<std::vector<WaterRegionData>, WaterRegionIndex> _water_region_data;
|
||||||
ReferenceThroughBaseContainer<std::vector<bool>> _is_water_region_valid;
|
TypedIndexContainer<std::vector<bool>, WaterRegionIndex> _is_water_region_valid;
|
||||||
|
|
||||||
static TileIndex GetTileIndexFromLocalCoordinate(int region_x, int region_y, int local_x, int local_y)
|
static TileIndex GetTileIndexFromLocalCoordinate(int region_x, int region_y, int local_x, int local_y)
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@ static const SaveLoad _engine_desc[] = {
|
|||||||
SLE_CONDSSTR(Engine, name, SLE_STR, SLV_84, SL_MAX_VERSION),
|
SLE_CONDSSTR(Engine, name, SLE_STR, SLV_84, SL_MAX_VERSION),
|
||||||
};
|
};
|
||||||
|
|
||||||
static ReferenceThroughBaseContainer<std::vector<Engine>> _temp_engine;
|
static TypedIndexContainer<std::vector<Engine>, EngineID> _temp_engine;
|
||||||
|
|
||||||
Engine *GetTempDataEngine(EngineID index)
|
Engine *GetTempDataEngine(EngineID index)
|
||||||
{
|
{
|
||||||
@ -134,7 +134,7 @@ struct ENGSChunkHandler : ChunkHandler {
|
|||||||
{
|
{
|
||||||
/* Load old separate String ID list into a temporary array. This
|
/* Load old separate String ID list into a temporary array. This
|
||||||
* was always 256 entries. */
|
* was always 256 entries. */
|
||||||
ReferenceThroughBaseContainer<std::array<StringID, 256>> names{};
|
TypedIndexContainer<std::array<StringID, 256>, EngineID> names{};
|
||||||
|
|
||||||
SlCopy(names.data(), std::size(names), SLE_STRINGID);
|
SlCopy(names.data(), std::size(names), SLE_STRINGID);
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ private:
|
|||||||
static std::tuple<bool, bool, bool, bool> DoCommandPrep();
|
static std::tuple<bool, bool, bool, bool> DoCommandPrep();
|
||||||
static bool DoCommandProcessResult(const CommandCost &res, Script_SuspendCallbackProc *callback, bool estimate_only, bool asynchronous);
|
static bool DoCommandProcessResult(const CommandCost &res, Script_SuspendCallbackProc *callback, bool estimate_only, bool asynchronous);
|
||||||
static CommandCallbackData *GetDoCommandCallback();
|
static CommandCallbackData *GetDoCommandCallback();
|
||||||
using RandomizerArray = ReferenceThroughBaseContainer<std::array<Randomizer, OWNER_END.base()>>;
|
using RandomizerArray = TypedIndexContainer<std::array<Randomizer, OWNER_END.base()>, Owner>;
|
||||||
static RandomizerArray random_states; ///< Random states for each of the scripts (game script uses OWNER_DEITY)
|
static RandomizerArray random_states; ///< Random states for each of the scripts (game script uses OWNER_DEITY)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -598,7 +598,7 @@ struct CompanySettings {
|
|||||||
/** Container for AI and Game script configuration. */
|
/** Container for AI and Game script configuration. */
|
||||||
struct ScriptConfigSettings
|
struct ScriptConfigSettings
|
||||||
{
|
{
|
||||||
ReferenceThroughBaseContainer<std::array<std::unique_ptr<class AIConfig>, MAX_COMPANIES>> ai; ///< settings per company
|
TypedIndexContainer<std::array<std::unique_ptr<class AIConfig>, MAX_COMPANIES>, CompanyID> ai; ///< settings per company
|
||||||
std::unique_ptr<class GameConfig> game; ///< settings for gamescript
|
std::unique_ptr<class GameConfig> game; ///< settings for gamescript
|
||||||
|
|
||||||
ScriptConfigSettings();
|
ScriptConfigSettings();
|
||||||
|
@ -181,7 +181,7 @@ static IndustryType _smallmap_industry_highlight = IT_INVALID;
|
|||||||
/** State of highlight blinking */
|
/** State of highlight blinking */
|
||||||
static bool _smallmap_industry_highlight_state;
|
static bool _smallmap_industry_highlight_state;
|
||||||
/** For connecting company ID to position in owner list (small map legend) */
|
/** For connecting company ID to position in owner list (small map legend) */
|
||||||
static ReferenceThroughBaseContainer<std::array<uint32_t, MAX_COMPANIES>> _company_to_list_pos;
|
static TypedIndexContainer<std::array<uint32_t, MAX_COMPANIES>, CompanyID> _company_to_list_pos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills an array for the industries legends.
|
* Fills an array for the industries legends.
|
||||||
|
@ -4431,8 +4431,8 @@ uint MoveGoodsToStation(CargoType cargo, uint amount, Source source, const Stati
|
|||||||
return UpdateStationWaiting(first_station, cargo, amount, source);
|
return UpdateStationWaiting(first_station, cargo, amount, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReferenceThroughBaseContainer<std::array<uint32_t, OWNER_END.base()>> company_best = {}; // best rating for each company, including OWNER_NONE
|
TypedIndexContainer<std::array<uint32_t, OWNER_END.base()>, Owner> company_best = {}; // best rating for each company, including OWNER_NONE
|
||||||
ReferenceThroughBaseContainer<std::array<uint32_t, OWNER_END.base()>> company_sum = {}; // sum of ratings for each company
|
TypedIndexContainer<std::array<uint32_t, OWNER_END.base()>, Owner> company_sum = {}; // sum of ratings for each company
|
||||||
uint best_rating = 0;
|
uint best_rating = 0;
|
||||||
uint best_sum = 0; // sum of best ratings for each company
|
uint best_sum = 0; // sum of best ratings for each company
|
||||||
|
|
||||||
|
@ -69,10 +69,10 @@ struct Town : TownPool::PoolItem<&_town_pool> {
|
|||||||
|
|
||||||
/* Company ratings. */
|
/* Company ratings. */
|
||||||
CompanyMask have_ratings{}; ///< which companies have a rating
|
CompanyMask have_ratings{}; ///< which companies have a rating
|
||||||
ReferenceThroughBaseContainer<std::array<uint8_t, MAX_COMPANIES>> unwanted{}; ///< how many months companies aren't wanted by towns (bribe)
|
TypedIndexContainer<std::array<uint8_t, MAX_COMPANIES>, CompanyID> unwanted{}; ///< how many months companies aren't wanted by towns (bribe)
|
||||||
CompanyID exclusivity = CompanyID::Invalid(); ///< which company has exclusivity
|
CompanyID exclusivity = CompanyID::Invalid(); ///< which company has exclusivity
|
||||||
uint8_t exclusive_counter = 0; ///< months till the exclusivity expires
|
uint8_t exclusive_counter = 0; ///< months till the exclusivity expires
|
||||||
ReferenceThroughBaseContainer<std::array<int16_t, MAX_COMPANIES>> ratings{}; ///< ratings of each company for this town
|
TypedIndexContainer<std::array<int16_t, MAX_COMPANIES>, CompanyID> ratings{}; ///< ratings of each company for this town
|
||||||
|
|
||||||
std::array<TransportedCargoStat<uint32_t>, NUM_CARGO> supplied{}; ///< Cargo statistics about supplied cargo.
|
std::array<TransportedCargoStat<uint32_t>, NUM_CARGO> supplied{}; ///< Cargo statistics about supplied cargo.
|
||||||
std::array<TransportedCargoStat<uint16_t>, NUM_TAE> received{}; ///< Cargo statistics about received cargotypes.
|
std::array<TransportedCargoStat<uint16_t>, NUM_TAE> received{}; ///< Cargo statistics about received cargotypes.
|
||||||
|
Loading…
Reference in New Issue
Block a user