17 #include "../stdafx.h" 19 #include "../window_func.h" 20 #include "../thread/thread.h" 25 #include "../safeguards.h" 43 _network_game_delayed_insertion_list = item;
51 while (_network_game_delayed_insertion_list != NULL) {
53 _network_game_delayed_insertion_list = ins_item->
next;
60 memset(&item->
info, 0,
sizeof(item->
info));
66 if (item->
manually) NetworkRebuildHostList();
86 strcmp(hostname,
"0.0.0.0") == 0 ||
87 strcmp(hostname,
"::") == 0) {
94 for (item = _network_game_list; item != NULL; item = item->
next) {
95 if (item->
address == address)
return item;
99 item = CallocT<NetworkGameList>(1);
103 if (prev_item == NULL) {
104 _network_game_list = item;
106 prev_item->
next = item;
108 DEBUG(net, 4,
"[gamelist] added server to list");
123 if (
remove == item) {
124 if (prev_item == NULL) {
125 _network_game_list =
remove->
next;
135 DEBUG(net, 4,
"[gamelist] removed server from list");
136 NetworkRebuildHostList();
153 static uint8 requery_cnt = 0;
163 uint8 retries = item->retries;
177 item->info.compatible = item->info.version_compatible;
179 for (
GRFConfig *c = item->
info.grfconfig; c != NULL; c = c->next) {
193 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.
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)
const GRFConfig * FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum, uint32 desired_version)
Find a NewGRF in the scanned list.
virtual void EndCritical(bool allow_recursive=false)=0
End of the critical section.
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.
static ThreadMutex * New()
Create a new mutex.
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...
static NetworkGameList * _network_game_delayed_insertion_list
The games to insert when the GUI thread has time for us.
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)
static void NetworkUDPQueryServer(NetworkAddress *address, bool needs_mutex, bool manually)
Helper function doing the actual work for querying the server.
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 ThreadMutex * _network_game_list_mutex
Mutex for handling delayed insertion/querying of servers.
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)
virtual void BeginCritical(bool allow_recursive=false)=0
Begin the critical section.
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)