OpenTTD: src/network/network_gamelist.cpp File Reference

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

Functions | Variables
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 "../window_func.h"`
`#include "../thread/thread.h"`
`#include "network_internal.h"`
`#include "network_udp.h"`
`#include "network_gamelist.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## 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()
| Mutex for handling delayed insertion/querying of servers.
static NetworkGameList * | _network_game_delayed_insertion_list = NULL
| The games to insert when the GUI thread has time for us.
static const uint | MAX_GAME_LIST_REQUERY_COUNT = 10
| How often do we requery in number of times per server?
static const uint | REQUERY_EVERY_X_GAMELOOPS = 60
| How often do we requery in time?
static const uint | REFRESH_GAMEINFO_X_REQUERIES = 50
| Refresh the game info itself after REFRESH_GAMEINFO_X_REQUERIES * REQUERY_EVERY_X_GAMELOOPS game loops.

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

## 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

Returns
  a point to the newly added or already existing item

Definition at line 80 of file network_gamelist.cpp.

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

Referenced by NetworkGameListHandleDelayedInsert(), and ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE().

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 39 of file network_gamelist.cpp.

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

Referenced by NetworkUDPQueryServer().

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

Remove an item from the gamelist linked list.

Parameters

  remove | pointer to the item to be removed

Definition at line 119 of file network_gamelist.cpp.

References ClearGRFConfigList(), DEBUG, free(), NetworkGameList::next, and UpdateNetworkGameWindow().

Referenced by NetworkGameWindow::OnKeyPress().

## Variable Documentation

NetworkGameList* _network_game_delayed_insertion_list = NULL
| static

The games to insert when the GUI thread has time for us.

Definition at line 32 of file network_gamelist.cpp.

Referenced by NetworkGameListAddItemDelayed(), and NetworkGameListHandleDelayedInsert().

ThreadMutex* _network_game_list_mutex = ThreadMutex::New()
| static

Mutex for handling delayed insertion/querying of servers.

Definition at line 30 of file network_gamelist.cpp.