- fixed some issues with setup parts for ZScript in the wrong place.

This never showed on GZDoom as an error but on Raze which has no actor classes it caused incompletely set up class descriptors.
This commit is contained in:
Christoph Oelckers 2020-06-14 17:22:56 +02:00
commit 75cd00a340
13 changed files with 74 additions and 167 deletions

View file

@ -650,6 +650,7 @@ int ZCCCompiler::Compile()
CreateStructTypes();
CompileAllConstants();
CompileAllFields();
InitDefaults();
InitFunctions();
return FScriptPosition::ErrorCounter;
}
@ -1942,6 +1943,18 @@ void ZCCCompiler::SetImplicitArgs(TArray<PType*>* args, TArray<uint32_t>* argfla
}
void ZCCCompiler::InitDefaults()
{
for (auto c : Classes)
{
if (c->ClassType()->ParentClass)
{
auto ti = c->ClassType();
ti->InitializeDefaults();
}
}
}
//==========================================================================
//
//

View file

@ -139,6 +139,7 @@ protected:
void CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool forclass);
void InitFunctions();
virtual void InitDefaults();
TArray<ZCC_ConstantDef *> Constants;
TArray<ZCC_StructWork *> Structs;

View file

@ -46,6 +46,7 @@
#include "vm.h"
#include "gstrings.h"
#include "printf.h"
#include "s_music.h"
//==========================================================================
@ -75,6 +76,20 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetName)
ACTION_RETURN_STRING(retval);
}
static int CheckForTexture(const FString& name, int type, int flags)
{
return TexMan.CheckForTexture(name, static_cast<ETextureType>(type), flags).GetIndex();
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckForTexture, CheckForTexture)
{
PARAM_PROLOGUE;
PARAM_STRING(name);
PARAM_INT(type);
PARAM_INT(flags);
ACTION_RETURN_INT(CheckForTexture(name, type, flags));
}
//==========================================================================
//
//
@ -618,3 +633,11 @@ DEFINE_ACTION_FUNCTION(_Console, Printf)
Printf("%s\n", s.GetChars());
return 0;
}
DEFINE_GLOBAL_NAMED(mus_playing, musplaying);
DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, name);
DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, baseorder);
DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, loop);
DEFINE_GLOBAL_NAMED(PClass::AllClasses, AllClasses)
DEFINE_GLOBAL(Bindings)

View file

@ -360,6 +360,10 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
OP(SS):
ASSERTA(a); ASSERTS(B); ASSERTKD(C);
GETADDR(PA,KC,X_WRITE_NIL);
#ifdef _DEBUG
// Should never happen, if it does it indicates a compiler side problem.
if (((FString*)ptr)->GetChars() == nullptr) ThrowAbortException(X_OTHER, "Uninitialized string");
#endif
*(FString *)ptr = reg.s[B];
NEXTOP;
OP(SS_R):