Fixed a bunch of npc->cond = 0 bugs

This commit is contained in:
Gabriel Ravier 2020-02-06 11:52:49 +01:00
parent f0206600b1
commit 81d672e158
5 changed files with 28 additions and 0 deletions

View file

@ -1621,7 +1621,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
}
}
if (crt->direct == 0)
@ -245,7 +248,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
}
}
crt->rect = rcLeft[crt->ani_no];
@ -449,7 +455,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
}
}
crt->rect = rect[crt->ani_no];
@ -469,7 +478,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
}
}
crt->rect = rcLeft[crt->ani_no];

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
}
}
if (npc->direct == 0)
@ -646,7 +649,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
}
switch (npc->direct)
{
@ -697,7 +703,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;