mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-06-04 19:10:59 +00:00
- implemented State as an actual native struct, so that its fields can be accessed from scripts.
- refactored state bitfield members into a flag word because the address of a bitfield cannot be taken, making such variables inaccessible to scripts. - actually use PNativeStruct for representing native structs defined in a script.
This commit is contained in:
parent
ff3baac8a7
commit
135cfcf016
12 changed files with 102 additions and 65 deletions
|
@ -5679,7 +5679,7 @@ FxExpression *FxMemberIdentifier::Resolve(FCompileContext& ctx)
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
else if (Object->ValueType->IsA(RUNTIME_CLASS(PStruct)))
|
||||
else if (Object->ValueType->IsKindOf(RUNTIME_CLASS(PStruct)))
|
||||
{
|
||||
auto ret = ResolveMember(ctx, ctx.Class, Object, static_cast<PStruct *>(Object->ValueType));
|
||||
delete this;
|
||||
|
@ -6278,7 +6278,7 @@ FxExpression *FxStructMember::Resolve(FCompileContext &ctx)
|
|||
return nullptr;
|
||||
}
|
||||
}
|
||||
else if (classx->ValueType->IsA(RUNTIME_CLASS(PStruct))) // Classes can never be used as value types so we do not have to consider that case.
|
||||
else if (classx->ValueType->IsKindOf(RUNTIME_CLASS(PStruct)))
|
||||
{
|
||||
// if this is a struct within a class or another struct we can simplify the expression by creating a new PField with a cumulative offset.
|
||||
if (classx->ExprType == EFX_ClassMember || classx->ExprType == EFX_StructMember)
|
||||
|
|
|
@ -699,7 +699,7 @@ static void ParseSpriteFrames (PClassActor *info, TArray<FState> &states, TArray
|
|||
{
|
||||
sc.ScriptError ("* must come after a frame");
|
||||
}
|
||||
state.Fullbright = true;
|
||||
state.StateFlags |= STF_FULLBRIGHT;
|
||||
}
|
||||
else if (*token < 'A' || *token > ']')
|
||||
{
|
||||
|
|
|
@ -274,24 +274,24 @@ do_stop:
|
|||
{
|
||||
if (sc.Compare("BRIGHT"))
|
||||
{
|
||||
state.Fullbright = true;
|
||||
state.StateFlags |= STF_FULLBRIGHT;
|
||||
continue;
|
||||
}
|
||||
if (sc.Compare("FAST"))
|
||||
{
|
||||
state.Fast = true;
|
||||
state.StateFlags |= STF_FAST;
|
||||
continue;
|
||||
}
|
||||
if (sc.Compare("SLOW"))
|
||||
{
|
||||
state.Slow = true;
|
||||
state.StateFlags |= STF_SLOW;
|
||||
continue;
|
||||
}
|
||||
if (sc.Compare("NODELAY"))
|
||||
{
|
||||
if (bag.statedef.GetStateLabelIndex(NAME_Spawn) == bag.statedef.GetStateCount())
|
||||
{
|
||||
state.NoDelay = true;
|
||||
state.StateFlags |= STF_NODELAY;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -327,7 +327,7 @@ do_stop:
|
|||
}
|
||||
if (sc.Compare("CANRAISE"))
|
||||
{
|
||||
state.CanRaise = true;
|
||||
state.StateFlags |= STF_CANRAISE;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -658,6 +658,7 @@ static int funccmp(const void * a, const void * b)
|
|||
//==========================================================================
|
||||
void G_InitLevelLocalsForScript();
|
||||
void P_InitPlayerForScript();
|
||||
void P_InitStateForScript();
|
||||
|
||||
void InitThingdef()
|
||||
{
|
||||
|
@ -669,6 +670,7 @@ void InitThingdef()
|
|||
|
||||
G_InitLevelLocalsForScript();
|
||||
P_InitPlayerForScript();
|
||||
P_InitStateForScript();
|
||||
|
||||
FAutoSegIterator probe(CRegHead, CRegTail);
|
||||
|
||||
|
|
|
@ -416,7 +416,10 @@ void ZCCCompiler::CreateStructTypes()
|
|||
for(auto s : Structs)
|
||||
{
|
||||
s->Outer = s->OuterDef == nullptr? nullptr : s->OuterDef->CType();
|
||||
s->strct->Type = NewStruct(s->NodeName(), s->Outer);
|
||||
if (s->strct->Flags & ZCC_Native)
|
||||
s->strct->Type = NewNativeStruct(s->NodeName(), nullptr);
|
||||
else
|
||||
s->strct->Type = NewStruct(s->NodeName(), s->Outer);
|
||||
s->strct->Symbol = new PSymbolType(s->NodeName(), s->Type());
|
||||
GlobalSymbols.AddSymbol(s->strct->Symbol);
|
||||
|
||||
|
@ -2568,11 +2571,12 @@ void ZCCCompiler::CompileStates()
|
|||
Error(sl, "Duration is not a constant");
|
||||
}
|
||||
}
|
||||
state.Fullbright = sl->bBright;
|
||||
state.Fast = sl->bFast;
|
||||
state.Slow = sl->bSlow;
|
||||
state.CanRaise = sl->bCanRaise;
|
||||
if ((state.NoDelay = sl->bNoDelay))
|
||||
if (sl->bBright) state.StateFlags |= STF_FULLBRIGHT;
|
||||
if (sl->bFast) state.StateFlags |= STF_FAST;
|
||||
if (sl->bSlow) state.StateFlags |= STF_SLOW;
|
||||
if (sl->bCanRaise) state.StateFlags |= STF_CANRAISE;
|
||||
if (sl->bNoDelay) state.StateFlags |= STF_NODELAY;
|
||||
if (sl->bNoDelay)
|
||||
{
|
||||
if (statedef.GetStateLabelIndex(NAME_Spawn) != statedef.GetStateCount())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue