mirror of
https://github.com/vcmi/vcmi.git
synced 2025-05-15 22:16:37 +02:00
* Fixed the jumping creature animation bug when a unit isn't fully display at the battle screen. The upper creature turret moved (randomly) from left to right during battle and wasn't displayed at the correct x position.
This commit is contained in:
parent
c165593896
commit
f3b5ede486
@ -155,11 +155,10 @@ void CCreatureAnimation::playOnce( CCreatureAnim::EAnimType type )
|
|||||||
template<int bpp>
|
template<int bpp>
|
||||||
int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame /*= true*/, bool yellowBorder /*= false*/, bool blueBorder /*= false*/, SDL_Rect * destRect /*= NULL*/)
|
int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame /*= true*/, bool yellowBorder /*= false*/, bool blueBorder /*= false*/, SDL_Rect * destRect /*= NULL*/)
|
||||||
{
|
{
|
||||||
//increasing frame numer
|
//increasing frame number
|
||||||
int SIndex = curFrame;
|
int SIndex = curFrame;
|
||||||
if (IncrementFrame)
|
if (IncrementFrame)
|
||||||
incrementFrame();
|
incrementFrame();
|
||||||
//frame number increased
|
|
||||||
|
|
||||||
long BaseOffset,
|
long BaseOffset,
|
||||||
SpriteWidth, SpriteHeight, //sprite format
|
SpriteWidth, SpriteHeight, //sprite format
|
||||||
@ -199,35 +198,19 @@ int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attack
|
|||||||
{
|
{
|
||||||
ftcp += LeftMargin;
|
ftcp += LeftMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
TotalRowLength = 0;
|
TotalRowLength = 0;
|
||||||
|
|
||||||
|
// Note: Bug fixed (Rev 2115): The implementation of omitting lines was false.
|
||||||
|
// We've to calculate several things so not showing/putting pixels should suffice.
|
||||||
|
|
||||||
int yB = ftcp / FullWidth + y;
|
int yB = ftcp / FullWidth + y;
|
||||||
|
|
||||||
bool omitIteration = false; //if true, we shouldn't try to blit this line to screen
|
|
||||||
|
|
||||||
if(yB < 0 || yB >= dest->h || (destRect && (destRect->y > yB || destRect->y + destRect->h <= yB ) ) )
|
|
||||||
{
|
|
||||||
//update variables
|
|
||||||
omitIteration = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
SegmentType = FDef[BaseOffset++];
|
SegmentType = FDef[BaseOffset++];
|
||||||
SegmentLength = FDef[BaseOffset++];
|
SegmentLength = FDef[BaseOffset++];
|
||||||
|
|
||||||
|
|
||||||
if(omitIteration)
|
|
||||||
{
|
|
||||||
ftcp += SegmentLength+1;
|
|
||||||
if(SegmentType == 0xFF)
|
|
||||||
{
|
|
||||||
BaseOffset += SegmentLength+1;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int xB = (attacker ? ftcp % FullWidth : FullWidth - ftcp % FullWidth - 1) + x;
|
int xB = (attacker ? ftcp % FullWidth : FullWidth - ftcp % FullWidth - 1) + x;
|
||||||
|
|
||||||
|
|
||||||
@ -235,7 +218,7 @@ int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attack
|
|||||||
|
|
||||||
for (int k = 0; k <= SegmentLength; k++)
|
for (int k = 0; k <= SegmentLength; k++)
|
||||||
{
|
{
|
||||||
if(xB>=0 && xB<dest->w)
|
if(xB >= 0 && xB < dest->w && yB >= 0 && yB < dest->h)
|
||||||
{
|
{
|
||||||
if(!destRect || (destRect->x <= xB && destRect->x + destRect->w > xB))
|
if(!destRect || (destRect->x <= xB && destRect->x + destRect->w > xB))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user