mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Define GRFConfigList alias and pass by reference.
This adds the distinction between a single GRFConfig and a GRFConfig list, and simplifies how GRFConfig lists are passed to various functions.
This commit is contained in:
parent
963ea141f2
commit
b5a7f1e975
|
@ -42,7 +42,7 @@ struct LoadCheckData {
|
|||
|
||||
CompanyPropertiesMap companies; ///< Company information.
|
||||
|
||||
GRFConfig *grfconfig; ///< NewGrf configuration from save.
|
||||
GRFConfigList grfconfig; ///< NewGrf configuration from save.
|
||||
GRFListCompatibility grf_compatibility; ///< Summary state of NewGrfs, whether missing files or only compatible found.
|
||||
|
||||
Gamelog gamelog; ///< Gamelog actions
|
||||
|
|
|
@ -59,7 +59,7 @@ void LoadCheckData::Clear()
|
|||
|
||||
this->gamelog.Reset();
|
||||
|
||||
ClearGRFConfigList(&this->grfconfig);
|
||||
ClearGRFConfigList(this->grfconfig);
|
||||
}
|
||||
|
||||
/** Load game/scenario with optional content download */
|
||||
|
@ -634,7 +634,7 @@ public:
|
|||
|
||||
case WID_SL_NEWGRF_INFO:
|
||||
if (_load_check_data.HasNewGrfs()) {
|
||||
ShowNewGRFSettings(false, false, false, &_load_check_data.grfconfig);
|
||||
ShowNewGRFSettings(false, false, false, _load_check_data.grfconfig);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -573,22 +573,22 @@ void Gamelog::GRFParameters(uint32_t grfid)
|
|||
/**
|
||||
* Logs adding of list of GRFs.
|
||||
* Useful when old savegame is loaded or when new game is started
|
||||
* @param newg head of GRF linked list
|
||||
* @param newg the GRFConfigList.
|
||||
*/
|
||||
void Gamelog::GRFAddList(const GRFConfig *newg)
|
||||
void Gamelog::GRFAddList(const GRFConfigList &newg)
|
||||
{
|
||||
assert(this->action_type == GLAT_START || this->action_type == GLAT_LOAD);
|
||||
|
||||
for (; newg != nullptr; newg = newg->next) {
|
||||
this->GRFAdd(newg);
|
||||
for (GRFConfig *gc = newg; gc != nullptr; gc = gc->next) {
|
||||
this->GRFAdd(gc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates GRFList
|
||||
* @param grfc head of GRF linked list
|
||||
* @param grfc the GRFConfigList.
|
||||
*/
|
||||
static std::vector<const GRFConfig *> GenerateGRFList(const GRFConfig *grfc)
|
||||
static std::vector<const GRFConfig *> GenerateGRFList(const GRFConfigList &grfc)
|
||||
{
|
||||
std::vector<const GRFConfig *> list;
|
||||
for (const GRFConfig *g = grfc; g != nullptr; g = g->next) {
|
||||
|
@ -603,7 +603,7 @@ static std::vector<const GRFConfig *> GenerateGRFList(const GRFConfig *grfc)
|
|||
* @param oldc original GRF list
|
||||
* @param newc new GRF list
|
||||
*/
|
||||
void Gamelog::GRFUpdate(const GRFConfig *oldc, const GRFConfig *newc)
|
||||
void Gamelog::GRFUpdate(const GRFConfigList &oldc, const GRFConfigList &newc)
|
||||
{
|
||||
std::vector<const GRFConfig *> ol = GenerateGRFList(oldc);
|
||||
std::vector<const GRFConfig *> nl = GenerateGRFList(newc);
|
||||
|
|
|
@ -76,8 +76,8 @@ public:
|
|||
void Oldver();
|
||||
void Setting(const std::string &name, int32_t oldval, int32_t newval);
|
||||
|
||||
void GRFUpdate(const GRFConfig *oldg, const GRFConfig *newg);
|
||||
void GRFAddList(const GRFConfig *newg);
|
||||
void GRFUpdate(const GRFConfigList &oldg, const GRFConfigList &newg);
|
||||
void GRFAddList(const GRFConfigList &newg);
|
||||
void GRFRemove(uint32_t grfid);
|
||||
void GRFAdd(const GRFConfig *newg);
|
||||
void GRFBug(uint32_t grfid, uint8_t bug, uint64_t data);
|
||||
|
|
|
@ -866,7 +866,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
break;
|
||||
|
||||
case WID_GL_NEWGRF_BUTTON: ///< NewGRF Settings
|
||||
ShowNewGRFSettings(true, true, false, &_grfconfig_newgame);
|
||||
ShowNewGRFSettings(true, true, false, _grfconfig_newgame);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -362,7 +362,7 @@ struct SelectGameWindow : public Window {
|
|||
case WID_SGI_HIGHSCORE: ShowHighscoreTable(); break;
|
||||
case WID_SGI_HELP: ShowHelpWindow(); break;
|
||||
case WID_SGI_SETTINGS_OPTIONS:ShowGameSettings(); break;
|
||||
case WID_SGI_GRF_SETTINGS: ShowNewGRFSettings(true, true, false, &_grfconfig_newgame); break;
|
||||
case WID_SGI_GRF_SETTINGS: ShowNewGRFSettings(true, true, false, _grfconfig_newgame); break;
|
||||
case WID_SGI_CONTENT_DOWNLOAD:
|
||||
if (!_network_available) {
|
||||
ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
|
||||
|
|
|
@ -94,7 +94,7 @@ enum NewGRFSerializationType {
|
|||
* The game information that is sent from the server to the client.
|
||||
*/
|
||||
struct NetworkServerGameInfo {
|
||||
GRFConfig *grfconfig; ///< List of NewGRF files used
|
||||
GRFConfigList grfconfig; ///< List of NewGRF files used
|
||||
TimerGameCalendar::Date calendar_start; ///< When the game started.
|
||||
TimerGameCalendar::Date calendar_date; ///< Current calendar date.
|
||||
TimerGameTick::TickCounter ticks_playing; ///< Amount of ticks the game has been running unpaused.
|
||||
|
|
|
@ -741,7 +741,7 @@ NetworkGameList *NetworkAddServer(const std::string &connection_string, bool man
|
|||
/* Ensure the item already exists in the list */
|
||||
NetworkGameList *item = NetworkGameListAddItem(connection_string);
|
||||
if (item->info.server_name.empty()) {
|
||||
ClearGRFConfigList(&item->info.grfconfig);
|
||||
ClearGRFConfigList(item->info.grfconfig);
|
||||
item->info.server_name = connection_string;
|
||||
|
||||
UpdateNetworkGameWindow();
|
||||
|
|
|
@ -153,6 +153,6 @@ extern ClientNetworkContentSocketHandler _network_content_client;
|
|||
|
||||
void ShowNetworkContentListWindow(ContentVector *cv = nullptr, ContentType type1 = CONTENT_TYPE_END, ContentType type2 = CONTENT_TYPE_END);
|
||||
|
||||
void ShowMissingContentWindow(const struct GRFConfig *list);
|
||||
void ShowMissingContentWindow(const GRFConfigList &list);
|
||||
|
||||
#endif /* NETWORK_CONTENT_H */
|
||||
|
|
|
@ -251,7 +251,7 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_LISTING(Packet &p)
|
|||
NetworkGameList *item = NetworkGameListAddItem(connection_string);
|
||||
|
||||
/* Clear any existing GRFConfig chain. */
|
||||
ClearGRFConfigList(&item->info.grfconfig);
|
||||
ClearGRFConfigList(item->info.grfconfig);
|
||||
/* Copy the new NetworkGameInfo info. */
|
||||
item->info = ngi;
|
||||
/* Check for compatability with the client. */
|
||||
|
|
|
@ -73,7 +73,7 @@ void NetworkGameListRemoveItem(NetworkGameList *remove)
|
|||
}
|
||||
|
||||
/* Remove GRFConfig information */
|
||||
ClearGRFConfigList(&remove->info.grfconfig);
|
||||
ClearGRFConfigList(remove->info.grfconfig);
|
||||
delete remove;
|
||||
|
||||
NetworkRebuildHostList();
|
||||
|
@ -100,7 +100,7 @@ void NetworkGameListRemoveExpired()
|
|||
*prev_item = item;
|
||||
|
||||
/* Remove GRFConfig information */
|
||||
ClearGRFConfigList(&remove->info.grfconfig);
|
||||
ClearGRFConfigList(remove->info.grfconfig);
|
||||
delete remove;
|
||||
} else {
|
||||
prev_item = &item->next;
|
||||
|
|
|
@ -768,7 +768,7 @@ public:
|
|||
break;
|
||||
|
||||
case WID_NG_NEWGRF: // NewGRF Settings
|
||||
if (this->server != nullptr) ShowNewGRFSettings(false, false, false, &this->server->info.grfconfig);
|
||||
if (this->server != nullptr) ShowNewGRFSettings(false, false, false, this->server->info.grfconfig);
|
||||
break;
|
||||
|
||||
case WID_NG_NEWGRF_MISSING: // Find missing content online
|
||||
|
|
|
@ -120,7 +120,7 @@ NetworkRecvStatus QueryNetworkGameSocketHandler::Receive_SERVER_GAME_INFO(Packet
|
|||
NetworkGameList *item = NetworkGameListAddItem(this->connection_string);
|
||||
|
||||
/* Clear any existing GRFConfig chain. */
|
||||
ClearGRFConfigList(&item->info.grfconfig);
|
||||
ClearGRFConfigList(item->info.grfconfig);
|
||||
/* Retrieve the NetworkGameInfo from the packet. */
|
||||
DeserializeNetworkGameInfo(p, item->info);
|
||||
/* Check for compatability with the client. */
|
||||
|
|
|
@ -159,10 +159,10 @@ void GRFConfig::FinalizeParameterInfo()
|
|||
}
|
||||
}
|
||||
|
||||
GRFConfig *_all_grfs;
|
||||
GRFConfig *_grfconfig;
|
||||
GRFConfig *_grfconfig_newgame;
|
||||
GRFConfig *_grfconfig_static;
|
||||
GRFConfigList _all_grfs;
|
||||
GRFConfigList _grfconfig;
|
||||
GRFConfigList _grfconfig_newgame;
|
||||
GRFConfigList _grfconfig_static;
|
||||
uint _missing_extra_graphics = 0;
|
||||
|
||||
/**
|
||||
|
@ -352,14 +352,14 @@ bool FillGRFDetails(GRFConfig *config, bool is_static, Subdirectory subdir)
|
|||
* @param config Start of the list.
|
||||
* @post \a config is set to \c nullptr.
|
||||
*/
|
||||
void ClearGRFConfigList(GRFConfig **config)
|
||||
void ClearGRFConfigList(GRFConfigList &config)
|
||||
{
|
||||
GRFConfig *c, *next;
|
||||
for (c = *config; c != nullptr; c = next) {
|
||||
for (c = config; c != nullptr; c = next) {
|
||||
next = c->next;
|
||||
delete c;
|
||||
}
|
||||
*config = nullptr;
|
||||
config = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -370,21 +370,22 @@ void ClearGRFConfigList(GRFConfig **config)
|
|||
* @param init_only the copied GRF will be processed up to GLS_INIT
|
||||
* @return pointer to the last value added to the destination list
|
||||
*/
|
||||
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only)
|
||||
GRFConfig **CopyGRFConfigList(GRFConfigList &dst, const GRFConfigList &src, bool init_only)
|
||||
{
|
||||
/* Clear destination as it will be overwritten */
|
||||
ClearGRFConfigList(dst);
|
||||
for (; src != nullptr; src = src->next) {
|
||||
GRFConfig *c = new GRFConfig(*src);
|
||||
GRFConfig **tail = &dst;
|
||||
for (GRFConfig *s = src; s != nullptr; s = s->next) {
|
||||
GRFConfig *c = new GRFConfig(*s);
|
||||
|
||||
ClrBit(c->flags, GCF_INIT_ONLY);
|
||||
if (init_only) SetBit(c->flags, GCF_INIT_ONLY);
|
||||
|
||||
*dst = c;
|
||||
dst = &c->next;
|
||||
*tail = c;
|
||||
tail = &c->next;
|
||||
}
|
||||
|
||||
return dst;
|
||||
return tail;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -400,7 +401,7 @@ GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_o
|
|||
*
|
||||
* @param list the list to remove the duplicates from
|
||||
*/
|
||||
static void RemoveDuplicatesFromGRFConfigList(GRFConfig *list)
|
||||
static void RemoveDuplicatesFromGRFConfigList(GRFConfigList &list)
|
||||
{
|
||||
GRFConfig *prev;
|
||||
GRFConfig *cur;
|
||||
|
@ -422,13 +423,13 @@ static void RemoveDuplicatesFromGRFConfigList(GRFConfig *list)
|
|||
* Appends the static GRFs to a list of GRFs
|
||||
* @param dst the head of the list to add to
|
||||
*/
|
||||
void AppendStaticGRFConfigs(GRFConfig **dst)
|
||||
void AppendStaticGRFConfigs(GRFConfigList &dst)
|
||||
{
|
||||
GRFConfig **tail = dst;
|
||||
GRFConfig **tail = &dst;
|
||||
while (*tail != nullptr) tail = &(*tail)->next;
|
||||
|
||||
CopyGRFConfigList(tail, _grfconfig_static, false);
|
||||
RemoveDuplicatesFromGRFConfigList(*dst);
|
||||
CopyGRFConfigList(*tail, _grfconfig_static, false);
|
||||
RemoveDuplicatesFromGRFConfigList(dst);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -436,21 +437,21 @@ void AppendStaticGRFConfigs(GRFConfig **dst)
|
|||
* @param dst the head of the list to add to
|
||||
* @param el the new tail to be
|
||||
*/
|
||||
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el)
|
||||
void AppendToGRFConfigList(GRFConfigList &dst, GRFConfig *el)
|
||||
{
|
||||
GRFConfig **tail = dst;
|
||||
GRFConfig **tail = &dst;
|
||||
while (*tail != nullptr) tail = &(*tail)->next;
|
||||
*tail = el;
|
||||
|
||||
RemoveDuplicatesFromGRFConfigList(*dst);
|
||||
RemoveDuplicatesFromGRFConfigList(dst);
|
||||
}
|
||||
|
||||
|
||||
/** Reset the current GRF Config to either blank or newgame settings. */
|
||||
void ResetGRFConfig(bool defaults)
|
||||
{
|
||||
CopyGRFConfigList(&_grfconfig, _grfconfig_newgame, !defaults);
|
||||
AppendStaticGRFConfigs(&_grfconfig);
|
||||
CopyGRFConfigList(_grfconfig, _grfconfig_newgame, !defaults);
|
||||
AppendStaticGRFConfigs(_grfconfig);
|
||||
}
|
||||
|
||||
|
||||
|
@ -465,7 +466,7 @@ void ResetGRFConfig(bool defaults)
|
|||
* <li> GLC_NOT_FOUND: For one or more GRF's no match was found at all
|
||||
* </ul>
|
||||
*/
|
||||
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
|
||||
GRFListCompatibility IsGoodGRFConfigList(GRFConfigList &grfconfig)
|
||||
{
|
||||
GRFListCompatibility res = GLC_ALL_GOOD;
|
||||
|
||||
|
@ -623,7 +624,7 @@ static bool GRFSorter(GRFConfig * const &c1, GRFConfig * const &c2)
|
|||
*/
|
||||
void DoScanNewGRFFiles(NewGRFScanCallback *callback)
|
||||
{
|
||||
ClearGRFConfigList(&_all_grfs);
|
||||
ClearGRFConfigList(_all_grfs);
|
||||
TarScanner::DoScan(TarScanner::NEWGRF);
|
||||
|
||||
Debug(grf, 1, "Scanning for NewGRFs");
|
||||
|
|
|
@ -187,6 +187,8 @@ struct GRFConfig {
|
|||
void FinalizeParameterInfo();
|
||||
};
|
||||
|
||||
using GRFConfigList = GRFConfig *;
|
||||
|
||||
/** Method to find GRFs using FindGRFConfig */
|
||||
enum FindGRFConfigMode {
|
||||
FGCM_EXACT, ///< Only find Grfs matching md5sum
|
||||
|
@ -196,10 +198,10 @@ enum FindGRFConfigMode {
|
|||
FGCM_ANY, ///< Use first found
|
||||
};
|
||||
|
||||
extern GRFConfig *_all_grfs; ///< First item in list of all scanned NewGRFs
|
||||
extern GRFConfig *_grfconfig; ///< First item in list of current GRF set up
|
||||
extern GRFConfig *_grfconfig_newgame; ///< First item in list of default GRF set up
|
||||
extern GRFConfig *_grfconfig_static; ///< First item in list of static GRF set up
|
||||
extern GRFConfigList _all_grfs; ///< First item in list of all scanned NewGRFs
|
||||
extern GRFConfigList _grfconfig; ///< First item in list of current GRF set up
|
||||
extern GRFConfigList _grfconfig_newgame; ///< First item in list of default GRF set up
|
||||
extern GRFConfigList _grfconfig_static; ///< First item in list of static GRF set up
|
||||
extern uint _missing_extra_graphics; ///< Number of sprites provided by the fallback extra GRF, i.e. missing in the baseset.
|
||||
|
||||
/** Callback for NewGRF scanning. */
|
||||
|
@ -215,17 +217,17 @@ size_t GRFGetSizeOfDataSection(FILE *f);
|
|||
void ScanNewGRFFiles(NewGRFScanCallback *callback);
|
||||
const GRFConfig *FindGRFConfig(uint32_t grfid, FindGRFConfigMode mode, const MD5Hash *md5sum = nullptr, uint32_t desired_version = 0);
|
||||
GRFConfig *GetGRFConfig(uint32_t grfid, uint32_t mask = 0xFFFFFFFF);
|
||||
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only);
|
||||
void AppendStaticGRFConfigs(GRFConfig **dst);
|
||||
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el);
|
||||
void ClearGRFConfigList(GRFConfig **config);
|
||||
GRFConfig **CopyGRFConfigList(GRFConfigList &dst, const GRFConfigList &src, bool init_only);
|
||||
void AppendStaticGRFConfigs(GRFConfigList &dst);
|
||||
void AppendToGRFConfigList(GRFConfigList &dst, GRFConfig *el);
|
||||
void ClearGRFConfigList(GRFConfigList &config);
|
||||
void ResetGRFConfig(bool defaults);
|
||||
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig);
|
||||
GRFListCompatibility IsGoodGRFConfigList(GRFConfigList &grfconfig);
|
||||
bool FillGRFDetails(GRFConfig *config, bool is_static, Subdirectory subdir = NEWGRF_DIR);
|
||||
std::string GRFBuildParamList(const GRFConfig *c);
|
||||
|
||||
/* In newgrf_gui.cpp */
|
||||
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);
|
||||
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfigList &config);
|
||||
void OpenGRFParameterWindow(bool is_baseset, GRFConfig *c, bool editable);
|
||||
|
||||
void UpdateNewGRFScanStatus(uint num, const char *name);
|
||||
|
|
|
@ -620,10 +620,10 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||
|
||||
StringList grf_presets; ///< List of known NewGRF presets.
|
||||
|
||||
GRFConfig *actives; ///< Temporary active grf list to which changes are made.
|
||||
GRFConfigList actives; ///< Temporary active grf list to which changes are made.
|
||||
GRFConfig *active_sel; ///< Selected active grf item.
|
||||
|
||||
GRFConfig **orig_list; ///< List active grfs in the game. Used as initial value, may be updated by the window.
|
||||
GRFConfigList *orig_list; ///< List active grfs in the game. Used as initial value, may be updated by the window.
|
||||
bool editable; ///< Is the window editable?
|
||||
bool show_params; ///< Are the grf-parameters shown in the info-panel?
|
||||
bool execute; ///< On pressing 'apply changes' are grf changes applied immediately, or only list is updated.
|
||||
|
@ -634,7 +634,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||
Scrollbar *vscroll;
|
||||
Scrollbar *vscroll2;
|
||||
|
||||
NewGRFWindow(WindowDesc *desc, bool editable, bool show_params, bool execute, GRFConfig **orig_list) : Window(desc), filter_editbox(EDITBOX_MAX_SIZE)
|
||||
NewGRFWindow(WindowDesc *desc, bool editable, bool show_params, bool execute, GRFConfigList *orig_list) : Window(desc), filter_editbox(EDITBOX_MAX_SIZE)
|
||||
{
|
||||
this->avail_sel = nullptr;
|
||||
this->avail_pos = -1;
|
||||
|
@ -647,7 +647,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||
this->preset = -1;
|
||||
this->active_over = -1;
|
||||
|
||||
CopyGRFConfigList(&this->actives, *orig_list, false);
|
||||
CopyGRFConfigList(this->actives, *orig_list, false);
|
||||
this->grf_presets = GetGRFPresetList();
|
||||
|
||||
this->CreateNestedTree();
|
||||
|
@ -682,7 +682,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||
CloseWindowByClass(WC_SAVE_PRESET);
|
||||
|
||||
if (this->editable && this->modified && !this->execute && !_exit_game) {
|
||||
CopyGRFConfigList(this->orig_list, this->actives, true);
|
||||
CopyGRFConfigList(*this->orig_list, this->actives, true);
|
||||
ResetGRFConfig(false);
|
||||
ReloadNewGRFData();
|
||||
}
|
||||
|
@ -693,7 +693,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||
~NewGRFWindow()
|
||||
{
|
||||
/* Remove the temporary copy of grf-list used in window */
|
||||
ClearGRFConfigList(&this->actives);
|
||||
ClearGRFConfigList(this->actives);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1123,7 +1123,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||
NewGRFConfirmationCallback
|
||||
);
|
||||
} else {
|
||||
CopyGRFConfigList(this->orig_list, this->actives, true);
|
||||
CopyGRFConfigList(*this->orig_list, this->actives, true);
|
||||
ResetGRFConfig(false);
|
||||
ReloadNewGRFData();
|
||||
this->InvalidateData(GOID_NEWGRF_CHANGES_APPLIED);
|
||||
|
@ -1180,7 +1180,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||
if (widget != WID_NS_PRESET_LIST) return;
|
||||
if (!this->editable) return;
|
||||
|
||||
ClearGRFConfigList(&this->actives);
|
||||
ClearGRFConfigList(this->actives);
|
||||
this->preset = index;
|
||||
|
||||
if (index != -1) {
|
||||
|
@ -1565,7 +1565,7 @@ private:
|
|||
* Show the content list window with all missing grfs from the given list.
|
||||
* @param list The list of grfs to check for missing / not exactly matching ones.
|
||||
*/
|
||||
void ShowMissingContentWindow(const GRFConfig *list)
|
||||
void ShowMissingContentWindow(const GRFConfigList &list)
|
||||
{
|
||||
/* Only show the things in the current list, or everything when nothing's selected */
|
||||
ContentVector cv;
|
||||
|
@ -1987,7 +1987,7 @@ static void NewGRFConfirmationCallback(Window *w, bool confirmed)
|
|||
|
||||
_gamelog.StartAction(GLAT_GRF);
|
||||
_gamelog.GRFUpdate(_grfconfig, nw->actives); // log GRF changes
|
||||
CopyGRFConfigList(nw->orig_list, nw->actives, false);
|
||||
CopyGRFConfigList(*nw->orig_list, nw->actives, false);
|
||||
ReloadNewGRFData();
|
||||
_gamelog.StopAction();
|
||||
|
||||
|
@ -1995,7 +1995,7 @@ static void NewGRFConfirmationCallback(Window *w, bool confirmed)
|
|||
GRFConfig *c;
|
||||
int i = 0;
|
||||
for (c = nw->actives; c != nullptr && c != nw->active_sel; c = c->next, i++) {}
|
||||
CopyGRFConfigList(&nw->actives, *nw->orig_list, false);
|
||||
CopyGRFConfigList(nw->actives, *nw->orig_list, false);
|
||||
for (c = nw->actives; c != nullptr && i > 0; c = c->next, i--) {}
|
||||
nw->active_sel = c;
|
||||
nw->avails.ForceRebuild();
|
||||
|
@ -2016,12 +2016,12 @@ static void NewGRFConfirmationCallback(Window *w, bool confirmed)
|
|||
* @param show_params show information about what parameters are set for the grf files
|
||||
* @param exec_changes if changes are made to the list (editable is true), apply these
|
||||
* changes immediately or only update the list
|
||||
* @param config pointer to a linked-list of grfconfig's that will be shown
|
||||
* @param config The GRFConfigList that will be shown.
|
||||
*/
|
||||
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
|
||||
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfigList &config)
|
||||
{
|
||||
CloseWindowByClass(WC_GAME_OPTIONS);
|
||||
new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config);
|
||||
new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, &config);
|
||||
}
|
||||
|
||||
/** Widget parts of the save preset window. */
|
||||
|
|
|
@ -90,16 +90,16 @@ struct NGRFChunkHandler : ChunkHandler {
|
|||
}
|
||||
|
||||
|
||||
void LoadCommon(GRFConfig *&grfconfig) const
|
||||
void LoadCommon(GRFConfigList &grfconfig) const
|
||||
{
|
||||
const std::vector<SaveLoad> slt = SlCompatTableHeader(_grfconfig_desc, _grfconfig_sl_compat);
|
||||
|
||||
ClearGRFConfigList(&grfconfig);
|
||||
ClearGRFConfigList(grfconfig);
|
||||
while (SlIterateArray() != -1) {
|
||||
GRFConfig *c = new GRFConfig();
|
||||
SlObject(c, slt);
|
||||
if (IsSavegameVersionBefore(SLV_101)) c->SetSuitablePalette();
|
||||
AppendToGRFConfigList(&grfconfig, c);
|
||||
AppendToGRFConfigList(grfconfig, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ struct NGRFChunkHandler : ChunkHandler {
|
|||
ResetGRFConfig(false);
|
||||
} else {
|
||||
/* Append static NewGRF configuration */
|
||||
AppendStaticGRFConfigs(&_grfconfig);
|
||||
AppendStaticGRFConfigs(_grfconfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1554,7 +1554,7 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int)
|
|||
/* Skip the first element: TTDP hack for the Action D special variables (FFFF0000 01) */
|
||||
ReadUint32(ls); ReadByte(ls); len -= 5;
|
||||
|
||||
ClearGRFConfigList(&_grfconfig);
|
||||
ClearGRFConfigList(_grfconfig);
|
||||
while (len != 0) {
|
||||
uint32_t grfid = ReadUint32(ls);
|
||||
|
||||
|
@ -1562,14 +1562,14 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int)
|
|||
GRFConfig *c = new GRFConfig("TTDP game, no information");
|
||||
c->ident.grfid = grfid;
|
||||
|
||||
AppendToGRFConfigList(&_grfconfig, c);
|
||||
AppendToGRFConfigList(_grfconfig, c);
|
||||
Debug(oldloader, 3, "TTDPatch game using GRF file with GRFID {:08X}", BSWAP32(c->ident.grfid));
|
||||
}
|
||||
len -= 5;
|
||||
}
|
||||
|
||||
/* Append static NewGRF configuration */
|
||||
AppendStaticGRFConfigs(&_grfconfig);
|
||||
AppendStaticGRFConfigs(_grfconfig);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -2997,7 +2997,7 @@ static SaveOrLoadResult DoLoad(std::shared_ptr<LoadFilter> reader, bool load_che
|
|||
* Note: this is done here because AfterLoadGame is also called
|
||||
* for TTO/TTD/TTDP savegames which have their own NewGRF logic.
|
||||
*/
|
||||
ClearGRFConfigList(&_grfconfig);
|
||||
ClearGRFConfigList(_grfconfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3080,7 +3080,7 @@ SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop,
|
|||
* and if so a new NewGRF list will be made in LoadOldSaveGame.
|
||||
* Note: this is done here because AfterLoadGame is also called
|
||||
* for OTTD savegames which have their own NewGRF logic. */
|
||||
ClearGRFConfigList(&_grfconfig);
|
||||
ClearGRFConfigList(_grfconfig);
|
||||
_gamelog.Reset();
|
||||
if (!LoadOldSaveGame(filename)) return SL_REINIT;
|
||||
_sl_version = SL_MIN_VERSION;
|
||||
|
|
|
@ -296,7 +296,7 @@ static CallBackFunction MenuClickSettings(int index)
|
|||
case OME_SETTINGS: ShowGameSettings(); return CBF_NONE;
|
||||
case OME_AI_SETTINGS: ShowAIConfigWindow(); return CBF_NONE;
|
||||
case OME_GAMESCRIPT_SETTINGS: ShowGSConfigWindow(); return CBF_NONE;
|
||||
case OME_NEWGRFSETTINGS: ShowNewGRFSettings(!_networking && _settings_client.gui.UserIsAllowedToChangeNewGRFs(), true, true, &_grfconfig); return CBF_NONE;
|
||||
case OME_NEWGRFSETTINGS: ShowNewGRFSettings(!_networking && _settings_client.gui.UserIsAllowedToChangeNewGRFs(), true, true, _grfconfig); return CBF_NONE;
|
||||
case OME_SANDBOX: ShowCheatWindow(); break;
|
||||
case OME_TRANSPARENCIES: ShowTransparencyToolbar(); break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue