13 #include "../stdafx.h" 15 #include "../window_func.h" 21 #include "../safeguards.h" 45 if (ins_item ==
nullptr)
break;
49 if (item !=
nullptr) {
52 memset(&item->
info, 0,
sizeof(item->
info));
58 if (item->
manually) NetworkRebuildHostList();
77 strcmp(hostname,
"0.0.0.0") == 0 ||
78 strcmp(hostname,
"::") == 0) {
85 for (item = _network_game_list; item !=
nullptr; item = item->
next) {
86 if (item->
address == address)
return item;
90 item = CallocT<NetworkGameList>(1);
94 if (prev_item ==
nullptr) {
95 _network_game_list = item;
97 prev_item->
next = item;
99 DEBUG(net, 4,
"[gamelist] added server to list");
114 if (
remove == item) {
115 if (prev_item ==
nullptr) {
116 _network_game_list =
remove->
next;
126 DEBUG(net, 4,
"[gamelist] removed server from list");
127 NetworkRebuildHostList();
144 static uint8 requery_cnt = 0;
154 uint8 retries = item->retries;
168 item->info.compatible = item->info.version_compatible;
170 for (
GRFConfig *c = item->
info.grfconfig; c !=
nullptr; c = c->next) {
184 item->info.compatible =
false;
NetworkGameList * next
Next pointer to make a linked game list.
void ClearGRFConfigList(GRFConfig **config)
Clear a GRF Config list, freeing all nodes.
static std::atomic< NetworkGameList * > _network_game_delayed_insertion_list(nullptr)
The games to insert when the GUI thread has time for us.
Sending and receiving UDP messages.
void NetworkGameListRemoveItem(NetworkGameList *remove)
Remove an item from the gamelist linked list.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
#define lastof(x)
Get the last element of an fixed size array.
GRF file was not found in the local cache.
Structure with information shown in the game list (GUI)
void NetworkUDPQueryServer(NetworkAddress address, bool manually)
Query a specific server.
const GRFConfig * FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum, uint32 desired_version)
Find a NewGRF in the scanned list.
char server_name[NETWORK_NAME_LENGTH]
Server name.
void UpdateNetworkGameWindow()
Update the network new window because a new server is found on the network.
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
static void NetworkGameListHandleDelayedInsert()
Perform the delayed (thread safe) insertion into the game list.
static const uint REQUERY_EVERY_X_GAMELOOPS
How often do we requery in time?
NetworkGameList * NetworkGameListAddItem(NetworkAddress address)
Add a new item to the linked gamelist.
GRFTextWrapper * FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create)
Finds the name of a NewGRF in the list of names for unknown GRFs.
Information about GRF, used in the game and (part of it) in savegames.
The data is copied from a grf in _all_grfs.
NetworkAddress address
The connection info of the game server.
const char * GetHostname()
Get the hostname; in case it wasn't given the IPv4 dotted representation is given.
NetworkGameInfo info
The game information of this server.
NetworkGameList * _network_game_list
Game list of this client.
void NetworkGameListRequery()
Requeries the (game) servers we have not gotten a reply from.
void NetworkAfterNewGRFScan()
Rebuild the GRFConfig's of the servers in the game list as we did a rescan and might have found new N...
The status of this grf file is unknown.
#define DEBUG(name, level,...)
Output a line of debugging information.
bool online
False if the server did not respond (default status)
static const uint MAX_GAME_LIST_REQUERY_COUNT
How often do we requery in number of times per server?
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Variables and function used internally.
Handling of the list of games.
void NetworkGameListAddItemDelayed(NetworkGameList *item)
Add a new item to the linked gamelist, but do it delayed in the next tick or so to prevent race condi...
Network window; Window numbers:
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
char * filename
Filename - either with or without full path.
GRFTextWrapper * name
NOSAVE: GRF name (Action 0x08)
bool manually
True if the server was added manually.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
char hostname[NETWORK_HOSTNAME_LENGTH]
Hostname of the server (if any)
Only find Grfs matching md5sum.
GRFConfig * grfconfig
List of NewGRF files used.
static const uint REFRESH_GAMEINFO_X_REQUERIES
Refresh the game info itself after REFRESH_GAMEINFO_X_REQUERIES * REQUERY_EVERY_X_GAMELOOPS game loop...
GRFTextWrapper * info
NOSAVE: GRF info (author, copyright, ...) (Action 0x08)