GRIM: Hide the zbuffer bitmap if it doesn't have the wanted image. Fix #296

This commit is contained in:
Giulio Camuffo
2011-07-27 16:30:59 +02:00
parent 2d9b1240ce
commit 075c1cae7d
3 changed files with 16 additions and 3 deletions
+8
View File
@@ -296,6 +296,14 @@ void Bitmap::draw() const {
g_driver->drawBitmap(this);
}
void Bitmap::setNumber(int n) {
if ((n - 1) >= _data->_numImages) {
warning("Bitmap::setNumber: no anim image: %d. (%s)", n, _data->_fname.c_str());
} else {
_currImage = n;
}
}
Bitmap::~Bitmap() {
--_data->_refCount;
if (_data->_refCount < 1) {
+1 -1
View File
@@ -75,7 +75,7 @@ public:
void draw() const;
// Set which image in an animated bitmap to use
void setNumber(int n) { if ((n - 1) >= _data->_numImages) warning("Bitmap::setNumber: no anim image: %d", n); else _currImage = n; }
void setNumber(int n);
int getNumImages() const { return _data->_numImages; }
int getCurrentImage() const { return _currImage; }
+7 -2
View File
@@ -63,8 +63,13 @@ void ObjectState::setNumber(int val) {
if (val) {
assert(_bitmap);
_bitmap->setNumber(val);
if (_zbitmap)
_zbitmap->setNumber(val);
if (_zbitmap) {
if (val > _zbitmap->getNumImages()) {
_zbitmap->setNumber(0);
} else {
_zbitmap->setNumber(val);
}
}
}
_visibility = val != 0;