mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-19 07:01:09 +00:00
- Duke: fix management of killit_flag.
This cannot be in the actor because event scripts can be called without a valid actor. It is now part of the parse state, but execute allows returning it to the caller, which is needed in one place.
This commit is contained in:
parent
89dfac62a9
commit
c19653262e
8 changed files with 21 additions and 20 deletions
|
@ -50,9 +50,9 @@ This file is a combination of code from the following sources:
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
|
||||||
void moveactor(DDukeActor* actor, int p, double pdist)
|
void moveactor(DDukeActor* actor, int p, double pdist, const int killit_flag)
|
||||||
{
|
{
|
||||||
if (actor->killit_flag == 1)
|
if (killit_flag == 1)
|
||||||
{
|
{
|
||||||
// if player was set to squish, first stop that..
|
// if player was set to squish, first stop that..
|
||||||
if (ps[p].actorsqu == actor)
|
if (ps[p].actorsqu == actor)
|
||||||
|
@ -131,8 +131,8 @@ void TickActor(DDukeActor* self)
|
||||||
self->curframe = 0;
|
self->curframe = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->killit_flag = 0;
|
int killit_flag = 0;
|
||||||
bool conres = execute(self, p, pdist);
|
bool conres = execute(self, p, pdist, &killit_flag);
|
||||||
if (!conres && (self->flags4 & SFLAG4_CONOVERRIDE))
|
if (!conres && (self->flags4 & SFLAG4_CONOVERRIDE))
|
||||||
{
|
{
|
||||||
self->flags4 |= SFLAG4_INRUNSTATE;
|
self->flags4 |= SFLAG4_INRUNSTATE;
|
||||||
|
@ -145,6 +145,7 @@ void TickActor(DDukeActor* self)
|
||||||
}
|
}
|
||||||
catch(const CDukeKillEvent& ev)
|
catch(const CDukeKillEvent& ev)
|
||||||
{
|
{
|
||||||
|
killit_flag = 1;
|
||||||
if (ev.Type() == 1)
|
if (ev.Type() == 1)
|
||||||
{
|
{
|
||||||
self->Destroy();
|
self->Destroy();
|
||||||
|
@ -156,7 +157,7 @@ void TickActor(DDukeActor* self)
|
||||||
conres = true;
|
conres = true;
|
||||||
}
|
}
|
||||||
// moveactor gets only called for actors with a scripted runner.
|
// moveactor gets only called for actors with a scripted runner.
|
||||||
if (conres) moveactor(self, p, pdist);
|
if (conres) moveactor(self, p, pdist, killit_flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ DDukeActor* LocateTheLocator(int n, sectortype* sectnum);
|
||||||
void clearcamera(player_struct* ps);
|
void clearcamera(player_struct* ps);
|
||||||
|
|
||||||
void LoadActor(DDukeActor* i, int p, int x);
|
void LoadActor(DDukeActor* i, int p, int x);
|
||||||
bool execute(DDukeActor* s, int p, double d);
|
bool execute(DDukeActor* s, int p, double d, int* killit_flag = nullptr);
|
||||||
void makeitfall(DDukeActor* s);
|
void makeitfall(DDukeActor* s);
|
||||||
DAngle furthestangle(DDukeActor* snum, int angDiv);
|
DAngle furthestangle(DDukeActor* snum, int angDiv);
|
||||||
void getglobalz(DDukeActor* s);
|
void getglobalz(DDukeActor* s);
|
||||||
|
|
|
@ -68,6 +68,7 @@ enum playeraction_t {
|
||||||
|
|
||||||
struct ParseState
|
struct ParseState
|
||||||
{
|
{
|
||||||
|
int killit_flag;
|
||||||
int g_p;
|
int g_p;
|
||||||
int g_x;
|
int g_x;
|
||||||
DDukeActor *g_ac;
|
DDukeActor *g_ac;
|
||||||
|
@ -1473,7 +1474,7 @@ int ParseState::parse(void)
|
||||||
{
|
{
|
||||||
int j, l;
|
int j, l;
|
||||||
|
|
||||||
if(g_ac->killit_flag) return 1;
|
if(killit_flag) return 1;
|
||||||
|
|
||||||
switch (*insptr)
|
switch (*insptr)
|
||||||
{
|
{
|
||||||
|
@ -1779,7 +1780,7 @@ int ParseState::parse(void)
|
||||||
return 1;
|
return 1;
|
||||||
case concmd_addammo:
|
case concmd_addammo:
|
||||||
insptr++;
|
insptr++;
|
||||||
if (!playeraddammo(&ps[g_p], *insptr, *(insptr + 1))) g_ac->killit_flag = 2;
|
if (!playeraddammo(&ps[g_p], *insptr, *(insptr + 1))) killit_flag = 2;
|
||||||
insptr += 2;
|
insptr += 2;
|
||||||
break;
|
break;
|
||||||
case concmd_money:
|
case concmd_money:
|
||||||
|
@ -1813,11 +1814,11 @@ int ParseState::parse(void)
|
||||||
break;
|
break;
|
||||||
case concmd_killit:
|
case concmd_killit:
|
||||||
insptr++;
|
insptr++;
|
||||||
g_ac->killit_flag = 1;
|
killit_flag = 1;
|
||||||
break;
|
break;
|
||||||
case concmd_addweapon:
|
case concmd_addweapon:
|
||||||
insptr++;
|
insptr++;
|
||||||
if (!playeraddweapon(&ps[g_p], *insptr, *(insptr + 1))) g_ac->killit_flag = 2;
|
if (!playeraddweapon(&ps[g_p], *insptr, *(insptr + 1))) killit_flag = 2;
|
||||||
insptr+=2;
|
insptr+=2;
|
||||||
break;
|
break;
|
||||||
case concmd_debug:
|
case concmd_debug:
|
||||||
|
@ -3157,7 +3158,7 @@ int ParseState::parse(void)
|
||||||
default:
|
default:
|
||||||
Printf(TEXTCOLOR_RED "Unrecognized PCode of %d in parse. Killing current sprite.\n",*insptr);
|
Printf(TEXTCOLOR_RED "Unrecognized PCode of %d in parse. Killing current sprite.\n",*insptr);
|
||||||
Printf(TEXTCOLOR_RED "Offset=%0X\n",int(insptr-ScriptCode.Data()));
|
Printf(TEXTCOLOR_RED "Offset=%0X\n",int(insptr-ScriptCode.Data()));
|
||||||
g_ac->killit_flag = 1;
|
killit_flag = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3179,6 +3180,7 @@ void LoadActor(DDukeActor *actor, int p, int x)
|
||||||
s.g_p = p; // Player ID
|
s.g_p = p; // Player ID
|
||||||
s.g_x = x; // ??
|
s.g_x = x; // ??
|
||||||
s.g_ac = actor;
|
s.g_ac = actor;
|
||||||
|
s.killit_flag = 0;
|
||||||
|
|
||||||
if ((actor->flags4 & SFLAG4_CONOVERRIDE) && overridecon) return;
|
if ((actor->flags4 & SFLAG4_CONOVERRIDE) && overridecon) return;
|
||||||
auto coninf = actor->conInfo();
|
auto coninf = actor->conInfo();
|
||||||
|
@ -3186,7 +3188,6 @@ void LoadActor(DDukeActor *actor, int p, int x)
|
||||||
auto addr = coninf->loadeventscriptptr;
|
auto addr = coninf->loadeventscriptptr;
|
||||||
if (addr == 0) return;
|
if (addr == 0) return;
|
||||||
|
|
||||||
actor->killit_flag = 0;
|
|
||||||
|
|
||||||
if(!actor->insector())
|
if(!actor->insector())
|
||||||
{
|
{
|
||||||
|
@ -3197,7 +3198,7 @@ void LoadActor(DDukeActor *actor, int p, int x)
|
||||||
done = s.parse();
|
done = s.parse();
|
||||||
while (done == 0);
|
while (done == 0);
|
||||||
|
|
||||||
if (actor->killit_flag == 1)
|
if (s.killit_flag == 1)
|
||||||
{
|
{
|
||||||
actor->Destroy();
|
actor->Destroy();
|
||||||
}
|
}
|
||||||
|
@ -3209,8 +3210,9 @@ void LoadActor(DDukeActor *actor, int p, int x)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool execute(DDukeActor *actor,int p,double pdist)
|
bool execute(DDukeActor *actor,int p,double pdist, int* killit_flag)
|
||||||
{
|
{
|
||||||
|
if (killit_flag) *killit_flag = 0;
|
||||||
if ((actor->flags4 & SFLAG4_CONOVERRIDE) && overridecon) return false;
|
if ((actor->flags4 & SFLAG4_CONOVERRIDE) && overridecon) return false;
|
||||||
|
|
||||||
auto coninf = actor->conInfo();
|
auto coninf = actor->conInfo();
|
||||||
|
@ -3221,12 +3223,15 @@ bool execute(DDukeActor *actor,int p,double pdist)
|
||||||
s.g_p = p; // Player ID
|
s.g_p = p; // Player ID
|
||||||
s.g_x = int(pdist / maptoworld); // ??
|
s.g_x = int(pdist / maptoworld); // ??
|
||||||
s.g_ac = actor;
|
s.g_ac = actor;
|
||||||
|
s.killit_flag = 0;
|
||||||
s.insptr = coninf? &ScriptCode[4 + coninf->scriptaddress] : nullptr;
|
s.insptr = coninf? &ScriptCode[4 + coninf->scriptaddress] : nullptr;
|
||||||
|
|
||||||
int done;
|
int done;
|
||||||
do
|
do
|
||||||
done = s.parse();
|
done = s.parse();
|
||||||
while( done == 0 );
|
while( done == 0 );
|
||||||
|
if (killit_flag) *killit_flag = s.killit_flag;
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3259,7 +3264,7 @@ void OnEvent(int iEventID, int p, DDukeActor *actor, int x)
|
||||||
|
|
||||||
s.insptr = &ScriptCode[apScriptGameEvent[iEventID]];
|
s.insptr = &ScriptCode[apScriptGameEvent[iEventID]];
|
||||||
|
|
||||||
actor->killit_flag = 0;
|
s.killit_flag = 0;
|
||||||
do
|
do
|
||||||
done = s.parse();
|
done = s.parse();
|
||||||
while (done == 0);
|
while (done == 0);
|
||||||
|
|
|
@ -79,7 +79,6 @@ public:
|
||||||
short tempval, basepicnum;
|
short tempval, basepicnum;
|
||||||
unsigned short timetosleep;
|
unsigned short timetosleep;
|
||||||
bool mapSpawned;
|
bool mapSpawned;
|
||||||
uint8_t killit_flag;
|
|
||||||
DVector2 ovel;
|
DVector2 ovel;
|
||||||
DAngle hitang;
|
DAngle hitang;
|
||||||
double floorz, ceilingz;
|
double floorz, ceilingz;
|
||||||
|
|
|
@ -301,7 +301,6 @@ DEFINE_FIELD(DDukeActor, curAction)
|
||||||
DEFINE_FIELD(DDukeActor, curMove)
|
DEFINE_FIELD(DDukeActor, curMove)
|
||||||
DEFINE_FIELD(DDukeActor, curAI)
|
DEFINE_FIELD(DDukeActor, curAI)
|
||||||
DEFINE_FIELD(DDukeActor, actioncounter)
|
DEFINE_FIELD(DDukeActor, actioncounter)
|
||||||
//DEFINE_FIELD(DDukeActor, killit_flag)
|
|
||||||
|
|
||||||
void TickActor(DDukeActor*);
|
void TickActor(DDukeActor*);
|
||||||
DEFINE_ACTION_FUNCTION(DDukeActor, Tick)
|
DEFINE_ACTION_FUNCTION(DDukeActor, Tick)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
spawnclasses
|
spawnclasses
|
||||||
{
|
{
|
||||||
2556 = NamShrinker
|
|
||||||
2533 = NamShell, noskill
|
2533 = NamShell, noskill
|
||||||
2535 = NamShotgunShell, noskill
|
2535 = NamShotgunShell, noskill
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
spawnclasses
|
spawnclasses
|
||||||
{
|
{
|
||||||
2556 = NamShrinker
|
|
||||||
2533 = NamShell, noskill
|
2533 = NamShell, noskill
|
||||||
2535 = NamShotgunShell, noskill
|
2535 = NamShotgunShell, noskill
|
||||||
2595 = WW2GIShotSpark, noskill
|
2595 = WW2GIShotSpark, noskill
|
||||||
|
|
|
@ -317,7 +317,6 @@ class DukeActor : CoreActor native
|
||||||
native ActorMove curMove;
|
native ActorMove curMove;
|
||||||
native Name curAI;
|
native Name curAI;
|
||||||
native int16 actioncounter;
|
native int16 actioncounter;
|
||||||
//native uint8 killit_flag;
|
|
||||||
|
|
||||||
// flags are implemented natively to avoid the prefixes.
|
// flags are implemented natively to avoid the prefixes.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue