From 5cf5c7469531f932a1974aaa75c5fe7bb32cfa9c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Oct 2019 00:47:40 +0200 Subject: [PATCH] - let kopenFileReader have a look into demolition.pk3 if nothing else is found. This should help as long as the old resource management is still in place. --- source/build/include/cache1d.h | 5 ++-- source/glbackend/glbackend.cpp | 31 +++++++++++++------ source/rr/src/_functio.h | 54 ---------------------------------- 3 files changed, 25 insertions(+), 65 deletions(-) diff --git a/source/build/include/cache1d.h b/source/build/include/cache1d.h index b175cbee0..1223e9c01 100644 --- a/source/build/include/cache1d.h +++ b/source/build/include/cache1d.h @@ -145,12 +145,13 @@ public: }; +FileReader openFromBaseResource(const char* name); // Wrappers for the handle based API to get rid of the direct calls without any actual changes to the implementation. inline FileReader kopenFileReader(const char* name, int where) { int handle = where == 0 ? kopen4loadfrommod(name, 0) : kopen4load(name, where); - KFileReaderInterface *fri = handle == buildvfs_kfd_invalid? nullptr : new KFileReaderInterface(handle); - return FileReader(fri); + if (handle != buildvfs_kfd_invalid) FileReader(new KFileReaderInterface(handle)); + return openFromBaseResource(name); } // This is only here to mark a file as not being part of the game assets (e.g. savegames) diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 2f6b4d687..3ad34cf54 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -65,15 +65,28 @@ void InitBaseRes() } } -FileReader GetBaseResource(const char* fn) +extern FString currentGame; +FileReader openFromBaseResource(const char* fn) { auto lump = engine_res->FindLump(fn); - if (!lump) + if (lump) return lump->NewReader(); + // Also look in game filtered directories. + FStringf filtername("filter/%s/%s", currentGame.GetChars(), fn); + lump = engine_res->FindLump(fn); + if (lump) return lump->NewReader(); + return FileReader(nullptr); + +} + +FileReader GetResource(const char* fn) +{ + auto fr = kopenFileReader(fn, 0); + if (!fr.isOpen()) { wm_msgbox("Fatal error", "Base resource '%s' not found", fn); exit(-1); } - return lump->NewReader(); + return fr; } GLInstance GLInterface; @@ -122,9 +135,9 @@ void GLInstance::Init() void GLInstance::LoadPolymostShader() { - auto fr1 = GetBaseResource("demolition/shaders/glsl/polymost.vp"); + auto fr1 = GetResource("demolition/shaders/glsl/polymost.vp"); TArray Vert = fr1.Read(); - fr1 = GetBaseResource("demolition/shaders/glsl/polymost.fp"); + fr1 = GetResource("demolition/shaders/glsl/polymost.fp"); TArray Frag = fr1.Read(); // Zero-terminate both strings. Vert.Push(0); @@ -136,9 +149,9 @@ void GLInstance::LoadPolymostShader() void GLInstance::LoadVPXShader() { - auto fr1 = GetBaseResource("demolition/shaders/glsl/animvpx.vp"); + auto fr1 = GetResource("demolition/shaders/glsl/animvpx.vp"); TArray Vert = fr1.Read(); - fr1 = GetBaseResource("demolition/shaders/glsl/animvpx.fp"); + fr1 = GetResource("demolition/shaders/glsl/animvpx.fp"); TArray Frag = fr1.Read(); // Zero-terminate both strings. Vert.Push(0); @@ -149,9 +162,9 @@ void GLInstance::LoadVPXShader() void GLInstance::LoadSurfaceShader() { - auto fr1 = GetBaseResource("demolition/shaders/glsl/glsurface.vp"); + auto fr1 = GetResource("demolition/shaders/glsl/glsurface.vp"); TArray Vert = fr1.Read(); - fr1 = GetBaseResource("demolition/shaders/glsl/glsurface.fp"); + fr1 = GetResource("demolition/shaders/glsl/glsurface.fp"); TArray Frag = fr1.Read(); // Zero-terminate both strings. Vert.Push(0); diff --git a/source/rr/src/_functio.h b/source/rr/src/_functio.h index 5db6bf666..5cc9c056a 100644 --- a/source/rr/src/_functio.h +++ b/source/rr/src/_functio.h @@ -263,60 +263,6 @@ static const char * mousedigitaldefaults[MAXMOUSEDIGITAL] = }; #if defined(GEKKO) -static const char * joystickdefaults[MAXJOYBUTTONSANDHATS] = - { - "Open", // A - "Fire", // B - "Run", // 1 - "Map", // 2 - "Previous_Weapon", // - - "Next_Weapon", // + - "", // Home - "Jump", // Z - "Crouch", // C - "Map", // X - "Run", // Y - "Jump", // L - "Quick_Kick", // R - "Crouch", // ZL - "Fire", // ZR - "Quick_Kick", // D-Pad Up - "Inventory_Right", // D-Pad Right - "Inventory", // D-Pad Down - "Inventory_Left", // D-Pad Left - }; - - -static const char * joystickclickeddefaults[MAXJOYBUTTONSANDHATS] = - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Inventory", - }; - - -static const char * joystickanalogdefaults[MAXJOYAXES] = - { - "analog_strafing", - "analog_moving", - "analog_turning", - "analog_lookingupanddown", - }; - - -static const char * joystickdigitaldefaults[MAXJOYDIGITAL] = - { - }; #else static const char * joystickdefaults[MAXJOYBUTTONSANDHATS] = {