From 9564de3f1661bd8c75859692ae5dea49ec7d79d4 Mon Sep 17 00:00:00 2001 From: RaveYard <29225776+MrRaveYard@users.noreply.github.com> Date: Mon, 6 May 2024 15:04:25 +0200 Subject: [PATCH] Expose lightmap defaults in mapinfo's gameinfo --- src/gamedata/gi.cpp | 21 ++++++++++++++++++++- src/gamedata/gi.h | 4 ++++ src/maploader/maploader.cpp | 8 ++++---- wadsrc/static/zscript/doombase.zs | 4 ++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/gamedata/gi.cpp b/src/gamedata/gi.cpp index e907722e9..b65fc013d 100644 --- a/src/gamedata/gi.cpp +++ b/src/gamedata/gi.cpp @@ -77,6 +77,10 @@ DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, defaultdropstyle) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, normforwardmove) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, normsidemove) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mHideParTimes) +DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, forceLightmaps) +DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, defaultSunColor) +DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, defaultSunDirection) +DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, defaultLightmapSampleDistance) const char *GameNames[17] = { @@ -207,6 +211,19 @@ const char* GameInfoBorders[] = gameinfo.key[1] = sc.Float; \ } +#define GAMEINFOKEY_THREEDOUBLES(key, variable) \ + else if(nextKey.CompareNoCase(variable) == 0) \ + { \ + sc.MustGetValue(true); \ + gameinfo.key[0] = sc.Float; \ + sc.MustGetToken(','); \ + sc.MustGetValue(true); \ + gameinfo.key[1] = sc.Float; \ + sc.MustGetToken(','); \ + sc.MustGetValue(true); \ + gameinfo.key[2] = sc.Float; \ + } + #define GAMEINFOKEY_COLOR(key, variable) \ else if(nextKey.CompareNoCase(variable) == 0) \ { \ @@ -460,7 +477,9 @@ void FMapInfoParser::ParseGameInfo() GAMEINFOKEY_TWODOUBLES(normsidemove, "normsidemove") GAMEINFOKEY_BOOL(nomergepickupmsg, "nomergepickupmsg") GAMEINFOKEY_BOOL(mHideParTimes, "hidepartimes") - + GAMEINFOKEY_BOOL(forceLightmaps, "forcelightmaps") + GAMEINFOKEY_THREEDOUBLES(defaultSunColor, "defaultsuncolor") + GAMEINFOKEY_THREEDOUBLES(defaultSunDirection, "defaultSunDirection") else { DPrintf(DMSG_ERROR, "Unknown GAMEINFO key \"%s\" found in %s:%i\n", nextKey.GetChars(), sc.ScriptName.GetChars(), sc.Line); diff --git a/src/gamedata/gi.h b/src/gamedata/gi.h index 5e713628d..589f39eaf 100644 --- a/src/gamedata/gi.h +++ b/src/gamedata/gi.h @@ -215,6 +215,10 @@ struct gameinfo_t bool nomergepickupmsg; bool mHideParTimes; CutsceneDef IntroScene; + bool forceLightmaps = false; + FVector3 defaultSunColor = FVector3(1.f, 1.f, 1.f); + FVector3 defaultSunDirection = FVector3(0.45f, 0.3f, 0.9f); + int defaultLightmapSampleDistance = 16; const char *GetFinalePage(unsigned int num) const; }; diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index a62bf1c30..c761e37a8 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -3205,10 +3205,10 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position) const int *oldvertextable = nullptr; // Reset defaults for lightmapping - Level->SunColor = FVector3(1.f, 1.f, 1.f); - Level->SunDirection = FVector3(0.45f, 0.3f, 0.9f); - Level->LightmapSampleDistance = 16; - Level->lightmaps = false; + Level->SunColor = gameinfo.defaultSunColor; + Level->SunDirection = gameinfo.defaultSunDirection; + Level->LightmapSampleDistance = gameinfo.defaultLightmapSampleDistance; + Level->lightmaps = gameinfo.forceLightmaps; // note: most of this ordering is important ForceNodeBuild = gennodes; diff --git a/wadsrc/static/zscript/doombase.zs b/wadsrc/static/zscript/doombase.zs index daaf143bf..479f802a2 100644 --- a/wadsrc/static/zscript/doombase.zs +++ b/wadsrc/static/zscript/doombase.zs @@ -107,6 +107,10 @@ extend struct GameInfoStruct native double normforwardmove[2]; native double normsidemove[2]; native bool mHideParTimes; + native bool forceLightmaps; + native FVector3 defaultSunColor; + native FVector3 defaultSunDirection; + native int defaultLightmapSampleDistance; } extend class Object