1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

* fixed #438 and crash on ZMM170S.DEF

This commit is contained in:
mateuszb
2010-07-15 16:21:53 +00:00
parent 1c15ee34e5
commit af52f308a2
2 changed files with 5 additions and 9 deletions

View File

@@ -459,6 +459,7 @@ CTerrainRect::CTerrainRect()
pos.h=ADVOPT.advmapH; pos.h=ADVOPT.advmapH;
moveX = moveY = 0; moveX = moveY = 0;
arrows = CDefHandler::giveDef("ADAG.DEF"); arrows = CDefHandler::giveDef("ADAG.DEF");
for(size_t y=0; y < arrows->ourImages.size(); ++y) for(size_t y=0; y < arrows->ourImages.size(); ++y)
{ {
CSDL_Ext::alphaTransform(arrows->ourImages[y].bitmap); CSDL_Ext::alphaTransform(arrows->ourImages[y].bitmap);

View File

@@ -235,21 +235,15 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co
if (SegmentType==0xFF) if (SegmentType==0xFF)
{ {
for (unsigned int k=0; k<SegmentLength;k++) memcpy(reinterpret_cast<char*>(ret->pixels)+ftcp, FDef + BaseOffset, SegmentLength);
{
(reinterpret_cast<char*>(ret->pixels))[ftcp++]=FDef[BaseOffset+k];
if ((TotalRowLength+k)>=SpriteWidth)
break;
}
BaseOffset+=SegmentLength; BaseOffset+=SegmentLength;
TotalRowLength+=SegmentLength;
} }
else else
{ {
memset(reinterpret_cast<char*>(ret->pixels)+ftcp, SegmentType, SegmentLength); memset(reinterpret_cast<char*>(ret->pixels)+ftcp, SegmentType, SegmentLength);
ftcp += SegmentLength;
TotalRowLength += SegmentLength;
} }
ftcp += SegmentLength;
TotalRowLength += SegmentLength;
}while(TotalRowLength<SpriteWidth); }while(TotalRowLength<SpriteWidth);
RowAdd=SpriteWidth-TotalRowLength; RowAdd=SpriteWidth-TotalRowLength;
@@ -322,6 +316,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const unsigned char * FDef, co
unsigned char value = (SegmentType & 31) + 1; unsigned char value = (SegmentType & 31) + 1;
int len = std::min<unsigned int>(value, SpriteWidth - TotalRowLength) - std::max(0, -LeftMargin); int len = std::min<unsigned int>(value, SpriteWidth - TotalRowLength) - std::max(0, -LeftMargin);
amax(len, 0);
if(code==7) if(code==7)
{ {