Permalink
Browse files

EXPERIMENTAL: Reduce mod loading and memory usage by lazy-loading ext…

…raSprites. Test your mods!

(you're welcome XPiratez)
  • Loading branch information...
SupSuper committed Sep 26, 2018
1 parent 6b81936 commit 385a8e68c7d878852b8f3281cb85d43007b68568
Showing with 231 additions and 168 deletions.
  1. +14 −1 src/Mod/ExtraSprites.cpp
  2. +2 −0 src/Mod/ExtraSprites.h
  3. +206 −163 src/Mod/Mod.cpp
  4. +9 −4 src/Mod/Mod.h
@@ -25,7 +25,7 @@ namespace OpenXcom
/**
* Creates a blank set of extra sprite data.
*/
ExtraSprites::ExtraSprites() : _width(320), _height(200), _singleImage(false), _modIndex(0), _subX(0), _subY(0)
ExtraSprites::ExtraSprites() : _width(320), _height(200), _singleImage(false), _modIndex(0), _subX(0), _subY(0), _loaded(false)
{
}
@@ -115,4 +115,17 @@ int ExtraSprites::getSubY() const
return _subY;
}
bool ExtraSprites::lazyLoad()
{
if (_loaded)
{
return true;
}
else
{
_loaded = true;
return false;
}
}
}
@@ -32,6 +32,7 @@ class ExtraSprites
int _width, _height;
bool _singleImage;
int _modIndex, _subX, _subY;
bool _loaded;
public:
/// Creates a blank external sprite set.
ExtraSprites();
@@ -54,6 +55,7 @@ class ExtraSprites
/// Gets the y subdivision.
int getSubY() const;
bool lazyLoad();
};
}
Oops, something went wrong.

0 comments on commit 385a8e6

Please sign in to comment.