Skip to content

Commit

Permalink
Add internal variable support to files outside gzdoom.pk3
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoLuis0 authored and coelckers committed Jan 20, 2023
1 parent d4e9438 commit ed6384e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/common/scripting/backend/codegen.cpp
Expand Up @@ -177,9 +177,9 @@ void FCompileContext::CheckReturn(PPrototype *proto, FScriptPosition &pos)
}
}

bool FCompileContext::IsWritable(int flags)
bool FCompileContext::IsWritable(int flags, int checkFileNo)
{
return !(flags & VARF_ReadOnly) || ((flags & VARF_InternalAccess) && fileSystem.GetFileContainer(Lump) == 0);
return !(flags & VARF_ReadOnly) || ((flags & VARF_InternalAccess) && fileSystem.GetFileContainer(Lump) == checkFileNo);
}

FxLocalVariableDeclaration *FCompileContext::FindLocalVariable(FName name)
Expand Down Expand Up @@ -6882,7 +6882,7 @@ FxGlobalVariable::FxGlobalVariable(PField* mem, const FScriptPosition &pos)
bool FxGlobalVariable::RequestAddress(FCompileContext &ctx, bool *writable)
{
AddressRequested = true;
if (writable != nullptr) *writable = AddressWritable && ctx.IsWritable(membervar->Flags);
if (writable != nullptr) *writable = AddressWritable && ctx.IsWritable(membervar->Flags, membervar->mDefFileNo);
return true;
}

Expand Down Expand Up @@ -7075,7 +7075,7 @@ FxStackVariable::~FxStackVariable()
bool FxStackVariable::RequestAddress(FCompileContext &ctx, bool *writable)
{
AddressRequested = true;
if (writable != nullptr) *writable = AddressWritable && ctx.IsWritable(membervar->Flags);
if (writable != nullptr) *writable = AddressWritable && ctx.IsWritable(membervar->Flags, membervar->mDefFileNo);
return true;
}

Expand Down Expand Up @@ -7177,7 +7177,7 @@ bool FxStructMember::RequestAddress(FCompileContext &ctx, bool *writable)
else if (writable != nullptr)
{
// [ZZ] original check.
bool bWritable = (AddressWritable && ctx.IsWritable(membervar->Flags) &&
bool bWritable = (AddressWritable && ctx.IsWritable(membervar->Flags, membervar->mDefFileNo) &&
(!classx->ValueType->isPointer() || !classx->ValueType->toPointer()->IsConst));
// [ZZ] implement write barrier between different scopes
if (bWritable)
Expand Down
2 changes: 1 addition & 1 deletion src/common/scripting/backend/codegen.h
Expand Up @@ -101,7 +101,7 @@ struct FCompileContext

void HandleJumps(int token, FxExpression *handler);
void CheckReturn(PPrototype *proto, FScriptPosition &pos);
bool IsWritable(int flags);
bool IsWritable(int flags, int checkFileNo = 0);
FxLocalVariableDeclaration *FindLocalVariable(FName name);
};

Expand Down

0 comments on commit ed6384e

Please sign in to comment.