- fixed some incomplete checks for static arrays.

- made AActor::OkaytoSwitchTarget scripted virtual.
This commit is contained in:
Christoph Oelckers 2017-03-15 01:39:59 +01:00
parent d283beb063
commit 64bdc8c495
4 changed files with 31 additions and 4 deletions

View file

@ -692,6 +692,7 @@ public:
int SpecialMissileHit (AActor *victim);
// Returns true if it's okay to switch target to "other" after being attacked by it.
bool CallOkayToSwitchTarget(AActor *other);
bool OkayToSwitchTarget (AActor *other);
// Note: Although some of the inventory functions are virtual, this

View file

@ -1682,8 +1682,13 @@ DEFINE_ACTION_FUNCTION(AActor, PoisonMobj)
return 0;
}
//==========================================================================
//
// OkayToSwitchTarget
//
//==========================================================================
bool AActor::OkayToSwitchTarget (AActor *other)
bool AActor::OkayToSwitchTarget(AActor *other)
{
if (other == this)
return false; // [RH] Don't hate self (can happen when shooting barrels)
@ -1743,6 +1748,27 @@ bool AActor::OkayToSwitchTarget (AActor *other)
return true;
}
DEFINE_ACTION_FUNCTION(AActor, OkayToSwitchTarget)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(other, AActor);
ACTION_RETURN_BOOL(self->OkayToSwitchTarget(other));
}
bool AActor::CallOkayToSwitchTarget(AActor *other)
{
IFVIRTUAL(AActor, OkayToSwitchTarget)
{
VMValue params[] = { (DObject*)this, other };
int retv;
VMReturn ret(&retv);
GlobalVMStack.Call(func, params, 2, &ret, 1);
return !!retv;
}
return false;
}
//==========================================================================
//
// P_PoisonPlayer - Sets up all data concerning poisoning

View file

@ -6293,7 +6293,7 @@ FxExpression *FxMemberIdentifier::Resolve(FCompileContext& ctx)
else
{
auto f = dyn_cast<PField>(sym);
if (f != nullptr && (f->Flags & VARF_Static | VARF_ReadOnly) == (VARF_Static | VARF_ReadOnly))
if (f != nullptr && (f->Flags & (VARF_Static | VARF_ReadOnly | VARF_Meta)) == (VARF_Static | VARF_ReadOnly))
{
auto x = new FxGlobalVariable(f, ScriptPosition);
delete this;
@ -6944,7 +6944,7 @@ FxExpression *FxStructMember::Resolve(FCompileContext &ctx)
}
// Even though this is global, static and readonly, we still need to do the scope checks for consistency.
if ((membervar->Flags & (VARF_Static | VARF_ReadOnly)) == (VARF_Static | VARF_ReadOnly))
if ((membervar->Flags & (VARF_Static | VARF_ReadOnly | VARF_Meta)) == (VARF_Static | VARF_ReadOnly))
{
// This is a static constant array, which is stored at a constant address, like a global variable.
auto x = new FxGlobalVariable(membervar, ScriptPosition);

View file

@ -438,7 +438,7 @@ class Actor : Thinker native
return Obituary;
}
native virtual bool OkayToSwitchTarget(Actor other);
native static class<Actor> GetReplacement(class<Actor> cls);
native static class<Actor> GetReplacee(class<Actor> cls);
native static int GetSpriteIndex(name sprt);