summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-07-05 01:53:43 +0300
committerAndrei Karas <akaras@inbox.ru>2017-07-05 01:53:43 +0300
commitebcc8eac47b5860c02413c1e8d4c2f3c553ef20e (patch)
treef785624746aada2dd74cd4df3ffaeebdfadf013b
parentb214e2da42e33d4deadef21f3fe74666fe33e82f (diff)
downloadplus-ebcc8eac47b5860c02413c1e8d4c2f3c553ef20e.tar.gz
plus-ebcc8eac47b5860c02413c1e8d4c2f3c553ef20e.tar.bz2
plus-ebcc8eac47b5860c02413c1e8d4c2f3c553ef20e.tar.xz
plus-ebcc8eac47b5860c02413c1e8d4c2f3c553ef20e.zip
Move resource dbs load/unload code into dbmanager.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/client.cpp105
-rw-r--r--src/resources/dbmanager.cpp135
-rw-r--r--src/resources/dbmanager.h30
5 files changed, 172 insertions, 102 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e91222219..7ca8b0dbd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -637,6 +637,8 @@ SET(SRCS
resources/db/commandsdb.h
resources/cursors.cpp
resources/cursors.h
+ resources/dbmanager.cpp
+ resources/dbmanager.h
resources/delayedmanager.cpp
resources/delayedmanager.h
resources/db/deaddb.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 87c06296d..3c05b05bf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -932,6 +932,8 @@ SRC = ${BASE_SRC} \
actions/windows.h \
client.cpp \
client.h \
+ resources/dbmanager.cpp \
+ resources/dbmanager.h \
resources/sprite/imagesprite.cpp \
resources/sprite/imagesprite.h \
resources/inventory/inventory.cpp \
diff --git a/src/client.cpp b/src/client.cpp
index 4a82ee9ce..322315e50 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -102,38 +102,9 @@
#include "particle/particleengine.h"
+#include "resources/dbmanager.h"
#include "resources/imagehelper.h"
-#include "resources/db/avatardb.h"
-#include "resources/db/badgesdb.h"
-#include "resources/db/chardb.h"
-#include "resources/db/colordb.h"
-#include "resources/db/deaddb.h"
-#include "resources/db/elementaldb.h"
-#include "resources/db/emotedb.h"
-#include "resources/db/homunculusdb.h"
-#include "resources/db/horsedb.h"
-#include "resources/db/itemdb.h"
-#include "resources/db/itemfielddb.h"
-#include "resources/db/itemoptiondb.h"
-#include "resources/db/languagedb.h"
-#include "resources/db/sounddb.h"
-#include "resources/db/mapdb.h"
-#include "resources/db/mercenarydb.h"
-#include "resources/db/moddb.h"
-#include "resources/db/monsterdb.h"
-#include "resources/db/networkdb.h"
-#include "resources/db/npcdb.h"
-#include "resources/db/npcdialogdb.h"
-#include "resources/db/palettedb.h"
-#include "resources/db/petdb.h"
-#include "resources/db/skillunitdb.h"
-#include "resources/db/statdb.h"
-#include "resources/db/statuseffectdb.h"
-#include "resources/db/textdb.h"
-#include "resources/db/unitsdb.h"
-#include "resources/db/weaponsdb.h"
-
#include "resources/dye/dyepalette.h"
#include "resources/resourcemanager/resourcemanager.h"
@@ -649,40 +620,7 @@ void Client::gameClear()
windowContainer->slowLogic();
stopTimers();
-
- // Unload XML databases
- CharDB::unload();
- StatDb::unload();
- DeadDB::unload();
- ColorDB::unload();
- SoundDB::unload();
- LanguageDb::unload();
- TextDb::unload();
- EmoteDB::unload();
- ItemDB::unload();
- ItemOptionDb::unload();
- ItemFieldDb::unload();
- const ServerTypeT type = Net::getNetworkType();
- if (type == ServerType::EATHENA ||
- type == ServerType::EVOL2)
- {
- MercenaryDB::unload();
- HomunculusDB::unload();
- ElementalDb::unload();
- SkillUnitDb::unload();
- HorseDB::unload();
- NetworkDb::unload();
- }
- MonsterDB::unload();
- NPCDB::unload();
- NpcDialogDB::unload();
- AvatarDB::unload();
- BadgesDB::unload();
- WeaponsDB::unload();
- PaletteDB::unload();
- PETDB::unload();
- StatusEffectDB::unload();
- ModDB::unload();
+ DbManager::unloadDb();
if (loginHandler != nullptr)
loginHandler->clearWorlds();
@@ -1385,44 +1323,7 @@ int Client::gameExec()
spellShortcut = new SpellShortcut;
AttributesEnum::init();
- // Load XML databases
- CharDB::load();
- StatDb::load();
- DeadDB::load();
- PaletteDB::load();
- ColorDB::load();
- SoundDB::load();
- LanguageDb::load();
- TextDb::load();
- MapDB::load();
- ItemFieldDb::load();
- ItemOptionDb::load();
- ItemDB::load();
- Being::load();
- const ServerTypeT type = Net::getNetworkType();
- if (type == ServerType::EATHENA ||
- type == ServerType::EVOL2)
- {
- NetworkDb::load();
- if (loginHandler != nullptr)
- loginHandler->updatePacketVersion();
- MercenaryDB::load();
- HomunculusDB::load();
- ElementalDb::load();
- SkillUnitDb::load();
- HorseDB::load();
- }
- MonsterDB::load();
- AvatarDB::load();
- BadgesDB::load();
- WeaponsDB::load();
- UnitsDb::loadUnits();
- NPCDB::load();
- NpcDialogDB::load();
- PETDB::load();
- EmoteDB::load();
-// ModDB::load();
- StatusEffectDB::load();
+ DbManager::loadDb();
EquipmentWindow::prepareSlotNames();
ActorSprite::load();
diff --git a/src/resources/dbmanager.cpp b/src/resources/dbmanager.cpp
new file mode 100644
index 000000000..47a9deeee
--- /dev/null
+++ b/src/resources/dbmanager.cpp
@@ -0,0 +1,135 @@
+/*
+ * 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 "resources/dbmanager.h"
+
+#include "being/being.h"
+
+#include "net/loginhandler.h"
+#include "net/net.h"
+
+#include "resources/db/avatardb.h"
+#include "resources/db/badgesdb.h"
+#include "resources/db/chardb.h"
+#include "resources/db/colordb.h"
+#include "resources/db/deaddb.h"
+#include "resources/db/elementaldb.h"
+#include "resources/db/emotedb.h"
+#include "resources/db/homunculusdb.h"
+#include "resources/db/horsedb.h"
+#include "resources/db/itemdb.h"
+#include "resources/db/itemfielddb.h"
+#include "resources/db/itemoptiondb.h"
+#include "resources/db/languagedb.h"
+#include "resources/db/sounddb.h"
+#include "resources/db/mapdb.h"
+#include "resources/db/mercenarydb.h"
+#include "resources/db/moddb.h"
+#include "resources/db/monsterdb.h"
+#include "resources/db/networkdb.h"
+#include "resources/db/npcdb.h"
+#include "resources/db/npcdialogdb.h"
+#include "resources/db/palettedb.h"
+#include "resources/db/petdb.h"
+#include "resources/db/skillunitdb.h"
+#include "resources/db/statdb.h"
+#include "resources/db/statuseffectdb.h"
+#include "resources/db/textdb.h"
+#include "resources/db/unitsdb.h"
+#include "resources/db/weaponsdb.h"
+
+#include "debug.h"
+
+void DbManager::loadDb()
+{
+ CharDB::load();
+ StatDb::load();
+ DeadDB::load();
+ PaletteDB::load();
+ ColorDB::load();
+ SoundDB::load();
+ LanguageDb::load();
+ TextDb::load();
+ MapDB::load();
+ ItemFieldDb::load();
+ ItemOptionDb::load();
+ ItemDB::load();
+ Being::load();
+ const ServerTypeT type = Net::getNetworkType();
+ if (type == ServerType::EATHENA ||
+ type == ServerType::EVOL2)
+ {
+ NetworkDb::load();
+ if (loginHandler != nullptr)
+ loginHandler->updatePacketVersion();
+ MercenaryDB::load();
+ HomunculusDB::load();
+ ElementalDb::load();
+ SkillUnitDb::load();
+ HorseDB::load();
+ }
+ MonsterDB::load();
+ AvatarDB::load();
+ BadgesDB::load();
+ WeaponsDB::load();
+ UnitsDb::loadUnits();
+ NPCDB::load();
+ NpcDialogDB::load();
+ PETDB::load();
+ EmoteDB::load();
+// ModDB::load();
+ StatusEffectDB::load();
+}
+
+void DbManager::unloadDb()
+{
+ CharDB::unload();
+ StatDb::unload();
+ DeadDB::unload();
+ ColorDB::unload();
+ SoundDB::unload();
+ LanguageDb::unload();
+ TextDb::unload();
+ EmoteDB::unload();
+ ItemDB::unload();
+ ItemOptionDb::unload();
+ ItemFieldDb::unload();
+ const ServerTypeT type = Net::getNetworkType();
+ if (type == ServerType::EATHENA ||
+ type == ServerType::EVOL2)
+ {
+ MercenaryDB::unload();
+ HomunculusDB::unload();
+ ElementalDb::unload();
+ SkillUnitDb::unload();
+ HorseDB::unload();
+ NetworkDb::unload();
+ }
+ MonsterDB::unload();
+ NPCDB::unload();
+ NpcDialogDB::unload();
+ AvatarDB::unload();
+ BadgesDB::unload();
+ WeaponsDB::unload();
+ PaletteDB::unload();
+ PETDB::unload();
+ StatusEffectDB::unload();
+ ModDB::unload();
+}
diff --git a/src/resources/dbmanager.h b/src/resources/dbmanager.h
new file mode 100644
index 000000000..3aceacb0e
--- /dev/null
+++ b/src/resources/dbmanager.h
@@ -0,0 +1,30 @@
+/*
+ * 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 RESOURCES_DBMANAGER_H
+#define RESOURCES_DBMANAGER_H
+
+namespace DbManager
+{
+ void loadDb();
+ void unloadDb();
+}
+
+#endif // RESOURCES_DBMANAGER_H