From 223182aac5ca813bb615d02bb49dab90b2cfc8c0 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Tue, 29 Jun 2021 21:11:40 +0200 Subject: [PATCH] vmap: Allow non underscore versions of light key/value pairs --- libs/entitylib.h | 20 ++++++++++++++++++++ tools/vmap/help.c | 7 +++---- tools/vmap/light.c | 42 +++++++++++++++++++++++++++++++++++------- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/libs/entitylib.h b/libs/entitylib.h index ba08f9a..22d439d 100644 --- a/libs/entitylib.h +++ b/libs/entitylib.h @@ -490,6 +490,26 @@ private: dupecheck = 1; else if (!strcmp(key, "message")) dupecheck = 1; + else if (!strcmp(key, "fade")) /* light keys */ + dupecheck = 1; + else if (!strcmp(key, "anglescale")) + dupecheck = 1; + else if (!strcmp(key, "style")) + dupecheck = 1; + else if (!strcmp(key, "light")) + dupecheck = 1; + else if (!strcmp(key, "deviance")) + dupecheck = 1; + else if (!strcmp(key, "samples")) + dupecheck = 1; + else if (!strcmp(key, "filter")) + dupecheck = 1; + else if (!strcmp(key, "color")) + dupecheck = 1; + else if (!strcmp(key, "color255")) + dupecheck = 1; + else if (!strcmp(key, "extradist")) + dupecheck = 1; KeyValues::iterator i = m_keyValues.find( key ); diff --git a/tools/vmap/help.c b/tools/vmap/help.c index 4b91e2b..9e9ce71 100644 --- a/tools/vmap/help.c +++ b/tools/vmap/help.c @@ -319,17 +319,16 @@ void HelpImport() void HelpCommon() { struct HelpOption common[] = { + {"-game ", "Sets a different game directory name (can be used more than once)"}, {"-connect
", "Talk to a WorldSpawn instance using a specific XML based protocol"}, {"-force", "Allow reading some broken/unsupported BSP files e.g. when decompiling, may also crash"}, {"-fs_basepath ", "Sets the given path as main directory of the game (can be used more than once to look in multiple paths)"}, - {"-fs_game ", "Sets a different game directory name (default for Q3A: baseq3, can be used more than once)"}, {"-fs_homebase ", "Specifies where the user home directory name is on Linux (default for Q3A: .q3a)"}, {"-fs_homepath ", "Sets the given path as home directory name"}, {"-fs_nobasepath", "Do not load base paths in VFS, imply -fs_nomagicpath"}, {"-fs_nomagicpath", "Do not try to guess base path magically"}, {"-fs_nohomepath", "Do not load home path in VFS"}, {"-fs_pakpath ", "Specify a package directory (can be used more than once to look in multiple paths)"}, - {"-game ", "Load settings for the given game (default: quake3)"}, {"-subdivisions ", "multiplier for patch subdivisions quality"}, {"-threads ", "number of threads to use"}, {"-v", "Verbose mode"} @@ -341,8 +340,8 @@ void HelpCommon() void HelpMain(const char* arg) { - printf("Usage: q3map2 [stage] [common options...] [stage options...] [stage source file]\n"); - printf(" q3map2 -help [stage]\n\n"); + printf("Usage: vmap [stage] [common options...] [stage options...] [stage source file]\n"); + printf(" vmap -help [stage]\n\n"); HelpCommon(); diff --git a/tools/vmap/light.c b/tools/vmap/light.c index 1247c60..1d0882f 100644 --- a/tools/vmap/light.c +++ b/tools/vmap/light.c @@ -411,7 +411,11 @@ void CreateEntityLights( void ){ } /* ydnar: set angle scaling (from vlight) */ - light->angleScale = FloatForKey( e, "_anglescale" ); + light->angleScale = FloatForKey( e, "anglescale" ); + + if ( light->angleScale != 0.0f ) { + light->angleScale = FloatForKey( e, "_anglescale" ); + } if ( light->angleScale != 0.0f ) { light->flags |= LIGHT_ATTEN_ANGLE; } @@ -447,14 +451,22 @@ void CreateEntityLights( void ){ intensity *= scale; /* ydnar: get deviance and samples */ - deviance = FloatForKey( e, "_deviance" ); + deviance = FloatForKey( e, "deviance" ); + if ( deviance == 0.0f ) { + deviance = FloatForKey( e, "_deviance" ); + } if ( deviance == 0.0f ) { deviance = FloatForKey( e, "_deviation" ); } if ( deviance == 0.0f ) { deviance = FloatForKey( e, "_jitter" ); } - numSamples = IntForKey( e, "_samples" ); + + numSamples = IntForKey( e, "samples" ); + if ( numSamples < 1 ) { + numSamples = IntForKey( e, "_samples" ); + } + if ( deviance < 0.0f || numSamples < 1 ) { deviance = 0.0f; numSamples = 1; @@ -462,7 +474,10 @@ void CreateEntityLights( void ){ intensity /= numSamples; /* ydnar: get filter radius */ - filterRadius = FloatForKey( e, "_filterradius" ); + filterRadius = FloatForKey( e, "filter" ); + if ( filterRadius == 0.0f ) { + filterRadius = FloatForKey( e, "_filterradius" ); + } if ( filterRadius == 0.0f ) { filterRadius = FloatForKey( e, "_filteradius" ); } @@ -475,7 +490,11 @@ void CreateEntityLights( void ){ light->filterRadius = filterRadius; /* set light color */ - _color = ValueForKey( e, "_color" ); + _color = ValueForKey( e, "color" ); + if ( !(_color && _color[ 0 ]) ) { + _color = ValueForKey( e, "_color" ); + } + if ( _color && _color[ 0 ] ) { sscanf( _color, "%f %f %f", &light->color[ 0 ], &light->color[ 1 ], &light->color[ 2 ] ); if ( colorsRGB ) { @@ -488,7 +507,12 @@ void CreateEntityLights( void ){ }*/ } else { /* alternative: read color in RGB8 values -eukara */ - _color = ValueForKey( e, "_color255" ); + _color = ValueForKey( e, "color255" ); + + if ( !(_color && _color[ 0 ]) ) { + _color = ValueForKey( e, "_color255" ); + } + if ( _color && _color[ 0 ] ) { sscanf( _color, "%f %f %f", &light->color[ 0 ], &light->color[ 1 ], &light->color[ 2 ] ); light->color[0] /= 255; @@ -505,7 +529,11 @@ void CreateEntityLights( void ){ } } - light->extraDist = FloatForKey( e, "_extradist" ); + light->extraDist = FloatForKey( e, "extradist" ); + if ( light->extraDist == 0.0f ) { + light->extraDist = FloatForKey( e, "_extradist" ); + } + if ( light->extraDist == 0.0f ) { light->extraDist = extraDist; }