1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 06:53:52 +00:00
openmw-tes3mp/components/openmw-mp/Master/MasterData.hpp

79 lines
2 KiB
C++
Raw Normal View History

2017-04-23 05:35:29 +00:00
//
// Created by koncord on 21.04.17.
//
#ifndef NEWMASTERPROTO_MASTERDATA_HPP
#define NEWMASTERPROTO_MASTERDATA_HPP
#include <string>
2017-10-09 23:17:41 +00:00
#include <utility>
2017-04-23 05:35:29 +00:00
#include <vector>
#include <map>
#include <list>
#include <MessageIdentifiers.h>
enum MASTER_PACKETS
{
ID_MASTER_QUERY = ID_USER_PACKET_ENUM,
ID_MASTER_UPDATE,
ID_MASTER_ANNOUNCE
};
struct ServerRule
{
char type;
std::string str;
double val;
};
struct Plugin
{
std::string name;
unsigned hash;
2017-10-10 22:17:02 +00:00
Plugin(std::string name = "", unsigned hash = 0): name(std::move(name)), hash(hash) {};
2017-04-23 05:35:29 +00:00
};
struct QueryData
2017-04-23 05:35:29 +00:00
{
QueryData()
2017-04-23 05:35:29 +00:00
{
rules["name"].type = 's';
rules["name"].str = "";
rules["version"].type = 's';
rules["version"].str = "";
rules["players"].type = 'v';
rules["players"].val = 0;
rules["maxPlayers"].type = 'v';
rules["maxPlayers"].val = 0;
rules["gamemode"].type = 's';
rules["gamemode"].str = "";
rules["passw"].type = 'v';
rules["passw"].val = 0;
}
2017-10-09 23:17:41 +00:00
const char *GetName() const { return rules.at("name").str.c_str(); }
2017-04-23 05:35:29 +00:00
void SetName(const char *name) { rules["name"].str = name; }
2017-10-09 23:17:41 +00:00
const char *GetVersion() const { return rules.at("version").str.c_str(); }
2017-04-23 05:35:29 +00:00
void SetVersion(const char *version) { rules["version"].str = version; }
2017-10-09 23:17:41 +00:00
int GetPlayers() const { return rules.at("players").val; }
2017-04-23 05:35:29 +00:00
void SetPlayers(int players) { rules["players"].val = players; }
2017-10-09 23:17:41 +00:00
int GetMaxPlayers() const { return rules.at("maxPlayers").val; }
2017-04-23 05:35:29 +00:00
void SetMaxPlayers(int players) { rules["maxPlayers"].val = players; }
2017-10-09 23:17:41 +00:00
const char *GetGameMode() const { return rules.at("gamemode").str.c_str(); }
2017-04-23 05:35:29 +00:00
void SetGameMode(const char *str) { rules["gamemode"].str = str; }
void SetPassword(int value) { rules["passw"].val = value; };
2017-10-09 23:17:41 +00:00
int GetPassword() const { return rules.at("passw").val; }
2017-04-23 05:35:29 +00:00
std::vector<std::string> players;
2017-04-23 05:35:29 +00:00
std::map<std::string, ServerRule> rules;
std::vector<Plugin> plugins;
};
#endif //NEWMASTERPROTO_MASTERDATA_HPP