Merge branch 'master' of https://github.com/coelckers/gzdoom into lightmaps2

# Conflicts:
#	src/common/rendering/gl/gl_shader.cpp
#	src/common/rendering/hwrenderer/data/buffers.h
#	src/common/rendering/v_video.h
This commit is contained in:
nashmuhandes 2022-01-16 01:57:38 +08:00
commit 57112742fe
298 changed files with 7614 additions and 3373 deletions

View file

@ -749,7 +749,6 @@ void F2DDrawer::AddPoly(FGameTexture *texture, FVector2 *points, int npoints,
void F2DDrawer::AddPoly(FGameTexture* img, FVector4* vt, size_t vtcount, const unsigned int* ind, size_t idxcount, int translation, PalEntry color, FRenderStyle style, int clipx1, int clipy1, int clipx2, int clipy2)
{
RenderCommand dg;
int method = 0;
if (!img || !img->isValid()) return;
@ -835,13 +834,13 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu
dg.mFlags = DTF_Wrap;
float fs = 1.f / float(flatscale);
bool flipc = false;
float sw = GetClassicFlatScalarWidth();
float sh = GetClassicFlatScalarHeight();
switch (local_origin)
{
default:
case 0:
fU1 = float(left) / (float)src->GetDisplayWidth() * fs;
fV1 = float(top) / (float)src->GetDisplayHeight() * fs;
@ -994,7 +993,7 @@ void F2DDrawer::AddLine(double x1, double y1, double x2, double y2, int clipx1,
dg.mScissor[3] = clipy2 + 1 + int(offset.Y);
dg.mFlags |= DTF_Scissor;
}
dg.mType = DrawTypeLines;
dg.mRenderStyle = LegacyRenderStyles[STYLE_Translucent];
dg.mVertCount = 2;

View file

@ -101,7 +101,7 @@ public:
}
};
struct RenderCommand
{
EDrawType mType;
@ -175,7 +175,7 @@ public:
public:
int fullscreenautoaspect = 3;
int cliptop = -1, clipleft = -1, clipwidth = -1, clipheight = -1;
int AddCommand(RenderCommand *data);
void AddIndices(int firstvert, int count, ...);
private:
@ -200,8 +200,8 @@ public:
void ClearScreen(PalEntry color = 0xff000000);
void AddDim(PalEntry color, float damount, int x1, int y1, int w, int h);
void AddClear(int left, int top, int right, int bottom, int palcolor, uint32_t color);
void AddLine(double x1, double y1, double x2, double y2, int cx, int cy, int cx2, int cy2, uint32_t color, uint8_t alpha = 255);
void AddThickLine(int x1, int y1, int x2, int y2, double thickness, uint32_t color, uint8_t alpha = 255);
void AddPixel(int x1, int y1, uint32_t color);

View file

@ -144,7 +144,7 @@ int GetUIScale(F2DDrawer *drawer, int altval)
// Default should try to scale to 640x400
int vscale = drawer->GetHeight() / 400;
int hscale = drawer->GetWidth() / 640;
scaleval = clamp(vscale, 1, hscale);
scaleval = max(1, min(vscale, hscale));
}
else scaleval = uiscale;
@ -165,7 +165,7 @@ int GetConScale(F2DDrawer* drawer, int altval)
// Default should try to scale to 640x400
int vscale = drawer->GetHeight() / 800;
int hscale = drawer->GetWidth() / 1280;
scaleval = clamp(vscale, 1, hscale);
scaleval = max(1, min(vscale, hscale));
}
else scaleval = (uiscale+1) / 2;
@ -671,7 +671,6 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
{
INTBOOL boolval;
int intval;
bool translationset = false;
bool fillcolorset = false;
if (!fortext)
@ -858,7 +857,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
parms->cleanmode = DTA_Base;
parms->virtHeight = ListGetDouble(tags);
break;
case DTA_FullscreenScale:
intval = ListGetInt(tags);
if (intval >= FSMode_None && intval < FSMode_Max)
@ -1016,10 +1015,16 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
case DTA_CenterOffsetRel:
assert(fortext == false);
if (fortext) return false;
if (ListGetInt(tags))
intval = ListGetInt(tags);
if (intval == 1)
{
parms->left = img->GetDisplayLeftOffset() + img->GetDisplayWidth() * 0.5;
parms->top = img->GetDisplayTopOffset() + img->GetDisplayHeight() * 0.5;
parms->left = img->GetDisplayLeftOffset() + (img->GetDisplayWidth() * 0.5);
parms->top = img->GetDisplayTopOffset() + (img->GetDisplayHeight() * 0.5);
}
else if (intval == 2)
{
parms->left = img->GetDisplayLeftOffset() + floor(img->GetDisplayWidth() * 0.5);
parms->top = img->GetDisplayTopOffset() + floor(img->GetDisplayHeight() * 0.5);
}
break;

View file

@ -36,7 +36,7 @@ enum
FSMode_Max,
// These all use ScaleToFit43, their purpose is to cut down on verbosity because they imply the virtual screen size.
FSMode_Predefined = 1000,
FSMode_Fit320x200 = 1000,
@ -325,3 +325,5 @@ public:
CleanHeight = savedheight;
}
};
void Draw2D(F2DDrawer* drawer, FRenderState& state);

View file

@ -226,7 +226,7 @@ void I_InitMusic(void)
nomusic = !!Args->CheckParm("-nomusic") || !!Args->CheckParm("-nosound");
snd_mididevice.Callback();
ZMusicCallbacks callbacks{};
callbacks.MessageFunc = zmusic_printfunc;

View file

@ -140,7 +140,7 @@ FileReader FSoundFontReader::Open(const char *name, std::string& filename)
ZMusicCustomReader* FSoundFontReader::open_interface(const char* name)
{
std::string filename;
FileReader fr = Open(name, filename);
if (!fr.isOpen()) return nullptr;
auto fri = GetMusicReader(fr);
@ -336,7 +336,7 @@ void FSoundFontManager::ProcessOneFile(const FString &fn)
// We already got a soundfont with this name. Do not add again.
if (!sfi.mName.CompareNoCase(fb)) return;
}
FileReader fr;
if (fr.OpenFile(fn))
{

View file

@ -29,13 +29,13 @@ protected:
// When reading from an archive it will always be case insensitive, just like the lump manager.
bool mCaseSensitivePaths = false;
TArray<FString> mPaths;
int pathcmp(const char *p1, const char *p2);
public:
virtual ~FSoundFontReader() {}
virtual FileReader OpenMainConfigFile() = 0; // this is special because it needs to be synthesized for .sf files and set some restrictions for patch sets
virtual FString MainConfigFileName()
@ -147,15 +147,15 @@ public:
class FSoundFontManager
{
TArray<FSoundFontInfo> soundfonts;
void ProcessOneFile(const FString & fn);
public:
void CollectSoundfonts();
const FSoundFontInfo *FindSoundFont(const char *name, int allowedtypes) const;
FSoundFontReader *OpenSoundFont(const char *name, int allowedtypes);
const auto &GetList() const { return soundfonts; } // This is for the menu
};

View file

@ -180,7 +180,7 @@ static bool FillStream(SoundStream* stream, void* buff, int len, void* userdata)
fbuf[i] = convert[i] * mus_playing.replayGainFactor * (1.f/32768.f);
}
}
if (!written)
{
memset((char*)buff, 0, len);
@ -298,7 +298,7 @@ void S_UpdateMusic ()
if (mus_playing.handle != nullptr)
{
ZMusic_Update(mus_playing.handle);
// [RH] Update music and/or playlist. IsPlaying() must be called
// to attempt to reconnect to broken net streams and to advance the
// playlist when the current song finishes.
@ -603,13 +603,13 @@ static void CheckReplayGain(const char *musicname, EMidiDevice playertype, const
{
float* sbuf = (float*)readbuffer.Data();
int numsamples = fmt.mBufferSize / 8;
auto index = lbuffer.Reserve(numsamples);
auto addr = lbuffer.Reserve(numsamples);
rbuffer.Reserve(numsamples);
for (int i = 0; i < numsamples; i++)
{
lbuffer[index + i] = sbuf[i * 2] * 32768.f;
rbuffer[index + i] = sbuf[i * 2 + 1] * 32768.f;
lbuffer[addr + i] = sbuf[i * 2] * 32768.f;
rbuffer[addr + i] = sbuf[i * 2 + 1] * 32768.f;
}
}
float accTime = lbuffer.Size() / (float)fmt.mSampleRate;
@ -684,8 +684,6 @@ bool S_ChangeMusic(const char* musicname, int order, bool looping, bool force)
return true;
}
int lumpnum = -1;
int length = 0;
ZMusic_MusicStream handle = nullptr;
MidiDeviceSetting* devp = MidiDevices.CheckKey(musicname);

View file

@ -107,7 +107,7 @@ public:
// Streaming sounds.
virtual SoundStream *CreateStream (SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata) = 0;
// Starts a sound.
virtual FISoundChannel *StartSound (SoundHandle sfx, float vol, int pitch, int chanflags, FISoundChannel *reuse_chan, float startTime = 0.f) = 0;
virtual FISoundChannel *StartSound3D (SoundHandle sfx, SoundListener *listener, float vol, FRolloffInfo *rolloff, float distscale, int pitch, int priority, const FVector3 &pos, const FVector3 &vel, int channum, int chanflags, FISoundChannel *reuse_chan, float startTime = 0.f) = 0;

View file

@ -329,7 +329,6 @@ public:
virtual FString GetStats()
{
FString stats;
size_t pos = 0, len = 0;
ALfloat volume;
ALint offset;
ALint processed;
@ -1676,7 +1675,7 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener)
const_cast<ReverbContainer*>(env)->Modified = false;
}
// NOTE: Moving into and out of water will undo pitch variations on sounds.
if(listener->underwater || env->SoftwareWater)
{
@ -1722,7 +1721,7 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener)
}
else if(WasInWater)
{
WasInWater = false;
if(EnvSlot != 0)

View file

@ -530,7 +530,7 @@ void S_ReadReverbDef (FScanner &sc)
{
const ReverbContainer *def;
ReverbContainer *newenv;
REVERB_PROPERTIES props;
REVERB_PROPERTIES props = {};
char *name;
int id1, id2, i, j;
bool inited[NUM_REVERB_FIELDS];

View file

@ -309,7 +309,6 @@ DEFINE_ACTION_FUNCTION(DReverbEdit, GetValue)
}
}
ACTION_RETURN_FLOAT(v);
return 1;
}
DEFINE_ACTION_FUNCTION(DReverbEdit, SetValue)
@ -337,14 +336,12 @@ DEFINE_ACTION_FUNCTION(DReverbEdit, SetValue)
}
ACTION_RETURN_FLOAT(v);
return 1;
}
DEFINE_ACTION_FUNCTION(DReverbEdit, GrayCheck)
{
PARAM_PROLOGUE;
ACTION_RETURN_BOOL(CurrentEnv->Builtin);
return 1;
}
DEFINE_ACTION_FUNCTION(DReverbEdit, GetSelectedEnvironment)

View file

@ -164,7 +164,6 @@ void SoundEngine::CacheSound (sfxinfo_t *sfx)
{
if (GSnd && !sfx->bTentative)
{
sfxinfo_t *orig = sfx;
while (!sfx->bRandomHeader && sfx->link != sfxinfo_t::NO_LINK)
{
sfx = &S_sfx[sfx->link];
@ -389,7 +388,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
FVector3 pos, vel;
FRolloffInfo *rolloff;
if (sound_id <= 0 || volume <= 0 || nosfx || !SoundEnabled() || blockNewSounds)
if (sound_id <= 0 || volume <= 0 || nosfx || !SoundEnabled() || blockNewSounds || (unsigned)sound_id >= S_sfx.Size())
return NULL;
// prevent crashes.
@ -403,7 +402,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
{
return nullptr;
}
sfx = &S_sfx[sound_id];
// Scale volume according to SNDINFO data.
@ -612,7 +611,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
{
chan->Source = source;
}
if (spitch > 0.0) // A_StartSound has top priority over all others.
SetPitch(chan, spitch);
else if (defpitch > 0.0) // $PitchSet overrides $PitchShift
@ -727,7 +726,7 @@ sfxinfo_t *SoundEngine::LoadSound(sfxinfo_t *sfx)
{
return sfx;
}
// See if there is another sound already initialized with this lump. If so,
// then set this one up as a link, and don't load the sound again.
for (i = 0; i < S_sfx.Size(); i++)
@ -831,7 +830,7 @@ bool SoundEngine::CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_
{
FSoundChan *chan;
int count;
for (chan = Channels, count = 0; chan != NULL && count < near_limit; chan = chan->NextChan)
{
if (chan->ChanFlags & CHANF_FORGETTABLE) continue;
@ -1085,13 +1084,14 @@ void SoundEngine::SetPitch(FSoundChan *chan, float pitch)
// Is a sound being played by a specific emitter?
//==========================================================================
int SoundEngine::GetSoundPlayingInfo (int sourcetype, const void *source, int sound_id)
int SoundEngine::GetSoundPlayingInfo (int sourcetype, const void *source, int sound_id, int chann)
{
int count = 0;
if (sound_id > 0)
{
for (FSoundChan *chan = Channels; chan != NULL; chan = chan->NextChan)
{
if (chann != -1 && chann != chan->EntChannel) continue;
if (chan->OrgID == sound_id && (sourcetype == SOURCE_Any ||
(chan->SourceType == sourcetype &&
chan->Source == source)))
@ -1104,6 +1104,7 @@ int SoundEngine::GetSoundPlayingInfo (int sourcetype, const void *source, int so
{
for (FSoundChan* chan = Channels; chan != NULL; chan = chan->NextChan)
{
if (chann != -1 && chann != chan->EntChannel) continue;
if ((sourcetype == SOURCE_Any || (chan->SourceType == sourcetype && chan->Source == source)))
{
count++;

View file

@ -73,7 +73,7 @@ class FSoundID
{
public:
FSoundID() = default;
static FSoundID byResId(int ndx)
{
return FSoundID(S_FindSoundByResID(ndx));
@ -120,7 +120,7 @@ protected:
enum EDummy { NoInit };
FSoundID(EDummy) {}
};
class FSoundIDNoInit : public FSoundID
{
public:
@ -196,7 +196,7 @@ void S_SetEnvironment (const ReverbContainer *settings);
ReverbContainer *S_FindEnvironment (const char *name);
ReverbContainer *S_FindEnvironment (int id);
void S_AddEnvironment (ReverbContainer *settings);
class SoundEngine
{
protected:
@ -249,9 +249,6 @@ public:
blockNewSounds = on;
}
virtual int SoundSourceIndex(FSoundChan* chan) { return 0; }
virtual void SetSource(FSoundChan* chan, int index) {}
virtual void StopChannel(FSoundChan* chan);
sfxinfo_t* LoadSound(sfxinfo_t* sfx);
const sfxinfo_t* GetSfx(unsigned snd)
@ -303,7 +300,7 @@ public:
bool IsSourcePlayingSomething(int sourcetype, const void* actor, int channel, int sound_id = -1);
// Stop and resume music, during game PAUSE.
int GetSoundPlayingInfo(int sourcetype, const void* source, int sound_id);
int GetSoundPlayingInfo(int sourcetype, const void* source, int sound_id, int chan = -1);
void UnloadAllSounds();
void Reset();
void MarkUsed(int num);

View file

@ -393,7 +393,7 @@ void FKeyBindings::PerformBind(FCommandLine &argv, const char *msg)
else
{
Printf ("%s:\n", msg);
for (i = 0; i < NUM_KEYS; i++)
{
if (!Binds[i].IsEmpty())
@ -696,7 +696,7 @@ void ReadBindings(int lump, bool override)
}
continue;
}
// bind destination is optional and is the same as the console command
if (sc.Compare("bind"))
{

View file

@ -101,13 +101,13 @@ int ButtonMap::ListActionCommands (const char *pattern)
int ButtonMap::FindButtonIndex (const char *key, int funclen) const
{
if (!key) return -1;
FName name = funclen == -1? FName(key, true) : FName(key, funclen, true);
if (name == NAME_None) return -1;
auto res = NameToNum.CheckKey(name);
if (!res) return -1;
return *res;
}

View file

@ -299,7 +299,7 @@ void FCommandBuffer::AddString(FString clip)
}
auto strp = (const uint8_t*)clip.GetChars();
while (auto chr = GetCharFromString(strp)) build += chr;
if (Text.length() == 0)
{
Text = build;

View file

@ -331,16 +331,16 @@ void C_DeinitConsole ()
// at runtime.)
for (size_t i = 0; i < countof(Commands); ++i)
{
FConsoleCommand *cmd = Commands[i];
FConsoleCommand *command = Commands[i];
while (cmd != NULL)
while (command != NULL)
{
FConsoleCommand *next = cmd->m_Next;
if (cmd->IsAlias())
FConsoleCommand *nextcmd = command->m_Next;
if (command->IsAlias())
{
delete cmd;
delete command;
}
cmd = next;
command = nextcmd;
}
}
@ -1027,7 +1027,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
TabbedList = false;
break;
}
case '`':
// Check to see if we have ` bound to the console before accepting
// it as a way to close the console.

View file

@ -72,7 +72,7 @@ FConsoleBuffer::FConsoleBuffer()
void FConsoleBuffer::AddText(int printlevel, const char *text)
{
FString build = TEXTCOLOR_TAN;
if (mAddType == REPLACELINE)
{
// Just wondering: Do we actually need this case? If so, it may need some work.
@ -85,15 +85,15 @@ void FConsoleBuffer::AddText(int printlevel, const char *text)
printlevel = -1;
mLastLineNeedsUpdate = true;
}
if (printlevel >= 0 && printlevel != PRINT_HIGH)
{
if (printlevel == 200) build = TEXTCOLOR_GREEN;
else if (printlevel < PRINTLEVELS) build.Format("%c%c", TEXTCOLOR_ESCAPE, PrintColors[printlevel]+'A');
}
size_t textsize = strlen(text);
if (text[textsize-1] == '\r')
{
textsize--;

View file

@ -56,12 +56,12 @@ class FConsoleBuffer
EAddType mAddType;
int mTextLines;
bool mBufferWasCleared;
FFont *mLastFont;
int mLastDisplayWidth;
bool mLastLineNeedsUpdate;
public:
FConsoleBuffer();
void AddText(int printlevel, const char *string);

View file

@ -333,6 +333,7 @@ UCVarValue FBaseCVar::FromBool (bool value, ECVarType type)
break;
default:
ret.Int = 0;
break;
}
@ -363,6 +364,7 @@ UCVarValue FBaseCVar::FromInt (int value, ECVarType type)
break;
default:
ret.Int = 0;
break;
}
@ -395,6 +397,7 @@ UCVarValue FBaseCVar::FromFloat (float value, ECVarType type)
break;
default:
ret.Int = 0;
break;
}
@ -456,6 +459,7 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type)
break;
default:
ret.Int = 0;
break;
}
@ -1426,12 +1430,12 @@ void C_ArchiveCVars (FConfigFile *f, uint32_t filter)
cvar = cvar->m_Next;
}
qsort(cvarlist.Data(), cvarlist.Size(), sizeof(FBaseCVar*), cvarcmp);
for (auto cvar : cvarlist)
for (auto cv : cvarlist)
{
const char* const value = (cvar->Flags & CVAR_ISDEFAULT)
? cvar->GetGenericRep(CVAR_String).String
: cvar->SafeValue.GetChars();
f->SetValueForKey(cvar->GetName(), value);
const char* const value = (cv->Flags & CVAR_ISDEFAULT)
? cv->GetGenericRep(CVAR_String).String
: cv->SafeValue.GetChars();
f->SetValueForKey(cv->GetName(), value);
}
}
@ -1643,7 +1647,6 @@ CCMD (archivecvar)
void C_ListCVarsWithoutDescription()
{
FBaseCVar* var = CVars;
int count = 0;
while (var)
{

View file

@ -175,7 +175,7 @@ public:
static void ResetColors (); // recalc color cvars' indices after screen change
static void ListVars (const char *filter, bool plain);
const FString &GetDescription() const { return Description; };
const FString& GetToggleMessage(int which) { return ToggleMessages[which]; }
void SetToggleMessages(const char* on, const char* off)
@ -398,7 +398,7 @@ public:
protected:
virtual void DoSet (UCVarValue value, ECVarType type);
static UCVarValue FromInt2 (int value, ECVarType type);
static int ToInt2 (UCVarValue value, ECVarType type);
};

View file

@ -253,7 +253,7 @@ void C_DoCommand (const char *cmd, int keynum)
return;
}
}
// Parse it as a normal command
// Checking for matching commands follows this search order:
// 1. Check the Commands[] hash table
@ -282,8 +282,8 @@ void C_DoCommand (const char *cmd, int keynum)
}
else
{
auto cmd = new FStoredCommand(com, beg);
delayedCommandQueue.AddCommand(cmd);
auto command = new FStoredCommand(com, beg);
delayedCommandQueue.AddCommand(command);
}
}
}
@ -373,8 +373,8 @@ void AddCommandString (const char *text, int keynum)
// Note that deferred commands lose track of which key
// (if any) they were pressed from.
*brkpt = ';';
auto cmd = new FWaitingCommand(brkpt, tics, UnsafeExecutionContext);
delayedCommandQueue.AddCommand(cmd);
auto command = new FWaitingCommand(brkpt, tics, UnsafeExecutionContext);
delayedCommandQueue.AddCommand(command);
}
return;
}
@ -851,8 +851,8 @@ CCMD (key)
for (i = 1; i < argv.argc(); ++i)
{
unsigned int key = MakeKey (argv[i]);
Printf (" 0x%08x\n", key);
unsigned int hash = MakeKey (argv[i]);
Printf (" 0x%08x\n", hash);
}
}
}
@ -1014,7 +1014,6 @@ void FExecList::AddPullins(TArray<FString> &wads, FConfigFile *config) const
FExecList *C_ParseExecFile(const char *file, FExecList *exec)
{
char cmd[4096];
int retval = 0;
FileReader fr;

View file

@ -248,7 +248,7 @@ done:
bool IsFloat (const char *str)
{
const char *pt;
if (*str == '+' || *str == '-')
str++;
@ -367,7 +367,7 @@ static FStringProd *DoubleToString (FProduction *prod)
static FDoubleProd *StringToDouble (FProduction *prod)
{
FDoubleProd *newprod;
newprod = NewDoubleProd (atof (static_cast<FStringProd *>(prod)->Value));
M_Free (prod);
return newprod;

View file

@ -126,7 +126,7 @@ void FNotifyBufferBase::Tick()
{
Text[i].Ticker++;
}
for (i = 0; i < Text.Size(); ++i)
{
if (Text[i].TimeOut != 0 && Text[i].TimeOut > Text[i].Ticker)

View file

@ -97,20 +97,20 @@ void FCycler::Update(double diff)
{
double mult, angle;
double step = m_end - m_start;
if (!m_shouldCycle)
{
return;
}
m_time += diff;
if (m_time >= m_cycle)
{
m_time = m_cycle;
}
mult = m_time / m_cycle;
switch (m_cycleType)
{
case CYCLE_Linear:
@ -149,7 +149,7 @@ void FCycler::Update(double diff)
}
break;
}
if (m_time == m_cycle)
{
m_time = 0.;

View file

@ -23,7 +23,7 @@ public:
FCycler() = default;
FCycler(const FCycler &other) = default;
FCycler &operator=(const FCycler &other) = default;
void Update(double diff);
void SetParams(double start, double end, double cycle, bool update = false);
void ShouldCycle(bool sc) { m_shouldCycle = sc; }

View file

@ -67,11 +67,21 @@ CVAR(Bool, m_filter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
void D_ProcessEvents (void)
{
event_t *ev;
FixedBitArray<NUM_KEYS> keywasdown;
TArray<event_t> delayedevents;
keywasdown.Zero();
while (eventtail != eventhead)
{
ev = &events[eventtail];
event_t *ev = &events[eventtail];
eventtail = (eventtail + 1) & (MAXEVENTS - 1);
if (ev->type == EV_KeyUp && keywasdown[ev->data1])
{
delayedevents.Push(*ev);
continue;
}
if (ev->type == EV_None)
continue;
if (ev->type == EV_DeviceChange)
@ -85,7 +95,12 @@ void D_ProcessEvents (void)
continue; // menu ate the event
}
G_Responder (ev);
if (G_Responder(ev) && ev->type == EV_KeyDown) keywasdown.Set(ev->data1);
}
for (auto& ev: delayedevents)
{
D_PostEvent(&ev);
}
}
@ -123,7 +138,7 @@ void D_RemoveNextCharEvent()
}
}
}
//==========================================================================
//

View file

@ -7,7 +7,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
@ -172,7 +172,7 @@ FString GetPlayerName(int num)
SOCKET UDPsocket (void)
{
SOCKET s;
// allocate a socket
s = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (s == INVALID_SOCKET)
@ -193,7 +193,7 @@ void BindToLocalPort (SOCKET s, u_short port)
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons(port);
v = bind (s, (sockaddr *)&address, sizeof(address));
if (v == SOCKET_ERROR)
I_FatalError ("BindToPort: %s", neterror ());
@ -459,7 +459,7 @@ void StartNetwork (bool autoPort)
netgame = true;
multiplayer = true;
// create communication socket
mysocket = UDPsocket ();
BindToLocalPort (mysocket, autoPort ? 0 : DOOMPORT);
@ -736,7 +736,7 @@ bool HostGame (int i)
{
// If we send the packets eight times to each guest,
// hopefully at least one of them will get through.
for (int i = 8; i != 0; --i)
for (int ii = 8; ii != 0; --ii)
{
PreSend (&packet, 2, &sendaddress[node]);
}
@ -892,7 +892,7 @@ bool JoinGame (int i)
SendAbort();
return false;
}
StartScreen->NetMessage ("Total players: %d", doomcom.numnodes);
doomcom.id = DOOMCOM_ID;

View file

@ -76,7 +76,7 @@ struct doomcom_t
// packet data to be sent
uint8_t data[MAX_MSGLEN];
};
extern doomcom_t doomcom;

View file

@ -21,7 +21,7 @@ enum EJoyAxis
struct NOVTABLE IJoystickConfig
{
virtual ~IJoystickConfig() = 0;
virtual FString GetName() = 0;
virtual float GetSensitivity() = 0;
virtual void SetSensitivity(float scale) = 0;

View file

@ -234,7 +234,7 @@ void PaletteContainer::UpdateTranslation(int trans, FRemapTable* remap)
int PaletteContainer::AddTranslation(int slot, FRemapTable* remap, int count)
{
uint32_t id;
uint32_t id = 0;
for (int i = 0; i < count; i++)
{
auto newremap = AddRemap(&remap[i]);
@ -265,7 +265,7 @@ FRemapTable *PaletteContainer::TranslationToTable(int translation)
unsigned int type = GetTranslationType(translation);
unsigned int index = GetTranslationIndex(translation);
if (type < 0 || type >= TranslationTables.Size() || index >= NumTranslations(type))
if (type >= TranslationTables.Size() || index >= NumTranslations(type))
{
return uniqueRemaps[0]; // this is the identity table.
}
@ -649,7 +649,6 @@ bool FRemapTable::AddTint(int start, int end, int r, int g, int b, int amount)
bool FRemapTable::AddToTranslation(const char *range)
{
int start,end;
bool desaturated = false;
FScanner sc;
sc.OpenMem("translation", range, int(strlen(range)));

View file

@ -857,7 +857,7 @@ bool FScanner::CheckFloat (bool evaluate)
UnGet();
return false;
}
Float = strtod (String, &stopper);
if (*stopper != 0)
{
@ -1131,9 +1131,7 @@ FString FScanner::TokenName (int token, const char *string)
}
else
{
FString work;
work.Format ("Unknown(%d)", token);
return work;
work.Format("Unknown(%d)", token);
}
return work;
}

View file

@ -159,7 +159,7 @@ public:
{
return constants.CheckKey(name);
}
// Token based variant
bool CheckValue(bool allowfloat, bool evaluate = true);
void MustGetValue(bool allowfloat, bool evaluate = true);

View file

@ -102,14 +102,14 @@ std2:
":" { RET(':'); }
";" { RET(';'); }
"}" { StateMode = 0; StateOptions = false; RET('}'); }
WSP+ { goto std1; }
"\n" { goto newline; }
TOKS = (NWS\[/":;}]);
TOKS* ([/] (TOKS\[*]) TOKS*)*
{ RET(TK_NonWhitespace); }
*/
}
else if (tokens) // A well-defined scanner, based on the c.re example.
@ -222,7 +222,7 @@ std2:
'canraise' { RET(StateOptions ? TK_CanRaise : TK_Identifier); }
'offset' { RET(StateOptions ? TK_Offset : TK_Identifier); }
'light' { RET(StateOptions ? TK_Light : TK_Identifier); }
/* other DECORATE top level keywords */
'#include' { RET(TK_Include); }

View file

@ -290,6 +290,28 @@ bool FSerializer::BeginObject(const char *name)
//
//==========================================================================
bool FSerializer::HasObject(const char* name)
{
if (isReading())
{
auto val = r->FindKey(name);
if (val != nullptr)
{
if (val->IsObject())
{
return true;
}
}
}
return false;
}
//==========================================================================
//
//
//
//==========================================================================
void FSerializer::EndObject()
{
if (isWriting())
@ -601,7 +623,7 @@ void FSerializer::WriteObjects()
void FSerializer::ReadObjects(bool hubtravel)
{
bool founderrors = false;
if (isReading() && BeginArray("objects"))
{
// Do not link any thinker that's being created here. This will be done by deserializing the thinker list later.
@ -619,7 +641,6 @@ void FSerializer::ReadObjects(bool hubtravel)
if (BeginObject(nullptr))
{
FString clsname; // do not deserialize the class type directly so that we can print appropriate errors.
int pindex = -1;
Serialize(*this, "classtype", clsname, nullptr);
PClass *cls = PClass::FindClass(clsname);
@ -643,6 +664,7 @@ void FSerializer::ReadObjects(bool hubtravel)
if (!founderrors)
{
// Reset to start;
unsigned size = r->mObjects.Size();
r->mObjects.Last().mIndex = 0;
for (unsigned i = 0; i < r->mDObjects.Size(); i++)
@ -652,7 +674,6 @@ void FSerializer::ReadObjects(bool hubtravel)
{
if (obj != nullptr)
{
int pindex = -1;
try
{
obj->SerializeUserVars(*this);
@ -660,6 +681,7 @@ void FSerializer::ReadObjects(bool hubtravel)
}
catch (CRecoverableError &err)
{
r->mObjects.Clamp(size); // close all inner objects.
// In case something in here throws an error, let's continue and deal with it later.
Printf(TEXTCOLOR_RED "'%s'\n while restoring %s\n", err.GetMessage(), obj ? obj->GetClass()->TypeName.GetChars() : "invalid object");
mErrors++;

View file

@ -85,6 +85,7 @@ public:
void ReadObjects(bool hubtravel);
bool BeginObject(const char *name);
void EndObject();
bool HasObject(const char* name);
bool BeginArray(const char *name);
void EndArray();
unsigned GetSize(const char *group);
@ -110,7 +111,7 @@ public:
{
return w != nullptr;
}
bool canSkip() const;
template<class T>
@ -234,7 +235,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FSoundID &sid, FSoundI
FSerializer &Serialize(FSerializer &arc, const char *key, FString &sid, FString *def);
FSerializer &Serialize(FSerializer &arc, const char *key, NumericValue &sid, NumericValue *def);
template<class T>
template <typename T/*, typename = std::enable_if_t<std::is_base_of_v<DObject, T>>*/>
FSerializer &Serialize(FSerializer &arc, const char *key, T *&value, T **)
{
DObject *v = static_cast<DObject*>(value);
@ -301,6 +302,11 @@ FSerializer& Serialize(FSerializer& arc, const char* key, FixedBitArray<size>& v
return arc.SerializeMemory(key, value.Storage(), value.StorageSize());
}
inline FSerializer& Serialize(FSerializer& arc, const char* key, BitArray& value, BitArray* def)
{
return arc.SerializeMemory(key, value.Storage().Data(), value.Storage().Size());
}
template<> FSerializer& Serialize(FSerializer& arc, const char* key, PClass*& clst, PClass** def);
template<> FSerializer& Serialize(FSerializer& arc, const char* key, FFont*& font, FFont** def);
template<> FSerializer &Serialize(FSerializer &arc, const char *key, Dictionary *&dict, Dictionary **def);

View file

@ -42,7 +42,7 @@ struct FWriter
rapidjson::StringBuffer mOutString;
TArray<DObject *> mDObjects;
TMap<DObject *, int> mObjectMap;
FWriter(bool pretty)
{
if (!pretty)
@ -193,7 +193,7 @@ struct FReader
rapidjson::Value *FindKey(const char *key)
{
FJSONObject &obj = mObjects.Last();
if (obj.mObject->IsObject())
{
if (key == nullptr)

View file

@ -47,7 +47,7 @@ public:
CurPos = 0;
NotchPos = 0;
}
virtual ~FStartupScreen() = default;
virtual void Progress() {}
@ -98,7 +98,7 @@ public:
void AppendStatusLine(const char *status);
protected:
void SetWindowSize();
int ThermX, ThermY, ThermWidth, ThermHeight;
int HMsgY, SMsgX;
};

View file

@ -61,28 +61,28 @@ public:
{
Sec = 0;
}
void Clock()
{
timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
Sec -= ts.tv_sec + ts.tv_nsec * 1e-9;
}
void Unclock()
{
timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
Sec += ts.tv_sec + ts.tv_nsec * 1e-9;
}
double Time()
{
return Sec;
}
double TimeMS()
{
return Sec * 1e3;
@ -159,24 +159,24 @@ public:
{
Counter = 0;
}
void Clock()
{
int64_t time = rdtsc();
Counter -= time;
}
void Unclock(bool checkvar = true)
{
int64_t time = rdtsc();
Counter += time;
}
double Time()
{
return Counter * PerfToSec;
}
double TimeMS()
{
return Counter * PerfToMillisec;

View file

@ -639,7 +639,7 @@ bool FStringTable::MatchDefaultString(const char *name, const char *content) con
// This only compares the first line to avoid problems with bad linefeeds. For the few cases where this feature is needed it is sufficient.
auto c = GetLanguageString(name, FStringTable::default_table);
if (!c) return false;
// Check a secondary key, in case the text comparison cannot be done due to needed orthographic fixes (see Harmony's exit text)
FStringf checkkey("%s_CHECK", name);
auto cc = GetLanguageString(checkkey, FStringTable::default_table);

View file

@ -91,7 +91,7 @@ public:
allStrings.Insert(override_table, map);
UpdateLanguage(nullptr);
}
const char *GetLanguageString(const char *name, uint32_t langtable, int gender = -1) const;
bool MatchDefaultString(const char *name, const char *content) const;
const char *GetString(const char *name, uint32_t *langtable, int gender = -1) const;
@ -110,7 +110,7 @@ private:
StringMacroMap allMacros;
LangMap allStrings;
TArray<std::pair<uint32_t, StringMap*>> currentLanguageSet;
void LoadLanguage (int lumpnum, const TArray<uint8_t> &buffer);
TArray<TArray<FString>> parseCSV(const TArray<uint8_t> &buffer);
bool ParseLanguageCSV(int lumpnum, const TArray<uint8_t> &buffer);
@ -127,7 +127,7 @@ public:
if (*str == '$') return str;
return FString("$") + str;
}
static FString MakeMacro(const char *str, size_t len)
{
if (*str == '$') return FString(str, len);

View file

@ -57,7 +57,7 @@ ColorTable256k RGB256k;
void BuildTransTable (const PalEntry *palette)
{
int r, g, b;
// create the RGB555 lookup table
for (r = 0; r < 32; r++)
for (g = 0; g < 32; g++)
@ -68,16 +68,16 @@ void BuildTransTable (const PalEntry *palette)
for (g = 0; g < 64; g++)
for (b = 0; b < 64; b++)
RGB256k.RGB[r][g][b] = ColorMatcher.Pick ((r<<2)|(r>>4), (g<<2)|(g>>4), (b<<2)|(b>>4));
int x, y;
// create the swizzled palette
for (x = 0; x < 65; x++)
for (y = 0; y < 256; y++)
Col2RGB8[x][y] = (((palette[y].r*x)>>4)<<20) |
((palette[y].g*x)>>4) |
(((palette[y].b*x)>>4)<<10);
// create the swizzled palette with the lsb of red and blue forced to 0
// (for green, a 1 is okay since it never gets added into)
for (x = 1; x < 64; x++)
@ -90,7 +90,7 @@ void BuildTransTable (const PalEntry *palette)
}
Col2RGB8_LessPrecision[0] = Col2RGB8[0];
Col2RGB8_LessPrecision[64] = Col2RGB8[64];
// create the inverse swizzled palette
for (x = 0; x < 65; x++)
for (y = 0; y < 256; y++)

View file

@ -41,8 +41,6 @@
#include "printf.h"
#include "findfile.h"
//==========================================================================
//
// Zip Lump
@ -120,7 +118,7 @@ int FDirectory::AddDirectory(const char *dirpath)
FString dirmatch = dirpath;
findstate_t find;
dirmatch += '*';
handle = I_FindFirst(dirmatch.GetChars(), &find);
if (handle == ((void *)(-1)))
{

View file

@ -99,7 +99,7 @@ bool FGrpFile::Open(bool quiet, LumpFilterInfo*)
Reader.Read(&header, sizeof(header));
NumLumps = LittleLong(header.NumLumps);
GrpLump *fileinfo = new GrpLump[NumLumps];
Reader.Read (fileinfo, NumLumps * sizeof(GrpLump));

View file

@ -95,7 +95,7 @@ bool FPakFile::Open(bool quiet, LumpFilterInfo* filter)
Reader.Read(&header, sizeof(header));
NumLumps = LittleLong(header.dirlen) / sizeof(dpackfile_t);
header.dirofs = LittleLong(header.dirofs);
TArray<dpackfile_t> fileinfo(NumLumps, true);
Reader.Seek (header.dirofs, FileReader::SeekSet);
Reader.Read (fileinfo.Data(), NumLumps * sizeof(dpackfile_t));

View file

@ -221,7 +221,7 @@ int FRFFLump::FillCache()
{
int cryptlen = min<int> (LumpSize, 256);
uint8_t *data = (uint8_t *)Cache;
for (int i = 0; i < cryptlen; ++i)
{
data[i] ^= i >> 1;

View file

@ -206,7 +206,7 @@ bool FWadFile::Open(bool quiet, LumpFilterInfo*)
Lumps[i].LumpSize = isBigEndian ? BigLong(fileinfo[i].Size) : LittleLong(fileinfo[i].Size);
Lumps[i].Namespace = ns_global;
Lumps[i].Flags = Lumps[i].Compressed ? LUMPF_COMPRESSED | LUMPF_SHORTNAME : LUMPF_SHORTNAME;
// Check if the lump is within the WAD file and print a warning if not.
if (Lumps[i].Position + Lumps[i].LumpSize > wadSize || Lumps[i].Position < 0 || Lumps[i].LumpSize < 0)
{
@ -279,7 +279,7 @@ void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, name
int numstartmarkers = 0, numendmarkers = 0;
unsigned int i;
TArray<Marker> markers;
for(i = 0; i < NumLumps; i++)
{
if (IsMarker(i, startmarker))
@ -302,20 +302,20 @@ void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, name
Printf(TEXTCOLOR_YELLOW"WARNING: %s marker without corresponding %s found.\n", endmarker, startmarker);
if (flathack)
{
// We have found no F_START but one or more F_END markers.
// mark all lumps before the last F_END marker as potential flats.
unsigned int end = markers[markers.Size()-1].index;
for(unsigned int i = 0; i < end; i++)
for(unsigned int ii = 0; ii < end; ii++)
{
if (Lumps[i].LumpSize == 4096)
if (Lumps[ii].LumpSize == 4096)
{
// We can't add this to the flats namespace but
// it needs to be flagged for the texture manager.
DPrintf(DMSG_NOTIFY, "Marking %s as potential flat\n", Lumps[i].getName());
Lumps[i].Flags |= LUMPF_MAYBEFLAT;
DPrintf(DMSG_NOTIFY, "Marking %s as potential flat\n", Lumps[ii].getName());
Lumps[ii].Flags |= LUMPF_MAYBEFLAT;
}
}
}
@ -428,18 +428,19 @@ void FWadFile::SkinHack ()
namespc++;
}
}
// needless to say, this check is entirely useless these days as map names can be more diverse..
if ((lump->getName()[0] == 'M' &&
lump->getName()[1] == 'A' &&
lump->getName()[2] == 'P' &&
lump->getName()[3] >= '0' && lump->getName()[3] <= '9' &&
lump->getName()[4] >= '0' && lump->getName()[4] <= '9' &&
lump->getName()[5] >= '\0')
lump->getName()[5] == '\0')
||
(lump->getName()[0] == 'E' &&
lump->getName()[1] >= '0' && lump->getName()[1] <= '9' &&
lump->getName()[2] == 'M' &&
lump->getName()[3] >= '0' && lump->getName()[3] <= '9' &&
lump->getName()[4] >= '\0'))
lump->getName()[4] == '\0'))
{
hasmap = true;
}

View file

@ -95,10 +95,10 @@ FWHResFile::FWHResFile(const char *filename, FileReader &file)
bool FWHResFile::Open(bool quiet, LumpFilterInfo*)
{
int directory[1024];
Reader.Seek(-4096, FileReader::SeekEnd);
Reader.Read(directory, 4096);
int nl =1024/3;
Lumps.Resize(nl);
@ -135,10 +135,10 @@ FResourceFile *CheckWHRes(const char *filename, FileReader &file, bool quiet, Lu
{
int directory[1024];
int nl =1024/3;
file.Seek(-4096, FileReader::SeekEnd);
file.Read(directory, 4096);
int checkpos = 0;
for(int k = 0; k < nl; k++)
{

View file

@ -218,14 +218,13 @@ void FileSystem::InitMultipleFiles (TArray<FString> &filenames, bool quiet, Lump
for(unsigned i=0;i<filenames.Size(); i++)
{
int baselump = NumEntries;
AddFile (filenames[i], nullptr, quiet, filter);
if (i == (unsigned)MaxIwadIndex) MoveLumpsInFolder("after_iwad/");
FStringf path("filter/%s", Files.Last()->GetHash().GetChars());
MoveLumpsInFolder(path);
}
NumEntries = FileInfo.Size();
if (NumEntries == 0)
{
@ -284,7 +283,7 @@ int FileSystem::AddFromBuffer(const char* name, const char* type, char* data, in
FileInfo.Last().resourceId = id;
return FileInfo.Size()-1;
}
//==========================================================================
//
// AddFile
@ -333,7 +332,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, bool quiet, L
startlump = NumEntries;
FResourceFile *resfile;
if (!isdir)
resfile = FResourceFile::OpenResourceFile(filename, filereader, quiet, false, filter);
else
@ -946,10 +945,10 @@ void FileSystem::MoveLumpsInFolder(const char *path)
{
return;
}
auto len = strlen(path);
auto rfnum = FileInfo.Last().rfnum;
unsigned i;
for (i = 0; i < FileInfo.Size(); i++)
{
@ -1022,7 +1021,7 @@ int FileSystem::FindLumpMulti (const char **names, int *lastlump, bool anyns, in
{
if (anyns || lump_p->Namespace == ns_global)
{
for(const char **name = names; *name != NULL; name++)
{
if (!strnicmp(*name, lump_p->shortName.String, 8))
@ -1512,7 +1511,7 @@ int FileSystem::GetEntryCount (int rfnum) const noexcept
{
return 0;
}
return Files[rfnum]->LumpCount();
}
@ -1669,3 +1668,20 @@ FResourceLump* FileSystem::GetFileAt(int no)
return FileInfo[no].lump;
}
#include "c_dispatch.h"
CCMD(fs_dir)
{
int numfiles = fileSystem.GetNumEntries();
for (int i = 0; i < numfiles; i++)
{
auto container = fileSystem.GetResourceFileFullName(fileSystem.GetFileContainer(i));
auto fn1 = fileSystem.GetFileFullName(i);
auto fns = fileSystem.GetFileShortName(i);
auto fnid = fileSystem.GetResourceId(i);
auto length = fileSystem.FileLength(i);
bool hidden = fileSystem.FindFile(fn1) != i;
Printf(PRINT_NONOTIFY, "%s%-64s %-15s (%5d) %10d %s %s\n", hidden ? TEXTCOLOR_RED : TEXTCOLOR_UNTRANSLATED, fn1, fns, fnid, length, container, hidden ? "(h)" : "");
}
}

View file

@ -306,11 +306,11 @@ int lumpcmp(const void * a, const void * b)
void FResourceFile::GenerateHash()
{
// hash the lump directory after sorting
Hash.Format(("%08X-%04X-"), (unsigned)Reader.GetLength(), NumLumps);
MD5Context md5;
uint8_t digest[16];
for(uint32_t i = 0; i < NumLumps; i++)
{
@ -382,9 +382,9 @@ int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize,
return 0;
}
filter << "filter/" << filtername << '/';
bool found = FindPrefixRange(filter, lumps, lumpsize, max, start, end);
// Workaround for old Doom filter names.
if (!found && filtername.IndexOf("doom.id.doom") == 0)
{
@ -490,7 +490,7 @@ bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize
{
uint32_t min, max, mid, inside;
FResourceLump *lump;
int cmp;
int cmp = 0;
end = start = 0;
@ -499,7 +499,7 @@ bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize
lumps = (uint8_t *)lumps - lumpsize;
// Binary search to find any match at all.
min = 1, max = maxlump;
mid = min = 1, max = maxlump;
while (min <= max)
{
mid = min + (max - min) / 2;

View file

@ -6,6 +6,7 @@
#include <limits.h>
#include "files.h"
#include "zstring.h"
struct LumpFilterInfo
{

View file

@ -86,10 +86,10 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
TMap<int, FGameTexture*> charMap;
int minchar = INT_MAX;
int maxchar = INT_MIN;
// Read the font's configuration.
// This will not be done for the default fonts, because they are not atomic and the default content does not need it.
TArray<FolderEntry> folderdata;
if (filetemplate != nullptr)
{
@ -97,16 +97,16 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
// If a name template is given, collect data from all resource files.
// For anything else, each folder is being treated as an atomic, self-contained unit and mixing from different glyph sets is blocked.
fileSystem.GetFilesInFolder(path, folderdata, nametemplate == nullptr);
//if (nametemplate == nullptr)
{
FStringf infpath("fonts/%s/font.inf", filetemplate);
unsigned index = folderdata.FindEx([=](const FolderEntry &entry)
{
return infpath.CompareNoCase(entry.name) == 0;
});
if (index < folderdata.Size())
{
FScanner sc;
@ -182,7 +182,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
}
}
}
if (FixedWidth > 0)
{
ReadSheetFont(folderdata, FixedWidth, FontHeight, Scale);
@ -292,12 +292,12 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
auto position = strtoll(base.GetChars(), &endp, 16);
if ((*endp == 0 || (*endp == '.' && position >= '!' && position < 0xffff)))
{
auto lump = TexMan.CheckForTexture(entry.name, ETextureType::MiscPatch);
if (lump.isValid())
auto texlump = TexMan.CheckForTexture(entry.name, ETextureType::MiscPatch);
if (texlump.isValid())
{
if ((int)position < minchar) minchar = (int)position;
if ((int)position > maxchar) maxchar = (int)position;
auto tex = TexMan.GetGameTexture(lump);
auto tex = TexMan.GetGameTexture(texlump);
tex->SetScale((float)Scale.X, (float)Scale.Y);
charMap.Insert((int)position, tex);
Type = Folder;
@ -313,10 +313,10 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
for (i = 0; i < count; i++)
{
auto lump = charMap.CheckKey(FirstChar + i);
if (lump != nullptr)
auto charlump = charMap.CheckKey(FirstChar + i);
if (charlump != nullptr)
{
auto pic = *lump;
auto pic = *charlump;
if (pic != nullptr)
{
double fheight = pic->GetDisplayHeight();
@ -399,8 +399,8 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
part[0].OriginY = -height * y;
part[0].TexImage = static_cast<FImageTexture*>(tex->GetTexture());
FMultiPatchTexture *image = new FMultiPatchTexture(width, height, part, false, false);
FImageTexture *tex = new FImageTexture(image);
auto gtex = MakeGameTexture(tex, nullptr, ETextureType::FontChar);
FImageTexture *imgtex = new FImageTexture(image);
auto gtex = MakeGameTexture(imgtex, nullptr, ETextureType::FontChar);
gtex->SetWorldPanning(true);
gtex->SetOffsets(0, 0, 0);
gtex->SetOffsets(1, 0, 0);
@ -424,7 +424,6 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
LastChar = maxchar;
auto count = maxchar - minchar + 1;
Chars.Resize(count);
int fontheight = 0;
for (int i = 0; i < count; i++)
{
@ -560,10 +559,10 @@ FFont *FFont::FindFont (FName name)
void RecordTextureColors (FImageSource *pic, uint32_t *usedcolors)
{
int x;
auto pixels = pic->GetPalettedPixels(false);
auto size = pic->GetWidth() * pic->GetHeight();
for(x = 0;x < size; x++)
{
usedcolors[pixels[x]]++;
@ -728,7 +727,7 @@ int FFont::GetCharCode(int code, bool needpic) const
{
return code;
}
// Use different substitution logic based on the fonts content:
// In a font which has both upper and lower case, prefer unaccented small characters over capital ones.
// In a pure upper-case font, do not check for lower case replacements.
@ -806,7 +805,7 @@ FGameTexture *FFont::GetChar (int code, int translation, int *const width) const
code -= FirstChar;
xmove = Chars[code].XMove;
}
if (width != nullptr)
{
*width = xmove;

View file

@ -266,7 +266,7 @@ int FHexFontChar2::CopyPixels(FBitmap* bmp, int conversion)
class FHexFont : public FFont
{
public:
//==========================================================================
//
@ -283,14 +283,14 @@ public:
assert(lump >= 0);
FontName = fontname;
FirstChar = hexdata.FirstChar;
LastChar = hexdata.LastChar;
FontHeight = 16;
SpaceWidth = 9;
GlobalKerning = 0;
Chars.Resize(LastChar - FirstChar + 1);
for (int i = FirstChar; i <= LastChar; i++)
{
@ -325,7 +325,7 @@ public:
else Translations[i] = LuminosityTranslation(i * 2 + 1, minlum, maxlum);
}
}
};

View file

@ -96,7 +96,7 @@ protected:
void LoadFON1 (int lump, const uint8_t *data);
void LoadFON2 (int lump, const uint8_t *data);
void LoadBMF (int lump, const uint8_t *data);
enum
{
FONT1,
@ -259,7 +259,7 @@ void FSingleLumpFont::LoadFON2 (int lump, const uint8_t *data)
LastChar = data[7];
ActiveColors = data[10]+1;
RescalePalette = data[9] == 0;
count = LastChar - FirstChar + 1;
Chars.Resize(count);
TArray<int> widths2(count, true);
@ -309,9 +309,9 @@ void FSingleLumpFont::LoadFON2 (int lump, const uint8_t *data)
}
Palette[0] = 0;
for (int i = 1; i < ActiveColors; i++)
for (int pp = 1; pp < ActiveColors; pp++)
{
Palette[i] = PalEntry(255, palette[i * 3], palette[i * 3 + 1], palette[i * 3 + 2]);
Palette[pp] = PalEntry(255, palette[pp * 3], palette[pp * 3 + 1], palette[pp * 3 + 2]);
}
data_p = palette + ActiveColors*3;

View file

@ -102,12 +102,12 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FGameTexture
if (charlumps[i] != nullptr)
{
auto pic = charlumps[i];
Chars[i].OriginalPic = MakeGameTexture(pic->GetTexture(), nullptr, ETextureType::FontChar);
Chars[i].OriginalPic->CopySize(pic, true);
auto charpic = charlumps[i];
Chars[i].OriginalPic = MakeGameTexture(charpic->GetTexture(), nullptr, ETextureType::FontChar);
Chars[i].OriginalPic->CopySize(charpic, true);
TexMan.AddGameTexture(Chars[i].OriginalPic);
Chars[i].XMove = (int)Chars[i].OriginalPic->GetDisplayWidth();
if (sysCallbacks.FontCharCreated) sysCallbacks.FontCharCreated(pic, Chars[i].OriginalPic);
if (sysCallbacks.FontCharCreated) sysCallbacks.FontCharCreated(charpic, Chars[i].OriginalPic);
}
else
{

View file

@ -106,10 +106,10 @@ FFont *V_GetFont(const char *name, const char *fontlumpname)
int lump = -1;
int folderfile = -1;
TArray<FolderEntry> folderdata;
FStringf path("fonts/%s/", name);
// Use a folder-based font only if it comes from a later file than the single lump version.
if (fileSystem.GetFilesInFolder(path, folderdata, true))
{
@ -119,7 +119,7 @@ FFont *V_GetFont(const char *name, const char *fontlumpname)
lump = fileSystem.CheckNumForFullName(fontlumpname? fontlumpname : name, true);
if (lump != -1 && fileSystem.GetFileContainer(lump) >= folderfile)
{
uint32_t head;
@ -725,9 +725,9 @@ static void CalcDefaultTranslation(FFont* base, int index)
auto lum = otherluminosity[i];
if (lum >= 0 && lum <= 1)
{
int index = int(lum * 255);
remap[index] = GPalette.BaseColors[i];
remap[index].a = 255;
int lumidx = int(lum * 255);
remap[lumidx] = GPalette.BaseColors[i];
remap[lumidx].a = 255;
}
}
@ -769,7 +769,7 @@ static void CalcDefaultTranslation(FFont* base, int index)
lowindex = highindex++;
}
}
}
//==========================================================================

View file

@ -88,7 +88,6 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
{
if (*string == '[')
{
const uint8_t* start = string;
while (*string != ']' && *string != '\0')
{
string++;

View file

@ -160,12 +160,12 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
it = opt->GetItem("ConnectMessage2");
if (it != nullptr) it->SetValue(0, !use_joystick);
for (int i = 0; i < (int)Joysticks.Size(); ++i)
for (int ii = 0; ii < (int)Joysticks.Size(); ++ii)
{
it = CreateOptionMenuItemJoyConfigMenu(Joysticks[i]->GetName(), Joysticks[i]);
it = CreateOptionMenuItemJoyConfigMenu(Joysticks[ii]->GetName(), Joysticks[ii]);
GC::WriteBarrier(opt, it);
opt->mItems.Push(it);
if (i == itemnum) opt->mSelectedItem = opt->mItems.Size();
if (ii == itemnum) opt->mSelectedItem = opt->mItems.Size();
}
if (opt->mSelectedItem >= (int)opt->mItems.Size())
{
@ -179,15 +179,15 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
auto p = CurrentMenu->PointerVar<IJoystickConfig>("mJoy");
if (p != nullptr)
{
unsigned i;
for (i = 0; i < Joysticks.Size(); ++i)
unsigned ii;
for (ii = 0; ii < Joysticks.Size(); ++ii)
{
if (Joysticks[i] == p)
if (Joysticks[ii] == p)
{
break;
}
}
if (i == Joysticks.Size())
if (ii == Joysticks.Size())
{
CurrentMenu->Close();
}

View file

@ -271,7 +271,7 @@ DMenu::DMenu(DMenu *parent)
DontDim = false;
GC::WriteBarrier(this, parent);
}
//=============================================================================
//
//

View file

@ -340,6 +340,10 @@ static void DoParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc, bool &s
{
desc->mCenter = true;
}
else if (sc.Compare("Selecteditem"))
{
desc->mSelectedItem = desc->mItems.Size() - 1;
}
else if (sc.Compare("animatedtransition"))
{
desc->mAnimatedTransition = true;
@ -563,8 +567,8 @@ static void DoParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc, bool &s
// NB: index has been incremented, so we're not affecting the newly inserted item here.
for (unsigned int i = insertIndex; i < desc->mItems.Size(); i++)
{
auto item = desc->mItems[i];
if (item->GetClass()->IsDescendantOf("ListMenuItemSelectable"))
auto litem = desc->mItems[i];
if (litem->GetClass()->IsDescendantOf("ListMenuItemSelectable"))
{
desc->mItems[i]->mYpos += desc->mLinespacing;
}
@ -660,9 +664,9 @@ static bool FindMatchingItem(DMenuItemBase *desc)
MenuDescriptorList::Pair *pair;
while (it.NextPair(pair))
{
for (auto it : pair->Value->mItems)
for (auto item : pair->Value->mItems)
{
if (it->mAction == name && GetGroup(it) == grp) return true;
if (item->mAction == name && GetGroup(item) == grp) return true;
}
}
return false;

View file

@ -151,8 +151,6 @@ int FSavegameManagerBase::InsertSaveNode(FSaveGameNode *node)
void FSavegameManagerBase::NotifyNewSave(const FString &file, const FString &title, bool okForQuicksave, bool forceQuicksave)
{
FSaveGameNode *node;
if (file.IsEmpty())
return;
@ -180,7 +178,7 @@ void FSavegameManagerBase::NotifyNewSave(const FString &file, const FString &tit
}
}
node = new FSaveGameNode;
auto node = new FSaveGameNode;
node->SaveTitle = title;
node->Filename = file;
node->bOldVersion = false;

View file

@ -6,7 +6,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
@ -98,7 +98,7 @@ static int FindGFXFile(FString & fn)
for (const char ** extp=extensions; *extp; extp++)
{
int lump = fileSystem.CheckNumForFullName(fn + *extp);
lump = fileSystem.CheckNumForFullName(fn + *extp);
if (lump >= best) best = lump;
}
return best;

View file

@ -48,7 +48,7 @@ protected:
unsigned int mNumIndices;
TArray<FModelVertex> mVertices;
TArray<unsigned int> mIndices;
void MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &check);
void AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int x4, int y4, int z4, uint8_t color, FVoxelMap &check);
unsigned int AddVertex(FModelVertex &vert, FVoxelMap &check);

View file

@ -6,7 +6,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
@ -217,10 +217,10 @@ void FDMDModel::LoadGeometry()
memcpy(lods[i].triangles, buffer + lodInfo[i].offsetTriangles, lodInfo[i].numTriangles * sizeof(FTriangle));
for (int j = 0; j < lodInfo[i].numTriangles; j++)
{
for (int k = 0; k < 3; k++)
for (int kk = 0; kk < 3; kk++)
{
lods[i].triangles[j].textureIndices[k] = LittleShort(lods[i].triangles[j].textureIndices[k]);
lods[i].triangles[j].vertexIndices[k] = LittleShort(lods[i].triangles[j].vertexIndices[k]);
lods[i].triangles[j].textureIndices[kk] = LittleShort(lods[i].triangles[j].textureIndices[kk]);
lods[i].triangles[j].vertexIndices[kk] = LittleShort(lods[i].triangles[j].vertexIndices[kk]);
}
}
}
@ -306,7 +306,7 @@ void FDMDModel::BuildVertexBuffer(FModelRenderer *renderer)
FTriangle *tri = lods[0].triangles;
for (int i = 0; i < lodInfo[0].numTriangles; i++)
for (int ii = 0; ii < lodInfo[0].numTriangles; ii++)
{
for (int j = 0; j < 3; j++)
{
@ -536,15 +536,15 @@ void FMD2Model::LoadGeometry()
}
lods[0].triangles = new FTriangle[lodInfo[0].numTriangles];
int cnt = lodInfo[0].numTriangles;
memcpy(lods[0].triangles, buffer + lodInfo[0].offsetTriangles, sizeof(FTriangle) * cnt);
for (int j = 0; j < cnt; j++)
{
for (int k = 0; k < 3; k++)
for (int kk = 0; kk < 3; kk++)
{
lods[0].triangles[j].textureIndices[k] = LittleShort(lods[0].triangles[j].textureIndices[k]);
lods[0].triangles[j].vertexIndices[k] = LittleShort(lods[0].triangles[j].vertexIndices[k]);
lods[0].triangles[j].textureIndices[kk] = LittleShort(lods[0].triangles[j].textureIndices[kk]);
lods[0].triangles[j].vertexIndices[kk] = LittleShort(lods[0].triangles[j].vertexIndices[kk]);
}
}
}

View file

@ -6,7 +6,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
@ -133,7 +133,7 @@ bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int le
auto numFrames = LittleLong(hdr->Num_Frames);
auto numSurfaces = LittleLong(hdr->Num_Surfaces);
numTags = LittleLong(hdr->Num_Tags);
md3_frame_t * frm = (md3_frame_t*)(buffer + LittleLong(hdr->Ofs_Frames));
@ -141,7 +141,7 @@ bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int le
Frames.Resize(numFrames);
for (unsigned i = 0; i < numFrames; i++)
{
strncpy(Frames[i].Name, frm[i].Name, 16);
strncpy(Frames[i].Name, frm[i].Name, 15);
for (int j = 0; j < 3; j++) Frames[i].origin[j] = frm[i].localorigin[j];
}
@ -164,15 +164,15 @@ bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int le
md3_shader_t * shader = (md3_shader_t*)(((char*)ss) + LittleLong(ss->Ofs_Shaders));
s->Skins.Resize(s->numSkins);
for (unsigned i = 0; i < s->numSkins; i++)
for (unsigned ii = 0; ii < s->numSkins; ii++)
{
// [BB] According to the MD3 spec, Name is supposed to include the full path.
// ... and since some tools seem to output backslashes, these need to be replaced with forward slashes to work.
FixPathSeperator(shader[i].Name);
s->Skins[i] = LoadSkin("", shader[i].Name);
FixPathSeperator(shader[ii].Name);
s->Skins[ii] = LoadSkin("", shader[ii].Name);
// [BB] Fall back and check if Name is relative.
if (!s->Skins[i].isValid())
s->Skins[i] = LoadSkin(path, shader[i].Name);
if (!s->Skins[ii].isValid())
s->Skins[ii] = LoadSkin(path, shader[ii].Name);
}
}
mLumpNum = lumpnum;
@ -203,31 +203,31 @@ void FMD3Model::LoadGeometry()
md3_triangle_t * tris = (md3_triangle_t*)(((char*)ss) + LittleLong(ss->Ofs_Triangles));
s->Tris.Resize(s->numTriangles);
for (unsigned i = 0; i < s->numTriangles; i++) for (int j = 0; j < 3; j++)
for (unsigned ii = 0; ii < s->numTriangles; ii++) for (int j = 0; j < 3; j++)
{
s->Tris[i].VertIndex[j] = LittleLong(tris[i].vt_index[j]);
s->Tris[ii].VertIndex[j] = LittleLong(tris[ii].vt_index[j]);
}
// Load texture coordinates
md3_texcoord_t * tc = (md3_texcoord_t*)(((char*)ss) + LittleLong(ss->Ofs_Texcoord));
s->Texcoords.Resize(s->numVertices);
for (unsigned i = 0; i < s->numVertices; i++)
for (unsigned ii = 0; ii < s->numVertices; ii++)
{
s->Texcoords[i].s = tc[i].s;
s->Texcoords[i].t = tc[i].t;
s->Texcoords[ii].s = tc[ii].s;
s->Texcoords[ii].t = tc[ii].t;
}
// Load vertices and texture coordinates
md3_vertex_t * vt = (md3_vertex_t*)(((char*)ss) + LittleLong(ss->Ofs_XYZNormal));
s->Vertices.Resize(s->numVertices * Frames.Size());
for (unsigned i = 0; i < s->numVertices * Frames.Size(); i++)
for (unsigned ii = 0; ii < s->numVertices * Frames.Size(); ii++)
{
s->Vertices[i].x = LittleShort(vt[i].x) / 64.f;
s->Vertices[i].y = LittleShort(vt[i].y) / 64.f;
s->Vertices[i].z = LittleShort(vt[i].z) / 64.f;
UnpackVector(LittleShort(vt[i].n), s->Vertices[i].nx, s->Vertices[i].ny, s->Vertices[i].nz);
s->Vertices[ii].x = LittleShort(vt[ii].x) / 64.f;
s->Vertices[ii].y = LittleShort(vt[ii].y) / 64.f;
s->Vertices[ii].z = LittleShort(vt[ii].z) / 64.f;
UnpackVector(LittleShort(vt[ii].n), s->Vertices[ii].nx, s->Vertices[ii].ny, s->Vertices[ii].nz);
}
}
}

View file

@ -1,21 +1,25 @@
//
//---------------------------------------------------------------------------
//
// Copyright(C) 2018 Marisa Kirisame
// All rights reserved.
// Copyright (c) 2018-2022 Marisa Kirisame, UnSX Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//--------------------------------------------------------------------------
//

View file

@ -6,7 +6,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
@ -100,7 +100,7 @@ TArray<uint8_t> FVoxelTexture::CreatePalettedPixels(int conversion)
pe.b = (pp[2] << 2) | (pp[2] >> 4);
// Alphatexture handling is just for completeness, but rather unlikely to be used ever.
Pixels[i] = conversion == luminance ? pe.r : ColorMatcher.Pick(pe);
}
}
else
@ -205,7 +205,6 @@ void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3
float PivotX = mVoxel->Mips[0].Pivot.X;
float PivotY = mVoxel->Mips[0].Pivot.Y;
float PivotZ = mVoxel->Mips[0].Pivot.Z;
int h = mVoxel->Mips[0].SizeZ;
FModelVertex vert;
unsigned int indx[4];
@ -286,8 +285,8 @@ void FVoxelModel::MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &chec
}
if (cull & 32)
{
int z = ztop+zleng-1;
AddFace(x+1, y, z+1, x, y, z+1, x+1, y+1, z+1, x, y+1, z+1, voxptr->col[zleng-1], check);
int zz = ztop+zleng-1;
AddFace(x+1, y, zz+1, x, y, zz+1, x+1, y+1, zz+1, x, y+1, zz+1, voxptr->col[zleng-1], check);
}
}

View file

@ -229,7 +229,6 @@ DObject::DObject ()
ObjNext = GC::Root;
GCNext = nullptr;
GC::Root = this;
GC::AllocCount++;
}
DObject::DObject (PClass *inClass)
@ -239,7 +238,6 @@ DObject::DObject (PClass *inClass)
ObjNext = GC::Root;
GCNext = nullptr;
GC::Root = this;
GC::AllocCount++;
}
//==========================================================================
@ -267,7 +265,7 @@ DObject::~DObject ()
Release();
}
}
if (nullptr != type)
{
type->DestroySpecials(this);
@ -277,7 +275,6 @@ DObject::~DObject ()
void DObject::Release()
{
if (GC::AllocCount > 0) GC::AllocCount--;
DObject **probe;
// Unlink this object from the GC list.

View file

@ -3,7 +3,7 @@
** The garbage collector. Based largely on Lua's.
**
**---------------------------------------------------------------------------
** Copyright 2008 Randy Heit
** Copyright 2008-2022 Marisa Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
@ -82,13 +82,19 @@
** infinity, where each step performs a full collection.) You can also
** change this value dynamically.
*/
#define DEFAULT_GCMUL 400 // GC runs 'quadruple the speed' of memory allocation
#define DEFAULT_GCMUL 200 // GC runs 'double the speed' of memory allocation
// Number of sectors to mark for each step.
// Minimum step size
#define GCSTEPSIZE (sizeof(DObject) * 16)
#define GCSTEPSIZE 1024u
// Maximum number of elements to sweep in a single step
#define GCSWEEPMAX 40
#define GCSWEEPCOST 10
// Cost of sweeping one element (the size of a small object divided by
// some adjust for the sweep speed)
#define GCSWEEPCOST (sizeof(DObject) / 4)
// Cost of calling of one destructor
#define GCFINALIZECOST 100
// TYPES -------------------------------------------------------------------
@ -99,6 +105,8 @@
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static size_t CalcStepSize();
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
// PUBLIC DATA DEFINITIONS -------------------------------------------------
@ -108,7 +116,6 @@ namespace GC
size_t AllocBytes;
size_t Threshold;
size_t Estimate;
size_t AllocCount;
DObject *Gray;
DObject *Root;
DObject *SoftRoots;
@ -118,11 +125,15 @@ EGCState State = GCS_Pause;
int Pause = DEFAULT_GCPAUSE;
int StepMul = DEFAULT_GCMUL;
int StepCount;
size_t Dept;
uint64_t CheckTime;
bool FinalGC;
// PRIVATE DATA DEFINITIONS ------------------------------------------------
static int LastCollectTime; // Time last time collector finished
static size_t LastCollectAlloc; // Memory allocation when collector finished
static size_t MinStepSize; // Cover at least this much memory per step
// CODE --------------------------------------------------------------------
//==========================================================================
@ -161,8 +172,8 @@ size_t PropagateMark()
//
// SweepList
//
// Runs a limited sweep on a list, returning the location where to resume
// the sweep at next time. (FIXME: Horrible Engrish in this description.)
// Runs a limited sweep on a list, returning the position in the list just
// after the last object swept.
//
//==========================================================================
@ -254,6 +265,26 @@ void MarkArray(DObject **obj, size_t count)
}
}
//==========================================================================
//
// CalcStepSize
//
// Decide how big a step should be based, depending on how long it took to
// allocate up to the threshold from the amount left after the previous
// collection.
//
//==========================================================================
static size_t CalcStepSize()
{
int time_passed = CheckTime - LastCollectTime;
auto alloc = min(LastCollectAlloc, Estimate);
size_t bytes_gained = AllocBytes > alloc ? AllocBytes - alloc : 0;
return (StepMul > 0 && time_passed > 0)
? std::max<size_t>(GCSTEPSIZE, bytes_gained / time_passed * StepMul / 100)
: std::numeric_limits<size_t>::max() / 2; // no limit
}
//==========================================================================
//
// MarkRoot
@ -310,6 +341,10 @@ static void Atomic()
SweepPos = &Root;
State = GCS_Sweep;
Estimate = AllocBytes;
// Now that we are about to start a sweep, establish a baseline minimum
// step size for how much memory we want to sweep each CheckGC().
MinStepSize = CalcStepSize();
}
//==========================================================================
@ -354,7 +389,8 @@ static size_t SingleStep()
case GCS_Finalize:
State = GCS_Pause; // end collection
Dept = 0;
LastCollectAlloc = AllocBytes;
LastCollectTime = CheckTime;
return 0;
default:
@ -374,29 +410,26 @@ static size_t SingleStep()
void Step()
{
size_t lim = (GCSTEPSIZE/100) * StepMul;
size_t olim;
if (lim == 0)
{
lim = (~(size_t)0) / 2; // no limit
}
Dept += AllocBytes - Threshold;
// We recalculate a step size in case the rate of allocation went up
// since we started sweeping because we don't want to fall behind.
// However, we also don't want to go slower than what was decided upon
// when the sweep began if the rate of allocation has slowed.
size_t lim = max(CalcStepSize(), MinStepSize);
do
{
olim = lim;
lim -= SingleStep();
} while (olim > lim && State != GCS_Pause);
if (State != GCS_Pause)
{
if (Dept < GCSTEPSIZE)
size_t done = SingleStep();
if (done < lim)
{
Threshold = AllocBytes + GCSTEPSIZE; // - lim/StepMul
lim -= done;
}
else
{
Dept -= GCSTEPSIZE;
Threshold = AllocBytes;
lim = 0;
}
} while (lim && State != GCS_Pause);
if (State != GCS_Pause)
{
Threshold = AllocBytes;
}
else
{
@ -571,16 +604,13 @@ ADD_STAT(gc)
" Sweep ",
"Finalize " };
FString out;
out.Format("[%s] Alloc:%6zuK Thresh:%6zuK Est:%6zuK Steps: %d",
out.Format("[%s] Alloc:%6zuK Thresh:%6zuK Est:%6zuK Steps: %d %zuK",
StateStrings[GC::State],
(GC::AllocBytes + 1023) >> 10,
(GC::Threshold + 1023) >> 10,
(GC::Estimate + 1023) >> 10,
GC::StepCount);
if (GC::State != GC::GCS_Pause)
{
out.AppendFormat(" %zuK", (GC::Dept + 1023) >> 10);
}
GC::StepCount,
(GC::MinStepSize + 1023) >> 10);
return out;
}

View file

@ -43,9 +43,6 @@ namespace GC
// Number of bytes currently allocated through M_Malloc/M_Realloc.
extern size_t AllocBytes;
// Number of allocated objects since last CheckGC call.
extern size_t AllocCount;
// Amount of memory to allocate before triggering a collection.
extern size_t Threshold;
@ -73,6 +70,9 @@ namespace GC
// Is this the final collection just before exit?
extern bool FinalGC;
// Counts the number of times CheckGC has been called.
extern uint64_t CheckTime;
// Current white value for known-dead objects.
static inline uint32_t OtherWhite()
{
@ -108,15 +108,11 @@ namespace GC
}
// Check if it's time to collect, and do a collection step if it is.
static inline bool CheckGC()
static inline void CheckGC()
{
AllocCount = 0;
CheckTime++;
if (AllocBytes >= Threshold)
{
Step();
return true;
}
return false;
}
// Forces a collection to start now.
@ -158,6 +154,10 @@ namespace GC
{
MarkArray((DObject **)(obj), count);
}
template<class T> void MarkArray(TObjPtr<T>* obj, size_t count)
{
MarkArray((DObject**)(obj), count);
}
template<class T> void MarkArray(TArray<T> &arr)
{
MarkArray(&arr[0], arr.Size());

View file

@ -429,7 +429,7 @@ void ProcessKeyboardEventInMenu(NSEvent* theEvent)
event.subtype = EV_GUI_Char;
event.data1 = realchar;
event.data2 = event.data3 & GKM_ALT;
D_PostEvent(&event);
}
}
@ -667,9 +667,9 @@ void ProcessMouseWheelEvent(NSEvent* theEvent)
{
return;
}
event_t event = {};
if (GUICapture)
{
event.type = EV_GUI_Event;
@ -681,7 +681,7 @@ void ProcessMouseWheelEvent(NSEvent* theEvent)
event.type = isZeroDelta ? EV_KeyUp : EV_KeyDown;
event.data1 = delta > 0.0f ? KEY_MWHEELUP : KEY_MWHEELDOWN;
}
D_PostEvent(&event);
}

View file

@ -1127,7 +1127,7 @@ void IOKitJoystickManager::AddDevices(const IONotificationPortRef notificationPo
}
IOObjectRelease(device);
PostDeviceChangeEvent();
}
}

View file

@ -90,10 +90,10 @@ static bool ReadSystemVersionFromPlist(NSOperatingSystemVersion& version)
if (stat(plistPath, &dummy) != 0)
return false;
char commandLine[1024] = {};
snprintf(commandLine, sizeof commandLine, "defaults read %s ProductVersion", plistPath);
FILE *const versionFile = popen(commandLine, "r");
if (versionFile == nullptr)
@ -146,7 +146,7 @@ void I_DetectOS()
}
const char* name = "Unknown version";
switch (version.majorVersion)
{
case 10:
@ -183,7 +183,7 @@ void I_DetectOS()
#else
"Unknown";
#endif
Printf("%s running %s %d.%d.%d (%s) %s\n", model, name,
int(version.majorVersion), int(version.minorVersion), int(version.patchVersion),
release, architecture);
@ -266,14 +266,14 @@ ApplicationController* appCtrl;
- (void)keyDown:(NSEvent*)theEvent
{
// Empty but present to avoid playing of 'beep' alert sound
ZD_UNUSED(theEvent);
}
- (void)keyUp:(NSEvent*)theEvent
{
// Empty but present to avoid playing of 'beep' alert sound
ZD_UNUSED(theEvent);
}
@ -283,7 +283,7 @@ extern bool AppActive;
- (void)applicationDidBecomeActive:(NSNotification*)aNotification
{
ZD_UNUSED(aNotification);
S_SetSoundPaused(1);
AppActive = true;
@ -292,7 +292,7 @@ extern bool AppActive;
- (void)applicationWillResignActive:(NSNotification*)aNotification
{
ZD_UNUSED(aNotification);
S_SetSoundPaused(i_soundinbackground);
AppActive = false;

View file

@ -449,7 +449,7 @@ public:
}
else
#endif
#ifdef HAVE_SOFTPOLY
if (vid_preferbackend == 2)
{
@ -832,7 +832,7 @@ bool I_SetCursor(FGameTexture *cursorpic)
if (NULL != cursorpic && cursorpic->isValid())
{
// Create bitmap image representation
auto sbuffer = cursorpic->GetTexture()->CreateTexBuffer(0);
const NSInteger imageWidth = sbuffer.mWidth;
@ -873,11 +873,11 @@ bool I_SetCursor(FGameTexture *cursorpic)
cursor = [[NSCursor alloc] initWithImage:cursorImage
hotSpot:NSMakePoint(0.0f, 0.0f)];
}
SystemBaseFrameBuffer::SetCursor(cursor);
[pool release];
return true;
}

View file

@ -256,7 +256,7 @@ FString M_GetDocumentsPath()
FString M_GetDemoPath()
{
FString path = GetSpecialPath(NSDocumentDirectory);
if (path.IsNotEmpty())
{
path += "/" GAME_DIR "/Demos/";

View file

@ -446,7 +446,7 @@ int I_PickIWad_Cocoa (WadStuff *wads, int numwads, bool showwin, int defaultiwad
if (ret >= 0)
{
NSString* parametersToAppend = [picker commandLineParameters];
if (0 != [parametersToAppend length])
{
RestartWithParameters(wads[ret], parametersToAppend);

View file

@ -67,6 +67,7 @@ void I_InitGraphics ()
#ifdef __APPLE__
SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "0");
#endif // __APPLE__
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0)
{
@ -78,7 +79,7 @@ void I_InitGraphics ()
extern IVideo *gl_CreateVideo();
Video = gl_CreateVideo();
if (Video == NULL)
I_FatalError ("Failed to initialize display");
}

View file

@ -205,7 +205,7 @@ static void MouseRead ()
static void I_CheckNativeMouse ()
{
bool focus = SDL_GetKeyboardFocus() != NULL;
bool captureModeInGame = sysCallbacks.CaptureModeInGame && sysCallbacks.CaptureModeInGame();
bool wantNative = !focus || (!use_mouse || GUICapture || !captureModeInGame);
@ -228,7 +228,7 @@ void MessagePump (const SDL_Event &sev)
static int lastx = 0, lasty = 0;
int x, y;
event_t event = { 0,0,0,0,0,0,0 };
switch (sev.type)
{
case SDL_QUIT:
@ -369,7 +369,7 @@ void MessagePump (const SDL_Event &sev)
{
break;
}
event.type = sev.type == SDL_KEYDOWN ? EV_KeyDown : EV_KeyUp;
// Try to look up our key mapped key for conversion to DirectInput.
@ -448,7 +448,7 @@ void MessagePump (const SDL_Event &sev)
if (GUICapture)
{
int size;
int unichar = utf8_decode((const uint8_t*)sev.text.text, &size);
if (size != 4)
{
@ -474,7 +474,7 @@ void MessagePump (const SDL_Event &sev)
void I_GetEvent ()
{
SDL_Event sev;
while (SDL_PollEvent (&sev))
{
MessagePump (sev);

View file

@ -171,7 +171,7 @@ int main (int argc, char **argv)
}
printf("\n");
Args = new FArgs(argc, argv);
// Should we even be doing anything with progdir on Unix systems?
@ -188,7 +188,7 @@ int main (int argc, char **argv)
{
progdir = "./";
}
I_StartupJoysticks();
const int result = GameMain();

View file

@ -159,7 +159,7 @@ void RedrawProgressBar(int CurPos, int MaxPos)
memset(progressBuffer,'.',512);
progressBuffer[sizeOfWindow.ws_col - 1] = 0;
int lengthOfStr = 0;
while (curProgVal-- > 0)
{
progressBuffer[lengthOfStr++] = '=';
@ -182,7 +182,9 @@ void I_PrintStr(const char *cp)
if (*srcp == 0x1c && con_printansi && terminal)
{
srcp += 1;
EColorRange range = V_ParseFontColor((const uint8_t*&)srcp, CR_UNTRANSLATED, CR_YELLOW);
const uint8_t* scratch = (const uint8_t*)srcp; // GCC does not like direct casting of the parameter.
EColorRange range = V_ParseFontColor(scratch, CR_UNTRANSLATED, CR_YELLOW);
srcp = (char*)scratch;
if (range != CR_UNDEFINED)
{
PalEntry color = V_LogColorFromColorRange(range);
@ -206,7 +208,7 @@ void I_PrintStr(const char *cp)
else if (v < 0.90) attrib = 0x7;
else attrib = 0xF;
}
printData.AppendFormat("\033[%um",((attrib & 0x8) ? 90 : 30) + (attrib & 0x7));
}
else printData.AppendFormat("\033[38;2;%u;%u;%um",color.r,color.g,color.b);
@ -222,7 +224,7 @@ void I_PrintStr(const char *cp)
else break;
}
}
if (StartScreen) CleanProgressBar();
fputs(printData.GetChars(),stdout);
if (terminal) fputs("\033[0m",stdout);
@ -301,7 +303,7 @@ int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
#ifdef __APPLE__
return I_PickIWad_Cocoa (wads, numwads, showwin, defaultiwad);
#endif
if (!isatty(fileno(stdin)))
{
return defaultiwad;

View file

@ -5,13 +5,13 @@ void Mac_I_FatalError(const char* errortext)
{
// Close window or exit fullscreen and release mouse capture
SDL_Quit();
const CFStringRef errorString = CFStringCreateWithCStringNoCopy( kCFAllocatorDefault,
errortext, kCFStringEncodingASCII, kCFAllocatorNull );
if ( NULL != errorString )
{
CFOptionFlags dummy;
CFUserNotificationDisplayAlert( 0, kCFUserNotificationStopAlertLevel, NULL, NULL, NULL,
CFSTR( "Fatal Error" ), errorString, CFSTR( "Exit" ), NULL, NULL, &dummy );
CFRelease( errorString );

View file

@ -53,7 +53,7 @@
#ifdef HAVE_GLES2
#include "gles_framebuffer.h"
#endif
#ifdef HAVE_VULKAN
#include "vulkan/system/vk_framebuffer.h"
#endif
@ -517,7 +517,7 @@ int SystemBaseFrameBuffer::GetClientWidth()
return width;
}
#endif
#ifdef HAVE_VULKAN
assert(Priv::vulkanEnabled);
SDL_Vulkan_GetDrawableSize(Priv::window, &width, nullptr);

View file

@ -228,7 +228,7 @@ void FTTYStartupScreen::NetMessage(const char *format, ...)
{
FString str;
va_list argptr;
va_start (argptr, format);
str.VFormat (format, argptr);
va_end (argptr);

View file

@ -279,7 +279,7 @@ void SystemBaseFrameBuffer::PositionWindow(bool fullscreen, bool initialcall)
RECT r;
LONG style, exStyle;
RECT monRect;
RECT monRect = {};
if (!m_Fullscreen && fullscreen && !initialcall) SaveWindowedPos();
if (m_Monitor)

View file

@ -165,5 +165,5 @@ void I_InitGraphics ()
// we somehow STILL don't have a display!!
if (Video == NULL)
I_FatalError ("Failed to initialize display");
}

View file

@ -340,7 +340,7 @@ static HANDLE WriteMyMiniDump (void)
MINIDUMP_EXCEPTION_INFORMATION exceptor = { DbgThreadID, &CrashPointers, FALSE };
WCHAR dbghelpPath[MAX_PATH+12], *bs;
WRITEDUMP pMiniDumpWriteDump;
HANDLE file;
HANDLE file = INVALID_HANDLE_VALUE;
BOOL good = FALSE;
HMODULE dbghelp = NULL;
@ -710,14 +710,14 @@ HANDLE WriteTextReport ()
ctxt->Rip, ctxt->Rsp, ctxt->SegCs, ctxt->SegSs, ctxt->EFlags);
#endif
DWORD j;
DWORD dw;
for (i = 0, j = 1; (size_t)i < sizeof(eflagsBits)/sizeof(eflagsBits[0]); j <<= 1, ++i)
for (i = 0, dw = 1; (size_t)i < sizeof(eflagsBits)/sizeof(eflagsBits[0]); dw <<= 1, ++i)
{
if (eflagsBits[i][0] != 'x')
{
Writef (file, " %c%c%c", eflagsBits[i][0], eflagsBits[i][1],
ctxt->EFlags & j ? '+' : '-');
ctxt->EFlags & dw ? '+' : '-');
}
}
Writef (file, "\r\n");
@ -1581,7 +1581,7 @@ static void AddZipFile (HANDLE ziphandle, TarFile *whichfile, short dosdate, sho
local.ModDate = dosdate;
local.UncompressedSize = LittleLong(whichfile->UncompressedSize);
local.NameLength = LittleShort((uint16_t)strlen(whichfile->Filename));
whichfile->ZipOffset = SetFilePointer (ziphandle, 0, NULL, FILE_CURRENT);
WriteFile (ziphandle, &local, sizeof(local), &wrote, NULL);
WriteFile (ziphandle, whichfile->Filename, (DWORD)strlen(whichfile->Filename), &wrote, NULL);

View file

@ -281,14 +281,6 @@ CUSTOM_CVAR(Bool, joy_dinput, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_NOINITCA
static const uint8_t POVButtons[9] = { 0x01, 0x03, 0x02, 0x06, 0x04, 0x0C, 0x08, 0x09, 0x00 };
//("dc12a687-737f-11cf-884d-00aa004b2e24")
static const IID IID_IWbemLocator = { 0xdc12a687, 0x737f, 0x11cf,
{ 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24 } };
//("4590f811-1d3a-11d0-891f-00aa004b2e24")
static const CLSID CLSID_WbemLocator = { 0x4590f811, 0x1d3a, 0x11d0,
{ 0x89, 0x1f, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24 } };
// CODE --------------------------------------------------------------------
//===========================================================================

View file

@ -514,8 +514,6 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_WTSSESSION_CHANGE:
case WM_POWERBROADCAST:
{
int oldstate = SessionState;
if (message == WM_WTSSESSION_CHANGE && lParam == (LPARAM)SessionID)
{
#ifdef _DEBUG

View file

@ -58,7 +58,7 @@ class FDInputKeyboard : public FKeyboard
public:
FDInputKeyboard();
~FDInputKeyboard();
bool GetDevice();
void ProcessInput();

View file

@ -777,7 +777,7 @@ int DoMain (HINSTANCE hInstance)
RECT cRect;
TIMECAPS tc;
DEVMODE displaysettings;
// Do not use the multibyte __argv here because we want UTF-8 arguments
// and those can only be done by converting the Unicode variants.
Args = new FArgs();
@ -787,17 +787,17 @@ int DoMain (HINSTANCE hInstance)
{
Args->AppendArg(FString(wargv[i]));
}
// Load Win32 modules
Kernel32Module.Load({"kernel32.dll"});
Shell32Module.Load({"shell32.dll"});
User32Module.Load({"user32.dll"});
// Under XP, get our session ID so we can know when the user changes/locks sessions.
// Since we need to remain binary compatible with older versions of Windows, we
// need to extract the ProcessIdToSessionId function from kernel32.dll manually.
HMODULE kernel = GetModuleHandleA ("kernel32.dll");
if (Args->CheckParm("-stdout"))
{
// As a GUI application, we don't normally get a console when we start.
@ -805,7 +805,7 @@ int DoMain (HINSTANCE hInstance)
// console. Otherwise, we can create a new one. If we already have a
// stdout handle, then we have been redirected and should just use that
// handle instead of creating a console window.
StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (StdOut != NULL)
{
@ -832,18 +832,18 @@ int DoMain (HINSTANCE hInstance)
{
StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
}
// These two functions do not exist in Windows XP.
BOOL (WINAPI* p_GetCurrentConsoleFontEx)(HANDLE hConsoleOutput, BOOL bMaximumWindow, PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx);
BOOL (WINAPI* p_SetCurrentConsoleFontEx)(HANDLE hConsoleOutput, BOOL bMaximumWindow, PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx);
p_SetCurrentConsoleFontEx = (decltype(p_SetCurrentConsoleFontEx))GetProcAddress(kernel, "SetCurrentConsoleFontEx");
p_GetCurrentConsoleFontEx = (decltype(p_GetCurrentConsoleFontEx))GetProcAddress(kernel, "GetCurrentConsoleFontEx");
if (p_SetCurrentConsoleFontEx && p_GetCurrentConsoleFontEx)
{
CONSOLE_FONT_INFOEX cfi;
cfi.cbSize = sizeof(cfi);
if (p_GetCurrentConsoleFontEx(StdOut, false, &cfi))
{
if (*cfi.FaceName == 0) // If the face name is empty, the default (useless) raster font is actoive.
@ -858,16 +858,16 @@ int DoMain (HINSTANCE hInstance)
FancyStdOut = true;
}
}
// Set the timer to be as accurate as possible
if (timeGetDevCaps (&tc, sizeof(tc)) != TIMERR_NOERROR)
TimerPeriod = 1; // Assume minimum resolution of 1 ms
else
TimerPeriod = tc.wPeriodMin;
timeBeginPeriod (TimerPeriod);
atexit(UnTbp);
// Figure out what directory the program resides in.
WCHAR progbuff[1024];
if (GetModuleFileNameW(nullptr, progbuff, sizeof progbuff) == 0)
@ -875,22 +875,22 @@ int DoMain (HINSTANCE hInstance)
MessageBoxA(nullptr, "Fatal", "Could not determine program location.", MB_ICONEXCLAMATION|MB_OK);
exit(-1);
}
progbuff[1023] = '\0';
if (auto lastsep = wcsrchr(progbuff, '\\'))
{
lastsep[1] = '\0';
}
progdir = progbuff;
FixPathSeperator(progdir);
HDC screenDC = GetDC(0);
int dpi = GetDeviceCaps(screenDC, LOGPIXELSX);
ReleaseDC(0, screenDC);
width = (512 * dpi + 96 / 2) / 96;
height = (384 * dpi + 96 / 2) / 96;
// Many Windows structures that specify their size do so with the first
// element. DEVMODE is not one of those structures.
memset (&displaysettings, 0, sizeof(displaysettings));
@ -898,12 +898,12 @@ int DoMain (HINSTANCE hInstance)
EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &displaysettings);
x = (displaysettings.dmPelsWidth - width) / 2;
y = (displaysettings.dmPelsHeight - height) / 2;
if (Args->CheckParm ("-0"))
{
x = y = 0;
}
WNDCLASS WndClass;
WndClass.style = 0;
WndClass.lpfnWndProc = LConProc;
@ -915,14 +915,14 @@ int DoMain (HINSTANCE hInstance)
WndClass.hbrBackground = NULL;
WndClass.lpszMenuName = NULL;
WndClass.lpszClassName = WinClassName;
/* register this new class with Windows */
if (!RegisterClass((LPWNDCLASS)&WndClass))
{
MessageBoxA(nullptr, "Could not register window class", "Fatal", MB_ICONEXCLAMATION|MB_OK);
exit(-1);
}
/* create window */
FStringf caption("" GAMENAME " %s " X64 " (%s)", GetVersionString(), GetGitTime());
std::wstring wcaption = caption.WideString();
@ -936,13 +936,13 @@ int DoMain (HINSTANCE hInstance)
(HMENU) NULL,
hInstance,
NULL);
if (!Window)
{
MessageBoxA(nullptr, "Unable to create main window", "Fatal", MB_ICONEXCLAMATION|MB_OK);
exit(-1);
}
if (kernel != NULL)
{
typedef BOOL (WINAPI *pts)(DWORD, DWORD *);
@ -969,15 +969,15 @@ int DoMain (HINSTANCE hInstance)
}
}
}
GetClientRect (Window, &cRect);
WinWidth = cRect.right;
WinHeight = cRect.bottom;
CoInitialize (NULL);
atexit (UnCOM);
int ret = GameMain ();
CheckForRestart();
@ -990,7 +990,7 @@ int DoMain (HINSTANCE hInstance)
{ // Outputting to a new console window: Wait for a keypress before quitting.
DWORD bytes;
HANDLE stdinput = GetStdHandle(STD_INPUT_HANDLE);
ShowWindow(Window, SW_HIDE);
WriteFile(StdOut, "Press any key to exit...", 24, &bytes, NULL);
FlushConsoleInputBuffer(stdinput);
@ -1017,7 +1017,7 @@ void I_ShowFatalError(const char *msg)
{
Printf("%s", CVMAbortException::stacktrace.GetChars());
}
if (!batchrun)
{
ShowErrorPane(msg);

View file

@ -86,7 +86,7 @@ class FDInputMouse : public FMouse
public:
FDInputMouse();
~FDInputMouse();
bool GetDevice();
void ProcessInput();
bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
@ -103,7 +103,7 @@ class FWin32Mouse : public FMouse
public:
FWin32Mouse();
~FWin32Mouse();
bool GetDevice();
void ProcessInput();
bool WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
@ -268,7 +268,6 @@ void I_CheckNativeMouse(bool preferNative, bool eventhandlerresult)
}
else
{
bool pauseState = false;
bool captureModeInGame = sysCallbacks.CaptureModeInGame && sysCallbacks.CaptureModeInGame();
want_native = ((!m_use_mouse || menuactive != MENU_WaitKey) &&
(!captureModeInGame || GUICapture));
@ -698,7 +697,7 @@ bool FDInputMouse::GetDevice()
{
return false;
}
// How many buttons does this mouse have?
DIDEVCAPS_DX3 caps = { sizeof(caps) };
hr = Device->GetCapabilities((DIDEVCAPS *)&caps);

View file

@ -503,7 +503,7 @@ bool FRawPS2Controller::ProcessInput(RAWHID *raw, int code)
// Generate events for buttons that have changed.
int buttons = 0;
// If we know we are digital, ignore the D-Pad.
if (!digital)
{
@ -538,7 +538,7 @@ void FRawPS2Controller::ProcessThumbstick(int value1, AxisInfo *axis1, int value
{
uint8_t buttonstate;
double axisval1, axisval2;
axisval1 = value1 * (2.0 / 255) - 1.0;
axisval2 = value2 * (2.0 / 255) - 1.0;
axisval1 = Joy_RemoveDeadZone(axisval1, axis1->DeadZone, NULL);

View file

@ -288,8 +288,8 @@ static void DoPrintStr(const char *cpt, HWND edit, HANDLE StdOut)
wchar_t wbuf[256];
int bpos = 0;
CHARRANGE selection;
CHARRANGE endselection;
CHARRANGE selection = {};
CHARRANGE endselection = {};
LONG lines_before = 0, lines_after;
CHARFORMAT format;
@ -868,7 +868,7 @@ static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP
// Delete the bitmaps.
DeleteObject(and_mask);
DeleteObject(color_mask);
return cursor;
}

View file

@ -310,7 +310,7 @@ void FXInputController::ProcessThumbstick(int value1, AxisInfo *axis1,
{
uint8_t buttonstate;
double axisval1, axisval2;
axisval1 = (value1 - SHRT_MIN) * 2.0 / 65536 - 1.0;
axisval2 = (value2 - SHRT_MIN) * 2.0 / 65536 - 1.0;
axisval1 = Joy_RemoveDeadZone(axisval1, axis1->DeadZone, NULL);
@ -337,7 +337,7 @@ void FXInputController::ProcessTrigger(int value, AxisInfo *axis, int base)
{
uint8_t buttonstate;
double axisval;
axisval = Joy_RemoveDeadZone(value / 256.0, axis->DeadZone, &buttonstate);
Joy_GenerateButtonEvents(axis->ButtonValue, buttonstate, 1, base);
axis->ButtonValue = buttonstate;

View file

@ -113,7 +113,7 @@ CUSTOM_CVAR(Int, showendoom, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
FStartupScreen *FStartupScreen::CreateInstance(int max_progress)
{
FStartupScreen *scr = NULL;
HRESULT hr;
HRESULT hr = -1;
if (!Args->CheckParm("-nostartup"))
{
@ -310,7 +310,7 @@ void FBasicStartupScreen::NetMessage(const char *format, ...)
{
FString str;
va_list argptr;
va_start (argptr, format);
str.VFormat (format, argptr);
va_end (argptr);

View file

@ -751,9 +751,9 @@ FStrifeStartupScreen::FStrifeStartupScreen(int max_progress, long& hr)
if (lumpnum >= 0 && (lumplen = fileSystem.FileLength(lumpnum)) == StrifeStartupPicSizes[i])
{
auto lumpr = fileSystem.OpenFileReader(lumpnum);
auto lumpr1 = fileSystem.OpenFileReader(lumpnum);
StartupPics[i] = new uint8_t[lumplen];
lumpr.Read(StartupPics[i], lumplen);
lumpr1.Read(StartupPics[i], lumplen);
}
}

View file

@ -423,8 +423,6 @@ bool Win32GLVideo::InitHardware(HWND Window, int multisample)
}
int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
const char *version = Args->CheckValue("-glversion");
for (; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++)
{

View file

@ -17,7 +17,7 @@ void I_GetVulkanDrawableSize(int *width, int *height)
RECT clientRect = { 0 };
GetClientRect(Window, &clientRect);
if (width != nullptr)
{
*width = clientRect.right;

View file

@ -21,7 +21,7 @@ public:
{
device = new VulkanDevice();
}
~Win32VulkanVideo()
{
delete device;

Some files were not shown because too many files have changed in this diff Show more