summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/base64.cpp214
-rw-r--r--src/utils/base64.h46
-rw-r--r--src/utils/booleanoptions.h32
-rw-r--r--src/utils/browserboxtools.cpp169
-rw-r--r--src/utils/browserboxtools.h39
-rw-r--r--src/utils/buildhex.h48
-rw-r--r--src/utils/cast.h35
-rw-r--r--src/utils/chatutils.cpp201
-rw-r--r--src/utils/chatutils.h36
-rw-r--r--src/utils/checkutils.cpp76
-rw-r--r--src/utils/checkutils.h261
-rw-r--r--src/utils/copynpaste.cpp522
-rw-r--r--src/utils/copynpaste.h42
-rw-r--r--src/utils/cpu.cpp178
-rw-r--r--src/utils/cpu.h48
-rw-r--r--src/utils/delete2.h36
-rw-r--r--src/utils/dtor.h60
-rw-r--r--src/utils/dumplibs.cpp169
-rw-r--r--src/utils/dumplibs.h28
-rw-r--r--src/utils/dumpsizes.cpp40
-rw-r--r--src/utils/dumpsizes.h28
-rw-r--r--src/utils/env.cpp73
-rw-r--r--src/utils/env.h30
-rw-r--r--src/utils/foreach.h36
-rw-r--r--src/utils/fuzzer.cpp60
-rw-r--r--src/utils/fuzzer.h34
-rw-r--r--src/utils/gettext.h55
-rw-r--r--src/utils/gettexthelper.cpp156
-rw-r--r--src/utils/gettexthelper.h45
-rw-r--r--src/utils/glxhelper.cpp142
-rw-r--r--src/utils/glxhelper.h42
-rw-r--r--src/utils/gmfunctions.cpp122
-rw-r--r--src/utils/gmfunctions.h43
-rw-r--r--src/utils/intmap.h30
-rw-r--r--src/utils/langs.cpp123
-rw-r--r--src/utils/langs.h41
-rw-r--r--src/utils/likely.h32
-rw-r--r--src/utils/mathutils.h251
-rw-r--r--src/utils/mrand.cpp45
-rw-r--r--src/utils/mrand.h30
-rw-r--r--src/utils/mutex.h110
-rw-r--r--src/utils/naclmessages.cpp109
-rw-r--r--src/utils/naclmessages.h41
-rw-r--r--src/utils/parameters.cpp119
-rw-r--r--src/utils/parameters.h33
-rw-r--r--src/utils/perfomance.cpp100
-rw-r--r--src/utils/perfomance.h83
-rw-r--r--src/utils/pnglib.cpp113
-rw-r--r--src/utils/pnglib.h38
-rw-r--r--src/utils/process.cpp328
-rw-r--r--src/utils/process.h37
-rw-r--r--src/utils/sdl2helper.cpp271
-rw-r--r--src/utils/sdl2helper.h84
-rw-r--r--src/utils/sdl2logger.cpp161
-rw-r--r--src/utils/sdl2logger.h36
-rw-r--r--src/utils/sdlcheckutils.cpp201
-rw-r--r--src/utils/sdlcheckutils.h78
-rw-r--r--src/utils/sdlhelper.cpp217
-rw-r--r--src/utils/sdlhelper.h85
-rw-r--r--src/utils/sdlmemoryobject.h55
-rw-r--r--src/utils/sdlpixel.h254
-rw-r--r--src/utils/sdlsharedhelper.cpp55
-rw-r--r--src/utils/sdlsharedhelper.h31
-rw-r--r--src/utils/stdmove.h30
-rw-r--r--src/utils/stringmap.h31
-rw-r--r--src/utils/stringutils.cpp1238
-rw-r--r--src/utils/stringutils.h288
-rw-r--r--src/utils/stringvector.h32
-rw-r--r--src/utils/timer.cpp124
-rw-r--r--src/utils/timer.h44
-rw-r--r--src/utils/translation/podict.cpp61
-rw-r--r--src/utils/translation/podict.h73
-rw-r--r--src/utils/translation/poparser.cpp286
-rw-r--r--src/utils/translation/poparser.h87
-rw-r--r--src/utils/translation/translationmanager.cpp154
-rw-r--r--src/utils/translation/translationmanager.h58
-rw-r--r--src/utils/vector.h32
-rw-r--r--src/utils/x11logger.cpp213
-rw-r--r--src/utils/x11logger.h36
-rw-r--r--src/utils/xml.h34
-rw-r--r--src/utils/xml.inc30
-rw-r--r--src/utils/xml/libxml.cpp346
-rw-r--r--src/utils/xml/libxml.h164
-rw-r--r--src/utils/xml/libxml.inc73
-rw-r--r--src/utils/xml/pugixml.cpp352
-rw-r--r--src/utils/xml/pugixml.h166
-rw-r--r--src/utils/xml/pugixml.inc58
-rw-r--r--src/utils/xml/pugixmlwriter.cpp74
-rw-r--r--src/utils/xml/pugixmlwriter.h65
-rw-r--r--src/utils/xml/tinyxml2.cpp323
-rw-r--r--src/utils/xml/tinyxml2.h168
-rw-r--r--src/utils/xml/tinyxml2.inc77
-rw-r--r--src/utils/xmlutils.cpp185
-rw-r--r--src/utils/xmlutils.h57
-rw-r--r--src/utils/xmlwriter.h28
95 files changed, 0 insertions, 11324 deletions
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
deleted file mode 100644
index 62ba76f21..000000000
--- a/src/utils/base64.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2000 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-
-#include "utils/base64.h"
-
-#include "utils/cast.h"
-
-#include "debug.h"
-
-static char base64_table[] =
-{
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0'
-};
-static const char base64_pad = '=';
-
-unsigned char *php3_base64_encode(const unsigned char *restrict const string,
- int length,
- int *restrict const ret_length)
-{
- if (string == nullptr)
- return nullptr;
- const unsigned char *current = string;
- int i = 0;
- unsigned char *const result = static_cast<unsigned char *>(
- calloc(CAST_SIZE((length + 3 - length % 3) * 4 / 3 + 1)
- * sizeof(unsigned char), 1));
- if (result == nullptr)
- return nullptr;
-
- while (length > 2)
- { /* keep going until we have less than 24 bits */
- result[i++] = base64_table[current[0] >> 2];
- result[i++] = base64_table[((current[0] & 0x03)
- << 4) + (current[1] >> 4)];
- result[i++] = base64_table[((current[1] & 0x0f)
- << 2) + (current[2] >> 6)];
- result[i++] = base64_table[current[2] & 0x3f];
-
- current += 3;
- length -= 3; /* we just handle 3 octets of data */
- }
-
- /* now deal with the tail end of things */
- if (length != 0)
- {
- result[i++] = base64_table[current[0] >> 2];
- if (length > 1)
- {
- result[i++] = base64_table[((current[0] & 0x03) << 4)
- + (current[1] >> 4)];
- result[i++] = base64_table[(current[1] & 0x0f) << 2];
- result[i++] = base64_pad;
- }
- else
- {
- result[i++] = base64_table[(current[0] & 0x03) << 4];
- result[i++] = base64_pad;
- result[i++] = base64_pad;
- }
- }
- if (ret_length != nullptr)
- {
- *ret_length = i;
- }
- result[i] = '\0';
- return result;
-}
-
-/* as above, but backwards. :) */
-unsigned char *php3_base64_decode(const unsigned char *restrict const string,
- const int length,
- int *restrict const ret_length)
-{
- const unsigned char *current = string;
- int ch, i = 0, j = 0, k;
-
- unsigned char *result = static_cast<unsigned char *>(
- calloc(length + 1, 1));
-
- if (result == nullptr)
- return nullptr;
-
- /* run through the whole string, converting as we go */
- while ((ch = *current++) != '\0')
- {
- if (ch == base64_pad)
- break;
-
- /* When Base64 gets POSTed, all pluses are interpreted as spaces.
- This line changes them back. It's not exactly the Base64 spec,
- but it is completely compatible with it (the spec says that
- spaces are invalid). This will also save many people considerable
- headache. - Turadg Aleahmad <turadg@wise.berkeley.edu>
- */
-
- if (ch == ' ') ch = '+';
-
- const char *const chp = strchr(base64_table, ch);
- if (chp == nullptr)
- continue;
- ch = CAST_S32(chp - base64_table);
-
- switch (i % 4)
- {
- case 0:
- result[j] = CAST_U8(ch << 2U);
- break;
- case 1:
- result[j++] |= CAST_U8(ch >> 4U);
- result[j] = CAST_U8((ch & 0x0f) << 4U);
- break;
- case 2:
- result[j++] |= CAST_U8(ch >>2U);
- result[j] = CAST_U8((ch & 0x03) << 6U);
- break;
- case 3:
- result[j++] |= CAST_U8(ch);
- break;
- default:
- break;
- }
- i++;
- }
-
- k = j;
- /* mop things up if we ended on a boundary */
- if (ch == base64_pad)
- {
- switch (i % 4)
- {
- case 0:
- case 1:
- free(result);
- return nullptr;
- case 2:
- k++;
- // copy from 3. is it should be here?
- result[k++] = 0;
- break;
- case 3:
- result[k++] = 0;
- break;
- default:
- break;
- }
- }
- if (ret_length != nullptr)
- {
- *ret_length = j;
- }
- result[k] = '\0';
- return result;
-}
-
-std::string encodeBase64String(std::string value)
-{
- int sz = 0;
- const unsigned char *const str = reinterpret_cast<unsigned char*>(
- const_cast<char*>(value.c_str()));
- unsigned char *const buf = php3_base64_encode(
- str, CAST_S32(value.size()), &sz);
- if (buf == nullptr)
- return std::string();
-
- value = std::string(reinterpret_cast<char*>(buf), sz);
- free(buf);
- return value;
-}
-
-std::string decodeBase64String(std::string value)
-{
- int sz = 0;
- const unsigned char *const str = reinterpret_cast<unsigned char*>(
- const_cast<char*>(value.c_str()));
- unsigned char *const buf = php3_base64_decode(
- str, CAST_S32(value.size()), &sz);
-
- if (buf != nullptr)
- value = std::string(reinterpret_cast<char*>(buf), sz);
- else
- value.clear();
- free(buf);
- return value;
-}
diff --git a/src/utils/base64.h b/src/utils/base64.h
deleted file mode 100644
index 4518a3e5a..000000000
--- a/src/utils/base64.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | 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 both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-
-#ifndef UTILS_BASE64_H
-#define UTILS_BASE64_H
-
-#include <string>
-
-#include "localconsts.h"
-
-unsigned char *php3_base64_encode(const unsigned char *restrict,
- int, int *restrict) A_WARN_UNUSED;
-unsigned char *php3_base64_decode(const unsigned char *restrict,
- int, int *restrict ) A_WARN_UNUSED;
-
-std::string encodeBase64String(std::string value) A_WARN_UNUSED;
-
-std::string decodeBase64String(std::string value) A_WARN_UNUSED;
-
-#endif // UTILS_BASE64_H
diff --git a/src/utils/booleanoptions.h b/src/utils/booleanoptions.h
deleted file mode 100644
index cd9f97862..000000000
--- a/src/utils/booleanoptions.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_BOOLEANOPTIONS_H
-#define UTILS_BOOLEANOPTIONS_H
-
-#include "utils/gettext.h"
-
-UTILS_GETTEXT_H
-
-// TRANSLATORS: chat option changed message
-#define BOOLEAN_OPTIONS _("Options to /%s are \"yes\", \"no\", \"true\", "\
-"\"false\", \"1\", \"0\".")
-
-#endif // UTILS_BOOLEANOPTIONS_H
diff --git a/src/utils/browserboxtools.cpp b/src/utils/browserboxtools.cpp
deleted file mode 100644
index 10113e220..000000000
--- a/src/utils/browserboxtools.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * The ManaPlus Client
- * 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/>.
- */
-
-#include "utils/browserboxtools.h"
-
-#include "itemcolormanager.h"
-#include "main.h"
-#include "settings.h"
-
-#include "input/inputmanager.h"
-
-#include "utils/stringutils.h"
-
-#ifndef DYECMD
-#include "const/resources/item/cards.h"
-
-#include "resources/beinginfo.h"
-#include "resources/iteminfo.h"
-
-#include "resources/db/homunculusdb.h"
-#include "resources/db/itemdb.h"
-#include "resources/db/mercenarydb.h"
-#include "resources/db/monsterdb.h"
-#include "resources/db/questdb.h"
-#include "resources/db/petdb.h"
-#endif // DYECMD
-
-#include "debug.h"
-
-void BrowserBoxTools::replaceVars(std::string &data)
-{
- data = replaceAll(data, "%VER%", SMALL_VERSION);
- data = replaceAll(data, "%SUPPORTURL%", settings.supportUrl);
-}
-
-void BrowserBoxTools::replaceKeys(std::string &data)
-{
- size_t idx1 = data.find("###");
- while (idx1 != std::string::npos)
- {
- const size_t idx2 = data.find(';', idx1);
- if (idx2 == std::string::npos)
- break;
-
- const std::string str = inputManager.getKeyValueByNameLong(
- data.substr(idx1 + 3, idx2 - idx1 - 3));
- data.replace(idx1, idx2 - idx1 + 1, str);
-
- idx1 = data.find("###");
- }
-}
-
-std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
-{
-#ifdef DYECMD
- return link;
-#else // DYECMD
-
- std::string data = link;
-
- if (strStartWith(data, "http://") ||
- strStartWith(data, "https://"))
- {
- return data;
- }
-
- if (!link.empty() && link[0] == 'm')
- { // monster link
- const BeingTypeId id = static_cast<BeingTypeId>(
- atoi(link.substr(1).c_str()));
- BeingInfo *const info = MonsterDB::get(id);
- if (info != nullptr)
- data = info->getName();
- }
- else if (!link.empty() && link[0] == 'p')
- { // pet link
- const BeingTypeId id = static_cast<BeingTypeId>(
- atoi(link.substr(1).c_str()));
- BeingInfo *const info = PETDB::get(id);
- if (info != nullptr)
- data = info->getName();
- }
- else if (!link.empty() && link[0] == 'h')
- { // homunculus link
- const BeingTypeId id = static_cast<BeingTypeId>(
- atoi(link.substr(1).c_str()));
- BeingInfo *const info = HomunculusDB::get(id);
- if (info != nullptr)
- data = info->getName();
- }
- else if (!link.empty() && link[0] == 'M')
- { // mercenary link
- const BeingTypeId id = static_cast<BeingTypeId>(
- atoi(link.substr(1).c_str()));
- BeingInfo *const info = MercenaryDB::get(id);
- if (info != nullptr)
- data = info->getName();
- }
- else if (!link.empty() && link[0] == 'q')
- { // quest link
- data = QuestDb::getName(
- atoi(link.substr(1).c_str()));
- }
- else
- { // item link
- size_t idx = link.find(',');
- if (idx != std::string::npos)
- {
- const int id = atoi(link.substr(0, idx).c_str());
- if (id != 0)
- {
- STD_VECTOR<int> parts;
- splitToIntVector(parts,
- link.substr(idx), ',');
- while (parts.size() < maxCards)
- parts.push_back(0);
- const ItemColor itemColor =
- ItemColorManager::getColorFromCards(&parts[0]);
- data = ItemDB::get(id).getName(itemColor);
- }
- }
- else
- {
- const int id = atoi(link.c_str());
- if (id != 0)
- data = ItemDB::get(id).getName();
- }
- }
- return data;
-#endif // DYECMD
-}
-
-void BrowserBoxTools::replaceTabs(std::string &data)
-{
- size_t idx1 = data.find("\\t");
- while (idx1 != std::string::npos)
- {
- const size_t idx2 = data.find(';', idx1);
- if (idx2 == std::string::npos)
- break;
-
- const unsigned int newSize = CAST_U32(
- atoi(data.substr(
- idx1 + 2, idx2 - idx1 - 2).c_str()));
- std::string str = data.substr(0, idx1);
- while (str.size() < newSize)
- str.append(" ");
- str.append(data.substr(idx2 + 1));
- data = str;
- idx1 = data.find("\\t");
- }
-}
diff --git a/src/utils/browserboxtools.h b/src/utils/browserboxtools.h
deleted file mode 100644
index 8caa0d89c..000000000
--- a/src/utils/browserboxtools.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_BROWSERBOXTOOLS_H
-#define UTILS_BROWSERBOXTOOLS_H
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace BrowserBoxTools
-{
- void replaceVars(std::string &data);
-
- void replaceKeys(std::string &data);
-
- std::string replaceLinkCommands(const std::string &link);
-
- void replaceTabs(std::string &data);
-} // namespace BrowserBoxTools
-
-#endif // UTILS_BROWSERBOXTOOLS_H
diff --git a/src/utils/buildhex.h b/src/utils/buildhex.h
deleted file mode 100644
index 6833e9528..000000000
--- a/src/utils/buildhex.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-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 UTILS_BUILDHEX_H
-#define UTILS_BUILDHEX_H
-
-#include "utils/cast.h"
-
-#include "localconsts.h"
-
-UTILS_CAST_H
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef SDL_BIG_ENDIAN
-#include <SDL_endian.h>
-#endif // SDL_BYTEORDER
-PRAGMA48(GCC diagnostic pop)
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-#define buildHex(a, b, c, d) \
- (d) * 16777216U + (c) * 65536U + (b) * 256U + CAST_U32(a)
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-#define buildHex(a, b, c, d) \
- (a) * 16777216U + (b) * 65536U + (c) * 256U + CAST_U32(d)
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
-#define buildHexOgl(a, b, c, d) \
- (a) * 16777216U + (b) * 65536U + (c) * 256U + CAST_U32(d)
-
-#endif // UTILS_BUILDHEX_H
diff --git a/src/utils/cast.h b/src/utils/cast.h
deleted file mode 100644
index f12f1badb..000000000
--- a/src/utils/cast.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_CAST_H
-#define UTILS_CAST_H
-
-#define CAST_8 static_cast<char>
-#define CAST_S8 static_cast<int8_t>
-#define CAST_U8 static_cast<uint8_t>
-#define CAST_S16 static_cast<int16_t>
-#define CAST_U16 static_cast<uint16_t>
-#define CAST_S32 static_cast<int32_t>
-#define CAST_U32 static_cast<uint32_t>
-#define CAST_S64 static_cast<int64_t>
-#define CAST_U64 static_cast<uint64_t>
-#define CAST_SIZE static_cast<size_t>
-
-#endif // UTILS_CAST_H
diff --git a/src/utils/chatutils.cpp b/src/utils/chatutils.cpp
deleted file mode 100644
index cb264dff1..000000000
--- a/src/utils/chatutils.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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/>.
- */
-
-#include "utils/chatutils.h"
-
-#include "actormanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-
-#include "const/gui/chat.h"
-
-#include "gui/widgets/tabs/chat/whispertab.h"
-
-#include "net/chathandler.h"
-#include "net/guildhandler.h"
-#include "net/partyhandler.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/net.h"
-
-#include "net/tmwa/guildmanager.h"
-#endif // TMWA_SUPPORT
-
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-void outStringNormal(ChatTab *const tab,
- const std::string &str,
- const std::string &def)
-{
- if (localPlayer == nullptr)
- return;
-
- if (tab == nullptr)
- {
- chatHandler->talk(str, GENERAL_CHANNEL);
- return;
- }
-
- switch (tab->getType())
- {
- case ChatTabType::PARTY:
- {
- partyHandler->chat(str);
- break;
- }
- case ChatTabType::GUILD:
- {
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- {
-#ifdef TMWA_SUPPORT
- if (guild->getServerGuild())
- {
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- return;
- guildHandler->chat(str);
- }
- else if (guildManager != nullptr)
- {
- guildManager->chat(str);
- }
-#else // TMWA_SUPPORT
-
- if (guild->getServerGuild())
- guildHandler->chat(str);
-#endif // TMWA_SUPPORT
- }
- break;
- }
- case ChatTabType::WHISPER:
- {
- const WhisperTab *const whisper
- = static_cast<const WhisperTab *>(tab);
- tab->chatLog(localPlayer->getName(), str);
- chatHandler->privateMessage(whisper->getNick(), str);
- break;
- }
- case ChatTabType::DEBUG:
- case ChatTabType::BATTLE:
- break;
- default:
- case ChatTabType::UNKNOWN:
- case ChatTabType::INPUT:
- case ChatTabType::TRADE:
- case ChatTabType::LANG:
- case ChatTabType::GM:
- case ChatTabType::CHANNEL:
- chatHandler->talk(def, GENERAL_CHANNEL);
- break;
- }
-}
-
-void replaceVars(std::string &str)
-{
- if ((localPlayer == nullptr) || (actorManager == nullptr))
- return;
-
- if (str.find("<PLAYER>") != std::string::npos)
- {
- const Being *target = localPlayer->getTarget();
- if ((target == nullptr) || target->getType() != ActorType::Player)
- {
- target = actorManager->findNearestLivingBeing(
- localPlayer, 20, ActorType::Player, AllowSort_true);
- }
- if (target != nullptr)
- replaceAll(str, "<PLAYER>", target->getName());
- else
- replaceAll(str, "<PLAYER>", "");
- }
- if (str.find("<MONSTER>") != std::string::npos)
- {
- const Being *target = localPlayer->getTarget();
- if ((target == nullptr) || target->getType() != ActorType::Monster)
- {
- target = actorManager->findNearestLivingBeing(
- localPlayer, 20, ActorType::Monster, AllowSort_true);
- }
- if (target != nullptr)
- replaceAll(str, "<MONSTER>", target->getName());
- else
- replaceAll(str, "<MONSTER>", "");
- }
- if (str.find("<PEOPLE>") != std::string::npos)
- {
- StringVect names;
- std::string newStr;
- actorManager->getPlayerNames(names, NpcNames_false);
- FOR_EACH (StringVectCIter, it, names)
- {
- if (*it != localPlayer->getName())
- newStr.append(*it).append(",");
- }
- if (!newStr.empty())
- {
- if (newStr[newStr.size() - 1] == ',')
- newStr = newStr.substr(0, newStr.size() - 1);
- replaceAll(str, "<PEOPLE>", newStr);
- }
- else
- {
- replaceAll(str, "<PEOPLE>", "");
- }
- }
- if (str.find("<PARTY>") != std::string::npos)
- {
- StringVect names;
- std::string newStr;
- const Party *party = nullptr;
- if (localPlayer->isInParty() &&
- ((party = localPlayer->getParty()) != nullptr))
- {
- party->getNames(names);
- FOR_EACH (StringVectCIter, it, names)
- {
- if (*it != localPlayer->getName())
- newStr.append(*it).append(",");
- }
- if (!newStr.empty())
- {
- if (newStr[newStr.size() - 1] == ',')
- newStr = newStr.substr(0, newStr.size() - 1);
- replaceAll(str, "<PARTY>", newStr);
- }
- else
- {
- replaceAll(str, "<PARTY>", "");
- }
- }
- else
- {
- replaceAll(str, "<PARTY>", "");
- }
- }
-}
-
-std::string textToMe(const std::string &str)
-{
- return strprintf("*%s*", str.c_str());
-}
diff --git a/src/utils/chatutils.h b/src/utils/chatutils.h
deleted file mode 100644
index dd2f81df1..000000000
--- a/src/utils/chatutils.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_CHATUTILS_H
-#define UTILS_CHATUTILS_H
-
-#include <string>
-
-class ChatTab;
-
-void outStringNormal(ChatTab *const tab,
- const std::string &str,
- const std::string &def);
-
-void replaceVars(std::string &str);
-
-std::string textToMe(const std::string &str);
-
-#endif // UTILS_CHATUTILS_H
diff --git a/src/utils/checkutils.cpp b/src/utils/checkutils.cpp
deleted file mode 100644
index 8e72dbf7d..000000000
--- a/src/utils/checkutils.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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/>.
- */
-
-#ifdef ENABLE_ASSERTS
-
-#include "utils/checkutils.h"
-
-#include "logger.h"
-
-#ifdef HAVE_EXECINFO
-#include <execinfo.h>
-#endif // HAVE_EXECINFO
-
-#include "debug.h"
-
-void reportAssertStack(const char *const file,
- const unsigned int line,
- const char *const func,
- const char *const name,
- const char *const text)
-{
- logger->log("--- Assert: %s --------------------------------------------",
- name);
- logger->assertLog("%s:%u: '%s' in function `%s'",
- file,
- line,
- text,
- func);
-#ifdef HAVE_EXECINFO
- reportStack();
-#endif // HAVE_EXECINFO
-}
-
-void reportLogStack(const char *const file,
- const unsigned int line,
- const char *const func)
-{
- logger->assertLog("%s:%u: in function `%s'",
- file,
- line,
- func);
-#ifdef HAVE_EXECINFO
- reportStack();
-#endif // HAVE_EXECINFO
-}
-
-void reportStack()
-{
-#ifdef HAVE_EXECINFO
- void *array[15];
- const int size = static_cast<int>(backtrace(array, 15));
- char **strings = backtrace_symbols(array, size);
- for (int i = 0; i < size; i++)
- logger->log1(strings[i]);
- free(strings);
-#endif // HAVE_EXECINFO
-}
-
-#endif // ENABLE_ASSERTS
diff --git a/src/utils/checkutils.h b/src/utils/checkutils.h
deleted file mode 100644
index dbac859e4..000000000
--- a/src/utils/checkutils.h
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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 UTILS_CHECKUTILS_H
-#define UTILS_CHECKUTILS_H
-
-#include "logger.h"
-LOGGER_H
-
-#ifdef ENABLE_ASSERTS
-
-#define reportFalseReal(val) \
- (val ? true : (reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val), false))
-
-#define reportTrueReal(val) \
- (val ? (reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val), true) : false)
-
-#define reportAlwaysReal(...) \
- { \
- logger->log("Assert:"); \
- logger->assertLog( \
- __VA_ARGS__); \
- reportLogStack(__FILE__, __LINE__, __func__); \
- }
-
-#define returnFalseVReal(val) \
- if (!val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val); \
- return; \
- }
-
-#define returnTrueVReal(val) \
- if (val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected true value", #val); \
- return; \
- }
-
-#define returnFalseReal(ret, val) \
- if (!val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val); \
- return ret; \
- }
-
-#define returnTrueReal(ret, val) \
- if (val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected true value", #val); \
- return ret; \
- }
-
-#define returnNullptrVReal(val) \
- if ((val) == nullptr) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected null value", #val); \
- return; \
- }
-
-#define returnNullptrReal(ret, val) \
- if ((val) == nullptr) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected null value", #val); \
- return ret; \
- }
-
-#define failFalse(val) \
- (val ? true : (reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val), \
- throw new std::exception(), false))
-
-#define failTrue(val) \
- (val ? (reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val), \
- throw new std::exception(), true) : false)
-
-#define returnFailFalseV(val) \
- if (!val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val); \
- throw new std::exception(); \
- }
-
-#define returnFailTrueV(val) \
- if (val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected true value", #val); \
- throw new std::exception(); \
- }
-
-#define returnFailFalse(ret, val) \
- if (!val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val); \
- throw new std::exception(); \
- }
-
-#define returnFailTrue(ret, val) \
- if (val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected true value", #val); \
- throw new std::exception(); \
- }
-
-#define returnFailNullptrV(val) \
- if ((val) == nullptr) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected null value", #val); \
- throw new std::exception(); \
- }
-
-#define returnFailNullptr(ret, val) \
- if ((val) == nullptr) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected null value", #val); \
- throw new std::exception(); \
- }
-
-#define failAlways(...) \
- { \
- logger->log("Assert:"); \
- logger->assertLog( \
- __VA_ARGS__); \
- reportLogStack(__FILE__, __LINE__, __func__); \
- throw new std::exception(); \
- }
-
-void reportAssertStack(const char *const file,
- const unsigned int line,
- const char *const func,
- const char *const name,
- const char *const text);
-
-void reportLogStack(const char *const file,
- const unsigned int line,
- const char *const func);
-
-void reportStack();
-
-#else // ENABLE_ASSERTS
-
-#define reportFalseReal(val) (val)
-#define reportTrueReal(val) (val)
-
-#define reportAlwaysReal(...) \
- { \
- logger->log("Error:"); \
- logger->log( \
- __VA_ARGS__); \
- }
-
-#define returnFalseVReal(val) \
- if (!val) \
- return;
-
-#define returnTrueVReal(val) \
- if (val) \
- return;
-
-#define returnFalseReal(ret, val) \
- if (!val) \
- return ret;
-
-#define returnTrueReal(ret, val) \
- if (val) \
- return ret;
-
-#define returnNullptrVReal(val) \
- if ((val) == nullptr) \
- return;
-
-#define returnNullptrReal(ret, val) \
- if ((val) == nullptr) \
- return ret;
-
-#define failFalse(val) (val)
-#define failTrue(val) (val)
-
-#define returnFailFalseV(val) \
- if (!val) \
- return;
-
-#define returnFailTrueV(val) \
- if (val) \
- return;
-
-#define returnFailFalse(ret, val) \
- if (!val) \
- return ret;
-
-#define returnFailTrue(ret, val) \
- if (val) \
- return ret;
-
-#define returnFailNullptrV(val) \
- if ((val) == nullptr) \
- return;
-
-#define returnFailNullptr(ret, val) \
- if ((val) == nullptr) \
- return ret;
-
-#define failAlways(...) ;
-
-#endif // ENABLE_ASSERTS
-
-#ifdef UNITTESTS
-#define reportFalse(val) failFalse(val)
-#define reportTrue(val) failTrue(val)
-#define reportAlways(...) failAlways(__VA_ARGS__)
-#define returnFalseV(val) returnFailFalseV(val)
-#define returnTrueV(val) returnFailTrueV(val)
-#define returnFalse(ret, val) returnFailFalse(ret, val)
-#define returnTrue(ret, val) returnFailTrue(ret, val)
-#define returnNullptrV(val) returnFailNullptrV(val)
-#define returnNullptr(ret, val) returnFailNullptr(ret, val)
-#else // UNITTESTS
-#define reportFalse(val) reportFalseReal(val)
-#define reportTrue(val) reportTrueReal(val)
-#define reportAlways(...) reportAlwaysReal(__VA_ARGS__)
-#define returnFalseV(val) returnFalseVReal(val)
-#define returnTrueV(val) returnTrueVReal(val)
-#define returnFalse(ret, val) returnFalseReal(ret, val)
-#define returnTrue(ret, val) returnTrueReal(ret, val)
-#define returnNullptrV(val) returnNullptrVReal(val)
-#define returnNullptr(ret, val) returnNullptrReal(ret, val)
-#endif // UNITTESTS
-
-#endif // UTILS_CHECKUTILS_H
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp
deleted file mode 100644
index 3896c2b6b..000000000
--- a/src/utils/copynpaste.cpp
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2001-2010 Wormux Team
- * 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/>.
- */
-
-/*
- * IMPORTANT!
- *
- * This code was taken from Wormux svn trunk at Feb 25 2010. Please don't
- * make any unnecessary modifications, and try to sync up modifications
- * when possible.
- */
-
-#ifdef _MSC_VER
-# include "msvc/config.h"
-#elif defined(HAVE_CONFIG_H)
-#include "config.h"
-#endif // _MSC_VER
-
-#include "utils/copynpaste.h"
-
-#include "debug.h"
-
-#ifdef USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_clipboard.h>
-PRAGMA48(GCC diagnostic pop)
-
-#else // USE_SDL2
-
-#if defined(__APPLE__)
-#ifdef Status
-#undef Status
-#endif // Status
-#include <Carbon/Carbon.h>
-#elif defined USE_X11
-#include "render/graphics.h"
-
-#include "utils/sdlhelper.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-#include <unistd.h>
-#elif defined __native_client__
-#include "utils/naclmessages.h"
-#elif defined WIN32
-#include "utils/cast.h"
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // defined(__APPLE__)
-
-#endif // USE_SDL2
-
-#ifdef USE_SDL2
-bool retrieveBuffer(std::string& text, size_t& pos)
-{
- char *buf = SDL_GetClipboardText();
- if (buf)
- {
- text.insert(pos, buf);
- pos += strlen(buf);
- SDL_free(buf);
- return true;
- }
- return false;
-}
-
-bool sendBuffer(const std::string &restrict text)
-{
- return !SDL_SetClipboardText(text.c_str());
-}
-
-#else // USE_SDL2
-
-#ifdef WIN32
-bool retrieveBuffer(std::string& text, size_t& pos)
-{
- bool ret = false;
-
- if (!OpenClipboard(nullptr))
- return false;
-
- HANDLE h = GetClipboardData(CF_UNICODETEXT);
- if (h)
- {
- LPCWSTR data = static_cast<LPCWSTR>(GlobalLock(h));
-
- if (data)
- {
- const size_t len = WideCharToMultiByte(CP_UTF8, 0, data, -1,
- nullptr, 0, nullptr, nullptr);
- if (len > 0)
- {
- // Convert from UTF-16 to UTF-8
- void *temp = calloc(len, 1);
- if (WideCharToMultiByte(CP_UTF8, 0, data, -1,
- static_cast<LPSTR>(temp), len, nullptr, nullptr))
- {
- text.insert(pos, static_cast<char*>(temp));
- pos += len - 1;
- }
- free(temp);
- ret = true;
- }
- }
- GlobalUnlock(h);
- }
- else
- {
- h = GetClipboardData(CF_TEXT);
-
- if (h)
- {
- const char *const data = static_cast<char*>(GlobalLock(h));
- if (data)
- {
- text.insert(pos, data);
- pos += strlen(data);
- ret = true;
- }
- GlobalUnlock(h);
- }
- }
-
- CloseClipboard();
- return ret;
-}
-
-bool sendBuffer(const std::string &restrict text)
-{
- const int wCharsLen = MultiByteToWideChar(CP_UTF8,
- 0, text.c_str(), -1, nullptr, 0);
- if (!wCharsLen)
- return false;
-
- HANDLE h = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
- CAST_SIZE(wCharsLen) * sizeof(WCHAR));
- WCHAR *const out = static_cast<WCHAR*>(GlobalLock(h));
-
- MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, out, wCharsLen);
-
- if (!OpenClipboard(nullptr))
- {
- GlobalUnlock(h);
- GlobalFree(h);
- return false;
- }
- GlobalUnlock(h);
- EmptyClipboard();
- if (!SetClipboardData(CF_UNICODETEXT, out))
- {
- GlobalFree(h);
- CloseClipboard();
- return false;
- }
- GlobalFree(h);
- CloseClipboard();
-
- return true;
-}
-
-#elif defined(__APPLE__)
-
-// Sorry for the very long code, all nicer OS X APIs are coded in
-// Objective C and not C!
-// Also it does very thorough error handling
-bool getDataFromPasteboard(PasteboardRef inPasteboard,
- char* flavorText /* out */,
- const int bufSize)
-{
- ItemCount itemCount;
- PasteboardSyncFlags syncFlags = PasteboardSynchronize(inPasteboard);
- OSStatus err = PasteboardGetItemCount(inPasteboard, &itemCount);
- require_noerr(err, CantGetPasteboardItemCount);
-
- for (UInt32 itemIndex = 1; itemIndex <= itemCount; itemIndex ++)
- {
- PasteboardItemID itemID;
- CFArrayRef flavorTypeArray;
- CFIndex flavorCount;
-
- err = PasteboardGetItemIdentifier(inPasteboard, itemIndex, &itemID);
- require_noerr(err, CantGetPasteboardItemIdentifier);
-
- err = PasteboardCopyItemFlavors(inPasteboard,
- itemID, &flavorTypeArray);
- require_noerr(err, CantCopyPasteboardItemFlavors);
-
- flavorCount = CFArrayGetCount(flavorTypeArray);
-
- for (CFIndex flavorIndex = 0; flavorIndex < flavorCount;
- flavorIndex ++)
- {
- CFStringRef flavorType = (CFStringRef)CFArrayGetValueAtIndex(
- flavorTypeArray, flavorIndex);
-
- // we're only interested by text...
- if (UTTypeConformsTo(flavorType, CFSTR("public.utf8-plain-text")))
- {
- CFDataRef flavorData;
- err = PasteboardCopyItemFlavorData(inPasteboard, itemID,
- flavorType, &flavorData);
- require_noerr(err, CantCopyFlavorData);
- CFIndex flavorDataSize = CFDataGetLength(flavorData);
- flavorDataSize = (flavorDataSize<254) ? flavorDataSize : 254;
-
- if (flavorDataSize + 2 > bufSize)
- {
- fprintf(stderr,
- "Cannot copy clipboard, contents is too big!\n");
- return false;
- }
-
- for (short dataIndex = 0; dataIndex <= flavorDataSize;
- dataIndex ++)
- {
- signed char byte = *(CFDataGetBytePtr(
- flavorData) + dataIndex);
- flavorText[dataIndex] = byte;
- }
-
- flavorText[flavorDataSize] = '\0';
- flavorText[flavorDataSize + 1] = '\n';
-
- CFRelease(flavorData);
- return true;
- }
-
- continue;
-CantCopyFlavorData:
- fprintf(stderr, "Cannot copy clipboard, CantCopyFlavorData!\n");
- }
-
- CFRelease(flavorTypeArray);
- continue;
-
-CantCopyPasteboardItemFlavors:
- fprintf(stderr,
- "Cannot copy clipboard, CantCopyPasteboardItemFlavors!\n");
- continue;
-CantGetPasteboardItemIdentifier:
- fprintf(stderr,
- "Cannot copy clipboard, CantGetPasteboardItemIdentifier!\n");
- continue;
- }
- fprintf(stderr,
- "Cannot copy clipboard, found no acceptable flavour!\n");
- return false;
-
-CantGetPasteboardItemCount:
- fprintf(stderr, "Cannot copy clipboard, CantGetPasteboardItemCount!\n");
- return false;
-}
-
-bool getClipBoard(char* text /* out */, const int bufSize)
-{
- PasteboardRef theClipboard;
- OSStatus err = PasteboardCreate(kPasteboardClipboard, &theClipboard);
- require_noerr(err, PasteboardCreateFailed);
-
- if (!getDataFromPasteboard(theClipboard, text, bufSize))
- {
- fprintf(stderr,
- "Cannot copy clipboard, getDataFromPasteboardFailed!\n");
- return false;
- }
-
- CFRelease(theClipboard);
-
- return true;
-
- // ---- error handling
-PasteboardCreateFailed:
- fprintf(stderr, "Cannot copy clipboard, PasteboardCreateFailed!\n");
- CFRelease(theClipboard);
- return false;
-}
-
-bool retrieveBuffer(std::string& text, size_t& pos)
-{
- const int bufSize = 512;
- char buffer[bufSize + 1];
-
- if (getClipBoard(buffer, bufSize))
- {
- text = buffer;
- pos += strlen(buffer);
- return true;
- }
- else
- {
- return false;
- }
-}
-
-bool sendBuffer(const std::string &restrict text)
-{
- return false;
-}
-
-#elif defined USE_X11
-
-static char* getSelection2(Display *const dpy, Window us, Atom selection,
- Atom request_target)
-{
- int max_events = 50;
- Window owner = XGetSelectionOwner(dpy, selection);
-
- if (owner == None)
- return nullptr;
-
- XConvertSelection(dpy, selection, request_target,
- XA_PRIMARY, us, CurrentTime);
- XFlush(dpy);
-
- while (max_events --)
- {
- XEvent e;
-
- XNextEvent(dpy, &e);
- if (e.type == SelectionNotify)
- {
- if (e.xselection.property == None)
- return nullptr;
-
- long unsigned len, left, dummy;
- int format;
- Atom type;
- unsigned char *data = nullptr;
-
- int ret = XGetWindowProperty(dpy, us, e.xselection.property, 0, 0,
- False, AnyPropertyType, &type, &format, &len, &left, &data);
- if (left < 1)
- {
- if (ret == Success)
- XFree(data);
- return nullptr;
- }
-
- ret = XGetWindowProperty(dpy, us, e.xselection.property, 0,
- left, False, AnyPropertyType, &type, &format, &len,
- &dummy, &data);
-
- if (ret != Success)
- return nullptr;
-
- return reinterpret_cast<char*>(data);
- }
- }
- return nullptr;
-}
-
-static Atom requestAtom;
-
-static char* getSelection(Display *const dpy, Window us, Atom selection)
-{
- char *data = nullptr;
- if (requestAtom != None)
- data = getSelection2(dpy, us, selection, requestAtom);
- if (!data)
- data = getSelection2(dpy, us, selection, XA_STRING);
- return data;
-}
-
-bool retrieveBuffer(std::string& text, size_t& pos)
-{
- SDL_SysWMinfo info;
-
- SDL_VERSION(&info.version);
- if (SDL::getWindowWMInfo(mainGraphics->getWindow(), &info))
- {
- Display *const dpy = info.info.x11.display;
- Window us = info.info.x11.window;
-
- requestAtom = XInternAtom(dpy, "UTF8_STRING", true);
- char *data = getSelection(dpy, us, XA_PRIMARY);
- if (!data)
- data = getSelection(dpy, us, XA_SECONDARY);
- if (!data)
- {
- Atom XA_CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", 0);
- if (XA_CLIPBOARD != None)
- data = getSelection(dpy, us, XA_CLIPBOARD);
- }
-
- if (data)
- {
- // check cursor position
- const size_t sz = text.size();
- if (pos > sz)
- pos = sz;
-
- text.insert(pos, data);
- pos += strlen(data);
- XFree(data);
-
- return true;
- }
- }
- return false;
-}
-
-static bool runxsel(const std::string &text, const char *p1,
- const char *p2 = nullptr);
-
-bool sendBuffer(const std::string &restrict text)
-{
- runxsel(text, "-i");
- runxsel(text, "-b", "-i");
- return true;
-}
-
-static bool runxsel(const std::string &text, const char *p1, const char *p2)
-{
- pid_t pid;
- int fd[2];
-
- if (pipe(fd))
- return false;
-
- if ((pid = fork()) == -1)
- { // fork error
- return false;
- }
- else if (!pid)
- { // child
- close(fd[1]);
-
- if (fd[0] != STDIN_FILENO)
- {
- if (dup2(fd[0], STDIN_FILENO) != STDIN_FILENO)
- {
- close(fd[0]);
- _exit(1);
- }
- close(fd[0]);
- }
-
- const char *const xselPath =
-#if defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
- "/usr/local/bin/xsel";
-#else // defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
- "/usr/bin/xsel";
-#endif // defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
-
- if (p2)
- {
- execl(xselPath, "xsel", p1, p2,
- static_cast<char *>(nullptr));
- }
- else
- {
- execl(xselPath, "xsel", p1,
- static_cast<char *>(nullptr));
- }
-
- _exit(1);
- }
-
- // parent
- close(fd[0]);
- const size_t len = text.length();
- if (write(fd[1], text.c_str(), len) != static_cast<ssize_t>(len))
- {
- close(fd[1]);
- return false;
- }
- close(fd[1]);
- return true;
-}
-
-#elif defined __native_client__
-
-bool retrieveBuffer(std::string& text, size_t& pos)
-{
- NaclMessageHandle *handle = naclRegisterMessageHandler("clipboard-paste");
- naclPostMessage("clipboard-paste", "");
- std::string response = naclWaitForMessage(handle);
- text.insert(pos, response);
- pos += response.size();
- return true;
-}
-
-bool sendBuffer(const std::string &restrict text)
-{
- naclPostMessage("clipboard-copy", text);
- return true;
-}
-#else // WIN32
-
-bool retrieveBuffer(std::string &text A_UNUSED, size_t &pos A_UNUSED)
-{
- return false;
-}
-
-bool sendBuffer(const std::string &restrict text A_UNUSED)
-{
- return false;
-}
-#endif // WIN32
-#endif // USE_SDL2
diff --git a/src/utils/copynpaste.h b/src/utils/copynpaste.h
deleted file mode 100644
index 73e086160..000000000
--- a/src/utils/copynpaste.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2001-2010 Wormux Team
- * 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 UTILS_COPYNPASTE_H
-#define UTILS_COPYNPASTE_H
-
-#include <string>
-
-#include "localconsts.h"
-
-/**
- * Attempts to retrieve text from the clipboard buffer and inserts it in
- * \a text at position. The characters are encoded in utf-8.
- *
- * Implemented for Windows, X11 and Mac OS X.
- *
- * @return <code>true</code> when successful or <code>false</code> when there
- * was a problem retrieving the clipboard buffer.
- */
-bool retrieveBuffer(std::string& text, size_t& pos) A_WARN_UNUSED;
-
-bool sendBuffer(const std::string &restrict text);
-
-#endif // UTILS_COPYNPASTE_H
diff --git a/src/utils/cpu.cpp b/src/utils/cpu.cpp
deleted file mode 100644
index ef6a419b6..000000000
--- a/src/utils/cpu.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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/>.
- */
-
-#include "utils/cpu.h"
-
-#include "logger.h"
-
-#if (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__) \
- && (GCC_VERSION >= 40800) && !defined(ANDROID)
-// nothing
-#elif defined(__linux__) || defined(__linux)
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-#endif // (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__)
- // && (GCC_VERSION >= 40800) && !defined(ANDROID)
-
-#ifdef USE_SDL2
-#include <SDL_cpuinfo.h>
-#endif // USE_SDL2
-
-#include "debug.h"
-
-namespace
-{
- uint32_t mCpuFlags;
-} // namespace
-
-void Cpu::detect()
-{
-#if (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__) \
- && (GCC_VERSION >= 40800) && !defined(ANDROID)
- __builtin_cpu_init();
- if (__builtin_cpu_supports ("mmx"))
- mCpuFlags |= FEATURE_MMX;
- if (__builtin_cpu_supports ("sse"))
- mCpuFlags |= FEATURE_SSE;
- if (__builtin_cpu_supports ("sse2"))
- mCpuFlags |= FEATURE_SSE2;
- if (__builtin_cpu_supports ("ssse3"))
- mCpuFlags |= FEATURE_SSSE3;
- if (__builtin_cpu_supports ("sse4.1"))
- mCpuFlags |= FEATURE_SSE4;
- if (__builtin_cpu_supports ("sse4.2"))
- mCpuFlags |= FEATURE_SSE42;
- if (__builtin_cpu_supports ("avx"))
- mCpuFlags |= FEATURE_AVX;
- if (__builtin_cpu_supports ("avx2"))
- mCpuFlags |= FEATURE_AVX2;
- printFlags();
-#elif defined(__linux__) || defined(__linux)
- FILE *file = fopen("/proc/cpuinfo", "r");
- char buf[1001];
- if (file == nullptr)
- return;
- while (fgets(buf, 1000, file) != nullptr)
- {
- std::string str = buf;
- if (findFirst(str, "flags"))
- {
- size_t idx = str.find(':');
- if (idx == std::string::npos)
- continue;
- str = str.substr(idx + 1);
- trim(str);
- StringVect vect;
- splitToStringVector(vect, str, ' ');
- FOR_EACH (StringVectCIter, it, vect)
- {
- const std::string &flag = *it;
- if (flag == "mmx")
- mCpuFlags |= FEATURE_MMX;
- else if (flag == "sse")
- mCpuFlags |= FEATURE_SSE;
- else if (flag == "sse2")
- mCpuFlags |= FEATURE_SSE2;
- else if (flag == "ssse3")
- mCpuFlags |= FEATURE_SSSE3;
- else if (flag == "sse4_1")
- mCpuFlags |= FEATURE_SSE4;
- else if (flag == "sse4_2")
- mCpuFlags |= FEATURE_SSE42;
- else if (flag == "avx")
- mCpuFlags |= FEATURE_AVX;
- else if (flag == "avx2")
- mCpuFlags |= FEATURE_AVX2;
- }
- fclose(file);
- printFlags();
- return;
- }
- }
- fclose(file);
- if (logger != nullptr)
- logger->log("cpu features was not detected");
-#else // OTHER
-
-#ifdef USE_SDL2
- if (SDL_HasMMX())
- mCpuFlags |= FEATURE_MMX;
- if (SDL_HasSSE())
- mCpuFlags |= FEATURE_SSE;
- if (SDL_HasSSE2())
- mCpuFlags |= FEATURE_SSE2;
- if (SDL_HasSSE3())
- mCpuFlags |= FEATURE_SSSE3;
- if (SDL_HasSSE41())
- mCpuFlags |= FEATURE_SSE4;
- if (SDL_HasSSE42())
- mCpuFlags |= FEATURE_SSE42;
-
-#if SDL_VERSION_ATLEAST(2, 0, 2)
- if (SDL_HasAVX())
- mCpuFlags |= FEATURE_AVX;
-#endif // SDL_VERSION_ATLEAST(2, 0, 2)
-#if SDL_VERSION_ATLEAST(2, 0, 4)
- if (SDL_HasAVX2())
- mCpuFlags |= FEATURE_AVX2;
-#endif // SDL_VERSION_ATLEAST(2, 0, 4)
-
- printFlags();
-#else // USE_SDL2
-
- if (logger)
- logger->log("cpu features not supported");
-#endif // USE_SDL2
-#endif // (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__)
- // && (GCC_VERSION >= 40800) && !defined(ANDROID)
-
-#if SDL_VERSION_ATLEAST(2, 0, 1)
- logger->log("System ram size: %d", SDL_GetSystemRAM());
-#endif // SDL_VERSION_ATLEAST(2, 0, 1)
-}
-
-void Cpu::printFlags()
-{
- if (logger == nullptr)
- return;
- std::string str("CPU features:");
- if ((mCpuFlags & FEATURE_MMX) != 0u)
- str.append(" mmx");
- if ((mCpuFlags & FEATURE_SSE) != 0u)
- str.append(" sse");
- if ((mCpuFlags & FEATURE_SSE2) != 0u)
- str.append(" sse2");
- if ((mCpuFlags & FEATURE_SSSE3) != 0u)
- str.append(" ssse3");
- if ((mCpuFlags & FEATURE_SSE4) != 0u)
- str.append(" sse4");
- if ((mCpuFlags & FEATURE_SSE42) != 0u)
- str.append(" sse4_2");
- if ((mCpuFlags & FEATURE_AVX) != 0u)
- str.append(" avx");
- if ((mCpuFlags & FEATURE_AVX2) != 0u)
- str.append(" avx2");
- logger->log(str);
-}
-
-uint32_t Cpu::getFlags()
-{
- return mCpuFlags;
-}
diff --git a/src/utils/cpu.h b/src/utils/cpu.h
deleted file mode 100644
index 8be6ccbc3..000000000
--- a/src/utils/cpu.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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 UTILS_CPU_H
-#define UTILS_CPU_H
-
-#include "localconsts.h"
-
-namespace Cpu
-{
- enum
- {
- FEATURE_EMPTY = 0,
- FEATURE_MMX = 1,
- FEATURE_SSE = 2,
- FEATURE_SSE2 = 4,
- FEATURE_SSSE3 = 8,
- FEATURE_SSE4 = 16,
- FEATURE_SSE42 = 32,
- FEATURE_AVX = 64,
- FEATURE_AVX2 = 128
- };
-
- void detect();
-
- void printFlags();
-
- uint32_t getFlags();
-} // namespace Cpu
-
-#endif // UTILS_CPU_H
diff --git a/src/utils/delete2.h b/src/utils/delete2.h
deleted file mode 100644
index 4c6b4c6a6..000000000
--- a/src/utils/delete2.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-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 UTILS_DELETE2_H
-#define UTILS_DELETE2_H
-
-#define delete2(var) \
- {\
- delete var;\
- var = nullptr;\
- }
-
-#define delete2Arr(var) \
- {\
- delete []var;\
- var = nullptr;\
- }
-
-#endif // UTILS_DELETE2_H
diff --git a/src/utils/dtor.h b/src/utils/dtor.h
deleted file mode 100644
index 21d0429e9..000000000
--- a/src/utils/dtor.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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 UTILS_DTOR_H
-#define UTILS_DTOR_H
-
-#include <algorithm>
-#include <functional>
-
-#include "localconsts.h"
-
-template<typename T>
-struct dtor final : public std::unary_function <T, void>
-{
- A_DEFAULT_COPY(dtor)
-
- void operator()(T &ptr)
- { delete ptr; }
-};
-
-template<typename T1, typename T2>
-struct dtor<std::pair<T1, T2> > :
-public std::unary_function <std::pair<T1, T2>, void>
-{
- void operator()(std::pair<T1, T2> &pair)
- { delete pair.second; }
-};
-
-template<class Cont>
-inline dtor<typename Cont::value_type> make_dtor(Cont const &d A_UNUSED)
-{
- return dtor<typename Cont::value_type>();
-}
-
-template<typename Container>
-inline void delete_all(Container &c)
-{
- std::for_each(c.begin(), c.end(), make_dtor(c));
-}
-
-#endif // UTILS_DTOR_H
diff --git a/src/utils/dumplibs.cpp b/src/utils/dumplibs.cpp
deleted file mode 100644
index 420ef62ce..000000000
--- a/src/utils/dumplibs.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 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/>.
- */
-
-#include "utils/dumplibs.h"
-
-#include "logger.h"
-
-#include "utils/stringutils.h"
-
-#include <png.h>
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_image.h>
-#include <SDL_mixer.h>
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
-#include <SDL_net.h>
-PRAGMACLANG6GCC(GCC diagnostic pop)
-#include <SDL_ttf.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include <zlib.h>
-
-#include <curl/curl.h>
-
-#ifdef ENABLE_LIBXML
-#include <libxml/xmlversion.h>
-#endif // ENABLE_LIBXML
-
-#include "debug.h"
-
-#define dumpCompiledSdlVersion(text, prefix) \
- logger->log(" " text ": %d.%d.%d", \
- prefix##_MAJOR_VERSION, \
- prefix##_MINOR_VERSION, \
- prefix##_PATCHLEVEL)
-
-#define sdlVersionJoin(prefix) \
- prefix##_MAJOR_VERSION, \
- prefix##_MINOR_VERSION, \
- prefix##_PATCHLEVEL
-
-static void dumpLinkedSdlVersion(const char *const text,
- const SDL_version *const version)
-{
- if (version != nullptr)
- {
- logger->log(" %s: %d.%d.%d",
- text,
- version->major,
- version->minor,
- version->patch);
- }
-}
-
-static void compareVersions(const char *const libName,
- const char *const buildVersion,
- const char *const linkedVersion)
-{
- if (strcmp(buildVersion, linkedVersion) != 0)
- {
- logger->assertLog(
- "%s: compiled and linked versions not same: %s vs %s",
- libName,
- buildVersion,
- linkedVersion);
- }
-}
-
-static void compareSDLVersions(const char *const libName,
- const int major,
- const int minor,
- const int patch,
- const SDL_version *const linkedVersion)
-{
- const std::string buildVersionStr = strprintf("%d.%d.%d",
- major,
- minor,
- patch);
- const std::string linkedVersionStr = strprintf("%d.%d.%d",
- linkedVersion->major,
- linkedVersion->minor,
- linkedVersion->patch);
- if (buildVersionStr != linkedVersionStr)
- {
- logger->assertLog(
- "%s: compiled and linked versions not same: %s vs %s",
- libName,
- buildVersionStr.c_str(),
- linkedVersionStr.c_str());
- }
-}
-
-void dumpLibs()
-{
- logger->log("Compiled with:");
- logger->log(" zLib: %s", ZLIB_VERSION);
-#ifdef ENABLE_LIBXML
- logger->log(" libxml2: %s", LIBXML_DOTTED_VERSION);
-#endif // ENABLE_LIBXML
-
- logger->log(" libcurl: %s", LIBCURL_VERSION);
- logger->log(" libpng: %s", PNG_LIBPNG_VER_STRING);
-
- dumpCompiledSdlVersion("SDL", SDL);
- dumpCompiledSdlVersion("SDL_net", SDL_NET);
- dumpCompiledSdlVersion("SDL_image", SDL_IMAGE);
- dumpCompiledSdlVersion("SDL_mixer", SDL_MIXER);
- dumpCompiledSdlVersion("SDL_ttf", SDL_TTF);
-
- logger->log("Linked with:");
-#if ZLIB_VERNUM >= 0x1020
- logger->log(" zLib: %s", zlibVersion());
-#endif // ZLIB_VERNUM >= 0x1020
-#ifdef LIBXML_TEST_VERSION
- LIBXML_TEST_VERSION
-#endif // LIBXML_TEST_VERSION
-#ifdef USE_SDL2
- SDL_version sdlVersion;
- sdlVersion.major = 0;
- sdlVersion.minor = 0;
- sdlVersion.patch = 0;
- SDL_GetVersion(&sdlVersion);
- dumpLinkedSdlVersion("SDL", &sdlVersion);
-#else // USE_SDL2
- dumpLinkedSdlVersion("SDL", SDL_Linked_Version());
-#endif // USE_SDL2
- dumpLinkedSdlVersion("SDL_net", SDLNet_Linked_Version());
- dumpLinkedSdlVersion("SDL_image", IMG_Linked_Version());
- dumpLinkedSdlVersion("SDL_mixer", Mix_Linked_Version());
- dumpLinkedSdlVersion("SDL_ttf", TTF_Linked_Version());
-
- compareVersions("zLib", ZLIB_VERSION, zlibVersion());
-#ifdef USE_SDL2
- compareSDLVersions("SDL", sdlVersionJoin(SDL), &sdlVersion);
-#else // USE_SDL2
- compareSDLVersions("SDL", sdlVersionJoin(SDL), SDL_Linked_Version());
-#endif // USE_SDL2
-
- compareSDLVersions("SDL_net",
- sdlVersionJoin(SDL_NET),
- SDLNet_Linked_Version());
- compareSDLVersions("SDL_image",
- sdlVersionJoin(SDL_IMAGE),
- IMG_Linked_Version());
- compareSDLVersions("SDL_mixer",
- sdlVersionJoin(SDL_MIXER),
- Mix_Linked_Version());
- compareSDLVersions("SDL_ttf",
- sdlVersionJoin(SDL_TTF),
- TTF_Linked_Version());
-}
diff --git a/src/utils/dumplibs.h b/src/utils/dumplibs.h
deleted file mode 100644
index 1013026f1..000000000
--- a/src/utils/dumplibs.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 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 UTILS_DUMPLIBS_H
-#define UTILS_DUMPLIBS_H
-
-#include "localconsts.h"
-
-void dumpLibs();
-
-#endif // UTILS_DUMPLIBS_H
diff --git a/src/utils/dumpsizes.cpp b/src/utils/dumpsizes.cpp
deleted file mode 100644
index 86f89b6cd..000000000
--- a/src/utils/dumpsizes.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 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/>.
- */
-
-#include "utils/dumpsizes.h"
-
-#include "logger.h"
-
-#include "utils/cast.h"
-
-#include "debug.h"
-
-#define dumpSize(str) \
- logger->log(" sizeof("#str"): %d", CAST_S32(sizeof(str)));
-
-void dumpSizes()
-{
- logger->log("Type sizes:");
- dumpSize(char);
- dumpSize(short);
- dumpSize(int);
- dumpSize(long);
- dumpSize(size_t);
-}
diff --git a/src/utils/dumpsizes.h b/src/utils/dumpsizes.h
deleted file mode 100644
index c7729ac14..000000000
--- a/src/utils/dumpsizes.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 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 UTILS_DUMPSIZES_H
-#define UTILS_DUMPSIZES_H
-
-#include "localconsts.h"
-
-void dumpSizes();
-
-#endif // UTILS_DUMPSIZES_H
diff --git a/src/utils/env.cpp b/src/utils/env.cpp
deleted file mode 100644
index e8808e238..000000000
--- a/src/utils/env.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * The ManaPlus Client
- * 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/>.
- */
-
-#include "utils/env.h"
-
-#include "configuration.h"
-#include "logger.h"
-#include "settings.h"
-
-#include "debug.h"
-
-void updateEnv()
-{
-#if defined(WIN32) || defined(__APPLE__)
- if (config.getBoolValue("centerwindow"))
- setEnv("SDL_VIDEO_CENTERED", "1");
- else
- setEnv("SDL_VIDEO_CENTERED", "0");
-#endif // defined(WIN32) || defined(__APPLE__)
-
-#ifndef WIN32
- const int vsync = settings.options.test.empty()
- ? config.getIntValue("vsync") : 1;
- // __GL_SYNC_TO_VBLANK is nvidia variable.
- // vblank_mode is MESA variable.
- switch (vsync)
- {
- case 1:
- setEnv("__GL_SYNC_TO_VBLANK", "0");
- setEnv("vblank_mode", "0");
- break;
- case 2:
- setEnv("__GL_SYNC_TO_VBLANK", "1");
- setEnv("vblank_mode", "2");
- break;
- default:
- break;
- }
-#endif // WIN32
-}
-
-void setEnv(const char *const name, const char *const value)
-{
- if ((name == nullptr) || (value == nullptr))
- return;
-#ifdef WIN32
- if (putenv(const_cast<char*>((std::string(name)
- + "=" + value).c_str())))
-#else // WIN32
-
- if (setenv(name, value, 1) != 0)
-#endif // WIN32
- {
- logger->log("setenv failed: %s=%s", name, value);
- }
-}
diff --git a/src/utils/env.h b/src/utils/env.h
deleted file mode 100644
index 8f42448f8..000000000
--- a/src/utils/env.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_ENV_H
-#define UTILS_ENV_H
-
-#include "localconsts.h"
-
-void setEnv(const char *const name, const char *const value);
-
-void updateEnv();
-
-#endif // UTILS_ENV_H
diff --git a/src/utils/foreach.h b/src/utils/foreach.h
deleted file mode 100644
index d3212795f..000000000
--- a/src/utils/foreach.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_FOREACH_H
-#define UTILS_FOREACH_H
-
-#define FOR_EACH(type, iter, array) for (type iter = array.begin(), \
- iter##_fend = array.end(); iter != iter##_fend; ++ iter)
-
-#define FOR_EACHR(type, iter, array) for (type iter = array.rbegin(), \
- iter##_fend = array.rend(); iter != iter##_fend; ++ iter)
-
-#define FOR_EACHP(type, iter, array) for (type iter = array->begin(), \
- iter##_fend = array->end(); iter != iter##_fend; ++ iter)
-
-#define FOR_EACH_SAFE(type, iter, array) for (type iter = array.begin(); \
- iter != array.end(); ++ iter)
-
-#endif // UTILS_FOREACH_H
diff --git a/src/utils/fuzzer.cpp b/src/utils/fuzzer.cpp
deleted file mode 100644
index d11d61de3..000000000
--- a/src/utils/fuzzer.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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/>.
- */
-
-#include "utils/fuzzer.h"
-
-#ifdef USE_FUZZER
-
-#include "client.h"
-#include "logger.h"
-#include "settings.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace
-{
- Logger *fuzz = nullptr;
- int fuzzRand = 50;
-} // namespace
-
-void Fuzzer::init()
-{
- fuzz = new Logger;
- fuzz->setLogFile(pathJoin(settings.localDataDir, "fuzzer.log"));
- unsigned int sr = time(nullptr);
-
- fuzz->log("Srand: %u", sr);
- srand(sr);
-}
-
-bool Fuzzer::conditionTerminate(const char *const name)
-{
- if ((rand() % 100) <= fuzzRand)
- {
- fuzz->log("deleted: %s", name);
- return true;
- }
- fuzz->log("passed: %s", name);
- return false;
-}
-
-#endif // USE_FUZZER
diff --git a/src/utils/fuzzer.h b/src/utils/fuzzer.h
deleted file mode 100644
index d43dcc294..000000000
--- a/src/utils/fuzzer.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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 UTILS_FUZZER_H
-#define UTILS_FUZZER_H
-
-#include "localconsts.h"
-
-#ifdef USE_FUZZER
-namespace Fuzzer
-{
- void init();
- bool conditionTerminate(const char *const name);
-} // namespace Fuzzer
-
-#endif // USE_FUZZER
-#endif // UTILS_FUZZER_H
diff --git a/src/utils/gettext.h b/src/utils/gettext.h
deleted file mode 100644
index 2265da585..000000000
--- a/src/utils/gettext.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-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 UTILS_GETTEXT_H
-#define UTILS_GETTEXT_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif // HAVE_CONFIG_H
-
-#ifdef ENABLE_NLS
-
-#include <libintl.h>
-
-#define _(s) (const_cast <char*>(gettext(s)))
-#define N_(s) (const_cast <char*>(s))
-
-#elif defined(ENABLE_CUSTOMNLS) // ENABLE_NLS
-
-#include "utils/translation/podict.h"
-
-#define gettext(s) const_cast <char*>(mainTranslator->getChar(s))
-#define _(s) const_cast <char*>(mainTranslator->getChar(s))
-#define N_(s) (const_cast <char*>(s))
-#define ngettext(s1, s2, i1) const_cast <char*>(mainTranslator->getChar(s1))
-
-#else // ENABLE_NLS
-
-#define gettext(s) (const_cast <char*>(s))
-#define _(s) (const_cast <char*>(s))
-#define N_(s) (const_cast <char*>(s))
-#define ngettext(s1, s2, i1) (const_cast <char*>(s1))
-
-#endif // ENABLE_NLS
-
-#endif // UTILS_GETTEXT_H
diff --git a/src/utils/gettexthelper.cpp b/src/utils/gettexthelper.cpp
deleted file mode 100644
index f7f02ba32..000000000
--- a/src/utils/gettexthelper.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * The ManaPlus Client
- * 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/>.
- */
-
-#include "utils/gettexthelper.h"
-
-#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
-#include "configuration.h"
-#endif // defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
-
-#ifdef ENABLE_NLS
-#include "client.h"
-#include "logger.h"
-
-#include "fs/virtfs/fs.h"
-
-#include <libintl.h>
-
-#ifdef WIN32
-#include <string>
-extern "C" char const *_nl_locale_name_default(void);
-#endif // WIN32
-#elif defined(ENABLE_CUSTOMNLS)
-#include "utils/translation/podict.h"
-#ifdef __native_client__
-#include "utils/naclmessages.h"
-#endif // __native_client__
-#endif // ENABLE_NLS
-
-#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS) && !defined(WIN32)
-#include "utils/env.h"
-#endif // defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS) && !defined(WIN32)
-
-#include "debug.h"
-
-#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
-static std::string setLangEnv()
-{
- std::string lang = config.getStringValue("lang");
-#if defined(ENABLE_NLS) && defined(WIN32)
- if (lang.empty())
- lang = std::string(_nl_locale_name_default());
-#elif defined(ENABLE_CUSTOMNLS) && defined(__native_client__)
- if (lang.empty())
- {
- NaclMessageHandle *handle = naclRegisterMessageHandler(
- "get-uilanguage");
- naclPostMessage("get-uilanguage", "");
- lang = naclWaitForMessage(handle);
- }
-#endif // defined(ENABLE_NLS) && defined(WIN32)
-
- if (!lang.empty())
- {
-#ifdef WIN32
- putenv(const_cast<char*>(("LANG=" + lang).c_str()));
- putenv(const_cast<char*>(("LANGUAGE=" + lang).c_str()));
-#else // WIN32
-
- if (!lang.empty())
- {
- setEnv("LANG", lang.c_str());
- setEnv("LANGUAGE", lang.c_str());
- }
-#endif // WIN32
- }
-
- return lang;
-}
-#endif // defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
-
-void GettextHelper::initLang()
-{
-#ifdef ENABLE_NLS
- const std::string lang = setLangEnv();
-#ifdef WIN32
- // mingw doesn't like LOCALEDIR to be defined for some reason
- if (lang != "C")
- bindTextDomain("translations/");
-#else // WIN32
-#ifdef ANDROID
-#ifdef USE_SDL2
- bindTextDomain((std::string(getenv("APPDIR")).append("/locale")).c_str());
-#else // USE_SDL2
-
- bindTextDomain((std::string(VirtFs::getBaseDir()).append(
- "/locale")).c_str());
-#endif // USE_SDL2
-#else // ANDROID
-#ifdef ENABLE_PORTABLE
- bindTextDomain((std::string(VirtFs::getBaseDir()).append(
- "../locale/")).c_str());
-#else // ENABLE_PORTABLE
-#ifdef __APPLE__
- bindTextDomain((std::string(VirtFs::getBaseDir())
- .append("ManaPlus.app/Contents/Resources/locale/")).c_str());
-#else // __APPLE__
-
- bindTextDomain(LOCALEDIR);
-#endif // __APPLE__
-#endif // ENABLE_PORTABLE
-#endif // ANDROID
-#endif // WIN32
-
- char *locale = setlocale(LC_MESSAGES, lang.c_str());
- if (locale)
- {
- logger->log("locale: %s", locale);
- }
- else
- {
- locale = setlocale(LC_MESSAGES, (lang + ".utf8").c_str());
- if (locale)
- logger->log("locale: %s", locale);
- else
- logger->log("locale empty");
- }
- bind_textdomain_codeset("manaplus", "UTF-8");
- textdomain("manaplus");
-#elif defined(ENABLE_CUSTOMNLS)
- mainTranslator = new PoDict("en");
- setLangEnv();
-#endif // ENABLE_NLS
-}
-
-#ifdef ENABLE_NLS
-void GettextHelper::bindTextDomain(const char *const path)
-{
- const char *const dir = bindtextdomain("manaplus", path);
- if (dir)
- logger->log("bindtextdomain: %s", dir);
- else
- logger->log("bindtextdomain failed");
-}
-#else // ENABLE_NLS
-
-void GettextHelper::bindTextDomain(const char *const path A_UNUSED)
-{
-}
-#endif // ENABLE_NLS
diff --git a/src/utils/gettexthelper.h b/src/utils/gettexthelper.h
deleted file mode 100644
index d42266d45..000000000
--- a/src/utils/gettexthelper.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_GETTEXTHELPER_H
-#define UTILS_GETTEXTHELPER_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif // HAVE_CONFIG_H
-
-#include "localconsts.h"
-
-class GettextHelper final
-{
- public:
- A_DELETE_COPY(GettextHelper)
-
- static void initLang();
-
- private:
-#ifdef ENABLE_NLS
- static void bindTextDomain(const char *const path);
-#else // ENABLE_NLS
- static void bindTextDomain(const char *const path A_UNUSED);
-#endif // ENABLE_NLS
-};
-
-#endif // UTILS_GETTEXTHELPER_H
diff --git a/src/utils/glxhelper.cpp b/src/utils/glxhelper.cpp
deleted file mode 100644
index 8525111dc..000000000
--- a/src/utils/glxhelper.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-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/>.
- */
-
-#include "utils/glxhelper.h"
-
-#if defined(USE_OPENGL) && defined(USE_X11)
-
-#include "logger.h"
-
-#include "render/opengl/mglcheck.h"
-
-#include "render/openglx/mglx.h"
-
-#include "render/opengl/mgldefines.h"
-RENDER_OPENGL_MGLDEFINES_H
-
-#include "debug.h"
-
-static int ErrorHandler(Display *d A_UNUSED, XErrorEvent *e A_UNUSED)
-{
- return 0;
-}
-
-void *GlxHelper::createContext(const unsigned long window,
- void *const display0,
- const int major,
- const int minor,
- const int profile)
-{
- Display *const display = static_cast<Display*>(display0);
- XSync(display, false);
- int (*handler)(Display *, XErrorEvent *) = XSetErrorHandler(ErrorHandler);
- void *context = mglXGetCurrentContext();
- if (!display)
- return context;
- if (isGLNull(mglXGetCurrentContext)
- || isGLNull(mglXCreateContextAttribs)
- || isGLNull(mglXChooseFBConfig))
- {
- logger->log("Can't change context, functions in driver "
- "not implemented");
- XSetErrorHandler(handler);
- return context;
- }
- if (!context)
- {
- logger->log("Can't change context, because current "
- "context not created");
- XSetErrorHandler(handler);
- return context;
- }
- int glxAttribs[] =
- {
- GLX_RENDER_TYPE, GLX_RGBA_BIT,
- GLX_RED_SIZE, 3,
- GLX_GREEN_SIZE, 3,
- GLX_BLUE_SIZE, 2,
- GLX_DOUBLEBUFFER, 1,
- 0
- };
-
- int fbcount = 0;
- GLXFBConfig *framebuffer_config = mglXChooseFBConfig(display,
- DefaultScreen(display),
- glxAttribs,
- &fbcount);
-
- if (!framebuffer_config || !fbcount)
- {
- logger->log("No correct fb profile found");
- XSetErrorHandler(handler);
- return nullptr;
- }
- logger->log("Found %d frame buffer contexts.", fbcount);
-
- int attribs[] =
- {
- GLX_CONTEXT_MAJOR_VERSION_ARB, major,
- GLX_CONTEXT_MINOR_VERSION_ARB, minor,
- GLX_CONTEXT_PROFILE_MASK_ARB, profile,
- 0, 0
- };
-
- void *const context2 = mglXCreateContextAttribs(display,
- framebuffer_config[0], context, true, attribs);
- if (!context2)
- {
- logger->log("context %d.%d creation failed", major, minor);
- XSetErrorHandler(handler);
- return nullptr;
- }
-
- XSync(display, false);
- XSetErrorHandler(handler);
-
- if (!mglXMakeCurrent(display, window, context2))
- {
- mglXDestroyContext(display, context2);
- logger->log("make current context %d.%d failed", major, minor);
- return nullptr;
- }
-
- if (mglXGetCurrentContext() != context2)
- {
- mglXDestroyContext(display, context2);
- logger->log("context cant be changed to %d.%d.", major, minor);
- return nullptr;
- }
-
-// do not delete SDL context, because on exit it will crash
-// mglXDestroyContext(display, context);
- logger->log("Context for %d.%d created", major, minor);
- return context2;
-}
-
-bool GlxHelper::makeCurrent(const unsigned long window,
- void *const display,
- void *const context)
-{
- if (!display)
- return false;
- return mglXMakeCurrent(static_cast<Display*>(display), window, context);
-}
-
-#endif // defined(USE_OPENGL) && defined(USE_X11)
diff --git a/src/utils/glxhelper.h b/src/utils/glxhelper.h
deleted file mode 100644
index c3f1be142..000000000
--- a/src/utils/glxhelper.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-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 UTILS_GLXHELPER_H
-#define UTILS_GLXHELPER_H
-
-#if defined(USE_OPENGL) && defined(USE_X11)
-
-#include "localconsts.h"
-
-namespace GlxHelper
-{
- void *createContext(const unsigned long window,
- void *const display,
- const int major,
- const int minor,
- const int profile);
-
- bool makeCurrent(const unsigned long window,
- void *const display,
- void *const context);
-} // namespace GlxHelper
-
-#endif // defined(USE_OPENGL) && defined(USE_X11)
-#endif // UTILS_GLXHELPER_H
diff --git a/src/utils/gmfunctions.cpp b/src/utils/gmfunctions.cpp
deleted file mode 100644
index e6abc3e83..000000000
--- a/src/utils/gmfunctions.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-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/>.
- */
-
-#include "utils/gmfunctions.h"
-
-#include "settings.h"
-
-#include "being/localplayer.h"
-
-#include "const/gui/chat.h"
-
-#include "net/chathandler.h"
-
-#include "debug.h"
-
-namespace Gm
-{
-
-void runCommand(const std::string &command,
- const std::string &params)
-{
- if (params.empty())
- {
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command),
- GENERAL_CHANNEL);
- }
- else
- {
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command).append(
- " ").append(
- params),
- GENERAL_CHANNEL);
- }
-}
-
-void runCommand(const std::string &command)
-{
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command),
- GENERAL_CHANNEL);
-}
-
-void runCharCommand(const std::string &command,
- const std::string &name,
- const std::string &params)
-{
- if ((localPlayer != nullptr) && name == localPlayer->getName())
- {
- if (params.empty())
- {
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command),
- GENERAL_CHANNEL);
- }
- else
- {
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command).append(
- " ").append(
- params),
- GENERAL_CHANNEL);
- }
- }
- else
- {
- chatHandler->talk(std::string(
- settings.gmCharCommandSymbol).append(
- command).append(
- " \"").append(
- name).append(
- "\" ").append(
- params),
- GENERAL_CHANNEL);
- }
-}
-
-void runCharCommand(const std::string &command,
- const std::string &name)
-{
- if ((localPlayer != nullptr) && name == localPlayer->getName())
- {
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command),
- GENERAL_CHANNEL);
- }
- else
- {
- chatHandler->talk(std::string(
- settings.gmCharCommandSymbol).append(
- command).append(
- " ").append(
- name),
- GENERAL_CHANNEL);
- }
-}
-
-} // namespace Gm
diff --git a/src/utils/gmfunctions.h b/src/utils/gmfunctions.h
deleted file mode 100644
index 3670b4b67..000000000
--- a/src/utils/gmfunctions.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-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 UTILS_GMFUNCTIONS_H
-#define UTILS_GMFUNCTIONS_H
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace Gm
-{
- void runCommand(const std::string &command,
- const std::string &params);
-
- void runCommand(const std::string &command);
-
- void runCharCommand(const std::string &command,
- const std::string &name,
- const std::string &params);
-
- void runCharCommand(const std::string &command,
- const std::string &name);
-} // namespace Gm
-
-#endif // UTILS_GMFUNCTIONS_H
diff --git a/src/utils/intmap.h b/src/utils/intmap.h
deleted file mode 100644
index d2786aa77..000000000
--- a/src/utils/intmap.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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 UTILS_INTMAP_H
-#define UTILS_INTMAP_H
-
-#include <map>
-
-typedef std::map<int, int> IntMap;
-typedef IntMap::iterator IntMapIter;
-typedef IntMap::const_iterator IntMapCIter;
-
-#endif // UTILS_INTMAP_H
diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp
deleted file mode 100644
index b4672197a..000000000
--- a/src/utils/langs.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * The ManaPlus Client
- * 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/>.
- */
-
-#include "utils/langs.h"
-
-#include "configuration.h"
-
-#ifndef DYECMD
-#include "being/playerinfo.h"
-
-#include "resources/db/languagedb.h"
-#endif // DYECMD
-
-#include "debug.h"
-
-static const char *getLangName()
-{
- const char *const lang = getenv("LANG");
- if ((lang != nullptr) && strlen(lang) > 1000)
- return nullptr;
- return lang;
-}
-
-LangVect getLang()
-{
- LangVect langs;
- std::string lang = config.getStringValue("lang");
- if (lang.empty())
- {
- const char *const lng = getLangName();
- if (lng == nullptr)
- return langs;
- lang = lng;
- }
- else if (lang.size() > 1000)
- {
- return langs;
- }
-
- size_t dot = lang.find('.');
- if (dot != std::string::npos)
- lang = lang.substr(0, dot);
- langs.push_back(lang);
- dot = lang.find('_');
- if (dot != std::string::npos)
- langs.push_back(lang.substr(0, dot));
- return langs;
-}
-
-LangVect getServerLang()
-{
- LangVect langs;
-#ifndef DYECMD
- const int id = PlayerInfo::getServerLanguage();
- const std::string &lang = LanguageDb::getPo(id);
- if (lang.empty())
- return langs;
- langs.push_back(lang);
- const size_t idx = lang.find('_');
- if (idx != std::string::npos)
- langs.push_back(lang.substr(0, idx));
-#endif // DYECMD
-
- return langs;
-}
-
-std::string getLangSimple()
-{
- const std::string lang = config.getStringValue("lang");
- if (lang.empty())
- {
- const char *const lng = getLangName();
- if (lng == nullptr)
- return "";
- return lng;
- }
- else if (lang.size() > 1000)
- {
- return "";
- }
- return lang;
-}
-
-std::string getLangShort()
-{
- std::string lang = config.getStringValue("lang");
- if (lang.empty())
- {
- const char *const lng = getLangName();
- if (lng == nullptr)
- return "";
- lang = lng;
- }
- else if (lang.size() > 1000)
- {
- return "";
- }
-
- size_t dot = lang.find('.');
- if (dot != std::string::npos)
- lang = lang.substr(0, dot);
- dot = lang.find('_');
- if (dot != std::string::npos)
- return lang.substr(0, dot);
- return lang;
-}
diff --git a/src/utils/langs.h b/src/utils/langs.h
deleted file mode 100644
index 63a6f9674..000000000
--- a/src/utils/langs.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_LANGS_H
-#define UTILS_LANGS_H
-
-#include "utils/vector.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-typedef STD_VECTOR<std::string> LangVect;
-typedef LangVect::const_iterator LangIter;
-
-LangVect getLang() A_WARN_UNUSED;
-
-LangVect getServerLang() A_WARN_UNUSED;
-
-std::string getLangSimple() A_WARN_UNUSED;
-
-std::string getLangShort() A_WARN_UNUSED;
-
-#endif // UTILS_LANGS_H
diff --git a/src/utils/likely.h b/src/utils/likely.h
deleted file mode 100644
index 0df22a379..000000000
--- a/src/utils/likely.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_LIKELY_H
-#define UTILS_LIKELY_H
-
-#ifdef __GNUC__
-#define A_LIKELY(x) __builtin_expect (!!(x), 1)
-#define A_UNLIKELY(x) __builtin_expect (!!(x), 0)
-#else // __GNUC__
-#define A_LIKELY(x) (x)
-#define A_UNLIKELY(x) (x)
-#endif // __GNUC__
-
-#endif // UTILS_LIKELY_H
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
deleted file mode 100644
index 045feb10a..000000000
--- a/src/utils/mathutils.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * 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 UTILS_MATHUTILS_H
-#define UTILS_MATHUTILS_H
-
-#include "utils/cast.h"
-
-#include <string>
-
-#ifndef USE_SDL2
-#include <cmath>
-#endif // USE_SDL2
-
-#include "localconsts.h"
-
-static constexpr const uint16_t crc_table[256] =
-{
- 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
- 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
- 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
- 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
- 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
- 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
- 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
- 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
- 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
- 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
- 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
- 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
- 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
- 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
- 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
- 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
- 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
- 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
- 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
- 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
- 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
- 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
- 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
- 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
- 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
- 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
- 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
- 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
- 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
- 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
- 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
- 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
-};
-
-static constexpr const uint8_t square_roots[1000] =
-{
- 0, 1, 1, 1, 2, 2, 2, 2, 2, 3,
- 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 28, 28, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 31, 31, 31, 31, 31, 31, 31, 31, 31,
- 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
- 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
- 31, 31, 31, 31, 31, 31, 31, 31, 31, 31
-};
-
-inline uint16_t getCrc16(const std::string &str) A_WARN_UNUSED;
-constexpr2 inline float fastInvSqrt(float x) A_WARN_UNUSED;
-constexpr2 inline float fastSqrt(const float x) A_WARN_UNUSED;
-constexpr inline float weightedAverage(const float n1, const float n2,
- const float w) A_WARN_UNUSED;
-constexpr inline int roundDouble(const double v) A_WARN_UNUSED;
-constexpr2 inline int powerOfTwo(const unsigned int input) A_WARN_UNUSED;
-constexpr2 inline int fastSqrtInt(const unsigned int n) A_WARN_UNUSED;
-
-inline uint16_t getCrc16(const std::string &str)
-{
- size_t f = str.size();
- uint16_t crc16 = 0xffff;
-
- while (f != 0)
- {
- f --;
- crc16 = CAST_U16(
- crc_table[(crc16 ^ (str[f])) & 0xff] ^ (crc16 >> 8));
- }
-
- return crc16;
-}
-
-/* A very fast function to calculate the approximate inverse square root of a
- * floating point value and a helper function that uses it for getting the
- * normal squareroot. For an explanation of the inverse squareroot function
- * read:
- * http://www.math.purdue.edu/~clomont/Math/Papers/2003/InvSqrt.pdf
- *
- * Unfortunately the original creator of this function seems to be unknown.
- */
-
-constexpr2 inline float fastInvSqrt(float x)
-{
- union { int i; float x; } tmp = {0U};
- const float xhalf = 0.5F * x;
- tmp.x = x;
- tmp.i = 0x5f375a86 - (tmp.i >> 1);
- x = tmp.x;
- x = x * (1.5F - xhalf * x * x);
- return x;
-}
-
-constexpr2 inline float fastSqrt(const float x)
-{
- return 1.0F / fastInvSqrt(x);
-}
-
-constexpr inline float weightedAverage(const float n1, const float n2,
- const float w)
-{
- return w < 0.0F ? n1 : (w > 1.0F ? n2 : w * n2 + (1.0F - w) * n1);
-}
-
-constexpr inline int roundDouble(const double v)
-{
- return (v > 0.0) ? CAST_S32(v + 0.5) : CAST_S32(v - 0.5);
-}
-
-constexpr2 inline int powerOfTwo(const unsigned int input)
-{
- unsigned int value = 1;
- while (value < input)
- value <<= 1;
- return value;
-}
-
-constexpr2 inline int fastSqrtInt(const unsigned int n)
-{
- if (n < 1000)
- return CAST_S32(square_roots[n]);
- return CAST_S32(sqrt(n));
-}
-
-#endif // UTILS_MATHUTILS_H
diff --git a/src/utils/mrand.cpp b/src/utils/mrand.cpp
deleted file mode 100644
index 1e74e815a..000000000
--- a/src/utils/mrand.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-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/>.
- */
-
-#include "utils/mrand.h"
-
-#include <cstdlib>
-
-#include "debug.h"
-
-namespace
-{
- constexpr const int randNumbers = 1024;
- int mPos = 0;
- int mRand[randNumbers];
-} // namespace
-
-void initRand()
-{
- for (int f = 0; f < randNumbers; f ++)
- mRand[f] = std::rand();
-}
-
-int mrand()
-{
- if (mPos >= randNumbers)
- mPos = 0;
- return mRand[mPos++];
-}
diff --git a/src/utils/mrand.h b/src/utils/mrand.h
deleted file mode 100644
index 8153554b7..000000000
--- a/src/utils/mrand.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-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 UTILS_MRAND_H
-#define UTILS_MRAND_H
-
-#include "localconsts.h"
-
-void initRand();
-
-int mrand();
-
-#endif // UTILS_MRAND_H
diff --git a/src/utils/mutex.h b/src/utils/mutex.h
deleted file mode 100644
index 3703d20ab..000000000
--- a/src/utils/mutex.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008-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 UTILS_MUTEX_H
-#define UTILS_MUTEX_H
-
-#include "logger.h"
-
-/**
- * A mutex provides mutual exclusion of access to certain data that is
- * accessed by multiple threads.
- */
-class Mutex final
-{
- public:
- Mutex();
-
- A_DELETE_COPY(Mutex)
-
- ~Mutex();
-
- void lock();
-
- void unlock();
-
- private:
-// Mutex(const Mutex&); // prevent copying
-// Mutex& operator=(const Mutex&);
-
- SDL_mutex *mMutex;
-};
-
-/**
- * A convenience class for locking a mutex.
- */
-class MutexLocker final
-{
- public:
- explicit MutexLocker(Mutex *const mutex);
-
- MutexLocker(const MutexLocker &m) :
- mMutex(m.mMutex)
- {
- }
-
- A_DEFAULT_COPY(MutexLocker)
-
- ~MutexLocker();
-
- private:
- Mutex *mMutex;
-};
-
-
-inline Mutex::Mutex() :
- mMutex(SDL_CreateMutex())
-{
-}
-
-inline Mutex::~Mutex()
-{
- SDL_DestroyMutex(mMutex);
-}
-
-inline void Mutex::lock()
-{
- if (SDL_mutexP(mMutex) == -1)
- logger->log("Mutex locking failed: %s", SDL_GetError());
-}
-
-inline void Mutex::unlock()
-{
- if (SDL_mutexV(mMutex) == -1)
- logger->log("Mutex unlocking failed: %s", SDL_GetError());
-}
-
-
-inline MutexLocker::MutexLocker(Mutex *const mutex) :
- mMutex(mutex)
-{
- if (mMutex != nullptr)
- mMutex->lock();
-}
-
-inline MutexLocker::~MutexLocker()
-{
- if (mMutex != nullptr)
- mMutex->unlock();
-}
-
-#endif // UTILS_MUTEX_H
diff --git a/src/utils/naclmessages.cpp b/src/utils/naclmessages.cpp
deleted file mode 100644
index 44e6aba1b..000000000
--- a/src/utils/naclmessages.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2015-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/>.
- */
-
-#ifdef __native_client__
-
-#include "utils/naclmessages.h"
-
-#include <ppapi_simple/ps.h>
-#include <ppapi_simple/ps_event.h>
-#include <ppapi/cpp/instance.h>
-#include <ppapi/cpp/var.h>
-
-#include <mutex>
-#include <condition_variable>
-
-#include "debug.h"
-
-struct NaclMessageHandle final
-{
- NaclMessageHandle() :
- handled(false),
- type(),
- message(),
- condv()
- { }
-
- A_DELETE_COPY(NaclMessageHandle)
-
- bool handled;
- std::string type;
- std::string message;
- std::condition_variable condv;
-};
-
-void naclPostMessage(const std::string &type,
- const std::string &message)
-{
- pp::Var msgVar = pp::Var(std::string(type).append(":").append(message));
- pp::Instance(PSGetInstanceId()).PostMessage(msgVar);
-}
-
-static void naclMessageHandlerFunc(struct PP_Var key,
- struct PP_Var value,
- void* user_data)
-{
- NaclMessageHandle *handle = reinterpret_cast<NaclMessageHandle *>(
- user_data);
-
- if (key.type != PP_VARTYPE_STRING || value.type != PP_VARTYPE_STRING)
- return;
- if (pp::Var(key).AsString() != handle->type)
- return;
-
- handle->handled = true;
- handle->message = pp::Var(value).AsString();
-
- handle->condv.notify_one();
-}
-
-NaclMessageHandle *naclRegisterMessageHandler(const std::string &type)
-{
- NaclMessageHandle *handle = new NaclMessageHandle;
- handle->handled = false;
- handle->type = type;
-
- PSEventRegisterMessageHandler(type.c_str(),
- naclMessageHandlerFunc,
- reinterpret_cast<void *>(handle));
- return handle;
-}
-
-void naclUnregisterMessageHandler(NaclMessageHandle *handle)
-{
- PSEventRegisterMessageHandler(handle->type.c_str(),
- nullptr,
- nullptr);
- delete handle;
-}
-
-std::string naclWaitForMessage(NaclMessageHandle *handle)
-{
- std::mutex mtx;
- std::unique_lock <std::mutex> lck(mtx);
-
- while (!handle->handled)
- handle->condv.wait(lck);
-
- handle->handled = false;
- return handle->message;
-}
-
-#endif // __native_client__
diff --git a/src/utils/naclmessages.h b/src/utils/naclmessages.h
deleted file mode 100644
index 1165b973e..000000000
--- a/src/utils/naclmessages.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2015-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 UTILS_NACLMESSAGES_H
-#define UTILS_NACLMESSAGES_H
-
-#ifdef __native_client__
-
-#include <string>
-
-#include "localconsts.h"
-
-struct NaclMessageHandle;
-
-void naclPostMessage(const std::string &type, const std::string &message);
-
-NaclMessageHandle *naclRegisterMessageHandler(const std::string &type);
-
-void naclUnregisterMessageHandler(NaclMessageHandle *handle);
-
-std::string naclWaitForMessage(NaclMessageHandle *handle);
-
-#endif // __native_client__
-#endif // UTILS_NACLMESSAGES_H
diff --git a/src/utils/parameters.cpp b/src/utils/parameters.cpp
deleted file mode 100644
index 019f7c239..000000000
--- a/src/utils/parameters.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-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/>.
- */
-
-#include "utils/parameters.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-static inline void addToken(StringVect &tokens,
- std::string str) A_INLINE;
-static inline void addToken(StringVect &tokens,
- std::string str)
-{
- std::string item = trim(str);
- const size_t sz = item.size();
- if (sz > 1)
- {
- if (str[0] == '\"' &&
- str[sz - 1] == '\"' &&
- str[sz - 2] != '\\')
- {
- item = item.substr(1, sz - 2);
- replaceAll(item, "\\\"", "\"");
- tokens.push_back(item);
- return;
- }
- }
- replaceAll(item, "\\\"", "\"");
- if (!item.empty())
- tokens.push_back(item);
-}
-
-static inline size_t findNextQuote(const std::string &str,
- const char quote,
- const size_t pos) A_INLINE;
-static inline size_t findNextQuote(const std::string &str,
- const char quote,
- const size_t pos)
-{
- size_t idx = str.find(quote, pos);
- while (idx > 0 &&
- idx != std::string::npos &&
- str[idx - 1] == '\\')
- {
- idx = str.find(quote, idx + 1);
- }
- return idx;
-}
-
-static inline size_t findNextSplit(const std::string &str,
- const std::string &separator,
- const char quote) A_INLINE;
-static inline size_t findNextSplit(const std::string &str,
- const std::string &separator,
- const char quote)
-{
- size_t pos = 0;
- while (true)
- {
- // search for next separator
- size_t idx1 = findAny(str, separator, pos);
- // search for next open quote, skipping escaped quotes
- size_t idx2 = findNextQuote(str, quote, pos);
- if (idx2 == std::string::npos) // not quotes, return next separator
- return idx1;
- else if (idx1 == std::string::npos) // also no separators, return npos
- return std::string::npos;
-
- if (idx2 < idx1)
- { // first is quote and after separator: for example "test line", ...
- idx2 = findNextQuote(str, quote, idx2 + 1);
- if (idx2 == std::string::npos)
- return std::string::npos; // no close quote, here error
- // set position for next separator or quote
- pos = idx2 + 1;
- }
- else
- {
- return idx1;
- }
- }
-}
-
-bool splitParameters(StringVect &tokens,
- std::string text,
- const std::string &separator,
- const char quote)
-{
- size_t idx = findNextSplit(text, separator, quote);
-
- while (idx != std::string::npos)
- {
- std::string item = text.substr(0, idx);
- addToken(tokens, item);
- text = text.substr(idx + 1);
- idx = findNextSplit(text, separator, quote);
- }
-
- addToken(tokens, text);
- return true;
-}
diff --git a/src/utils/parameters.h b/src/utils/parameters.h
deleted file mode 100644
index 0f1827428..000000000
--- a/src/utils/parameters.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2016-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 UTILS_PARAMETERS_H
-#define UTILS_PARAMETERS_H
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-bool splitParameters(StringVect &tokens,
- std::string text,
- const std::string &separator,
- const char quote);
-
-#endif // UTILS_PARAMETERS_H
diff --git a/src/utils/perfomance.cpp b/src/utils/perfomance.cpp
deleted file mode 100644
index 226c3d244..000000000
--- a/src/utils/perfomance.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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/>.
- */
-
-#include "localconsts.h"
-
-#ifdef USE_PROFILER
-
-#include "utils/perfomance.h"
-
-#include "configuration.h"
-#include "game.h"
-
-#include "utils/timer.h"
-
-#include <algorithm>
-#include <cstdarg>
-#include <cstdio>
-#include <fcntl.h>
-#include <fstream>
-#include <iostream>
-
-#include "debug.h"
-
-static const clockid_t clockType = CLOCK_MONOTONIC;
-
-#define timeData ((static_cast<long long int>(time.tv_sec) * 1000000000LL \
- + static_cast<long long int>(time.tv_nsec)) / 1)
-
-namespace Perfomance
-{
- std::ofstream file;
- std::string temp;
- long long unsigned int startTime;
-
- void init(const std::string &path)
- {
- file.open(path.c_str(), std::ios_base::trunc);
- timespec time;
- clock_gettime(clockType, &time);
- temp.reserve(10000000U);
- startTime = timeData;
- }
-
- void clear()
- {
- if (file.is_open())
- file.close();
- }
-
- void start()
- {
- timespec time;
- clock_gettime(clockType, &time);
- temp.append(toString(timeData - startTime)).append(
- " __init__\n");
- }
-
- void blockStart(const std::string &name)
- {
- timespec time;
- clock_gettime(clockType, &time);
- temp.append(toString(timeData - startTime)).append(
- " start: ").append(name).append("\n");
- }
-
- void blockEnd(const std::string &name)
- {
- timespec time;
- clock_gettime(clockType, &time);
- temp.append(toString(timeData - startTime)).append(
- " end: ").append(name).append("\n");
- }
-
- void flush()
- {
- if (fps < 40)
- file << temp;
- temp.clear();
-// file.flush();
- }
-} // namespace Perfomance
-
-#endif // USE_PROFILER
diff --git a/src/utils/perfomance.h b/src/utils/perfomance.h
deleted file mode 100644
index 1e8688551..000000000
--- a/src/utils/perfomance.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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 UTILS_PERFOMANCE_H
-#define UTILS_PERFOMANCE_H
-
-#ifdef USE_PROFILER
-#include "utils/vector.h"
-
-#include <string>
-#include <sstream>
-#include <list>
-#include <set>
-
-#include "localconsts.h"
-
-#define PROFILER_START() Perfomance::start();
-#define PROFILER_END() Perfomance::flush();
-#define BLOCK_START(name) Perfomance::blockStart(name);
-#define BLOCK_END(name) Perfomance::blockEnd(name);
-#define FUNC_BLOCK(name, id) Perfomance::Func PerfomanceFunc##id(name);
-
-namespace Perfomance
-{
- void start();
-
- void init(const std::string &path);
-
- void clear();
-
- void blockStart(const std::string &name);
-
- void blockEnd(const std::string &name);
-
- void flush();
-
- class Func final
- {
- public:
- explicit Func(const std::string &str) :
- name(str)
- {
- blockStart(str);
- }
-
- A_DELETE_COPY(Func)
-
- ~Func()
- {
- blockEnd(name);
- }
-
- std::string name;
- };
-} // namespace Perfomance
-
-#else // USE_PROFILER
-
-#define PROFILER_START()
-#define PROFILER_END()
-#define BLOCK_START(name)
-#define BLOCK_END(name)
-#define FUNC_BLOCK(name, id)
-
-#endif // USE_PROFILER
-#endif // UTILS_PERFOMANCE_H
diff --git a/src/utils/pnglib.cpp b/src/utils/pnglib.cpp
deleted file mode 100644
index d472bd565..000000000
--- a/src/utils/pnglib.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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/>.
- */
-
-#include "utils/pnglib.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-
-#include <png.h>
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_video.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-bool PngLib::writePNG(SDL_Surface *const surface,
- const std::string &filename)
-{
- if (surface == nullptr)
- return false;
-
-
- if (SDL_MUSTLOCK(surface))
- SDL_LockSurface(surface);
-
- png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
- nullptr, nullptr, nullptr);
- if (png_ptr == nullptr)
- {
- reportAlways("Had trouble creating png_structp");
- return false;
- }
-
- png_infop info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == nullptr)
- {
- png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(nullptr));
- reportAlways("Could not create png_info");
- return false;
- }
-
- if (setjmp(png_jmpbuf(png_ptr)))
- {
- png_destroy_write_struct(&png_ptr, &info_ptr);
- reportAlways("problem writing to %s", filename.c_str());
- return false;
- }
-
- FILE *const fp = fopen(filename.c_str(), "wb");
- if (fp == nullptr)
- {
- reportAlways("could not open file %s for writing",
- filename.c_str());
- return false;
- }
-
- png_init_io(png_ptr, fp);
-
- const int colortype = (surface->format->BitsPerPixel == 24) ?
- PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_RGB_ALPHA;
-
- png_set_IHDR(png_ptr, info_ptr, surface->w, surface->h, 8, colortype,
- PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
- PNG_FILTER_TYPE_DEFAULT);
-
- png_write_info(png_ptr, info_ptr);
-
- png_set_packing(png_ptr);
-
- png_bytep *const row_pointers
- = new png_bytep[CAST_SIZE(surface->h)];
-
- for (int i = 0; i < surface->h; i++)
- {
- row_pointers[i] = static_cast<png_bytep>(static_cast<uint8_t *>(
- surface->pixels) + CAST_SIZE(i * surface->pitch));
- }
-
- png_write_image(png_ptr, row_pointers);
- png_write_end(png_ptr, info_ptr);
-
- fclose(fp);
-
- delete [] row_pointers;
-
- png_destroy_write_struct(&png_ptr,
- &info_ptr);
-
- if (SDL_MUSTLOCK(surface))
- SDL_UnlockSurface(surface);
-
- return true;
-}
diff --git a/src/utils/pnglib.h b/src/utils/pnglib.h
deleted file mode 100644
index 11f5c1581..000000000
--- a/src/utils/pnglib.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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 UTILS_PNGLIB_H
-#define UTILS_PNGLIB_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct SDL_Surface;
-
-namespace PngLib
-{
- bool writePNG(SDL_Surface *const surface,
- const std::string &filename);
-} // namespace PngLib
-
-#endif // UTILS_PNGLIB_H
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
deleted file mode 100644
index c4639e4db..000000000
--- a/src/utils/process.cpp
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * The ManaPlus Client
- * 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/>.
- */
-
-#include "utils/process.h"
-
-#include <unistd.h>
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifdef USE_SDL2
-#ifdef ANDROID
-#include <SDL_system.h>
-#endif // ANDROID
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#ifndef __native_client__
-const int timeOut = 10;
-#endif // __native_client__
-
-#ifdef WIN32
-
-#include "utils/stringutils.h"
-
-#include <windows.h>
-
-int execFileWait(const std::string &pathName, const std::string &name A_UNUSED,
- const std::string &arg1, const std::string &arg2,
- const int waitTime A_UNUSED)
-{
-// if (!waitTime)
-// waitTime = timeOut;
-
- STARTUPINFO siStartupInfo;
- PROCESS_INFORMATION piProcessInfo;
- memset(&siStartupInfo, 0, sizeof(siStartupInfo));
- memset(&piProcessInfo, 0, sizeof(piProcessInfo));
- siStartupInfo.cb = sizeof(siStartupInfo);
- DWORD ret = -1;
- std::string args(std::string(pathName).append(" ").append(arg1));
- if (!arg2.empty())
- args.append(" ").append(arg2);
-
- if (CreateProcess(pathName.c_str(), const_cast<char*>(args.c_str()),
- nullptr, nullptr, false, CREATE_DEFAULT_ERROR_MODE, nullptr, nullptr,
- &siStartupInfo, &piProcessInfo) != false)
- {
- if (!WaitForSingleObject(piProcessInfo.hProcess, timeOut * 1000))
- {
- if (GetExitCodeProcess(piProcessInfo.hProcess, &ret))
- {
- CloseHandle(piProcessInfo.hProcess);
- CloseHandle(piProcessInfo.hThread);
- return ret;
- }
- }
- TerminateProcess(piProcessInfo.hProcess, -1);
- }
-
- CloseHandle(piProcessInfo.hProcess);
- CloseHandle(piProcessInfo.hThread);
- return -1;
-}
-
-bool execFile(const std::string &pathName, const std::string &name A_UNUSED,
- const std::string &arg1, const std::string &arg2)
-{
- STARTUPINFO siStartupInfo;
- PROCESS_INFORMATION piProcessInfo;
- memset(&siStartupInfo, 0, sizeof(siStartupInfo));
- memset(&piProcessInfo, 0, sizeof(piProcessInfo));
- siStartupInfo.cb = sizeof(siStartupInfo);
- std::string args(std::string(pathName).append(" ").append(arg1));
- if (!arg2.empty())
- args.append(" ").append(arg2);
-
- bool res = CreateProcess(pathName.c_str(), const_cast<char*>(
- args.c_str()), nullptr, nullptr, false,
- CREATE_DEFAULT_ERROR_MODE, nullptr, nullptr, &siStartupInfo,
- &piProcessInfo);
-
- CloseHandle(piProcessInfo.hProcess);
- CloseHandle(piProcessInfo.hThread);
- return res;
-}
-
-
-#elif defined __linux__ || defined __linux || defined __APPLE__
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <csignal>
-
-int execFileWait(const std::string &pathName, const std::string &name,
- const std::string &arg1, const std::string &arg2,
- int waitTime)
-{
- pid_t mon_pid;
- int status;
-
- if (waitTime == 0)
- waitTime = timeOut;
-
- if ((mon_pid = fork()) == -1)
- { // fork error
- return -1;
- }
- else if (mon_pid == 0)
- { // monitoring child
- pid_t pid;
- if ((pid = fork()) == -1)
- { // fork error
- return -1;
- }
- else if (pid == 0)
- { // work child
- if (arg2.empty())
- {
- execl(pathName.c_str(), name.c_str(),
- arg1.c_str(), static_cast<char *>(nullptr));
- }
- else
- {
- execl(pathName.c_str(), name.c_str(), arg1.c_str(),
- arg2.c_str(), static_cast<char *>(nullptr));
- }
- _exit(-1);
- }
-
- // monitoring process
- pid_t sleep_pid;
- if ((sleep_pid = fork()) == -1)
- { // fork error
- return -1;
- }
- else if (sleep_pid == 0)
- { // sleep pid
- sleep(waitTime);
- execl("/bin/true", "/bin/true", static_cast<char *>(nullptr));
- _exit(-1);
- }
-
- // monitoring process
- const pid_t exited_pid = wait(&status);
- int ret = -1;
- if (exited_pid == pid)
- {
- kill(sleep_pid, SIGKILL);
- if (WIFEXITED(status))
- ret = WEXITSTATUS(status);
- }
- else
- {
- kill(pid, SIGKILL);
- ret = -1;
- }
- wait(nullptr);
- execl("/bin/true", "/bin/true", static_cast<char *>(nullptr));
- _exit(ret);
- }
-
- // monitoring parent
- waitpid(mon_pid, &status, 0);
- if (WIFEXITED(status))
- return WEXITSTATUS(status);
-
- return -1;
-}
-
-bool execFile(const std::string &pathName, const std::string &name,
- const std::string &arg1, const std::string &arg2)
-{
- struct stat statbuf;
- // file not exists
- if (stat(pathName.c_str(), &statbuf) != 0)
- return false;
-
- pid_t pid;
- if ((pid = fork()) == -1)
- { // fork error
- return false;
- }
- else if (pid == 0)
- { // work child
- if (arg2.empty())
- {
- execl(pathName.c_str(), name.c_str(),
- arg1.c_str(), static_cast<char *>(nullptr));
- }
- else
- {
- execl(pathName.c_str(), name.c_str(), arg1.c_str(),
- arg2.c_str(), static_cast<char *>(nullptr));
- }
- _exit(-1);
- PRAGMACLANG6(GCC diagnostic push)
- PRAGMACLANG6(GCC diagnostic ignored "-Wunreachable-code-return")
- return false;
- PRAGMACLANG6(GCC diagnostic pop)
- }
- return true;
-}
-
-#else // OTHER
-
-int execFileWait(const std::string &pathName A_UNUSED,
- const std::string &name A_UNUSED,
- const std::string &arg1 A_UNUSED,
- const std::string &arg2 A_UNUSED,
- int waitTime A_UNUSED)
-{
- return -1;
-}
-
-bool execFile(const std::string &pathName A_UNUSED,
- const std::string &name A_UNUSED,
- const std::string &arg1 A_UNUSED,
- const std::string &arg2 A_UNUSED)
-{
- return false;
-}
-
-#endif // WIN32
-
-#if defined WIN64
-bool openBrowser(std::string url)
-{
- return reinterpret_cast<int64_t>(ShellExecute(nullptr, "open",
- replaceAll(url, " ", "").c_str(),
- nullptr, nullptr, SW_SHOWNORMAL)) > 32;
-}
-#elif defined WIN32
-bool openBrowser(std::string url)
-{
- return reinterpret_cast<int32_t>(ShellExecute(nullptr, "open",
- replaceAll(url, " ", "").c_str(),
- nullptr, nullptr, SW_SHOWNORMAL)) > 32;
-}
-#elif defined ANDROID
-#include "utils/stringutils.h"
-#ifndef USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_screenkeyboard.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // USE_SDL2
-
-bool openBrowser(std::string url)
-{
-#ifdef USE_SDL2
- SDL_OpenBrowser(replaceAll(url, " ", "").c_str());
-#else // USE_SDL2
-
- SDL_ANDROID_OpenBrowser(replaceAll(url, " ", "").c_str());
-#endif // USE_SDL2
-
- return true;
-}
-#elif defined __APPLE__
-bool openBrowser(std::string url)
-{
- return execFile("/usr/bin/open", "/usr/bin/open", url, "");
-}
-#elif defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
-bool openBrowser(std::string url)
-{
- return execFile("/usr/local/bin/xdg-open",
- "/usr/local/bin/xdg-open", url, "");
-}
-#elif defined __linux__ || defined __linux
-bool openBrowser(std::string url)
-{
- return execFile("/usr/bin/xdg-open", "/usr/bin/xdg-open", url, "");
-}
-#elif defined __native_client__
-
-#include "utils/naclmessages.h"
-
-bool openBrowser(std::string url)
-{
- naclPostMessage("open-browser", url);
- return true;
-}
-#else // OTHER
-bool openBrowser(std::string url)
-{
- return false;
-}
-
-#endif // WIN32
-
-#ifdef WIN32
-void setPriority(const bool big)
-{
- HANDLE hCurrentProcess = GetCurrentProcess();
- if (big)
- SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS);
- else
- SetPriorityClass(hCurrentProcess, BELOW_NORMAL_PRIORITY_CLASS);
-}
-#else // WIN32
-
-void setPriority(const bool big A_UNUSED)
-{
-}
-#endif // WIN32
diff --git a/src/utils/process.h b/src/utils/process.h
deleted file mode 100644
index bf622c15b..000000000
--- a/src/utils/process.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_PROCESS_H
-#define UTILS_PROCESS_H
-
-#include <string>
-
-int execFileWait(const std::string &pathName, const std::string &name,
- const std::string &arg1, const std::string &arg2,
- int waitTime = 0);
-
-bool execFile(const std::string &pathName, const std::string &name,
- const std::string &arg1, const std::string &arg2);
-
-bool openBrowser(std::string url);
-
-void setPriority(const bool big);
-
-#endif // UTILS_PROCESS_H
diff --git a/src/utils/sdl2helper.cpp b/src/utils/sdl2helper.cpp
deleted file mode 100644
index 68fb9cf4d..000000000
--- a/src/utils/sdl2helper.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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/>.
- */
-
-#ifdef USE_SDL2
-
-#include "utils/sdl2helper.h"
-
-#include "logger.h"
-
-#include "utils/foreach.h"
-#include "utils/sdl2logger.h"
-#include "utils/stringutils.h"
-
-#include <algorithm>
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-#include <SDL_hints.h>
-#include <SDL_render.h>
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-bool SDL::getAllVideoModes(StringVect &modeList)
-{
- std::set<std::string> modes;
- const int numDisplays = SDL_GetNumVideoDisplays();
- for (int display = 0; display < numDisplays; display ++)
- {
- const int numModes = SDL_GetNumDisplayModes(display);
- if (numModes > 0)
- {
- for (int f = 0; f < numModes; f ++)
- {
- SDL_DisplayMode mode;
- SDL_GetDisplayMode(display, f, &mode);
- const int w = mode.w;
- const int h = mode.h;
- logger->log("%dx%dx%d", w, h, mode.refresh_rate);
- modes.insert(strprintf("%dx%d", w, h));
- }
- }
- }
- FOR_EACH (std::set<std::string>::const_iterator, it, modes)
- modeList.push_back(*it);
- return true;
-}
-
-void SDL::SetWindowTitle(SDL_Window *const window, const char *const title)
-{
- SDL_SetWindowTitle(window, title);
-}
-
-void SDL::SetWindowIcon(SDL_Window *const window, SDL_Surface *const icon)
-{
- SDL_SetWindowIcon(window, icon);
-}
-
-void SDL::grabInput(SDL_Window *const window, const bool grab)
-{
- SDL_SetWindowGrab(window, grab ? SDL_TRUE : SDL_FALSE);
-}
-
-void SDL::setGamma(SDL_Window *const window, const float gamma)
-{
- SDL_SetWindowBrightness(window, gamma);
-}
-
-void SDL::setVsync(const int val)
-{
- SDL_GL_SetSwapInterval(val);
-}
-
-bool SDL::getWindowWMInfo(SDL_Window *const window, SDL_SysWMinfo *const info)
-{
- return SDL_GetWindowWMInfo(window, info);
-}
-
-SDL_Thread *SDL::createThread(SDL_ThreadFunction fn,
- const char *restrict const name,
- void *restrict const data)
-{
- return SDL_CreateThread(fn, name, data);
-}
-
-void *SDL::createGLContext(SDL_Window *const window,
- const int major,
- const int minor,
- const int profile)
-{
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile);
-// SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
- SDL_ClearError();
- void *context = SDL_GL_CreateContext(window);
- if (context == nullptr)
- {
- logger->log("Error to switch to context %d.%d: %s",
- major,
- minor,
- SDL_GetError());
- }
- if (context == nullptr && (major > 3 || (major == 3 && minor > 3)))
- {
- logger->log("Try fallback to OpenGL 3.3 context");
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
- SDL_ClearError();
- context = SDL_GL_CreateContext(window);
- if (context == nullptr)
- {
- logger->log("Error to switch to context 3.3: %s",
- SDL_GetError());
- }
- if (context == nullptr && profile == 0x01)
- {
- logger->log("Try fallback to OpenGL 3.3 compatibility context");
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0x02);
- SDL_ClearError();
- context = SDL_GL_CreateContext(window);
- if (context == nullptr)
- {
- logger->log("Error to switch to compatibility context 3.3: %s",
- SDL_GetError());
- }
- }
- }
- if (context == nullptr && (major > 3 || (major == 3 && minor > 0)))
- {
- logger->log("Error to switch to core context %d.%d: %s",
- major,
- minor,
- SDL_GetError());
- logger->log("Try fallback to OpenGL 3.0 core context");
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile);
- context = SDL_GL_CreateContext(window);
- if (context == nullptr)
- {
- logger->log("Error to switch to core context 3.0: %s",
- SDL_GetError());
- }
- }
- if (context == nullptr && (major > 2 || (major == 2 && minor > 1)))
- {
- logger->log("Try fallback to OpenGL 2.1 compatibility context");
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0x02);
- context = SDL_GL_CreateContext(window);
- if (context == nullptr)
- {
- logger->log("Error to switch to compatibility context 2.1: %s",
- SDL_GetError());
- }
- }
- if (context == nullptr)
- {
- logger->log("Cant find working context.");
- }
- return context;
-}
-
-void SDL::makeCurrentContext(void *const context A_UNUSED)
-{
-}
-
-void SDL::initLogger()
-{
- SDL2Logger::init();
-}
-
-void SDL::setLogLevel(const int level)
-{
- SDL2Logger::setLogLevel(level);
-}
-
-void SDL::WaitThread(SDL_Thread *const thread)
-{
- if (thread != nullptr)
- SDL_WaitThread(thread, nullptr);
-}
-
-bool SDL::PollEvent(SDL_Event *event)
-{
- SDL_PumpEvents();
- return SDL_PeepEvents(event,
- 1,
- SDL_GETEVENT,
- SDL_FIRSTEVENT,
- SDL_LASTEVENT) > 0;
-}
-
-void SDL::allowScreenSaver(const bool allow)
-{
- if (allow)
- {
-#if SDL_VERSION_ATLEAST(2, 0, 2)
- SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
-#endif // SDL_VERSION_ATLEAST(2, 0, 2)
- SDL_EnableScreenSaver();
- }
- else
- {
-#if SDL_VERSION_ATLEAST(2, 0, 2)
- SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "0");
-#endif // SDL_VERSION_ATLEAST(2, 0, 2)
- SDL_DisableScreenSaver();
- }
-}
-
-void SDL::getRenderers(StringVect &list,
- const std::string &currentRenderer)
-{
- SDL_RendererInfo info;
- const int num = SDL_GetNumRenderDrivers();
- for (int f = 0; f < num; f ++)
- {
- if (!SDL_GetRenderDriverInfo(f, &info))
- list.push_back(info.name);
- }
- if (!currentRenderer.empty())
- {
- bool found(false);
- FOR_EACH (StringVectCIter, it, list)
- {
- if (*it == currentRenderer)
- {
- found = true;
- break;
- }
- }
- if (!found)
- list.push_back(currentRenderer);
- }
- std::sort(list.begin(), list.end());
-}
-
-void SDL::setRendererHint(const std::string &driver)
-{
- if (!driver.empty())
- {
- SDL_SetHint(SDL_HINT_RENDER_DRIVER,
- driver.c_str());
- }
-}
-
-#endif // USE_SDL2
diff --git a/src/utils/sdl2helper.h b/src/utils/sdl2helper.h
deleted file mode 100644
index 6c50bb1be..000000000
--- a/src/utils/sdl2helper.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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 UTILS_SDL2HELPER_H
-#define UTILS_SDL2HELPER_H
-
-#ifdef USE_SDL2
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_thread.h>
-PRAGMA48(GCC diagnostic pop)
-
-union SDL_Event;
-
-struct SDL_Surface;
-struct SDL_SysWMinfo;
-struct SDL_Window;
-
-namespace SDL
-{
- bool getAllVideoModes(StringVect &modeList);
-
- void SetWindowTitle(SDL_Window *const window, const char *const title);
-
- void SetWindowIcon(SDL_Window *const window, SDL_Surface *const icon);
-
- void grabInput(SDL_Window *const window, const bool grab);
-
- void setGamma(SDL_Window *const window, const float gamma);
-
- void setVsync(const int val);
-
- bool getWindowWMInfo(SDL_Window *const window, SDL_SysWMinfo *const info);
-
- SDL_Thread *createThread(SDL_ThreadFunction fn,
- const char *restrict const name,
- void *restrict const data);
-
- void *createGLContext(SDL_Window *const window,
- const int major,
- const int minor,
- const int profile);
-
- void makeCurrentContext(void *const context);
-
- void initLogger();
-
- void setLogLevel(const int level);
-
- void WaitThread(SDL_Thread *const thread);
-
- bool PollEvent(SDL_Event *event);
-
- void allowScreenSaver(const bool allow);
-
- void getRenderers(StringVect &list,
- const std::string &currentRenderer);
-
- void setRendererHint(const std::string &driver);
-} // namespace SDL
-
-#endif // USE_SDL2
-#endif // UTILS_SDL2HELPER_H
diff --git a/src/utils/sdl2logger.cpp b/src/utils/sdl2logger.cpp
deleted file mode 100644
index 9edac9a29..000000000
--- a/src/utils/sdl2logger.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 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/>.
- */
-
-#ifdef USE_SDL2
-
-#include "utils/sdl2logger.h"
-
-#include "utils/checkutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_assert.h>
-#include <SDL_log.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#define logStr(category, msg) \
- case category: \
- message.append(msg); \
- break
-
-// before 2.0.4 this names not exists
-#if !SDL_VERSION_ATLEAST(2, 0, 4)
-#define SDL_AssertState SDL_assert_state
-#define SDL_AssertData SDL_assert_data
-#endif // !SDL_VERSION_ATLEAST(2, 0, 4)
-
-static void logCallback(void *userData A_UNUSED,
- int category,
- SDL_LogPriority priority,
- const char *msg)
-{
- std::string message("SDL ERROR:");
- switch (priority)
- {
- logStr(SDL_LOG_PRIORITY_VERBOSE,
- " VERBOSE");
- logStr(SDL_LOG_PRIORITY_DEBUG,
- " DEBUG");
- logStr(SDL_LOG_PRIORITY_INFO,
- " INFO");
- logStr(SDL_LOG_PRIORITY_WARN,
- " WARN");
- logStr(SDL_LOG_PRIORITY_ERROR,
- " ERROR");
- logStr(SDL_LOG_PRIORITY_CRITICAL,
- " CRITICAL");
- case SDL_NUM_LOG_PRIORITIES:
- default:
- message.append(" ?");
- break;
- }
-
- switch (category)
- {
- logStr(SDL_LOG_CATEGORY_APPLICATION,
- " APPLICATION");
- logStr(SDL_LOG_CATEGORY_ERROR,
- " ERROR");
- logStr(SDL_LOG_CATEGORY_ASSERT,
- " ASSERT");
- logStr(SDL_LOG_CATEGORY_SYSTEM,
- " SYSTEM");
- logStr(SDL_LOG_CATEGORY_AUDIO,
- " AUDIO");
- logStr(SDL_LOG_CATEGORY_VIDEO,
- " VIDEO");
- logStr(SDL_LOG_CATEGORY_RENDER,
- " RENDER");
- logStr(SDL_LOG_CATEGORY_INPUT,
- " INPUT");
- logStr(SDL_LOG_CATEGORY_TEST,
- " TEST");
- logStr(SDL_LOG_CATEGORY_RESERVED1,
- " RESERVED1");
- logStr(SDL_LOG_CATEGORY_RESERVED2,
- " RESERVED2");
- logStr(SDL_LOG_CATEGORY_RESERVED3,
- " RESERVED3");
- logStr(SDL_LOG_CATEGORY_RESERVED4,
- " RESERVED4");
- logStr(SDL_LOG_CATEGORY_RESERVED5,
- " RESERVED5");
- logStr(SDL_LOG_CATEGORY_RESERVED6,
- " RESERVED6");
- logStr(SDL_LOG_CATEGORY_RESERVED7,
- " RESERVED7");
- logStr(SDL_LOG_CATEGORY_RESERVED8,
- " RESERVED8");
- logStr(SDL_LOG_CATEGORY_RESERVED9,
- " RESERVED9");
- logStr(SDL_LOG_CATEGORY_RESERVED10,
- " RESERVED10");
- logStr(SDL_LOG_CATEGORY_CUSTOM,
- " CUSTOM");
- default:
- message.append(" ?");
- break;
- }
- reportAlways("%s %s",
- message.c_str(),
- msg);
-}
-
-static SDL_AssertState assertCallback(const SDL_AssertData *data,
- void *userdata A_UNUSED)
-{
- reportAlways(
- "SDL assert at %s (%s:%d):\n%s",
- data->function,
- data->filename,
- data->linenum,
- data->condition);
- return SDL_ASSERTION_IGNORE;
-}
-
-void SDL2Logger::init()
-{
-#ifdef UNITTESTS
-#if SDL_VERSION_ATLEAST(2, 0, 4)
- SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
-#else // SDL_VERSION_ATLEAST(2, 0, 4)
- // versions below 2.0.4 report OpenGL error even if OpenGL was not used
- SDL_LogSetAllPriority(SDL_LOG_PRIORITY_CRITICAL);
-#endif // SDL_VERSION_ATLEAST(2, 0, 4)
-#else // UNITTESTS
-
- SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
-#endif // UNITTESTS
-
- SDL_LogSetOutputFunction(&logCallback, nullptr);
- SDL_SetAssertionHandler(&assertCallback, nullptr);
-}
-
-void SDL2Logger::setLogLevel(const int level)
-{
- if (level > 0)
- SDL_LogSetAllPriority(static_cast<SDL_LogPriority>(level));
- else
- SDL_LogResetPriorities();
-}
-
-#endif // USE_SDL2
diff --git a/src/utils/sdl2logger.h b/src/utils/sdl2logger.h
deleted file mode 100644
index c3ecd1ada..000000000
--- a/src/utils/sdl2logger.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 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 UTILS_SDL2LOGGER_H
-#define UTILS_SDL2LOGGER_H
-
-#ifdef USE_SDL2
-
-#include "localconsts.h"
-
-namespace SDL2Logger
-{
- void init();
-
- void setLogLevel(const int level);
-} // namespace SDL2Logger
-
-#endif // USE_SDL2
-#endif // UTILS_SDL2LOGGER_H
diff --git a/src/utils/sdlcheckutils.cpp b/src/utils/sdlcheckutils.cpp
deleted file mode 100644
index 4ce07f2e5..000000000
--- a/src/utils/sdlcheckutils.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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/>.
- */
-
-#include "utils/sdlcheckutils.h"
-
-#ifdef DEBUG_SDL_SURFACES
-
-#include "logger.h"
-
-#include "utils/sdlmemoryobject.h"
-#include "utils/stringutils.h"
-
-#include <map>
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_image.h>
-#include <SDL_ttf.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#define DEBUG_SURFACE_ALLOCATION 1
-
-std::map<void*, SDLMemoryObject*> mSurfaces;
-
-static SDL_Surface *addSurface(const char *restrict const name,
- SDL_Surface *restrict const surface,
- const char *restrict const file,
- const unsigned line)
-{
-#ifdef DEBUG_SURFACE_ALLOCATION
- logger->log("add surface: %s %s:%u %p", name,
- file, line, static_cast<void*>(surface));
-#endif // DEBUG_SURFACE_ALLOCATION
-
- std::map<void*, SDLMemoryObject*>::iterator
- it = mSurfaces.find(surface);
- if (it != mSurfaces.end())
- {
- SDLMemoryObject *const obj = (*it).second;
- if (obj)
- { // found some time ago created surface
-#ifdef DEBUG_SURFACE_ALLOCATION
- logger->log("adding existing surface: %p, count:%d\n"
- "was add %s\nwas deleted %s", surface, obj->mCnt,
- obj->mAddFile.c_str(), obj->mRemoveFile.c_str());
-#endif // DEBUG_SURFACE_ALLOCATION
-
- obj->mCnt ++;
- }
- }
- else
- { // creating surface object
- mSurfaces[surface] = new SDLMemoryObject(name, file, line);
- }
- return surface;
-}
-
-static void deleteSurface(const char *restrict const name A_UNUSED,
- SDL_Surface *restrict const surface,
- const char *restrict const file,
- const unsigned line)
-{
-#ifdef DEBUG_SURFACE_ALLOCATION
- logger->log("delete surface: %s %s:%u %p", name, file, line, surface);
-#endif // DEBUG_SURFACE_ALLOCATION
-
- std::map<void*, SDLMemoryObject*>::iterator
- it = mSurfaces.find(surface);
- if (it == mSurfaces.end())
- {
- logger->log("bad surface delete: %p at %s:%d",
- static_cast<void*>(surface), file, line);
- }
- else
- {
- SDLMemoryObject *const obj = (*it).second;
- if (obj)
- {
- const int cnt = obj->mCnt;
-#ifdef DEBUG_SURFACE_ALLOCATION
- logger->log("debug deleting surface: %p, count:%d\n"
- "was add %s\nwas deleted %s", surface, cnt,
- obj->mAddFile.c_str(), obj->mRemoveFile.c_str());
-#endif // DEBUG_SURFACE_ALLOCATION
-
- if (cnt < 1)
- { // surface was here but was deleted
- logger->log("deleting already deleted surface: %p at %s:%d\n"
- "was add %s\nwas deleted %s", static_cast<void*>(surface),
- file, line, obj->mAddFile.c_str(),
- obj->mRemoveFile.c_str());
- }
- else if (cnt == 1)
- {
- mSurfaces.erase(surface);
- delete obj;
- }
- else
- {
- obj->mCnt --;
- obj->mRemoveFile = strprintf("%s:%u", file, line);
- }
- }
- }
-}
-
-SDL_Surface *FakeIMG_LoadPNG_RW(SDL_RWops *const src, const char *const file,
- const unsigned line)
-{
- return addSurface("IMG_LoadPNG_RW", IMG_LoadPNG_RW(src), file, line);
-}
-
-SDL_Surface *FakeIMG_LoadJPG_RW(SDL_RWops *const src, const char *const file,
- const unsigned line)
-{
- return addSurface("IMG_LoadJPG_RW", IMG_LoadJPG_RW(src), file, line);
-}
-
-SDL_Surface *FakeIMG_Load(const char *name, const char *const file,
- const unsigned line)
-{
- return addSurface("IMG_Load", IMG_Load(name), file, line);
-}
-
-void FakeSDL_FreeSurface(SDL_Surface *const surface, const char *const file,
- const unsigned line)
-{
- deleteSurface("SDL_FreeSurface", surface, file, line);
- SDL_FreeSurface(surface);
-}
-
-SDL_Surface *FakeSDL_CreateRGBSurface(const uint32_t flags,
- const int width, const int height,
- const int depth,
- const uint32_t rMask,
- const uint32_t gMask,
- const uint32_t bMask,
- const uint32_t aMask,
- const char *const file,
- const unsigned line)
-{
- return addSurface("SDL_CreateRGBSurface", SDL_CreateRGBSurface(flags,
- width, height, depth, rMask, gMask, bMask, aMask), file, line);
-}
-
-SDL_Surface *FakeSDL_ConvertSurface(SDL_Surface *const src,
- SDL_PixelFormat *const fmt,
- const uint32_t flags,
- const char *const file,
- const unsigned line)
-{
- return addSurface("SDL_ConvertSurface", SDL_ConvertSurface(
- src, fmt, flags), file, line);
-}
-
-SDL_Surface *FakeTTF_RenderUTF8_Blended(_TTF_Font *const font,
- const char *restrict const text,
- const SDL_Color &fg,
- const char *restrict const file,
- const unsigned line)
-{
- return addSurface("TTF_RenderUTF8_Blended", TTF_RenderUTF8_Blended(
- font, text, fg), file, line);
-}
-
-SDL_Surface *FakeSDL_DisplayFormat(SDL_Surface *const surface,
- const char *const file,
- const unsigned line)
-{
- return addSurface("SDL_DisplayFormat",
- SDL_DisplayFormat(surface), file, line);
-}
-
-SDL_Surface *FakeSDL_DisplayFormatAlpha(SDL_Surface *const surface,
- const char *const file,
- const unsigned line)
-{
- return addSurface("SDL_DisplayFormatAlpha",
- SDL_DisplayFormatAlpha(surface), file, line);
-}
-
-#endif // DEBUG_SDL_SURFACES
diff --git a/src/utils/sdlcheckutils.h b/src/utils/sdlcheckutils.h
deleted file mode 100644
index 29fd48a7b..000000000
--- a/src/utils/sdlcheckutils.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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 UTILS_SDLCHECKUTILS_H
-#define UTILS_SDLCHECKUTILS_H
-
-#include "localconsts.h"
-#ifdef DEBUG_SDL_SURFACES
-
-#include <string>
-
-struct _TTF_Font;
-struct SDL_Color;
-struct SDL_PixelFormat;
-struct SDL_RWops;
-struct SDL_Surface;
-
-SDL_Surface *FakeIMG_LoadPNG_RW(SDL_RWops *const src, const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeIMG_LoadJPG_RW(SDL_RWops *const src, const char *const file,
- const unsigned line);
-
-void FakeSDL_FreeSurface(SDL_Surface *const surface, const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeSDL_CreateRGBSurface(const uint32_t flags,
- const int width, const int height,
- const int depth,
- const uint32_t rMask,
- const uint32_t gMask,
- const uint32_t bMask,
- const uint32_t aMask,
- const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeSDL_ConvertSurface(SDL_Surface *const src,
- SDL_PixelFormat *const fmt,
- const uint32_t flags,
- const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeTTF_RenderUTF8_Blended(_TTF_Font *restrict const font,
- const char *restrict const text,
- const SDL_Color &fg,
- const char *restrict const file,
- const unsigned line);
-
-SDL_Surface *FakeIMG_Load(const char *name, const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeSDL_DisplayFormat(SDL_Surface *const surface,
- const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeSDL_DisplayFormatAlpha(SDL_Surface *const surface,
- const char *const file,
- const unsigned line);
-
-#endif // DEBUG_SDL_SURFACES
-#endif // UTILS_SDLCHECKUTILS_H
diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp
deleted file mode 100644
index e30bdebaa..000000000
--- a/src/utils/sdlhelper.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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 USE_SDL2
-
-#include "utils/sdlhelper.h"
-
-#include "logger.h"
-
-#include "utils/cast.h"
-#include "utils/env.h"
-#include "utils/stringutils.h"
-
-#if defined(USE_X11) && defined(USE_OPENGL)
-#include "utils/glxhelper.h"
-#endif // defined(USE_X11) && defined(USE_OPENGL)
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-bool SDL::getAllVideoModes(StringVect &modeList)
-{
- /* Get available fullscreen/hardware modes */
- SDL_Rect *const *const modes = SDL_ListModes(nullptr,
- SDL_FULLSCREEN | SDL_HWSURFACE);
-
-#ifdef ANDROID
- const std::string modeString =
- toString(CAST_S32(modes[0]->w)).append("x")
- .append(toString(CAST_S32(modes[0]->h)));
- logger->log("support mode: " + modeString);
- modeList.push_back(modeString);
- return true;
-#else // ANDROID
-
- /* Check which modes are available */
- if (modes == static_cast<SDL_Rect **>(nullptr))
- {
- logger->log1("No modes available");
- return false;
- }
- else if (modes == reinterpret_cast<SDL_Rect **>(-1))
- {
- logger->log1("All resolutions available");
- return true;
- }
- else
- {
- for (int i = 0; modes[i] != nullptr; ++ i)
- {
- const std::string modeString =
- toString(CAST_S32(modes[i]->w)).append("x")
- .append(toString(CAST_S32(modes[i]->h)));
- logger->log("support mode: " + modeString);
- modeList.push_back(modeString);
- }
- return true;
- }
-#endif // ANDROID
-}
-
-void SDL::SetWindowTitle(const SDL_Surface *const window A_UNUSED,
- const char *const title)
-{
- SDL_WM_SetCaption(title, nullptr);
-}
-
-void SDL::SetWindowIcon(const SDL_Surface *const window A_UNUSED,
- SDL_Surface *const icon)
-{
- SDL_WM_SetIcon(icon, nullptr);
-}
-
-void SDL::grabInput(const SDL_Surface *const window A_UNUSED, const bool grab)
-{
- SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF);
-}
-
-void SDL::setGamma(const SDL_Surface *const window A_UNUSED, const float gamma)
-{
- SDL_SetGamma(gamma, gamma, gamma);
-}
-
-void SDL::setVsync(const int val)
-{
- SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, val);
-}
-
-bool SDL::getWindowWMInfo(const SDL_Surface *const window A_UNUSED,
- SDL_SysWMinfo *const info)
-{
- return SDL_GetWMInfo(info) != 0;
-}
-
-SDL_Thread *SDL::createThread(int (SDLCALL *fn)(void *),
- const char *const name A_UNUSED,
- void *const data)
-{
- return SDL_CreateThread(fn, data);
-}
-
-#if defined(USE_X11) && defined(USE_OPENGL)
-void *SDL::createGLContext(SDL_Surface *const window A_UNUSED,
- const int major,
- const int minor,
- const int profile)
-{
- SDL_SysWMinfo info;
- SDL_VERSION(&info.version);
- SDL_GetWMInfo(&info);
- void *context = GlxHelper::createContext(info.info.x11.window,
- info.info.x11.display, major, minor, profile);
- if (!context && (major > 3 || (major == 3 && minor > 3)))
- {
- logger->log("Try fallback to OpenGL 3.3 core context");
- context = GlxHelper::createContext(info.info.x11.window,
- info.info.x11.display, 3, 3, profile);
- if (!context && profile == 0x01)
- {
- logger->log("Try fallback to OpenGL 3.3 compatibility context");
- context = GlxHelper::createContext(info.info.x11.window,
- info.info.x11.display, 3, 3, 0x02);
- }
- }
- if (!context && (major > 3 || (major == 3 && minor > 0)))
- {
- logger->log("Try fallback to OpenGL 3.0 core context");
- context = GlxHelper::createContext(info.info.x11.window,
- info.info.x11.display, 3, 0, profile);
- }
- if (!context && (major > 2 || (major == 2 && minor > 1)))
- {
- logger->log("Try fallback to OpenGL 2.1 compatibility context");
- context = GlxHelper::createContext(info.info.x11.window,
- info.info.x11.display, 2, 1, 0x02);
- }
- return context;
-}
-
-void SDL::makeCurrentContext(void *const context)
-{
- SDL_SysWMinfo info;
- SDL_VERSION(&info.version);
- SDL_GetWMInfo(&info);
- GlxHelper::makeCurrent(info.info.x11.window,
- info.info.x11.display,
- context);
-}
-#else // defined(USE_X11) && defined(USE_OPENGL)
-
-void *SDL::createGLContext(SDL_Surface *const window A_UNUSED,
- const int major A_UNUSED,
- const int minor A_UNUSED,
- const int profile A_UNUSED)
-{
- return nullptr;
-}
-
-void SDL::makeCurrentContext(void *const context A_UNUSED)
-{
-}
-#endif // defined(USE_X11) && defined(USE_OPENGL)
-
-void SDL::initLogger()
-{
-}
-
-void SDL::setLogLevel(const int level A_UNUSED)
-{
-}
-
-void SDL::WaitThread(SDL_Thread *const thread)
-{
- if (thread != nullptr && SDL_GetThreadID(thread) != 0u)
- SDL_WaitThread(thread, nullptr);
-}
-
-bool SDL::PollEvent(SDL_Event *event)
-{
- SDL_PumpEvents();
- return SDL_PeepEvents(event,
- 1,
- SDL_GETEVENT,
- SDL_ALLEVENTS) > 0;
-}
-
-void SDL::allowScreenSaver(const bool allow)
-{
- if (allow)
- setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "1");
- else
- setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "0");
-}
-
-#endif // USE_SDL2
diff --git a/src/utils/sdlhelper.h b/src/utils/sdlhelper.h
deleted file mode 100644
index f304036aa..000000000
--- a/src/utils/sdlhelper.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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 UTILS_SDLHELPER_H
-#define UTILS_SDLHELPER_H
-
-#ifdef USE_SDL2
-#include "utils/sdl2helper.h"
-UTILS_SDL2HELPER_H
-
-#else
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_thread.h>
-PRAGMA48(GCC diagnostic pop)
-
-union SDL_Event;
-
-struct SDL_Surface;
-struct SDL_SysWMinfo;
-
-namespace SDL
-{
- bool getAllVideoModes(StringVect &modeList);
-
- void SetWindowTitle(const SDL_Surface *const window,
- const char *const title);
-
- void SetWindowIcon(const SDL_Surface *const window A_UNUSED,
- SDL_Surface *const icon);
-
- void grabInput(const SDL_Surface *const window A_UNUSED, const bool grab);
-
- void setGamma(const SDL_Surface *const window A_UNUSED, const float gamma);
-
- void setVsync(const int val);
-
- bool getWindowWMInfo(const SDL_Surface *const window A_UNUSED,
- SDL_SysWMinfo *const info);
-
- SDL_Thread *createThread(int (SDLCALL *fn)(void *),
- const char *const name A_UNUSED,
- void *const data);
-
- void *createGLContext(SDL_Surface *const window A_UNUSED,
- const int major,
- const int minor,
- const int profile);
-
- void makeCurrentContext(void *const context);
-
- void initLogger();
-
- void setLogLevel(const int level);
-
- void WaitThread(SDL_Thread *const thread);
-
- bool PollEvent(SDL_Event *event);
-
- void allowScreenSaver(const bool allow);
-} // namespace SDL
-
-#endif // USE_SDL2
-#endif // UTILS_SDLHELPER_H
diff --git a/src/utils/sdlmemoryobject.h b/src/utils/sdlmemoryobject.h
deleted file mode 100644
index daab75088..000000000
--- a/src/utils/sdlmemoryobject.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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 UTILS_SDLMEMORYOBJECT_H
-#define UTILS_SDLMEMORYOBJECT_H
-
-#ifdef DEBUG_SDL_SURFACES
-
-#include "logger.h"
-
-#include "utils/stringutils.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct SDLMemoryObject final
-{
- SDLMemoryObject(const std::string &name,
- const char *const file,
- const unsigned int line) :
- mName(name),
- mAddFile(strprintf("%s:%u", file, line)),
- mRemoveFile(),
- mCnt(1)
- {
- }
-
- A_DELETE_COPY(SDLMemoryObject)
-
- std::string mName;
- std::string mAddFile;
- std::string mRemoveFile;
- int mCnt;
-};
-
-#endif // DEBUG_SDL_SURFACES
-#endif // UTILS_SDLMEMORYOBJECT_H
diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h
deleted file mode 100644
index 920ad4164..000000000
--- a/src/utils/sdlpixel.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * The ManaPlus Client
- * 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef UTILS_SDLPIXEL_H
-#define UTILS_SDLPIXEL_H
-
-#include "gui/color.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL.h>
-PRAGMA48(GCC diagnostic pop)
-
-#ifndef SDL_BYTEORDER
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-/**
- * Puts a pixel on an SDL_Surface.
- *
- * @param x the x coordinate on the surface.
- * @param y the y coordinate on the surface.
- * @param color the color the pixel should be in.
- */
-inline void SDLputPixel(SDL_Surface* surface, int x, int y,
- const Color& color)
-{
- if (surface == nullptr)
- return;
-
- const int bpp = surface->format->BytesPerPixel;
-
- SDL_LockSurface(surface);
-
- Uint8 *const p = static_cast<uint8_t*>(surface->pixels)
- + CAST_SIZE(y * surface->pitch + x * bpp);
-
- const Uint32 pixel = SDL_MapRGB(surface->format,
- CAST_U8(color.r), CAST_U8(color.g),
- CAST_U8(color.b));
-
- switch (bpp)
- {
- case 1:
- *p = CAST_U8(pixel);
- break;
-
- case 2:
- *reinterpret_cast<uint16_t*>(p) = CAST_U16(pixel);
- break;
-
- case 3:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- p[0] = CAST_U8((pixel >> 16) & 0xff);
- p[1] = CAST_U8((pixel >> 8) & 0xff);
- p[2] = CAST_U8((pixel) & 0xff);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- p[0] = CAST_U8((pixel) & 0xff);
- p[1] = CAST_U8((pixel >> 8) & 0xff);
- p[2] = CAST_U8((pixel >> 16) & 0xff);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- break;
-
- case 4:
- *reinterpret_cast<Uint32*>(p) = pixel;
- break;
-
- default:
- break;
- }
-
- SDL_UnlockSurface(surface);
-}
-
-/**
- * Blends two 32 bit colors together.
- *
- * @param src the source color.
- * @param dst the destination color.
- * @param a alpha.
- */
-inline unsigned int SDLAlpha32(const unsigned int src,
- const unsigned int dst,
- const unsigned char a)
-{
- const unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8;
- const unsigned int g = ((src & 0xff00) * a + (dst & 0xff00)
- * (255 - a)) >> 8;
- const unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000)
- * (255 - a)) >> 8;
-
- return (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
-}
-
-inline unsigned short SDLAlpha16(const unsigned short src,
- const unsigned short dst,
- const unsigned char a,
- const SDL_PixelFormat *const f) A_NONNULL(4);
-
-/**
- * Blends two 16 bit colors together.
- *
- * @param src the source color.
- * @param dst the destination color.
- * @param a alpha.
- */
-inline unsigned short SDLAlpha16(const unsigned short src,
- const unsigned short dst,
- const unsigned char a,
- const SDL_PixelFormat *const f)
-{
- unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask)
- * (255 - a)) >> 8;
- unsigned int g = ((src & f->Gmask) * a + (dst & f->Gmask)
- * (255 - a)) >> 8;
- unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask)
- * (255 - a)) >> 8;
-
- return static_cast<unsigned short>((b & f->Rmask)
- | (g & f->Gmask) | (r & f->Bmask));
-}
-
-/**
- * Puts a pixel on an SDL_Surface with alpha
- *
- * @param x the x coordinate on the surface.
- * @param y the y coordinate on the surface.
- * @param color the color the pixel should be in.
- */
-inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y,
- const Color& color)
-{
- if (surface == nullptr)
- return;
- const int bpp = surface->format->BytesPerPixel;
-
- SDL_LockSurface(surface);
-
- Uint8 *const p = static_cast<uint8_t*>(surface->pixels)
- + CAST_SIZE(y * surface->pitch + x * bpp);
-
- const Uint32 pixel = SDL_MapRGB(surface->format,
- CAST_U8(color.r),
- CAST_U8(color.g),
- CAST_U8(color.b));
-
- switch (bpp)
- {
- case 1:
- *p = CAST_U8(pixel);
- break;
-
- case 2:
- *reinterpret_cast<Uint16*>(p) = SDLAlpha16(
- static_cast<unsigned short>(pixel),
- *reinterpret_cast<unsigned short*>(p),
- CAST_U8(color.a), surface->format);
- break;
-
- case 3:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- p[2] = CAST_U8((p[2] * (255 - color.a)
- + color.b * color.a) >> 8);
- p[1] = CAST_U8((p[1] * (255 - color.a)
- + color.g * color.a) >> 8);
- p[0] = CAST_U8((p[0] * (255 - color.a)
- + color.r * color.a) >> 8);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- p[0] = CAST_U8((p[0] * (255 - color.a)
- + color.b * color.a) >> 8);
- p[1] = CAST_U8((p[1] * (255 - color.a)
- + color.g * color.a) >> 8);
- p[2] = CAST_U8((p[2] * (255 - color.a)
- + color.r * color.a) >> 8);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- break;
-
- case 4:
- *reinterpret_cast<Uint32*>(p) = SDLAlpha32(pixel,
- *reinterpret_cast<Uint32*>(p),
- CAST_U8(color.a));
- break;
- default:
- break;
- }
-
- SDL_UnlockSurface(surface);
-}
-
-#endif // UTILS_SDLPIXEL_H
diff --git a/src/utils/sdlsharedhelper.cpp b/src/utils/sdlsharedhelper.cpp
deleted file mode 100644
index 1f2f04a85..000000000
--- a/src/utils/sdlsharedhelper.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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/>.
- */
-
-#include "utils/sdlsharedhelper.h"
-
-#ifdef __native_client__
-#include <ppapi/c/ppb_mouse_cursor.h>
-#include <ppapi/cpp/instance.h>
-#include <ppapi/cpp/mouse_cursor.h>
-#include <ppapi_simple/ps.h>
-#endif // __native_client__
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-void SDL::showCursor(const bool show)
-{
-#ifdef __native_client__
- PP_MouseCursor_Type cursor;
- if (show)
- cursor = PP_MOUSECURSOR_TYPE_POINTER; // show default cursor
- else
- cursor = PP_MOUSECURSOR_TYPE_NONE; // hide cursor
-
- pp::MouseCursor::SetCursor(
- pp::InstanceHandle(PSGetInstanceId()),
- cursor);
-#endif // __native_client__
-
- if (show)
- SDL_ShowCursor(SDL_ENABLE);
- else
- SDL_ShowCursor(SDL_DISABLE);
-}
diff --git a/src/utils/sdlsharedhelper.h b/src/utils/sdlsharedhelper.h
deleted file mode 100644
index 799bf5965..000000000
--- a/src/utils/sdlsharedhelper.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2013-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 UTILS_SDLSHAREDHELPER_H
-#define UTILS_SDLSHAREDHELPER_H
-
-#include "localconsts.h"
-
-namespace SDL
-{
- void showCursor(const bool show);
-} // namespace SDL
-
-#endif // UTILS_SDLSHAREDHELPER_H
diff --git a/src/utils/stdmove.h b/src/utils/stdmove.h
deleted file mode 100644
index b72b941aa..000000000
--- a/src/utils/stdmove.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 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 UTILS_STDMOVE_H
-#define UTILS_STDMOVE_H
-
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-#define STD_MOVE(var) std::move(var)
-#else // __GXX_EXPERIMENTAL_CXX0X__
-#define STD_MOVE(var) (var)
-#endif // __GXX_EXPERIMENTAL_CXX0X__
-
-#endif // UTILS_STDMOVE_H
diff --git a/src/utils/stringmap.h b/src/utils/stringmap.h
deleted file mode 100644
index 90200764a..000000000
--- a/src/utils/stringmap.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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 UTILS_STRINGMAP_H
-#define UTILS_STRINGMAP_H
-
-#include <string>
-#include <map>
-
-typedef std::map<std::string, int> StringIntMap;
-typedef StringIntMap::iterator StringIntMapIter;
-typedef StringIntMap::const_iterator StringIntMapCIter;
-
-#endif // UTILS_STRINGMAP_H
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
deleted file mode 100644
index 4f3a156cc..000000000
--- a/src/utils/stringutils.cpp
+++ /dev/null
@@ -1,1238 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-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/>.
- */
-
-#include "utils/stringutils.h"
-
-#include "const/utils/utf8.h"
-
-#ifdef DYECMD
-#include "utils/cast.h"
-#else // DYECMD
-#include "resources/iteminfo.h"
-#include "resources/db/itemdb.h"
-#endif // DYECMD
-
-#include "utils/gettext.h"
-#include "utils/foreach.h"
-
-#include <algorithm>
-#include <sstream>
-
-#ifdef WIN32
-#include <sys/time.h>
-#endif // WIN32
-
-#include "debug.h"
-
-std::string &trim(std::string &str)
-{
- size_t pos = str.find_last_not_of(' ');
- if (pos != std::string::npos)
- {
- str.erase(pos + 1);
- pos = str.find_first_not_of(' ');
-
- if (pos != std::string::npos)
- str.erase(0, pos);
- }
- else
- {
- // There is nothing else but whitespace in the string
- str.clear();
- }
- return str;
-}
-
-std::string &toLower(std::string &str)
-{
- std::transform(str.begin(), str.end(), str.begin(), &tolower);
- return str;
-}
-
-std::string &toUpper(std::string &str)
-{
- std::transform(str.begin(), str.end(), str.begin(), &toupper);
- return str;
-}
-
-unsigned int atox(const std::string &str)
-{
- unsigned int value = 0;
- if (sscanf(str.c_str(), "0x%06x", &value) != 0)
- return value;
- return 0;
-}
-
-const char *ipToString(const uint32_t address)
-{
- static char asciiIP[18];
-
- snprintf(asciiIP, sizeof(asciiIP), "%i.%i.%i.%i",
- CAST_U8(address),
- CAST_U8(address >> 8),
- CAST_U8(address >> 16),
- CAST_U8(address >> 24));
- asciiIP[17] = 0;
-
- return asciiIP;
-}
-
-std::string strprintf(const char *const format, ...)
-{
- char buf[257];
- va_list(args);
- va_start(args, format);
- size_t nb = vsnprintf(buf, 256, format, args);
- buf[256] = 0;
- va_end(args);
- if (nb < 256)
- return buf;
-
- // The static size was not big enough, try again with a dynamic allocation.
- ++nb;
- char *buf2 = new char[nb];
- va_start(args, format);
- vsnprintf(buf2, nb, format, args);
- va_end(args);
- std::string res(buf2);
- delete [] buf2;
- return res;
-}
-
-std::string removeColors(std::string msg)
-{
- for (unsigned int f = 0; f < msg.length() - 2 && msg.length() > 2; f++)
- {
- while (msg.length() > f + 2 && msg.at(f) == '#'
- && msg.at(f + 1) == '#')
- {
- msg = msg.erase(f, 3);
- }
- }
- return msg;
-}
-
-int compareStrI(const std::string &a, const std::string &b)
-{
- std::string::const_iterator itA = a.begin();
- const std::string::const_iterator endA = a.end();
- std::string::const_iterator itB = b.begin();
- const std::string::const_iterator endB = b.end();
-
- for (; itA < endA && itB < endB; ++itA, ++itB)
- {
- const int comp = tolower(*itA) - tolower(*itB);
- if (comp != 0)
- return comp;
- }
-
- // Check string lengths
- if (itA == endA && itB == endB)
- return 0;
- else if (itA == endA)
- return -1;
- else
- return 1;
-}
-
-
-bool isWordSeparator(const signed char chr)
-{
- return chr == ' ' ||
- chr == ',' ||
- chr == '.' ||
- chr == '"';
-}
-
-const std::string findSameSubstring(const std::string &restrict str1,
- const std::string &restrict str2)
-{
- const int minLength = str1.length() > str2.length()
- ? CAST_S32(str2.length()) : CAST_S32(str1.length());
- for (int f = 0; f < minLength; f ++)
- {
- if (str1.at(f) != str2.at(f))
- return str1.substr(0, f);
- }
- return str1.substr(0, minLength);
-}
-
-const std::string findSameSubstringI(const std::string &restrict s1,
- const std::string &restrict s2)
-{
- std::string str1 = s1;
- std::string str2 = s2;
- toLower(str1);
- toLower(str2);
-
- const size_t minLength = str1.length() > str2.length()
- ? str2.length() : str1.length();
- for (size_t f = 0; f < minLength; f ++)
- {
- if (str1.at(f) != str2.at(f))
- return s1.substr(0, f);
- }
- return s1.substr(0, minLength);
-}
-
-size_t findI(std::string str, std::string subStr)
-{
- str = toLower(str);
- subStr = toLower(subStr);
- return str.find(subStr);
-}
-
-size_t findI(std::string text, const StringVect &list)
-{
- toLower(text);
- FOR_EACH (StringVectCIter, i, list)
- {
- std::string subStr = *i;
- subStr = toLower(subStr);
- const size_t idx = text.find(subStr);
- if (idx != std::string::npos)
- return idx;
- }
- return std::string::npos;
-}
-
-size_t findAny(const std::string &restrict text,
- const std::string &restrict chars,
- const size_t pos)
-{
- size_t idx = std::string::npos;
- const size_t sz = chars.size();
- for (size_t f = 0; f < sz; f ++)
- {
- const size_t idx2 = text.find(chars[f], pos);
- if (idx2 != std::string::npos && idx2 < idx)
- idx = idx2;
- }
- return idx;
-}
-
-namespace
-{
- unsigned int base = 94;
- unsigned int start = 33;
-} // namespace
-
-const std::string encodeStr(unsigned int value, const unsigned int size)
-{
- std::string buf;
-
- do
- {
- buf += CAST_S8(value % base + start);
- value /= base;
- }
- while (value != 0u);
-
- while (buf.length() < size)
- buf += CAST_S8(start);
- return buf;
-}
-
-
-unsigned int decodeStr(const std::string &str)
-{
- if (str.empty())
- return 0;
-
- int res = str[0] - start;
- int mult = 1;
- for (unsigned int f = 1; f < str.length(); f ++)
- {
- mult *= base;
- res = res + (str[f] - start) * mult;
- }
- return res;
-}
-
-std::string extractNameFromSprite(std::string str)
-{
- const size_t pos1 = str.rfind('.');
- if (pos1 != std::string::npos)
- {
- size_t pos2 = str.rfind('/');
- const size_t pos3 = str.rfind('\\');
- if (pos3 != std::string::npos)
- {
- if (pos2 == std::string::npos || pos3 > pos2)
- pos2 = pos3;
- }
- if (pos2 == std::string::npos)
- pos2 = CAST_SIZE(-1);
-
- const int size = CAST_S32(pos1) - CAST_S32(pos2) - 1;
- if (size > 0)
- str = str.substr(pos2 + 1, size);
- }
- return str;
-}
-
-std::string removeSpriteIndex(std::string str)
-{
- const size_t pos1 = str.rfind('[');
-
- if (pos1 != std::string::npos)
- {
- size_t pos2 = str.rfind('/');
- const size_t pos3 = str.rfind('\\');
- if (pos3 != std::string::npos)
- {
- if (pos2 == std::string::npos || pos3 > pos2)
- pos2 = pos3;
- }
- if (pos2 == std::string::npos)
- pos2 = CAST_SIZE(-1);
-
- const int size = CAST_S32(pos1) - CAST_S32(pos2) - 1;
- if (size > 0)
- str = str.substr(pos2 + 1, size);
- }
- return str;
-}
-
-const char* getSafeUtf8String(const std::string &text)
-{
- const size_t sz = text.size();
- const size_t size = sz + UTF8_MAX_SIZE;
- char *const buf = new char[size];
- memcpy(buf, text.c_str(), sz);
- memset(buf + sz, 0, UTF8_MAX_SIZE);
- return buf;
-}
-
-void getSafeUtf8String(std::string text, char *const buf)
-{
- if (buf == nullptr)
- return;
- const size_t sz = text.size();
- const size_t size = sz + UTF8_MAX_SIZE;
- if (size > 65500)
- {
- text = text.substr(0, 65500);
- const size_t sz1 = text.size();
- memcpy(buf, text.c_str(), sz1);
- memset(buf + sz1, 0, UTF8_MAX_SIZE);
- }
- else
- {
- memcpy(buf, text.c_str(), sz);
- memset(buf + sz, 0, UTF8_MAX_SIZE);
- }
-}
-
-std::string getFileName(const std::string &path)
-{
- size_t pos1 = path.rfind('/');
- const size_t pos2 = path.rfind('\\');
- if (pos1 == std::string::npos)
- pos1 = pos2;
- else if (pos2 != std::string::npos && pos2 > pos1)
- pos1 = pos2;
-
- if (pos1 == std::string::npos)
- return path;
- return path.substr(pos1 + 1);
-}
-
-std::string getFileDir(const std::string &path)
-{
- size_t pos1 = path.rfind('/');
- const size_t pos2 = path.rfind('\\');
- if (pos1 == std::string::npos)
- pos1 = pos2;
- else if (pos2 != std::string::npos && pos2 > pos1)
- pos1 = pos2;
-
- if (pos1 == std::string::npos)
- return path;
- return path.substr(0, pos1);
-}
-
-std::string& replaceAll(std::string& context,
- const std::string &restrict from,
- const std::string &restrict to)
-{
- if (from.empty())
- return context;
- size_t lookHere = 0;
- size_t foundHere;
- const size_t fromSize = from.size();
- const size_t toSize = to.size();
- while ((foundHere = context.find(from, lookHere)) != std::string::npos)
- {
- context.replace(foundHere, fromSize, to);
- lookHere = foundHere + toSize;
- }
- return context;
-}
-
-void replaceRecursiveAll(std::string& context,
- const std::string &restrict from,
- const char to)
-{
- size_t lookHere = 0;
- size_t foundHere;
- const size_t fromSize = from.size();
- while ((foundHere = context.find(from, lookHere)) != std::string::npos)
- {
- context.replace(foundHere, fromSize, 1, to);
- lookHere = foundHere;
- }
-}
-
-bool getBoolFromString(const std::string &text)
-{
- std::string txt = text;
- toLower(trim(txt));
- if (txt == "true" || txt == "yes" || txt == "on" || txt == "1")
- return true;
- else if (txt == "false" || txt == "no" || txt == "off" || txt == "0")
- return false;
- else
- return static_cast<bool>(atoi(txt.c_str()));
-}
-
-void replaceSpecialChars(std::string &text)
-{
- size_t pos1 = text.find('&');
- while (pos1 != std::string::npos)
- {
- const size_t idx = pos1 + 1;
- const size_t sz = text.size();
- if (idx >= sz)
- break;
-
- size_t f;
- for (f = idx; f < sz; f ++)
- {
- if (text[f] < '0' || text[f] > '9')
- break;
- }
- if (idx + 1 < f && text[f] == ';')
- {
- std::string str(" ");
- str[0] = CAST_S8(atoi(text.substr(
- idx, f - idx).c_str()));
- text = text.substr(0, pos1).append(str).append(text.substr(f + 1));
- pos1 += 1;
- }
- else
- {
- pos1 = f + 1;
- }
-
- pos1 = text.find('&', pos1);
- }
-}
-
-std::string normalize(const std::string &name)
-{
- std::string normalized = name;
- return toLower(trim(normalized));
-}
-
-void splitToIntSet(std::set<int> &tokens,
- const std::string &text,
- const char separator)
-{
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- tokens.insert(atoi(item.c_str()));
-}
-
-std::list<int> splitToIntList(const std::string &text,
- const char separator)
-{
- std::list<int> tokens;
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- tokens.push_back(atoi(item.c_str()));
-
- return tokens;
-}
-
-std::list<std::string> splitToStringList(const std::string &text,
- const char separator)
-{
- std::list<std::string> tokens;
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- tokens.push_back(item);
-
- return tokens;
-}
-
-void splitToStringVector(StringVect &tokens,
- const std::string &text,
- const char separator)
-{
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- {
- item = trim(item);
- if (!item.empty())
- tokens.push_back(item);
- }
-}
-
-void splitToStringSet(std::set<std::string> &tokens,
- const std::string &text,
- const char separator)
-{
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- {
- item = trim(item);
- if (!item.empty())
- tokens.insert(item);
- }
-}
-
-void splitToIntVector(STD_VECTOR<int> &tokens,
- const std::string &text,
- const char separator)
-{
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- {
- item = trim(item);
- if (!item.empty())
- tokens.push_back(atoi(item.c_str()));
- }
-}
-
-std::string combineDye(std::string file,
- const std::string &dye)
-{
- if (dye.empty())
- return file;
- const size_t pos = file.find_last_of('|');
- if (pos != std::string::npos)
- return file.substr(0, pos).append("|").append(dye);
- return file.append("|").append(dye);
-}
-
-std::string combineDye2(std::string file,
- const std::string &dye)
-{
- if (dye.empty())
- return file;
-
- const size_t pos = file.find_last_of('|');
- if (pos != std::string::npos)
- {
- const std::string dye1 = file.substr(pos + 1);
- std::string str;
- file = file.substr(0, pos);
- const std::list<std::string> list1 = splitToStringList(dye1, ';');
- const std::list<std::string> list2 = splitToStringList(dye, ';');
- for (std::list<std::string>::const_iterator it1 = list1.begin(),
- it2 = list2.begin(), it1_end = list1.end(), it2_end = list2.end();
- it1 != it1_end && it2 != it2_end; ++it1, ++it2)
- {
- str.append(*it1).append(":").append(*it2).append(";");
- }
- return file.append("|").append(str);
- }
- return file;
-}
-
-std::string combineDye3(std::string file,
- const std::string &dye)
-{
- if (dye.empty())
- return file;
-
- const size_t pos = file.find_last_of('|');
- if (pos != std::string::npos)
- {
- const std::string dye1 = file.substr(pos + 1);
- std::string str;
- file = file.substr(0, pos);
- const std::list<std::string> list1 = splitToStringList(dye1, ';');
- const std::list<std::string> list2 = splitToStringList(dye, ';');
- for (std::list<std::string>::const_iterator it1 = list1.begin(),
- it2 = list2.begin(), it1_end = list1.end(), it2_end = list2.end();
- it1 != it1_end && it2 != it2_end; ++it1, ++it2)
- {
- str.append(*it1).append(":").append(*it2).append(";");
- }
- return file.append("|").append(str);
- }
- if (dye.empty() || file.empty())
- return file;
- return file.append("|").append(dye);
-}
-
-std::string packList(const std::list<std::string> &list)
-{
- std::list<std::string>::const_iterator i = list.begin();
- std::string str;
- while (i != list.end())
- {
- str.append(*i).append("|");
- ++ i;
- }
- const size_t sz = str.size();
- if (sz > 1)
- str = str.substr(0, sz - 1);
- return str;
-}
-
-std::list<std::string> unpackList(const std::string &str)
-{
- return splitToStringList(str, '|');
-}
-
-std::string stringToHexPath(const std::string &str)
-{
- if (str.empty())
- return "";
-
- std::string hex = strprintf("%%%2x/", CAST_U32(str[0]));
- for (unsigned f = 1, fsz = CAST_U32(str.size());
- f < fsz; f ++)
- {
- hex.append(strprintf("%%%2x", CAST_U32(str[f])));
- }
- return hex;
-}
-
-void deleteCharLeft(std::string &str,
- unsigned *const pos)
-{
- if (pos == nullptr)
- return;
-
- while (*pos > 0)
- {
- (*pos)--;
- const int v = str[*pos];
- str.erase(*pos, 1);
- if ((v & 192) != 128)
- break;
- }
-}
-
-bool findLast(const std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return false;
- if (str1.substr(s1 - s2) == str2)
- return true;
- return false;
-}
-
-bool findFirst(const std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return false;
- if (str1.substr(0, s2) == str2)
- return true;
- return false;
-}
-
-bool findCutLast(std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return false;
- if (str1.substr(s1 - s2) == str2)
- {
- str1 = str1.substr(0, s1 - s2);
- return true;
- }
- return false;
-}
-
-void cutLast(std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return;
- if (str1.substr(s1 - s2) == str2)
- str1 = str1.substr(0, s1 - s2);
-}
-
-bool findCutFirst(std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return false;
- if (str1.substr(0, s2) == str2)
- {
- str1 = str1.substr(s2);
- return true;
- }
- return false;
-}
-
-void cutFirst(std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return;
- if (str1.substr(0, s2) == str2)
- str1 = str1.substr(s2);
-}
-
-std::string &removeProtocol(std::string &url)
-{
- const size_t i = url.find("://");
- if (i != std::string::npos)
- url = url.substr(i + 3);
- return url;
-}
-
-bool strStartWith(const std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t sz2 = str2.size();
- if (str1.size() < sz2)
- return false;
- return str1.substr(0, sz2) == str2;
-}
-
-std::string getDateString()
-{
- char buffer[80];
- time_t rawtime;
- time(&rawtime);
- const tm *const timeinfo = localtime(&rawtime);
-
- strftime(buffer, 79, "%Y-%m-%d", timeinfo);
- return std::string(buffer);
-}
-
-std::string getDateTimeString()
-{
- char buffer[80];
- time_t rawtime;
- time(&rawtime);
- const tm *const timeinfo = localtime(&rawtime);
-
- strftime(buffer, 79, "%Y-%m-%d %H:%M:%S", timeinfo);
- return std::string(buffer);
-}
-
-signed char parseBoolean(const std::string &value)
-{
- std::string txt = value;
- toLower(trim(txt));
- if (txt == "true" || txt == "yes" || txt == "on" || txt == "1")
- return 1;
- else if (txt == "false" || txt == "no" || txt == "off" || txt == "0")
- return 0;
- else
- return -1;
-}
-
-std::string encodeLinkText(std::string data)
-{
- return replaceAll(data, "|", "\342\235\230");
-}
-
-std::string decodeLinkText(std::string data)
-{
- return replaceAll(data, "\342\235\230", "|");
-}
-
-std::string toStringPrint(const unsigned int val)
-{
- static char str[100];
- snprintf(str, sizeof(str), "%u 0x%x", val, val);
- str[99] = 0;
- return str;
-}
-
-std::string toString(uint32_t num)
-{
- char buf[30];
- buf[29] = '\0';
- size_t idx = 28;
- do
- buf[idx--] = CAST_8((num % 10) + '0');
- while ((num /= 10) != 0);
- return buf + idx + 1;
-}
-
-std::string toString(uint64_t num)
-{
- char buf[100];
- buf[99] = '\0';
- size_t idx = 98;
- do
- buf[idx--] = CAST_8((num % 10) + '0');
- while ((num /= 10) != 0);
- return buf + idx + 1;
-}
-
-std::string toString(uint16_t num)
-{
- char buf[10];
- buf[9] = '\0';
- size_t idx = 8;
- do
- buf[idx--] = CAST_8((num % 10) + '0');
- while ((num /= 10) != 0);
- return buf + idx + 1;
-}
-
-std::string toString(unsigned char num)
-{
- char buf[5];
- buf[4] = '\0';
- size_t idx = 3;
- do
- buf[idx--] = CAST_8((num % 10) + '0');
- while ((num /= 10) != 0);
- return buf + idx + 1;
-}
-
-std::string toString(int32_t num)
-{
- char buf[30];
- bool useSign(false);
- buf[29] = '\0';
- size_t idx = 28;
-
- if (num < 0)
- {
- useSign = true;
- num = -num;
- }
- do
- buf[idx--] = CAST_8((num % 10) + '0');
- while ((num /= 10) != 0);
- if (useSign)
- buf[idx--] = '-';
- return buf + idx + 1;
-}
-
-std::string toString(const float num)
-{
- return strprintf("%f", num);
-}
-
-std::string toString(const double num)
-{
- return strprintf("%f", static_cast<float>(num));
-}
-
-bool isDigit(const std::string &str)
-{
- if (str.empty())
- return false;
- const size_t sz = str.size();
- for (size_t f = 0; f < sz; f ++)
- {
- const char &chr = str[f];
- if (chr < '0' || chr > '9')
- return false;
- }
- return true;
-}
-
-void secureChatCommand(std::string &str)
-{
- if (str[0] == '/' || str[0] == '@' || str[0] == '#')
- str = "_" + str;
-}
-
-bool parse2Int(const std::string &args,
- int &x,
- int &y)
-{
- bool isValid = false;
- size_t pos = args.find(' ');
- if (pos == std::string::npos)
- pos = args.find(',');
- if (pos != std::string::npos)
- {
- if (pos + 1 < args.length())
- {
- x = atoi(args.substr(0, pos).c_str());
- y = atoi(args.substr(pos + 1, args.length()).c_str());
- isValid = true;
- }
- }
- return isValid;
-}
-
-bool parse2Str(const std::string &args,
- std::string &str1,
- std::string &str2)
-{
- bool isValid = false;
- size_t pos = args.find(' ');
- if (pos == std::string::npos)
- pos = args.find(',');
- if (pos != std::string::npos)
- {
- if (pos + 1 < args.length())
- {
- str1 = args.substr(0, pos);
- str2 = args.substr(pos + 1, args.length());
- isValid = true;
- }
- }
- return isValid;
-}
-
-uint32_t parseNumber(const std::string &str)
-{
- uint32_t i = 0;
- int idx = 0;
- if (strStartWith(str, "0x"))
- idx = 2;
- else if (str[0] == 'h' || str[0] == 'x')
- idx = 1;
- if (idx > 0)
- sscanf(str.substr(idx).c_str(), "%10x", &i);
- else
- i = atoi(str.c_str());
- return i;
-}
-
-std::string removeToken(std::string &str,
- const std::string &token)
-{
- const size_t idx = str.find(token);
- if (idx > 0 && idx != std::string::npos)
- str = str.substr(idx + 1);
- else
- str.clear();
- return str;
-}
-
-std::string timeToStr(const uint32_t time)
-{
- char buf[101];
- const time_t tempTime = time;
- tm *const timeInfo = localtime(&tempTime);
- if (strftime(&buf[0], 100, "%Y-%m-%d_%H-%M-%S", timeInfo) != 0u)
- return std::string(buf);
- return "unknown";
-}
-
-std::string timeDiffToString(int timeDiff)
-{
- std::string str;
-
- const int weeks = timeDiff / 60 / 60 / 24 / 7;
- if (weeks > 0)
- {
- // TRANSLATORS: uptime command
- str = strprintf(ngettext(N_("%d week"), N_("%d weeks"),
- weeks), weeks);
- timeDiff -= weeks * 60 * 60 * 24 * 7;
- }
-
- const int days = timeDiff / 60 / 60 / 24;
- if (days > 0)
- {
- if (!str.empty())
- str.append(", ");
- // TRANSLATORS: uptime command
- str.append(strprintf(ngettext(N_("%d day"), N_("%d days"),
- days), days));
- timeDiff -= days * 60 * 60 * 24;
- }
- const int hours = timeDiff / 60 / 60;
- if (hours > 0)
- {
- if (!str.empty())
- str.append(", ");
- // TRANSLATORS: uptime command
- str.append(strprintf(ngettext(N_("%d hour"), N_("%d hours"),
- hours), hours));
- timeDiff -= hours * 60 * 60;
- }
- const int min = timeDiff / 60;
- if (min > 0)
- {
- if (!str.empty())
- str.append(", ");
- // TRANSLATORS: uptime command
- str.append(strprintf(ngettext(N_("%d minute"), N_("%d minutes"),
- min), min));
- timeDiff -= min * 60;
- }
-
- if (timeDiff > 0)
- {
- if (!str.empty())
- str.append(", ");
- // TRANSLATORS: uptime command
- str.append(strprintf(ngettext(N_("%d second"), N_("%d seconds"),
- timeDiff), timeDiff));
- }
- if (str.empty())
- {
- // TRANSLATORS: uptime command
- str.append(strprintf(ngettext(N_("%d second"), N_("%d seconds"),
- 0), 0));
- }
- return str;
-}
-
-std::string escapeString(std::string str)
-{
- replaceAll(str, "\"", "\\\"");
- return "\"" + str + "\"";
-}
-
-void sanitizePath(std::string &path)
-{
-#ifdef WIN32
- const char sepStr = '\\';
- const std::string sep2Str = "\\\\";
- const std::string sepWrongStr = "/";
-#else
- const char sepStr = '/';
- const std::string sep2Str = "//";
- const std::string sepWrongStr = "\\";
-#endif
- replaceRecursiveAll(path, sepWrongStr, sepStr);
- replaceRecursiveAll(path, sep2Str, sepStr);
-}
-
-std::string pathJoin(std::string str1,
- const std::string &str2)
-{
-#ifdef WIN32
- const char sep = '\\';
- std::string sepStr = "\\";
-#else
- const char sep = '/';
- std::string sepStr = "/";
-#endif
-
- if (str1.empty())
- {
- if (str2[0] == sep)
- return str2;
- return sepStr.append(str2);
- }
- const size_t sz1 = str1.size();
- if (str2.empty())
- {
- if (str1[sz1 - 1] == sep)
- return str1;
- return str1.append(sepStr);
- }
- if (str1[sz1 - 1] == sep)
- {
- if (str2[0] == sep)
- return str1.append(str2.substr(1));
- return str1.append(str2);
- }
- else
- {
- if (str2[0] == sep)
- return str1.append(str2);
- return str1.append(sepStr).append(str2);
- }
-}
-
-std::string pathJoin(std::string str1,
- const std::string &str2,
- const std::string &str3)
-{
-#ifdef WIN32
- const char sep = '\\';
- std::string sepStr = "\\";
-#else
- const char sep = '/';
- std::string sepStr = "/";
-#endif
-
- if (str1.empty())
- {
- return pathJoin(str2, str3);
- }
- size_t sz1 = str1.size();
- if (str2.empty())
- {
- return pathJoin(str1, str3);
- }
- if (str3.empty())
- {
- return pathJoin(str1, str2);
- }
- if (str1[sz1 - 1] == sep)
- {
- if (str2[0] == sep)
- str1.append(str2.substr(1));
- else
- str1.append(str2);
- }
- else
- {
- if (str2[0] == sep)
- str1.append(str2);
- else
- str1.append(sepStr).append(str2);
- }
-
- sz1 = str1.size();
- if (str1[sz1 - 1] == sep)
- {
- if (str3[0] == sep)
- return str1.append(str3.substr(1));
- return str1.append(str3);
- }
- else
- {
- if (str3[0] == sep)
- return str1.append(str3);
- return str1.append(sepStr).append(str3);
- }
-}
-
-std::string urlJoin(std::string str1,
- const std::string &str2)
-{
- const char sep = '/';
- std::string sepStr = "/";
-
- if (str1.empty())
- {
- if (str2[0] == sep)
- return str2;
- return sepStr.append(str2);
- }
- const size_t sz1 = str1.size();
- if (str2.empty())
- {
- if (str1[sz1 - 1] == sep)
- return str1;
- return str1.append(sepStr);
- }
- if (str1[sz1 - 1] == sep)
- {
- if (str2[0] == sep)
- return str1.append(str2.substr(1));
- return str1.append(str2);
- }
- else
- {
- if (str2[0] == sep)
- return str1.append(str2);
- return str1.append(sepStr).append(str2);
- }
-}
-
-#ifndef DYECMD
-void replaceItemLinks(std::string &msg)
-{
- // Check for item link
- size_t start2 = msg.find('[');
- size_t sz = msg.size();
- while (start2 + 1 < sz &&
- start2 != std::string::npos &&
- msg[start2 + 1] != '@')
- {
- const size_t end = msg.find(']', start2);
- if (start2 + 1 != end &&
- end != std::string::npos)
- {
- // Catch multiple embeds and ignore them
- // so it doesn't crash the client.
- while ((msg.find('[', start2 + 1) != std::string::npos) &&
- (msg.find('[', start2 + 1) < end))
- {
- start2 = msg.find('[', start2 + 1);
- }
-
- if (start2 + 1 < sz &&
- end < sz &&
- end > start2 + 1)
- {
- std::string itemStr = msg.substr(start2 + 1, end - start2 - 1);
-
- StringVect parts;
- splitToStringVector(parts, itemStr, ',');
- if (parts.empty())
- return;
-
- const ItemInfo &itemInfo = ItemDB::get(parts[0]);
- const int itemId = itemInfo.getId();
- if (itemId != 0)
- {
- std::string temp = strprintf("@@%d", itemId);
- std::string name = parts[0];
- msg.erase(start2 + 1, end - start2 - 1);
- parts.erase(parts.begin());
- if (!parts.empty())
- name.clear();
-
- FOR_EACH (StringVectCIter, it, parts)
- {
- std:: string str = *it;
- trim(str);
- const ItemInfo &itemInfo2 = ItemDB::get(str);
- const int cardId = itemInfo2.getId();
- if (cardId != 0)
- temp.append(strprintf(",%d", cardId));
- }
- temp.append("|");
- temp.append(name);
- temp.append("@@");
- msg.insert(start2 + 1, temp);
- sz = msg.size();
- }
- }
- }
- start2 = msg.find('[', start2 + 1);
- }
-}
-#else // DYECMD
-
-void replaceItemLinks(std::string &msg A_UNUSED)
-{
-}
-#endif // DYECMD
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
deleted file mode 100644
index 1b93c41d7..000000000
--- a/src/utils/stringutils.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007-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 UTILS_STRINGUTILS_H
-#define UTILS_STRINGUTILS_H
-
-#include "utils/stringvector.h"
-
-#include <list>
-#include <set>
-
-#include "localconsts.h"
-
-/**
- * Trims spaces off the end and the beginning of the given string.
- *
- * @param str the string to trim spaces off
- * @return a reference to the trimmed string
- */
-std::string &trim(std::string &str);
-
-/**
- * Converts the given string to lower case.
- *
- * @param str the string to convert to lower case
- * @return a reference to the given string converted to lower case
- */
-std::string &toLower(std::string &str);
-
-/**
- * Converts the given string to upper case.
- *
- * @param str the string to convert to upper case
- * @return a reference to the given string converted to upper case
- */
-std::string &toUpper(std::string &str);
-
-
-/**
- * Converts an ascii hexidecimal string to an integer
- *
- * @param str the hex string to convert to an int
- * @return the integer representation of the hex string
- */
-unsigned int atox(const std::string &str) A_WARN_UNUSED;
-
-/**
- * Converts the given value to a string.
- *
- * @param num the value to convert to a string
- * @return the string representation of arg
- */
-std::string toString(uint32_t num);
-
-std::string toString(uint64_t num);
-
-std::string toString(unsigned char num);
-
-std::string toString(int32_t num);
-
-std::string toString(uint16_t num);
-
-std::string toString(const float num);
-
-std::string toString(const double num);
-
-std::string toStringPrint(const unsigned int val);
-
-/**
- * Converts the given IP address to a string.
- *
- * The returned string is statically allocated, and shouldn't be freed. It is
- * changed upon the next use of this method.
- *
- * @param address the address to convert to a string
- * @return the string representation of the address
- */
-const char *ipToString(const uint32_t address) A_WARN_UNUSED;
-
-/**
- * A safe version of sprintf that returns a std::string of the result.
- */
-std::string strprintf(const char *const format, ...) A_NONNULL(1) A_WARN_UNUSED
-#ifdef __GNUC__
-#ifdef __OpenBSD__
- __attribute__((__format__(printf, 1, 2)))
-#else // __OpenBSD__
- __attribute__((__format__(gnu_printf, 1, 2)))
-#endif // __OpenBSD__
-#endif // __GNUC__
-;
-
-/**
- * Removes colors from a string
- *
- * @param msg the string to remove the colors from
- * @return string without colors
- */
-std::string removeColors(std::string msg) A_WARN_UNUSED;
-
-const std::string findSameSubstring(const std::string &restrict str1,
- const std::string &restrict str2);
-
-const std::string findSameSubstringI(const std::string &restrict str1,
- const std::string &restrict str2);
-
-/**
- * Compares the two strings case-insensitively.
- *
- * @param a the first string in the comparison
- * @param b the second string in the comparison
- * @return 0 if the strings are equal, positive if the first is greater,
- * negative if the second is greater
- */
-int compareStrI(const std::string &a, const std::string &b) A_WARN_UNUSED;
-
-/**
- * Tells wether the character is a word separator.
- */
-bool isWordSeparator(const signed char chr) A_CONST A_WARN_UNUSED;
-
-size_t findI(std::string str, std::string subStr) A_WARN_UNUSED;
-
-size_t findI(std::string text, const StringVect &list) A_WARN_UNUSED;
-
-size_t findAny(const std::string &restrict text,
- const std::string &restrict chars,
- const size_t pos) A_WARN_UNUSED;
-
-const std::string encodeStr(unsigned int value,
- const unsigned int size = 0) A_WARN_UNUSED;
-
-unsigned int decodeStr(const std::string &str) A_WARN_UNUSED;
-
-std::string extractNameFromSprite(std::string str) A_WARN_UNUSED;
-
-std::string removeSpriteIndex(std::string str) A_WARN_UNUSED;
-
-const char* getSafeUtf8String(const std::string &text) A_WARN_UNUSED;
-
-void getSafeUtf8String(std::string text, char *const buf);
-
-std::string getFileName(const std::string &path) A_WARN_UNUSED;
-
-std::string getFileDir(const std::string &path) A_WARN_UNUSED;
-
-std::string& replaceAll(std::string& context,
- const std::string &restrict from,
- const std::string &restrict to);
-
-void replaceRecursiveAll(std::string& context,
- const std::string &restrict from,
- const char to);
-
-/**
- * Returns a bool value depending on the given string value.
- *
- * @param text the string used to get the bool value
- * @return a boolean value..
- */
-bool getBoolFromString(const std::string &text) A_WARN_UNUSED;
-
-void replaceSpecialChars(std::string &text);
-
-/**
- * Normalize a string, which means lowercase and trim it.
- */
-std::string normalize(const std::string &name) A_WARN_UNUSED;
-
-void splitToIntSet(std::set<int> &tokens, const std::string &text,
- const char separator);
-
-std::list<int> splitToIntList(const std::string &text,
- const char separator) A_WARN_UNUSED;
-
-std::list<std::string> splitToStringList(const std::string &text,
- const char separator) A_WARN_UNUSED;
-
-void splitToStringVector(StringVect &tokens,
- const std::string &text, const char separator);
-
-void splitToStringSet(std::set<std::string> &tokens,
- const std::string &text, const char separator);
-
-void splitToIntVector(STD_VECTOR<int> &tokens,
- const std::string &text, const char separator);
-
-std::string combineDye(std::string file, const std::string &dye) A_WARN_UNUSED;
-
-std::string combineDye2(std::string file,
- const std::string &dye) A_WARN_UNUSED;
-
-std::string combineDye3(std::string file,
- const std::string &dye) A_WARN_UNUSED;
-
-std::string packList(const std::list<std::string> &list) A_WARN_UNUSED;
-
-std::list<std::string> unpackList(const std::string &str) A_WARN_UNUSED;
-
-std::string stringToHexPath(const std::string &str) A_WARN_UNUSED;
-
-void deleteCharLeft(std::string &str, unsigned *const pos);
-
-bool findLast(const std::string &restrict str1,
- const std::string &restrict str2) A_WARN_UNUSED;
-
-bool findFirst(const std::string &restrict str1,
- const std::string &restrict str2) A_WARN_UNUSED;
-
-bool findCutLast(std::string &restrict str1,
- const std::string &restrict str2) A_WARN_UNUSED;
-
-void cutLast(std::string &restrict str1,
- const std::string &restrict str2);
-
-bool findCutFirst(std::string &restrict str1,
- const std::string &restrict str2);
-
-void cutFirst(std::string &restrict str1,
- const std::string &restrict str2);
-
-std::string &removeProtocol(std::string &url);
-
-bool strStartWith(const std::string &restrict str,
- const std::string &restrict start) A_WARN_UNUSED;
-
-std::string getDateString() A_WARN_UNUSED;
-
-std::string getDateTimeString() A_WARN_UNUSED;
-
-signed char parseBoolean(const std::string &value);
-
-std::string encodeLinkText(std::string data);
-
-std::string decodeLinkText(std::string data);
-
-bool isDigit(const std::string &str);
-
-void secureChatCommand(std::string &str);
-
-bool parse2Int(const std::string &args, int &x, int &y);
-
-bool parse2Str(const std::string &args, std::string &str1, std::string &str2);
-
-uint32_t parseNumber(const std::string &str);
-
-std::string removeToken(std::string &str, const std::string &token);
-
-std::string timeToStr(const uint32_t time);
-
-std::string timeDiffToString(int timeDiff);
-
-void replaceItemLinks(std::string &msg);
-
-std::string escapeString(std::string str);
-
-void sanitizePath(std::string &path);
-
-std::string pathJoin(std::string str1,
- const std::string &str2);
-
-std::string pathJoin(std::string str1,
- const std::string &str2,
- const std::string &str3);
-
-std::string urlJoin(std::string str1,
- const std::string &str2);
-
-#endif // UTILS_STRINGUTILS_H
diff --git a/src/utils/stringvector.h b/src/utils/stringvector.h
deleted file mode 100644
index 18a53881c..000000000
--- a/src/utils/stringvector.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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 UTILS_STRINGVECTOR_H
-#define UTILS_STRINGVECTOR_H
-
-#include "utils/vector.h"
-
-#include <string>
-
-typedef STD_VECTOR<std::string> StringVect;
-typedef StringVect::iterator StringVectIter;
-typedef StringVect::const_iterator StringVectCIter;
-
-#endif // UTILS_STRINGVECTOR_H
diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp
deleted file mode 100644
index 21ef307ba..000000000
--- a/src/utils/timer.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * The ManaPlus Client
- * 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/>.
- */
-
-#include "utils/timer.h"
-
-#include "const/utils/timer.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_timer.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include <climits>
-
-#include "debug.h"
-
-namespace
-{
-#ifdef USE_SDL2
- SDL_TimerID mLogicCounterId(0);
- SDL_TimerID mSecondsCounterId(0);
-#else // USE_SDL2
-
- SDL_TimerID mLogicCounterId(nullptr);
- SDL_TimerID mSecondsCounterId(nullptr);
-#endif // USE_SDL2
-} // namespace
-
-/**
- * Tells the max tick value,
- * setting it back to zero (and start again).
- */
-static const int MAX_TICK_VALUE = INT_MAX / 2;
-
-volatile int tick_time; /**< Tick counter */
-volatile int fps = 0; /**< Frames counted in the last second */
-volatile int lps = 0; /**< Logic processed per second */
-volatile int frame_count = 0; /**< Counts the frames during one second */
-volatile int logic_count = 0; /**< Counts the logic during one second */
-volatile time_t cur_time = 0;
-
-static uint32_t nextTick(uint32_t interval, void *param A_UNUSED);
-static uint32_t nextSecond(uint32_t interval, void *param A_UNUSED);
-
-/**
- * Advances game logic counter.
- * Called every 10 milliseconds by SDL_AddTimer()
- * @see MILLISECONDS_IN_A_TICK value
- */
-static uint32_t nextTick(uint32_t interval, void *param A_UNUSED)
-{
- tick_time++;
- if (tick_time == MAX_TICK_VALUE)
- tick_time = 0;
- return interval;
-}
-
-/**
- * Updates fps.
- * Called every seconds by SDL_AddTimer()
- */
-static uint32_t nextSecond(uint32_t interval, void *param A_UNUSED)
-{
- fps = frame_count;
- lps = logic_count;
- frame_count = 0;
- logic_count = 0;
-
- return interval;
-}
-
-/**
- * @return the elapsed time in milliseconds
- * between two tick values.
- */
-int get_elapsed_time(const int startTime)
-{
- const int time = tick_time;
- if (startTime <= time)
- {
- return (time - startTime) * MILLISECONDS_IN_A_TICK;
- }
- return (time + (MAX_TICK_VALUE - startTime))
- * MILLISECONDS_IN_A_TICK;
-}
-
-int get_elapsed_time1(const int startTime)
-{
- const int time = tick_time;
- if (startTime <= time)
- return time - startTime;
- return time + (MAX_TICK_VALUE - startTime);
-}
-
-void startTimers()
-{
- // Initialize logic and seconds counters
- tick_time = 0;
- mLogicCounterId = SDL_AddTimer(MILLISECONDS_IN_A_TICK, nextTick, nullptr);
- mSecondsCounterId = SDL_AddTimer(1000, nextSecond, nullptr);
-}
-
-void stopTimers()
-{
- SDL_RemoveTimer(mLogicCounterId);
- SDL_RemoveTimer(mSecondsCounterId);
-}
diff --git a/src/utils/timer.h b/src/utils/timer.h
deleted file mode 100644
index ea1d21e31..000000000
--- a/src/utils/timer.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_TIMER_H
-#define UTILS_TIMER_H
-
-#include "localconsts.h"
-
-extern volatile int fps;
-extern volatile int lps;
-extern volatile int tick_time;
-extern volatile time_t cur_time;
-extern volatile int frame_count;
-extern volatile int logic_count;
-
-void startTimers();
-
-void stopTimers();
-
-/**
- * Returns elapsed time. (Warning: supposes the delay is always < 100 seconds)
- */
-int get_elapsed_time(const int startTime) A_WARN_UNUSED;
-
-int get_elapsed_time1(const int startTime) A_WARN_UNUSED;
-
-#endif // UTILS_TIMER_H
diff --git a/src/utils/translation/podict.cpp b/src/utils/translation/podict.cpp
deleted file mode 100644
index cd374319f..000000000
--- a/src/utils/translation/podict.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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/>.
- */
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-std::string empty;
-
-PoDict *translator = nullptr;
-PoDict *dictionary = nullptr;
-PoDict *reverseDictionary = nullptr;
-#ifdef ENABLE_CUSTOMNLS
-PoDict *mainTranslator = nullptr;
-#endif // ENABLE_CUSTOMNLS
-
-PoDict::PoDict(const std::string &lang) :
- mPoLines(),
- mLang(lang)
-{
-}
-
-PoDict::~PoDict()
-{
-}
-
-const std::string PoDict::getStr(const std::string &str)
-{
- if (mPoLines.find(str) == mPoLines.end())
- return str;
- return mPoLines[str];
-}
-
-const char *PoDict::getChar(const char *const str)
-{
- if (mPoLines.find(str) == mPoLines.end())
- return str;
- return mPoLines[str].c_str();
-}
-
-bool PoDict::haveStr(const std::string &str) const
-{
- return mPoLines.find(str) != mPoLines.end();
-}
diff --git a/src/utils/translation/podict.h b/src/utils/translation/podict.h
deleted file mode 100644
index d8f47b896..000000000
--- a/src/utils/translation/podict.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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 UTILS_TRANSLATION_PODICT_H
-#define UTILS_TRANSLATION_PODICT_H
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-typedef std::map <std::string, std::string> PoMap;
-
-class PoDict final
-{
- public:
- explicit PoDict(const std::string &lang);
-
- A_DELETE_COPY(PoDict)
-
- ~PoDict();
-
- const std::string getStr(const std::string &str);
-
- const char *getChar(const char *const str);
-
- bool haveStr(const std::string &str) const;
-
-#ifndef UNITTESTS
- protected:
-#endif // UNITTESTS
- friend class PoParser;
- friend class TranslationManager;
-
- PoMap *getMap()
- { return &mPoLines; }
-
- void set(const std::string &key, const std::string &value)
- { mPoLines[key] = value; }
-
- void setLang(const std::string &lang)
- { mLang = lang; }
-
- private:
- PoMap mPoLines;
- std::string mLang;
-};
-
-extern PoDict *translator;
-extern PoDict *dictionary;
-extern PoDict *reverseDictionary;
-#ifdef ENABLE_CUSTOMNLS
-extern PoDict *mainTranslator;
-#endif // ENABLE_CUSTOMNLS
-
-#endif // UTILS_TRANSLATION_PODICT_H
diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp
deleted file mode 100644
index 399980a21..000000000
--- a/src/utils/translation/poparser.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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/>.
- */
-
-#include "utils/translation/poparser.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "logger.h"
-
-#include "debug.h"
-
-PoParser::PoParser() :
- mLang(),
- mFile(),
- mLine(),
- mMsgId(),
- mMsgStr(),
- mDict(nullptr),
- mReadingId(false),
- mReadingStr(false),
- mSkipId(false)
-{
-}
-
-void PoParser::openFile(const std::string &name)
-{
- int size;
- const char *buf = VirtFs::loadFile(getFileName(name), size);
-
- if (buf != nullptr)
- {
- mFile.str(std::string(buf, size));
- delete [] buf;
- }
- else
- {
- mFile.clear();
- }
-}
-
-PoDict *PoParser::load(const std::string &restrict lang,
- const std::string &restrict fileName,
- PoDict *restrict const dict)
-{
- logger->log("loading lang: %s, file: %s", lang.c_str(), fileName.c_str());
-
- setLang(lang);
- if (dict == nullptr)
- mDict = getDict();
- else
- mDict = dict;
-
- if (fileName.empty())
- openFile(mLang);
- else
- openFile(fileName);
-
- mMsgId.clear();
- mMsgStr.clear();
-
- // cycle by msgid+msgstr
- while (readLine())
- {
- // reading msgid
- while (readMsgId())
- {
- if (!readLine())
- break;
- }
-
- if (!mMsgId.empty())
- {
- // if we got msgid then reading msgstr
- while (readMsgStr())
- {
- if (!readLine())
- break;
- }
- }
-
- if (!mMsgId.empty() && !mMsgStr.empty())
- {
-// logger->log("add key: " + mMsgId);
-// logger->log("add value: " + mMsgStr);
-
- convertStr(mMsgId);
- convertStr(mMsgStr);
- // store key and value
- mDict->set(mMsgId, mMsgStr);
- }
-
- mMsgId.clear();
- mMsgStr.clear();
- }
-
- return mDict;
-}
-
-bool PoParser::readLine()
-{
- char line[1001];
- if (!mFile.getline(line, 1000))
- return false;
- // skip plurals msgid if present
- if (strStartWith(line, "msgid_plural \""))
- {
- if (!mFile.getline(line, 1000))
- return false;
- }
- mLine = line;
- return true;
-}
-
-bool PoParser::readMsgId()
-{
- // if we reading msgstr then stop here
- if (mReadingStr)
- return false;
-
- const std::string msgId1("msgid \"");
-
- // check if in reading process
- if (mReadingId)
- {
- // if we get empty line in file then stop reading
- if (mLine.empty())
- {
- mReadingId = false;
- return false;
- }
- else if (checkLine())
- {
- // reading text from: "text"
- mMsgId.append(mLine.substr(1, mLine.size() - 2));
- mLine.clear();
- return true;
- }
- // stop reading in other case
- mReadingId = false;
- return false;
- }
-
- // check line start from msgid "
- if (strStartWith(mLine, msgId1))
- {
- if (!mSkipId)
- { // translation not fuzzed and can be processed
- mReadingId = true;
- const size_t msgId1Size = msgId1.size();
- // reading text from: msgid "text"
- mMsgId.append(mLine.substr(msgId1Size,
- mLine.size() - 1 - msgId1Size));
- }
- else
- { // skipped fuzzed translation. reset skip flag
- mSkipId = false;
- }
- mLine.clear();
- return true;
- }
- else if (mLine == "#, fuzzy")
- { // check for fuzzy translation
- mSkipId = true;
- mLine.clear();
- return true;
- }
- // stop reading if we don't read msgid before
- return mMsgId.empty();
-}
-
-bool PoParser::readMsgStr()
-{
- // normal msgstr
- const std::string msgStr1("msgstr \"");
- // plurals first msgstr
- const std::string msgStr2("msgstr[0] \"");
-
- // check if in reading process
- if (mReadingStr)
- {
- // if we get empty line in file then stop reading
- if (mLine.empty())
- {
- mReadingStr = false;
- return false;
- }
- if (checkLine())
- {
- // reading text from: "text"
- mMsgStr.append(mLine.substr(1, mLine.size() - 2));
- mLine.clear();
- return true;
- }
- // stop reading in other case
- mReadingStr = false;
- }
- else
- {
- // check line start from msgstr "
- if (strStartWith(mLine, msgStr1))
- {
- mReadingStr = true;
- const size_t msgStr1Size = msgStr1.size();
- // reading text from: msgstr "text"
- mMsgStr.append(mLine.substr(msgStr1Size,
- mLine.size() - 1 - msgStr1Size));
- mLine.clear();
- return true;
- }
- // checl list start from msgstr[0] "
- else if (strStartWith(mLine, msgStr2))
- {
- mReadingStr = true;
- const size_t msgStr2Size = msgStr2.size();
- // reading text from: msgstr[0] "text"
- mMsgStr.append(mLine.substr(msgStr2Size,
- mLine.size() - 1 - msgStr2Size));
- mLine.clear();
- return true;
- }
- }
-
- // stop reading in other case
- return false;
-}
-
-bool PoParser::checkLine() const
-{
- const size_t sz = mLine.size();
- // check is line in format: "text"
- return sz > 2 && mLine[0] == '\"' && mLine[sz - 1] == '\"';
-}
-
-PoDict *PoParser::getEmptyDict()
-{
- return new PoDict("");
-}
-
-bool PoParser::checkLang(const std::string &lang)
-{
- // check is po file exists
- return VirtFs::exists(getFileName(lang));
-}
-
-std::string PoParser::getFileName(const std::string &lang)
-{
- // get po file name from lang name
-// logger->log("getFileName: translations/%s.po", lang.c_str());
- return strprintf("translations/%s.po", lang.c_str());
-}
-
-PoDict *PoParser::getDict() const
-{
- return new PoDict(mLang);
-}
-
-void PoParser::convertStr(std::string &str)
-{
- if (str.empty())
- return;
-
- replaceAll(str, "\\n", "\n");
- replaceAll(str, "\\\"", "\"");
- replaceAll(str, "\\\\", "\\");
-}
diff --git a/src/utils/translation/poparser.h b/src/utils/translation/poparser.h
deleted file mode 100644
index 9f6fd7d35..000000000
--- a/src/utils/translation/poparser.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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 UTILS_TRANSLATION_POPARSER_H
-#define UTILS_TRANSLATION_POPARSER_H
-
-#include "localconsts.h"
-
-#include <sstream>
-
-class PoDict;
-
-class PoParser final
-{
- public:
- PoParser();
-
- A_DELETE_COPY(PoParser)
-
- PoDict *load(const std::string &restrict lang,
- const std::string &restrict fileName = "",
- PoDict *restrict const dict = nullptr);
-
- static bool checkLang(const std::string &lang);
-
- static PoDict *getEmptyDict();
-
- private:
- void setLang(const std::string &lang)
- { mLang = lang; }
-
- void openFile(const std::string &name);
-
- bool readLine();
-
- bool readMsgId();
-
- bool readMsgStr();
-
- bool checkLine() const;
-
- static std::string getFileName(const std::string &lang);
-
- PoDict *getDict() const RETURNS_NONNULL A_WARN_UNUSED;
-
- static void convertStr(std::string &str);
-
- // current lang
- std::string mLang;
-
- // po file object
- std::istringstream mFile;
-
- // current line from po file
- std::string mLine;
-
- std::string mMsgId;
-
- std::string mMsgStr;
-
- PoDict *mDict;
-
- bool mReadingId;
-
- bool mReadingStr;
-
- bool mSkipId;
-};
-
-#endif // UTILS_TRANSLATION_POPARSER_H
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
deleted file mode 100644
index d02ff2c02..000000000
--- a/src/utils/translation/translationmanager.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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/>.
- */
-
-#include "utils/translation/translationmanager.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/delete2.h"
-#include "utils/stringutils.h"
-
-#include "utils/foreach.h"
-
-#include "utils/translation/podict.h"
-#include "utils/translation/poparser.h"
-
-#include "logger.h"
-
-#include "debug.h"
-
-void TranslationManager::init()
-{
- delete translator;
- translator = PoParser::getEmptyDict();
-}
-
-void TranslationManager::loadCurrentLang()
-{
- delete translator;
- translator = loadLang(getLang(), "");
- translator = loadLang(getLang(), "help/", translator);
-}
-
-void TranslationManager::loadDictionaryLang()
-{
- delete dictionary;
- delete reverseDictionary;
- dictionary = loadLang(getServerLang(), "dict/");
- reverseDictionary = reverseLang(dictionary);
-}
-
-#ifdef ENABLE_CUSTOMNLS
-void TranslationManager::loadGettextLang()
-{
- delete mainTranslator;
- mainTranslator = loadLang(getLang(), "manaplus/");
-}
-#endif // ENABLE_CUSTOMNLS
-
-void TranslationManager::close()
-{
- delete2(translator);
- delete2(dictionary);
- delete2(reverseDictionary);
-}
-
-PoDict *TranslationManager::loadLang(const LangVect &lang,
- const std::string &subName,
- PoDict *const dict)
-{
- std::string name;
- PoParser parser;
-
- FOR_EACH (LangIter, it, lang)
- {
- if (*it == "C")
- continue;
-
-// logger->log("check file: " + subName + *it);
- if (PoParser::checkLang(subName + *it))
- {
- name = *it;
- break;
- }
- }
- if (!name.empty())
- return parser.load(name, subName + name, dict);
- logger->log("can't find client data translation");
- if (dict != nullptr)
- return dict;
- return PoParser::getEmptyDict();
-}
-
-bool TranslationManager::translateFile(const std::string &fileName,
- PoDict *const dict,
- StringVect &lines)
-{
- if ((dict == nullptr) || fileName.empty())
- return false;
-
- int contentsLength;
- const char *fileContents = VirtFs::loadFile(fileName,
- contentsLength);
-
- if (fileContents == nullptr)
- {
- logger->log("Couldn't load file: %s", fileName.c_str());
- return false;
- }
- std::string str = std::string(fileContents, contentsLength);
-
- size_t oldPos1 = std::string::npos;
- size_t pos1;
-
- while ((pos1 = str.find("<<")) != std::string::npos)
- {
- if (pos1 == oldPos1)
- break; // detected infinite loop
- const size_t pos2 = str.find(">>", pos1 + 2);
- if (pos2 == std::string::npos)
- break;
- const std::string key(str.substr(pos1 + 2, pos2 - pos1 - 2));
- const std::string key2("<<" + str.substr(
- pos1 + 2, pos2 - pos1 - 2) + ">>");
- const std::string val(dict->getStr(key));
- replaceAll(str, key2, val);
- oldPos1 = pos1;
- }
-
- std::istringstream iss(str);
- std::string line;
-
- while (getline(iss, line))
- lines.push_back(line);
-
- delete [] fileContents;
- return true;
-}
-
-PoDict *TranslationManager::reverseLang(const PoDict *const dict)
-{
- PoDict *const revDict = new PoDict(dict->mLang);
- FOR_EACH (PoMap::const_iterator, it, dict->mPoLines)
- {
- revDict->set((*it).second, (*it).first);
- }
- return revDict;
-}
diff --git a/src/utils/translation/translationmanager.h b/src/utils/translation/translationmanager.h
deleted file mode 100644
index 088d97449..000000000
--- a/src/utils/translation/translationmanager.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2012-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 UTILS_TRANSLATION_TRANSLATIONMANAGER_H
-#define UTILS_TRANSLATION_TRANSLATIONMANAGER_H
-
-#include "localconsts.h"
-
-#include "utils/langs.h"
-#include "utils/stringvector.h"
-
-class PoDict;
-
-class TranslationManager final
-{
- public:
- A_DELETE_COPY(TranslationManager)
-
- static PoDict *loadLang(const LangVect &lang,
- const std::string &subName,
- PoDict *const dict = nullptr);
-
- static void init();
-
- static void close();
-
- static void loadCurrentLang();
-
- static void loadDictionaryLang();
-
-#ifdef ENABLE_CUSTOMNLS
- static void loadGettextLang();
-#endif // ENABLE_CUSTOMNLS
-
- static bool translateFile(const std::string &fileName,
- PoDict *const dict,
- StringVect &lines);
- static PoDict *reverseLang(const PoDict *const dict);
-};
-
-#endif // UTILS_TRANSLATION_TRANSLATIONMANAGER_H
diff --git a/src/utils/vector.h b/src/utils/vector.h
deleted file mode 100644
index 6ec054edf..000000000
--- a/src/utils/vector.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 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 UTILS_VECTOR_H
-#define UTILS_VECTOR_H
-
-#ifdef ENABLE_STLDEBUG
-#include "debug/mse/msemstdvector.h"
-#define STD_VECTOR mse::mstd::vector
-#else // ENABLE_STLDEBUG
-#include <vector>
-#define STD_VECTOR std::vector
-#endif // ENABLE_STLDEBUG
-
-#endif // UTILS_VECTOR_H
diff --git a/src/utils/x11logger.cpp b/src/utils/x11logger.cpp
deleted file mode 100644
index 5b83886fe..000000000
--- a/src/utils/x11logger.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 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/>.
- */
-
-#ifdef USE_X11
-
-#include "utils/x11logger.h"
-
-#include "logger.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "utils/cast.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-#define logType(val, str) \
- case val: \
- typeStr = str; \
- break
-
-bool X11Logger::logEvent(const SDL_Event &event)
-{
- if (event.syswm.msg->subsystem != SDL_SYSWM_X11)
- return false;
- std::string typeStr;
-
-#ifdef USE_SDL2
- XEvent &xEvent = event.syswm.msg->msg.x11.event;
-#else // USE_SDL2
-
- XEvent &xEvent = event.syswm.msg->event.xevent;
-#endif // USE_SDL2
-
- const int type = xEvent.type;
-
- switch (type)
- {
- logType(2, strprintf("KeyPress: %u,%u %d,%d",
- xEvent.xkey.keycode,
- xEvent.xkey.state,
- xEvent.xkey.x,
- xEvent.xkey.y));
- logType(3, strprintf("KeyRelease: %u,%u %d,%d",
- xEvent.xkey.keycode,
- xEvent.xkey.state,
- xEvent.xkey.x,
- xEvent.xkey.y));
- logType(4, strprintf("ButtonPress: %u,%u %d,%d",
- xEvent.xbutton.button,
- xEvent.xbutton.state,
- xEvent.xbutton.x,
- xEvent.xbutton.y));
- logType(5, strprintf("ButtonRelease: %u,%u %d,%d",
- xEvent.xbutton.button,
- xEvent.xbutton.state,
- xEvent.xbutton.x,
- xEvent.xbutton.y));
- logType(6, strprintf("MotionNotify: %d,%u %d,%d",
- CAST_S32(xEvent.xmotion.is_hint),
- xEvent.xmotion.state,
- xEvent.xmotion.x,
- xEvent.xmotion.y));
- logType(7, strprintf("EnterNotify: %d,%d,%d,%u, %d,%d",
- xEvent.xcrossing.mode,
- xEvent.xcrossing.detail,
- xEvent.xcrossing.focus ? 1 : 0,
- xEvent.xcrossing.state,
- xEvent.xcrossing.x,
- xEvent.xcrossing.y));
- logType(8, strprintf("LeaveNotify: %d,%d,%d,%u, %d,%d",
- xEvent.xcrossing.mode,
- xEvent.xcrossing.detail,
- xEvent.xcrossing.focus ? 1 : 0,
- xEvent.xcrossing.state,
- xEvent.xcrossing.x,
- xEvent.xcrossing.y));
- logType(9, strprintf("FocusIn: %d,%d",
- xEvent.xfocus.mode,
- xEvent.xfocus.detail));
- logType(10, strprintf("FocusOut: %d,%d",
- xEvent.xfocus.mode,
- xEvent.xfocus.detail));
- case 11:
- typeStr = "KeymapNotify: ";
- for (int f = 0; f < 32; f ++)
- {
- typeStr.append(strprintf("%u ",
- CAST_U32(xEvent.xkeymap.key_vector[f])));
- }
- break;
- logType(12, strprintf("Expose: %d,%d,%d,%d %d",
- xEvent.xexpose.x,
- xEvent.xexpose.y,
- xEvent.xexpose.width,
- xEvent.xexpose.height,
- xEvent.xexpose.count));
- logType(13, strprintf("GraphicsExpose: %d,%d,%d,%d %d,%d,%d",
- xEvent.xgraphicsexpose.x,
- xEvent.xgraphicsexpose.y,
- xEvent.xgraphicsexpose.width,
- xEvent.xgraphicsexpose.height,
- xEvent.xgraphicsexpose.count,
- xEvent.xgraphicsexpose.major_code,
- xEvent.xgraphicsexpose.minor_code));
- logType(14, strprintf("NoExpose: %d,%d",
- xEvent.xnoexpose.major_code,
- xEvent.xnoexpose.minor_code));
- logType(15, strprintf("VisibilityNotify: %d",
- xEvent.xvisibility.state));
- logType(16, strprintf("CreateNotify: %d,%d,%d,%d %d,%d",
- xEvent.xcreatewindow.x,
- xEvent.xcreatewindow.y,
- xEvent.xcreatewindow.width,
- xEvent.xcreatewindow.height,
- xEvent.xcreatewindow.border_width,
- xEvent.xcreatewindow.override_redirect ? 1 : 0));
- logType(17, "DestroyNotify");
- logType(18, strprintf("UnmapNotify: %d",
- xEvent.xunmap.from_configure ? 1: 0));
- logType(19, strprintf("MapNotify: %d",
- xEvent.xmap.override_redirect ? 1 : 0));
- logType(20, "MapRequest");
- logType(21, strprintf("ReparentNotify: %d,%d, %d",
- xEvent.xreparent.x,
- xEvent.xreparent.y,
- xEvent.xreparent.override_redirect ? 1 : 0));
- logType(22, strprintf("ConfigureNotify: %d,%d %d,%d %d,%d",
- xEvent.xconfigure.x,
- xEvent.xconfigure.y,
- xEvent.xconfigure.width,
- xEvent.xconfigure.height,
- xEvent.xconfigure.border_width,
- xEvent.xconfigure.override_redirect ? 1 : 0));
- logType(23, strprintf("ConfigureRequest: %d,%d %d,%d %d,%d",
- xEvent.xconfigurerequest.x,
- xEvent.xconfigurerequest.y,
- xEvent.xconfigurerequest.width,
- xEvent.xconfigurerequest.height,
- xEvent.xconfigurerequest.border_width,
- xEvent.xconfigurerequest.detail));
- logType(24, strprintf("GravityNotify: %d,%d",
- xEvent.xgravity.x,
- xEvent.xgravity.y));
- logType(25, strprintf("ResizeRequest: %d,%d",
- xEvent.xresizerequest.width,
- xEvent.xresizerequest.height));
- logType(26, strprintf("CirculateNotify: %d",
- xEvent.xcirculate.place));
- logType(27, strprintf("CirculateRequest: %d",
- xEvent.xcirculaterequest.place));
- logType(28, strprintf("PropertyNotify: %u, %d",
- CAST_U32(xEvent.xproperty.atom),
- xEvent.xproperty.state));
- logType(29, strprintf("SelectionClear: %u",
- CAST_U32(xEvent.xselectionclear.selection)));
- logType(30, strprintf("SelectionRequest: %u,%u,%u",
- CAST_U32(xEvent.xselectionrequest.selection),
- CAST_U32(xEvent.xselectionrequest.target),
- CAST_U32(xEvent.xselectionrequest.property)));
- logType(31, strprintf("SelectionNotify: %u,%u,%u",
- CAST_U32(xEvent.xselection.selection),
- CAST_U32(xEvent.xselection.target),
- CAST_U32(xEvent.xselection.property)));
- logType(32, strprintf("ColormapNotify: %u,%d",
- CAST_U32(xEvent.xcolormap.colormap),
-// xEvent.xcolormap.new ? 1 : 0,
- xEvent.xcolormap.state));
- case 33:
- typeStr = strprintf("ClientMessage: %u,%d (",
- CAST_U32(xEvent.xclient.message_type),
- xEvent.xclient.format);
- for (int f = 0; f < 20; f ++)
- typeStr.append(strprintf("%c", xEvent.xclient.data.b[f]));
- typeStr.append(")");
- break;
- logType(34, strprintf("MappingNotify: %d,%d,%d",
- xEvent.xmapping.request,
- xEvent.xmapping.first_keycode,
- xEvent.xmapping.count));
- logType(35, "GenericEvent");
- default:
- typeStr = strprintf("Unknown: %d", type);
- break;
- }
-
- logger->log("event: SDL_SYSWMEVENT: X11: %s",
- typeStr.c_str());
- return true;
-}
-
-#endif // USE_X11
diff --git a/src/utils/x11logger.h b/src/utils/x11logger.h
deleted file mode 100644
index 6ba01e579..000000000
--- a/src/utils/x11logger.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 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 UTILS_X11LOGGER_H
-#define UTILS_X11LOGGER_H
-
-#ifdef USE_X11
-
-#include "localconsts.h"
-
-union SDL_Event;
-
-namespace X11Logger
-{
- bool logEvent(const SDL_Event &event);
-} // namespace X11Logger
-
-#endif // USE_X11
-#endif // UTILS_X11LOGGER_H
diff --git a/src/utils/xml.h b/src/utils/xml.h
deleted file mode 100644
index ac93231fc..000000000
--- a/src/utils/xml.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_XML_H
-#define UTILS_XML_H
-
-#ifdef ENABLE_PUGIXML
-#include "utils/xml/pugixml.h"
-#elif defined(ENABLE_TINYXML2)
-#include "utils/xml/tinyxml2.h"
-#else // ENABLE_PUGIXML
-#include "utils/xml/libxml.h"
-#endif // ENABLE_PUGIXML
-
-XML_INCLUDE_DEFINE
-
-#endif // UTILS_XML_H
diff --git a/src/utils/xml.inc b/src/utils/xml.inc
deleted file mode 100644
index 1b6aea25a..000000000
--- a/src/utils/xml.inc
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_XML_INC
-#define UTILS_XML_INC
-
-#ifdef ENABLE_PUGIXML
-#include "utils/xml/pugixml.inc"
-#else // ENABLE_PUGIXML
-#include "utils/xml/libxml.inc"
-#endif // ENABLE_PUGIXML
-
-#endif // UTILS_XML_INC
diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp
deleted file mode 100644
index 6dd87b3f2..000000000
--- a/src/utils/xml/libxml.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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/>.
- */
-
-#ifdef ENABLE_LIBXML
-
-#include "utils/xml/libxml.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace
-{
- bool valid = false;
-} // namespace
-
-static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...)
-#ifdef __GNUC__
-#ifdef __OpenBSD__
- __attribute__((__format__(printf, 2, 3)))
-#else // __OpenBSD__
- __attribute__((__format__(gnu_printf, 2, 3)))
-#endif // __OpenBSD__
-#endif // __GNUC__
-;
-
-static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...)
-{
- if (msg == nullptr)
- return;
-
- size_t size = 1024;
- const size_t msgSize = strlen(msg);
- if (msgSize * 3 > size)
- size = msgSize * 3;
-
- char* buf = new char[size + 1];
- va_list ap;
-
- // Use a temporary buffer to fill in the variables
- va_start(ap, msg);
- vsnprintf(buf, size, msg, ap);
- buf[size] = 0;
- va_end(ap);
-
- if (logger != nullptr)
- logger->log_r("%s", buf);
- else
- puts(buf);
-
- // Delete temporary buffer
- delete [] buf;
- valid = false;
-}
-
-namespace XML
-{
- Document::Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError) :
- Resource(),
- mDoc(nullptr),
- mIsValid(false)
- {
-#ifdef USE_FUZZER
- if (Fuzzer::conditionTerminate(filename.c_str()))
- return;
-#endif // USE_FUZZER
-
- BLOCK_START("XML::Document::Document")
- int size = 0;
- char *data = nullptr;
- valid = true;
- if (useResman == UseVirtFs_true)
- {
- data = const_cast<char*>(VirtFs::loadFile(
- filename,
- size));
- }
- else
- {
- std::ifstream file;
- file.open(filename.c_str(), std::ios::in);
-
- if (file.is_open())
- {
- // Get length of file
- file.seekg(0, std::ios::end);
- size = CAST_S32(file.tellg());
- if (size < 0)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- else
- {
- file.seekg(0, std::ios::beg);
- data = new char[size];
- file.read(data, size);
- }
- file.close();
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- }
-
- if (data != nullptr)
- {
- mDoc = xmlParseMemory(data, size);
- delete [] data;
-
- if (mDoc == nullptr)
- {
- reportAlways("Error parsing XML file %s", filename.c_str());
- }
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s", filename.c_str());
- }
- mIsValid = valid;
- BLOCK_END("XML::Document::Document")
- }
-
- Document::Document(const char *const data, const int size) :
- mDoc(data != nullptr ? xmlParseMemory(data, size) : nullptr),
- mIsValid(true)
- {
- }
-
- Document::~Document()
- {
- if (mDoc != nullptr)
- xmlFreeDoc(mDoc);
- }
-
- XmlNodePtr Document::rootNode()
- {
- return mDoc != nullptr ? xmlDocGetRootElement(mDoc) : nullptr;
- }
-
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def)
- {
- int &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = atoi(reinterpret_cast<const char*>(prop));
- xmlFree(prop);
- }
-
- return ret;
- }
-
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max)
- {
- int &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = atoi(reinterpret_cast<char*>(prop));
- xmlFree(prop);
- }
- if (ret < min)
- ret = min;
- else if (ret > max)
- ret = max;
- return ret;
- }
-
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def)
- {
- float &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = static_cast<float>(atof(reinterpret_cast<char*>(prop)));
- xmlFree(prop);
- }
-
- return ret;
- }
-
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def)
- {
- double &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = atof(reinterpret_cast<char*>(prop));
- xmlFree(prop);
- }
-
- return ret;
- }
-
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- std::string val = reinterpret_cast<char*>(prop);
- xmlFree(prop);
- return val;
- }
-
- return def;
- }
-
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- std::string str = getProperty(node, name, def);
- if (translator == nullptr)
- return str;
-
- return translator->getStr(str);
- }
-
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def)
- {
- xmlChar *const prop = XmlGetProp(node, name);
-
- if (XmlStrEqual(prop, "true"))
- {
- XmlFree(prop);
- return true;
- }
- if (XmlStrEqual(prop, "false"))
- {
- XmlFree(prop);
- return false;
- }
- XmlFree(prop);
- return def;
- }
-
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- {
- if (parent == nullptr)
- return nullptr;
- for_each_xml_child_node(child, parent)
- {
- if (xmlNameEqual(child, name))
- return child;
- }
-
- return nullptr;
- }
-
- // Initialize libxml2 and check for potential ABI mismatches between
- // compiled version and the shared library actually used.
- void initXML()
- {
- xmlInitParser();
- LIBXML_TEST_VERSION;
-
- // Suppress libxml2 error messages
- xmlSetGenericErrorFunc(nullptr, &xmlErrorLogger);
- }
-
- // Shutdown libxml
- void cleanupXML()
- {
- xmlCleanupParser();
- }
-
- bool Document::validateXml(const std::string &fileName)
- {
- const xmlDocPtr doc = xmlReadFile(fileName.c_str(),
- nullptr, XML_PARSE_PEDANTIC);
- const bool valid1(doc != nullptr);
- xmlFreeDoc(doc);
- if (!valid1)
- return false;
-
- std::ifstream file;
- file.open(fileName.c_str(), std::ios::in);
- if (!file.is_open())
- {
- file.close();
- return false;
- }
- char line[101];
- if (!file.getline(line, 100))
- return false;
- file.close();
-
- const std::string str = line;
- if (!strStartWith(str, "<?xml "))
- return false;
-
- return true;
- }
-} // namespace XML
-
-#endif // ENABLE_LIBXML
diff --git a/src/utils/xml/libxml.h b/src/utils/xml/libxml.h
deleted file mode 100644
index 6ec0ce08d..000000000
--- a/src/utils/xml/libxml.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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 UTILS_XML_LIBXML_H
-#define UTILS_XML_LIBXML_H
-
-#ifdef ENABLE_LIBXML
-
-#define XML_INCLUDE_DEFINE
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/libxml.inc"
-
-#include "resources/resource.h"
-
-#ifndef _GLIBCXX_STRING
-#include <string>
-#endif // _GLIBCXX_STRING
-
-#include "localconsts.h"
-
-/**
- * XML helper functions.
- */
-namespace XML
-{
- /**
- * A helper class for parsing an XML document, which also cleans it up
- * again (RAII).
- */
- class Document final : public Resource
- {
- public:
- /**
- * Constructor that attempts to load the given file through the
- * resource manager. Logs errors.
- */
- Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError);
-
- /**
- * Constructor that attempts to load an XML document from memory.
- * Does not log errors.
- *
- * @param data the string to parse as XML
- * @param size the length of the string in bytes
- */
- Document(const char *const data, const int size);
-
- A_DELETE_COPY(Document)
-
- /**
- * Destructor. Frees the loaded XML file.
- */
- ~Document();
-
- /**
- * Returns the root node of the document (or NULL if there was a
- * load error).
- */
- XmlNodePtr rootNode() A_WARN_UNUSED;
-
- bool isLoaded() const
- { return mDoc != nullptr; }
-
- bool isValid() const
- { return mIsValid; }
-
- static bool validateXml(const std::string &fileName);
-
- private:
- xmlDocPtr mDoc;
- bool mIsValid;
- };
-
- /**
- * Gets an floating point property from an XmlNodePtr.
- */
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def) A_WARN_UNUSED;
-
- /**
- * Gets an double point property from an XmlNodePtr.
- */
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max) A_WARN_UNUSED;
-
- /**
- * Gets a string property from an XmlNodePtr.
- */
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a translated string property from an XmlNodePtr.
- */
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a boolean property from an XmlNodePtr.
- */
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def) A_WARN_UNUSED;
-
- /**
- * Finds the first child node with the given name
- */
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name) A_WARN_UNUSED;
-
- void initXML();
-
- void cleanupXML();
-} // namespace XML
-
-#define for_each_xml_child_node(var, parent) \
- for (XmlNodePtr var = parent->xmlChildrenNode; var; var = var->next)
-
-#endif // ENABLE_LIBXML
-#endif // UTILS_XML_LIBXML_H
diff --git a/src/utils/xml/libxml.inc b/src/utils/xml/libxml.inc
deleted file mode 100644
index ec837f224..000000000
--- a/src/utils/xml/libxml.inc
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_XML_LIBXML_INC
-#define UTILS_XML_LIBXML_INC
-
-#ifdef ENABLE_LIBXML
-
-#include <libxml/xmlwriter.h>
-
-__XML_XMLWRITER_H__
-
-#define XmlNodePtr xmlNodePtr
-#define XmlNodePtrConst xmlNode *const
-#define XmlNodeConstPtr const xmlNodePtr
-#define XmlNodeConstPtrConst const xmlNode *const
-#define XmlStrEqual(str1, str2) xmlStrEqual(str1, \
- reinterpret_cast<const xmlChar*>(str2))
-#define xmlNameEqual(node, str) xmlStrEqual((node)->name, \
- reinterpret_cast<const xmlChar*>(str))
-#define XmlTextWriterPtr const xmlTextWriterPtr
-#define xmlTypeEqual(node, typ) ((node)->type == (typ))
-#define XmlHasProp(node, name) (xmlHasProp(node, \
- reinterpret_cast<const xmlChar*>(name)) != nullptr)
-#define XmlGetProp(node, name) xmlGetProp(node, \
- reinterpret_cast<const xmlChar*>(name))
-#define XmlTextWriterStartRootElement(writer, name) \
- xmlTextWriterStartElement(writer, reinterpret_cast<const xmlChar*>(name))
-#define XmlTextWriterStartElement(writer, name) \
- xmlTextWriterStartElement(writer, reinterpret_cast<const xmlChar*>(name))
-#define XmlTextWriterEndElement(writer) xmlTextWriterEndElement(writer)
-#define XmlTextWriterWriteAttribute(writer, name, content) \
- xmlTextWriterWriteAttribute(writer, \
- reinterpret_cast<const xmlChar*>(name), \
- reinterpret_cast<const xmlChar*>(content))
-#define XmlNodeGetContent(node) xmlNodeGetContent(node)
-#define XmlNewTextWriterFilename(name, flags) \
- xmlNewTextWriterFilename(name, flags)
-#define XmlSaveTextWriterFilename(writer, name)
-#define XmlTextWriterSetIndent(writer, flags) \
- xmlTextWriterSetIndent(writer, flags)
-#define XmlTextWriterStartDocument(writer, p1, p2, p3) \
- xmlTextWriterStartDocument(writer, p1, p2, p3)
-#define XmlTextWriterEndDocument(writer) xmlTextWriterEndDocument(writer)
-#define XmlFreeTextWriter(writer) xmlFreeTextWriter(writer)
-#define XmlHaveChildContent(node) ((node)->xmlChildrenNode != nullptr && \
- (node)->xmlChildrenNode->content != nullptr)
-#define XmlChildContent(node) reinterpret_cast<const char*>(\
- (node)->xmlChildrenNode->content)
-#define XmlFree(ptr) xmlFree(ptr)
-#define XmlNodeDefault nullptr
-#define XmlChar char
-#define XmlConstChar const char
-
-#endif // ENABLE_LIBXML
-#endif // UTILS_XML_LIBXML_INC
diff --git a/src/utils/xml/pugixml.cpp b/src/utils/xml/pugixml.cpp
deleted file mode 100644
index 12d885a4f..000000000
--- a/src/utils/xml/pugixml.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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/>.
- */
-
-#ifdef ENABLE_PUGIXML
-
-#include "utils/xml/pugixml.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace
-{
- bool valid = false;
-} // namespace
-
-namespace XML
-{
- static void showErrorStatus(pugi::xml_parse_result &result)
- {
-/*
- switch (result.status)
- {
- case pugi::status_ok:
- break;
- case pugi::status_file_not_found:
- logger->log("xml error: %s", result.description());
- break;
- }
-*/
- logger->log("xml error: %s", result.description());
- }
-
- Document::Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError) :
- Resource(),
- mDoc(),
- mData(nullptr),
- mIsValid(false)
- {
-#ifdef USE_FUZZER
- if (Fuzzer::conditionTerminate(filename.c_str()))
- return;
-#endif // USE_FUZZER
-
- BLOCK_START("XML::Document::Document")
- int size = 0;
- char *data = nullptr;
- valid = true;
- if (useResman == UseVirtFs_true)
- {
- data = const_cast<char*>(VirtFs::loadFile(
- filename.c_str(),
- size));
- }
- else
- {
- std::ifstream file;
- file.open(filename.c_str(), std::ios::in);
-
- if (file.is_open())
- {
- // Get length of file
- file.seekg(0, std::ios::end);
- size = CAST_S32(file.tellg());
- if (size < 0)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- else
- {
- file.seekg(0, std::ios::beg);
- data = new char[size];
- file.read(data, size);
- }
- file.close();
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- }
-
- if (data)
- {
- // +++ use other pugi::parse_* flags
- pugi::xml_parse_result result = mDoc.load_buffer_inplace(data,
- size,
- pugi::parse_default,
- pugi::encoding_utf8);
- if (result.status != pugi::status_ok)
- {
- showErrorStatus(result);
- delete [] data;
- }
- else
- {
- mData = data;
- }
-
-// if (!mDoc)
-// logger->log("Error parsing XML file %s", filename.c_str());
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading %s", filename.c_str());
- }
- mIsValid = valid;
- BLOCK_END("XML::Document::Document")
- }
-
- Document::Document(const char *const data, const int size) :
- mDoc(),
- mData(nullptr),
- mIsValid(true)
- {
- if (!data)
- return;
-
- char *buf = new char[size + 1];
- strncpy(buf, data, size);
- buf[size] = 0;
- pugi::xml_parse_result result = mDoc.load_buffer_inplace(buf,
- size,
- pugi::parse_default,
- pugi::encoding_utf8);
- if (result.status != pugi::status_ok)
- {
- showErrorStatus(result);
- delete [] buf;
- }
- else
- {
- mData = buf;
- }
- }
-
- Document::~Document()
- {
- delete [] mData;
- mData = nullptr;
- }
-
- XmlNodePtr Document::rootNode()
- {
- return mDoc.first_child();
- }
-
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atoi(attr.value());
-
- return ret;
- }
-
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atoi(attr.value());
-
- if (ret < min)
- ret = min;
- else if (ret > max)
- ret = max;
- return ret;
- }
-
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def)
- {
- float &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atof(attr.value());
-
- return ret;
- }
-
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def)
- {
- double &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atof(attr.value());
-
- return ret;
- }
-
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- if (!node)
- return def;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- return attr.value();
-
- return def;
- }
-
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- std::string str = getProperty(node, name, def);
- if (!translator)
- return str;
-
- return translator->getStr(str);
- }
-
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def)
- {
- if (!node)
- return def;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- {
- std::string val = attr.value();
- if (val == "true")
- return true;
- if (val == "false")
- return false;
- }
-
- return def;
- }
-
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- {
- if (!parent || !name)
- return pugi::xml_node();
- for_each_xml_child_node(child, parent)
- {
- if (!strcmp(child.name(), name))
- return child;
- }
-
- return pugi::xml_node();
- }
-
- // Initialize libxml2 and check for potential ABI mismatches between
- // compiled version and the shared library actually used.
- void initXML()
- {
-// xmlInitParser();
-// LIBXML_TEST_VERSION;
-
- // Suppress libxml2 error messages
-// xmlSetGenericErrorFunc(nullptr, &xmlErrorLogger);
- }
-
- // Shutdown libxml
- void cleanupXML()
- {
-// xmlCleanupParser();
- }
-
- bool Document::validateXml(const std::string &fileName)
- {
- pugi::xml_document doc;
- pugi::xml_parse_result result = doc.load_file(fileName.c_str(),
- pugi::parse_default,
- pugi::encoding_utf8);
-
- if (result.status != pugi::status_ok)
- {
- showErrorStatus(result);
- return false;
- }
-
- std::ifstream file;
- file.open(fileName.c_str(), std::ios::in);
- if (!file.is_open())
- {
- file.close();
- return false;
- }
- char line[101];
- if (!file.getline(line, 100))
- return false;
- file.close();
-
- const std::string str = line;
- if (!strStartWith(str, "<?xml "))
- return false;
-
- return true;
- }
-} // namespace XML
-
-#endif // ENABLE_PUGIXML
diff --git a/src/utils/xml/pugixml.h b/src/utils/xml/pugixml.h
deleted file mode 100644
index e4337140e..000000000
--- a/src/utils/xml/pugixml.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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 UTILS_XML_PUGIXML_H
-#define UTILS_XML_PUGIXML_H
-
-#ifdef ENABLE_PUGIXML
-
-#define XML_INCLUDE_DEFINE
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/pugixml.inc"
-
-#include "resources/resource.h"
-
-#include <pugixml.hpp>
-
-#include <string>
-
-#include "localconsts.h"
-
-/**
- * XML helper functions.
- */
-namespace XML
-{
- /**
- * A helper class for parsing an XML document, which also cleans it up
- * again (RAII).
- */
- class Document final : public Resource
- {
- public:
- /**
- * Constructor that attempts to load the given file through the
- * resource manager. Logs errors.
- */
- Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError);
-
- /**
- * Constructor that attempts to load an XML document from memory.
- * Does not log errors.
- *
- * @param data the string to parse as XML
- * @param size the length of the string in bytes
- */
- Document(const char *const data, const int size);
-
- A_DELETE_COPY(Document)
-
- /**
- * Destructor. Frees the loaded XML file.
- */
- ~Document();
-
- /**
- * Returns the root node of the document (or NULL if there was a
- * load error).
- */
- XmlNodePtr rootNode() A_WARN_UNUSED;
-
- bool isLoaded() const
- { return !mDoc.empty(); }
-
- bool isValid() const
- { return mIsValid; }
-
- static bool validateXml(const std::string &fileName);
-
- private:
- pugi::xml_document mDoc;
- char *mData;
- bool mIsValid;
- };
-
- /**
- * Gets an floating point property from an XmlNodePtr.
- */
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def) A_WARN_UNUSED;
-
- /**
- * Gets an double point property from an XmlNodePtr.
- */
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max) A_WARN_UNUSED;
-
- /**
- * Gets a string property from an XmlNodePtr.
- */
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a translated string property from an XmlNodePtr.
- */
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a boolean property from an XmlNodePtr.
- */
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def) A_WARN_UNUSED;
-
- /**
- * Finds the first child node with the given name
- */
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name) A_WARN_UNUSED;
-
- void initXML();
-
- void cleanupXML();
-} // namespace XML
-
-#define for_each_xml_child_node(var, parent) \
- for (pugi::xml_node var = parent.first_child(); \
- var; var = var.next_sibling())
-
-#endif // ENABLE_PUGIXML
-#endif // UTILS_XML_PUGIXML_H
diff --git a/src/utils/xml/pugixml.inc b/src/utils/xml/pugixml.inc
deleted file mode 100644
index c8685f877..000000000
--- a/src/utils/xml/pugixml.inc
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_XML_PUGIXML_INC
-#define UTILS_XML_PUGIXML_INC
-
-#ifdef ENABLE_PUGIXML
-
-#define XML_ELEMENT_NODE pugi::node_element
-
-#define XmlNodePtr pugi::xml_node
-#define XmlNodePtrConst pugi::xml_node
-#define XmlNodeConstPtr const pugi::xml_node
-#define XmlNodeConstPtrConst const pugi::xml_node
-#define xmlNameEqual(node, str) !strcmp((node).name(), str)
-#define xmlTypeEqual(node, typ) ((node).type() == (typ))
-#define XmlHasProp(node, name) (!((node).attribute(name).empty()))
-#define XmlHaveChildContent(node) ((node).child_value() != nullptr && \
- *(node).child_value())
-#define XmlChildContent(node) (node).child_value()
-#define xmlChar char
-#define XmlFree(ptr)
-#define XmlNodeDefault pugi::xml_node()
-#define XmlNodeGetContent(node) (node).child_value()
-#define XmlTextWriterPtr const XML::Writer *
-#define XmlTextWriterStartRootElement(writer, name) (writer)->startNode(name)
-#define XmlTextWriterStartElement(writer, name) (writer)->startNode(name)
-#define XmlTextWriterEndElement(writer) (writer)->endNode()
-#define XmlTextWriterWriteAttribute(writer, name, content) \
- (writer)->addAttribute(name, content)
-#define XmlNewTextWriterFilename(name, flags) new XML::Writer(name);
-#define XmlSaveTextWriterFilename(writer, name)
-#define XmlTextWriterSetIndent(writer, flags)
-#define XmlTextWriterStartDocument(writer, p1, p2, p3)
-#define XmlTextWriterEndDocument(writer) (writer)->endDocument()
-#define XmlFreeTextWriter(writer) delete writer
-#define XmlChar const char
-#define XmlConstChar const char
-
-#endif // ENABLE_PUGIXML
-#endif // UTILS_XML_PUGIXML_INC
diff --git a/src/utils/xml/pugixmlwriter.cpp b/src/utils/xml/pugixmlwriter.cpp
deleted file mode 100644
index b8c6aafec..000000000
--- a/src/utils/xml/pugixmlwriter.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * The ManaPlus Client
- * 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/>.
- */
-
-#ifdef ENABLE_PUGIXML
-
-#include "utils/xml/pugixmlwriter.h"
-
-#include "logger.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/delete2.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace XML
-{
- Writer::Writer(const std::string &filename) :
- mDoc(),
- mNode(),
- mName(filename)
- {
- mNode = mDoc;
- }
-
- Writer::~Writer()
- {
- }
-
- void Writer::startNode(const std::string &name) const
- {
- mNode = mNode.append_child(name.c_str());
- }
-
- void Writer::endNode() const
- {
- mNode = mNode.parent();
- }
-
- void Writer::endDocument() const
- {
- mDoc.save_file(mName.c_str());
- }
-
- void Writer::addAttribute(const std::string &name,
- const std::string &value) const
- {
- mNode.append_attribute(name.c_str()) = value.c_str();
- }
-
-} // namespace XML
-
-#endif // ENABLE_PUGIXML
diff --git a/src/utils/xml/pugixmlwriter.h b/src/utils/xml/pugixmlwriter.h
deleted file mode 100644
index fe5977655..000000000
--- a/src/utils/xml/pugixmlwriter.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_XML_PUGIXMLWRITER_H
-#define UTILS_XML_PUGIXMLWRITER_H
-
-#ifdef ENABLE_PUGIXML
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/pugixml.h"
-
-#include <pugixml.hpp>
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace XML
-{
- class Writer final
- {
- public:
- explicit Writer(const std::string &filename);
-
- A_DELETE_COPY(Writer)
-
- ~Writer();
-
- void startNode(const std::string &name) const;
-
- void endNode() const;
-
- void endDocument() const;
-
- void addAttribute(const std::string &name,
- const std::string &value) const;
-
- private:
- mutable pugi::xml_document mDoc;
- mutable pugi::xml_node mNode;
- std::string mName;
- };
-} // namespace XML
-
-#endif // ENABLE_PUGIXML
-#endif // UTILS_XML_PUGIXMLWRITER_H
diff --git a/src/utils/xml/tinyxml2.cpp b/src/utils/xml/tinyxml2.cpp
deleted file mode 100644
index a7275b7f1..000000000
--- a/src/utils/xml/tinyxml2.cpp
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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/>.
- */
-
-#ifdef ENABLE_TINYXML2
-
-#include "utils/xml/tinyxml2.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace
-{
- bool valid = false;
-} // namespace
-
-namespace XML
-{
- static void showErrorStatus(tinyxml2::XMLDocument &doc)
- {
- logger->log("xml error: %s, in lines: %s\n%s",
- doc.ErrorName(),
- doc.GetErrorStr1(),
- doc.GetErrorStr2());
- }
-
- Document::Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError) :
- Resource(),
- mDoc(),
- mData(nullptr),
- mIsValid(false)
- {
-#ifdef USE_FUZZER
- if (Fuzzer::conditionTerminate(filename.c_str()))
- return;
-#endif // USE_FUZZER
-
- BLOCK_START("XML::Document::Document")
- int size = 0;
- char *data = nullptr;
- valid = true;
- if (useResman == UseVirtFs_true)
- {
- data = const_cast<char*>(VirtFs::loadFile(
- filename.c_str(),
- size));
- }
- else
- {
- std::ifstream file;
- file.open(filename.c_str(), std::ios::in);
-
- if (file.is_open())
- {
- // Get length of file
- file.seekg(0, std::ios::end);
- size = CAST_S32(file.tellg());
- if (size < 0)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- else
- {
- file.seekg(0, std::ios::beg);
- data = new char[size];
- file.read(data, size);
- }
- file.close();
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- }
-
- if (data)
- {
- tinyxml2::XMLError result = mDoc.Parse(data,
- size);
- if (result != tinyxml2::XML_SUCCESS)
- {
- showErrorStatus(mDoc);
- delete [] data;
- }
- else
- {
- mData = data;
- }
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading %s", filename.c_str());
- }
- mIsValid = valid;
- BLOCK_END("XML::Document::Document")
- }
-
- Document::Document(const char *const data, const int size) :
- Resource(),
- mDoc(),
- mData(nullptr),
- mIsValid(true)
- {
- if (!data)
- return;
-
- char *buf = new char[size + 1];
- strncpy(buf, data, size);
- buf[size] = 0;
-
- tinyxml2::XMLError result = mDoc.Parse(buf,
- size);
- if (result != tinyxml2::XML_SUCCESS)
- {
- showErrorStatus(mDoc);
- delete [] buf;
- }
- else
- {
- mData = buf;
- }
- }
-
- Document::~Document()
- {
- delete [] mData;
- mData = nullptr;
- }
-
- XmlNodeConstPtr Document::rootNode()
- {
- return mDoc.FirstChildElement();
- }
-
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atoi(attr);
-
- return ret;
- }
-
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atoi(attr);
-
- if (ret < min)
- ret = min;
- else if (ret > max)
- ret = max;
- return ret;
- }
-
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def)
- {
- float &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atof(attr);
-
- return ret;
- }
-
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def)
- {
- double &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atof(attr);
-
- return ret;
- }
-
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- if (!node)
- return def;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- return attr;
-
- return def;
- }
-
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- std::string str = getProperty(node, name, def);
- if (!translator)
- return str;
-
- return translator->getStr(str);
- }
-
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def)
- {
- if (!node)
- return def;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- {
- std::string val = attr;
- if (val == "true")
- return true;
- if (val == "false")
- return false;
- }
-
- return def;
- }
-
- XmlNodeConstPtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- {
- if (!parent || !name)
- return nullptr;
- return parent->FirstChildElement(name);
- }
-
- // Initialize xml
- void initXML()
- {
- }
-
- // Shutdown xml
- void cleanupXML()
- {
- }
-
- bool Document::validateXml(const std::string &fileName)
- {
- tinyxml2::XMLDocument doc;
- tinyxml2::XMLError result = doc.LoadFile(fileName.c_str());
-
- if (result != tinyxml2::XML_SUCCESS)
- {
- showErrorStatus(doc);
- return false;
- }
-
- std::ifstream file;
- file.open(fileName.c_str(), std::ios::in);
- if (!file.is_open())
- {
- file.close();
- return false;
- }
- char line[101];
- if (!file.getline(line, 100))
- return false;
- file.close();
-
- const std::string str = line;
- if (!strStartWith(str, "<?xml "))
- return false;
-
- return true;
- }
-} // namespace XML
-
-#endif // ENABLE_TINYXML2
diff --git a/src/utils/xml/tinyxml2.h b/src/utils/xml/tinyxml2.h
deleted file mode 100644
index f056dc43a..000000000
--- a/src/utils/xml/tinyxml2.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-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 UTILS_XML_TINYXML2_H
-#define UTILS_XML_TINYXML2_H
-
-#ifdef ENABLE_TINYXML2
-
-#define XML_INCLUDE_DEFINE
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/tinyxml2.inc"
-
-#include "resources/resource.h"
-
-#ifndef _GLIBCXX_STRING
-#include <string>
-#endif // _GLIBCXX_STRING
-
-#include "localconsts.h"
-
-/**
- * XML helper functions.
- */
-namespace XML
-{
- /**
- * A helper class for parsing an XML document, which also cleans it up
- * again (RAII).
- */
- class Document final : public Resource
- {
- public:
- /**
- * Constructor that attempts to load the given file through the
- * resource manager. Logs errors.
- */
- Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError);
-
- /**
- * Constructor that attempts to load an XML document from memory.
- * Does not log errors.
- *
- * @param data the string to parse as XML
- * @param size the length of the string in bytes
- */
- Document(const char *const data, const int size);
-
- A_DELETE_COPY(Document)
-
- /**
- * Destructor. Frees the loaded XML file.
- */
- ~Document();
-
- /**
- * Returns the root node of the document (or NULL if there was a
- * load error).
- */
- XmlNodePtr rootNode() A_WARN_UNUSED;
-
- bool isLoaded() const
- { return mDoc.Error() == false; }
-
- bool isValid() const
- { return mIsValid; }
-
- static bool validateXml(const std::string &fileName);
-
- private:
- tinyxml2::XMLDocument mDoc;
- char *mData;
- bool mIsValid;
- };
-
- /**
- * Gets an floating point property from an XmlNodePtr.
- */
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def) A_WARN_UNUSED;
-
- /**
- * Gets an double point property from an XmlNodePtr.
- */
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max) A_WARN_UNUSED;
-
- /**
- * Gets a string property from an XmlNodePtr.
- */
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a translated string property from an XmlNodePtr.
- */
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a boolean property from an XmlNodePtr.
- */
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def) A_WARN_UNUSED;
-
- /**
- * Finds the first child node with the given name
- */
- XmlNodeConstPtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- A_WARN_UNUSED;
-
- void initXML();
-
- void cleanupXML();
-} // namespace XML
-
-#define for_each_xml_child_node(var, parent) \
- for (const tinyxml2::XMLElement *var = parent->FirstChildElement(); \
- var != nullptr; \
- var = var->NextSiblingElement())
-
-#endif // ENABLE_TINYXML2
-#endif // UTILS_XML_TINYXML2_H
diff --git a/src/utils/xml/tinyxml2.inc b/src/utils/xml/tinyxml2.inc
deleted file mode 100644
index 408638184..000000000
--- a/src/utils/xml/tinyxml2.inc
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_XML_TINYXML2_INC
-#define UTILS_XML_TINYXML2_INC
-
-#ifdef ENABLE_TINYXML2
-
-PRAGMA49(GCC diagnostic push)
-PRAGMA49(GCC diagnostic ignored "-Wzero-as-null-pointer-constant")
-PRAGMA49(GCC diagnostic ignored "-Wsuggest-override")
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
-#include <tinyxml2.h>
-PRAGMACLANG6GCC(GCC diagnostic pop)
-PRAGMA49(GCC diagnostic pop)
-
-TINYXML2_INCLUDED
-
-#define XML_ELEMENT_NODE tinyxml2::XMLElement
-
-#define XmlNodePtr const tinyxml2::XMLElement*
-#define XmlNodePtrConst const tinyxml2::XMLElement *const
-#define XmlNodeConstPtr const tinyxml2::XMLElement*
-#define XmlNodeConstPtrConst const tinyxml2::XMLElement *const
-#define xmlNameEqual(node, str) !strcmp((node)->Value(), str)
-#define XmlTextWriterPtr tinyxml2::XMLPrinter*
-// +++ need replace xmlTypeEqual to isXmlElementNode
-#define xmlTypeEqual(node, typ) true
-#define XmlHasProp(node, name) ((node)->Attribute(name) != nullptr)
-
-#define XmlNodeGetContent(node) (node)->GetText()
-#define XmlHaveChildContent(node) ((node)->GetText() != nullptr)
-#define XmlChildContent(node) ((node)->GetText())
-
-#define XmlFree(ptr)
-#define XmlNodeDefault nullptr
-#define XmlChar const char
-#define XmlConstChar const char
-
-#define XmlTextWriterStartElement(writer, name) (writer)->OpenElement(name)
-#define XmlTextWriterStartRootElement(writer, name) (writer)->OpenElement(name)
-#define XmlTextWriterEndElement(writer) (writer)->CloseElement()
-#define XmlTextWriterWriteAttribute(writer, name, content) \
- (writer)->PushAttribute(name, content)
-#define XmlNewTextWriterFilename(name, flags) new tinyxml2::XMLPrinter
-#define XmlSaveTextWriterFilename(writer, name) \
- { \
- FILE *const writer##File = fopen(name, "wb"); \
- fwrite((writer)->CStr(), 1, (writer)->CStrSize() - 1, writer##File); \
- fclose(writer##File); \
- }
-#define XmlTextWriterSetIndent(writer, flags)
-#define XmlTextWriterStartDocument(writer, p1, p2, p3) \
- (writer)->PushDeclaration("xml version=\"1.0\" encoding=\"utf-8\"")
-#define XmlTextWriterEndDocument(writer) (writer)->CloseElement()
-#define XmlFreeTextWriter(writer) delete writer
-
-#endif // ENABLE_TINYXML2
-#endif // UTILS_XML_TINYXML2_INC
diff --git a/src/utils/xmlutils.cpp b/src/utils/xmlutils.cpp
deleted file mode 100644
index 56510c316..000000000
--- a/src/utils/xmlutils.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-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/>.
- */
-
-#include "utils/xmlutils.h"
-
-#include "logger.h"
-
-#include "utils/xml.h"
-
-#include "debug.h"
-
-void readXmlIntVector(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeName,
- STD_VECTOR<int> &arr,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
- {
- logger->log("Error while loading %s!", fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(sectionNode, rootNode)
- {
- if (!xmlNameEqual(sectionNode, sectionName.c_str()))
- continue;
- for_each_xml_child_node(childNode, sectionNode)
- {
- if (xmlNameEqual(childNode, itemName.c_str()))
- {
- const int val = XML::getProperty(childNode,
- attributeName.c_str(), -1);
- if (val == -1)
- continue;
- arr.push_back(val);
- }
- else if (xmlNameEqual(childNode, "include"))
- {
- const std::string name = XML::getProperty(
- childNode, "name", "");
- if (!name.empty())
- {
- readXmlIntVector(name,
- rootName,
- sectionName,
- itemName,
- attributeName,
- arr,
- skipError);
- }
- }
- }
- }
-}
-
-void readXmlStringMap(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeKeyName,
- const std::string &attributeValueName,
- std::map<std::string, std::string> &arr,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
- {
- logger->log("Error while loading %s!", fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(sectionNode, rootNode)
- {
- if (!xmlNameEqual(sectionNode, sectionName.c_str()))
- continue;
- for_each_xml_child_node(childNode, sectionNode)
- {
- if (xmlNameEqual(childNode, itemName.c_str()))
- {
- const std::string key = XML::getProperty(childNode,
- attributeKeyName.c_str(), "");
- if (key.empty())
- continue;
- const std::string val = XML::getProperty(childNode,
- attributeValueName.c_str(), "");
- arr[key] = val;
- }
- else if (xmlNameEqual(childNode, "include"))
- {
- const std::string name = XML::getProperty(
- childNode, "name", "");
- if (!name.empty())
- {
- readXmlStringMap(name,
- rootName,
- sectionName,
- itemName,
- attributeKeyName,
- attributeValueName,
- arr,
- skipError);
- }
- }
- }
- }
-}
-
-void readXmlIntMap(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeKeyName,
- const std::string &attributeValueName,
- std::map<int32_t, int32_t> &arr,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
- {
- logger->log("Error while loading %s!", fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(sectionNode, rootNode)
- {
- if (!xmlNameEqual(sectionNode, sectionName.c_str()))
- continue;
- for_each_xml_child_node(childNode, sectionNode)
- {
- if (xmlNameEqual(childNode, itemName.c_str()))
- {
- const std::string key = XML::getProperty(childNode,
- attributeKeyName.c_str(), "");
- if (key.empty())
- continue;
- const int32_t val = XML::getProperty(childNode,
- attributeValueName.c_str(), 0);
- arr[atoi(key.c_str())] = val;
- }
- else if (xmlNameEqual(childNode, "include"))
- {
- const std::string name = XML::getProperty(
- childNode, "name", "");
- if (!name.empty())
- {
- readXmlIntMap(name,
- rootName,
- sectionName,
- itemName,
- attributeKeyName,
- attributeValueName,
- arr,
- skipError);
- }
- }
- }
- }
-}
diff --git a/src/utils/xmlutils.h b/src/utils/xmlutils.h
deleted file mode 100644
index daa0575a8..000000000
--- a/src/utils/xmlutils.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2014-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 UTILS_XMLUTILS_H
-#define UTILS_XMLUTILS_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/vector.h"
-
-#include <string>
-#include <map>
-
-void readXmlIntVector(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeName,
- STD_VECTOR<int> &arr,
- const SkipError skipError);
-
-void readXmlStringMap(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeKeyName,
- const std::string &attributeValueName,
- std::map<std::string, std::string> &arr,
- const SkipError skipError);
-
-void readXmlIntMap(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeKeyName,
- const std::string &attributeValueName,
- std::map<int32_t, int32_t> &arr,
- const SkipError skipError);
-
-#endif // UTILS_XMLUTILS_H
diff --git a/src/utils/xmlwriter.h b/src/utils/xmlwriter.h
deleted file mode 100644
index 8e182d72a..000000000
--- a/src/utils/xmlwriter.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * The ManaPlus Client
- * 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 UTILS_XMLWRITER_H
-#define UTILS_XMLWRITER_H
-
-#ifdef ENABLE_PUGIXML
-#include "utils/xml/pugixmlwriter.h"
-#endif // ENABLE_PUGIXML
-
-#endif // UTILS_XMLWRITER_H