summaryrefslogtreecommitdiff
path: root/src/resources/spritedef.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-10 00:33:27 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-10 00:33:27 +0300
commita0c7a0e2d34a13f2c3e86f662e352977ebe2ae73 (patch)
tree15996308da765b18751048c6bdaeb81926959328 /src/resources/spritedef.cpp
parentc5ff42706d5ff540b5f557fa1a2b1924a6cdf07b (diff)
downloadmanaplus-a0c7a0e2d34a13f2c3e86f662e352977ebe2ae73.tar.gz
manaplus-a0c7a0e2d34a13f2c3e86f662e352977ebe2ae73.tar.bz2
manaplus-a0c7a0e2d34a13f2c3e86f662e352977ebe2ae73.tar.xz
manaplus-a0c7a0e2d34a13f2c3e86f662e352977ebe2ae73.zip
Add option to left all per map sprites in memory if once was loaded.
This can prevent random lags and also can use more memory.
Diffstat (limited to 'src/resources/spritedef.cpp')
-rw-r--r--src/resources/spritedef.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index ff9b71901..b417345fd 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -73,7 +73,8 @@ unsigned SpriteDef::findNumber(const unsigned num) const
return min;
}
-SpriteDef *SpriteDef::load(const std::string &animationFile, const int variant)
+SpriteDef *SpriteDef::load(const std::string &animationFile,
+ const int variant, bool prot)
{
const size_t pos = animationFile.find('|');
std::string palettes;
@@ -90,7 +91,7 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, const int variant)
std::string errorFile = paths.getStringValue("sprites").append(
paths.getStringValue("spriteErrorFile"));
if (animationFile != errorFile)
- return load(errorFile, 0);
+ return load(errorFile, 0, prot);
else
return nullptr;
}
@@ -101,6 +102,11 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, const int variant)
def->substituteActions();
if (serverVersion < 1)
def->fixDeadAction();
+ if (prot)
+ {
+ def->incRef();
+ def->setProtected(true);
+ }
return def;
}