This commit is contained in:
Rachael Alexanderson 2016-12-28 21:16:14 -05:00
commit 07f22a090c
14 changed files with 217 additions and 63 deletions

View File

@ -220,6 +220,9 @@ Note: All <bool> fields default to false unless mentioned otherwise.
floorglowheight = <float>; // Height of floor glow. This only has an effect for the sector's own glow color, but not for a texture based glow.
ceilingglowcolor = <integer>; // Sector's ceiling glow color as RRGGBB value, default = 'use texture's definition'. Set to -1 to disable glowing.
ceilingglowheight = <float>; // Height of ceiling glow. This only has an effect for the sector's own glow color, but not for a texture based glow.
fogdensity = <integer>; // Sets an explicit fog density for the sector, overriding the default calculation from the light level. Value range is 0-510,
// 0 meaning that the default is to be used, 2 equalling the density of a light level of 250, and 255 equalling the density of
// a light level of 0.
portal_ceil_alpha = <float> // translucency of ceiling portal (default is 0 (not visible))
portal_ceil_blocksound = <bool> // ceiling portal blocks sound.

View File

@ -1021,6 +1021,7 @@ set (PCH_SOURCES
c_cvars.cpp
c_dispatch.cpp
c_expr.cpp
c_functions.cpp
cmdlib.cpp
colormatcher.cpp
compatibility.cpp
@ -1431,7 +1432,7 @@ source_group("Audio Files\\WildMidi\\Headers" REGULAR_EXPRESSION "^${CMAKE_CURRE
source_group("Audio Files\\WildMidi\\Source" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/wildmidi/.+\\.cpp$")
source_group("External\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/math/.+")
source_group("External\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/.+")
source_group("Externak\\SFMT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sfmt/.+")
source_group("External\\SFMT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sfmt/.+")
source_group("FraggleScript" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/fragglescript/.+")
source_group("Games\\Strife Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_strife/.+")
source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+")

View File

@ -71,6 +71,7 @@
#include "v_video.h"
#include "r_utility.h"
#include "r_data/r_interpolate.h"
#include "c_functions.h"
extern FILE *Logfile;
extern bool insave;
@ -870,20 +871,17 @@ CCMD (wdir)
//
//
//-----------------------------------------------------------------------------
CCMD(linetarget)
{
FTranslatedLineTarget t;
if (CheckCheatmode () || players[consoleplayer].mo == NULL) return;
P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->Angles.Yaw, MISSILERANGE, &t, 0.);
C_AimLine(&t, false);
if (t.linetarget)
{
Printf("Target=%s, Health=%d, Spawnhealth=%d\n",
t.linetarget->GetClass()->TypeName.GetChars(),
t.linetarget->health,
t.linetarget->SpawnHealth());
}
else Printf("No target found\n");
C_PrintInfo(t.linetarget);
else
Printf("No target found\n");
}
// As linetarget, but also give info about non-shootable actors
@ -892,28 +890,18 @@ CCMD(info)
FTranslatedLineTarget t;
if (CheckCheatmode () || players[consoleplayer].mo == NULL) return;
P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->Angles.Yaw, MISSILERANGE,
&t, 0., ALF_CHECKNONSHOOTABLE|ALF_FORCENOSMART);
C_AimLine(&t, true);
if (t.linetarget)
{
Printf("Target=%s, Health=%d, Spawnhealth=%d\n",
t.linetarget->GetClass()->TypeName.GetChars(),
t.linetarget->health,
t.linetarget->SpawnHealth());
PrintMiscActorInfo(t.linetarget);
}
else Printf("No target found. Info cannot find actors that have "
C_PrintInfo(t.linetarget);
else
Printf("No target found. Info cannot find actors that have "
"the NOBLOCKMAP flag or have height/radius of 0.\n");
}
CCMD(myinfo)
{
if (CheckCheatmode () || players[consoleplayer].mo == NULL) return;
Printf("Target=%s, Health=%d, Spawnhealth=%d\n",
players[consoleplayer].mo->GetClass()->TypeName.GetChars(),
players[consoleplayer].mo->health,
players[consoleplayer].mo->SpawnHealth());
PrintMiscActorInfo(players[consoleplayer].mo);
C_PrintInfo(players[consoleplayer].mo);
}
typedef bool (*ActorTypeChecker) (AActor *);

84
src/c_functions.cpp Normal file
View File

@ -0,0 +1,84 @@
/*
** c_functions.cpp
** Miscellaneous console command helper functions.
**
**---------------------------------------------------------------------------
** Copyright 2016 Rachael Alexanderson
** Copyright 2003-2016 Christoph Oelckers
** Copyright 1998-2016 Randy Heit
** 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 "d_player.h"
#include "p_local.h"
#include "c_functions.h"
void C_PrintInfo(AActor *target)
{
if (target->player)
Printf("Player=%s, ", target->player->userinfo.GetName());
Printf("Class=%s, Health=%d, Spawnhealth=%d\n",
target->GetClass()->TypeName.GetChars(),
target->health,
target->SpawnHealth());
PrintMiscActorInfo(target);
}
void C_AimLine(FTranslatedLineTarget *t, bool nonshootable)
{
P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->Angles.Yaw, MISSILERANGE, t, 0.,
(nonshootable) ? ALF_CHECKNONSHOOTABLE|ALF_FORCENOSMART : 0);
}
void C_PrintInv(AActor *target)
{
AInventory *item;
int count = 0;
if (target == NULL)
{
Printf("No target found!\n");
return;
}
if (target->player)
Printf("Inventory for Player '%s':\n", target->player->userinfo.GetName());
else
Printf("Inventory for Target '%s':\n", target->GetClass()->TypeName.GetChars());
for (item = target->Inventory; item != NULL; item = item->Inventory)
{
Printf (" %s #%u (%d/%d)\n", item->GetClass()->TypeName.GetChars(),
item->InventoryID,
item->Amount, item->MaxAmount);
count++;
}
Printf (" List count: %d\n", count);
}

39
src/c_functions.h Normal file
View File

@ -0,0 +1,39 @@
/*
** c_functions.h
** Miscellaneous console command helper functions.
**
**---------------------------------------------------------------------------
** Copyright 2016 Rachael Alexanderson
** 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.
**---------------------------------------------------------------------------
**
*/
void C_PrintInv(AActor *target);
void C_AimLine(FTranslatedLineTarget *t, bool nonshootable);
void C_PrintInfo(AActor *target);
struct FTranslatedLineTarget;

View File

@ -21,6 +21,7 @@
#include "serializer.h"
#include "virtual.h"
#include "a_ammo.h"
#include "c_functions.h"
EXTERN_CVAR(Bool, sv_unlimited_pickup)
@ -1567,7 +1568,6 @@ bool AInventory::CanPickup (AActor *toucher)
CCMD (printinv)
{
AInventory *item;
int pnum = consoleplayer;
#ifdef _DEBUG
@ -1581,37 +1581,21 @@ CCMD (printinv)
}
}
#endif
if (players[pnum].mo == NULL)
{
return;
}
for (item = players[pnum].mo->Inventory; item != NULL; item = item->Inventory)
{
Printf ("%s #%u (%d/%d)\n", item->GetClass()->TypeName.GetChars(),
item->InventoryID,
item->Amount, item->MaxAmount);
}
C_PrintInv(players[pnum].mo);
}
CCMD (targetinv)
{
AInventory *item;
FTranslatedLineTarget t;
if (CheckCheatmode () || players[consoleplayer].mo == NULL)
return;
P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->Angles.Yaw, MISSILERANGE,
&t, 0., ALF_CHECKNONSHOOTABLE|ALF_FORCENOSMART);
C_AimLine(&t, true);
if (t.linetarget)
{
for (item = t.linetarget->Inventory; item != NULL; item = item->Inventory)
{
Printf ("%s #%u (%d/%d)\n", item->GetClass()->TypeName.GetChars(),
item->InventoryID,
item->Amount, item->MaxAmount);
}
C_PrintInv(t.linetarget);
}
else Printf("No target found. Targetinv cannot find actors that have "
"the NOBLOCKMAP flag or have height/radius of 0.\n");

View File

@ -515,7 +515,7 @@ void GLWall::RenderFogBoundaryCompat()
{
// without shaders some approximation is needed. This won't look as good
// as the shader version but it's an acceptable compromise.
float fogdensity = gl_GetFogDensity(lightlevel, Colormap.FadeColor);
float fogdensity = gl_GetFogDensity(lightlevel, Colormap.FadeColor, Colormap.fogdensity);
float dist1 = Dist2(ViewPos.X, ViewPos.Y, glseg.x1, glseg.y1);
float dist2 = Dist2(ViewPos.X, ViewPos.Y, glseg.x2, glseg.y2);

View File

@ -32,6 +32,7 @@ struct FColormap
PalEntry FadeColor; // a is fadedensity>>1
int desaturation;
int blendfactor;
int fogdensity;
void Clear()
{
@ -39,6 +40,7 @@ struct FColormap
FadeColor=0;
desaturation = 0;
blendfactor=0;
fogdensity = 0;
}
void ClearColor()
@ -55,6 +57,7 @@ struct FColormap
desaturation = from->Desaturate;
FadeColor = from->Fade;
blendfactor = from->Color.a;
fogdensity = from->Fade.a*2;
return * this;
}

View File

@ -294,43 +294,48 @@ void gl_SetColor(int sectorlightlevel, int rellight, const FColormap &cm, float
//
//==========================================================================
float gl_GetFogDensity(int lightlevel, PalEntry fogcolor)
float gl_GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity)
{
float density;
if (glset.lightmode&4)
if (glset.lightmode & 4)
{
// uses approximations of Legacy's default settings.
density = fogdensity? fogdensity : 18;
density = fogdensity ? fogdensity : 18;
}
else if ((fogcolor.d & 0xffffff) == 0)
{
// case 1: black fog
if (glset.lightmode != 8)
{
density=distfogtable[glset.lightmode!=0][gl_ClampLight(lightlevel)];
density = distfogtable[glset.lightmode != 0][gl_ClampLight(lightlevel)];
}
else
{
density = 0;
}
}
else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff))
else if (sectorfogdensity != 0)
{
// case 2. outsidefogdensity has already been set as needed
density=outsidefogdensity;
// case 2: Sector has an explicit fog density set.
density = sectorfogdensity;
}
else if (fogdensity!=0)
else if (outsidefogdensity != 0 && outsidefogcolor.a != 0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff))
{
// case 3: level has fog density set
density=fogdensity;
// case 3. outsidefogdensity has already been set as needed
density = outsidefogdensity;
}
else if (fogdensity != 0)
{
// case 4: level has fog density set
density = fogdensity;
}
else if (lightlevel < 248)
{
// case 4: use light level
density=clamp<int>(255-lightlevel,30,255);
// case 5: use light level
density = clamp<int>(255 - lightlevel, 30, 255);
}
else
else
{
density = 0.f;
}
@ -487,7 +492,7 @@ void gl_SetFog(int lightlevel, int rellight, const FColormap *cmap, bool isaddit
else if (cmap != NULL && gl_fixedcolormap == 0)
{
fogcolor = cmap->FadeColor;
fogdensity = gl_GetFogDensity(lightlevel, fogcolor);
fogdensity = gl_GetFogDensity(lightlevel, fogcolor, cmap->fogdensity);
fogcolor.a=0;
}
else

View File

@ -18,7 +18,7 @@ void gl_SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefog
int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon);
void gl_SetColor(int light, int rellight, const FColormap &cm, float alpha, bool weapon=false);
float gl_GetFogDensity(int lightlevel, PalEntry fogcolor);
float gl_GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity);
struct sector_t;
bool gl_CheckFog(FColormap *cm, int lightlevel);
bool gl_CheckFog(sector_t *frontsector, sector_t *backsector);

View File

@ -581,6 +581,7 @@ xx(floorglowcolor)
xx(floorglowheight)
xx(ceilingglowcolor)
xx(ceilingglowheight)
xx(fogdensity)
// USDF keywords
xx(Amount)

View File

@ -85,6 +85,7 @@
#include "a_pickups.h"
#include "a_armor.h"
#include "a_ammo.h"
#include "r_data/colormaps.h"
extern FILE *Logfile;
@ -4411,6 +4412,11 @@ enum EACSFunctions
ACSF_SetActorFlag,
ACSF_SetTranslation,
// OpenGL stuff
ACSF_SetSectorGlow = 400,
ACSF_SetFogDensity,
// ZDaemon
ACSF_GetTeamScore = 19620, // (int team)
ACSF_SetTeamScore, // (int team, int value
@ -6065,6 +6071,38 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
return 1;
}
// OpenGL exclusive functions
case ACSF_SetSectorGlow:
{
int which = !!args[1];
PalEntry color(args[2], args[3], args[4]);
float height = float(args[5]);
if (args[2] == -1) color = -1;
FSectorTagIterator it(args[0]);
int s;
while ((s = it.Next()) >= 0)
{
sectors[s].planes[which].GlowColor = color;
sectors[s].planes[which].GlowHeight = height;
}
break;
}
case ACSF_SetFogDensity:
{
FSectorTagIterator it(args[0]);
int s;
int d = clamp(args[1]/2, 0, 255);
while ((s = it.Next()) >= 0)
{
auto f = sectors[s].ColorMap->Fade;
sectors[s].ColorMap = GetSpecialLights(sectors[s].ColorMap->Color, PalEntry(d, f.r, f.g, f.b), sectors[s].ColorMap->Desaturate);
}
break;
}
default:
break;
}

View File

@ -1279,8 +1279,9 @@ public:
void ParseSector(sector_t *sec, int index)
{
int lightcolor = -1;
int fadecolor = -1;
PalEntry lightcolor = -1;
PalEntry fadecolor = -1;
int fogdensity = -1;
int desaturation = -1;
int fplaneflags = 0, cplaneflags = 0;
double fp[4] = { 0 }, cp[4] = { 0 };
@ -1461,6 +1462,10 @@ public:
desaturation = int(255*CheckFloat(key));
continue;
case NAME_fogdensity:
fogdensity = clamp(CheckInt(key), 0, 511);
break;
case NAME_Silent:
Flag(sec->Flags, SECF_SILENT, key);
continue;
@ -1682,7 +1687,7 @@ public:
sec->ceilingplane.set(n.X, n.Y, n.Z, cp[3]);
}
if (lightcolor == -1 && fadecolor == -1 && desaturation == -1)
if (lightcolor == -1 && fadecolor == -1 && desaturation == -1 && fogdensity == -1)
{
// [RH] Sectors default to white light with the default fade.
// If they are outside (have a sky ceiling), they use the outside fog.
@ -1710,6 +1715,8 @@ public:
fadecolor = level.fadeto;
}
if (desaturation == -1) desaturation = NormalLight.Desaturate;
if (fogdensity != -1) fadecolor.a = fogdensity / 2;
else fadecolor.a = 0;
sec->ColorMap = GetSpecialLights (lightcolor, fadecolor, desaturation);
}

View File

@ -25,6 +25,7 @@ struct FDynamicColormap : FSWColormap
void ChangeFade (PalEntry fadecolor);
void ChangeColor (PalEntry lightcolor, int desaturate);
void ChangeColorFade (PalEntry lightcolor, PalEntry fadecolor);
void ChangeFogDensity(int newdensity);
void BuildLights ();
static void RebuildAllLights();