summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/enums/net/serverfreetype.h37
-rw-r--r--src/gui/models/serverslistmodel.h14
-rw-r--r--src/gui/windows/serverdialog.cpp5
-rw-r--r--src/net/serverinfo.h18
6 files changed, 76 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8b3908a9b..8baf3b537 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -572,6 +572,7 @@ SET(SRCS
const/net/nostat.h
net/partyhandler.h
enums/net/partyshare.h
+ enums/net/serverfreetype.h
enums/net/servertype.h
enums/net/storesearchtype.h
net/pethandler.h
diff --git a/src/Makefile.am b/src/Makefile.am
index c4767ac47..0be6ca0cc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -403,6 +403,7 @@ BASE_SRC += events/actionevent.h \
enums/net/npcaction.h \
enums/net/packettype.h \
enums/net/partyshare.h \
+ enums/net/serverfreetype.h \
enums/net/servertype.h \
enums/net/storesearchtype.h \
enums/net/updatetype.h \
diff --git a/src/enums/net/serverfreetype.h b/src/enums/net/serverfreetype.h
new file mode 100644
index 000000000..0819f10f1
--- /dev/null
+++ b/src/enums/net/serverfreetype.h
@@ -0,0 +1,37 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ENUMS_NET_SERVERFREETYPE_H
+#define ENUMS_NET_SERVERFREETYPE_H
+
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(ServerFreeType)
+{
+ Unknown = 0,
+ NotSet = 1,
+ Free = 2,
+ NonFree = 3
+}
+enumEnd(ServerFreeType);
+
+#endif // ENUMS_NET_SERVERFREETYPE_H
diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h
index 935fd3422..206daa02a 100644
--- a/src/gui/models/serverslistmodel.h
+++ b/src/gui/models/serverslistmodel.h
@@ -31,6 +31,8 @@
#include "gui/models/listmodel.h"
+#include "utils/gettext.h"
+
/**
* Server and Port List Model
*/
@@ -68,6 +70,18 @@ class ServersListModel final : public ListModel
MutexLocker lock = mParent->lock();
const ServerInfo &server = mServers->at(elementIndex);
std::string myServer;
+ if (server.freeType == ServerFreeType::NonFree)
+ {
+ // TRANSLATORS: server license comment
+ myServer.append(_("(NON FREE)"));
+ myServer.append(" ");
+ }
+ else if (server.freeType == ServerFreeType::Unknown)
+ {
+ // TRANSLATORS: server license comment
+ myServer.append(_("(UNKNOWN)"));
+ myServer.append(" ");
+ }
myServer.append(server.hostname);
return myServer;
}
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index 9600028b3..89a4774ee 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -240,6 +240,7 @@ void ServerDialog::connectToSelectedServer()
mServerInfo->defaultHostName = server.defaultHostName;
mServerInfo->save = true;
mServerInfo->persistentIp = server.persistentIp;
+ mServerInfo->freeType = server.freeType;
mServerInfo->updateMirrors = server.updateMirrors;
mServerInfo->packetVersion = server.packetVersion;
mServerInfo->updateHosts = server.updateHosts;
@@ -524,6 +525,9 @@ void ServerDialog::loadServers(const bool addNew)
serverNode, "type", "unknown");
ServerInfo server;
server.type = ServerInfo::parseType(type);
+ const std::string licenseType = XML::getProperty(
+ serverNode, "licenseType", "notset");
+ server.freeType = ServerInfo::parseFreeType(licenseType);
// Ignore unknown server types
if (server.type == ServerType::UNKNOWN)
@@ -630,6 +634,7 @@ void ServerDialog::loadServers(const bool addNew)
// Use the name listed in the server list
mServers[i].name = server.name;
mServers[i].type = server.type;
+ mServers[i].freeType = server.freeType;
mServers[i].version = server.version;
mServers[i].description = server.description;
mServers[i].registerUrl = server.registerUrl;
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index c02e67505..e83e51b56 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -23,6 +23,7 @@
#ifndef NET_SERVERINFO_H
#define NET_SERVERINFO_H
+#include "enums/net/serverfreetype.h"
#include "enums/net/servertype.h"
#include "net/hostsgroup.h"
@@ -37,6 +38,7 @@ class ServerInfo final
typedef std::pair<int, std::string> VersionString;
ServerTypeT type;
+ ServerFreeTypeT freeType;
std::string name;
std::string hostname;
std::string althostname;
@@ -55,6 +57,7 @@ class ServerInfo final
ServerInfo() :
type(ServerType::TMWATHENA),
+ freeType(ServerFreeType::NotSet),
name(),
hostname(),
althostname(),
@@ -80,6 +83,7 @@ class ServerInfo final
ServerInfo(const ServerInfo &info) :
type(info.type),
+ freeType(info.freeType),
name(info.name),
hostname(info.hostname),
althostname(info.althostname),
@@ -105,6 +109,7 @@ class ServerInfo final
ServerInfo &operator=(const ServerInfo &info)
{
type = info.type;
+ freeType = info.freeType;
name = info.name;
hostname = info.hostname;
althostname = info.althostname;
@@ -150,6 +155,7 @@ class ServerInfo final
packetVersion = 0;
save = false;
persistentIp = true;
+ freeType = ServerFreeType::Unknown;
}
bool operator==(const ServerInfo &other) const
@@ -180,6 +186,18 @@ class ServerInfo final
return ServerType::EVOL2;
return ServerType::UNKNOWN;
}
+
+ static ServerFreeTypeT parseFreeType(const std::string &serverFreeType)
+ A_WARN_UNUSED
+ {
+ if (compareStrI(serverFreeType, "free") == 0)
+ return ServerFreeType::Free;
+ else if (compareStrI(serverFreeType, "nonfree") == 0)
+ return ServerFreeType::NonFree;
+ else if (compareStrI(serverFreeType, "unknown") == 0)
+ return ServerFreeType::Unknown;
+ return ServerFreeType::NotSet;
+ }
};
typedef std::vector<ServerInfo> ServerInfos;