mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
- backend update.
This commit is contained in:
parent
f41e0f9f50
commit
a9141af545
28 changed files with 128 additions and 68 deletions
|
@ -914,6 +914,7 @@ set (PCH_SOURCES
|
|||
common/engine/renderstyle.cpp
|
||||
common/engine/v_colortables.cpp
|
||||
common/engine/serializer.cpp
|
||||
common/engine/m_joy.cpp
|
||||
common/engine/m_random.cpp
|
||||
common/objects/dobject.cpp
|
||||
common/objects/dobjgc.cpp
|
||||
|
@ -983,10 +984,6 @@ set (PCH_SOURCES
|
|||
core/menu/messagebox.cpp
|
||||
core/menu/optionmenu.cpp
|
||||
core/menu/resolutionmenu.cpp
|
||||
|
||||
#core/input/i_joystick.cpp
|
||||
#core/input/i_input.cpp
|
||||
core/input/m_joy.cpp
|
||||
)
|
||||
|
||||
if( ${HAVE_VM_JIT} )
|
||||
|
|
|
@ -110,12 +110,7 @@ void scrLoadPalette(void)
|
|||
numshades = 64;
|
||||
paletteloaded |= PALETTE_MAIN;
|
||||
scrLoadPLUs();
|
||||
paletteloaded |= PALETTE_SHADE;
|
||||
Printf("Loading translucency table\n");
|
||||
DICTNODE *pTrans = gSysRes.Lookup("TRANS", "TLU");
|
||||
if (!pTrans)
|
||||
ThrowError("TRANS.TLU not found");
|
||||
paletteloaded |= PALETTE_TRANSLUC;
|
||||
paletteloaded |= PALETTE_SHADE | PALETTE_TRANSLUC;
|
||||
|
||||
enginePostInit();
|
||||
|
||||
|
|
|
@ -378,7 +378,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
|
|||
FVector3 pos, vel;
|
||||
FRolloffInfo *rolloff;
|
||||
|
||||
if (sound_id <= 0 || volume <= 0 || nosfx || nosound )
|
||||
if (sound_id <= 0 || volume <= 0 || nosfx || nosound || blockNewSounds)
|
||||
return NULL;
|
||||
|
||||
// prevent crashes.
|
||||
|
|
|
@ -238,6 +238,7 @@ protected:
|
|||
TArray<uint8_t> S_SoundCurve;
|
||||
TMap<int, int> ResIdMap;
|
||||
TArray<FRandomSoundList> S_rnd;
|
||||
bool blockNewSounds = false;
|
||||
|
||||
private:
|
||||
void LinkChannel(FSoundChan* chan, FSoundChan** head);
|
||||
|
@ -268,6 +269,11 @@ public:
|
|||
}
|
||||
void EvictAllChannels();
|
||||
|
||||
void BlockNewSounds(bool on)
|
||||
{
|
||||
blockNewSounds = on;
|
||||
}
|
||||
|
||||
virtual int SoundSourceIndex(FSoundChan* chan) { return 0; }
|
||||
virtual void SetSource(FSoundChan* chan, int index) {}
|
||||
|
||||
|
|
|
@ -1600,3 +1600,22 @@ CCMD (archivecvar)
|
|||
}
|
||||
}
|
||||
|
||||
void C_ListCVarsWithoutDescription()
|
||||
{
|
||||
FBaseCVar* var = CVars;
|
||||
int count = 0;
|
||||
|
||||
while (var)
|
||||
{
|
||||
if (var->GetDescription().IsEmpty())
|
||||
{
|
||||
Printf("%s\n", var->GetName());
|
||||
}
|
||||
var = var->m_Next;
|
||||
}
|
||||
}
|
||||
|
||||
CCMD(listcvarswithoutdescription)
|
||||
{
|
||||
C_ListCVarsWithoutDescription();
|
||||
}
|
||||
|
|
|
@ -143,6 +143,10 @@ public:
|
|||
void SetArchiveBit () { Flags |= CVAR_ARCHIVE; }
|
||||
void MarkUnsafe();
|
||||
void MarkSafe() { Flags &= ~CVAR_UNSAFECONTEXT; }
|
||||
void AddDescription(const FString& label)
|
||||
{
|
||||
if (Description.IsEmpty()) Description = label;
|
||||
}
|
||||
|
||||
int ToInt()
|
||||
{
|
||||
|
@ -214,6 +218,7 @@ private:
|
|||
friend void C_SetCVarsToDefaults (void);
|
||||
friend void FilterCompactCVars (TArray<FBaseCVar *> &cvars, uint32_t filter);
|
||||
friend void C_DeinitConsole();
|
||||
friend void C_ListCVarsWithoutDescription();
|
||||
};
|
||||
|
||||
// Returns a string with all cvars whose flags match filter. In compact mode,
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "c_cvars.h"
|
||||
#include "c_buttons.h"
|
||||
#include "findfile.h"
|
||||
#include "gstrings.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
@ -300,7 +301,7 @@ void C_DoCommand (const char *cmd, int keynum)
|
|||
}
|
||||
else
|
||||
{ // Get the variable's value
|
||||
if (var->GetDescription().Len()) Printf("%s\n", var->GetDescription().GetChars());
|
||||
if (var->GetDescription().Len()) Printf("%s\n", GStrings.localize(var->GetDescription()));
|
||||
Printf ("\"%s\" is \"%s\"\n", var->GetName(), var->GetHumanString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "gameconfigfile.h"
|
||||
#include "d_event.h"
|
||||
#include "cmdlib.h"
|
||||
#include "printf.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
@ -124,23 +125,23 @@ bool M_LoadJoystickConfig(IJoystickConfig *joy)
|
|||
numaxes = joy->GetNumAxes();
|
||||
for (int i = 0; i < numaxes; ++i)
|
||||
{
|
||||
axislen = snprintf(key, countof(key), "Axis%u", i);
|
||||
axislen = mysnprintf(key, countof(key), "Axis%u", i);
|
||||
|
||||
snprintf(key + axislen, countof(key) - axislen, "deadzone");
|
||||
mysnprintf(key + axislen, countof(key) - axislen, "deadzone");
|
||||
value = GameConfig->GetValueForKey(key);
|
||||
if (value != NULL)
|
||||
{
|
||||
joy->SetAxisDeadZone(i, (float)atof(value));
|
||||
}
|
||||
|
||||
snprintf(key + axislen, countof(key) - axislen, "scale");
|
||||
mysnprintf(key + axislen, countof(key) - axislen, "scale");
|
||||
value = GameConfig->GetValueForKey(key);
|
||||
if (value != NULL)
|
||||
{
|
||||
joy->SetAxisScale(i, (float)atof(value));
|
||||
}
|
||||
|
||||
snprintf(key + axislen, countof(key) - axislen, "map");
|
||||
mysnprintf(key + axislen, countof(key) - axislen, "map");
|
||||
value = GameConfig->GetValueForKey(key);
|
||||
if (value != NULL)
|
||||
{
|
||||
|
@ -173,30 +174,30 @@ void M_SaveJoystickConfig(IJoystickConfig *joy)
|
|||
GameConfig->ClearCurrentSection();
|
||||
if (!joy->IsSensitivityDefault())
|
||||
{
|
||||
snprintf(value, countof(value), "%g", joy->GetSensitivity());
|
||||
mysnprintf(value, countof(value), "%g", joy->GetSensitivity());
|
||||
GameConfig->SetValueForKey("Sensitivity", value);
|
||||
}
|
||||
numaxes = joy->GetNumAxes();
|
||||
for (int i = 0; i < numaxes; ++i)
|
||||
{
|
||||
axislen = snprintf(key, countof(key), "Axis%u", i);
|
||||
axislen = mysnprintf(key, countof(key), "Axis%u", i);
|
||||
|
||||
if (!joy->IsAxisDeadZoneDefault(i))
|
||||
{
|
||||
snprintf(key + axislen, countof(key) - axislen, "deadzone");
|
||||
snprintf(value, countof(value), "%g", joy->GetAxisDeadZone(i));
|
||||
mysnprintf(key + axislen, countof(key) - axislen, "deadzone");
|
||||
mysnprintf(value, countof(value), "%g", joy->GetAxisDeadZone(i));
|
||||
GameConfig->SetValueForKey(key, value);
|
||||
}
|
||||
if (!joy->IsAxisScaleDefault(i))
|
||||
{
|
||||
snprintf(key + axislen, countof(key) - axislen, "scale");
|
||||
snprintf(value, countof(value), "%g", joy->GetAxisScale(i));
|
||||
mysnprintf(key + axislen, countof(key) - axislen, "scale");
|
||||
mysnprintf(value, countof(value), "%g", joy->GetAxisScale(i));
|
||||
GameConfig->SetValueForKey(key, value);
|
||||
}
|
||||
if (!joy->IsAxisMapDefault(i))
|
||||
{
|
||||
snprintf(key + axislen, countof(key) - axislen, "map");
|
||||
snprintf(value, countof(value), "%d", joy->GetAxisMap(i));
|
||||
mysnprintf(key + axislen, countof(key) - axislen, "map");
|
||||
mysnprintf(value, countof(value), "%d", joy->GetAxisMap(i));
|
||||
GameConfig->SetValueForKey(key, value);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef M_JOY_H
|
||||
#define M_JOY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "basics.h"
|
||||
#include "tarray.h"
|
||||
#include "c_cvars.h"
|
||||
|
||||
|
@ -18,7 +18,7 @@ enum EJoyAxis
|
|||
};
|
||||
|
||||
// Generic configuration interface for a controller.
|
||||
struct IJoystickConfig
|
||||
struct NOVTABLE IJoystickConfig
|
||||
{
|
||||
virtual ~IJoystickConfig() = 0;
|
||||
|
|
@ -1386,7 +1386,7 @@ FileReader FileSystem::ReopenFileReader(int lump, bool alwayscache)
|
|||
if (rl->RefCount == 0 && rd != nullptr && !rd->GetBuffer() && !alwayscache && !(rl->Flags & LUMPF_COMPRESSED))
|
||||
{
|
||||
int fileno = fileSystem.GetFileContainer(lump);
|
||||
const char *filename = fileSystem.GetResourceFileName(fileno);
|
||||
const char *filename = fileSystem.GetResourceFileFullName(fileno);
|
||||
FileReader fr;
|
||||
if (fr.OpenFile(filename, rl->GetFileOffset(), rl->LumpSize))
|
||||
{
|
||||
|
|
|
@ -266,14 +266,12 @@ private:
|
|||
|
||||
void *operator new(size_t len, nonew&)
|
||||
{
|
||||
GC::AllocBytes += len;
|
||||
return M_Malloc(len);
|
||||
}
|
||||
public:
|
||||
|
||||
void operator delete (void *mem, nonew&)
|
||||
{
|
||||
GC::AllocBytes -= _msize(mem);
|
||||
M_Free(mem);
|
||||
}
|
||||
|
||||
|
|
|
@ -306,6 +306,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
uniform sampler2D texture6;
|
||||
uniform sampler2D texture7;
|
||||
uniform sampler2D texture8;
|
||||
uniform sampler2D texture9;
|
||||
uniform sampler2D texture10;
|
||||
uniform sampler2D texture11;
|
||||
|
||||
// timer data
|
||||
uniform float timer;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <signal.h>
|
||||
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
|
|
@ -183,6 +183,9 @@ static const char *shaderBindings = R"(
|
|||
layout(set = 1, binding = 5) uniform sampler2D texture6;
|
||||
layout(set = 1, binding = 6) uniform sampler2D texture7;
|
||||
layout(set = 1, binding = 7) uniform sampler2D texture8;
|
||||
layout(set = 1, binding = 8) uniform sampler2D texture9;
|
||||
layout(set = 1, binding = 9) uniform sampler2D texture10;
|
||||
layout(set = 1, binding = 10) uniform sampler2D texture11;
|
||||
|
||||
// This must match the PushConstants struct
|
||||
layout(push_constant) uniform PushConstants
|
||||
|
|
|
@ -2229,7 +2229,7 @@ remove them if not needed.
|
|||
#include <mutex> // for std::mutex
|
||||
#include <atomic> // for std::atomic
|
||||
|
||||
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
|
||||
#include <malloc.h> // for aligned_alloc()
|
||||
#endif
|
||||
|
||||
|
|
|
@ -170,6 +170,6 @@ public:
|
|||
}
|
||||
|
||||
void AddTexturesLumps(int lump1, int lump2, int patcheslump);
|
||||
void ParseTexture(FScanner &sc, ETextureType usetype);
|
||||
void ParseTexture(FScanner &sc, ETextureType usetype, int deflump);
|
||||
void ResolveAllPatches();
|
||||
};
|
||||
|
|
|
@ -389,7 +389,7 @@ void FGameTexture::SetSpriteRect()
|
|||
|
||||
void FGameTexture::CleanHardwareData(bool full)
|
||||
{
|
||||
Base->CleanHardwareTextures();
|
||||
if (full) Base->CleanHardwareTextures();
|
||||
for (auto mat : Material) if (mat) mat->DeleteDescriptors();
|
||||
}
|
||||
|
||||
|
|
|
@ -241,10 +241,6 @@ public:
|
|||
DisplayHeight = h;
|
||||
ScaleX = TexelWidth / w;
|
||||
ScaleY = TexelHeight / h;
|
||||
if (shouldUpscaleFlag < 2)
|
||||
{
|
||||
shouldUpscaleFlag = ScaleX < 2 && ScaleY < 2;
|
||||
}
|
||||
|
||||
// compensate for roundoff errors
|
||||
if (int(ScaleX * w) != TexelWidth) ScaleX += (1 / 65536.);
|
||||
|
@ -271,10 +267,6 @@ public:
|
|||
{
|
||||
ScaleX = x;
|
||||
ScaleY = y;
|
||||
if (shouldUpscaleFlag < 2)
|
||||
{
|
||||
shouldUpscaleFlag = ScaleX < 2 && ScaleY < 2;
|
||||
}
|
||||
DisplayWidth = TexelWidth / x;
|
||||
DisplayHeight = TexelHeight / y;
|
||||
}
|
||||
|
@ -374,7 +366,7 @@ enum EUpscaleFlags
|
|||
extern int upscalemask;
|
||||
void UpdateUpscaleMask();
|
||||
|
||||
int calcShouldUpscale(FGameTexture* tex);
|
||||
void calcShouldUpscale(FGameTexture* tex);
|
||||
inline int shouldUpscale(FGameTexture* tex, EUpscaleFlags UseType)
|
||||
{
|
||||
// This only checks the global scale mask and the texture's validation for upscaling. Everything else has been done up front elsewhere.
|
||||
|
|
|
@ -502,20 +502,21 @@ void FTexture::CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasA
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int calcShouldUpscale(FGameTexture *tex)
|
||||
void calcShouldUpscale(FGameTexture *tex)
|
||||
{
|
||||
tex->SetUpscaleFlag(0);
|
||||
// [BB] Don't resample if width * height of the input texture is bigger than gl_texture_hqresize_maxinputsize squared.
|
||||
const int maxInputSize = gl_texture_hqresize_maxinputsize;
|
||||
if (tex->GetTexelWidth() * tex->GetTexelHeight() > maxInputSize * maxInputSize)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
// [BB] Don't try to upsample textures based off FCanvasTexture. (This should never get here in the first place!)
|
||||
if (tex->isHardwareCanvas())
|
||||
return 0;
|
||||
return;
|
||||
|
||||
// already scaled?
|
||||
if (tex->GetScaleX() >= 2.f || tex->GetScaleY() > 2.f)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
return CTF_Upscale;
|
||||
tex->SetUpscaleFlag(1);
|
||||
}
|
|
@ -48,6 +48,11 @@ public:
|
|||
return sourcetex;
|
||||
}
|
||||
|
||||
void ClearLayers()
|
||||
{
|
||||
mTextureLayers.Resize(1);
|
||||
}
|
||||
|
||||
void AddTextureLayer(FTexture *tex, bool allowscale)
|
||||
{
|
||||
mTextureLayers.Push({ tex, allowscale });
|
||||
|
|
|
@ -606,7 +606,7 @@ void FMultipatchTextureBuilder::ParsePatch(FScanner &sc, BuildInfo &info, TexPar
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FMultipatchTextureBuilder::ParseTexture(FScanner &sc, ETextureType UseType)
|
||||
void FMultipatchTextureBuilder::ParseTexture(FScanner &sc, ETextureType UseType, int deflump)
|
||||
{
|
||||
BuildInfo &buildinfo = BuiltTextures[BuiltTextures.Reserve(1)];
|
||||
|
||||
|
@ -637,6 +637,7 @@ void FMultipatchTextureBuilder::ParseTexture(FScanner &sc, ETextureType UseType)
|
|||
sc.MustGetStringName(",");
|
||||
sc.MustGetNumber();
|
||||
buildinfo.Height = sc.Number;
|
||||
buildinfo.DefinitionLump = deflump;
|
||||
|
||||
bool offset2set = false;
|
||||
if (sc.CheckString("{"))
|
||||
|
@ -777,14 +778,11 @@ void FMultipatchTextureBuilder::ResolvePatches(BuildInfo &buildinfo)
|
|||
TArray<FTextureID> list;
|
||||
TexMan.ListTextures(buildinfo.Inits[i].TexName, list, true);
|
||||
for (int i = list.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
if (list[i] != buildinfo.texture->GetID())
|
||||
{
|
||||
auto gtex = TexMan.GetGameTexture(list[i]);
|
||||
if (gtex && !dynamic_cast<FMultiPatchTexture*>(gtex->GetTexture()))
|
||||
if (gtex && gtex != buildinfo.texture && gtex->GetTexture() && gtex->GetTexture()->GetImage() && !dynamic_cast<FMultiPatchTexture*>(gtex->GetTexture()->GetImage()))
|
||||
{
|
||||
texno = list[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -911,6 +909,7 @@ void FMultipatchTextureBuilder::ResolveAllPatches()
|
|||
{
|
||||
auto img = new FMultiPatchTexture(buildinfo.Width, buildinfo.Height, buildinfo.Parts, buildinfo.bComplex, buildinfo.textual);
|
||||
auto itex = new FImageTexture(img);
|
||||
itex->SetSourceLump(buildinfo.DefinitionLump);
|
||||
AddImageToTexture(itex, buildinfo);
|
||||
}
|
||||
BuiltTextures.Delete(i);
|
||||
|
|
|
@ -106,7 +106,7 @@ void FTextureManager::DeleteAll()
|
|||
// This must not, under any circumstances, delete the wipe textures, because
|
||||
// all CCMDs triggering a flush can be executed while a wipe is in progress
|
||||
//
|
||||
// This now also deletes the software textures because having the software
|
||||
// This now also deletes the software textures because the software
|
||||
// renderer can also use the texture scalers and that is the
|
||||
// main reason to call this outside of the destruction code.
|
||||
//
|
||||
|
@ -120,8 +120,8 @@ void FTextureManager::FlushAll()
|
|||
{
|
||||
Textures[i].Texture->CleanHardwareData();
|
||||
delete Textures[i].Texture->GetSoftwareTexture();
|
||||
Textures[i].Texture->SetSoftwareTexture(nullptr);
|
||||
calcShouldUpscale(Textures[i].Texture);
|
||||
Textures[i].Texture->SetSoftwareTexture(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -782,23 +782,23 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build
|
|||
}
|
||||
else if (sc.Compare("texture"))
|
||||
{
|
||||
build.ParseTexture(sc, ETextureType::Override);
|
||||
build.ParseTexture(sc, ETextureType::Override, lump);
|
||||
}
|
||||
else if (sc.Compare("sprite"))
|
||||
{
|
||||
build.ParseTexture(sc, ETextureType::Sprite);
|
||||
build.ParseTexture(sc, ETextureType::Sprite, lump);
|
||||
}
|
||||
else if (sc.Compare("walltexture"))
|
||||
{
|
||||
build.ParseTexture(sc, ETextureType::Wall);
|
||||
build.ParseTexture(sc, ETextureType::Wall, lump);
|
||||
}
|
||||
else if (sc.Compare("flat"))
|
||||
{
|
||||
build.ParseTexture(sc, ETextureType::Flat);
|
||||
build.ParseTexture(sc, ETextureType::Flat, lump);
|
||||
}
|
||||
else if (sc.Compare("graphic"))
|
||||
{
|
||||
build.ParseTexture(sc, ETextureType::MiscPatch);
|
||||
build.ParseTexture(sc, ETextureType::MiscPatch, lump);
|
||||
}
|
||||
else if (sc.Compare("#include"))
|
||||
{
|
||||
|
|
|
@ -253,6 +253,7 @@ public:
|
|||
bool isCanvas() const { return bHasCanvas; }
|
||||
|
||||
int GetSourceLump() { return SourceLump; } // needed by the scripted GetName method.
|
||||
void SetSourceLump(int sl) { SourceLump = sl; }
|
||||
bool FindHoles(const unsigned char * buffer, int w, int h);
|
||||
|
||||
void CopySize(FTexture* BaseTexture)
|
||||
|
|
|
@ -38,14 +38,14 @@
|
|||
#elif defined(__APPLE__)
|
||||
#include <stdlib.h>
|
||||
#include <malloc/malloc.h>
|
||||
#elif defined(__OpenBSD__)
|
||||
#elif defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include "engineerrors.h"
|
||||
#include "m_alloc.h"
|
||||
#include "dobject.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#define _NORMAL_BLOCK 0
|
||||
|
@ -62,16 +62,22 @@ void *M_Malloc(size_t size)
|
|||
if (block == NULL)
|
||||
I_FatalError("Could not malloc %zu bytes", size);
|
||||
|
||||
GC::AllocBytes += _msize(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
void *M_Realloc(void *memblock, size_t size)
|
||||
{
|
||||
if (memblock != NULL)
|
||||
{
|
||||
GC::AllocBytes -= _msize(memblock);
|
||||
}
|
||||
void *block = realloc(memblock, size);
|
||||
if (block == NULL)
|
||||
{
|
||||
I_FatalError("Could not realloc %zu bytes", size);
|
||||
}
|
||||
GC::AllocBytes += _msize(block);
|
||||
return block;
|
||||
}
|
||||
#else
|
||||
|
@ -86,6 +92,7 @@ void *M_Malloc(size_t size)
|
|||
*sizeStore = size;
|
||||
block = sizeStore+1;
|
||||
|
||||
GC::AllocBytes += _msize(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -94,6 +101,10 @@ void *M_Realloc(void *memblock, size_t size)
|
|||
if(memblock == NULL)
|
||||
return M_Malloc(size);
|
||||
|
||||
if (memblock != NULL)
|
||||
{
|
||||
GC::AllocBytes -= _msize(memblock);
|
||||
}
|
||||
void *block = realloc(((size_t*) memblock)-1, size+sizeof(size_t));
|
||||
if (block == NULL)
|
||||
{
|
||||
|
@ -104,6 +115,7 @@ void *M_Realloc(void *memblock, size_t size)
|
|||
*sizeStore = size;
|
||||
block = sizeStore+1;
|
||||
|
||||
GC::AllocBytes += _msize(block);
|
||||
return block;
|
||||
}
|
||||
#endif
|
||||
|
@ -120,16 +132,22 @@ void *M_Malloc_Dbg(size_t size, const char *file, int lineno)
|
|||
if (block == NULL)
|
||||
I_FatalError("Could not malloc %zu bytes in %s, line %d", size, file, lineno);
|
||||
|
||||
GC::AllocBytes += _msize(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
void *M_Realloc_Dbg(void *memblock, size_t size, const char *file, int lineno)
|
||||
{
|
||||
if (memblock != NULL)
|
||||
{
|
||||
GC::AllocBytes -= _msize(memblock);
|
||||
}
|
||||
void *block = _realloc_dbg(memblock, size, _NORMAL_BLOCK, file, lineno);
|
||||
if (block == NULL)
|
||||
{
|
||||
I_FatalError("Could not realloc %zu bytes in %s, line %d", size, file, lineno);
|
||||
}
|
||||
GC::AllocBytes += _msize(block);
|
||||
return block;
|
||||
}
|
||||
#else
|
||||
|
@ -144,6 +162,7 @@ void *M_Malloc_Dbg(size_t size, const char *file, int lineno)
|
|||
*sizeStore = size;
|
||||
block = sizeStore+1;
|
||||
|
||||
GC::AllocBytes += _msize(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -152,6 +171,10 @@ void *M_Realloc_Dbg(void *memblock, size_t size, const char *file, int lineno)
|
|||
if(memblock == NULL)
|
||||
return M_Malloc_Dbg(size, file, lineno);
|
||||
|
||||
if (memblock != NULL)
|
||||
{
|
||||
GC::AllocBytes -= _msize(memblock);
|
||||
}
|
||||
void *block = _realloc_dbg(((size_t*) memblock)-1, size+sizeof(size_t), _NORMAL_BLOCK, file, lineno);
|
||||
|
||||
if (block == NULL)
|
||||
|
@ -163,6 +186,7 @@ void *M_Realloc_Dbg(void *memblock, size_t size, const char *file, int lineno)
|
|||
*sizeStore = size;
|
||||
block = sizeStore+1;
|
||||
|
||||
GC::AllocBytes += _msize(block);
|
||||
return block;
|
||||
}
|
||||
#endif
|
||||
|
@ -173,6 +197,7 @@ void M_Free (void *block)
|
|||
{
|
||||
if (block != NULL)
|
||||
{
|
||||
GC::AllocBytes -= _msize(block);
|
||||
free(block);
|
||||
}
|
||||
}
|
||||
|
@ -181,6 +206,7 @@ void M_Free (void *block)
|
|||
{
|
||||
if(block != NULL)
|
||||
{
|
||||
GC::AllocBytes -= _msize(block);
|
||||
free(((size_t*) block)-1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#if defined(__APPLE__)
|
||||
#include <malloc/malloc.h>
|
||||
#define _msize(p) malloc_size(p)
|
||||
#elif defined(__solaris__) || defined(__OpenBSD__)
|
||||
#elif defined(__solaris__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
#define _msize(p) (*((size_t*)(p)-1))
|
||||
#elif !defined(_WIN32)
|
||||
#include <malloc.h>
|
||||
|
|
|
@ -444,7 +444,7 @@ void MakeGoodRemap(uint32_t* BaseColors, uint8_t* Remap)
|
|||
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
sortcopy[i] = BaseColors[i] | (i << 24);
|
||||
sortcopy[i] = (BaseColors[i] & 0xffffff) | (i << 24);
|
||||
}
|
||||
qsort(sortcopy, 256, 4, sortforremap);
|
||||
for (i = 255; i > 0; --i)
|
||||
|
|
|
@ -107,7 +107,6 @@ void paletteLoadFromDisk(void)
|
|||
// LameDuke and Witchaven use an older variant.
|
||||
if (fil.GetLength() == 41600)
|
||||
{
|
||||
fil.Seek(-2, FileReader::SeekCur);
|
||||
numshades = 32;
|
||||
}
|
||||
else
|
||||
|
@ -129,8 +128,7 @@ void paletteLoadFromDisk(void)
|
|||
if (buffer.Size() != length) return;
|
||||
lookups.setTable(0, buffer.Data());
|
||||
|
||||
paletteloaded |= PALETTE_SHADE;
|
||||
paletteloaded |= PALETTE_TRANSLUC;
|
||||
paletteloaded |= PALETTE_SHADE | PALETTE_TRANSLUC;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -309,6 +309,16 @@ float R_DoomLightingEquation(float light)
|
|||
z = pixelpos.w;
|
||||
}
|
||||
|
||||
if ((uPalLightLevels >> 16) == 5) // gl_lightmode 5: Build software lighting emulation.
|
||||
{
|
||||
// This is a lot more primitive than Doom's lighting...
|
||||
float numShades = float(uPalLightLevels & 255);
|
||||
float curshade = (1.0 - light) * (numShades - 1.0);
|
||||
float visibility = max(uGlobVis * uLightFactor * z, 0.0);
|
||||
float shade = clamp((curshade + visibility), 0.0, numShades - 1.0);
|
||||
return clamp(shade * uLightDist, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float colormap = R_DoomColormap(light, z);
|
||||
|
||||
if ((uPalLightLevels & 0xff) != 0)
|
||||
|
|
Loading…
Reference in a new issue