[Scummvm-cvs-logs] SF.net SVN: scummvm:[50422] scummvm/trunk/engines/sci/graphics
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon Jun 28 13:20:33 CEST 2010
Revision: 50422
http://scummvm.svn.sourceforge.net/scummvm/?rev=50422&view=rev
Author: fingolfin
Date: 2010-06-28 11:20:33 +0000 (Mon, 28 Jun 2010)
Log Message:
-----------
SCI: Remove GfxView::getLoopInfo; add assert to GfxView::getCelInfo
The return value of GfxView::getCelInfo was used virtually everywhere
without a check for it being non-NULL. Hence instead of returning
NULL when the loop count is zero, it makes more sense to assert out
(instead of a segfault, or worse, random data being used).
Modified Paths:
--------------
scummvm/trunk/engines/sci/graphics/cache.cpp
scummvm/trunk/engines/sci/graphics/view.cpp
scummvm/trunk/engines/sci/graphics/view.h
Modified: scummvm/trunk/engines/sci/graphics/cache.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/cache.cpp 2010-06-28 11:20:14 UTC (rev 50421)
+++ scummvm/trunk/engines/sci/graphics/cache.cpp 2010-06-28 11:20:33 UTC (rev 50422)
@@ -102,7 +102,7 @@
}
int16 GfxCache::kernelViewGetCelCount(GuiResourceId viewId, int16 loopNo) {
- return getView(viewId)->getLoopInfo(loopNo)->celCount;
+ return getView(viewId)->getCelCount(loopNo);
}
} // End of namespace Sci
Modified: scummvm/trunk/engines/sci/graphics/view.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/view.cpp 2010-06-28 11:20:14 UTC (rev 50421)
+++ scummvm/trunk/engines/sci/graphics/view.cpp 2010-06-28 11:20:33 UTC (rev 50422)
@@ -272,44 +272,49 @@
}
const CelInfo *GfxView::getCelInfo(int16 loopNo, int16 celNo) const {
+ assert(_loopCount);
loopNo = CLIP<int16>(loopNo, 0, _loopCount - 1);
celNo = CLIP<int16>(celNo, 0, _loop[loopNo].celCount - 1);
- return _loopCount ? &_loop[loopNo].cel[celNo] : NULL;
+ return &_loop[loopNo].cel[celNo];
}
-const LoopInfo *GfxView::getLoopInfo(int16 loopNo) const {
- loopNo = CLIP<int16>(loopNo, 0, _loopCount - 1);
- return _loopCount ? &_loop[loopNo] : NULL;
+uint16 GfxView::getCelCount(int16 loopNo) const {
+// assert(_loopCount);
+// loopNo = CLIP<int16>(loopNo, 0, _loopCount - 1);
+ if ((loopNo < 0) || (loopNo >= _loopCount))
+ return 0;
+ return _loop[loopNo].celCount;
}
+Palette *GfxView::getPalette() {
+ return _embeddedPal ? &_viewPalette : NULL;
+}
+
void GfxView::getCelRect(int16 loopNo, int16 celNo, int16 x, int16 y, int16 z, Common::Rect &outRect) const {
const CelInfo *celInfo = getCelInfo(loopNo, celNo);
- if (celInfo) {
- outRect.left = x + celInfo->displaceX - (celInfo->width >> 1);
- outRect.right = outRect.left + celInfo->width;
- outRect.bottom = y + celInfo->displaceY - z + 1;
- outRect.top = outRect.bottom - celInfo->height;
- }
+ outRect.left = x + celInfo->displaceX - (celInfo->width >> 1);
+ outRect.right = outRect.left + celInfo->width;
+ outRect.bottom = y + celInfo->displaceY - z + 1;
+ outRect.top = outRect.bottom - celInfo->height;
}
void GfxView::getCelScaledRect(int16 loopNo, int16 celNo, int16 x, int16 y, int16 z, int16 scaleX, int16 scaleY, Common::Rect &outRect) const {
int16 scaledDisplaceX, scaledDisplaceY;
int16 scaledWidth, scaledHeight;
const CelInfo *celInfo = getCelInfo(loopNo, celNo);
- if (celInfo) {
- // Scaling displaceX/Y, Width/Height
- scaledDisplaceX = (celInfo->displaceX * scaleX) >> 7;
- scaledDisplaceY = (celInfo->displaceY * scaleY) >> 7;
- scaledWidth = (celInfo->width * scaleX) >> 7;
- scaledHeight = (celInfo->height * scaleY) >> 7;
- scaledWidth = CLIP<int16>(scaledWidth, 0, _screen->getWidth());
- scaledHeight = CLIP<int16>(scaledHeight, 0, _screen->getHeight());
- outRect.left = x + scaledDisplaceX - (scaledWidth >> 1);
- outRect.right = outRect.left + scaledWidth;
- outRect.bottom = y + scaledDisplaceY - z + 1;
- outRect.top = outRect.bottom - scaledHeight;
- }
+ // Scaling displaceX/Y, Width/Height
+ scaledDisplaceX = (celInfo->displaceX * scaleX) >> 7;
+ scaledDisplaceY = (celInfo->displaceY * scaleY) >> 7;
+ scaledWidth = (celInfo->width * scaleX) >> 7;
+ scaledHeight = (celInfo->height * scaleY) >> 7;
+ scaledWidth = CLIP<int16>(scaledWidth, 0, _screen->getWidth());
+ scaledHeight = CLIP<int16>(scaledHeight, 0, _screen->getHeight());
+
+ outRect.left = x + scaledDisplaceX - (scaledWidth >> 1);
+ outRect.right = outRect.left + scaledWidth;
+ outRect.bottom = y + scaledDisplaceY - z + 1;
+ outRect.top = outRect.bottom - scaledHeight;
}
void GfxView::unpackCel(int16 loopNo, int16 celNo, byte *outPtr, uint32 pixelCount) {
@@ -660,14 +665,4 @@
}
}
-uint16 GfxView::getCelCount(int16 loopNo) const {
- if ((loopNo < 0) || (loopNo >= _loopCount))
- return 0;
- return _loop[loopNo].celCount;
-}
-
-Palette *GfxView::getPalette() {
- return _embeddedPal ? &_viewPalette : NULL;
-}
-
} // End of namespace Sci
Modified: scummvm/trunk/engines/sci/graphics/view.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/view.h 2010-06-28 11:20:14 UTC (rev 50421)
+++ scummvm/trunk/engines/sci/graphics/view.h 2010-06-28 11:20:33 UTC (rev 50422)
@@ -64,7 +64,6 @@
int16 getWidth(int16 loopNo, int16 celNo) const;
int16 getHeight(int16 loopNo, int16 celNo) const;
const CelInfo *getCelInfo(int16 loopNo, int16 celNo) const;
- const LoopInfo *getLoopInfo(int16 loopNo) const;
void getCelRect(int16 loopNo, int16 celNo, int16 x, int16 y, int16 z, Common::Rect &outRect) const;
void getCelScaledRect(int16 loopNo, int16 celNo, int16 x, int16 y, int16 z, int16 scaleX, int16 scaleY, Common::Rect &outRect) const;
const byte *getBitmap(int16 loopNo, int16 celNo);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list