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/Text.h"
8 #include "Structs.h"
9 
10 //* Methods
14 class Methods
15 {
16 public:
23  Methods(GbxRemote* serverPtr, std::map<std::string, Player>* playerListPtr);
24 
29 
36  bool Authenticate(std::string username, std::string password);
37 
44  bool ChangeAuthPassword(std::string username, std::string password);
45 
51  bool EnableCallbacks(bool enable);
52 
58  bool SetApiVersion(std::string version);
59 
65  std::vector<std::string> ListMethods();
66 
73 
80 
87  bool SetConnectionRates(int downloadRate, int uploadRate);
88 
95 
99  bool QuitGame();
100 
106  bool ChatSendServerMessage(std::string text);
107 
114  bool ChatSendServerMessageToLogin(std::string text, std::string login);
115 
122  bool ChatSendServerMessageToPlayer(std::string text, Player player);
123 
127  std::vector<std::string> GetChatLines();
128 
135  bool ChatEnableManualRouting(bool enable, bool autoForward);
136 
144  bool ChatForwardToLogin(std::string text, std::string sender, std::string destination = "");
145 
153  bool SendNotice(std::string text, std::string avatarLogin = "", int variant = 0);
154 
163  bool SendNoticeToLogin(std::string login, std::string text, std::string avatarLogin = "", int variant = 0);
164 
172  bool SendOpenLinkToLogin(std::string login, std::string link, int linkType);
173 
179  bool CallVote(std::string xmlRequest);
180 
189  bool CallVoteEx(std::string xmlRequest, double ratio, int timeout, int whoVotes);
190 
194  bool CancelVote();
195 
200 
206  bool SetCallVoteTimeOut(int timeout);
207 
212 
218  bool SetCallVoteRatio(double ratio);
219 
223  double GetCallVoteRatio();
224 
230  bool SetCallVoteRatios(std::vector<CallVoteRatio> ratios);
231 
235  std::vector<CallVoteRatio> GetCallVoteRatios();
236 
245  bool SetCallVoteRatiosEx(bool replaceAll, std::vector<ExtendedCallVoteRatio> ratios);
246 
250  std::vector<ExtendedCallVoteRatio> GetCallVoteRatiosEx();
251 
259  bool SendDisplayManialinkPage(std::string page, int timeout, bool hideOnClick);
260 
269  bool SendDisplayManialinkPageToLogin(std::string login, std::string page, int timeout, bool hideOnClick);
270 
274  bool SendHideManialinkPage();
275 
281  bool SendHideManialinkPageToLogin(std::string login);
282 
286  std::vector<ManiaLinkPageAnswer> GetManialinkPageAnswers();
287 
288  /*bool SendOpenLinkToLogin(std::string login, std::string link, int linkType);
289 
290  bool Kick(std::string login, std::string message = "");
291  bool Ban(std::string login, std::string message = "");
292  bool BanAndBlackList(std::string login, std::string message, bool save = false);
293  bool UnBan(std::string login);
294  bool CleanBanList();
295  //array[struct{Login,ClientName,IPAddress}] GetBanList(int amount, int index);
296  bool BlackList(std::string login);
297  bool UnBlackList(std::string login);
298  bool CleanBlackList();
299  //array[struct{Login}] GetBlackList(int amount, int index);
300  bool LoadBlackList(std::string file);
301  bool SaveBlackList(std::string file);
302 
303  bool AddGuest(std::string login);
304  bool RemoveGuest(std::string login);
305  bool CleanGuestList();
306  //array[struct{Login}] GetGuestList(int amount, int index);
307  bool LoadGuestList(std::string file);
308  bool SaveGuestList(std::string file);
309 
310  bool SetBuddyNotification(std::string login, bool enabled);
311  bool GetBuddyNotification(std::string login);
312 
313  // bool WriteFile(std::string file, base64 content);
314 
315  bool Echo(std::string value1, std::string value2);
316 
317  bool Ignore(std::string login);
318  bool UnIgnore(std::string login);
319  bool CleanIgnoreList();
320  // array[struct{Login}] GetIgnoreList(int amount, int index);
321 
322  int Pay(std::string login, int cost, std::string label);
323  int SendBill(std::string loginFrom, int cost, std::string label, std::string loginTo = "");
324  // struct{State, StateName, TransactionId} GetBillState(int billId);
325  int GetServerPlanets();
326 
327  //array[struct{Name, Value}] GetServerTags();
328  bool SetServerTag(std::string name, std::string value);
329  bool UnsetServerTag(std::string name);
330  bool ResetServerTags();
331 
332  bool SetServerName(std::string name);
333  std::string GetServerName();
334  bool SetServerComment(std::string comment);
335  std::string GetServerComment();
336  bool SetHideServer(int setting);
337  int GetHideServer();
338  bool IsRelayServer();
339  bool SetServerPassword(std::string password);
340  std::string GetServerPassword();
341  bool SetServerPasswordForSpectator(std::string password);
342  std::string GetServerPasswordForSpectator();
343 
344  bool SetMaxPlayers(int limit);
345  int GetMaxPlayers();
346  bool SetMaxSpectators(int limit);
347  int GetMaxSpectators();
348 
349  bool SetLobbyInfo(bool isLobby, int numPlayers, int maxPlayers, double averageLevel);
350  //struct{IsLobby,LobbyPlayers,LobbyMaxPlayers,LobbyPlayersLevel} GetLobbyInfo();
351 
352  bool CustomizeQuitDialog(std::string manialink, std::string sendToServer, bool proposeAddToFavourites, int delayQuitButton);
353 
354  bool KeepPlayerSlots(bool keepPlayerSlots);
355  bool IsKeepingPlayerSlots();
356 
357  bool EnableP2PUpload(bool enable);
358  bool IsP2PUpload();
359  bool EnableP2PDownload(bool enable);
360  bool IsP2PDownload();
361  bool AllowMapDownload(bool allow);
362  bool IsMapDownloadAllowed();
363 
364  std::string GameDataDirectory();
365  std::string GetMapsDirectory();
366  std::string GetSkinsDirectory();*/
367 
372 
380 
386  Map GetMapInfo(std::string fileName);
387 
393  bool CheckMapForCurrentServerParams(std::string fileName);
394 
401  std::vector<Map> GetMapList(int limit, int index);
402 
408  bool AddMap(std::string fileName);
409 
415  int AddMapList(std::vector<std::string> fileNames);
416 
422  bool RemoveMap(std::string fileName);
423 
429  int RemoveMapList(std::vector<std::string> fileNames);
430 
436  bool InsertMap(std::string fileName);
437 
443  int InsertMapList(std::vector<std::string> fileNames);
444 
450  bool ChooseNextMap(std::string fileName);
451 
457  int ChooseNextMapList(std::vector<std::string> fileNames);
458 
459 private:
461  std::map<std::string, Player>* playerList;
462 };
463 
464 #endif // METHODS_H_
std::vector< Map > GetMapList(int limit, int index)
Gets the maplist from the server.
Definition: MapInfo.cpp:67
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
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:460
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
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
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:10
bool Authenticate(std::string username, std::string password)
Authenticates with the server. Returns whether authentication was successful.
Definition: Global.cpp:3
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
ServerVersion GetVersion()
Returns server version information.
Definition: Global.cpp:87
bool CallVote(std::string xmlRequest)
Start callvote.
Definition: CallVote.cpp:3
std::vector< std::string > GetChatLines()
Get latest chat lines.
Definition: Chat.cpp:45
bool SetApiVersion(std::string version)
Sets the API version of the server. Returns whether change was successful.
Definition: Global.cpp:53
Struct with system information.
Definition: Structs.h:21
Contains all information about a map in easy-to-use format.
Definition: Map.h:10
std::map< std::string, Player > * playerList
Pointer to the playerlist.
Definition: Methods.h:461
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
Contains all server methods and returns usable data types.
Definition: Methods.h:14
Struct with server status.
Definition: Structs.h:39
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:8
bool SendNotice(std::string text, std::string avatarLogin="", int variant=0)
Send notice to all players.
Definition: Notice.cpp:3
Struct with a current callvote.
Definition: Structs.h:59
bool SendDisplayManialinkPageToLogin(std::string login, std::string page, int timeout, bool hideOnClick)
Displays ManiaLink page to a player.
Definition: ManiaLink.cpp:21
std::vector< ManiaLinkPageAnswer > GetManialinkPageAnswers()
Returns the latest results from the current ManiaLink page.
Definition: ManiaLink.cpp:70
bool ChatSendServerMessageToPlayer(std::string text, Player player)
Send chat message to player.
Definition: Chat.cpp:40
bool CancelVote()
Cancels the current callvote.
Definition: CallVote.cpp:38
bool SetCallVoteTimeOut(int timeout)
Sets the default callvote timeout.
Definition: CallVote.cpp:67
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
Map GetCurrentMapInfo()
Provides a map object for the map currently being played on the server.
Definition: MapInfo.cpp:3
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:91
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
CurrentNextValue GetCallVoteTimeOut()
Gets the default callvote timeout.
Definition: CallVote.cpp:83
ServerStatus GetStatus()
Returns server status.
Definition: Global.cpp:147
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
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
bool SetConnectionRates(int downloadRate, int uploadRate)
Sets the server connection rates.
Definition: Global.cpp:130
GbxError GetCurrentError()
Returns the current server error (from GbxRemote).
Definition: Methods.cpp:9
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
Methods(GbxRemote *serverPtr, std::map< std::string, Player > *playerListPtr)
Constructor with link to server connection.
Definition: Methods.cpp:3
bool CallVoteEx(std::string xmlRequest, double ratio, int timeout, int whoVotes)
Start callvote.
Definition: CallVote.cpp:19