mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 06:53:40 +00:00
- fixed: ACS calls need to explicitly pass the level into COPY_AAPTR.
Unlike from an action function, this can be called with a null actor, which for the player constants still needs to return something valid.
This commit is contained in:
parent
5af5717cf1
commit
bcc1aa95b2
6 changed files with 19 additions and 13 deletions
|
@ -62,13 +62,12 @@
|
|||
Only one selector of each type can be used.
|
||||
*/
|
||||
|
||||
AActor *COPY_AAPTR(AActor *origin, int selector)
|
||||
AActor *COPY_AAPTREX(FLevelLocals *Level, AActor *origin, int selector)
|
||||
{
|
||||
if (selector == AAPTR_DEFAULT) return origin;
|
||||
|
||||
FTranslatedLineTarget t;
|
||||
|
||||
auto Level = origin->Level;
|
||||
auto AAPTR_RESOLVE_PLAYERNUM = [=](int playernum) -> AActor*
|
||||
{
|
||||
return (Level->PlayerInGame(playernum) ? Level->Players[playernum]->mo : nullptr);
|
||||
|
@ -119,6 +118,11 @@ AActor *COPY_AAPTR(AActor *origin, int selector)
|
|||
return origin;
|
||||
}
|
||||
|
||||
AActor *COPY_AAPTR(AActor *origin, int selector)
|
||||
{
|
||||
if (origin == nullptr) return nullptr;
|
||||
return COPY_AAPTREX(origin->Level, origin, selector);
|
||||
}
|
||||
|
||||
// [FDARI] Exported logic for guarding against loops in Target (for missiles) and Master (for all) chains.
|
||||
// It is called from multiple locations.
|
||||
|
|
|
@ -64,8 +64,9 @@ enum AAPTR
|
|||
Only one selector of each type can be used.
|
||||
*/
|
||||
|
||||
struct FLevelLocals;
|
||||
AActor *COPY_AAPTR(AActor *origin, int selector);
|
||||
|
||||
AActor *COPY_AAPTREX(FLevelLocals *Level, AActor *origin, int selector);
|
||||
enum PTROP
|
||||
{
|
||||
PTROP_UNSAFETARGET = 1,
|
||||
|
|
|
@ -5352,7 +5352,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
|
|||
AActor *ptr = Level->SingleActorFromTID(args[1], activator);
|
||||
if (argCount > 2)
|
||||
{
|
||||
ptr = COPY_AAPTR(ptr, args[2]);
|
||||
ptr = COPY_AAPTREX(Level, ptr, args[2]);
|
||||
}
|
||||
if (ptr == activator) ptr = NULL;
|
||||
ASSIGN_AAPTR(activator, args[0], ptr, (argCount > 3) ? args[3] : 0);
|
||||
|
@ -6326,7 +6326,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
actor = Level->SingleActorFromTID(tid1, activator);
|
||||
AActor * actor2 = tid2 == tid1 ? actor : Level->SingleActorFromTID(tid2, activator);
|
||||
|
||||
return COPY_AAPTR(actor, args[0]) == COPY_AAPTR(actor2, args[1]);
|
||||
return COPY_AAPTREX(Level, actor, args[0]) == COPY_AAPTREX(Level, actor2, args[1]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -6504,7 +6504,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
int count = argCount >= 4 ? args[3] : 1;
|
||||
int flags = argCount >= 5 ? args[4] : 0;
|
||||
int ptr = argCount >= 6 ? args[5] : AAPTR_DEFAULT;
|
||||
return P_Thing_CheckProximity(actor, classname, distance, count, flags, ptr);
|
||||
return P_Thing_CheckProximity(Level, actor, classname, distance, count, flags, ptr);
|
||||
}
|
||||
|
||||
case ACSF_CheckActorState:
|
||||
|
@ -6528,8 +6528,8 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
case ACSF_DamageActor: // [arookas] wrapper around P_DamageMobj
|
||||
{
|
||||
// (target, ptr_select1, inflictor, ptr_select2, amount, damagetype)
|
||||
AActor* target = COPY_AAPTR(Level->SingleActorFromTID(args[0], activator), args[1]);
|
||||
AActor* inflictor = COPY_AAPTR(Level->SingleActorFromTID(args[2], activator), args[3]);
|
||||
AActor* target = COPY_AAPTREX(Level, Level->SingleActorFromTID(args[0], activator), args[1]);
|
||||
AActor* inflictor = COPY_AAPTREX(Level, Level->SingleActorFromTID(args[2], activator), args[3]);
|
||||
FName damagetype(Level->Behaviors.LookupString(args[5]));
|
||||
return P_DamageMobj(target, inflictor, inflictor, args[4], damagetype);
|
||||
}
|
||||
|
|
|
@ -485,7 +485,7 @@ DEFINE_ACTION_FUNCTION(AActor, CountProximity)
|
|||
}
|
||||
else
|
||||
{
|
||||
ret->SetInt(P_Thing_CheckProximity(self, classname, distance, 0, flags, ptr, true));
|
||||
ret->SetInt(P_Thing_CheckProximity(self->Level, self, classname, distance, 0, flags, ptr, true));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -4520,7 +4520,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckProximity)
|
|||
PARAM_INT(flags);
|
||||
PARAM_INT(ptr);
|
||||
|
||||
ACTION_RETURN_BOOL(!!P_Thing_CheckProximity(self, classname, distance, count, flags, ptr));
|
||||
ACTION_RETURN_BOOL(!!P_Thing_CheckProximity(self->Level, self, classname, distance, count, flags, ptr));
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
|
|
|
@ -148,7 +148,8 @@ PClassActor *P_GetSpawnableType(int spawnnum);
|
|||
void InitSpawnablesFromMapinfo();
|
||||
int P_Thing_CheckInputNum(player_t *p, int inputnum);
|
||||
int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, double zofs, DAngle angle, int flags, double heightoffset, double radiusoffset, DAngle pitch);
|
||||
int P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, int count, int flags, int ptr, bool counting = false);
|
||||
struct FLevelLocals;
|
||||
int P_Thing_CheckProximity(FLevelLocals *Level, AActor *self, PClass *classname, double distance, int count, int flags, int ptr, bool counting = false);
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -567,9 +567,9 @@ int P_Thing_CheckInputNum(player_t *p, int inputnum)
|
|||
}
|
||||
return renum;
|
||||
}
|
||||
int P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, int count, int flags, int ptr, bool counting)
|
||||
int P_Thing_CheckProximity(FLevelLocals *Level, AActor *self, PClass *classname, double distance, int count, int flags, int ptr, bool counting)
|
||||
{
|
||||
AActor *ref = COPY_AAPTR(self, ptr);
|
||||
AActor *ref = COPY_AAPTREX(Level, self, ptr);
|
||||
|
||||
// We need these to check out.
|
||||
if (!ref || !classname || distance <= 0)
|
||||
|
|
Loading…
Reference in a new issue