BF2MC-Matchmaker
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Battlefield::GameServer Class Reference

Class representing game server information. More...

#include <gameserver.h>

Public Types

enum class  Regions : uint64_t { Unknown = 0 , America = 1 , Asia = 2048 , Europe = 65536 }
 Enumeration defining regions where a game server can be located. More...
 
enum class  MapCyclingOptions : uint8_t {
  Unknown = 0 , LevelMapWithMapName = 1 , AllMaps = 2 , AssaultMaps = 3 ,
  IncursionMaps = 4 , DominationMaps = 5
}
 Enumeration defining the map cycling options. More...
 
typedef bool(Battlefield::GameServer::* SetterFunc) (const std::string &)
 

Public Member Functions

int GetId () const
 
std::string GetIp () const
 
void GetIpArray (uint8_t *ip) const
 
uint16_t GetPort () const
 
uint8_t GetFlag () const
 
std::string GetLocalIp () const
 
uint16_t GetLocalPort () const
 
uint8_t GetNatNeg () const
 
std::string GetGameName () const
 
std::string GetHostName () const
 
uint16_t GetHostPort () const
 
std::string GetGameVersion () const
 
std::string GetClientVersion () const
 
std::string GetRV () const
 
std::string GetMap () const
 
uint8_t GetMapCycling () const
 
uint8_t GetMapName () const
 
uint8_t GetGC () const
 
std::string GetGameType () const
 
std::string GetGameVariant () const
 
uint8_t GetNumPlayers () const
 
uint8_t GetMaxPlayers () const
 
uint8_t GetNumTeams () const
 
std::string GetGameMode () const
 
uint8_t GetTeamplay () const
 
uint8_t GetFlagLimit () const
 
uint8_t GetTeamFragLimit () const
 
uint16_t GetTimeLimit () const
 
uint16_t GetTimeElapsed () const
 
uint8_t GetPassword () const
 
uint8_t GetMinRank () const
 
uint8_t GetMaxRank () const
 
uint8_t GetFriendlyFire () const
 
uint8_t GetStatsTracking () const
 
uint8_t GetReconfigurable () const
 
int64_t GetMinIpRange () const
 
int64_t GetMaxIpRange () const
 
uint8_t GetQM () const
 
uint64_t GetRegion () const
 
int GetClan1Id () const
 
int GetClan2Id () const
 
std::string GetClan1Name () const
 
std::string GetClan2Name () const
 
uint8_t GetClan1Claimed () const
 
uint8_t GetClan2Claimed () const
 
std::string GetTeam1Name () const
 
std::string GetTeam2Name () const
 
int16_t GetTeam1Score () const
 
int16_t GetTeam2Score () const
 
std::string GetUpdatedAt () const
 
bool isVerified () const
 
GameServerPlayers GetPlayers () const
 
bool SetId (int id)
 
bool SetIp (const std::string &ip)
 
bool SetPort (uint16_t port)
 
bool SetFlag (uint8_t flag)
 
bool SetLocalIp (const std::string &localip)
 
bool SetLocalPort (uint16_t localport)
 
bool SetLocalPort (const std::string &str_localport)
 
bool SetNatNeg (uint8_t natneg)
 
bool SetNatNeg (const std::string &str_natneg)
 
bool SetGameName (const std::string &gamename)
 
bool SetHostName (const std::string &hostname)
 
bool SetHostPort (uint16_t hostport)
 
bool SetHostPort (const std::string &str_hostport)
 
bool SetGameVersion (const std::string &gamever)
 
bool SetClientVersion (const std::string &clientver)
 
bool SetRV (const std::string &rv)
 
bool SetMap (const std::string &map)
 
bool SetMapCycling (uint8_t mc)
 
bool SetMapCycling (const std::string &str_mc)
 
bool SetMapName (uint8_t mapname)
 
bool SetMapName (const std::string &str_mapname)
 
bool SetGC (uint8_t gc)
 
bool SetGC (const std::string &str_gc)
 
bool SetGameType (const std::string &gametype)
 
bool SetGameVariant (const std::string &gamevariant)
 
bool SetNumPlayers (uint8_t numplayers)
 
bool SetNumPlayers (const std::string &str_numplayers)
 
bool SetMaxPlayers (uint8_t maxplayers)
 
bool SetMaxPlayers (const std::string &str_maxplayers)
 
bool SetNumTeams (uint8_t numteams)
 
bool SetNumTeams (const std::string &str_numteams)
 
bool SetGameMode (const std::string &gamemode)
 
bool SetTeamplay (uint8_t teamplay)
 
bool SetTeamplay (const std::string &str_teamplay)
 
bool SetFlagLimit (uint8_t fraglimit)
 
bool SetFlagLimit (const std::string &str_fraglimit)
 
bool SetTeamFragLimit (uint8_t teamfraglimit)
 
bool SetTeamFragLimit (const std::string &str_teamfraglimit)
 
bool SetTimeLimit (uint16_t timelimit)
 
bool SetTimeLimit (const std::string &str_timelimit)
 
bool SetTimeElapsed (uint16_t timeelapsed)
 
bool SetTimeElapsed (const std::string &str_timeelapsed)
 
bool SetPassword (uint8_t password)
 
bool SetPassword (const std::string &str_password)
 
bool SetMinRank (uint8_t nr)
 
bool SetMinRank (const std::string &str_nr)
 
bool SetMaxRank (uint8_t xr)
 
bool SetMaxRank (const std::string &str_xr)
 
bool SetFriendlyFire (uint8_t ff)
 
bool SetFriendlyFire (const std::string &str_ff)
 
bool SetStatsTracking (uint8_t sr)
 
bool SetStatsTracking (const std::string &str_sr)
 
bool SetReconfigurable (uint8_t rc)
 
bool SetReconfigurable (const std::string &str_rc)
 
bool SetMinIpRange (int64_t ni)
 
bool SetMinIpRange (const std::string &str_ni)
 
bool SetMaxIpRange (int64_t xi)
 
bool SetMaxIpRange (const std::string &str_xi)
 
bool SetQM (uint8_t qm)
 
bool SetQM (const std::string &str_qm)
 
bool SetRegion (uint64_t region)
 
bool SetRegion (const std::string &str_region)
 
bool SetClan1Id (int c0)
 
bool SetClan1Id (const std::string &str_c0)
 
bool SetClan2Id (int c1)
 
bool SetClan2Id (const std::string &str_c1)
 
bool SetClan1Name (const std::string &n0)
 
bool SetClan2Name (const std::string &n1)
 
bool SetClan1Claimed (uint8_t c0c)
 
bool SetClan1Claimed (const std::string &str_c0c)
 
bool SetClan2Claimed (uint8_t c1c)
 
bool SetClan2Claimed (const std::string &str_c1c)
 
bool SetTeam1Name (const std::string &team0)
 
bool SetTeam2Name (const std::string &team1)
 
bool SetTeam1Score (int16_t score0)
 
bool SetTeam1Score (const std::string &str_score0)
 
bool SetTeam2Score (int16_t score1)
 
bool SetTeam2Score (const std::string &str_score1)
 
bool SetUpdatedAt (MYSQL_TIME updated_at)
 
bool SetVerified (bool verified)
 
bool SetVerified (uint8_t verified)
 
void AddPlayer (const GameServerPlayer &gsplayer)
 Adds a player to the game server. More...
 
bool IsAlive ()
 Checks if the game server is alive. More...
 
void useExample ()
 Performs an example operation using the GameServer class. More...
 
void Debug ()
 

Static Public Attributes

static std::unordered_map< std::string, SetterFunc > SetterMap
 

Private Attributes

int _id = -1
 
std::string _ip = ""
 
uint16_t _port = 3658
 
uint8_t _flag = 59
 
std::string _localip0 = ""
 
uint16_t _localport = 3658
 
uint8_t _natneg = 0
 
std::string _gamename = ""
 
std::string _hostname = ""
 
uint16_t _hostport = 3658
 
std::string _gamever = "V1.31a"
 
std::string _cl = ""
 
std::string _rv = ""
 
std::string _map = ""
 
uint8_t _mc = 0
 
uint8_t _mapname = 0
 
uint8_t _gc = 0
 
std::string _gametype = ""
 
std::string _gamevariant = ""
 
uint8_t _numplayers = 0
 
uint8_t _maxplayers = 0
 
uint8_t _numteams = 0
 
std::string _gamemode = ""
 
uint8_t _teamplay = 0
 
uint8_t _fraglimit = 0
 
uint8_t _teamfraglimit = 0
 
uint16_t _timelimit = 0
 
uint16_t _timeelapsed = 0
 
uint8_t _password = 0
 
uint8_t _nr = 0
 
uint8_t _xr = 0
 
uint8_t _ff = 0
 
uint8_t _sr = 0
 
uint8_t _rc = 0
 
int64_t _ni = 0
 
int64_t _xi = 0
 
uint8_t _qm = 0
 
uint64_t _region = 1
 
int _c0 = -1
 
int _c1 = -1
 
std::string _n0 = ""
 
std::string _n1 = ""
 
uint8_t _c0c = 0
 
uint8_t _c1c = 0
 
std::string _team0 = ""
 
std::string _team1 = ""
 
int16_t _score0 = 0
 
int16_t _score1 = 0
 
std::string _updated_at = ""
 
bool _verified = false
 
std::vector< GameServerPlayer_players
 

Detailed Description

Class representing game server information.

This class encapsulates information about a game server, including its region.

Definition at line 62 of file gameserver.h.

Member Enumeration Documentation

◆ MapCyclingOptions

Enumeration defining the map cycling options.

Enumerator
Unknown 

Unknown map cycling option.

LevelMapWithMapName 

Level map with map name.

AllMaps 

All maps.

AssaultMaps 

Assault maps.

IncursionMaps 

Incursion maps.

DominationMaps 

Domination maps.

Definition at line 85 of file gameserver.h.

◆ Regions

enum Battlefield::GameServer::Regions : uint64_t
strong

Enumeration defining regions where a game server can be located.

This enumeration specifies the regions where a game server can be located, including America, Asia, Europe, and Unknown.

For more information, see: https://documentation.help/GameSpy-SDK/Gamespy%20Server%20Browsing%20SDK.html#Appendix-Region-Codes-and-Usage

Enumerator
Unknown 

Unknown region code

America 

America region code

Asia 

Asia region code

Europe 

Europe region code

Definition at line 74 of file gameserver.h.

Member Function Documentation

◆ AddPlayer()

void Battlefield::GameServer::AddPlayer ( const GameServerPlayer gsplayer)

Adds a player to the game server.

Parameters
gsplayerThe GameServerPlayer object representing the player to add.

Definition at line 763 of file gameserver.cpp.

◆ IsAlive()

bool Battlefield::GameServer::IsAlive ( )

Checks if the game server is alive.

This function determines the liveness of the game server based on its last update time. A game server is considered alive if its last update time is within the last two minutes.

Returns
True if the game server is considered alive (updated within last 2 minutes), false otherwise.

The function calculates the difference between the server's last update time and the current time. If the difference is less than or equal to 0 (i.e., the server's last update time is in the past), and if the difference between the last update time and two minutes ago is greater than or equal to 0, then the server is considered alive.

Note
The last update time is obtained from the GetUpdatedAt() function, which should return a string in the format "%Y-%m-%d %H:%M:%S %Z" (e.g., "2024-04-19 15:30:00 UTC").
See also
GetUpdatedAt

Definition at line 768 of file gameserver.cpp.

◆ useExample()

void Battlefield::GameServer::useExample ( )

Performs an example operation using the GameServer class.

This member function demonstrates an example operation using the GameServer class. It serves as a placeholder for illustrating the usage of the GameServer class.

Note
This is just an example function and does not perform any meaningful operation.

Definition at line 54 of file gameserver.cpp.

Member Data Documentation

◆ _c0

int Battlefield::GameServer::_c0 = -1
private

Clan ID for team 1.

Definition at line 171 of file gameserver.h.

◆ _c0c

uint8_t Battlefield::GameServer::_c0c = 0
private

Indicates if team 1 is claimed (1: true, 0: false).

Definition at line 175 of file gameserver.h.

◆ _c1

int Battlefield::GameServer::_c1 = -1
private

Clan ID for team 2.

Definition at line 172 of file gameserver.h.

◆ _c1c

uint8_t Battlefield::GameServer::_c1c = 0
private

Indicates if team 2 is claimed (1: true, 0: false).

Definition at line 176 of file gameserver.h.

◆ _cl

std::string Battlefield::GameServer::_cl = ""
private

Client version.

Definition at line 110 of file gameserver.h.

◆ _ff

uint8_t Battlefield::GameServer::_ff = 0
private

Friendly fire (1: true, 0: false).

Definition at line 155 of file gameserver.h.

◆ _flag

uint8_t Battlefield::GameServer::_flag = 59
private

Flag indicating server information.

Definition at line 99 of file gameserver.h.

◆ _fraglimit

uint8_t Battlefield::GameServer::_fraglimit = 0
private

Number of kills or points for level change or game restart.

Definition at line 148 of file gameserver.h.

◆ _gamemode

std::string Battlefield::GameServer::_gamemode = ""
private

Game status:

  • "openwaiting": Open and waiting for players to join.
  • "closedwaiting": Closed and waiting for players to join.
  • "closedplaying": Closed and currently in progress.
  • "openplaying": Open and currently in progress.
  • "openstaging": Open and in staging phase.
  • "closedstaging": Closed and in staging phase.
  • "exiting": Exiting or shutting down.

Definition at line 139 of file gameserver.h.

◆ _gamename

std::string Battlefield::GameServer::_gamename = ""
private

Name of the game.

Definition at line 105 of file gameserver.h.

◆ _gametype

std::string Battlefield::GameServer::_gametype = ""
private

String which specifies the type of game or the mod being played.

  • "conquest": Conquest game mode.
  • "capturetheflag": Capture the Flag game mode.

Definition at line 123 of file gameserver.h.

◆ _gamevariant

std::string Battlefield::GameServer::_gamevariant = ""
private

Game variant or code name.

Definition at line 125 of file gameserver.h.

◆ _gamever

std::string Battlefield::GameServer::_gamever = "V1.31a"
private

Version of the game.

Definition at line 109 of file gameserver.h.

◆ _gc

uint8_t Battlefield::GameServer::_gc = 0
private

Game type.

Definition at line 117 of file gameserver.h.

◆ _hostname

std::string Battlefield::GameServer::_hostname = ""
private

Host name of the game server.

Definition at line 106 of file gameserver.h.

◆ _hostport

uint16_t Battlefield::GameServer::_hostport = 3658
private

Host port number of the game server.

Definition at line 107 of file gameserver.h.

◆ _id

int Battlefield::GameServer::_id = -1
private

Unique identifier for the game server.

Definition at line 96 of file gameserver.h.

◆ _ip

std::string Battlefield::GameServer::_ip = ""
private

IP address of the game server.

Definition at line 97 of file gameserver.h.

◆ _localip0

std::string Battlefield::GameServer::_localip0 = ""
private

Local IP address of the game server.

Definition at line 102 of file gameserver.h.

◆ _localport

uint16_t Battlefield::GameServer::_localport = 3658
private

Local port number of the game server.

Definition at line 103 of file gameserver.h.

◆ _map

std::string Battlefield::GameServer::_map = ""
private

Name of the current map.

Definition at line 113 of file gameserver.h.

◆ _mapname

uint8_t Battlefield::GameServer::_mapname = 0
private

Map ID.

Definition at line 115 of file gameserver.h.

◆ _maxplayers

uint8_t Battlefield::GameServer::_maxplayers = 0
private

Maximum number of players.

Definition at line 127 of file gameserver.h.

◆ _mc

uint8_t Battlefield::GameServer::_mc = 0
private

Map cycling option. See MapCyclingOptions enum for available options.

Definition at line 114 of file gameserver.h.

◆ _n0

std::string Battlefield::GameServer::_n0 = ""
private

Clan name for team 1.

Definition at line 173 of file gameserver.h.

◆ _n1

std::string Battlefield::GameServer::_n1 = ""
private

Clan name for team 2.

Definition at line 174 of file gameserver.h.

◆ _natneg

uint8_t Battlefield::GameServer::_natneg = 0
private

Enable client-to-client connections (1: true, 0: false).

Definition at line 104 of file gameserver.h.

◆ _ni

int64_t Battlefield::GameServer::_ni = 0
private

Minimum IP range.

Definition at line 158 of file gameserver.h.

◆ _nr

uint8_t Battlefield::GameServer::_nr = 0
private

Minimum rank number filter.

Definition at line 153 of file gameserver.h.

◆ _numplayers

uint8_t Battlefield::GameServer::_numplayers = 0
private

Number of players.

Definition at line 126 of file gameserver.h.

◆ _numteams

uint8_t Battlefield::GameServer::_numteams = 0
private

Number of teams.

Definition at line 128 of file gameserver.h.

◆ _password

uint8_t Battlefield::GameServer::_password = 0
private

Password requirement to join (1: true, 0: false).

Definition at line 152 of file gameserver.h.

◆ _players

std::vector<GameServerPlayer> Battlefield::GameServer::_players
private

Vector containing information about players currently in the server.

Definition at line 187 of file gameserver.h.

◆ _port

uint16_t Battlefield::GameServer::_port = 3658
private

Port number of the game server.

Definition at line 98 of file gameserver.h.

◆ _qm

uint8_t Battlefield::GameServer::_qm = 0
private

Server status:

  • 0: Reserved/User for clan matches.
  • 5: Unclaimed server free for use, visible to everyone.
  • Other values: Custom server status.

Definition at line 166 of file gameserver.h.

◆ _rc

uint8_t Battlefield::GameServer::_rc = 0
private

Server is reconfigurable (1: true, 0: false).

Definition at line 157 of file gameserver.h.

◆ _region

uint64_t Battlefield::GameServer::_region = 1
private

Server region. See Battlefield::GameServer::Regions enum for possible values.

Definition at line 168 of file gameserver.h.

◆ _rv

std::string Battlefield::GameServer::_rv = ""
private

Retail version.

Definition at line 111 of file gameserver.h.

◆ _score0

int16_t Battlefield::GameServer::_score0 = 0
private

Score of team 1.

Definition at line 181 of file gameserver.h.

◆ _score1

int16_t Battlefield::GameServer::_score1 = 0
private

Score of team 2.

Definition at line 182 of file gameserver.h.

◆ _sr

uint8_t Battlefield::GameServer::_sr = 0
private

Stats tracking (1: true, 0: false).

Definition at line 156 of file gameserver.h.

◆ _team0

std::string Battlefield::GameServer::_team0 = ""
private

Name of team 1.

Definition at line 179 of file gameserver.h.

◆ _team1

std::string Battlefield::GameServer::_team1 = ""
private

Name of team 2.

Definition at line 180 of file gameserver.h.

◆ _teamfraglimit

uint8_t Battlefield::GameServer::_teamfraglimit = 0
private

Number of team kills or points for level change or game restart.

Definition at line 149 of file gameserver.h.

◆ _teamplay

uint8_t Battlefield::GameServer::_teamplay = 0
private

Type of teamplay in use, or 0 for no teamplay.

  • 0: No teamplay.
  • 3: Clan game.
  • Other values: Custom teamplay defined by the developer.

Definition at line 146 of file gameserver.h.

◆ _timeelapsed

uint16_t Battlefield::GameServer::_timeelapsed = 0
private

Time elapsed since current level or game started (in seconds).

Definition at line 151 of file gameserver.h.

◆ _timelimit

uint16_t Battlefield::GameServer::_timelimit = 0
private

Total time before level change or game restart (in seconds).

Definition at line 150 of file gameserver.h.

◆ _updated_at

std::string Battlefield::GameServer::_updated_at = ""
private

Datetime when server information was last updated.

Definition at line 184 of file gameserver.h.

◆ _verified

bool Battlefield::GameServer::_verified = false
private

Indicates whether the server is verified in the database.

Definition at line 185 of file gameserver.h.

◆ _xi

int64_t Battlefield::GameServer::_xi = 0
private

Maximum IP range.

Definition at line 159 of file gameserver.h.

◆ _xr

uint8_t Battlefield::GameServer::_xr = 0
private

Maximum rank number filter.

Definition at line 154 of file gameserver.h.


The documentation for this class was generated from the following files: