ManaPlus
Public Types | Public Member Functions | Static Public Member Functions | Data Fields
ServerInfo Class Reference

#include <serverinfo.h>

Public Types

typedef std::pair< int, std::string > VersionString
 

Public Member Functions

 ServerInfo ()
 
 ServerInfo (const ServerInfo &info)
 
ServerInfooperator= (const ServerInfo &info)
 
bool isValid () const
 
void clear ()
 
bool operator== (const ServerInfo &other) const
 
bool operator!= (const ServerInfo &other) const
 

Static Public Member Functions

static ServerTypeT parseType (const std::string &serverType)
 
static ServerFreeTypeT parseFreeType (const std::string &serverFreeType)
 

Data Fields

ServerTypeT type
 
ServerFreeTypeT freeType
 
std::string name
 
std::string hostname
 
std::string althostname
 
std::string description
 
std::string registerUrl
 
std::string onlineListUrl
 
std::string supportUrl
 
std::string serverUrl
 
std::string defaultHostName
 
std::vector< std::string > updateMirrors
 
std::vector< HostsGroupupdateHosts
 
std::vector< ServerUrlInfofreeSources
 
std::vector< ServerUrlInfononFreeSources
 
std::vector< ServerUrlInfodocs
 
uint16_t port
 
VersionString version
 
int packetVersion
 
bool save
 
bool persistentIp
 

Detailed Description

Definition at line 37 of file serverinfo.h.

Member Typedef Documentation

◆ VersionString

typedef std::pair<int, std::string> ServerInfo::VersionString

Definition at line 40 of file serverinfo.h.

Constructor & Destructor Documentation

◆ ServerInfo() [1/2]

ServerInfo::ServerInfo ( )
inline

Definition at line 64 of file serverinfo.h.

64  :
67  name(),
68  hostname(),
69  althostname(),
70  description(),
71  registerUrl(),
72  onlineListUrl(),
73  supportUrl(),
74  serverUrl(),
76  updateMirrors(),
77  updateHosts(),
78  freeSources(),
80  docs(),
81 #ifdef TMWA_SUPPORT
82  port(6901),
83 #else // TMWA_SUPPORT
84  port(6900),
85 #endif // TMWA_SUPPORT
86  version(),
87  packetVersion(),
88  save(false),
89  persistentIp(true)
90  {
91  version.first = 0;
92  }
std::string hostname
Definition: serverinfo.h:45
std::vector< std::string > updateMirrors
Definition: serverinfo.h:53
std::string serverUrl
Definition: serverinfo.h:51
std::vector< ServerUrlInfo > nonFreeSources
Definition: serverinfo.h:56
std::string supportUrl
Definition: serverinfo.h:50
std::string althostname
Definition: serverinfo.h:46
uint16_t port
Definition: serverinfo.h:58
std::vector< HostsGroup > updateHosts
Definition: serverinfo.h:54
std::vector< ServerUrlInfo > docs
Definition: serverinfo.h:57
std::string onlineListUrl
Definition: serverinfo.h:49
int packetVersion
Definition: serverinfo.h:60
VersionString version
Definition: serverinfo.h:59
ServerTypeT type
Definition: serverinfo.h:42
bool persistentIp
Definition: serverinfo.h:62
std::string name
Definition: serverinfo.h:44
std::string registerUrl
Definition: serverinfo.h:48
std::string defaultHostName
Definition: serverinfo.h:52
std::string description
Definition: serverinfo.h:47
ServerFreeTypeT freeType
Definition: serverinfo.h:43
bool save
Definition: serverinfo.h:61
std::vector< ServerUrlInfo > freeSources
Definition: serverinfo.h:55

References version.

◆ ServerInfo() [2/2]

ServerInfo::ServerInfo ( const ServerInfo info)
inline

Definition at line 94 of file serverinfo.h.

94  :
95  type(info.type),
96  freeType(info.freeType),
97  name(info.name),
98  hostname(info.hostname),
99  althostname(info.althostname),
100  description(info.description),
101  registerUrl(info.registerUrl),
102  onlineListUrl(info.onlineListUrl),
103  supportUrl(info.supportUrl),
104  serverUrl(info.serverUrl),
105  defaultHostName(info.defaultHostName),
106  updateMirrors(info.updateMirrors),
107  updateHosts(info.updateHosts),
108  freeSources(info.freeSources),
109  nonFreeSources(info.nonFreeSources),
110  docs(info.docs),
111  port(info.port),
112  version(),
113  packetVersion(info.packetVersion),
114  save(info.save),
115  persistentIp(info.persistentIp)
116  {
117  version.first = info.version.first;
118  version.second = info.version.second;
119  }
bool info(InputEvent &event)
Definition: commands.cpp:57

References Actions::info(), and version.

Member Function Documentation

◆ clear()

void ServerInfo::clear ( )
inline

Definition at line 157 of file serverinfo.h.

158  {
160  name.clear();
161  hostname.clear();
162  althostname.clear();
163  port = 0;
164  description.clear();
165  registerUrl.clear();
166  onlineListUrl.clear();
167  supportUrl.clear();
168  serverUrl.clear();
169  defaultHostName.clear();
170  updateMirrors.clear();
171  updateHosts.clear();
172  freeSources.clear();
173  nonFreeSources.clear();
174  docs.clear();
175  version.first = 0;
176  version.second.clear();
177  packetVersion = 0;
178  save = false;
179  persistentIp = true;
181  }

References althostname, defaultHostName, description, docs, freeSources, freeType, hostname, name, nonFreeSources, onlineListUrl, packetVersion, persistentIp, port, registerUrl, save, serverUrl, supportUrl, type, ServerFreeType::Unknown, ServerType::UNKNOWN, updateHosts, updateMirrors, and version.

◆ isValid()

bool ServerInfo::isValid ( ) const
inline

Definition at line 150 of file serverinfo.h.

151  {
152  return !(hostname.empty()
153  || port == 0
154  || type == ServerType::UNKNOWN);
155  }

References hostname, port, type, and ServerType::UNKNOWN.

Referenced by ServerDialog::loadCustomServers(), and ServerDialog::saveCustomServers().

◆ operator!=()

bool ServerInfo::operator!= ( const ServerInfo other) const
inline

Definition at line 190 of file serverinfo.h.

191  {
192  return name != other.name ||
193  hostname != other.hostname ||
194  port != other.port;
195  }

References hostname, name, and port.

◆ operator=()

ServerInfo& ServerInfo::operator= ( const ServerInfo info)
inline

Definition at line 123 of file serverinfo.h.

124  {
125  type = info.type;
126  freeType = info.freeType;
127  name = info.name;
128  hostname = info.hostname;
129  althostname = info.althostname;
130  description = info.description;
131  registerUrl = info.registerUrl;
132  onlineListUrl = info.onlineListUrl;
133  supportUrl = info.supportUrl;
134  serverUrl = info.serverUrl;
135  defaultHostName = info.defaultHostName;
136  updateMirrors = info.updateMirrors;
137  updateHosts = info.updateHosts;
138  freeSources = info.freeSources;
139  nonFreeSources = info.nonFreeSources;
140  docs = info.docs;
141  port = info.port;
142  save = info.save;
143  persistentIp = info.persistentIp;
144  version.first = info.version.first;
145  version.second = info.version.second;
146  packetVersion = info.packetVersion;
147  return *this;
148  }

References althostname, defaultHostName, description, docs, freeSources, freeType, hostname, Actions::info(), name, nonFreeSources, onlineListUrl, packetVersion, persistentIp, port, registerUrl, save, serverUrl, supportUrl, type, updateHosts, updateMirrors, and version.

◆ operator==()

bool ServerInfo::operator== ( const ServerInfo other) const
inline

Definition at line 183 of file serverinfo.h.

184  {
185  return name == other.name &&
186  hostname == other.hostname &&
187  port == other.port;
188  }

References hostname, name, and port.

◆ parseFreeType()

static ServerFreeTypeT ServerInfo::parseFreeType ( const std::string &  serverFreeType)
inlinestatic

Definition at line 214 of file serverinfo.h.

216  {
217  if (compareStrI(serverFreeType, "free") == 0)
218  return ServerFreeType::Free;
219  else if (compareStrI(serverFreeType, "nonfree") == 0)
221  else if (compareStrI(serverFreeType, "unknown") == 0)
223  return ServerFreeType::NotSet;
224  }
int compareStrI(const std::string &a, const std::string &b)

References compareStrI(), ServerFreeType::Free, ServerFreeType::NonFree, ServerFreeType::NotSet, and ServerFreeType::Unknown.

Referenced by ServerDialog::loadServers().

◆ parseType()

static ServerTypeT ServerInfo::parseType ( const std::string &  serverType)
inlinestatic

Definition at line 197 of file serverinfo.h.

199  {
200 #ifdef TMWA_SUPPORT
201  if (compareStrI(serverType, "tmwathena") == 0)
202  return ServerType::TMWATHENA;
203  else
204 #endif // TMWA_SUPPORT
205  if (compareStrI(serverType, "eathena") == 0)
206  return ServerType::EATHENA;
207  else if (compareStrI(serverType, "hercules") == 0)
208  return ServerType::EATHENA;
209  else if (compareStrI(serverType, "evol2") == 0)
210  return ServerType::EVOL2;
211  return ServerType::UNKNOWN;
212  }

References compareStrI(), ServerType::EATHENA, ServerType::EVOL2, ServerType::TMWATHENA, and ServerType::UNKNOWN.

Referenced by ServerDialog::loadCustomServers(), and ServerDialog::loadServers().

Field Documentation

◆ althostname

std::string ServerInfo::althostname

◆ defaultHostName

std::string ServerInfo::defaultHostName

◆ description

std::string ServerInfo::description

◆ docs

std::vector<ServerUrlInfo> ServerInfo::docs

◆ freeSources

std::vector<ServerUrlInfo> ServerInfo::freeSources

◆ freeType

ServerFreeTypeT ServerInfo::freeType

◆ hostname

std::string ServerInfo::hostname

◆ name

std::string ServerInfo::name

◆ nonFreeSources

std::vector<ServerUrlInfo> ServerInfo::nonFreeSources

◆ onlineListUrl

std::string ServerInfo::onlineListUrl

◆ packetVersion

int ServerInfo::packetVersion

◆ persistentIp

bool ServerInfo::persistentIp

◆ port

uint16_t ServerInfo::port

◆ registerUrl

std::string ServerInfo::registerUrl

◆ save

bool ServerInfo::save

◆ serverUrl

std::string ServerInfo::serverUrl

◆ supportUrl

std::string ServerInfo::supportUrl

◆ type

ServerTypeT ServerInfo::type

◆ updateHosts

std::vector<HostsGroup> ServerInfo::updateHosts

◆ updateMirrors

std::vector<std::string> ServerInfo::updateMirrors

◆ version

VersionString ServerInfo::version

Definition at line 59 of file serverinfo.h.

Referenced by clear(), ServerDialog::loadServers(), operator=(), and ServerInfo().


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