Codechange: Define GRFConfigList alias and pass by reference. (#13358)

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:
Peter Nelson
2025-01-22 22:30:32 +00:00
committed by GitHub
parent b1ab1b9f06
commit f6ab2b69c6
21 changed files with 127 additions and 120 deletions
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -696,7 +696,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();
+1 -1
View File
@@ -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 */
+1 -1
View File
@@ -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. */
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -773,7 +773,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
+1 -1
View File
@@ -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. */