Skip to content

Commit

Permalink
Merge branch 'gzdoom' into materials
Browse files Browse the repository at this point in the history
  • Loading branch information
dpjudas committed Feb 9, 2018
2 parents 3207d8a + 7cbe866 commit 94fbcac
Show file tree
Hide file tree
Showing 53 changed files with 419 additions and 122 deletions.
22 changes: 22 additions & 0 deletions README.md
@@ -0,0 +1,22 @@
# Welcome to GZDoom!

[![Build Status](https://ci.appveyor.com/api/projects/status/github/coelckers/gzdoom?branch=master&svg=true)](https://ci.appveyor.com/project/coelckers/gzdoom) [![Build Status](https://travis-ci.org/coelckers/gzdoom.svg?branch=master)](https://travis-ci.org/coelckers/gzdoom)

## GZDoom is a modder-friendly OpenGL source port based on the DOOM engine

Copyright (c) 1998-2018 ZDoom + GZDoom teams, and contributors

Doom Source (c) 1997 id Software, Raven Software, and contributors

Please see license files for individual contributor licenses

Special thanks to Coraline of the 3DGE team for allowing us to use her README.md as a template for this one.

### Licensed under the GPL v3 (or greater)
##### https://www.gnu.org/licenses/quick-guide-gplv3.en.html
---

## How to build GZDoom

To build GZDoom, please see the [wiki](https://zdoom.org/wiki/) and see the "Programmer's Corner" on the bottom-right corner of the page to build for your platform.

4 changes: 4 additions & 0 deletions specs/udmf_zdoom.txt
Expand Up @@ -283,6 +283,7 @@ Note: All <bool> fields default to false unless mentioned otherwise.

For things with ACS specials (80-86 and 226), if arg0str is present and non-null, it
will be used as the name of the script to execute, and arg0 will be ignored.
On dynamic lights, arg0str can be used to set a color by name, this will supersede all args which are normally used to define a color.
}


Expand Down Expand Up @@ -426,6 +427,9 @@ floor_reflect and ceiling_reflect.
1.28 28.01.2017
sector material colors.

1.29 04.02.2018
arg0str in dynamic lights.

===============================================================================
EOF
===============================================================================
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -511,7 +511,7 @@ set( PLAT_SDL_SOURCES
posix/sdl/st_start.cpp )
set( PLAT_UNIX_SOURCES
posix/unix/i_specialpaths.cpp
posix/unix/iwadpicker_gtk.cpp )
posix/unix/gtk_dialogs.cpp )
set( PLAT_OSX_SOURCES
posix/osx/iwadpicker_cocoa.mm
posix/osx/i_specialpaths.mm
Expand Down
2 changes: 1 addition & 1 deletion src/c_cmds.cpp
Expand Up @@ -681,7 +681,7 @@ UNSAFE_CCMD (crashout)
#endif


CCMD (dir)
UNSAFE_CCMD (dir)
{
FString dir, path;
char curdir[256];
Expand Down
20 changes: 20 additions & 0 deletions src/c_cvars.cpp
Expand Up @@ -53,6 +53,7 @@
#include "colormatcher.h"
#include "menu/menu.h"
#include "vm.h"
#include "v_text.h"

struct FLatchedValue
{
Expand Down Expand Up @@ -1706,13 +1707,27 @@ void C_ArchiveCVars (FConfigFile *f, uint32_t filter)

EXTERN_CVAR(Bool, sv_cheats);

static bool IsUnsafe(const FBaseCVar *const var)
{
const bool unsafe = UnsafeExecutionContext && !(var->GetFlags() & CVAR_MOD);
if (unsafe)
{
Printf(TEXTCOLOR_RED "Cannot set console variable" TEXTCOLOR_GOLD " %s " TEXTCOLOR_RED "from unsafe command\n", var->GetName());
}
return unsafe;
}

void FBaseCVar::CmdSet (const char *newval)
{
if ((GetFlags() & CVAR_CHEAT) && !sv_cheats)
{
Printf("sv_cheats must be true to set this console variable.\n");
return;
}
else if (IsUnsafe(this))
{
return;
}

UCVarValue val;

Expand Down Expand Up @@ -1799,6 +1814,11 @@ CCMD (toggle)
{
if ( (var = FindCVar (argv[1], &prev)) )
{
if (IsUnsafe(var))
{
return;
}

val = var->GetGenericRep (CVAR_Bool);
val.Bool = !val.Bool;
var->SetGenericRep (val, CVAR_Bool);
Expand Down
37 changes: 22 additions & 15 deletions src/c_dispatch.cpp
Expand Up @@ -127,8 +127,24 @@ FButtonStatus Button_Mlook, Button_Klook, Button_Use, Button_AltAttack,
Button_AM_PanLeft, Button_AM_PanRight, Button_AM_PanDown, Button_AM_PanUp,
Button_AM_ZoomIn, Button_AM_ZoomOut;

bool ParsingKeyConf;
static bool UnsafeExecutionContext;
bool ParsingKeyConf, UnsafeExecutionContext;

class UnsafeExecutionScope
{
const bool wasEnabled;

public:
explicit UnsafeExecutionScope(const bool enable = true)
: wasEnabled(UnsafeExecutionContext)
{
UnsafeExecutionContext = enable;
}

~UnsafeExecutionScope()
{
UnsafeExecutionContext = wasEnabled;
}
};

// To add new actions, go to the console and type "key <action name>".
// This will give you the key value to use in the first column. Then
Expand Down Expand Up @@ -227,10 +243,8 @@ void DWaitingCommand::Tick ()
{
if (--TicsLeft == 0)
{
const bool wasUnsafe = UnsafeExecutionContext;
UnsafeExecutionContext = IsUnsafe;
UnsafeExecutionScope scope;
AddCommandString (Command);
UnsafeExecutionContext = wasUnsafe;
Destroy ();
}
}
Expand Down Expand Up @@ -658,12 +672,6 @@ void C_DoCommand (const char *cmd, int keynum)

if (args.argc() >= 2)
{ // Set the variable
if (UnsafeExecutionContext && !(var->GetFlags() & CVAR_MOD))
{
Printf(TEXTCOLOR_RED "Cannot set console variable" TEXTCOLOR_GOLD " %s " TEXTCOLOR_RED "from unsafe command\n", var->GetName());
return;
}

var->CmdSet (args[1]);
}
else
Expand All @@ -684,9 +692,9 @@ DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand)
if (CurrentMenu == nullptr) return 0;
PARAM_PROLOGUE;
PARAM_STRING(cmd);
UnsafeExecutionContext = true;
PARAM_BOOL(unsafe);
UnsafeExecutionScope scope(unsafe);
C_DoCommand(cmd);
UnsafeExecutionContext = false;
return 0;
}

Expand Down Expand Up @@ -1515,9 +1523,8 @@ void FConsoleAlias::SafeDelete ()

void FUnsafeConsoleAlias::Run (FCommandLine &args, APlayerPawn *instigator, int key)
{
UnsafeExecutionContext = true;
UnsafeExecutionScope scope;
FConsoleAlias::Run(args, instigator, key);
UnsafeExecutionContext = false;
}

void FExecList::AddCommand(const char *cmd, const char *file)
Expand Down
2 changes: 1 addition & 1 deletion src/c_dispatch.h
Expand Up @@ -200,7 +200,7 @@ extern FButtonStatus Button_Mlook, Button_Klook, Button_Use, Button_AltAttack,
Button_User1, Button_User2, Button_User3, Button_User4,
Button_AM_PanLeft, Button_AM_PanRight, Button_AM_PanDown, Button_AM_PanUp,
Button_AM_ZoomIn, Button_AM_ZoomOut;
extern bool ParsingKeyConf;
extern bool ParsingKeyConf, UnsafeExecutionContext;

void ResetButtonTriggers (); // Call ResetTriggers for all buttons
void ResetButtonStates (); // Same as above, but also clear bDown
Expand Down
2 changes: 1 addition & 1 deletion src/dobjtype.cpp
Expand Up @@ -280,7 +280,7 @@ void PClass::StaticShutdown ()

// This must be done in two steps because the native classes are not ordered by inheritance,
// so all meta data must be gone before deleting the actual class objects.
for (auto cls : AllClasses) cls->DestroyMeta(cls->Meta);
for (auto cls : AllClasses) if (cls->Meta != nullptr) cls->DestroyMeta(cls->Meta);
for (auto cls : AllClasses) delete cls;
// Unless something went wrong, anything left here should be class and type objects only, which do not own any scripts.
bShutdown = true;
Expand Down
2 changes: 1 addition & 1 deletion src/g_game.cpp
Expand Up @@ -2599,7 +2599,7 @@ void G_DeferedPlayDemo (const char *name)
gameaction = (gameaction == ga_loadgame) ? ga_loadgameplaydemo : ga_playdemo;
}

CCMD (playdemo)
UNSAFE_CCMD (playdemo)
{
if (netgame)
{
Expand Down
36 changes: 32 additions & 4 deletions src/g_inventory/a_weapons.cpp
Expand Up @@ -220,7 +220,21 @@ void AWeapon::MarkPrecacheSounds() const
//
//===========================================================================

bool AWeapon::CheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo, int ammocount)
bool AWeapon::CheckAmmo(int fireMode, bool autoSwitch, bool requireAmmo, int ammocount)
{
IFVIRTUAL(AWeapon, CheckAmmo)
{
VMValue params[] = { (DObject*)this, fireMode, autoSwitch, requireAmmo, ammocount };
VMReturn ret;
int retval;
ret.IntAt(&retval);
VMCall(func, params, 5, &ret, 1);
return !!retval;
}
return CheckAmmo(fireMode, autoSwitch, requireAmmo, ammocount);
}

bool AWeapon::DoCheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo, int ammocount)
{
int altFire;
int count1, count2;
Expand Down Expand Up @@ -293,7 +307,7 @@ DEFINE_ACTION_FUNCTION(AWeapon, CheckAmmo)
PARAM_BOOL(autoswitch);
PARAM_BOOL_DEF(require);
PARAM_INT_DEF(ammocnt);
ACTION_RETURN_BOOL(self->CheckAmmo(mode, autoswitch, require, ammocnt));
ACTION_RETURN_BOOL(self->DoCheckAmmo(mode, autoswitch, require, ammocnt));
}

//===========================================================================
Expand All @@ -306,7 +320,21 @@ DEFINE_ACTION_FUNCTION(AWeapon, CheckAmmo)
//
//===========================================================================

bool AWeapon::DepleteAmmo (bool altFire, bool checkEnough, int ammouse)
bool AWeapon::DepleteAmmo(bool altFire, bool checkEnough, int ammouse)
{
IFVIRTUAL(AWeapon, DepleteAmmo)
{
VMValue params[] = { (DObject*)this, altFire, checkEnough, ammouse };
VMReturn ret;
int retval;
ret.IntAt(&retval);
VMCall(func, params, 4, &ret, 1);
return !!retval;
}
return DoDepleteAmmo(altFire, checkEnough, ammouse);
}

bool AWeapon::DoDepleteAmmo (bool altFire, bool checkEnough, int ammouse)
{
if (!((dmflags & DF_INFINITE_AMMO) || (Owner->FindInventory (PClass::FindActor(NAME_PowerInfiniteAmmo), true) != nullptr)))
{
Expand Down Expand Up @@ -357,7 +385,7 @@ DEFINE_ACTION_FUNCTION(AWeapon, DepleteAmmo)
PARAM_BOOL(altfire);
PARAM_BOOL_DEF(checkenough);
PARAM_INT_DEF(ammouse);
ACTION_RETURN_BOOL(self->DepleteAmmo(altfire, checkenough, ammouse));
ACTION_RETURN_BOOL(self->DoDepleteAmmo(altfire, checkenough, ammouse));
}


Expand Down
2 changes: 2 additions & 0 deletions src/g_inventory/a_weapons.h
Expand Up @@ -142,7 +142,9 @@ class AWeapon : public AStateProvider
EitherFire
};
bool CheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo=false, int ammocount = -1);
bool DoCheckAmmo(int fireMode, bool autoSwitch, bool requireAmmo, int ammocount);
bool DepleteAmmo (bool altFire, bool checkEnough=true, int ammouse = -1);
bool DoDepleteAmmo(bool altFire, bool checkEnough, int ammouse);

enum
{
Expand Down
23 changes: 22 additions & 1 deletion src/g_level.cpp
Expand Up @@ -648,7 +648,8 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill

// If this is co-op, respawn any dead players now so they can
// keep their inventory on the next map.
if ((multiplayer || level.flags2 & LEVEL2_ALLOWRESPAWN || sv_singleplayerrespawn) && !deathmatch && player->playerstate == PST_DEAD)
if ((multiplayer || level.flags2 & LEVEL2_ALLOWRESPAWN || sv_singleplayerrespawn || !!G_SkillProperty(SKILLP_PlayerRespawn))
&& !deathmatch && player->playerstate == PST_DEAD)
{
// Copied from the end of P_DeathThink [[
player->cls = NULL; // Force a new class if the player is using a random class
Expand Down Expand Up @@ -2028,6 +2029,10 @@ DEFINE_FIELD(FLevelLocals, F1Pic)
DEFINE_FIELD(FLevelLocals, maptype)
DEFINE_FIELD(FLevelLocals, Music)
DEFINE_FIELD(FLevelLocals, musicorder)
DEFINE_FIELD(FLevelLocals, skytexture1)
DEFINE_FIELD(FLevelLocals, skytexture2)
DEFINE_FIELD(FLevelLocals, skyspeed1)
DEFINE_FIELD(FLevelLocals, skyspeed2)
DEFINE_FIELD(FLevelLocals, total_secrets)
DEFINE_FIELD(FLevelLocals, found_secrets)
DEFINE_FIELD(FLevelLocals, total_items)
Expand Down Expand Up @@ -2093,3 +2098,19 @@ CCMD(skyfog)
}
}


//==========================================================================
//
// ZScript counterpart to ACS ChangeSky, uses TextureIDs
//
//==========================================================================
DEFINE_ACTION_FUNCTION(FLevelLocals, ChangeSky)
{
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
PARAM_INT(sky1);
PARAM_INT(sky2);
sky1texture = self->skytexture1 = FSetTextureID(sky1);
sky2texture = self->skytexture2 = FSetTextureID(sky2);
R_InitSkyMap();
return 0;
}
2 changes: 1 addition & 1 deletion src/gl/scene/gl_decal.cpp
Expand Up @@ -289,7 +289,7 @@ void GLWall::DrawDecal(DBaseDecal *decal)
// Note: This should be replaced with proper shader based lighting.
double x, y;
decal->GetXY(seg->sidedef, x, y);
gl_SetDynSpriteLight(NULL, x, y, zpos, sub);
gl_SetDynSpriteLight(nullptr, x, y, zpos - decalheight * 0.5f, sub);
}

// alpha color only has an effect when using an alpha texture.
Expand Down
2 changes: 1 addition & 1 deletion src/gl/scene/gl_scene.cpp
Expand Up @@ -842,7 +842,7 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
stereo3dMode.SetUp();
for (int eye_ix = 0; eye_ix < stereo3dMode.eye_count(); ++eye_ix)
{
if (eye_ix > 0)
if (eye_ix > 0 && camera->player)
SetFixedColormap(camera->player); // reiterate color map for each eye, so night vision goggles work in both eyes
const s3d::EyePose * eye = stereo3dMode.getEyePose(eye_ix);
eye->SetUp();
Expand Down
3 changes: 1 addition & 2 deletions src/gl/scene/gl_sprite.cpp
Expand Up @@ -987,9 +987,8 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
RenderStyle.CheckFuzz();
if (RenderStyle.BlendOp == STYLEOP_Fuzz)
{
if (gl_fuzztype != 0 && !gl.legacyMode)
if (gl_fuzztype != 0 && !gl.legacyMode && !(RenderStyle.Flags & STYLEF_InvertSource))
{
// Todo: implement shader selection here
RenderStyle = LegacyRenderStyles[STYLE_Translucent];
OverrideShader = SHADER_NoTexture + gl_fuzztype;
trans = 0.99f; // trans may not be 1 here
Expand Down
2 changes: 1 addition & 1 deletion src/gl/scene/gl_spritelight.cpp
Expand Up @@ -74,7 +74,7 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t *
while (node)
{
light=node->lightsource;
if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->lightflags&LF_DONTLIGHTSELF) || light->target != self) && !(light->lightflags&LF_DONTLIGHTACTORS))
if (light->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->lightflags&LF_DONTLIGHTSELF) || light->target != self || !self) && !(light->lightflags&LF_DONTLIGHTACTORS))
{
float dist;
FVector3 L;
Expand Down
6 changes: 5 additions & 1 deletion src/gl/stereo3d/gl_stereo_cvars.cpp
Expand Up @@ -32,6 +32,7 @@
#include "gl/stereo3d/gl_sidebyside3d.h"
#include "gl/stereo3d/gl_interleaved3d.h"
#include "gl/system/gl_cvars.h"
#include "version.h"

// Set up 3D-specific console variables:
CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG)
Expand All @@ -42,7 +43,10 @@ CVAR(Bool, vr_swap_eyes, false, CVAR_GLOBALCONFIG)
// For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode.
// Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo,
// but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo
CVAR(Bool, vr_enable_quadbuffered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Bool, vr_enable_quadbuffered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
Printf("You must restart " GAMENAME " to switch quad stereo mode\n");
}

// intraocular distance in meters
CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS
Expand Down
2 changes: 1 addition & 1 deletion src/m_misc.cpp
Expand Up @@ -673,7 +673,7 @@ void M_ScreenShot (const char *filename)
}
}

CCMD (screenshot)
UNSAFE_CCMD (screenshot)
{
if (argv.argc() == 1)
G_ScreenShot (NULL);
Expand Down

0 comments on commit 94fbcac

Please sign in to comment.