OpenTTD Source: src/network/network_gamelist.cpp File Reference

OpenTTD Source 1.11.0-RC1

Functions | Variables
network_gamelist.cpp File Reference
`#include "../stdafx.h"`
`#include "../debug.h"`
`#include "../window_func.h"`
`#include "network_internal.h"`
`#include "network_udp.h"`
`#include "network_gamelist.h"`
`#include <atomic>`
`#include "../safeguards.h"`

Go to the source code of this file.

## Functions
static std::atomic< NetworkGameList * > | _network_game_delayed_insertion_list (nullptr)
| The games to insert when the GUI thread has time for us.
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. More...
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. More...
void | NetworkGameListRemoveItem (NetworkGameList *remove)
| Remove an item from the gamelist linked list. More...
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 = nullptr
| Game list of this client.
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

## ◆ NetworkGameListAddItem()

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

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

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

## ◆ NetworkGameListAddItemDelayed()

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 _network_game_delayed_insertion_list(), and NetworkGameList::next.

Referenced by DoNetworkUDPQueryServer().

## ◆ NetworkGameListRemoveItem()

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 _network_game_list, ClearGRFConfigList(), DEBUG, free(), NetworkGameInfo::grfconfig, NetworkGameList::info, and NetworkGameList::next.