Mania++
 All Classes Functions Variables Pages
Public Member Functions | Private Attributes | List of all members
Methods Class Reference

Contains all server methods and returns usable data types. More...

#include <Methods.h>

Public Member Functions

 Methods (GbxRemote *serverPtr, std::map< std::string, Player > *playerListPtr, ServerInfo *serverInfoPtr)
 Constructor with link to server connection. More...
 
GbxError GetCurrentError ()
 Returns the current server error (from GbxRemote).
 
bool Authenticate (std::string username, std::string password)
 Authenticates with the server. Returns whether authentication was successful. More...
 
bool ChangeAuthPassword (std::string username, std::string password)
 Changes authentication passwordd. Returns whether change was successful. More...
 
bool EnableCallbacks (bool enable)
 Enables/disables callbacks. Returns whether change was successful. More...
 
bool SetApiVersion (std::string version)
 Sets the API version of the server. Returns whether change was successful. More...
 
std::vector< std::string > ListMethods ()
 Returns list of available server methods. More...
 
ServerVersion GetVersion ()
 Returns server version information. More...
 
SystemInfo GetSystemInfo ()
 Returns system information. More...
 
bool SetConnectionRates (int downloadRate, int uploadRate)
 Sets the server connection rates. More...
 
ServerStatus GetStatus ()
 Returns server status. More...
 
bool QuitGame ()
 Quit the server.
 
bool ChatSendServerMessage (std::string text)
 Send chat message to all players. More...
 
bool ChatSendServerMessageToLogin (std::string text, std::string login)
 Send chat message to player login. More...
 
bool ChatSendServerMessageToPlayer (std::string text, Player player)
 Send chat message to player. More...
 
std::vector< std::string > GetChatLines ()
 Get latest chat lines.
 
bool ChatEnableManualRouting (bool enable, bool autoForward)
 Enable/disable manual chat routing. More...
 
bool ChatForwardToLogin (std::string text, std::string sender, std::string destination="")
 Forwards chat message to player. More...
 
bool SendNotice (std::string text, std::string avatarLogin="", int variant=0)
 Send notice to all players. More...
 
bool SendNoticeToLogin (std::string login, std::string text, std::string avatarLogin="", int variant=0)
 Send notice to player login. More...
 
bool SendOpenLinkToLogin (std::string login, std::string link, int linkType)
 Send link to player login. More...
 
bool CallVote (std::string xmlRequest)
 Start callvote. More...
 
bool CallVoteEx (std::string xmlRequest, double ratio, int timeout, int whoVotes)
 Start callvote. More...
 
bool CancelVote ()
 Cancels the current callvote.
 
CurrentCallVote GetCurrentCallVote ()
 Returns the current callvote.
 
bool SetCallVoteTimeOut (int timeout)
 Sets the default callvote timeout. More...
 
CurrentNextValue GetCallVoteTimeOut ()
 Gets the default callvote timeout.
 
bool SetCallVoteRatio (double ratio)
 Sets the default callvote ratio. More...
 
double GetCallVoteRatio ()
 Gets the default callvote ratio.
 
bool SetCallVoteRatios (std::vector< CallVoteRatio > ratios)
 Sets the callvote ratios. More...
 
std::vector< CallVoteRatioGetCallVoteRatios ()
 Gets the callvote ratios.
 
bool SetCallVoteRatiosEx (bool replaceAll, std::vector< ExtendedCallVoteRatio > ratios)
 Sets the callvote ratios. More...
 
std::vector
< ExtendedCallVoteRatio
GetCallVoteRatiosEx ()
 Gets the callvote ratios.
 
bool SendDisplayManialinkPage (std::string page, int timeout, bool hideOnClick)
 Displays ManiaLink page to all players. More...
 
bool SendDisplayManialinkPageToLogin (std::string login, std::string page, int timeout, bool hideOnClick)
 Displays ManiaLink page to a player. More...
 
bool SendHideManialinkPage ()
 Hides all ManiaLink pages for all players.
 
bool SendHideManialinkPageToLogin (std::string login)
 Hides all ManiaLink pages for a player. More...
 
std::vector< ManiaLinkPageAnswerGetManialinkPageAnswers ()
 Returns the latest results from the current ManiaLink page.
 
bool SetServerName (std::string name)
 Sets the server name. More...
 
std::string GetServerName ()
 Returns the current server name.
 
bool SetServerComment (std::string comment)
 Sets the server comment. More...
 
std::string GetServerComment ()
 Returns the current server comment.
 
bool SetHideServer (int setting)
 Sets the hide setting of the server. More...
 
int GetHideServer ()
 Gets the hide setting of the server (0 = visible, 1 = always hidden, 2 = hidden from nations).
 
bool IsRelayServer ()
 Returns whether the server is a relay server.
 
bool SetServerPassword (std::string password)
 Sets the server password. More...
 
std::string GetServerPassword ()
 Gets the server password.
 
bool SetServerPasswordForSpectator (std::string password)
 Sets the spectator password. More...
 
std::string GetServerPasswordForSpectator ()
 Gets the spectator password.
 
bool SetMaxPlayers (int limit)
 Sets the playerlimit. More...
 
CurrentNextValue GetMaxPlayers ()
 Gets the playerlimit.
 
bool SetMaxSpectators (int limit)
 Sets the spectatorlimit. More...
 
bool SetGameMode (GameMode mode)
 Sets the game mode (0 = Script, 1 = Rounds, 2 = TimeAttack, 3 = Team, 4 = Laps, 5 = Cup, 6 = Stunts). More...
 
GameMode GetGameMode ()
 Get the game mode (0 = Script, 1 = Rounds, 2 = TimeAttack, 3 = Team, 4 = Laps, 5 = Cup, 6 = Stunts).
 
CurrentNextValue GetMaxSpectators ()
 Gets the spectatorlimit.
 
Map GetNextMapInfo ()
 Provides a map object for the map being played next on the server.
 
Map GetCurrentMapInfo ()
 Provides a map object for the map currently being played on the server. More...
 
Map GetMapInfo (std::string fileName)
 Provides a map object for the map with the specified file name. More...
 
bool CheckMapForCurrentServerParams (std::string fileName)
 Checks if the map matches the current server settings. More...
 
std::vector< MapGetMapList (int limit, int index)
 Gets the maplist from the server. More...
 
bool AddMap (std::string fileName)
 Add the map with the specified filename at the end of the current selection. More...
 
int AddMapList (std::vector< std::string > fileNames)
 Add the list of maps with the specified filenames at the end of the current selection. More...
 
bool RemoveMap (std::string fileName)
 Remove the map with the specified filename from the current selection. More...
 
int RemoveMapList (std::vector< std::string > fileNames)
 Remove the list of maps with the specified filenames from the current selection. More...
 
bool InsertMap (std::string fileName)
 Insert the map with the specified filename after the current map. More...
 
int InsertMapList (std::vector< std::string > fileNames)
 Insert the list of maps with the specified filenames after the current map. More...
 
bool ChooseNextMap (std::string fileName)
 Set as next map the one with the specified filename, if it is present in the selection. More...
 
int ChooseNextMapList (std::vector< std::string > fileNames)
 Set as next maps the list of maps with the specified filenames, if they are present in the selection. More...
 
std::string GetValidationReplay (std::string login)
 Retrieve validation replay by player login. More...
 
std::string GetGhostReplay (std::string login, std::string fileName)
 Retrieve ghost replay by player login. More...
 
std::string GameDataDirectory ()
 Retrieve the location of the GameData directory.
 
std::string GetMapsDirectory ()
 Retrieve the location of the maps directory.
 
std::string GetSkinsDirectory ()
 Retrieve the location of the skins directory.
 
bool Kick (std::string login, std::string message="")
 Kick a player from the server. More...
 
bool Ban (std::string login, std::string message="")
 Ban a player from the server. More...
 
bool BanAndBlackList (std::string login, std::string message, bool save=false)
 Ban and blacklist a player from the server. More...
 
bool UnBan (std::string login)
 Unban a player from the server. More...
 
bool CleanBanList ()
 Clear the banlist.
 
std::vector< BannedPlayerGetBanList (int amount, int index)
 Retrieve the banlist. More...
 
bool BlackList (std::string login)
 Blacklist a player from the server. More...
 
bool UnBlackList (std::string login)
 Unblacklist a player from the server. More...
 
bool CleanBlackList ()
 Clear the blacklist.
 
std::vector< std::string > GetBlackList (int amount, int index)
 Retrieve the blacklist. More...
 
bool LoadBlackList (std::string file)
 Load the blacklist to the server. More...
 
bool SaveBlackList (std::string file)
 Save the blacklist from the server. More...
 
bool AddGuest (std::string login)
 Add a player as guest on the server. More...
 
bool RemoveGuest (std::string login)
 Remove a player as guest on the server. More...
 
bool CleanGuestList ()
 Clear the guestlist.
 
std::vector< std::string > GetGuestList (int amount, int index)
 Retrieve the guestlist. More...
 
bool LoadGuestList (std::string file)
 Load the guestlist to the server. More...
 
bool SaveGuestList (std::string file)
 Save the guestlist from the server. More...
 
bool Ignore (std::string login)
 Ignore a player on the server. More...
 
bool UnIgnore (std::string login)
 Unignore a player on the server. More...
 
bool CleanIgnoreList ()
 Clear the ignorelist.
 
std::vector< std::string > GetIgnoreList (int amount, int index)
 Retrieve the ignorelist. More...
 

Private Attributes

GbxRemoteserver
 Pointer to GbxRemote.
 
std::map< std::string, Player > * playerList
 Pointer to the playerlist.
 
ServerInfoserverInfo
 Pointer to the server information.
 

Detailed Description

Contains all server methods and returns usable data types.

Constructor & Destructor Documentation

Methods::Methods ( GbxRemote serverPtr,
std::map< std::string, Player > *  playerListPtr,
ServerInfo serverInfoPtr 
)

Constructor with link to server connection.

Parameters
serverPtrPointer to server connection.
playerListPtrPointer to the playerlist.
serverInfoPtrPointer to the server information

Member Function Documentation

bool Methods::AddGuest ( std::string  login)

Add a player as guest on the server.

Parameters
loginPlayer login.
bool Methods::AddMap ( std::string  fileName)

Add the map with the specified filename at the end of the current selection.

Parameters
fileNameFilename of the map.
int Methods::AddMapList ( std::vector< std::string >  fileNames)

Add the list of maps with the specified filenames at the end of the current selection.

Parameters
fileNamesList of map filenames.
bool Methods::Authenticate ( std::string  username,
std::string  password 
)

Authenticates with the server. Returns whether authentication was successful.

Parameters
usernameServer username (f.e. SuperAdmin).
passwordServer password.
bool Methods::Ban ( std::string  login,
std::string  message = "" 
)

Ban a player from the server.

Parameters
loginPlayer login.
messageOptional ban message.
bool Methods::BanAndBlackList ( std::string  login,
std::string  message,
bool  save = false 
)

Ban and blacklist a player from the server.

Parameters
loginPlayer login.
messageBan message.
saveSave the blacklist.
bool Methods::BlackList ( std::string  login)

Blacklist a player from the server.

Parameters
loginPlayer login.
bool Methods::CallVote ( std::string  xmlRequest)

Start callvote.

Parameters
xmlRequestCallvote request.
bool Methods::CallVoteEx ( std::string  xmlRequest,
double  ratio,
int  timeout,
int  whoVotes 
)

Start callvote.

Parameters
xmlRequestCallvote request.
ratioPassing ratio (between 0 and 1, -1 = default).
timeoutTimeout for the callvote (0 = default, 1 = indefinite).
whoVotesWho votes for the callvote (0 = active players, 1 = all players, 2 = everyone, including spectators).
bool Methods::ChangeAuthPassword ( std::string  username,
std::string  password 
)

Changes authentication passwordd. Returns whether change was successful.

Parameters
usernameServer username (f.e. SuperAdmin).
passwordNew password for user.
bool Methods::ChatEnableManualRouting ( bool  enable,
bool  autoForward 
)

Enable/disable manual chat routing.

Parameters
enableEnable routing?
autoForwardAutoforward?
bool Methods::ChatForwardToLogin ( std::string  text,
std::string  sender,
std::string  destination = "" 
)

Forwards chat message to player.

Parameters
textChat message.
senderSending login.
destinationDestination login (empty for all players).
bool Methods::ChatSendServerMessage ( std::string  text)

Send chat message to all players.

Parameters
textChat message.
bool Methods::ChatSendServerMessageToLogin ( std::string  text,
std::string  login 
)

Send chat message to player login.

Parameters
textChat message.
loginPlayer login to which the message should be send.
bool Methods::ChatSendServerMessageToPlayer ( std::string  text,
Player  player 
)

Send chat message to player.

Parameters
textChat message.
playerPlayer object to which the message should be send.
bool Methods::CheckMapForCurrentServerParams ( std::string  fileName)

Checks if the map matches the current server settings.

Parameters
fileNameFile name of the map.
bool Methods::ChooseNextMap ( std::string  fileName)

Set as next map the one with the specified filename, if it is present in the selection.

Parameters
fileNameFilename of the map.
int Methods::ChooseNextMapList ( std::vector< std::string >  fileNames)

Set as next maps the list of maps with the specified filenames, if they are present in the selection.

Parameters
fileNamesList of map filenames.
bool Methods::EnableCallbacks ( bool  enable)

Enables/disables callbacks. Returns whether change was successful.

Parameters
enableEnable (true) or disable (false).
std::vector< BannedPlayer > Methods::GetBanList ( int  amount,
int  index 
)

Retrieve the banlist.

Parameters
amountAmount of players from the banlist to be retrieved.
indexStarting index.
std::vector< std::string > Methods::GetBlackList ( int  amount,
int  index 
)

Retrieve the blacklist.

Parameters
amountAmount of players from the blacklist to be retrieved.
indexStarting index.
Map Methods::GetCurrentMapInfo ( )

Provides a map object for the map currently being played on the server.

This is mainly meant for the start-up of the controller. The current map can always be request via the Current property of MapList.

std::string Methods::GetGhostReplay ( std::string  login,
std::string  fileName 
)

Retrieve ghost replay by player login.

Parameters
loginPlayer login.
fileNameFile to store the replay in.
std::vector< std::string > Methods::GetGuestList ( int  amount,
int  index 
)

Retrieve the guestlist.

Parameters
amountAmount of players from the guestlist to be retrieved.
indexStarting index.
std::vector< std::string > Methods::GetIgnoreList ( int  amount,
int  index 
)

Retrieve the ignorelist.

Parameters
amountAmount of players from the ignorelist to be retrieved.
indexStarting index.
Map Methods::GetMapInfo ( std::string  fileName)

Provides a map object for the map with the specified file name.

Parameters
fileNameFile name of the map.
std::vector< Map > Methods::GetMapList ( int  limit,
int  index 
)

Gets the maplist from the server.

Parameters
limitMaximum amount of maps to be retrieved.
indexMap index on which to start the retrieval.
ServerStatus Methods::GetStatus ( )

Returns server status.

Returns empty struct if no information could be retrieved.

SystemInfo Methods::GetSystemInfo ( )

Returns system information.

Returns empty struct if no information could be retrieved.

std::string Methods::GetValidationReplay ( std::string  login)

Retrieve validation replay by player login.

Parameters
loginPlayer login.
ServerVersion Methods::GetVersion ( )

Returns server version information.

Returns empty struct if no information could be retrieved.

bool Methods::Ignore ( std::string  login)

Ignore a player on the server.

Parameters
loginPlayer login.
bool Methods::InsertMap ( std::string  fileName)

Insert the map with the specified filename after the current map.

Parameters
fileNameFilename of the map.
int Methods::InsertMapList ( std::vector< std::string >  fileNames)

Insert the list of maps with the specified filenames after the current map.

Parameters
fileNamesList of map filenames.
bool Methods::Kick ( std::string  login,
std::string  message = "" 
)

Kick a player from the server.

Parameters
loginPlayer login.
messageOptional kick message.
std::vector< std::string > Methods::ListMethods ( )

Returns list of available server methods.

Returns empty vector if no methods could be retrieved.

bool Methods::LoadBlackList ( std::string  file)

Load the blacklist to the server.

Parameters
fileFilename to load the blacklist from.
bool Methods::LoadGuestList ( std::string  file)

Load the guestlist to the server.

Parameters
fileFilename to load the guestlist from.
bool Methods::RemoveGuest ( std::string  login)

Remove a player as guest on the server.

Parameters
loginPlayer login.
bool Methods::RemoveMap ( std::string  fileName)

Remove the map with the specified filename from the current selection.

Parameters
fileNameFilename of the map.
int Methods::RemoveMapList ( std::vector< std::string >  fileNames)

Remove the list of maps with the specified filenames from the current selection.

Parameters
fileNamesList of map filenames.
bool Methods::SaveBlackList ( std::string  file)

Save the blacklist from the server.

Parameters
fileFilename to save the blacklist to.
bool Methods::SaveGuestList ( std::string  file)

Save the guestlist from the server.

Parameters
fileFilename to save the guestlist to.
bool Methods::SendDisplayManialinkPage ( std::string  page,
int  timeout,
bool  hideOnClick 
)

Displays ManiaLink page to all players.

Parameters
pageXML page to be displayed.
timeoutTimeout to autohide (0 = permanent).
hideOnClickHide the page if a page option is clicked.
bool Methods::SendDisplayManialinkPageToLogin ( std::string  login,
std::string  page,
int  timeout,
bool  hideOnClick 
)

Displays ManiaLink page to a player.

Parameters
loginPlayer login.
pageXML page to be displayed.
timeoutTimeout to autohide (0 = permanent).
hideOnClickHide the page if a page option is clicked.
bool Methods::SendHideManialinkPageToLogin ( std::string  login)

Hides all ManiaLink pages for a player.

Parameters
loginPlayer login.
bool Methods::SendNotice ( std::string  text,
std::string  avatarLogin = "",
int  variant = 0 
)

Send notice to all players.

Parameters
textChat message.
avatarLoginAvatar login.
variantNotice variant (0 = normal, 1 = sad, 2 = happy).
bool Methods::SendNoticeToLogin ( std::string  login,
std::string  text,
std::string  avatarLogin = "",
int  variant = 0 
)

Send notice to player login.

Parameters
loginPlayer login.
textChat message.
avatarLoginAvatar login.
variantNotice variant (0 = normal, 1 = sad, 2 = happy).
bool Methods::SendOpenLinkToLogin ( std::string  login,
std::string  link,
int  linkType 
)

Send link to player login.

Parameters
loginPlayer login.
linkLink address.
linkTypeLink type (0 = external, 1 = ManiaLink).
bool Methods::SetApiVersion ( std::string  version)

Sets the API version of the server. Returns whether change was successful.

Parameters
versionAPI version.
bool Methods::SetCallVoteRatio ( double  ratio)

Sets the default callvote ratio.

Parameters
ratioDefault timeout.
bool Methods::SetCallVoteRatios ( std::vector< CallVoteRatio ratios)

Sets the callvote ratios.

Parameters
ratiosList of callvote ratios.
bool Methods::SetCallVoteRatiosEx ( bool  replaceAll,
std::vector< ExtendedCallVoteRatio ratios 
)

Sets the callvote ratios.

Parameters
replaceAllReplace all current callvote ratios?
ratiosList of callvote ratios.
Todo:
Implement when GbxParameters supports structs.
bool Methods::SetCallVoteTimeOut ( int  timeout)

Sets the default callvote timeout.

Parameters
timeoutDefault timeout.
bool Methods::SetConnectionRates ( int  downloadRate,
int  uploadRate 
)

Sets the server connection rates.

Parameters
downloadRateNew download rate.
uploadRateNew upload rate.
bool Methods::SetGameMode ( GameMode  mode)

Sets the game mode (0 = Script, 1 = Rounds, 2 = TimeAttack, 3 = Team, 4 = Laps, 5 = Cup, 6 = Stunts).

Parameters
modeNew game mode.
bool Methods::SetHideServer ( int  setting)

Sets the hide setting of the server.

Parameters
settingNew hide setting (0 = visible, 1 = always hidden, 2 = hidden from nations).
bool Methods::SetMaxPlayers ( int  limit)

Sets the playerlimit.

Parameters
limitNew playerlimit.
bool Methods::SetMaxSpectators ( int  limit)

Sets the spectatorlimit.

Parameters
limitNew spectatorlimit.
bool Methods::SetServerComment ( std::string  comment)

Sets the server comment.

Parameters
commentNew server comment.
bool Methods::SetServerName ( std::string  name)

Sets the server name.

Parameters
nameNew server name.
bool Methods::SetServerPassword ( std::string  password)

Sets the server password.

Parameters
passwordNew server password.
bool Methods::SetServerPasswordForSpectator ( std::string  password)

Sets the spectator password.

Parameters
passwordNew spectator password.
bool Methods::UnBan ( std::string  login)

Unban a player from the server.

Parameters
loginPlayer login.
bool Methods::UnBlackList ( std::string  login)

Unblacklist a player from the server.

Parameters
loginPlayer login.
bool Methods::UnIgnore ( std::string  login)

Unignore a player on the server.

Parameters
loginPlayer login.

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