diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-07-24 00:13:24 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-07-24 00:13:24 +0000 |
commit | 4789ebb11407eb9402c385f3cc6fa242d91214c2 (patch) | |
tree | 6bf5bed52073ae19ef4b5b08e7fe92af603f04d8 /src/engine.cpp | |
parent | 1b7ff9ad4160fd0ff79d2da658eca8d8c8abf815 (diff) | |
download | mana-4789ebb11407eb9402c385f3cc6fa242d91214c2.tar.gz mana-4789ebb11407eb9402c385f3cc6fa242d91214c2.tar.bz2 mana-4789ebb11407eb9402c385f3cc6fa242d91214c2.tar.xz mana-4789ebb11407eb9402c385f3cc6fa242d91214c2.zip |
Implemented caching of spritesets, including a lot of cleanups to the new
animation system. Action now refers to the Spriteset directly and
AnimatedSprite refers to the current Action directly instead of using the
std::map with a std::string constantly. Some methods and parameters are marked
as const. The READ_PROP macro was replaced by static methods. Warnings are
logged when unnamed actions are defined or when actions refer to undefined
imagesets. Code is more tolerant towards missing actions.
Diffstat (limited to 'src/engine.cpp')
-rw-r--r-- | src/engine.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index c5cf5c1a..b1fb9b4b 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -38,8 +38,6 @@ #include "map.h" #include "sound.h" -#include "graphic/spriteset.h" - #include "gui/gui.h" #include "gui/minimap.h" @@ -49,6 +47,7 @@ #include "resources/itemmanager.h" #include "resources/mapreader.h" #include "resources/resourcemanager.h" +#include "resources/spriteset.h" #include "utils/dtor.h" #include "utils/tostring.h" @@ -75,12 +74,12 @@ Engine::Engine(Network *network): // Load the sprite sets ResourceManager *resman = ResourceManager::getInstance(); - npcset = resman->createSpriteset("graphics/sprites/npcs.png", 50, 80); - emotionset = resman->createSpriteset("graphics/sprites/emotions.png", + npcset = resman->getSpriteset("graphics/sprites/npcs.png", 50, 80); + emotionset = resman->getSpriteset("graphics/sprites/emotions.png", 30, 32); for (int i = 0; i < 2; i++) { - Spriteset *tmp = ResourceManager::getInstance()->createSpriteset( + Spriteset *tmp = ResourceManager::getInstance()->getSpriteset( "graphics/sprites/weapon" + toString(i) + ".png", 64, 64); if (!tmp) { logger->error("Unable to load weaponset"); @@ -88,11 +87,10 @@ Engine::Engine(Network *network): weaponset.push_back(tmp); } } - itemset = resman->createSpriteset("graphics/sprites/items.png", 32, 32); + itemset = resman->getSpriteset("graphics/sprites/items.png", 32, 32); if (!npcset) logger->error("Unable to load NPC spriteset!"); if (!emotionset) logger->error("Unable to load emotions spriteset!"); - //if (!weaponset) logger->error("Unable to load weapon spriteset!"); if (!itemset) logger->error("Unable to load item spriteset!"); // Initialize item manager @@ -102,11 +100,16 @@ Engine::Engine(Network *network): Engine::~Engine() { // Delete sprite sets - delete npcset; - delete emotionset; - for_each(weaponset.begin(), weaponset.end(), make_dtor(weaponset)); + npcset->decRef(); + emotionset->decRef(); + itemset->decRef(); + + std::vector<Spriteset *>::iterator iter; + for (iter = weaponset.begin(); iter != weaponset.end(); ++iter) + { + (*iter)->decRef(); + } weaponset.clear(); - delete itemset; delete itemDb; |