summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/Makefile.am2
-rw-r--r--src/resources/loaders/walklayerloader.cpp69
-rw-r--r--src/resources/loaders/walklayerloader.h39
-rw-r--r--src/resources/mapreader.cpp4
-rw-r--r--src/resources/resourcemanager/resourcemanager.cpp37
-rw-r--r--src/resources/resourcemanager/resourcemanager.h2
7 files changed, 116 insertions, 41 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index caea51ea2..e6d3ef40c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -735,6 +735,8 @@ SET(SRCS
resources/loaders/subimageloader.h
resources/loaders/subimagesetloader.cpp
resources/loaders/subimagesetloader.h
+ resources/loaders/walklayerloader.cpp
+ resources/loaders/walklayerloader.h
resources/resourcemanager/resourcemanager.cpp
resources/resourcemanager/resourcemanager.h
resources/safeopenglimagehelper.cpp
@@ -1441,6 +1443,8 @@ SET(DYE_CMD_SRCS
resources/loaders/subimageloader.h
resources/loaders/subimagesetloader.cpp
resources/loaders/subimagesetloader.h
+ resources/loaders/walklayerloader.cpp
+ resources/loaders/walklayerloader.h
resources/resourcemanager/resourcemanager.cpp
resources/resourcemanager/resourcemanager.h
resources/sdl2softwareimagehelper.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 057fe1299..610452f8c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -406,6 +406,8 @@ SRC += events/actionevent.h \
resources/loaders/subimageloader.h \
resources/loaders/subimagesetloader.cpp \
resources/loaders/subimagesetloader.h \
+ resources/loaders/walklayerloader.cpp \
+ resources/loaders/walklayerloader.h \
resources/resourcemanager/resourcemanager.cpp \
resources/resourcemanager/resourcemanager.h \
resources/safeopenglimagehelper.cpp \
diff --git a/src/resources/loaders/walklayerloader.cpp b/src/resources/loaders/walklayerloader.cpp
new file mode 100644
index 000000000..eb2b49826
--- /dev/null
+++ b/src/resources/loaders/walklayerloader.cpp
@@ -0,0 +1,69 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2016 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/resourcemanager/resourcemanager.h"
+
+#include "logger.h"
+#include "navigationmanager.h"
+
+#include "resources/map/walklayer.h"
+
+#include "resources/loaders/walklayerloader.h"
+
+#include "utils/checkutils.h"
+
+#include "debug.h"
+
+#ifndef DYECMD
+struct WalkLayerLoader final
+{
+ const std::string name;
+ Map *map;
+
+ static Resource *load(const void *const v)
+ {
+ if (!v)
+ return nullptr;
+
+ const WalkLayerLoader *const rl = static_cast<const
+ WalkLayerLoader *const>(v);
+ Resource *const resource = NavigationManager::loadWalkLayer(rl->map);
+ if (!resource)
+ reportAlways("WalkLayer creation error");
+ return resource;
+ }
+};
+
+WalkLayer *Loader::getWalkLayer(const std::string &name,
+ Map *const map)
+{
+ WalkLayerLoader rl = {name, map};
+ return static_cast<WalkLayer*>(resourceManager->get("map_" + name,
+ WalkLayerLoader::load, &rl));
+}
+#else
+WalkLayer *Loader::getWalkLayer(const std::string &name A_UNUSED,
+ Map *const map A_UNUSED)
+{
+ return nullptr;
+}
+#endif
diff --git a/src/resources/loaders/walklayerloader.h b/src/resources/loaders/walklayerloader.h
new file mode 100644
index 000000000..d1b91c75e
--- /dev/null
+++ b/src/resources/loaders/walklayerloader.h
@@ -0,0 +1,39 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2016 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_LOADERS_WALKLAYERLOADER_H
+#define RESOURCES_LOADERS_WALKLAYERLOADER_H
+
+#include <string>
+
+#include "localconsts.h"
+
+class Map;
+class WalkLayer;
+
+namespace Loader
+{
+ WalkLayer *getWalkLayer(const std::string &name,
+ Map *const map) A_WARN_UNUSED;
+} // namespace Loader
+
+#endif // RESOURCES_LOADERS_WALKLAYERLOADER_H
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 9cc2542a5..638eb9392 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -49,7 +49,7 @@
#include "resources/loaders/imageloader.h"
-#include "resources/resourcemanager/resourcemanager.h"
+#include "resources/loaders/walklayerloader.h"
#include "utils/base64.h"
#include "utils/delete2.h"
@@ -475,7 +475,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
map->clearIndexedTilesets();
map->setActorsFix(0, atoi(map->getProperty("actorsfix").c_str()));
map->reduce();
- map->setWalkLayer(resourceManager->getWalkLayer(fileName, map));
+ map->setWalkLayer(Loader::getWalkLayer(fileName, map));
unloadTempLayers();
map->updateDrawLayersList();
BLOCK_END("MapReader::readMap xml")
diff --git a/src/resources/resourcemanager/resourcemanager.cpp b/src/resources/resourcemanager/resourcemanager.cpp
index e4a540fc3..dd652c22b 100644
--- a/src/resources/resourcemanager/resourcemanager.cpp
+++ b/src/resources/resourcemanager/resourcemanager.cpp
@@ -527,43 +527,6 @@ Resource *ResourceManager::get(const std::string &idPath,
return resource;
}
-#ifndef DYECMD
-struct WalkLayerLoader final
-{
- const std::string name;
- Map *map;
-
- static Resource *load(const void *const v)
- {
- if (!v)
- return nullptr;
-
- const WalkLayerLoader *const rl = static_cast<const
- WalkLayerLoader *const>(v);
- Resource *const resource = NavigationManager::loadWalkLayer(rl->map);
- if (!resource)
- reportAlways("WalkLayer creation error");
- return resource;
- }
-};
-#endif
-
-#ifndef DYECMD
-WalkLayer *ResourceManager::getWalkLayer(const std::string &name,
- Map *const map)
-{
- WalkLayerLoader rl = {name, map};
- return static_cast<WalkLayer*>(get("map_" + name,
- WalkLayerLoader::load, &rl));
-}
-#else
-WalkLayer *ResourceManager::getWalkLayer(const std::string &name A_UNUSED,
- Map *const map A_UNUSED)
-{
- return nullptr;
-}
-#endif
-
struct SpriteDefLoader final
{
std::string path;
diff --git a/src/resources/resourcemanager/resourcemanager.h b/src/resources/resourcemanager/resourcemanager.h
index f0e184825..582359079 100644
--- a/src/resources/resourcemanager/resourcemanager.h
+++ b/src/resources/resourcemanager/resourcemanager.h
@@ -133,8 +133,6 @@ class ResourceManager final : public MemoryCounter
*/
bool addResource(const std::string &idPath, Resource *const resource);
- WalkLayer *getWalkLayer(const std::string &name, Map *const map);
-
/**
* Creates a sprite definition based on a given path and the supplied
* variant.