- added the SHOOT event and fixed some issues with poor code generation for the game data accessors.

They created different code depending on the passed index, this was changed to always emit the optional parameter, even when not needed, so that the interpreter does not need to second-guess.
This commit is contained in:
Christoph Oelckers 2020-09-17 23:02:52 +02:00
parent 8fa5d3d9d2
commit f5d14f826a
6 changed files with 31 additions and 11 deletions

View file

@ -361,6 +361,8 @@ enum
EVENT_USEMEDKIT,
EVENT_USEJETPACK,
EVENT_TURNAROUND,
// The ones in-between here are not supported and many may never be.
EVENT_SHOOT = 51,
EVENT_NUMEVENTS,
EVENT_MAXEVENT = EVENT_NUMEVENTS - 1

View file

@ -2014,7 +2014,7 @@ int ConCompiler::parsecommand()
appendscriptvalue(sectorlabels[lLabelID].lId);
if (sectorlabels[lLabelID].flags & LABEL_HASPARM2)
{
getlabel();
getlabel();
checkforkeyword();
@ -2027,6 +2027,7 @@ int ConCompiler::parsecommand()
}
appendscriptvalue(i);
}
else appendscriptvalue(0);
// now at target VAR...
@ -2239,6 +2240,7 @@ int ConCompiler::parsecommand()
}
appendscriptvalue(i); // the ID of the DEF (offset into array...)
}
else appendscriptvalue(0);
// now at target VAR...
@ -2337,6 +2339,7 @@ int ConCompiler::parsecommand()
}
appendscriptvalue(i); // the ID of the DEF (offset into array...)
}
else appendscriptvalue(0);
// now at target VAR...
getlabel();
@ -2413,6 +2416,7 @@ int ConCompiler::parsecommand()
}
appendscriptvalue(i); // the ID of the DEF (offset into array...)
}
else appendscriptvalue(0);
// now at target VAR...
@ -2611,6 +2615,7 @@ int ConCompiler::parsecommand()
}
appendscriptvalue(i); // the ID of the DEF (offset into array...)
}
else appendscriptvalue(0);
// now at target VAR...

View file

@ -2884,6 +2884,7 @@ int ParseState::parse(void)
lWhat = *(insptr++);
lVar1 = *(insptr++);
lLabelID = *(insptr++);
lParm2 = *(insptr++);
lVar2 = *(insptr++);
DoSector(lWhat == concmd_setsector, lVar1, lLabelID, lVar2, g_i, g_p, lParm2);
break;
@ -3007,15 +3008,7 @@ int ParseState::parse(void)
lWhat = *(insptr++);
lVar1 = *(insptr++);
lLabelID = *(insptr++);
// HACK: need to have access to labels structure at run-time...
if (lLabelID == PLAYER_AMMO_AMOUNT)
{
lParm2 = *(insptr++);
}
else
{
lParm2 = 0;
}
lParm2 = *(insptr++);
lVar2 = *(insptr++);
DoPlayer(lWhat == concmd_setplayer, lVar1, lLabelID, lVar2, g_i, g_p, lParm2);
@ -3034,6 +3027,7 @@ int ParseState::parse(void)
lWhat = *(insptr++);
lVar1 = -1;
lLabelID = *(insptr++);
lParm2 = *(insptr++);
lVar2 = *(insptr++);
DoUserDef(lWhat == concmd_setuserdef, lVar1, lLabelID, lVar2, g_i, g_p, lParm2);
@ -3052,6 +3046,7 @@ int ParseState::parse(void)
lWhat = *(insptr++);
lVar1 = *(insptr++);
lLabelID = *(insptr++);
lParm2 = *(insptr++);
lVar2 = *(insptr++);
DoWall(lWhat == concmd_setwall, lVar1, lLabelID, lVar2, g_i, g_p, lParm2);
@ -3116,6 +3111,7 @@ int ParseState::parse(void)
lWhat = *(insptr++);
lVar1 = *(insptr++);
lLabelID = *(insptr++);
lParm2 = *(insptr++);
lVar2 = *(insptr++);
DoActor(lWhat == concmd_setactor, lVar1, lLabelID, lVar2, g_i, g_p, lParm2);

View file

@ -112,6 +112,7 @@ extern int g_iWorksLikeVarID; // var ID of "WORKSLIKE"
extern int g_iZRangeVarID; // var ID of "ZRANGE"
extern int g_iAngRangeVarID; // var ID of "ANGRANGE"
extern int g_iAimAngleVarID; // var ID of "AUTOAIMANGLE"
extern int g_iAtWithVarID; // var ID of "AtWith"
extern int g_iLoTagID; // var ID of "LOTAG"
extern int g_iHiTagID; // ver ID of "HITAG"
extern int g_iTextureID; // var ID of "TEXTURE"

View file

@ -101,7 +101,15 @@ void shoot_d(int i, int atwith)
p = -1;
}
SetGameVarID(g_iAtWithVarID, 0, p, atwith);
SetGameVarID(g_iReturnVarID, 0, p, i);
OnEvent(EVENT_SHOOT, i, p, -1);
if (GetGameVarID(g_iReturnVarID, p, i) != 0)
{
return;
}
sect = s->sectnum;
zvel = 0;

View file

@ -124,6 +124,14 @@ void shoot_r(int i, int atwith)
}
}
SetGameVarID(g_iAtWithVarID, 0, p, atwith);
SetGameVarID(g_iReturnVarID, 0, p, i);
OnEvent(EVENT_SHOOT, i, p, -1);
if (GetGameVarID(g_iReturnVarID, p, i) != 0)
{
return;
}
switch (atwith)
{
case SLINGBLADE: