qzdoom/src/r_data/r_vanillatrans.cpp
Rachael Alexanderson 68b6f922f7 - Added auto-detection scheme for r_vanillatrans
It now works the following way:
(0) - Force off (ZDoom defaults)
(1) - Force on (Doom defaults)
(2) - Auto off (Prefer ZDoom defaults - if DEHACKED is detected with no ZSCRIPT it will turn on) (default)
(3) - Auto on (Prefer Doom defaults - if DECORATE is detected with no ZSCRIPT it will turn off)
2017-06-04 12:30:35 +02:00

67 lines
1.2 KiB
C++

#include "templates.h"
#include "c_cvars.h"
#include "w_wad.h"
#ifdef _DEBUG
#include "c_dispatch.h"
#endif
CVAR (Int, r_vanillatrans, 2, CVAR_ARCHIVE)
namespace
{
bool firstTime = true;
bool foundDehacked = false;
bool foundDecorate = false;
bool foundZScript = false;
}
#ifdef _DEBUG
CCMD (debug_checklumps)
{
Printf("firstTime: %d\n", firstTime);
Printf("foundDehacked: %d\n", foundDehacked);
Printf("foundDecorate: %d\n", foundDecorate);
Printf("foundZScript: %d\n", foundZScript);
}
#endif
void UpdateVanillaTransparency()
{
firstTime = true;
}
bool UseVanillaTransparency()
{
if (firstTime)
{
int lastlump = 0;
Wads.FindLump("ZSCRIPT", &lastlump); // ignore first ZScript
if (Wads.FindLump("ZSCRIPT", &lastlump) == -1) // no loaded ZScript
{
lastlump = 0;
foundDehacked = Wads.FindLump("DEHACKED", &lastlump) != -1;
lastlump = 0;
foundDecorate = Wads.FindLump("DECORATE", &lastlump) != -1;
foundZScript = false;
}
else
{
foundZScript = true;
foundDehacked = false;
foundDecorate = false;
}
firstTime = false;
}
switch (r_vanillatrans)
{
case 0: return false;
case 1: return true;
default:
if (foundDehacked)
return true;
if (foundDecorate)
return false;
return r_vanillatrans == 3;
}
}