Merge pull request #101 from GabrielRavier/fixPortableBugs2

Fixed a bunch of npc->cond = 0 bugs
This commit is contained in:
Clownacy 2020-04-06 13:55:58 +01:00 committed by GitHub
commit 12e4be58ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 0 deletions

View file

@ -1640,7 +1640,10 @@ void ActBullet_Edge(BULLET *bul)
bul->damage = 1;
if (bul->ani_no > 4)
{
bul->cond = 0;
return; // Prevent UB at rc[bul->ani_no] when bul->ani_no == 5
}
break;
}

View file

@ -73,7 +73,10 @@ void ActCaret01(CARET *crt)
{
crt->ani_wait = 0;
if (++crt->ani_no > 3)
{
crt->cond = 0;
return; // Prevent UB at rc[crt->ani_no] when crt->ani_no == 4
}
}
// Note that 'crt->ani_no' can exceed the size of 'rcLeft' and 'rcRight'
@ -247,7 +250,10 @@ void ActCaret07(CARET *crt)
crt->ani_wait = 0;
if (++crt->ani_no > 6)
{
crt->cond = 0;
return; // Prevent UB at rcLeft[crt->ani_no] when crt->ani_no == 6
}
}
// Note that 'crt->ani_no' can exceed the size of rcLeft
@ -453,7 +459,10 @@ void ActCaret14(CARET *crt)
crt->ani_wait = 0;
if (++crt->ani_no > 4)
{
crt->cond = 0;
return; // Prevent UB at rect[crt->ani_no] when crt->ani_no == 5
}
}
// Note that 'crt->ani_no' can exceed the size of 'rect'
@ -475,7 +484,10 @@ void ActCaret15(CARET *crt)
crt->ani_wait = 0;
if (++crt->ani_no > 3)
{
crt->cond = 0;
return; // Prevent UB at rcLeft[crt->ani_no] when crt->ani_no == 4
}
}
// Note that 'crt->ani_no' can exceed the size of 'rcLeft'

View file

@ -585,7 +585,10 @@ void ActNpc127(NPCHAR *npc)
{
npc->ani_wait = 0;
if (++npc->ani_no > 2)
{
npc->cond = 0;
return; // Prevent UB at rc[npc->ani_no] when npc->ani_no == 3
}
}
// Note that 'npc->ani_no' can exceed the size of 'rcH' and 'rcV'
@ -648,7 +651,10 @@ void ActNpc128(NPCHAR *npc)
}
if (++npc->ani_no > 4)
{
npc->cond = 0;
return; // Prevent UB at rc[npc->ani_no] when npc->ani_no == 5
}
// Note that 'npc->ani_no' can exceed the bounds of 'rcLeft', 'rcUp', 'rcRight' and 'rcDown'
@ -701,7 +707,10 @@ void ActNpc129(NPCHAR *npc)
npc->ani_wait = 0;
if (++npc->ani_no > 2)
{
npc->cond = 0;
return; // Prevent UB at rect[(npc->direct * 3) + npc->ani_no] when npc->direct == 5 and npc->ani_no == 3
}
}
npc->y += npc->ym;

View file

@ -753,6 +753,7 @@ void ActNpc146(NPCHAR *npc)
{
SetDestroyNpChar(npc->x, npc->y, 0x1000, 8);
npc->cond = 0;
return; // Prevent UB at rect[npc->ani_no] when npc->ani_no == 5
}
break;

View file

@ -1426,7 +1426,10 @@ void ActNpc199(NPCHAR *npc)
}
if (npc->ani_no > 4)
{
npc->cond = 0;
return; // Prevent UB at rect[npc->ani_no] when npc->ani_no == 5
}
npc->x += npc->xm;
npc->y += npc->ym;