# network_gamelist.cpp File Reference

This file handles the GameList Also, it handles the request to a server for data about the server. More...

`#include "../stdafx.h"`
`#include "../debug.h"`
`#include "../thread/thread.h"`
`#include "network_internal.h"`
`#include "network_udp.h"`
`#include "network_gamelist.h"`

Go to the source code of this file.

## Enumerations

enum | { MAX_GAME_LIST_REQUERY_COUNT = 10, REQUERY_EVERY_X_GAMELOOPS = 60, REFRESH_GAMEINFO_X_REQUERIES = 50 }

## Functions

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 conditions.
static void | NetworkGameListHandleDelayedInsert ()
| Perform the delayed (thread safe) insertion into the game list.
NetworkGameList * | NetworkGameListAddItem (NetworkAddress address)
| Add a new item to the linked gamelist.
void | NetworkGameListRemoveItem (NetworkGameList *remove)
| Remove an item from the gamelist linked list.
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 NewGRFs.

## Variables

NetworkGameList * | _network_game_list = NULL
| Game list of this client.
static ThreadMutex * | _network_game_list_mutex = ThreadMutex::New()
static NetworkGameList * | _network_game_delayed_insertion_list = NULL

## Detailed Description

This file handles the GameList Also, it handles the request to a server for data about the server.

Definition in file network_gamelist.cpp.

## Enumeration Type Documentation

anonymous enum

Enumerator:

  MAX_GAME_LIST_REQUERY_COUNT | How often do we requery in number of times per server?
  REQUERY_EVERY_X_GAMELOOPS | How often do we requery in time?
  REFRESH_GAMEINFO_X_REQUERIES | Refresh the game info itself after REFRESH_GAMEINFO_X_REQUERIES * REQUERY_EVERY_X_GAMELOOPS game loops.

Definition at line 135 of file network_gamelist.cpp.

## Function Documentation

NetworkGameList* NetworkGameListAddItem | ( | NetworkAddress | address | ) |

Add a new item to the linked gamelist.

If the IP and Port match return the existing item instead of adding it again

Parameters:

  | address | the address of the to-be added item
  | port | the port the server is running on

Returns:
  a point to the newly added or already existing item

Definition at line 73 of file network_gamelist.cpp.

References NetworkGameList::address, NetworkAddress::GetHostname(), NetworkGameList::next, StrEmpty(), and UpdateNetworkGameWindow().

Referenced by NetworkGameListHandleDelayedInsert(), and NetworkGameWindow::OnClick().

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 conditions.

Parameters:

  | item | the item to add. Will be freed once added.

Definition at line 33 of file network_gamelist.cpp.

References ThreadMutex::BeginCritical(), ThreadMutex::EndCritical(), and NetworkGameList::next.

Referenced by NetworkUDPQueryServerThread().

void NetworkGameListRemoveItem | ( | NetworkGameList * | remove | ) |

Remove an item from the gamelist linked list.

Parameters:

  | remove | pointer to the item to be removed

Definition at line 110 of file network_gamelist.cpp.

References NetworkGameList::next, and UpdateNetworkGameWindow().

Referenced by NetworkGameWindow::OnKeyPress().