Make SetEquFrameIndex safe

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2840 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2007-08-15 06:20:42 +00:00
parent 22ed62d903
commit c8be727068
2 changed files with 18 additions and 15 deletions
+17 -7
View File
@@ -17,6 +17,7 @@
*/ */
#include "gfxintrn.h" #include "gfxintrn.h"
#include "libs/log.h"
FRAME FRAME
CaptureDrawable (DRAWABLE Drawable) CaptureDrawable (DRAWABLE Drawable)
@@ -128,14 +129,23 @@ SetRelFrameIndex (FRAME FramePtr, SIZE FrameOffs)
FRAME FRAME
SetEquFrameIndex (FRAME DstFramePtr, FRAME SrcFramePtr) SetEquFrameIndex (FRAME DstFramePtr, FRAME SrcFramePtr)
{ {
if (DstFramePtr && SrcFramePtr) COUNT Index;
return ((FRAME)(
(BYTE*)((GetFrameParentDrawable (DstFramePtr))->Frame)
+ ((BYTE*)SrcFramePtr -
(BYTE*)((GetFrameParentDrawable (SrcFramePtr))->Frame))
));
return (0); if (!DstFramePtr || !SrcFramePtr)
return 0;
Index = GetFrameIndex (SrcFramePtr);
#ifdef DEBUG
{
DRAWABLE_DESC *DrawablePtr = GetFrameParentDrawable (DstFramePtr);
if (Index > DrawablePtr->MaxIndex)
log_add (log_Debug, "SetEquFrameIndex: source index (%d) beyond "
"destination range (%d)", (int)Index,
(int)DrawablePtr->MaxIndex);
}
#endif
return SetAbsFrameIndex (DstFramePtr, Index);
} }
FRAME FRAME
+1 -8
View File
@@ -921,16 +921,9 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
else else
CALC_ZOOM_STUFF (&index, &scale); CALC_ZOOM_STUFF (&index, &scale);
ElementPtr->next.image.frame = ElementPtr->next.image.frame = SetEquFrameIndex (
#ifdef SAFE
SetAbsFrameIndex (
ElementPtr->next.image.farray[index],
GetFrameIndex (ElementPtr->next.image.frame));
#else /* SAFE */
SetEquFrameIndex (
ElementPtr->next.image.farray[index], ElementPtr->next.image.farray[index],
ElementPtr->next.image.frame); ElementPtr->next.image.frame);
#endif /* SAFE */
if (optMeleeScale == TFB_SCALE_TRILINEAR && if (optMeleeScale == TFB_SCALE_TRILINEAR &&
index < 2 && scale != 256) index < 2 && scale != 256)