From 02afa902026664d00efc0c728cc4e80e2ed2cabf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Sep 2020 16:16:53 +0200 Subject: [PATCH] - another backend update from merging several GZDoom PRs. --- source/common/console/keydef.h | 2 ++ source/common/objects/dobjtype.cpp | 8 ++++++-- source/common/objects/dobjtype.h | 2 +- source/common/platform/posix/sdl/i_gui.cpp | 2 ++ source/common/platform/posix/sdl/i_input.cpp | 11 ++++------- source/common/platform/win32/i_dijoy.cpp | 2 +- source/common/rendering/hwrenderer/hw_draw2d.cpp | 3 ++- source/common/scripting/backend/codegen.cpp | 4 ++-- source/common/scripting/frontend/zcc_compile.cpp | 5 +++-- source/common/textures/gametexture.h | 2 +- 10 files changed, 24 insertions(+), 17 deletions(-) diff --git a/source/common/console/keydef.h b/source/common/console/keydef.h index 2cbdf621b..108806774 100644 --- a/source/common/console/keydef.h +++ b/source/common/console/keydef.h @@ -75,6 +75,8 @@ enum EKeyCodes KEY_JOY6, KEY_JOY7, KEY_JOY8, + KEY_JOY14 = KEY_FIRSTJOYBUTTON+13, + KEY_JOY15 = KEY_FIRSTJOYBUTTON+14, KEY_LASTJOYBUTTON = 0x187, KEY_JOYPOV1_UP = 0x188, KEY_JOYPOV1_RIGHT = 0x189, diff --git a/source/common/objects/dobjtype.cpp b/source/common/objects/dobjtype.cpp index cf6d32d04..a22a9f185 100644 --- a/source/common/objects/dobjtype.cpp +++ b/source/common/objects/dobjtype.cpp @@ -51,6 +51,7 @@ // TYPES ------------------------------------------------------------------- // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- +bool AreCompatiblePointerTypes(PType* dest, PType* source, bool forcompare = false); // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -665,7 +666,7 @@ PClass *PClass::FindClassTentative(FName name) // //========================================================================== -int PClass::FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction *parentfunc) +int PClass::FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction *parentfunc, bool exactReturnType) { auto proto = variant->Proto; for (unsigned i = 0; i < Virtuals.Size(); i++) @@ -693,7 +694,10 @@ int PClass::FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction for (unsigned a = 0; a < proto->ReturnTypes.Size(); a++) { - if (proto->ReturnTypes[a] != vproto->ReturnTypes[a]) + PType* expected = vproto->ReturnTypes[a]; + PType* actual = proto->ReturnTypes[a]; + + if (expected != actual && (exactReturnType || !AreCompatiblePointerTypes(expected, actual))) { fail = true; break; diff --git a/source/common/objects/dobjtype.h b/source/common/objects/dobjtype.h index 07a48454e..f7996d89d 100644 --- a/source/common/objects/dobjtype.h +++ b/source/common/objects/dobjtype.h @@ -43,7 +43,7 @@ public: void InitializeSpecials(void* addr, void* defaults, TArray PClass::* Inits); void WriteAllFields(FSerializer &ar, const void *addr) const; bool ReadAllFields(FSerializer &ar, void *addr) const; - int FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction *parentfunc); + int FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction *parentfunc, bool exactReturnType); PSymbol *FindSymbol(FName symname, bool searchparents) const; PField *AddField(FName name, PType *type, uint32_t flags); void InitializeDefaults(); diff --git a/source/common/platform/posix/sdl/i_gui.cpp b/source/common/platform/posix/sdl/i_gui.cpp index d06732624..9290f063f 100644 --- a/source/common/platform/posix/sdl/i_gui.cpp +++ b/source/common/platform/posix/sdl/i_gui.cpp @@ -52,6 +52,7 @@ bool I_SetCursor(FGameTexture *cursorpic) return false; } + SDL_ShowCursor(SDL_DISABLE); if (cursorSurface == NULL) cursorSurface = SDL_CreateRGBSurface (0, 32, 32, 32, MAKEARGB(0,255,0,0), MAKEARGB(0,0,255,0), MAKEARGB(0,0,0,255), MAKEARGB(255,0,0,0)); @@ -67,6 +68,7 @@ bool I_SetCursor(FGameTexture *cursorpic) SDL_FreeCursor (cursor); cursor = SDL_CreateColorCursor (cursorSurface, 0, 0); SDL_SetCursor (cursor); + SDL_ShowCursor(SDL_ENABLE); } else { diff --git a/source/common/platform/posix/sdl/i_input.cpp b/source/common/platform/posix/sdl/i_input.cpp index 846796831..63bf4b638 100644 --- a/source/common/platform/posix/sdl/i_input.cpp +++ b/source/common/platform/posix/sdl/i_input.cpp @@ -493,13 +493,10 @@ void MessagePump (const SDL_Event &sev) case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: - if (!GUICapture) - { - event.type = sev.type == SDL_JOYBUTTONDOWN ? EV_KeyDown : EV_KeyUp; - event.data1 = KEY_FIRSTJOYBUTTON + sev.jbutton.button; - if(event.data1 != 0) - D_PostEvent(&event); - } + event.type = sev.type == SDL_JOYBUTTONDOWN ? EV_KeyDown : EV_KeyUp; + event.data1 = KEY_FIRSTJOYBUTTON + sev.jbutton.button; + if(event.data1 != 0) + D_PostEvent(&event); break; } } diff --git a/source/common/platform/win32/i_dijoy.cpp b/source/common/platform/win32/i_dijoy.cpp index eb016fdd4..79b6fcf8f 100644 --- a/source/common/platform/win32/i_dijoy.cpp +++ b/source/common/platform/win32/i_dijoy.cpp @@ -459,7 +459,7 @@ void FDInputJoystick::ProcessInput() { // Since we sorted the axes, we know that the first two are definitely X and Y. // They are probably a single stick, so use angular position to determine buttons. - buttonstate = Joy_XYAxesToButtons(axisval, Axes[0].Value); + buttonstate = Joy_XYAxesToButtons(Axes[0].Value, axisval); Joy_GenerateButtonEvents(info->ButtonValue, buttonstate, 4, KEY_JOYAXIS1PLUS); } info->ButtonValue = buttonstate; diff --git a/source/common/rendering/hwrenderer/hw_draw2d.cpp b/source/common/rendering/hwrenderer/hw_draw2d.cpp index 5652777c2..be1c6831e 100644 --- a/source/common/rendering/hwrenderer/hw_draw2d.cpp +++ b/source/common/rendering/hwrenderer/hw_draw2d.cpp @@ -169,7 +169,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) } state.SetFog(cmd.mColor1, 0); state.SetColor(1, 1, 1, 1, cmd.mDesaturate); - state.SetSoftLightLevel(cmd.mLightLevel); + if (cmd.mFlags & F2DDrawer::DTF_Indexed) state.SetSoftLightLevel(cmd.mLightLevel); state.SetLightParms(0, 0); state.AlphaFunc(Alpha_GEqual, 0.f); @@ -232,6 +232,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) state.SetTextureMode(TM_NORMAL); state.EnableFog(false); state.SetScreenFade(1); + state.SetSoftLightLevel(255); state.ResetColor(); drawer->mIsFirstPass = false; twoD.Unclock(); diff --git a/source/common/scripting/backend/codegen.cpp b/source/common/scripting/backend/codegen.cpp index 0ec83f20a..fe3d8e938 100644 --- a/source/common/scripting/backend/codegen.cpp +++ b/source/common/scripting/backend/codegen.cpp @@ -81,7 +81,7 @@ static const FLOP FxFlops[] = { NAME_Round, FLOP_ROUND, [](double v) { return round(v); } }, }; -static bool AreCompatiblePointerTypes(PType* dest, PType* source, bool forcompare = false); +bool AreCompatiblePointerTypes(PType* dest, PType* source, bool forcompare = false); //========================================================================== // @@ -271,7 +271,7 @@ PFunction *FindBuiltinFunction(FName funcname) // //========================================================================== -static bool AreCompatiblePointerTypes(PType *dest, PType *source, bool forcompare) +bool AreCompatiblePointerTypes(PType *dest, PType *source, bool forcompare) { if (dest->isPointer() && source->isPointer()) { diff --git a/source/common/scripting/frontend/zcc_compile.cpp b/source/common/scripting/frontend/zcc_compile.cpp index 0bc337bde..a4908e7bc 100644 --- a/source/common/scripting/frontend/zcc_compile.cpp +++ b/source/common/scripting/frontend/zcc_compile.cpp @@ -2366,6 +2366,7 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool sym->Variants[0].Implementation->VarFlags = sym->Variants[0].Flags; } + bool exactReturnType = mVersion < MakeVersion(4, 4); PClass *clstype = forclass? static_cast(c->Type())->Descriptor : nullptr; if (varflags & VARF_Virtual) { @@ -2379,7 +2380,7 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool { auto parentfunc = clstype->ParentClass? dyn_cast(clstype->ParentClass->VMType->Symbols.FindSymbol(sym->SymbolName, true)) : nullptr; - int vindex = clstype->FindVirtualIndex(sym->SymbolName, &sym->Variants[0], parentfunc); + int vindex = clstype->FindVirtualIndex(sym->SymbolName, &sym->Variants[0], parentfunc, exactReturnType); // specifying 'override' is necessary to prevent one of the biggest problem spots with virtual inheritance: Mismatching argument types. if (varflags & VARF_Override) { @@ -2459,7 +2460,7 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool } else if (forclass) { - int vindex = clstype->FindVirtualIndex(sym->SymbolName, &sym->Variants[0], nullptr); + int vindex = clstype->FindVirtualIndex(sym->SymbolName, &sym->Variants[0], nullptr, exactReturnType); if (vindex != -1) { Error(f, "Function %s attempts to override parent function without 'override' qualifier", FName(f->Name).GetChars()); diff --git a/source/common/textures/gametexture.h b/source/common/textures/gametexture.h index ec013b3d5..c07753eac 100644 --- a/source/common/textures/gametexture.h +++ b/source/common/textures/gametexture.h @@ -239,7 +239,7 @@ public: TexelWidth = x; TexelHeight = y; SetDisplaySize(float(x), float(y)); - GetTexture()->SetSize(x, y); + if (GetTexture()) GetTexture()->SetSize(x, y); } void SetDisplaySize(float w, float h) {