Mania++
 All Classes Functions Variables Pages
Methods.h
1 #ifndef METHODS_H_
2 #define METHODS_H_
3 
4 #include "../GbxRemote/GbxRemote.h"
5 #include "../Objects/Map.h"
6 #include "../Objects/Player.h"
7 #include "../Utils/Logging.h"
8 #include "../Utils/Text.h"
9 #include "Structs.h"
10 
11 //* Methods
15 class Methods
16 {
17 public:
25  Methods(GbxRemote* serverPtr, std::map<std::string, Player>* playerListPtr, ServerInfo* serverInfoPtr);
26 
31 
38  bool Authenticate(std::string username, std::string password);
39 
46  bool ChangeAuthPassword(std::string username, std::string password);
47 
53  bool EnableCallbacks(bool enable);
54 
60  bool SetApiVersion(std::string version);
61 
67  std::vector<std::string> ListMethods();
68 
75 
82 
89  bool SetConnectionRates(int downloadRate, int uploadRate);
90 
97 
101  bool QuitGame();
102 
108  bool ChatSendServerMessage(std::string text);
109 
116  bool ChatSendServerMessageToLogin(std::string text, std::string login);
117 
124  bool ChatSendServerMessageToPlayer(std::string text, Player player);
125 
129  std::vector<std::string> GetChatLines();
130 
137  bool ChatEnableManualRouting(bool enable, bool autoForward);
138 
146  bool ChatForwardToLogin(std::string text, std::string sender, std::string destination = "");
147 
155  bool SendNotice(std::string text, std::string avatarLogin = "", int variant = 0);
156 
165  bool SendNoticeToLogin(std::string login, std::string text, std::string avatarLogin = "", int variant = 0);
166 
174  bool SendOpenLinkToLogin(std::string login, std::string link, int linkType);
175 
181  bool CallVote(std::string xmlRequest);
182 
191  bool CallVoteEx(std::string xmlRequest, double ratio, int timeout, int whoVotes);
192 
196  bool CancelVote();
197 
202 
208  bool SetCallVoteTimeOut(int timeout);
209 
214 
220  bool SetCallVoteRatio(double ratio);
221 
225  double GetCallVoteRatio();
226 
232  bool SetCallVoteRatios(std::vector<CallVoteRatio> ratios);
233 
237  std::vector<CallVoteRatio> GetCallVoteRatios();
238 
247  bool SetCallVoteRatiosEx(bool replaceAll, std::vector<ExtendedCallVoteRatio> ratios);
248 
252  std::vector<ExtendedCallVoteRatio> GetCallVoteRatiosEx();
253 
261  bool SendDisplayManialinkPage(std::string page, int timeout, bool hideOnClick);
262 
271  bool SendDisplayManialinkPageToLogin(std::string login, std::string page, int timeout, bool hideOnClick);
272 
276  bool SendHideManialinkPage();
277 
283  bool SendHideManialinkPageToLogin(std::string login);
284 
288  std::vector<ManiaLinkPageAnswer> GetManialinkPageAnswers();
289 
295  bool SetServerName(std::string name);
296 
300  std::string GetServerName();
301 
307  bool SetServerComment(std::string comment);
308 
312  std::string GetServerComment();
313 
319  bool SetHideServer(int setting);
320 
324  int GetHideServer();
325 
329  bool IsRelayServer();
330 
336  bool SetServerPassword(std::string password);
337 
341  std::string GetServerPassword();
342 
348  bool SetServerPasswordForSpectator(std::string password);
349 
353  std::string GetServerPasswordForSpectator();
354 
360  bool SetMaxPlayers(int limit);
361 
366 
372  bool SetMaxSpectators(int limit);
373 
379  bool SetGameMode(GameMode mode);
380 
384  GameMode GetGameMode();
385 
390 
395 
403 
409  Map GetMapInfo(std::string fileName);
410 
416  bool CheckMapForCurrentServerParams(std::string fileName);
417 
424  std::vector<Map> GetMapList(int limit, int index);
425 
431  bool AddMap(std::string fileName);
432 
438  int AddMapList(std::vector<std::string> fileNames);
439 
445  bool RemoveMap(std::string fileName);
446 
452  int RemoveMapList(std::vector<std::string> fileNames);
453 
459  bool InsertMap(std::string fileName);
460 
466  int InsertMapList(std::vector<std::string> fileNames);
467 
473  bool ChooseNextMap(std::string fileName);
474 
480  int ChooseNextMapList(std::vector<std::string> fileNames);
481 
487  std::string GetValidationReplay(std::string login);
488 
495  std::string GetGhostReplay(std::string login, std::string fileName);
496 
500  std::string GameDataDirectory();
501 
505  std::string GetMapsDirectory();
506 
510  std::string GetSkinsDirectory();
511 
518  bool Kick(std::string login, std::string message = "");
519 
526  bool Ban(std::string login, std::string message = "");
527 
535  bool BanAndBlackList(std::string login, std::string message, bool save = false);
536 
542  bool UnBan(std::string login);
543 
547  bool CleanBanList();
548 
555  std::vector<BannedPlayer> GetBanList(int amount, int index);
556 
562  bool BlackList(std::string login);
563 
569  bool UnBlackList(std::string login);
570 
574  bool CleanBlackList();
575 
582  std::vector<std::string> GetBlackList(int amount, int index);
583 
589  bool LoadBlackList(std::string file);
590 
596  bool SaveBlackList(std::string file);
597 
603  bool AddGuest(std::string login);
604 
610  bool RemoveGuest(std::string login);
611 
615  bool CleanGuestList();
616 
623  std::vector<std::string> GetGuestList(int amount, int index);
624 
630  bool LoadGuestList(std::string file);
631 
637  bool SaveGuestList(std::string file);
638 
644  bool Ignore(std::string login);
645 
651  bool UnIgnore(std::string login);
652 
656  bool CleanIgnoreList();
657 
664  std::vector<std::string> GetIgnoreList(int amount, int index);
665 
666  /*bool SetBuddyNotification(std::string login, bool enabled);
667  bool GetBuddyNotification(std::string login);
668 
669  // bool WriteFile(std::string file, base64 content);
670 
671  bool Echo(std::string value1, std::string value2);
672 
673  int Pay(std::string login, int cost, std::string label);
674  int SendBill(std::string loginFrom, int cost, std::string label, std::string loginTo = "");
675  // struct{State, StateName, TransactionId} GetBillState(int billId);
676  int GetServerPlanets();
677 
678  //array[struct{Name, Value}] GetServerTags();
679  bool SetServerTag(std::string name, std::string value);
680  bool UnsetServerTag(std::string name);
681  bool ResetServerTags();
682 
683  bool SetLobbyInfo(bool isLobby, int numPlayers, int maxPlayers, double averageLevel);
684  //struct{IsLobby,LobbyPlayers,LobbyMaxPlayers,LobbyPlayersLevel} GetLobbyInfo();
685 
686  bool CustomizeQuitDialog(std::string manialink, std::string sendToServer, bool proposeAddToFavourites, int delayQuitButton);
687 
688  bool KeepPlayerSlots(bool keepPlayerSlots);
689  bool IsKeepingPlayerSlots();
690 
691  bool EnableP2PUpload(bool enable);
692  bool IsP2PUpload();
693  bool EnableP2PDownload(bool enable);
694  bool IsP2PDownload();
695  bool AllowMapDownload(bool allow);
696  bool IsMapDownloadAllowed(); */
697 
698 private:
700  std::map<std::string, Player>* playerList;
702 };
703 
704 #endif // METHODS_H_
bool UnBlackList(std::string login)
Unblacklist a player from the server.
Definition: PlayerActions.cpp:129
bool CleanIgnoreList()
Clear the ignorelist.
Definition: PlayerActions.cpp:345
std::vector< Map > GetMapList(int limit, int index)
Gets the maplist from the server.
Definition: MapInfo.cpp:67
bool LoadGuestList(std::string file)
Load the guestlist to the server.
Definition: PlayerActions.cpp:281
bool IsRelayServer()
Returns whether the server is a relay server.
Definition: Info.cpp:100
bool InsertMap(std::string fileName)
Insert the map with the specified filename after the current map.
Definition: MapActions.cpp:67
bool SendNoticeToLogin(std::string login, std::string text, std::string avatarLogin="", int variant=0)
Send notice to player login.
Definition: Notice.cpp:21
Handles communication with the ManiaPlanet server.
Definition: GbxRemote.h:20
std::vector< CallVoteRatio > GetCallVoteRatios()
Gets the callvote ratios.
Definition: CallVote.cpp:143
std::string GetValidationReplay(std::string login)
Retrieve validation replay by player login.
Definition: Replays.cpp:6
bool SetServerComment(std::string comment)
Sets the server comment.
Definition: Info.cpp:37
bool SetMaxPlayers(int limit)
Sets the playerlimit.
Definition: Info.cpp:171
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...
Definition: MapActions.cpp:115
Map GetNextMapInfo()
Provides a map object for the map being played next on the server.
Definition: MapInfo.cpp:18
GbxRemote * server
Pointer to GbxRemote.
Definition: Methods.h:699
std::string GetServerPassword()
Gets the server password.
Definition: Info.cpp:129
bool SetCallVoteRatios(std::vector< CallVoteRatio > ratios)
Sets the callvote ratios.
Definition: CallVote.cpp:127
bool SendHideManialinkPage()
Hides all ManiaLink pages for all players.
Definition: ManiaLink.cpp:41
Map GetMapInfo(std::string fileName)
Provides a map object for the map with the specified file name.
Definition: MapInfo.cpp:33
bool CleanBanList()
Clear the banlist.
Definition: PlayerActions.cpp:73
bool SetServerPassword(std::string password)
Sets the server password.
Definition: Info.cpp:113
CurrentCallVote GetCurrentCallVote()
Returns the current callvote.
Definition: CallVote.cpp:51
bool ChatForwardToLogin(std::string text, std::string sender, std::string destination="")
Forwards chat message to player.
Definition: Chat.cpp:78
bool EnableCallbacks(bool enable)
Enables/disables callbacks. Returns whether change was successful.
Definition: Global.cpp:37
bool QuitGame()
Quit the server.
Definition: Global.cpp:163
bool SetServerPasswordForSpectator(std::string password)
Sets the spectator password.
Definition: Info.cpp:142
std::vector< std::string > ListMethods()
Returns list of available server methods.
Definition: Global.cpp:69
Contains all information about a player in easy-to-use format.
Definition: Player.h:11
bool Authenticate(std::string username, std::string password)
Authenticates with the server. Returns whether authentication was successful.
Definition: Global.cpp:3
bool Ban(std::string login, std::string message="")
Ban a player from the server.
Definition: PlayerActions.cpp:21
int InsertMapList(std::vector< std::string > fileNames)
Insert the list of maps with the specified filenames after the current map.
Definition: MapActions.cpp:83
bool AddMap(std::string fileName)
Add the map with the specified filename at the end of the current selection.
Definition: MapActions.cpp:3
bool ChatSendServerMessageToLogin(std::string text, std::string login)
Send chat message to player login.
Definition: Chat.cpp:21
std::vector< BannedPlayer > GetBanList(int amount, int index)
Retrieve the banlist.
Definition: PlayerActions.cpp:86
bool SetHideServer(int setting)
Sets the hide setting of the server.
Definition: Info.cpp:71
ServerVersion GetVersion()
Returns server version information.
Definition: Global.cpp:87
bool CallVote(std::string xmlRequest)
Start callvote.
Definition: CallVote.cpp:3
std::string GetGhostReplay(std::string login, std::string fileName)
Retrieve ghost replay by player login.
Definition: Replays.cpp:22
std::vector< std::string > GetChatLines()
Get latest chat lines.
Definition: Chat.cpp:45
GameMode GetGameMode()
Get the game mode (0 = Script, 1 = Rounds, 2 = TimeAttack, 3 = Team, 4 = Laps, 5 = Cup...
Definition: Game.cpp:20
bool BlackList(std::string login)
Blacklist a player from the server.
Definition: PlayerActions.cpp:113
bool SetApiVersion(std::string version)
Sets the API version of the server. Returns whether change was successful.
Definition: Global.cpp:53
std::vector< std::string > GetBlackList(int amount, int index)
Retrieve the blacklist.
Definition: PlayerActions.cpp:158
bool SaveBlackList(std::string file)
Save the blacklist from the server.
Definition: PlayerActions.cpp:197
Struct with system information.
Definition: Structs.h:23
bool RemoveGuest(std::string login)
Remove a player as guest on the server.
Definition: PlayerActions.cpp:229
bool LoadBlackList(std::string file)
Load the blacklist to the server.
Definition: PlayerActions.cpp:181
Contains all information about a map in easy-to-use format.
Definition: Map.h:14
bool Ignore(std::string login)
Ignore a player on the server.
Definition: PlayerActions.cpp:313
bool CleanBlackList()
Clear the blacklist.
Definition: PlayerActions.cpp:145
std::map< std::string, Player > * playerList
Pointer to the playerlist.
Definition: Methods.h:700
bool SendHideManialinkPageToLogin(std::string login)
Hides all ManiaLink pages for a player.
Definition: ManiaLink.cpp:54
bool SendDisplayManialinkPage(std::string page, int timeout, bool hideOnClick)
Displays ManiaLink page to all players.
Definition: ManiaLink.cpp:3
bool SetServerName(std::string name)
Sets the server name.
Definition: Info.cpp:3
Contains all server methods and returns usable data types.
Definition: Methods.h:15
bool BanAndBlackList(std::string login, std::string message, bool save=false)
Ban and blacklist a player from the server.
Definition: PlayerActions.cpp:39
bool SetMaxSpectators(int limit)
Sets the spectatorlimit.
Definition: Info.cpp:207
ServerInfo * serverInfo
Pointer to the server information.
Definition: Methods.h:701
Struct with server status.
Definition: Structs.h:60
bool RemoveMap(std::string fileName)
Remove the map with the specified filename from the current selection.
Definition: MapActions.cpp:35
bool SetCallVoteRatio(double ratio)
Sets the default callvote ratio.
Definition: CallVote.cpp:98
Struct with server version information.
Definition: Structs.h:10
bool SendNotice(std::string text, std::string avatarLogin="", int variant=0)
Send notice to all players.
Definition: Notice.cpp:3
bool UnBan(std::string login)
Unban a player from the server.
Definition: PlayerActions.cpp:57
bool Kick(std::string login, std::string message="")
Kick a player from the server.
Definition: PlayerActions.cpp:3
std::string GameDataDirectory()
Retrieve the location of the GameData directory.
Definition: Directories.cpp:3
Struct with a current callvote.
Definition: Structs.h:80
std::string GetMapsDirectory()
Retrieve the location of the maps directory.
Definition: Directories.cpp:16
bool CleanGuestList()
Clear the guestlist.
Definition: PlayerActions.cpp:245
bool SetGameMode(GameMode mode)
Sets the game mode (0 = Script, 1 = Rounds, 2 = TimeAttack, 3 = Team, 4 = Laps, 5 = Cup...
Definition: Game.cpp:3
CurrentNextValue GetMaxSpectators()
Gets the spectatorlimit.
Definition: Info.cpp:228
bool SendDisplayManialinkPageToLogin(std::string login, std::string page, int timeout, bool hideOnClick)
Displays ManiaLink page to a player.
Definition: ManiaLink.cpp:21
int GetHideServer()
Gets the hide setting of the server (0 = visible, 1 = always hidden, 2 = hidden from nations)...
Definition: Info.cpp:87
std::vector< ManiaLinkPageAnswer > GetManialinkPageAnswers()
Returns the latest results from the current ManiaLink page.
Definition: ManiaLink.cpp:70
std::vector< std::string > GetGuestList(int amount, int index)
Retrieve the guestlist.
Definition: PlayerActions.cpp:258
bool ChatSendServerMessageToPlayer(std::string text, Player player)
Send chat message to player.
Definition: Chat.cpp:40
std::string GetSkinsDirectory()
Retrieve the location of the skins directory.
Definition: Directories.cpp:29
bool CancelVote()
Cancels the current callvote.
Definition: CallVote.cpp:38
bool SetCallVoteTimeOut(int timeout)
Sets the default callvote timeout.
Definition: CallVote.cpp:67
std::vector< std::string > GetIgnoreList(int amount, int index)
Retrieve the ignorelist.
Definition: PlayerActions.cpp:358
bool ChatEnableManualRouting(bool enable, bool autoForward)
Enable/disable manual chat routing.
Definition: Chat.cpp:61
SystemInfo GetSystemInfo()
Returns system information.
Definition: Global.cpp:106
Stores error details from the communication with the server.
Definition: GbxStructs.h:27
bool SaveGuestList(std::string file)
Save the guestlist from the server.
Definition: PlayerActions.cpp:297
Map GetCurrentMapInfo()
Provides a map object for the map currently being played on the server.
Definition: MapInfo.cpp:3
std::string GetServerName()
Returns the current server name.
Definition: Info.cpp:24
bool ChatSendServerMessage(std::string text)
Send chat message to all players.
Definition: Chat.cpp:3
bool SendOpenLinkToLogin(std::string login, std::string link, int linkType)
Send link to player login.
Definition: Notice.cpp:40
Struct with a current and next value.
Definition: Structs.h:112
int AddMapList(std::vector< std::string > fileNames)
Add the list of maps with the specified filenames at the end of the current selection.
Definition: MapActions.cpp:19
bool SetCallVoteRatiosEx(bool replaceAll, std::vector< ExtendedCallVoteRatio > ratios)
Sets the callvote ratios.
Definition: CallVote.cpp:166
bool UnIgnore(std::string login)
Unignore a player on the server.
Definition: PlayerActions.cpp:329
CurrentNextValue GetCallVoteTimeOut()
Gets the default callvote timeout.
Definition: CallVote.cpp:83
ServerStatus GetStatus()
Returns server status.
Definition: Global.cpp:147
bool AddGuest(std::string login)
Add a player as guest on the server.
Definition: PlayerActions.cpp:213
std::vector< ExtendedCallVoteRatio > GetCallVoteRatiosEx()
Gets the callvote ratios.
Definition: CallVote.cpp:196
bool CheckMapForCurrentServerParams(std::string fileName)
Checks if the map matches the current server settings.
Definition: MapInfo.cpp:51
std::string GetServerPasswordForSpectator()
Gets the spectator password.
Definition: Info.cpp:158
bool ChooseNextMap(std::string fileName)
Set as next map the one with the specified filename, if it is present in the selection.
Definition: MapActions.cpp:99
double GetCallVoteRatio()
Gets the default callvote ratio.
Definition: CallVote.cpp:114
Methods(GbxRemote *serverPtr, std::map< std::string, Player > *playerListPtr, ServerInfo *serverInfoPtr)
Constructor with link to server connection.
Definition: Methods.cpp:3
bool SetConnectionRates(int downloadRate, int uploadRate)
Sets the server connection rates.
Definition: Global.cpp:130
CurrentNextValue GetMaxPlayers()
Gets the playerlimit.
Definition: Info.cpp:192
GbxError GetCurrentError()
Returns the current server error (from GbxRemote).
Definition: Methods.cpp:10
bool ChangeAuthPassword(std::string username, std::string password)
Changes authentication passwordd. Returns whether change was successful.
Definition: Global.cpp:20
int RemoveMapList(std::vector< std::string > fileNames)
Remove the list of maps with the specified filenames from the current selection.
Definition: MapActions.cpp:51
Struct with server information.
Definition: Structs.h:41
std::string GetServerComment()
Returns the current server comment.
Definition: Info.cpp:58
bool CallVoteEx(std::string xmlRequest, double ratio, int timeout, int whoVotes)
Start callvote.
Definition: CallVote.cpp:19