diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e71eaa73c..31b85960c1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -911,7 +911,9 @@ set (PCH_SOURCES f_wipe.cpp files.cpp files_decompress.cpp + g_cvars.cpp g_doomedmap.cpp + g_dumpinfo.cpp g_game.cpp g_hub.cpp g_level.cpp diff --git a/src/c_console.h b/src/c_console.h index 9e563b3eff..39c16c9bbb 100644 --- a/src/c_console.h +++ b/src/c_console.h @@ -65,6 +65,7 @@ void C_Ticker (void); void AddToConsole (int printlevel, const char *string); int PrintString (int printlevel, const char *string); +int PrintStringHigh (const char *string); int VPrintf (int printlevel, const char *format, va_list parms) GCCFORMAT(2); void C_DrawConsole (); diff --git a/src/d_main.cpp b/src/d_main.cpp index ef9c18e11f..b04fc33e62 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -99,6 +99,7 @@ #include "events.h" #include "vm.h" #include "types.h" +#include "g_cvars.h" #include "r_data/r_vanillatrans.h" EXTERN_CVAR(Bool, hud_althud) diff --git a/src/g_cvars.cpp b/src/g_cvars.cpp new file mode 100644 index 0000000000..cb26743bf2 --- /dev/null +++ b/src/g_cvars.cpp @@ -0,0 +1,48 @@ +/* + ** g_cvars.cpp + ** collects all the CVARs that were scattered all across the code before + ** + **--------------------------------------------------------------------------- + ** Copyright 1998-2016 Randy Heit + ** Copyright 2003-2018 Christoph Oelckers + ** All rights reserved. + ** + ** Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions + ** are met: + ** + ** 1. Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** 2. Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in the + ** documentation and/or other materials provided with the distribution. + ** 3. The name of the author may not be used to endorse or promote products + ** derived from this software without specific prior written permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + **--------------------------------------------------------------------------- + ** + */ + +#include "c_cvars.h" +#include "g_levellocals.h" + +CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + for (auto Level : AllLevels()) + { + if (self) Level->RecreateAllAttachedLights(); + else Level->DeleteAllAttachedLights(); + } +} + + diff --git a/src/g_cvars.h b/src/g_cvars.h new file mode 100644 index 0000000000..35930b2a2a --- /dev/null +++ b/src/g_cvars.h @@ -0,0 +1,9 @@ + +#pragma once + +#include "c_cvars.h" + + +EXTERN_CVAR(Bool, r_dynlights) +EXTERN_CVAR(Bool, gl_lights) + diff --git a/src/g_dumpinfo.cpp b/src/g_dumpinfo.cpp new file mode 100644 index 0000000000..b4d177490f --- /dev/null +++ b/src/g_dumpinfo.cpp @@ -0,0 +1,100 @@ +/* + ** g_dumpinfo.cpp + ** diagnostic CCMDs that output info about the current game + ** + **--------------------------------------------------------------------------- + ** Copyright 1998-2016 Randy Heit + ** Copyright 2003-2018 Christoph Oelckers + ** All rights reserved. + ** + ** Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions + ** are met: + ** + ** 1. Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** 2. Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in the + ** documentation and/or other materials provided with the distribution. + ** 3. The name of the author may not be used to endorse or promote products + ** derived from this software without specific prior written permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + **--------------------------------------------------------------------------- + ** + */ + +#include "c_dispatch.h" +#include "g_levellocals.h" +#include "a_dynlight.h" + +//========================================================================== +// +// CCMDs +// +//========================================================================== + +CCMD(listlights) +{ + int walls, sectors; + int allwalls=0, allsectors=0, allsubsecs = 0; + int i=0, shadowcount = 0; + FDynamicLight * dl; + + for (auto Level : AllLevels()) + { + Printf("Lights for %s\n", Level->MapName.GetChars()); + for (dl = Level->lights; dl; dl = dl->next) + { + walls=0; + sectors=0; + Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f %s %s", + dl->target->GetClass()->TypeName.GetChars(), + dl->X(), dl->Y(), dl->Z(), dl->GetRed(), dl->GetGreen(), dl->GetBlue(), + dl->radius, dl->IsAttenuated()? "attenuated" : "", dl->shadowmapped? "shadowmapped" : ""); + i++; + shadowcount += dl->shadowmapped; + + if (dl->target) + { + FTextureID spr = sprites[dl->target->sprite].GetSpriteFrame(dl->target->frame, 0, 0., nullptr); + Printf(", frame = %s ", TexMan.GetTexture(spr)->GetName().GetChars()); + } + + + FLightNode * node; + + node=dl->touching_sides; + + while (node) + { + walls++; + allwalls++; + node = node->nextTarget; + } + + + node = dl->touching_sector; + + while (node) + { + allsectors++; + sectors++; + node = node->nextTarget; + } + Printf("- %d walls, %d sectors\n", walls, sectors); + + } + Printf("%i dynamic lights, %d shadowmapped, %d walls, %d sectors\n\n\n", i, shadowcount, allwalls, allsectors); + } +} + diff --git a/src/g_shared/a_dynlight.cpp b/src/g_shared/a_dynlight.cpp index be6f903643..f3462a69b0 100644 --- a/src/g_shared/a_dynlight.cpp +++ b/src/g_shared/a_dynlight.cpp @@ -69,31 +69,8 @@ static FMemArena DynLightArena(sizeof(FDynamicLight) * 200); static TArray FreeList; static FRandom randLight; -CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - for (auto Level : AllLevels()) - { - if (self) Level->RecreateAllAttachedLights(); - else Level->DeleteAllAttachedLights(); - } -} +extern TArray StateLights; -//========================================================================== -// -//========================================================================== -DEFINE_CLASS_PROPERTY(type, S, DynamicLight) -{ - PROP_STRING_PARM(str, 0); - static const char * ltype_names[]={ - "Point","Pulse","Flicker","Sector","RandomFlicker", "ColorPulse", "ColorFlicker", "RandomColorFlicker", nullptr}; - - static const int ltype_values[]={ - PointLight, PulseLight, FlickerLight, SectorLight, RandomFlickerLight, ColorPulseLight, ColorFlickerLight, RandomColorFlickerLight }; - - int style = MatchString(str, ltype_names); - if (style < 0) I_Error("Unknown light type '%s'", str); - defaults->IntVar(NAME_lighttype) = ltype_values[style]; -} //========================================================================== // @@ -505,9 +482,9 @@ static FLightNode * DeleteLightNode(FLightNode * node) tn=node->nextTarget; delete node; return(tn); - } + } return(nullptr); -} // phares 3/13/98 +} @@ -774,7 +751,6 @@ void AActor::AttachLight(unsigned int count, const FLightDefaults *lightdef) // per-state light adjustment // //========================================================================== -extern TArray StateLights; void AActor::SetDynamicLights() { @@ -870,64 +846,3 @@ void FLevelLocals::RecreateAllAttachedLights() } } -//========================================================================== -// -// CCMDs -// -//========================================================================== - -CCMD(listlights) -{ - int walls, sectors; - int allwalls=0, allsectors=0, allsubsecs = 0; - int i=0, shadowcount = 0; - FDynamicLight * dl; - - for (auto Level : AllLevels()) - { - Printf("Lights for %s\n", Level->MapName.GetChars()); - for (dl = Level->lights; dl; dl = dl->next) - { - walls=0; - sectors=0; - Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f %s %s", - dl->target->GetClass()->TypeName.GetChars(), - dl->X(), dl->Y(), dl->Z(), dl->GetRed(), dl->GetGreen(), dl->GetBlue(), - dl->radius, dl->IsAttenuated()? "attenuated" : "", dl->shadowmapped? "shadowmapped" : ""); - i++; - shadowcount += dl->shadowmapped; - - if (dl->target) - { - FTextureID spr = sprites[dl->target->sprite].GetSpriteFrame(dl->target->frame, 0, 0., nullptr); - Printf(", frame = %s ", TexMan.GetTexture(spr)->GetName().GetChars()); - } - - - FLightNode * node; - - node=dl->touching_sides; - - while (node) - { - walls++; - allwalls++; - node = node->nextTarget; - } - - - node = dl->touching_sector; - - while (node) - { - allsectors++; - sectors++; - node = node->nextTarget; - } - Printf("- %d walls, %d sectors\n", walls, sectors); - - } - Printf("%i dynamic lights, %d shadowmapped, %d walls, %d sectors\n\n\n", i, shadowcount, allwalls, allsectors); - } -} - diff --git a/src/g_shared/a_dynlight.h b/src/g_shared/a_dynlight.h index e61c2a3fc6..54da9e7d54 100644 --- a/src/g_shared/a_dynlight.h +++ b/src/g_shared/a_dynlight.h @@ -4,9 +4,6 @@ #include "cycler.h" #include "g_levellocals.h" -EXTERN_CVAR(Bool, r_dynlights) -EXTERN_CVAR(Bool, gl_lights) - struct side_t; struct seg_t; diff --git a/src/hwrenderer/utility/hw_cvars.h b/src/hwrenderer/utility/hw_cvars.h index 1f08a4722d..025880fc43 100644 --- a/src/hwrenderer/utility/hw_cvars.h +++ b/src/hwrenderer/utility/hw_cvars.h @@ -15,8 +15,6 @@ EXTERN_CVAR(Bool, gl_usefb) EXTERN_CVAR(Int, gl_weaponlight) -EXTERN_CVAR (Bool, gl_lights); - EXTERN_CVAR (Bool, gl_light_sprites); EXTERN_CVAR (Bool, gl_light_particles); EXTERN_CVAR (Bool, gl_light_shadowmap); @@ -69,4 +67,4 @@ EXTERN_CVAR(Bool, gl_billboard_particles) EXTERN_CVAR(Int, gl_enhanced_nv_stealth) EXTERN_CVAR(Int, gl_fuzztype) -EXTERN_CVAR(Int, gl_shadowmap_filter) \ No newline at end of file +EXTERN_CVAR(Int, gl_shadowmap_filter) diff --git a/src/polyrenderer/scene/poly_model.cpp b/src/polyrenderer/scene/poly_model.cpp index 5ed08ef9b8..a0c544ab8b 100644 --- a/src/polyrenderer/scene/poly_model.cpp +++ b/src/polyrenderer/scene/poly_model.cpp @@ -128,7 +128,7 @@ void PolyModelRenderer::AddLights(AActor *actor) while (node) // check all lights touching a subsector { FDynamicLight *light = node->lightsource; - if (light->ShouldLightActor(actor)) + if (light->ShouldLightActor(actor)) { int group = subsector->sector->PortalGroup; DVector3 pos = light->PosRelative(group); diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index 17a546a94e..5cf0ebb0b0 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -54,6 +54,7 @@ #include "a_keys.h" #include "g_levellocals.h" #include "types.h" +#include "a_dynlight.h" //========================================================================== // @@ -1789,3 +1790,21 @@ DEFINE_CLASS_PROPERTY(unmorphflash, S, PowerMorph) defaults->PointerVar(NAME_UnMorphFlash) = FindClassTentative(str, RUNTIME_CLASS(AActor), bag.fromDecorate); } +//========================================================================== +// +//========================================================================== +DEFINE_CLASS_PROPERTY(type, S, DynamicLight) +{ + PROP_STRING_PARM(str, 0); + static const char * ltype_names[]={ + "Point","Pulse","Flicker","Sector","RandomFlicker", "ColorPulse", "ColorFlicker", "RandomColorFlicker", nullptr}; + + static const int ltype_values[]={ + PointLight, PulseLight, FlickerLight, SectorLight, RandomFlickerLight, ColorPulseLight, ColorFlickerLight, RandomColorFlickerLight }; + + int style = MatchString(str, ltype_names); + if (style < 0) I_Error("Unknown light type '%s'", str); + defaults->IntVar(NAME_lighttype) = ltype_values[style]; +} + +