diff --git a/src/common/2d/v_2ddrawer.cpp b/src/common/2d/v_2ddrawer.cpp index 443acb293..69ab0d530 100644 --- a/src/common/2d/v_2ddrawer.cpp +++ b/src/common/2d/v_2ddrawer.cpp @@ -993,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; diff --git a/src/common/2d/v_2ddrawer.h b/src/common/2d/v_2ddrawer.h index ab87085f5..623559978 100644 --- a/src/common/2d/v_2ddrawer.h +++ b/src/common/2d/v_2ddrawer.h @@ -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); diff --git a/src/common/2d/v_draw.cpp b/src/common/2d/v_draw.cpp index a7d213cb4..1ff348bc7 100644 --- a/src/common/2d/v_draw.cpp +++ b/src/common/2d/v_draw.cpp @@ -857,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) diff --git a/src/common/2d/v_draw.h b/src/common/2d/v_draw.h index a0407179e..0d25d5999 100644 --- a/src/common/2d/v_draw.h +++ b/src/common/2d/v_draw.h @@ -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, diff --git a/src/common/audio/music/i_music.cpp b/src/common/audio/music/i_music.cpp index 26989992d..bc05d4da5 100644 --- a/src/common/audio/music/i_music.cpp +++ b/src/common/audio/music/i_music.cpp @@ -226,7 +226,7 @@ void I_InitMusic(void) nomusic = !!Args->CheckParm("-nomusic") || !!Args->CheckParm("-nosound"); snd_mididevice.Callback(); - + ZMusicCallbacks callbacks{}; callbacks.MessageFunc = zmusic_printfunc; diff --git a/src/common/audio/music/i_soundfont.cpp b/src/common/audio/music/i_soundfont.cpp index a8b4e9fdf..8d928a42c 100644 --- a/src/common/audio/music/i_soundfont.cpp +++ b/src/common/audio/music/i_soundfont.cpp @@ -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)) { diff --git a/src/common/audio/music/i_soundfont.h b/src/common/audio/music/i_soundfont.h index 9f07b8cc4..ef0295071 100644 --- a/src/common/audio/music/i_soundfont.h +++ b/src/common/audio/music/i_soundfont.h @@ -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 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 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 - + }; diff --git a/src/common/audio/music/music.cpp b/src/common/audio/music/music.cpp index d8766ae90..d125bf36d 100644 --- a/src/common/audio/music/music.cpp +++ b/src/common/audio/music/music.cpp @@ -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. diff --git a/src/common/audio/sound/i_sound.h b/src/common/audio/sound/i_sound.h index 060838edf..da11e9bde 100644 --- a/src/common/audio/sound/i_sound.h +++ b/src/common/audio/sound/i_sound.h @@ -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; diff --git a/src/common/audio/sound/oalsound.cpp b/src/common/audio/sound/oalsound.cpp index f3c46746d..240b4c8ab 100644 --- a/src/common/audio/sound/oalsound.cpp +++ b/src/common/audio/sound/oalsound.cpp @@ -1675,7 +1675,7 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener) const_cast(env)->Modified = false; } - + // NOTE: Moving into and out of water will undo pitch variations on sounds. if(listener->underwater || env->SoftwareWater) { @@ -1721,7 +1721,7 @@ void OpenALSoundRenderer::UpdateListener(SoundListener *listener) } else if(WasInWater) { - + WasInWater = false; if(EnvSlot != 0) diff --git a/src/common/audio/sound/s_sound.cpp b/src/common/audio/sound/s_sound.cpp index 5201891c0..74393dfdd 100644 --- a/src/common/audio/sound/s_sound.cpp +++ b/src/common/audio/sound/s_sound.cpp @@ -402,7 +402,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, { return nullptr; } - + sfx = &S_sfx[sound_id]; // Scale volume according to SNDINFO data. @@ -611,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 @@ -726,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++) @@ -830,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; diff --git a/src/common/audio/sound/s_soundinternal.h b/src/common/audio/sound/s_soundinternal.h index 13ca33e7a..f15c994dc 100644 --- a/src/common/audio/sound/s_soundinternal.h +++ b/src/common/audio/sound/s_soundinternal.h @@ -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: diff --git a/src/common/console/c_bind.cpp b/src/common/console/c_bind.cpp index 1bca5072c..d131cb6ed 100644 --- a/src/common/console/c_bind.cpp +++ b/src/common/console/c_bind.cpp @@ -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")) { diff --git a/src/common/console/c_buttons.cpp b/src/common/console/c_buttons.cpp index 860824ca5..3464553e3 100644 --- a/src/common/console/c_buttons.cpp +++ b/src/common/console/c_buttons.cpp @@ -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; } diff --git a/src/common/console/c_commandbuffer.cpp b/src/common/console/c_commandbuffer.cpp index b079d7f76..0c570da14 100644 --- a/src/common/console/c_commandbuffer.cpp +++ b/src/common/console/c_commandbuffer.cpp @@ -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; diff --git a/src/common/console/c_console.cpp b/src/common/console/c_console.cpp index 8d4f8b44a..483f9a378 100644 --- a/src/common/console/c_console.cpp +++ b/src/common/console/c_console.cpp @@ -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. diff --git a/src/common/console/c_consolebuffer.cpp b/src/common/console/c_consolebuffer.cpp index a75a0588c..ea6be80e2 100644 --- a/src/common/console/c_consolebuffer.cpp +++ b/src/common/console/c_consolebuffer.cpp @@ -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--; diff --git a/src/common/console/c_consolebuffer.h b/src/common/console/c_consolebuffer.h index 98a42b42e..58bc0edea 100644 --- a/src/common/console/c_consolebuffer.h +++ b/src/common/console/c_consolebuffer.h @@ -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); diff --git a/src/common/console/c_cvars.h b/src/common/console/c_cvars.h index abbe31a4b..7d5201a1d 100644 --- a/src/common/console/c_cvars.h +++ b/src/common/console/c_cvars.h @@ -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); }; diff --git a/src/common/console/c_dispatch.cpp b/src/common/console/c_dispatch.cpp index 76e0f19e2..7de13e2ea 100644 --- a/src/common/console/c_dispatch.cpp +++ b/src/common/console/c_dispatch.cpp @@ -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 diff --git a/src/common/console/c_expr.cpp b/src/common/console/c_expr.cpp index d203c8cd5..4a48439b7 100644 --- a/src/common/console/c_expr.cpp +++ b/src/common/console/c_expr.cpp @@ -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(prod)->Value)); M_Free (prod); return newprod; diff --git a/src/common/console/c_notifybufferbase.cpp b/src/common/console/c_notifybufferbase.cpp index e31a8f07c..11be81dd3 100644 --- a/src/common/console/c_notifybufferbase.cpp +++ b/src/common/console/c_notifybufferbase.cpp @@ -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) diff --git a/src/common/engine/cycler.cpp b/src/common/engine/cycler.cpp index 1d0d28486..1dbf1fce0 100644 --- a/src/common/engine/cycler.cpp +++ b/src/common/engine/cycler.cpp @@ -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.; diff --git a/src/common/engine/cycler.h b/src/common/engine/cycler.h index 0b49e644d..a2789f9ca 100644 --- a/src/common/engine/cycler.h +++ b/src/common/engine/cycler.h @@ -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; } diff --git a/src/common/engine/d_event.cpp b/src/common/engine/d_event.cpp index 7a51d054a..dd23c6e0d 100644 --- a/src/common/engine/d_event.cpp +++ b/src/common/engine/d_event.cpp @@ -138,7 +138,7 @@ void D_RemoveNextCharEvent() } } } - + //========================================================================== // diff --git a/src/common/engine/i_net.cpp b/src/common/engine/i_net.cpp index 40bedd562..cf5773b0c 100644 --- a/src/common/engine/i_net.cpp +++ b/src/common/engine/i_net.cpp @@ -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); @@ -892,7 +892,7 @@ bool JoinGame (int i) SendAbort(); return false; } - + StartScreen->NetMessage ("Total players: %d", doomcom.numnodes); doomcom.id = DOOMCOM_ID; diff --git a/src/common/engine/i_net.h b/src/common/engine/i_net.h index 87d720014..f608f662a 100644 --- a/src/common/engine/i_net.h +++ b/src/common/engine/i_net.h @@ -76,7 +76,7 @@ struct doomcom_t // packet data to be sent uint8_t data[MAX_MSGLEN]; - + }; extern doomcom_t doomcom; diff --git a/src/common/engine/m_joy.h b/src/common/engine/m_joy.h index 016aa78d6..fc99379b0 100644 --- a/src/common/engine/m_joy.h +++ b/src/common/engine/m_joy.h @@ -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; diff --git a/src/common/engine/sc_man.cpp b/src/common/engine/sc_man.cpp index 68bc8542d..bbc209b14 100644 --- a/src/common/engine/sc_man.cpp +++ b/src/common/engine/sc_man.cpp @@ -857,7 +857,7 @@ bool FScanner::CheckFloat (bool evaluate) UnGet(); return false; } - + Float = strtod (String, &stopper); if (*stopper != 0) { diff --git a/src/common/engine/sc_man.h b/src/common/engine/sc_man.h index 1caa177a2..a39b8f5c3 100644 --- a/src/common/engine/sc_man.h +++ b/src/common/engine/sc_man.h @@ -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); diff --git a/src/common/engine/sc_man_scanner.re b/src/common/engine/sc_man_scanner.re index b10f48081..145abea41 100644 --- a/src/common/engine/sc_man_scanner.re +++ b/src/common/engine/sc_man_scanner.re @@ -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); } diff --git a/src/common/engine/serializer.cpp b/src/common/engine/serializer.cpp index f123fb42d..f42289573 100644 --- a/src/common/engine/serializer.cpp +++ b/src/common/engine/serializer.cpp @@ -623,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. diff --git a/src/common/engine/serializer.h b/src/common/engine/serializer.h index 4797ca20d..b114923df 100644 --- a/src/common/engine/serializer.h +++ b/src/common/engine/serializer.h @@ -111,7 +111,7 @@ public: { return w != nullptr; } - + bool canSkip() const; template diff --git a/src/common/engine/serializer_internal.h b/src/common/engine/serializer_internal.h index e05d5785c..31cf76c1a 100644 --- a/src/common/engine/serializer_internal.h +++ b/src/common/engine/serializer_internal.h @@ -42,7 +42,7 @@ struct FWriter rapidjson::StringBuffer mOutString; TArray mDObjects; TMap 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) diff --git a/src/common/engine/st_start.h b/src/common/engine/st_start.h index 1456e051c..09eb6ae67 100644 --- a/src/common/engine/st_start.h +++ b/src/common/engine/st_start.h @@ -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; }; diff --git a/src/common/engine/stats.h b/src/common/engine/stats.h index 3e048ac16..735931cb5 100644 --- a/src/common/engine/stats.h +++ b/src/common/engine/stats.h @@ -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; diff --git a/src/common/engine/stringtable.cpp b/src/common/engine/stringtable.cpp index b36e6e409..92819c144 100644 --- a/src/common/engine/stringtable.cpp +++ b/src/common/engine/stringtable.cpp @@ -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); diff --git a/src/common/engine/stringtable.h b/src/common/engine/stringtable.h index 0467b27ed..d75864303 100644 --- a/src/common/engine/stringtable.h +++ b/src/common/engine/stringtable.h @@ -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> currentLanguageSet; - + void LoadLanguage (int lumpnum, const TArray &buffer); TArray> parseCSV(const TArray &buffer); bool ParseLanguageCSV(int lumpnum, const TArray &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); diff --git a/src/common/engine/v_colortables.cpp b/src/common/engine/v_colortables.cpp index 36849862b..b891ff142 100644 --- a/src/common/engine/v_colortables.cpp +++ b/src/common/engine/v_colortables.cpp @@ -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++) diff --git a/src/common/filesystem/file_directory.cpp b/src/common/filesystem/file_directory.cpp index 9d215784d..80b9f6e57 100644 --- a/src/common/filesystem/file_directory.cpp +++ b/src/common/filesystem/file_directory.cpp @@ -118,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))) { diff --git a/src/common/filesystem/file_grp.cpp b/src/common/filesystem/file_grp.cpp index 97f17f17f..7128c1307 100644 --- a/src/common/filesystem/file_grp.cpp +++ b/src/common/filesystem/file_grp.cpp @@ -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)); diff --git a/src/common/filesystem/file_pak.cpp b/src/common/filesystem/file_pak.cpp index 13aafa985..3a868766c 100644 --- a/src/common/filesystem/file_pak.cpp +++ b/src/common/filesystem/file_pak.cpp @@ -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 fileinfo(NumLumps, true); Reader.Seek (header.dirofs, FileReader::SeekSet); Reader.Read (fileinfo.Data(), NumLumps * sizeof(dpackfile_t)); diff --git a/src/common/filesystem/file_rff.cpp b/src/common/filesystem/file_rff.cpp index e8c4fce81..3e512b62d 100644 --- a/src/common/filesystem/file_rff.cpp +++ b/src/common/filesystem/file_rff.cpp @@ -221,7 +221,7 @@ int FRFFLump::FillCache() { int cryptlen = min (LumpSize, 256); uint8_t *data = (uint8_t *)Cache; - + for (int i = 0; i < cryptlen; ++i) { data[i] ^= i >> 1; diff --git a/src/common/filesystem/file_wad.cpp b/src/common/filesystem/file_wad.cpp index 216fab58b..8af39b5f8 100644 --- a/src/common/filesystem/file_wad.cpp +++ b/src/common/filesystem/file_wad.cpp @@ -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 markers; - + for(i = 0; i < NumLumps; i++) { if (IsMarker(i, startmarker)) @@ -302,7 +302,7 @@ 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. diff --git a/src/common/filesystem/file_whres.cpp b/src/common/filesystem/file_whres.cpp index 1c573ad38..969aaafab 100644 --- a/src/common/filesystem/file_whres.cpp +++ b/src/common/filesystem/file_whres.cpp @@ -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++) { diff --git a/src/common/filesystem/filesystem.cpp b/src/common/filesystem/filesystem.cpp index 6151925a0..6e3bea388 100644 --- a/src/common/filesystem/filesystem.cpp +++ b/src/common/filesystem/filesystem.cpp @@ -219,12 +219,12 @@ void FileSystem::InitMultipleFiles (TArray &filenames, bool quiet, Lump for(unsigned i=0;iGetHash().GetChars()); MoveLumpsInFolder(path); } - + NumEntries = FileInfo.Size(); if (NumEntries == 0) { @@ -283,7 +283,7 @@ int FileSystem::AddFromBuffer(const char* name, const char* type, char* data, in FileInfo.Last().resourceId = id; return FileInfo.Size()-1; } - + //========================================================================== // // AddFile @@ -332,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 @@ -945,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++) { @@ -1021,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)) @@ -1511,7 +1511,7 @@ int FileSystem::GetEntryCount (int rfnum) const noexcept { return 0; } - + return Files[rfnum]->LumpCount(); } diff --git a/src/common/filesystem/resourcefile.cpp b/src/common/filesystem/resourcefile.cpp index 154b3a0bd..3b8e39915 100644 --- a/src/common/filesystem/resourcefile.cpp +++ b/src/common/filesystem/resourcefile.cpp @@ -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) { diff --git a/src/common/fonts/font.cpp b/src/common/fonts/font.cpp index 5ae353e4b..e554f6366 100644 --- a/src/common/fonts/font.cpp +++ b/src/common/fonts/font.cpp @@ -86,10 +86,10 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla TMap 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 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); @@ -559,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]]++; @@ -727,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. @@ -805,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; diff --git a/src/common/fonts/hexfont.cpp b/src/common/fonts/hexfont.cpp index 612d3d326..3b985619e 100644 --- a/src/common/fonts/hexfont.cpp +++ b/src/common/fonts/hexfont.cpp @@ -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); } } - + }; diff --git a/src/common/fonts/singlelumpfont.cpp b/src/common/fonts/singlelumpfont.cpp index 6da14b0d0..d3bee25a3 100644 --- a/src/common/fonts/singlelumpfont.cpp +++ b/src/common/fonts/singlelumpfont.cpp @@ -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 widths2(count, true); diff --git a/src/common/fonts/v_font.cpp b/src/common/fonts/v_font.cpp index 20aa502bd..28af85202 100644 --- a/src/common/fonts/v_font.cpp +++ b/src/common/fonts/v_font.cpp @@ -106,10 +106,10 @@ FFont *V_GetFont(const char *name, const char *fontlumpname) int lump = -1; int folderfile = -1; - + TArray 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; @@ -769,7 +769,7 @@ static void CalcDefaultTranslation(FFont* base, int index) lowindex = highindex++; } } - + } //========================================================================== diff --git a/src/common/menu/menu.cpp b/src/common/menu/menu.cpp index bbfe2f4a5..89017d67b 100644 --- a/src/common/menu/menu.cpp +++ b/src/common/menu/menu.cpp @@ -271,7 +271,7 @@ DMenu::DMenu(DMenu *parent) DontDim = false; GC::WriteBarrier(this, parent); } - + //============================================================================= // // diff --git a/src/common/models/model_kvx.h b/src/common/models/model_kvx.h index 36db774c7..8d456d52c 100644 --- a/src/common/models/model_kvx.h +++ b/src/common/models/model_kvx.h @@ -48,7 +48,7 @@ protected: unsigned int mNumIndices; TArray mVertices; TArray 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); diff --git a/src/common/models/models_md2.cpp b/src/common/models/models_md2.cpp index 17cde4548..8924392a4 100644 --- a/src/common/models/models_md2.cpp +++ b/src/common/models/models_md2.cpp @@ -536,7 +536,7 @@ 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++) diff --git a/src/common/models/models_md3.cpp b/src/common/models/models_md3.cpp index 202ccf8d1..0ec4d700f 100644 --- a/src/common/models/models_md3.cpp +++ b/src/common/models/models_md3.cpp @@ -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)); diff --git a/src/common/models/models_voxel.cpp b/src/common/models/models_voxel.cpp index e0036d6da..50fc4df09 100644 --- a/src/common/models/models_voxel.cpp +++ b/src/common/models/models_voxel.cpp @@ -100,7 +100,7 @@ TArray 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 diff --git a/src/common/objects/dobject.cpp b/src/common/objects/dobject.cpp index 8516229de..34e2f4cc7 100644 --- a/src/common/objects/dobject.cpp +++ b/src/common/objects/dobject.cpp @@ -267,7 +267,7 @@ DObject::~DObject () Release(); } } - + if (nullptr != type) { type->DestroySpecials(this); diff --git a/src/common/objects/dobjgc.h b/src/common/objects/dobjgc.h index d01e52cf6..bd33a896c 100644 --- a/src/common/objects/dobjgc.h +++ b/src/common/objects/dobjgc.h @@ -158,6 +158,10 @@ namespace GC { MarkArray((DObject **)(obj), count); } + template void MarkArray(TObjPtr* obj, size_t count) + { + MarkArray((DObject**)(obj), count); + } template void MarkArray(TArray &arr) { MarkArray(&arr[0], arr.Size()); diff --git a/src/common/platform/posix/cocoa/i_input.mm b/src/common/platform/posix/cocoa/i_input.mm index ebda85a2e..f53ae8ebc 100644 --- a/src/common/platform/posix/cocoa/i_input.mm +++ b/src/common/platform/posix/cocoa/i_input.mm @@ -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); } diff --git a/src/common/platform/posix/cocoa/i_joystick.cpp b/src/common/platform/posix/cocoa/i_joystick.cpp index 2bbfedb1d..733380366 100644 --- a/src/common/platform/posix/cocoa/i_joystick.cpp +++ b/src/common/platform/posix/cocoa/i_joystick.cpp @@ -1127,7 +1127,7 @@ void IOKitJoystickManager::AddDevices(const IONotificationPortRef notificationPo } IOObjectRelease(device); - + PostDeviceChangeEvent(); } } diff --git a/src/common/platform/posix/cocoa/i_main.mm b/src/common/platform/posix/cocoa/i_main.mm index 727edef78..09c1daf56 100644 --- a/src/common/platform/posix/cocoa/i_main.mm +++ b/src/common/platform/posix/cocoa/i_main.mm @@ -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; diff --git a/src/common/platform/posix/cocoa/i_video.mm b/src/common/platform/posix/cocoa/i_video.mm index 8f730e488..2350ca954 100644 --- a/src/common/platform/posix/cocoa/i_video.mm +++ b/src/common/platform/posix/cocoa/i_video.mm @@ -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; } diff --git a/src/common/platform/posix/osx/i_specialpaths.mm b/src/common/platform/posix/osx/i_specialpaths.mm index ff435b769..d51bd4ca5 100644 --- a/src/common/platform/posix/osx/i_specialpaths.mm +++ b/src/common/platform/posix/osx/i_specialpaths.mm @@ -256,7 +256,7 @@ FString M_GetDocumentsPath() FString M_GetDemoPath() { FString path = GetSpecialPath(NSDocumentDirectory); - + if (path.IsNotEmpty()) { path += "/" GAME_DIR "/Demos/"; diff --git a/src/common/platform/posix/osx/iwadpicker_cocoa.mm b/src/common/platform/posix/osx/iwadpicker_cocoa.mm index 4ff7d737b..e72aa5aad 100644 --- a/src/common/platform/posix/osx/iwadpicker_cocoa.mm +++ b/src/common/platform/posix/osx/iwadpicker_cocoa.mm @@ -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); diff --git a/src/common/platform/posix/sdl/hardware.cpp b/src/common/platform/posix/sdl/hardware.cpp index ce877e943..46daca4f9 100644 --- a/src/common/platform/posix/sdl/hardware.cpp +++ b/src/common/platform/posix/sdl/hardware.cpp @@ -79,7 +79,7 @@ void I_InitGraphics () extern IVideo *gl_CreateVideo(); Video = gl_CreateVideo(); - + if (Video == NULL) I_FatalError ("Failed to initialize display"); } diff --git a/src/common/platform/posix/sdl/i_input.cpp b/src/common/platform/posix/sdl/i_input.cpp index a102b38a8..300e22370 100644 --- a/src/common/platform/posix/sdl/i_input.cpp +++ b/src/common/platform/posix/sdl/i_input.cpp @@ -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); diff --git a/src/common/platform/posix/sdl/i_main.cpp b/src/common/platform/posix/sdl/i_main.cpp index b52561fdf..a28b90f01 100644 --- a/src/common/platform/posix/sdl/i_main.cpp +++ b/src/common/platform/posix/sdl/i_main.cpp @@ -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(); diff --git a/src/common/platform/posix/sdl/i_system.cpp b/src/common/platform/posix/sdl/i_system.cpp index e370780ca..0bca72304 100644 --- a/src/common/platform/posix/sdl/i_system.cpp +++ b/src/common/platform/posix/sdl/i_system.cpp @@ -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++] = '='; @@ -208,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); @@ -224,7 +224,7 @@ void I_PrintStr(const char *cp) else break; } } - + if (StartScreen) CleanProgressBar(); fputs(printData.GetChars(),stdout); if (terminal) fputs("\033[0m",stdout); @@ -303,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; diff --git a/src/common/platform/posix/sdl/i_system.mm b/src/common/platform/posix/sdl/i_system.mm index 50faf94a8..f9212f08c 100644 --- a/src/common/platform/posix/sdl/i_system.mm +++ b/src/common/platform/posix/sdl/i_system.mm @@ -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 ); diff --git a/src/common/platform/posix/sdl/sdlglvideo.cpp b/src/common/platform/posix/sdl/sdlglvideo.cpp index 73ca00b99..9b4aa6cd6 100644 --- a/src/common/platform/posix/sdl/sdlglvideo.cpp +++ b/src/common/platform/posix/sdl/sdlglvideo.cpp @@ -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); diff --git a/src/common/platform/posix/sdl/st_start.cpp b/src/common/platform/posix/sdl/st_start.cpp index 6d41fa629..4c434bba9 100644 --- a/src/common/platform/posix/sdl/st_start.cpp +++ b/src/common/platform/posix/sdl/st_start.cpp @@ -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); diff --git a/src/common/platform/win32/hardware.cpp b/src/common/platform/win32/hardware.cpp index 13e799594..a5e67604f 100644 --- a/src/common/platform/win32/hardware.cpp +++ b/src/common/platform/win32/hardware.cpp @@ -165,5 +165,5 @@ void I_InitGraphics () // we somehow STILL don't have a display!! if (Video == NULL) I_FatalError ("Failed to initialize display"); - + } diff --git a/src/common/platform/win32/i_crash.cpp b/src/common/platform/win32/i_crash.cpp index a8d7b5c54..94ca7d6c2 100644 --- a/src/common/platform/win32/i_crash.cpp +++ b/src/common/platform/win32/i_crash.cpp @@ -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); diff --git a/src/common/platform/win32/i_keyboard.cpp b/src/common/platform/win32/i_keyboard.cpp index ce204f71c..00f910949 100644 --- a/src/common/platform/win32/i_keyboard.cpp +++ b/src/common/platform/win32/i_keyboard.cpp @@ -58,7 +58,7 @@ class FDInputKeyboard : public FKeyboard public: FDInputKeyboard(); ~FDInputKeyboard(); - + bool GetDevice(); void ProcessInput(); diff --git a/src/common/platform/win32/i_main.cpp b/src/common/platform/win32/i_main.cpp index acdfd2eb5..68cd06a00 100644 --- a/src/common/platform/win32/i_main.cpp +++ b/src/common/platform/win32/i_main.cpp @@ -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); diff --git a/src/common/platform/win32/i_mouse.cpp b/src/common/platform/win32/i_mouse.cpp index 102b1fbab..4c2673e35 100644 --- a/src/common/platform/win32/i_mouse.cpp +++ b/src/common/platform/win32/i_mouse.cpp @@ -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); @@ -697,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); diff --git a/src/common/platform/win32/i_rawps2.cpp b/src/common/platform/win32/i_rawps2.cpp index 90e575a71..f418872e8 100644 --- a/src/common/platform/win32/i_rawps2.cpp +++ b/src/common/platform/win32/i_rawps2.cpp @@ -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); diff --git a/src/common/platform/win32/i_system.cpp b/src/common/platform/win32/i_system.cpp index 07d00b59b..9a3f4a795 100644 --- a/src/common/platform/win32/i_system.cpp +++ b/src/common/platform/win32/i_system.cpp @@ -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; } diff --git a/src/common/platform/win32/i_xinput.cpp b/src/common/platform/win32/i_xinput.cpp index 2e8b79dc3..ba4605dd0 100644 --- a/src/common/platform/win32/i_xinput.cpp +++ b/src/common/platform/win32/i_xinput.cpp @@ -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; diff --git a/src/common/platform/win32/st_start.cpp b/src/common/platform/win32/st_start.cpp index 43e113a1b..3e67c795c 100644 --- a/src/common/platform/win32/st_start.cpp +++ b/src/common/platform/win32/st_start.cpp @@ -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); diff --git a/src/common/platform/win32/win32vulkanvideo.cpp b/src/common/platform/win32/win32vulkanvideo.cpp index d2c2e7b40..4c8f887c0 100644 --- a/src/common/platform/win32/win32vulkanvideo.cpp +++ b/src/common/platform/win32/win32vulkanvideo.cpp @@ -17,7 +17,7 @@ void I_GetVulkanDrawableSize(int *width, int *height) RECT clientRect = { 0 }; GetClientRect(Window, &clientRect); - + if (width != nullptr) { *width = clientRect.right; diff --git a/src/common/platform/win32/win32vulkanvideo.h b/src/common/platform/win32/win32vulkanvideo.h index 2654597c7..0e77d18a7 100644 --- a/src/common/platform/win32/win32vulkanvideo.h +++ b/src/common/platform/win32/win32vulkanvideo.h @@ -21,7 +21,7 @@ public: { device = new VulkanDevice(); } - + ~Win32VulkanVideo() { delete device; diff --git a/src/common/rendering/gl/gl_buffers.cpp b/src/common/rendering/gl/gl_buffers.cpp index 9338fee98..5439319a9 100644 --- a/src/common/rendering/gl/gl_buffers.cpp +++ b/src/common/rendering/gl/gl_buffers.cpp @@ -192,12 +192,12 @@ void GLBuffer::GPUDropSync() void GLBuffer::GPUWaitSync() { GLenum status = glClientWaitSync(mGLSync, GL_SYNC_FLUSH_COMMANDS_BIT, 1000 * 1000 * 50); // Wait for a max of 50ms... - + if (status != GL_ALREADY_SIGNALED && status != GL_CONDITION_SATISFIED) { //Printf("Error on glClientWaitSync: %d\n", status); } - + glDeleteSync(mGLSync); mGLSync = NULL; @@ -213,10 +213,10 @@ void GLVertexBuffer::SetFormat(int numBindingPoints, int numAttributes, size_t s { static int VFmtToGLFmt[] = { GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_UNSIGNED_BYTE, GL_INT_2_10_10_10_REV }; static uint8_t VFmtToSize[] = {4, 3, 2, 1, 4, 4}; - + mStride = stride; mNumBindingPoints = numBindingPoints; - + for(int i = 0; i < numAttributes; i++) { if (attrs[i].location >= 0 && attrs[i].location < VATTR_MAX) diff --git a/src/common/rendering/gl/gl_framebuffer.h b/src/common/rendering/gl/gl_framebuffer.h index 8f8a139b6..37da64ba4 100644 --- a/src/common/rendering/gl/gl_framebuffer.h +++ b/src/common/rendering/gl/gl_framebuffer.h @@ -65,7 +65,7 @@ public: bool HWGammaActive = false; // Are we using hardware or software gamma? std::shared_ptr mDebug; // Debug API - + FTexture *WipeStartScreen() override; FTexture *WipeEndScreen() override; diff --git a/src/common/rendering/gl/gl_hwtexture.cpp b/src/common/rendering/gl/gl_hwtexture.cpp index e2a7074bf..37b066155 100644 --- a/src/common/rendering/gl/gl_hwtexture.cpp +++ b/src/common/rendering/gl/gl_hwtexture.cpp @@ -148,7 +148,7 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int { sourcetype = GL_BGRA; } - + if (!firstCall && glBufferID > 0) glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rw, rh, sourcetype, GL_UNSIGNED_BYTE, buffer); else @@ -315,7 +315,7 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i int w = 0, h = 0; // Create this texture - + FTextureBuffer texbuffer; if (!tex->isHardwareCanvas()) diff --git a/src/common/rendering/gl/gl_renderer.h b/src/common/rendering/gl/gl_renderer.h index 3a4c55a70..71da1bf65 100644 --- a/src/common/rendering/gl/gl_renderer.h +++ b/src/common/rendering/gl/gl_renderer.h @@ -80,7 +80,7 @@ public: void DrawPresentTexture(const IntRect &box, bool applyGamma); void Flush(); void BeginFrame(); - + bool StartOffscreen(); void EndOffscreen(); diff --git a/src/common/rendering/gl/gl_renderstate.cpp b/src/common/rendering/gl/gl_renderstate.cpp index 04fe15ae2..688e46904 100644 --- a/src/common/rendering/gl/gl_renderstate.cpp +++ b/src/common/rendering/gl/gl_renderstate.cpp @@ -311,7 +311,7 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio if (tex->isHardwareCanvas()) static_cast(tex->GetTexture())->NeedUpdate(); clampmode = tex->GetClampMode(clampmode); - + // avoid rebinding the same texture multiple times. if (mat == lastMaterial && lastClamp == clampmode && translation == lastTranslation) return; lastMaterial = mat; diff --git a/src/common/rendering/gl/gl_samplers.cpp b/src/common/rendering/gl/gl_samplers.cpp index 3f1f53110..5ed7cbc19 100644 --- a/src/common/rendering/gl/gl_samplers.cpp +++ b/src/common/rendering/gl/gl_samplers.cpp @@ -98,7 +98,7 @@ void FSamplerManager::UnbindAll() glBindSampler(i, 0); } } - + uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) { unsigned int samp = mSamplers[num]; @@ -106,11 +106,11 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) return 255; } - + void FSamplerManager::SetTextureFilterMode() { GLint bounds[IHardwareTexture::MAX_TEXTURES]; - + // Unbind all for(int i = IHardwareTexture::MAX_TEXTURES-1; i >= 0; i--) { @@ -138,4 +138,4 @@ void FSamplerManager::SetTextureFilterMode() } -} \ No newline at end of file +} diff --git a/src/common/rendering/gl/gl_shader.cpp b/src/common/rendering/gl/gl_shader.cpp index 9ebaf8711..f8287a499 100644 --- a/src/common/rendering/gl/gl_shader.cpp +++ b/src/common/rendering/gl/gl_shader.cpp @@ -336,7 +336,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * #endif )"; - + #ifdef __APPLE__ // The noise functions are completely broken in macOS OpenGL drivers diff --git a/src/common/rendering/gl/gl_shader.h b/src/common/rendering/gl/gl_shader.h index b42e144ef..ec2289833 100644 --- a/src/common/rendering/gl/gl_shader.h +++ b/src/common/rendering/gl/gl_shader.h @@ -325,7 +325,7 @@ class FShaderCollection void Clean(); void CompileShaders(EPassType passType); - + public: FShaderCollection(EPassType passType); ~FShaderCollection(); diff --git a/src/common/rendering/gl_load/gl_interface.cpp b/src/common/rendering/gl_load/gl_interface.cpp index 3b5309e8c..344a3d4fa 100644 --- a/src/common/rendering/gl_load/gl_interface.cpp +++ b/src/common/rendering/gl_load/gl_interface.cpp @@ -230,7 +230,7 @@ void gl_PrintStartupLog() Printf ("Max. texture units: %d\n", v); glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); Printf ("Max. varying: %d\n", v); - + if (gl.flags & RFL_SHADER_STORAGE_BUFFER) { glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &v); diff --git a/src/common/rendering/gl_load/gl_load.c b/src/common/rendering/gl_load/gl_load.c index bf563afe0..e29207f4a 100644 --- a/src/common/rendering/gl_load/gl_load.c +++ b/src/common/rendering/gl_load/gl_load.c @@ -9,7 +9,7 @@ static void* AppleGLGetProcAddress (const char *name) { static void* image = NULL; - + if (NULL == image) image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); @@ -61,9 +61,9 @@ static int TestPointer(const PROC pTest) ptrdiff_t iTest; if(!pTest) return 0; iTest = (ptrdiff_t)pTest; - + if(iTest == 1 || iTest == 2 || iTest == 3 || iTest == -1) return 0; - + return 1; } @@ -119,7 +119,7 @@ static PROC WinGetProcAddress(const char *name) glMod = GetModuleHandleA("OpenGL32.dll"); return (PROC)GetProcAddress(glMod, (LPCSTR)name); } - + #define IntGetProcAddress(name) WinGetProcAddress(name) #else #if defined(__APPLE__) @@ -3363,7 +3363,7 @@ static ogl_StrToExtMap *FindExtEntry(const char *extensionName) if(strcmp(extensionName, currLoc->extensionName) == 0) return currLoc; } - + return NULL; } @@ -3465,7 +3465,7 @@ int ogl_LoadFunctions() { int numFailed = 0; ClearExtensionVars(); - + _ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress("glGetIntegerv"); if(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED; _ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi"); @@ -3479,7 +3479,7 @@ int ogl_LoadFunctions() } numFailed = Load_Version_4_5(); - + if(numFailed == 0) return ogl_LOAD_SUCCEEDED; else @@ -3515,7 +3515,7 @@ int ogl_IsVersionGEQ(int majorVersion, int minorVersion) { if(g_major_version == 0) GetGLVersion(); - + if(majorVersion < g_major_version) return 1; if(majorVersion > g_major_version) return 0; if(minorVersion <= g_minor_version) return 1; diff --git a/src/common/rendering/gles/glad/include/glad/glad.h b/src/common/rendering/gles/glad/include/glad/glad.h index 5a7c1505e..212864bc1 100644 --- a/src/common/rendering/gles/glad/include/glad/glad.h +++ b/src/common/rendering/gles/glad/include/glad/glad.h @@ -7,7 +7,7 @@ APIs: gles2=2.0 Profile: compatibility Extensions: - + Loader: True Local files: False Omit khrplatform: False diff --git a/src/common/rendering/gles/glad/include/glad/glad_egl.h b/src/common/rendering/gles/glad/include/glad/glad_egl.h index fbc5b8630..1c47f7ced 100644 --- a/src/common/rendering/gles/glad/include/glad/glad_egl.h +++ b/src/common/rendering/gles/glad/include/glad/glad_egl.h @@ -7,7 +7,7 @@ APIs: egl=1.4 Profile: - Extensions: - + Loader: True Local files: False Omit khrplatform: False diff --git a/src/common/rendering/gles/glad/src/glad.c b/src/common/rendering/gles/glad/src/glad.c index 9da9f0ed1..6653cc3f6 100644 --- a/src/common/rendering/gles/glad/src/glad.c +++ b/src/common/rendering/gles/glad/src/glad.c @@ -7,7 +7,7 @@ APIs: gles2=2.0 Profile: compatibility Extensions: - + Loader: True Local files: False Omit khrplatform: False diff --git a/src/common/rendering/gles/glad/src/glad_egl.c b/src/common/rendering/gles/glad/src/glad_egl.c index 3c939401c..8d0744041 100644 --- a/src/common/rendering/gles/glad/src/glad_egl.c +++ b/src/common/rendering/gles/glad/src/glad_egl.c @@ -7,7 +7,7 @@ APIs: egl=1.4 Profile: - Extensions: - + Loader: True Local files: False Omit khrplatform: False diff --git a/src/common/rendering/gles/gles_buffers.cpp b/src/common/rendering/gles/gles_buffers.cpp index de815ea34..0b5f18024 100644 --- a/src/common/rendering/gles/gles_buffers.cpp +++ b/src/common/rendering/gles/gles_buffers.cpp @@ -79,7 +79,7 @@ GLBuffer::~GLBuffer() glBindBuffer(mUseType, 0); glDeleteBuffers(1, &mBufferId); } - + if (memory) delete[] memory; } @@ -129,9 +129,9 @@ void GLBuffer::SetData(size_t size, const void* data, BufferUsageType usage) void GLBuffer::SetSubData(size_t offset, size_t size, const void *data) { Bind(); - + memcpy(memory + offset, data, size); - + if (!isData) { glBufferSubData(mUseType, offset, size, data); @@ -143,7 +143,7 @@ void GLBuffer::Upload(size_t start, size_t size) if (!gles.useMappedBuffers) { Bind(); - + if(size) glBufferSubData(mUseType, start, size, memory + start); } @@ -278,10 +278,10 @@ void GLVertexBuffer::SetFormat(int numBindingPoints, int numAttributes, size_t s { static int VFmtToGLFmt[] = { GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_UNSIGNED_BYTE, GL_FLOAT }; // TODO Fix last entry GL_INT_2_10_10_10_REV, normals for models will be broken static uint8_t VFmtToSize[] = {4, 3, 2, 1, 4, 4}; - + mStride = stride; mNumBindingPoints = numBindingPoints; - + for(int i = 0; i < numAttributes; i++) { if (attrs[i].location >= 0 && attrs[i].location < VATTR_MAX) diff --git a/src/common/rendering/gles/gles_framebuffer.cpp b/src/common/rendering/gles/gles_framebuffer.cpp index 3d44dd4d9..f3806f132 100644 --- a/src/common/rendering/gles/gles_framebuffer.cpp +++ b/src/common/rendering/gles/gles_framebuffer.cpp @@ -136,7 +136,7 @@ void OpenGLFrameBuffer::InitializeState() glEnable(GL_DITHER); glDisable(GL_CULL_FACE); glDisable(GL_POLYGON_OFFSET_FILL); - + glEnable(GL_BLEND); if (gles.depthClampAvailable) glEnable(GL_DEPTH_CLAMP); @@ -237,7 +237,7 @@ const char* OpenGLFrameBuffer::DeviceName() const void OpenGLFrameBuffer::Swap() { - + Finish.Reset(); Finish.Clock(); @@ -245,7 +245,7 @@ void OpenGLFrameBuffer::Swap() FPSLimit(); SwapBuffers(); - + mVertexData->NextPipelineBuffer(); mVertexData->WaitSync(); diff --git a/src/common/rendering/gles/gles_framebuffer.h b/src/common/rendering/gles/gles_framebuffer.h index 25626c659..d550b8f10 100644 --- a/src/common/rendering/gles/gles_framebuffer.h +++ b/src/common/rendering/gles/gles_framebuffer.h @@ -61,7 +61,7 @@ public: bool HWGammaActive = false; // Are we using hardware or software gamma? std::shared_ptr mDebug; // Debug API - + FTexture *WipeStartScreen() override; FTexture *WipeEndScreen() override; diff --git a/src/common/rendering/gles/gles_hwtexture.cpp b/src/common/rendering/gles/gles_hwtexture.cpp index 3bf889087..43425ce7d 100644 --- a/src/common/rendering/gles/gles_hwtexture.cpp +++ b/src/common/rendering/gles/gles_hwtexture.cpp @@ -176,7 +176,7 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int glGenerateMipmap(GL_TEXTURE_2D); mipmapped = true; } - + if (texunit > 0) glActiveTexture(GL_TEXTURE0); else if (texunit == -1) glBindTexture(GL_TEXTURE_2D, textureBinding); return glTexID; @@ -317,7 +317,7 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i int w = 0, h = 0; // Create this texture - + FTextureBuffer texbuffer; if (!tex->isHardwareCanvas()) diff --git a/src/common/rendering/gles/gles_postprocess.cpp b/src/common/rendering/gles/gles_postprocess.cpp index d473f337e..1bedaf9cc 100644 --- a/src/common/rendering/gles/gles_postprocess.cpp +++ b/src/common/rendering/gles/gles_postprocess.cpp @@ -158,7 +158,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma) mPresentShader->Uniforms->Offset = { 0.0f, 0.0f }; mPresentShader->Uniforms.SetData(); - + for (size_t n = 0; n < mPresentShader->Uniforms.mFields.size(); n++) { UniformFieldDesc desc = mPresentShader->Uniforms.mFields[n]; @@ -178,7 +178,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma) break; } } - + RenderScreenQuad(); } @@ -223,4 +223,4 @@ void FGLRenderer::ClearBorders() glDisable(GL_SCISSOR_TEST); } -} \ No newline at end of file +} diff --git a/src/common/rendering/gles/gles_renderbuffers.cpp b/src/common/rendering/gles/gles_renderbuffers.cpp index 4d587aa87..002734b99 100644 --- a/src/common/rendering/gles/gles_renderbuffers.cpp +++ b/src/common/rendering/gles/gles_renderbuffers.cpp @@ -44,7 +44,7 @@ namespace OpenGLESRenderer FGLRenderBuffers::FGLRenderBuffers() { - + } //========================================================================== @@ -56,7 +56,7 @@ namespace OpenGLESRenderer FGLRenderBuffers::~FGLRenderBuffers() { ClearScene(); - + DeleteTexture(mDitherTexture); } @@ -163,7 +163,7 @@ namespace OpenGLESRenderer mSceneTex = Create2DTexture("PipelineTexture", GL_RGBA, width, height); } - + //========================================================================== // @@ -178,7 +178,7 @@ namespace OpenGLESRenderer tex.Height = height; glGenTextures(1, &tex.handle); glBindTexture(GL_TEXTURE_2D, tex.handle); - + GLenum dataformat = 0, datatype = 0; /* switch (format) @@ -224,7 +224,7 @@ namespace OpenGLESRenderer PPGLRenderBuffer buf; glGenRenderbuffers(1, &buf.handle); glBindRenderbuffer(GL_RENDERBUFFER, buf.handle); - + glRenderbufferStorage(GL_RENDERBUFFER, format, width, height); return buf; } @@ -240,7 +240,7 @@ namespace OpenGLESRenderer PPGLFrameBuffer fb; glGenFramebuffers(1, &fb.handle); glBindFramebuffer(GL_FRAMEBUFFER, fb.handle); - + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer.handle, 0); if (CheckFrameBufferCompleteness()) ClearFrameBuffer(false, false); @@ -252,7 +252,7 @@ namespace OpenGLESRenderer PPGLFrameBuffer fb; glGenFramebuffers(1, &fb.handle); glBindFramebuffer(GL_FRAMEBUFFER, fb.handle); - + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer.handle, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthstencil.handle); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, gles.depthStencilAvailable ? depthstencil.handle : stencil.handle); @@ -266,7 +266,7 @@ namespace OpenGLESRenderer PPGLFrameBuffer fb; glGenFramebuffers(1, &fb.handle); glBindFramebuffer(GL_FRAMEBUFFER, fb.handle); - + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer.handle); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthstencil.handle); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, gles.depthStencilAvailable ? depthstencil.handle : stencil.handle); @@ -284,7 +284,7 @@ namespace OpenGLESRenderer glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer0.handle, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthstencil.handle); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, gles.depthStencilAvailable ? depthstencil.handle : stencil.handle); - + if (CheckFrameBufferCompleteness()) ClearFrameBuffer(true, true); return fb; @@ -311,7 +311,7 @@ namespace OpenGLESRenderer case GL_FRAMEBUFFER_UNSUPPORTED: error << "GL_FRAMEBUFFER_UNSUPPORTED"; break; } Printf("%s\n", error.GetChars()); - + return false; } @@ -369,7 +369,7 @@ namespace OpenGLESRenderer mDitherTexture.Bind(1, GL_NEAREST, GL_REPEAT); } - + //========================================================================== // // Makes the scene frame buffer active (multisample, depth, stecil, etc.) diff --git a/src/common/rendering/gles/gles_renderbuffers.h b/src/common/rendering/gles/gles_renderbuffers.h index ce052e26f..3369a864f 100644 --- a/src/common/rendering/gles/gles_renderbuffers.h +++ b/src/common/rendering/gles/gles_renderbuffers.h @@ -113,7 +113,7 @@ public: private: void ClearScene(); - + void CreateScene(int width, int height); void CreatePipeline(int width, int height); diff --git a/src/common/rendering/gles/gles_renderer.cpp b/src/common/rendering/gles/gles_renderer.cpp index 0cd4d8e5e..1a33b3bd7 100644 --- a/src/common/rendering/gles/gles_renderer.cpp +++ b/src/common/rendering/gles/gles_renderer.cpp @@ -83,7 +83,7 @@ void FGLRenderer::Initialize(int width, int height) mScreenBuffers = new FGLRenderBuffers(); mBuffers = mScreenBuffers; mPresentShader = new FPresentShader(); - + mFBID = 0; mOldFBID = 0; @@ -97,7 +97,7 @@ FGLRenderer::~FGLRenderer() TexMan.FlushAll(); if (mShaderManager != nullptr) delete mShaderManager; if (mFBID != 0) glDeleteFramebuffers(1, &mFBID); - + if (mBuffers) delete mBuffers; if (mPresentShader) delete mPresentShader; } diff --git a/src/common/rendering/gles/gles_renderer.h b/src/common/rendering/gles/gles_renderer.h index a19690029..3322e06bf 100644 --- a/src/common/rendering/gles/gles_renderer.h +++ b/src/common/rendering/gles/gles_renderer.h @@ -67,12 +67,12 @@ public: void PresentStereo(); void RenderScreenQuad(); void PostProcessScene(int fixedcm, float flash, const std::function &afterBloomDrawEndScene2D); - + void CopyToBackbuffer(const IntRect *bounds, bool applyGamma); void DrawPresentTexture(const IntRect &box, bool applyGamma); void Flush(); void BeginFrame(); - + bool StartOffscreen(); void EndOffscreen(); diff --git a/src/common/rendering/gles/gles_renderstate.cpp b/src/common/rendering/gles/gles_renderstate.cpp index 75c479c51..76718f649 100644 --- a/src/common/rendering/gles/gles_renderstate.cpp +++ b/src/common/rendering/gles/gles_renderstate.cpp @@ -94,7 +94,7 @@ void FGLRenderState::Reset() bool FGLRenderState::ApplyShader() { static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f }; - + ShaderFlavourData flavour; // Need to calc light data now in order to select correct shader @@ -127,7 +127,7 @@ bool FGLRenderState::ApplyShader() if (modLights + subLights + addLights > (int)gles.maxlights) addLights = gles.maxlights - modLights - subLights; - + totalLights = modLights + subLights + addLights; // Skip passed the first 4 floats so the upload below only contains light data @@ -152,12 +152,13 @@ bool FGLRenderState::ApplyShader() flavour.texFlags = tm >> 16; //Move flags to start of word if (mTextureClamp && flavour.textureMode == TM_NORMAL) flavour.textureMode = TM_CLAMPY; // fixme. Clamp can now be combined with all modes. - + if (flavour.textureMode == -1) flavour.textureMode = 0; flavour.blendFlags = (int)(mStreamData.uTextureAddColor.a + 0.01); + flavour.paletteInterpolate = !!(flavour.blendFlags & 0x4000); flavour.twoDFog = false; flavour.fogEnabled = false; @@ -165,7 +166,7 @@ bool FGLRenderState::ApplyShader() flavour.colouredFog = false; flavour.fogEquationRadial = (gl_fogmode == 2); - + flavour.twoDFog = false; flavour.fogEnabled = false; flavour.colouredFog = false; @@ -196,7 +197,7 @@ bool FGLRenderState::ApplyShader() flavour.useObjectColor2 = (mStreamData.uObjectColor2.a > 0); flavour.useGlowTopColor = mGlowEnabled && (mStreamData.uGlowTopColor[3] > 0); flavour.useGlowBottomColor = mGlowEnabled && (mStreamData.uGlowBottomColor[3] > 0); - + flavour.useColorMap = (mColorMapSpecial >= CM_FIRSTSPECIALCOLORMAP) || (mColorMapFlash != 1); flavour.buildLighting = (mHwUniforms->mPalLightLevels >> 16) == 5; // Build engine mode @@ -217,7 +218,7 @@ bool FGLRenderState::ApplyShader() activeShader->Bind(flavour); } - + if (mHwUniforms) { activeShader->cur->muProjectionMatrix.Set(&mHwUniforms->mProjectionMatrix); @@ -334,7 +335,7 @@ bool FGLRenderState::ApplyShader() { // Calculate the total number of vec4s we need int totalVectors = totalLights * LIGHT_VEC4_NUM; - + if (totalVectors > (int)gles.numlightvectors) totalVectors = gles.numlightvectors; @@ -347,7 +348,7 @@ bool FGLRenderState::ApplyShader() activeShader->cur->muLightRange.Set(range); } - + return true; } @@ -449,7 +450,7 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio if (tex->isHardwareCanvas()) static_cast(tex->GetTexture())->NeedUpdate(); clampmode = tex->GetClampMode(clampmode); - + // avoid rebinding the same texture multiple times. if (mat == lastMaterial && lastClamp == clampmode && translation == lastTranslation) return; lastMaterial = mat; diff --git a/src/common/rendering/gles/gles_samplers.cpp b/src/common/rendering/gles/gles_samplers.cpp index c088657c7..8d9ddecdf 100644 --- a/src/common/rendering/gles/gles_samplers.cpp +++ b/src/common/rendering/gles/gles_samplers.cpp @@ -60,9 +60,9 @@ FSamplerManager::~FSamplerManager() void FSamplerManager::UnbindAll() { - + } - + uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) { @@ -157,14 +157,14 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) return 255; } - + void FSamplerManager::SetTextureFilterMode() { /* GLRenderer->FlushTextures(); GLint bounds[IHardwareTexture::MAX_TEXTURES]; - + // Unbind all for(int i = IHardwareTexture::MAX_TEXTURES-1; i >= 0; i--) { diff --git a/src/common/rendering/gles/gles_shader.cpp b/src/common/rendering/gles/gles_shader.cpp index 37a9fd7ed..f67aa375e 100644 --- a/src/common/rendering/gles/gles_shader.cpp +++ b/src/common/rendering/gles/gles_shader.cpp @@ -266,7 +266,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char * // light buffers uniform vec4 lights[MAXIMUM_LIGHT_VECTORS]; - + uniform mat4 ProjectionMatrix; uniform mat4 ViewMatrix; uniform mat4 NormalViewMatrix; @@ -370,7 +370,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char * #define glowtexture texture4 #endif )"; - + #ifdef NPOT_EMULATION i_data += "#define NPOT_EMULATION\nuniform vec2 uNpotEmulation;\n"; #endif @@ -392,7 +392,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char * assert(screen->mLights != NULL); - bool lightbuffertype = screen->mLights->GetBufferType(); unsigned int lightbuffersize = screen->mLights->GetBlockSize(); vp_comb.Format("#version 100\n#define NUM_UBO_LIGHTS %d\n#define NO_CLIPDISTANCE_SUPPORT\n", lightbuffersize); @@ -495,7 +494,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char * } shaderData->hShader = glCreateProgram(); - + uint32_t binaryFormat = 0; TArray binary; if (IsShaderCacheActive()) @@ -687,7 +686,7 @@ bool FShader::Bind(ShaderFlavourData& flavour) variantConfig.AppendFormat("#define MAXIMUM_LIGHT_VECTORS %d\n", gles.numlightvectors); variantConfig.AppendFormat("#define DEF_TEXTURE_MODE %d\n", flavour.textureMode); variantConfig.AppendFormat("#define DEF_TEXTURE_FLAGS %d\n", flavour.texFlags); - variantConfig.AppendFormat("#define DEF_BLEND_FLAGS %d\n", flavour.blendFlags); + variantConfig.AppendFormat("#define DEF_BLEND_FLAGS %d\n", flavour.blendFlags & 0x7); variantConfig.AppendFormat("#define DEF_FOG_2D %d\n", flavour.twoDFog); variantConfig.AppendFormat("#define DEF_FOG_ENABLED %d\n", flavour.fogEnabled); variantConfig.AppendFormat("#define DEF_FOG_RADIAL %d\n", flavour.fogEquationRadial); @@ -695,7 +694,7 @@ bool FShader::Bind(ShaderFlavourData& flavour) variantConfig.AppendFormat("#define DEF_USE_U_LIGHT_LEVEL %d\n", flavour.useULightLevel); variantConfig.AppendFormat("#define DEF_DO_DESATURATE %d\n", flavour.doDesaturate); - + variantConfig.AppendFormat("#define DEF_DYNAMIC_LIGHTS_MOD %d\n", flavour.dynLightsMod); variantConfig.AppendFormat("#define DEF_DYNAMIC_LIGHTS_SUB %d\n", flavour.dynLightsSub); variantConfig.AppendFormat("#define DEF_DYNAMIC_LIGHTS_ADD %d\n", flavour.dynLightsAdd); @@ -703,7 +702,7 @@ bool FShader::Bind(ShaderFlavourData& flavour) variantConfig.AppendFormat("#define DEF_USE_OBJECT_COLOR_2 %d\n", flavour.useObjectColor2); variantConfig.AppendFormat("#define DEF_USE_GLOW_TOP_COLOR %d\n", flavour.useGlowTopColor); variantConfig.AppendFormat("#define DEF_USE_GLOW_BOTTOM_COLOR %d\n", flavour.useGlowBottomColor); - + variantConfig.AppendFormat("#define DEF_USE_COLOR_MAP %d\n", flavour.useColorMap); variantConfig.AppendFormat("#define DEF_BUILD_LIGHTING %d\n", flavour.buildLighting); variantConfig.AppendFormat("#define DEF_BANDED_SW_LIGHTING %d\n", flavour.bandedSwLight); @@ -715,6 +714,7 @@ bool FShader::Bind(ShaderFlavourData& flavour) #endif variantConfig.AppendFormat("#define DEF_HAS_SPOTLIGHT %d\n", flavour.hasSpotLight); + variantConfig.AppendFormat("#define DEF_PALETTE_INTERPOLATE %d\n", flavour.paletteInterpolate); //Printf("Shader: %s, %08x %s", mFragProg2.GetChars(), tag, variantConfig.GetChars()); @@ -851,7 +851,7 @@ void FShaderCollection::CompileShaders(EPassType passType) mMaterialShaders.Push(shc); if (i < SHADER_NoTexture) { - FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, defaultshaders[i].lightfunc, defaultshaders[i].Defines, false, passType); + shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, defaultshaders[i].lightfunc, defaultshaders[i].Defines, false, passType); mMaterialShadersNAT.Push(shc); } } diff --git a/src/common/rendering/gles/gles_shader.h b/src/common/rendering/gles/gles_shader.h index b9c98fb6e..72a242c1b 100644 --- a/src/common/rendering/gles/gles_shader.h +++ b/src/common/rendering/gles/gles_shader.h @@ -277,13 +277,14 @@ public: #endif bool hasSpotLight; + bool paletteInterpolate; }; class FShader { friend class FShaderCollection; friend class FGLRenderState; - + FName mName; FString mVertProg; @@ -378,7 +379,7 @@ public: FShader(const char *name) : mName(name) { - + } ~FShader(); @@ -393,9 +394,9 @@ public: { uint32_t tag = 0; tag |= (flavour.textureMode & 0x7); - + tag |= (flavour.texFlags & 7) << 3; - + tag |= (flavour.blendFlags & 7) << 6; tag |= (flavour.twoDFog & 1) << 7; @@ -419,15 +420,15 @@ public: #ifdef NPOT_EMULATION tag |= (flavour.npotEmulation & 1) << 22; #endif - tag |= (flavour.hasSpotLight & 1) << 23; + tag |= (flavour.paletteInterpolate & 1) << 24; return tag; } bool Bind(ShaderFlavourData& flavour); - + }; //========================================================================== @@ -461,7 +462,7 @@ class FShaderCollection void Clean(); void CompileShaders(EPassType passType); - + public: FShaderCollection(EPassType passType); ~FShaderCollection(); diff --git a/src/common/rendering/gles/gles_shaderprogram.cpp b/src/common/rendering/gles/gles_shaderprogram.cpp index 6aa9ec172..784c85c30 100644 --- a/src/common/rendering/gles/gles_shaderprogram.cpp +++ b/src/common/rendering/gles/gles_shaderprogram.cpp @@ -104,7 +104,7 @@ void FShaderProgram::CompileShader(ShaderType type) const auto &handle = mShaders[type]; - + const FString &patchedCode = mShaderSources[type]; int lengths[1] = { (int)patchedCode.Len() }; const char *sources[1] = { patchedCode.GetChars() }; @@ -290,4 +290,4 @@ void FPresentShader::Bind() mShader->Bind(); } -} \ No newline at end of file +} diff --git a/src/common/rendering/gles/gles_system.cpp b/src/common/rendering/gles/gles_system.cpp index 79f6e0a48..51f8ee6a2 100644 --- a/src/common/rendering/gles/gles_system.cpp +++ b/src/common/rendering/gles/gles_system.cpp @@ -63,7 +63,7 @@ static PROC(WINAPI* getprocaddress)(LPCSTR name); static void* LoadGLES2Proc(const char* name) { HINSTANCE hGetProcIDDLL = LoadLibraryA("libGLESv2.dll"); - + int error = GetLastError(); void* addr = GetProcAddress(hGetProcIDDLL, name); @@ -169,14 +169,14 @@ namespace OpenGLESRenderer gles.modelstring = (char*)glGetString(GL_RENDERER); gles.vendorstring = (char*)glGetString(GL_VENDOR); - + gl_customshader = false; GLint maxTextureSize[1]; glGetIntegerv(GL_MAX_TEXTURE_SIZE, maxTextureSize); gles.max_texturesize = maxTextureSize[0]; - + Printf("GL_MAX_TEXTURE_SIZE: %d\n", gles.max_texturesize); #if USE_GLES2 @@ -189,7 +189,7 @@ namespace OpenGLESRenderer gles.useMappedBuffers = true; gles.depthClampAvailable = true; #endif - + gles.numlightvectors = (gles.maxlights * LIGHT_VEC4_NUM); } } diff --git a/src/common/rendering/hwrenderer/data/buffers.h b/src/common/rendering/hwrenderer/data/buffers.h index 980adde5e..021040de0 100644 --- a/src/common/rendering/hwrenderer/data/buffers.h +++ b/src/common/rendering/hwrenderer/data/buffers.h @@ -24,7 +24,7 @@ enum VATTR_VERTEX2, VATTR_NORMAL, VATTR_NORMAL2, - + VATTR_MAX }; diff --git a/src/common/rendering/hwrenderer/data/flatvertices.h b/src/common/rendering/hwrenderer/data/flatvertices.h index 619128a33..b6f5b7eb1 100644 --- a/src/common/rendering/hwrenderer/data/flatvertices.h +++ b/src/common/rendering/hwrenderer/data/flatvertices.h @@ -52,7 +52,7 @@ public: IVertexBuffer *mVertexBufferPipeline[HW_MAX_PIPELINE_BUFFERS]; IIndexBuffer *mIndexBuffer; - + unsigned int mIndex; std::atomic mCurIndex; diff --git a/src/common/rendering/hwrenderer/data/hw_clock.cpp b/src/common/rendering/hwrenderer/data/hw_clock.cpp index e9affdbe6..a9209d236 100644 --- a/src/common/rendering/hwrenderer/data/hw_clock.cpp +++ b/src/common/rendering/hwrenderer/data/hw_clock.cpp @@ -167,7 +167,7 @@ void CheckBench() FString compose; if (sysCallbacks.GetLocationDescription) compose = sysCallbacks.GetLocationDescription(); - + AppendRenderStats(compose); AppendRenderTimes(compose); AppendLightStats(compose); diff --git a/src/common/rendering/hwrenderer/data/hw_dynlightdata.h b/src/common/rendering/hwrenderer/data/hw_dynlightdata.h index 4631fd434..d54b7427e 100644 --- a/src/common/rendering/hwrenderer/data/hw_dynlightdata.h +++ b/src/common/rendering/hwrenderer/data/hw_dynlightdata.h @@ -51,7 +51,7 @@ struct FDynLightData if (siz[1] > max) siz[1] = max; if (siz[2] > max) siz[2] = max; } - + }; diff --git a/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp b/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp index c36863d53..622626056 100644 --- a/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp +++ b/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp @@ -37,10 +37,10 @@ FLightBuffer::FLightBuffer(int pipelineNbr): mPipelineNbr(pipelineNbr) { int maxNumberOfLights = 80000; - + mBufferSize = maxNumberOfLights * ELEMENTS_PER_LIGHT; mByteSize = mBufferSize * ELEMENT_SIZE; - + // Hack alert: On Intel's GL driver SSBO's perform quite worse than UBOs. // We only want to disable using SSBOs for lights but not disable the feature entirely. // Note that using an uniform buffer here will limit the number of lights per surface so it isn't done for NVidia and AMD. @@ -57,7 +57,7 @@ FLightBuffer::FLightBuffer(int pipelineNbr): mBlockSize = screen->maxuniformblock / ELEMENT_SIZE; mBlockAlign = screen->uniformblockalignment / ELEMENT_SIZE; mMaxUploadSize = (mBlockSize - mBlockAlign); - + //mByteSize += screen->maxuniformblock; // to avoid mapping beyond the end of the buffer. REMOVED this...This can try to allocate 100's of MB.. } @@ -96,7 +96,7 @@ int FLightBuffer::UploadLights(FDynLightData &data) if (totalsize > (int)mMaxUploadSize) { int diff = totalsize - (int)mMaxUploadSize; - + size2 -= diff; if (size2 < 0) { @@ -115,14 +115,14 @@ int FLightBuffer::UploadLights(FDynLightData &data) assert(mBufferPointer != nullptr); if (mBufferPointer == nullptr) return -1; if (totalsize <= 1) return -1; // there are no lights - + unsigned thisindex = mIndex.fetch_add(totalsize); float parmcnt[] = { 0, float(size0), float(size0 + size1), float(size0 + size1 + size2) }; if (thisindex + totalsize <= mBufferSize) { float *copyptr = mBufferPointer + thisindex*4; - + memcpy(©ptr[0], parmcnt, ELEMENT_SIZE); memcpy(©ptr[4], &data.arrays[0][0], size0 * ELEMENT_SIZE); memcpy(©ptr[4 + 4*size0], &data.arrays[1][0], size1 * ELEMENT_SIZE); diff --git a/src/common/rendering/hwrenderer/data/hw_lightbuffer.h b/src/common/rendering/hwrenderer/data/hw_lightbuffer.h index 441dc55ff..ad266bd94 100644 --- a/src/common/rendering/hwrenderer/data/hw_lightbuffer.h +++ b/src/common/rendering/hwrenderer/data/hw_lightbuffer.h @@ -23,7 +23,7 @@ class FLightBuffer unsigned int mBufferSize; unsigned int mByteSize; unsigned int mMaxUploadSize; - + void CheckSize(); public: diff --git a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp b/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp index 26eaa2d2c..18f23e1d5 100644 --- a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp +++ b/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp @@ -38,13 +38,13 @@ but then only in 2D where this reduces itself to a square. When main.fp samples from the shadow map it first decides in which direction the fragment is (relative to the light), like cubemap sampling does for 3D, but once again just for the 2D case. - + Texels 0-255 is Y positive, 256-511 is X positive, 512-767 is Y negative and 768-1023 is X negative. Generating the shadow map itself is done by FShadowMap::Update(). The shadow map texture's FBO is bound and then a screen quad is drawn to make a fragment shader cover all texels. For each fragment it shoots a ray and collects the distance to what it hit. - + The shadowmap.fp shader knows which light and texel it is processing by mapping gl_FragCoord.y back to the light index, and it knows which direction to ray trace by looking at gl_FragCoord.x. For example, if gl_FragCoord.y is 20.5, then it knows its processing light 20, and if gl_FragCoord.x is diff --git a/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp b/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp index d9230230b..0ab124025 100644 --- a/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp +++ b/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp @@ -98,7 +98,7 @@ void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll) matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f); matrices.CalcDependencies(); - + for (int n = 0; n < mPipelineNbr; n++) { mBufferPipeline[n]->Map(); diff --git a/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.h b/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.h index 0fbd46dfa..90c64ca7f 100644 --- a/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.h +++ b/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.h @@ -18,7 +18,7 @@ class HWViewpointBuffer unsigned int mLastMappedIndex; unsigned int mByteSize; TArray mClipPlaneInfo; - + int m2DWidth = -1, m2DHeight = -1; unsigned int mBlockSize; diff --git a/src/common/rendering/polyrenderer/drawers/poly_thread.cpp b/src/common/rendering/polyrenderer/drawers/poly_thread.cpp index 502705ca5..35566138b 100644 --- a/src/common/rendering/polyrenderer/drawers/poly_thread.cpp +++ b/src/common/rendering/polyrenderer/drawers/poly_thread.cpp @@ -679,7 +679,7 @@ int PolyTriangleThreadData::ClipEdge(const ShadedTriVertex *const* verts) // -v.w <= v.x <= v.w // -v.w <= v.y <= v.w // -v.w <= v.z <= v.w - + // halfspace clip distances static const int numclipdistances = 9; #ifdef NO_SSE @@ -799,7 +799,7 @@ int PolyTriangleThreadData::ClipEdge(const ShadedTriVertex *const* verts) for (int k = 0; k < 3; k++) output[outputverts * 3 + k] = input[i * 3 + k] * (1.0f - t1) + input[j * 3 + k] * t1; outputverts++; - + if (t2 != 1.0f && t2 > t1) { // add t2 vertex diff --git a/src/common/rendering/polyrenderer/drawers/screen_shader.cpp b/src/common/rendering/polyrenderer/drawers/screen_shader.cpp index 7403a9336..66c4e6ffb 100644 --- a/src/common/rendering/polyrenderer/drawers/screen_shader.cpp +++ b/src/common/rendering/polyrenderer/drawers/screen_shader.cpp @@ -456,7 +456,7 @@ static void GetLightColor(int x0, int x1, PolyTriangleThreadData* thread) uint32_t fogG = (int)((thread->mainVertexShader.Data.uFogColor.g) * 255.0f); uint32_t fogB = (int)((thread->mainVertexShader.Data.uFogColor.b) * 255.0f); float uFogDensity = thread->PushConstants->uFogDensity; - + float* w = thread->scanline.W; for (int x = x0; x < x1; x++) { diff --git a/src/common/rendering/r_thread.cpp b/src/common/rendering/r_thread.cpp index 09ecde78b..552418605 100644 --- a/src/common/rendering/r_thread.cpp +++ b/src/common/rendering/r_thread.cpp @@ -60,7 +60,7 @@ void DrawerThreads::Execute(DrawerCommandQueuePtr commands) { if (!commands || commands->commands.empty()) return; - + auto queue = Instance(); queue->StartThreads(); diff --git a/src/common/rendering/r_thread.h b/src/common/rendering/r_thread.h index f1e49d416..f8db730cd 100644 --- a/src/common/rendering/r_thread.h +++ b/src/common/rendering/r_thread.h @@ -156,17 +156,17 @@ public: static void WaitForWorkers(); static void ResetDebugDrawPos(); - + private: DrawerThreads(); ~DrawerThreads(); - + void StartThreads(); void StopThreads(); void WorkerMain(DrawerThread *thread); static DrawerThreads *Instance(); - + std::mutex threads_mutex; std::vector threads; @@ -182,7 +182,7 @@ private: size_t debug_draw_end = 0; DrawerThread single_core_thread; - + friend class DrawerCommandQueue; }; @@ -192,9 +192,9 @@ class DrawerCommandQueue { public: DrawerCommandQueue(RenderMemory *memoryAllocator); - + void Clear() { commands.clear(); } - + // Queue command to be executed by drawer worker threads template void Push(Types &&... args) @@ -212,13 +212,13 @@ public: command.Execute(&threads->single_core_thread); } } - + private: // Allocate memory valid for the duration of a command execution void *AllocMemory(size_t size); - + std::vector commands; RenderMemory *FrameMemory; - + friend class DrawerThreads; }; diff --git a/src/common/rendering/r_videoscale.cpp b/src/common/rendering/r_videoscale.cpp index c135a129b..705fe905f 100644 --- a/src/common/rendering/r_videoscale.cpp +++ b/src/common/rendering/r_videoscale.cpp @@ -125,7 +125,7 @@ namespace min_height = VID_MIN_UI_HEIGHT; } } - + // the odd formatting of this struct definition is meant to resemble a table header. set your tab stops to 4 when editing this file. struct v_ScaleTable { bool isValid; uint32_t(*GetScaledWidth)(uint32_t Width, uint32_t Height); uint32_t(*GetScaledHeight)(uint32_t Width, uint32_t Height); float pixelAspect; bool isCustom; }; @@ -178,7 +178,7 @@ bool ViewportLinearScale() aspectmult = 1.f / aspectmult; if ((ViewportScaledWidth(x,y) > (x * aspectmult)) || (ViewportScaledHeight(x,y) > (y * aspectmult))) return true; - + return vid_scale_linear; } diff --git a/src/common/rendering/v_video.cpp b/src/common/rendering/v_video.cpp index 7d8075c4f..9476bf6ab 100644 --- a/src/common/rendering/v_video.cpp +++ b/src/common/rendering/v_video.cpp @@ -219,13 +219,13 @@ void DCanvas::Resize(int width, int height, bool optimizepitch) { Width = width; Height = height; - + // Making the pitch a power of 2 is very bad for performance // Try to maximize the number of cache lines that can be filled // for each column drawing operation by making the pitch slightly // longer than the width. The values used here are all based on // empirical evidence. - + if (width <= 640 || !optimizepitch) { // For low resolutions, just keep the pitch the same as the width. @@ -337,15 +337,15 @@ void V_InitScreenSize () { const char *i; int width, height, bits; - + width = height = bits = 0; - + if ( (i = Args->CheckValue ("-width")) ) width = atoi (i); - + if ( (i = Args->CheckValue ("-height")) ) height = atoi (i); - + if (width == 0) { if (height == 0) diff --git a/src/common/rendering/v_video.h b/src/common/rendering/v_video.h index b78afd4b0..e5d79d881 100644 --- a/src/common/rendering/v_video.h +++ b/src/common/rendering/v_video.h @@ -151,7 +151,7 @@ public: int mPipelineNbr = 1; // Number of HW buffers to pipeline int mPipelineType = 0; - + public: DFrameBuffer (int width=1, int height=1); virtual ~DFrameBuffer(); @@ -219,7 +219,7 @@ public: virtual int GetClientWidth() = 0; virtual int GetClientHeight() = 0; virtual void BlurScene(float amount) {} - + // Interface to hardware rendering resources virtual IVertexBuffer *CreateVertexBuffer() { return nullptr; } virtual IIndexBuffer *CreateIndexBuffer() { return nullptr; } diff --git a/src/common/rendering/vulkan/shaders/vk_shader.cpp b/src/common/rendering/vulkan/shaders/vk_shader.cpp index df065e1ce..b1994eb2d 100644 --- a/src/common/rendering/vulkan/shaders/vk_shader.cpp +++ b/src/common/rendering/vulkan/shaders/vk_shader.cpp @@ -150,7 +150,7 @@ static const char *shaderBindings = R"( int useVertexData; vec4 uVertexColor; vec4 uVertexNormal; - + vec4 uGlowTopPlane; vec4 uGlowTopColor; vec4 uGlowBottomPlane; diff --git a/src/common/rendering/vulkan/textures/vk_samplers.cpp b/src/common/rendering/vulkan/textures/vk_samplers.cpp index adc6dd2b4..06e105aed 100644 --- a/src/common/rendering/vulkan/textures/vk_samplers.cpp +++ b/src/common/rendering/vulkan/textures/vk_samplers.cpp @@ -82,7 +82,7 @@ void VkSamplerManager::SetTextureFilterMode() void VkSamplerManager::Create() { int filter = sysCallbacks.DisableTextureFilter && sysCallbacks.DisableTextureFilter()? 0 : gl_texture_filter; - + for (int i = CLAMP_NONE; i <= CLAMP_XY; i++) { SamplerBuilder builder; diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index 1bcd1fa41..a35ceea27 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -1964,7 +1964,7 @@ ExpEmit FxUnaryNotBitwise::Emit(VMFunctionBuilder *build) from.Free(build); ExpEmit to(build, REGT_INT); assert(!from.Konst); - + build->Emit(OP_NOT, to.RegNum, from.RegNum, 0); return to; } @@ -2746,7 +2746,7 @@ FxExpression *FxAddSub::Resolve(FCompileContext& ctx) delete this; return nullptr; } - + if (compileEnvironment.CheckForCustomAddition) { auto result = compileEnvironment.CheckForCustomAddition(this, ctx); @@ -2756,7 +2756,7 @@ FxExpression *FxAddSub::Resolve(FCompileContext& ctx) goto goon; } } - + if (left->ValueType == TypeTextureID && right->IsInteger()) { ValueType = TypeTextureID; @@ -5125,10 +5125,10 @@ ExpEmit FxNew::Emit(VMFunctionBuilder *build) // Call DecoRandom to generate a random number. VMFunction *callfunc; auto sym = FindBuiltinFunction(compileEnvironment.CustomBuiltinNew != NAME_None? compileEnvironment.CustomBuiltinNew : NAME_BuiltinNew); - + assert(sym); callfunc = sym->Variants[0].Implementation; - + FunctionCallEmitter emitters(callfunc); int outerside = -1; @@ -5886,7 +5886,7 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx) { PSymbol * sym; FxExpression *newex = nullptr; - + CHECKRESOLVED(); // Local variables have highest priority. @@ -6038,7 +6038,7 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx) deprecationMessage.IsEmpty() ? "" : ", ", deprecationMessage.GetChars()); } } - + newex = new FxGlobalVariable(static_cast(sym), ScriptPosition); goto foundit; @@ -6068,7 +6068,7 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx) newex = new FxCVar(cvar, ScriptPosition); goto foundit; } - + ScriptPosition.Message(MSG_ERROR, "Unknown identifier '%s'", Identifier.GetChars()); delete this; return nullptr; @@ -6406,7 +6406,7 @@ bool FxLocalVariable::RequestAddress(FCompileContext &ctx, bool *writable) if (writable != nullptr) *writable = !ctx.CheckWritable(Variable->VarFlags); return true; } - + ExpEmit FxLocalVariable::Emit(VMFunctionBuilder *build) { // 'Out' variables are actually pointers but this fact must be hidden to the script. @@ -6771,7 +6771,7 @@ FxExpression *FxStackVariable::Resolve(FCompileContext &ctx) ExpEmit FxStackVariable::Emit(VMFunctionBuilder *build) { int offsetreg = -1; - + if (membervar->Offset != 0) offsetreg = build->GetConstantInt((int)membervar->Offset); if (AddressRequested) @@ -6963,7 +6963,7 @@ FxExpression *FxStructMember::Resolve(FCompileContext &ctx) { locvar->RegOffset = int(membervar->Offset); } - + locvar->ValueType = membervar->Type; classx = nullptr; delete this; @@ -7245,7 +7245,7 @@ FxExpression *FxArrayElement::Resolve(FCompileContext &ctx) ExpEmit FxArrayElement::Emit(VMFunctionBuilder *build) { PArray *arraytype; - + if (arrayispointer) { auto ptr = Array->ValueType->toPointer(); @@ -7267,7 +7267,7 @@ ExpEmit FxArrayElement::Emit(VMFunctionBuilder *build) ExpEmit start; ExpEmit bound; bool nestedarray = false; - + if (SizeAddr != ~0u) { bool ismeta = Array->ExprType == EFX_ClassMember && static_cast(Array)->membervar->Flags & VARF_Meta; @@ -7669,7 +7669,7 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx) return x->Resolve(ctx); } } - + if (compileEnvironment.CheckCustomGlobalFunctions) { auto result = compileEnvironment.CheckCustomGlobalFunctions(this, ctx); @@ -8508,7 +8508,7 @@ VMFunction *FxVMFunctionCall::GetDirectFunction(PFunction *callingfunc, const Ve if (Function->Variants[0].ArgFlags.Size() > imp && !(Function->Variants[0].ArgFlags[imp] & VARF_Optional)) return nullptr; return Function->Variants[0].Implementation; } - + return nullptr; } @@ -8567,7 +8567,7 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx) delete this; return nullptr; } - + bool foundvarargs = false; PType * type = nullptr; int flag = 0; @@ -10509,7 +10509,7 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) delete this; return nullptr; } - + if (basex->ValueType != TypeName && basex->ValueType != TypeString) { ScriptPosition.Message(MSG_ERROR, "Cannot convert %s to class type", basex->ValueType->DescriptiveName()); @@ -10526,7 +10526,7 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) { if (Explicit) cls = FindClassType(clsname, ctx); else cls = PClass::FindClass(clsname); - + if (cls == nullptr || cls->VMType == nullptr) { /* lax */ @@ -10761,7 +10761,7 @@ FxExpression *FxLocalVariableDeclaration::Resolve(FCompileContext &ctx) { auto sfunc = static_cast(ctx.Function->Variants[0].Implementation); StackOffset = sfunc->AllocExtraStack(ValueType); - + if (Init != nullptr) { ScriptPosition.Message(MSG_ERROR, "Cannot initialize non-scalar variable %s here", Name.GetChars()); @@ -11203,7 +11203,7 @@ ExpEmit FxLocalArrayDeclaration::Emit(VMFunctionBuilder *build) break; } build->Registers[regtype].Return(regNum, 1); - + emitval.Free(build); } else diff --git a/src/common/scripting/backend/codegen.h b/src/common/scripting/backend/codegen.h index ac5f058ab..43fb7f061 100644 --- a/src/common/scripting/backend/codegen.h +++ b/src/common/scripting/backend/codegen.h @@ -206,7 +206,7 @@ struct ExpVal int regtype = Type->GetRegType(); return regtype == REGT_INT ? !!Int : regtype == REGT_FLOAT ? Float!=0. : false; } - + FName GetName() const { if (Type == TypeString) @@ -325,7 +325,7 @@ protected: public: virtual ~FxExpression() {} virtual FxExpression *Resolve(FCompileContext &ctx); - + virtual bool isConstant() const; virtual bool RequestAddress(FCompileContext &ctx, bool *writable); virtual PPrototype *ReturnProto(); @@ -525,7 +525,7 @@ public: } ValueType = value.Type = type; } - + static FxExpression *MakeConstant(PSymbol *sym, const FScriptPosition &pos); bool isConstant() const @@ -1864,7 +1864,7 @@ protected: : FxExpression(etype, pos) { } - + void Backpatch(VMFunctionBuilder *build, size_t loopstart, size_t loopend); FxExpression *Resolve(FCompileContext&) final; virtual FxExpression *DoResolve(FCompileContext&) = 0; diff --git a/src/common/scripting/backend/vmbuilder.cpp b/src/common/scripting/backend/vmbuilder.cpp index 4c1401e8e..1624aa42f 100644 --- a/src/common/scripting/backend/vmbuilder.cpp +++ b/src/common/scripting/backend/vmbuilder.cpp @@ -398,7 +398,7 @@ int VMFunctionBuilder::RegAvailability::Get(int count) { return -1; } - + mask = count == 32 ? ~0u : (1 << count) - 1; for (i = 0; i < 256 / 32; ++i) diff --git a/src/common/scripting/core/dynarrays.cpp b/src/common/scripting/core/dynarrays.cpp index 583bbd647..8c51daa94 100644 --- a/src/common/scripting/core/dynarrays.cpp +++ b/src/common/scripting/core/dynarrays.cpp @@ -130,7 +130,7 @@ template<> unsigned int ArrayReserve(TArray *self, int amount) if (fillCount > 0) memset(&(*self)[oldSize], 0, sizeof(DObject*) * fillCount); - + return oldSize; } diff --git a/src/common/scripting/core/scopebarrier.h b/src/common/scripting/core/scopebarrier.h index fb931d223..b5eeae78f 100644 --- a/src/common/scripting/core/scopebarrier.h +++ b/src/common/scripting/core/scopebarrier.h @@ -46,7 +46,7 @@ struct FScopeBarrier // static int FlagsFromSide(int side); static EScopeFlags ObjectFlagsFromSide(int side); - + // used for errors static const char* StringFromSide(int side); diff --git a/src/common/scripting/core/types.cpp b/src/common/scripting/core/types.cpp index 3fb97cb32..c98cc7435 100644 --- a/src/common/scripting/core/types.cpp +++ b/src/common/scripting/core/types.cpp @@ -410,7 +410,7 @@ bool PContainerType::IsMatch(intptr_t id1, intptr_t id2) const { const PTypeBase *outer = (const PTypeBase *)id1; FName name = (ENamedName)(intptr_t)id2; - + return Outer == outer && TypeName == name; } diff --git a/src/common/scripting/frontend/zcc_compile.cpp b/src/common/scripting/frontend/zcc_compile.cpp index c34039e12..8fc0bbe24 100644 --- a/src/common/scripting/frontend/zcc_compile.cpp +++ b/src/common/scripting/frontend/zcc_compile.cpp @@ -1069,7 +1069,7 @@ void ZCCCompiler::AddConstant(ZCC_ConstantWork &constant) auto def = constant.node; auto val = def->Value; ExpVal &c = constant.constval; - + // This is for literal constants. if (val->NodeType == AST_ExprConstant) { @@ -1364,7 +1364,7 @@ void ZCCCompiler::CompileAllFields() for (unsigned i = 0; i < Classes.Size(); i++) { auto type = Classes[i]->ClassType(); - + if (type->Size == TentativeClass) { if (type->ParentClass->Size == TentativeClass) @@ -1528,7 +1528,7 @@ bool ZCCCompiler::CompileFields(PContainerType *type, TArrayFindSymbol(type->UserType->Id, true); if (sym == nullptr) sym = OutNamespace->Symbols.FindSymbol(type->UserType->Id, true); @@ -2244,7 +2244,7 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool flags |= VARF_Optional; hasoptionals = true; - + if ((varflags & VARF_Override) && !overridemsg) { // This is illegal, but in older compilers wasn't checked, so there it has to be demoted to a warning. @@ -2465,11 +2465,11 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool sym->Variants[0].Flags |= VARF_ReadOnly; if (oldfunc->VarFlags & VARF_Protected) sym->Variants[0].Flags |= VARF_Protected; - + clstype->Virtuals[virtindex] = sym->Variants[0].Implementation; sym->Variants[0].Implementation->VirtualIndex = virtindex; sym->Variants[0].Implementation->VarFlags = sym->Variants[0].Flags; - + // Defaults must be identical to parent class if (parentfunc->Variants[0].Implementation->DefaultArgs.Size() > 0) { @@ -3112,7 +3112,7 @@ FxExpression *ZCCCompiler::ConvertImplicitScopeNode(ZCC_TreeNode *node, ZCC_Stat { return nullptr; } - + FxExpression *nestedExpr = ConvertNode(nested); assert(nullptr != nestedExpr); diff --git a/src/common/scripting/frontend/zcc_compile.h b/src/common/scripting/frontend/zcc_compile.h index ca19d8aff..ca1beb3f2 100644 --- a/src/common/scripting/frontend/zcc_compile.h +++ b/src/common/scripting/frontend/zcc_compile.h @@ -140,7 +140,7 @@ protected: void InitFunctions(); virtual void InitDefaults(); - + TArray Constants; TArray Structs; TArray Classes; diff --git a/src/common/scripting/frontend/zcc_parser.cpp b/src/common/scripting/frontend/zcc_parser.cpp index 0d1928653..1ac9342aa 100644 --- a/src/common/scripting/frontend/zcc_parser.cpp +++ b/src/common/scripting/frontend/zcc_parser.cpp @@ -1267,7 +1267,7 @@ ZCC_TreeNode *TreeNodeDeepCopy_Internal(ZCC_AST *ast, ZCC_TreeNode *orig, bool c break; } - + case AST_ClassCast: { TreeNodeDeepCopy_Start(ClassCast); diff --git a/src/common/scripting/jit/jit_call.cpp b/src/common/scripting/jit/jit_call.cpp index ee35fc139..83808c0ed 100644 --- a/src/common/scripting/jit/jit_call.cpp +++ b/src/common/scripting/jit/jit_call.cpp @@ -340,7 +340,7 @@ void JitCompiler::EmitNativeCall(VMNativeFunction *target) I_Error("Unexpected register type for self pointer\n"); break; } - + cc.test(*reg, *reg); cc.jz(label); } diff --git a/src/common/scripting/jit/jit_flow.cpp b/src/common/scripting/jit/jit_flow.cpp index 8439481cf..6157bf340 100644 --- a/src/common/scripting/jit/jit_flow.cpp +++ b/src/common/scripting/jit/jit_flow.cpp @@ -7,7 +7,7 @@ void JitCompiler::EmitTEST() cc.cmp(regD[A], BC); cc.jne(GetLabel(i + 2)); } - + void JitCompiler::EmitTESTN() { int bc = BC; diff --git a/src/common/scripting/jit/jit_math.cpp b/src/common/scripting/jit/jit_math.cpp index d2fb45c7d..ea9402594 100644 --- a/src/common/scripting/jit/jit_math.cpp +++ b/src/common/scripting/jit/jit_math.cpp @@ -902,7 +902,7 @@ void JitCompiler::EmitMINF_RK() cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp)); cc.minpd(regF[A], rb); // minsd requires SSE 4.1 } - + void JitCompiler::EmitMAXF_RR() { auto rc = CheckRegF(C, A); @@ -919,7 +919,7 @@ void JitCompiler::EmitMAXF_RK() cc.movsd(regF[A], asmjit::x86::qword_ptr(tmp)); cc.maxpd(regF[A], rb); // maxsd requires SSE 4.1 } - + void JitCompiler::EmitATAN2() { auto result = newResultXmmSd(); @@ -1441,7 +1441,7 @@ void JitCompiler::EmitEQV3_R() EmitVectorComparison<3> (check, fail, success); }); } - + void JitCompiler::EmitEQV3_K() { I_Error("EQV3_K is not used."); diff --git a/src/common/scripting/jit/jit_runtime.cpp b/src/common/scripting/jit/jit_runtime.cpp index 73dd40702..647647442 100644 --- a/src/common/scripting/jit/jit_runtime.cpp +++ b/src/common/scripting/jit/jit_runtime.cpp @@ -403,7 +403,7 @@ static void WriteCIE(TArray &stream, const TArray &cieInstruct unsigned int lengthPos = stream.Size(); WriteUInt32(stream, 0); // Length WriteUInt32(stream, 0); // CIE ID - + WriteUInt8(stream, 1); // CIE Version WriteUInt8(stream, 'z'); WriteUInt8(stream, 'R'); // fde encoding @@ -428,7 +428,7 @@ static void WriteFDE(TArray &stream, const TArray &fdeInstruct WriteUInt32(stream, 0); // Length uint32_t offsetToCIE = stream.Size() - cieLocation; WriteUInt32(stream, offsetToCIE); - + functionStart = stream.Size(); WriteUInt64(stream, 0); // func start WriteUInt64(stream, 0); // func size @@ -499,7 +499,7 @@ static TArray CreateUnwindInfoUnix(asmjit::CCFunc *func, unsigned int & // // The CFI_Parser::decodeFDE parser on the other side.. // https://github.com/llvm-mirror/libunwind/blob/master/src/DwarfParser.hpp - + // Asmjit -> DWARF register id int dwarfRegId[16]; dwarfRegId[X86Gp::kIdAx] = 0; @@ -520,7 +520,7 @@ static TArray CreateUnwindInfoUnix(asmjit::CCFunc *func, unsigned int & dwarfRegId[X86Gp::kIdR15] = 15; int dwarfRegRAId = 16; int dwarfRegXmmId = 17; - + TArray cieInstructions; TArray fdeInstructions; @@ -529,7 +529,7 @@ static TArray CreateUnwindInfoUnix(asmjit::CCFunc *func, unsigned int & WriteDefineCFA(cieInstructions, dwarfRegId[X86Gp::kIdSp], stackOffset); WriteRegisterStackLocation(cieInstructions, returnAddressReg, stackOffset); - + FuncFrameLayout layout; Error error = layout.init(func->getDetail(), func->getFrameInfo()); if (error != kErrorOk) @@ -702,7 +702,7 @@ void *AddJitFunction(asmjit::CodeHolder* code, JitCompiler *compiler) uint64_t length64 = *((uint64_t *)(entry + 4)); if (length64 == 0) break; - + uint64_t offset = *((uint64_t *)(entry + 12)); if (offset != 0) { diff --git a/src/common/scripting/vm/vmexec.h b/src/common/scripting/vm/vmexec.h index baff63b8c..a4d666dcc 100644 --- a/src/common/scripting/vm/vmexec.h +++ b/src/common/scripting/vm/vmexec.h @@ -515,7 +515,7 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret) DoCast(reg, f, a, B, C); } NEXTOP; - + OP(CASTB): if (C == CASTB_I) { @@ -538,7 +538,7 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret) reg.d[a] = reg.s[B].Len() > 0; } NEXTOP; - + OP(TEST): ASSERTD(a); if (reg.d[a] != BC) @@ -852,7 +852,7 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret) ASSERTD(a); ASSERTS(B); reg.d[a] = (int)reg.s[B].Len(); NEXTOP; - + OP(CMPS): // String comparison is a fairly expensive operation, so I've // chosen to conserve a few opcodes by condensing all the @@ -1347,7 +1347,7 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret) fb = reg.f[B]; reg.f[a] = (C == FLOP_ABS) ? fabs(fb) : (C == FLOP_NEG) ? -fb : DoFLOP(C, fb); NEXTOP; - + OP(EQF_R): ASSERTF(B); ASSERTF(C); if (a & CMP_APPROX) diff --git a/src/common/statusbar/base_sbar.h b/src/common/statusbar/base_sbar.h index 9b1204412..972cbf0df 100644 --- a/src/common/statusbar/base_sbar.h +++ b/src/common/statusbar/base_sbar.h @@ -131,7 +131,7 @@ class DStatusBarCore : public DObject DECLARE_CLASS(DStatusBarCore, DObject) protected: - + public: diff --git a/src/common/textures/animlib.cpp b/src/common/textures/animlib.cpp index c712ae2bf..e42386bd9 100644 --- a/src/common/textures/animlib.cpp +++ b/src/common/textures/animlib.cpp @@ -44,38 +44,38 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) static inline uint16_t findpage(anim_t *anim, uint16_t framenumber) { - // curlpnum is initialized to 0xffff, obviously - size_t i = anim->curlpnum & ~0xffff; - size_t const nLps = anim->lpheader->nLps; - bool j = true; + // curlpnum is initialized to 0xffff, obviously + size_t i = anim->curlpnum & ~0xffff; + size_t const nLps = anim->lpheader->nLps; + bool j = true; - if (framenumber < anim->currentframe) - i = 0, j = false; + if (framenumber < anim->currentframe) + i = 0, j = false; - // this scans the last used page and higher first and then scans the - // previously accessed pages afterwards if it doesn't find anything - do - { - for (; i < nLps; ++i) - { - lp_descriptor & lp = anim->LpArray[i]; - if (lp.baseRecord <= framenumber && framenumber < lp.baseRecord + lp.nRecords) - return (uint16_t)i; - } + // this scans the last used page and higher first and then scans the + // previously accessed pages afterwards if it doesn't find anything + do + { + for (; i < nLps; ++i) + { + lp_descriptor & lp = anim->LpArray[i]; + if (lp.baseRecord <= framenumber && framenumber < lp.baseRecord + lp.nRecords) + return (uint16_t)i; + } - if (j && i == nLps) - { - // handle out of order pages... I don't think any Duke .ANM files - // have them, but they're part of the file spec - i = 0, j = false; - continue; - } + if (j && i == nLps) + { + // handle out of order pages... I don't think any Duke .ANM files + // have them, but they're part of the file spec + i = 0, j = false; + continue; + } - break; - } - while (1); + break; + } + while (1); - return (uint16_t)i; + return (uint16_t)i; } @@ -88,13 +88,13 @@ static inline uint16_t findpage(anim_t *anim, uint16_t framenumber) static inline void loadpage(anim_t *anim, uint16_t pagenumber, uint16_t **pagepointer) { - if (anim->curlpnum == pagenumber) - return; + if (anim->curlpnum == pagenumber) + return; - anim->curlpnum = pagenumber; - anim->curlp = &anim->LpArray[pagenumber]; - *pagepointer = (uint16_t *)(anim->buffer + 0xb00 + (pagenumber*IMAGEBUFFERSIZE) + - sizeof(lp_descriptor) + sizeof(uint16_t)); + anim->curlpnum = pagenumber; + anim->curlp = &anim->LpArray[pagenumber]; + *pagepointer = (uint16_t *)(anim->buffer + 0xb00 + (pagenumber*IMAGEBUFFERSIZE) + + sizeof(lp_descriptor) + sizeof(uint16_t)); } @@ -114,63 +114,63 @@ static inline void loadpage(anim_t *anim, uint16_t pagenumber, uint16_t **pagepo static void decodeframe(uint8_t * srcP, uint8_t * dstP) { - do - { - { - /* short op */ - uint8_t count = *srcP++; + do + { + { + /* short op */ + uint8_t count = *srcP++; - if (!count) /* short RLE */ - { - uint8_t color = *(srcP+1); - count = *(uint8_t *)srcP; - srcP += sizeof(int16_t); - memset(dstP, color, count); - dstP += count; - continue; - } - else if ((count & 0x80) == 0) /* short copy */ - { - memcpy(dstP, srcP, count); - dstP += count; - srcP += count; - continue; - } - else if ((count &= ~0x80) > 0) /* short skip */ - { - dstP += count; - continue; - } - } + if (!count) /* short RLE */ + { + uint8_t color = *(srcP+1); + count = *(uint8_t *)srcP; + srcP += sizeof(int16_t); + memset(dstP, color, count); + dstP += count; + continue; + } + else if ((count & 0x80) == 0) /* short copy */ + { + memcpy(dstP, srcP, count); + dstP += count; + srcP += count; + continue; + } + else if ((count &= ~0x80) > 0) /* short skip */ + { + dstP += count; + continue; + } + } - { - /* long op */ - uint16_t count = LittleShort((uint16_t)GetShort(srcP)); - srcP += sizeof(int16_t); + { + /* long op */ + uint16_t count = LittleShort((uint16_t)GetShort(srcP)); + srcP += sizeof(int16_t); - if (!count) /* stop sign */ - return; - else if ((count & 0x8000) == 0) /* long skip */ - { - dstP += count; - continue; - } - else if ((count &= ~0x8000) & 0x4000) /* long RLE */ - { - uint8_t color = *srcP++; - count &= ~0x4000; - memset(dstP, color, count); - dstP += count; - continue; - } + if (!count) /* stop sign */ + return; + else if ((count & 0x8000) == 0) /* long skip */ + { + dstP += count; + continue; + } + else if ((count &= ~0x8000) & 0x4000) /* long RLE */ + { + uint8_t color = *srcP++; + count &= ~0x4000; + memset(dstP, color, count); + dstP += count; + continue; + } - /* long copy */ - memcpy(dstP, srcP, count); - dstP += count; - srcP += count; - } - } - while (1); + /* long copy */ + memcpy(dstP, srcP, count); + dstP += count; + srcP += count; + } + } + while (1); } @@ -183,23 +183,23 @@ static void decodeframe(uint8_t * srcP, uint8_t * dstP) static void renderframe(anim_t *anim, uint16_t framenumber, uint16_t *pagepointer) { - uint16_t offset = 0; - uint16_t frame = framenumber - anim->curlp->baseRecord; + uint16_t offset = 0; + uint16_t frame = framenumber - anim->curlp->baseRecord; - while (frame--) offset += LittleShort(pagepointer[frame]); + while (frame--) offset += LittleShort(pagepointer[frame]); if (offset >= anim->curlp->nBytes) return; - uint8_t *ppointer = (uint8_t *)(pagepointer) + anim->curlp->nRecords*2 + offset + 4; + uint8_t *ppointer = (uint8_t *)(pagepointer) + anim->curlp->nRecords*2 + offset + 4; - if ((ppointer-4)[1]) - { - uint16_t const temp = LittleShort(((uint16_t *)(ppointer-4))[1]); - ppointer += temp + (temp & 1); - } + if ((ppointer-4)[1]) + { + uint16_t const temp = LittleShort(((uint16_t *)(ppointer-4))[1]); + ppointer += temp + (temp & 1); + } - decodeframe((uint8_t *)ppointer, (uint8_t *)anim->imagebuffer); + decodeframe((uint8_t *)ppointer, (uint8_t *)anim->imagebuffer); } @@ -212,79 +212,79 @@ static void renderframe(anim_t *anim, uint16_t framenumber, uint16_t *pagepointe static inline void drawframe(anim_t *anim, uint16_t framenumber) { - loadpage(anim, findpage(anim, framenumber), &anim->thepage); - renderframe(anim, framenumber, anim->thepage); + loadpage(anim, findpage(anim, framenumber), &anim->thepage); + renderframe(anim, framenumber, anim->thepage); } // is the file size, for consistency checking. int32_t ANIM_LoadAnim(anim_t *anim, uint8_t *buffer, int32_t length) { - if (memcmp(buffer, "LPF ", 4)) return -1; + if (memcmp(buffer, "LPF ", 4)) return -1; - length -= sizeof(lpfileheader)+128+768; - if (length < 0) - return -1; + length -= sizeof(lpfileheader)+128+768; + if (length < 0) + return -1; - anim->curlpnum = 0xffff; - anim->currentframe = -1; + anim->curlpnum = 0xffff; + anim->currentframe = -1; - // this just modifies the data in-place instead of copying it elsewhere now - lpfileheader & lpheader = *(anim->lpheader = (lpfileheader *)(anim->buffer = buffer)); + // this just modifies the data in-place instead of copying it elsewhere now + lpfileheader & lpheader = *(anim->lpheader = (lpfileheader *)(anim->buffer = buffer)); - lpheader.id = LittleLong(lpheader.id); - lpheader.maxLps = LittleShort(lpheader.maxLps); - lpheader.nLps = LittleShort(lpheader.nLps); - lpheader.nRecords = LittleLong(lpheader.nRecords); - lpheader.maxRecsPerLp = LittleShort(lpheader.maxRecsPerLp); - lpheader.lpfTableOffset = LittleShort(lpheader.lpfTableOffset); - lpheader.contentType = LittleLong(lpheader.contentType); - lpheader.width = LittleShort(lpheader.width); - lpheader.height = LittleShort(lpheader.height); - lpheader.nFrames = LittleLong(lpheader.nFrames); - lpheader.framesPerSecond = LittleShort(lpheader.framesPerSecond); + lpheader.id = LittleLong(lpheader.id); + lpheader.maxLps = LittleShort(lpheader.maxLps); + lpheader.nLps = LittleShort(lpheader.nLps); + lpheader.nRecords = LittleLong(lpheader.nRecords); + lpheader.maxRecsPerLp = LittleShort(lpheader.maxRecsPerLp); + lpheader.lpfTableOffset = LittleShort(lpheader.lpfTableOffset); + lpheader.contentType = LittleLong(lpheader.contentType); + lpheader.width = LittleShort(lpheader.width); + lpheader.height = LittleShort(lpheader.height); + lpheader.nFrames = LittleLong(lpheader.nFrames); + lpheader.framesPerSecond = LittleShort(lpheader.framesPerSecond); - length -= lpheader.nLps * sizeof(lp_descriptor); - if (length < 0) - return -2; + length -= lpheader.nLps * sizeof(lp_descriptor); + if (length < 0) + return -2; - buffer += sizeof(lpfileheader)+128; + buffer += sizeof(lpfileheader)+128; - // load the color palette - for (uint8_t * pal = anim->pal, * pal_end = pal+768; pal < pal_end; pal += 3, buffer += 4) - { - pal[2] = buffer[0]; - pal[1] = buffer[1]; - pal[0] = buffer[2]; - } + // load the color palette + for (uint8_t * pal = anim->pal, * pal_end = pal+768; pal < pal_end; pal += 3, buffer += 4) + { + pal[2] = buffer[0]; + pal[1] = buffer[1]; + pal[0] = buffer[2]; + } - // set up large page descriptors - anim->LpArray = (lp_descriptor *)buffer; + // set up large page descriptors + anim->LpArray = (lp_descriptor *)buffer; - // theoretically we should be able to play files with more than 256 frames now - // assuming the utilities to create them can make them that way - for (lp_descriptor * lp = anim->LpArray, * lp_end = lp+lpheader.nLps; lp < lp_end; ++lp) - { - lp->baseRecord = LittleShort(lp->baseRecord); - lp->nRecords = LittleShort(lp->nRecords); - lp->nBytes = LittleShort(lp->nBytes); - } - return ANIM_NumFrames(anim) <= 0 ? -1 : 0; + // theoretically we should be able to play files with more than 256 frames now + // assuming the utilities to create them can make them that way + for (lp_descriptor * lp = anim->LpArray, * lp_end = lp+lpheader.nLps; lp < lp_end; ++lp) + { + lp->baseRecord = LittleShort(lp->baseRecord); + lp->nRecords = LittleShort(lp->nRecords); + lp->nBytes = LittleShort(lp->nBytes); + } + return ANIM_NumFrames(anim) <= 0 ? -1 : 0; } uint8_t * ANIM_DrawFrame(anim_t *anim, int32_t framenumber) { - uint32_t cnt = anim->currentframe; + uint32_t cnt = anim->currentframe; - // handle first play and looping or rewinding - if (cnt > (uint32_t)framenumber) - cnt = 0; + // handle first play and looping or rewinding + if (cnt > (uint32_t)framenumber) + cnt = 0; - do drawframe(anim, cnt++); - while (cnt < (uint32_t)framenumber); + do drawframe(anim, cnt++); + while (cnt < (uint32_t)framenumber); - anim->currentframe = framenumber; - return anim->imagebuffer; + anim->currentframe = framenumber; + return anim->imagebuffer; } diff --git a/src/common/textures/animlib.h b/src/common/textures/animlib.h index dd9415aa4..23d0d89da 100644 --- a/src/common/textures/animlib.h +++ b/src/common/textures/animlib.h @@ -45,37 +45,37 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) struct lpfileheader { - uint32_t id; /* 4 uint8_tacter ID == "LPF " */ - uint16_t maxLps; /* max # largePages allowed. 256 FOR NOW. */ - uint16_t nLps; /* # largePages in this file. */ - uint32_t nRecords; /* # records in this file. 65534 is current limit + ring */ - uint16_t maxRecsPerLp; /* # records permitted in an lp. 256 FOR NOW. */ - uint16_t lpfTableOffset; /* Absolute Seek position of lpfTable. 1280 FOR NOW. */ - uint32_t contentType; /* 4 character ID == "ANIM" */ - uint16_t width; /* Width of screen in pixels. */ - uint16_t height; /* Height of screen in pixels. */ - uint8_t variant; /* 0==ANIM. */ - uint8_t version; /* 0==frame rate in 18/sec, 1= 70/sec */ - uint8_t hasLastDelta; /* 1==Last record is a delta from last-to-first frame. */ - uint8_t lastDeltaValid; /* 0==Ignore ring frame. */ - uint8_t pixelType; /* 0==256 color. */ - uint8_t CompressionType; /* 1==(RunSkipDump) Only one used FOR NOW. */ - uint8_t otherRecsPerFrm; /* 0 FOR NOW. */ - uint8_t bitmaptype; /* 1==320x200, 256-color. Only one implemented so far. */ - uint8_t recordTypes[32]; /* Not yet implemented. */ - uint32_t nFrames; /* Number of actual frames in the file, includes ring frame. */ - uint16_t framesPerSecond; /* Number of frames to play per second. */ - uint16_t pad2[29]; /* 58 bytes of filler to round up to 128 bytes total. */ + uint32_t id; /* 4 uint8_tacter ID == "LPF " */ + uint16_t maxLps; /* max # largePages allowed. 256 FOR NOW. */ + uint16_t nLps; /* # largePages in this file. */ + uint32_t nRecords; /* # records in this file. 65534 is current limit + ring */ + uint16_t maxRecsPerLp; /* # records permitted in an lp. 256 FOR NOW. */ + uint16_t lpfTableOffset; /* Absolute Seek position of lpfTable. 1280 FOR NOW. */ + uint32_t contentType; /* 4 character ID == "ANIM" */ + uint16_t width; /* Width of screen in pixels. */ + uint16_t height; /* Height of screen in pixels. */ + uint8_t variant; /* 0==ANIM. */ + uint8_t version; /* 0==frame rate in 18/sec, 1= 70/sec */ + uint8_t hasLastDelta; /* 1==Last record is a delta from last-to-first frame. */ + uint8_t lastDeltaValid; /* 0==Ignore ring frame. */ + uint8_t pixelType; /* 0==256 color. */ + uint8_t CompressionType; /* 1==(RunSkipDump) Only one used FOR NOW. */ + uint8_t otherRecsPerFrm; /* 0 FOR NOW. */ + uint8_t bitmaptype; /* 1==320x200, 256-color. Only one implemented so far. */ + uint8_t recordTypes[32]; /* Not yet implemented. */ + uint32_t nFrames; /* Number of actual frames in the file, includes ring frame. */ + uint16_t framesPerSecond; /* Number of frames to play per second. */ + uint16_t pad2[29]; /* 58 bytes of filler to round up to 128 bytes total. */ }; // this is the format of a large page structure struct lp_descriptor { - uint16_t baseRecord; // Number of first record in this large page. - uint16_t nRecords; // Number of records in lp. - // bit 15 of "nRecords" == "has continuation from previous lp". - // bit 14 of "nRecords" == "final record continues on next lp". - uint16_t nBytes; // Total number of bytes of contents, excluding header. + uint16_t baseRecord; // Number of first record in this large page. + uint16_t nRecords; // Number of records in lp. + // bit 15 of "nRecords" == "has continuation from previous lp". + // bit 14 of "nRecords" == "final record continues on next lp". + uint16_t nBytes; // Total number of bytes of contents, excluding header. }; #pragma pack(pop) @@ -84,16 +84,16 @@ struct lp_descriptor struct anim_t { - uint16_t framecount; // current frame of anim - lpfileheader * lpheader; // file header will be loaded into this structure - lp_descriptor * LpArray; // arrays of large page structs used to find frames - uint16_t curlpnum; // initialize to an invalid Large page number - lp_descriptor * curlp; // header of large page currently in memory - uint16_t * thepage; // buffer where current large page is loaded - uint8_t imagebuffer[IMAGEBUFFERSIZE]; // buffer where anim frame is decoded - uint8_t * buffer; - uint8_t pal[768]; - int32_t currentframe; + uint16_t framecount; // current frame of anim + lpfileheader * lpheader; // file header will be loaded into this structure + lp_descriptor * LpArray; // arrays of large page structs used to find frames + uint16_t curlpnum; // initialize to an invalid Large page number + lp_descriptor * curlp; // header of large page currently in memory + uint16_t * thepage; // buffer where current large page is loaded + uint8_t imagebuffer[IMAGEBUFFERSIZE]; // buffer where anim frame is decoded + uint8_t * buffer; + uint8_t pal[768]; + int32_t currentframe; }; //**************************************************************************** @@ -116,7 +116,7 @@ int32_t ANIM_LoadAnim(anim_t *anim, uint8_t *buffer, int32_t length); inline int32_t ANIM_NumFrames(anim_t* anim) { - return anim->lpheader->nRecords; + return anim->lpheader->nRecords; } //**************************************************************************** @@ -138,7 +138,7 @@ uint8_t * ANIM_DrawFrame(anim_t* anim, int32_t framenumber); inline uint8_t* ANIM_GetPalette(anim_t* anim) { - return anim->pal; + return anim->pal; } #endif diff --git a/src/common/textures/animtexture.cpp b/src/common/textures/animtexture.cpp index 039021641..a3be03079 100644 --- a/src/common/textures/animtexture.cpp +++ b/src/common/textures/animtexture.cpp @@ -44,42 +44,42 @@ void AnimTexture::SetFrameSize(int format, int width, int height) { - pixelformat = format; - FTexture::SetSize(width, height); - Image.Resize(width * height * (format == Paletted ? 1 : 3)); - memset(Image.Data(), 0, Image.Size()); + pixelformat = format; + FTexture::SetSize(width, height); + Image.Resize(width * height * (format == Paletted ? 1 : 3)); + memset(Image.Data(), 0, Image.Size()); } void AnimTexture::SetFrame(const uint8_t* palette, const void* data_) { - if (palette) memcpy(Palette, palette, 768); - if (data_) - { - if (pixelformat == YUV) - { - auto spix = (const uint8_t*)data_; - auto dpix = Image.Data(); - for (int i = 0; i < Width * Height; i++) - { - int p = i * 4; - int q = i * 3; - float y = spix[p] * (1 / 255.f); - float u = spix[p + 1] * (1 / 255.f) - 0.5f; - float v = spix[p + 2] * (1 / 255.f) - 0.5f; + if (palette) memcpy(Palette, palette, 768); + if (data_) + { + if (pixelformat == YUV) + { + auto spix = (const uint8_t*)data_; + auto dpix = Image.Data(); + for (int i = 0; i < Width * Height; i++) + { + int p = i * 4; + int q = i * 3; + float y = spix[p] * (1 / 255.f); + float u = spix[p + 1] * (1 / 255.f) - 0.5f; + float v = spix[p + 2] * (1 / 255.f) - 0.5f; - y = 1.1643f * (y - 0.0625f); + y = 1.1643f * (y - 0.0625f); - float r = y + 1.5958f * v; - float g = y - 0.39173f * u - 0.81290f * v; - float b = y + 2.017f * u; + float r = y + 1.5958f * v; + float g = y - 0.39173f * u - 0.81290f * v; + float b = y + 2.017f * u; - dpix[q + 0] = (uint8_t)(clamp(r, 0.f, 1.f) * 255); - dpix[q + 1] = (uint8_t)(clamp(g, 0.f, 1.f) * 255); - dpix[q + 2] = (uint8_t)(clamp(b, 0.f, 1.f) * 255); - } - } - else memcpy(Image.Data(), data_, Width * Height * (pixelformat == Paletted ? 1 : 3)); - } + dpix[q + 0] = (uint8_t)(clamp(r, 0.f, 1.f) * 255); + dpix[q + 1] = (uint8_t)(clamp(g, 0.f, 1.f) * 255); + dpix[q + 2] = (uint8_t)(clamp(b, 0.f, 1.f) * 255); + } + } + else memcpy(Image.Data(), data_, Width * Height * (pixelformat == Paletted ? 1 : 3)); + } } //=========================================================================== @@ -90,37 +90,37 @@ void AnimTexture::SetFrame(const uint8_t* palette, const void* data_) FBitmap AnimTexture::GetBgraBitmap(const PalEntry* remap, int* trans) { - FBitmap bmp; + FBitmap bmp; - bmp.Create(Width, Height); + bmp.Create(Width, Height); - auto spix = Image.Data(); - auto dpix = bmp.GetPixels(); - if (pixelformat == Paletted) - { - for (int i = 0; i < Width * Height; i++) - { - int p = i * 4; - int index = spix[i]; - dpix[p + 0] = Palette[index * 3 + 2]; - dpix[p + 1] = Palette[index * 3 + 1]; - dpix[p + 2] = Palette[index * 3]; - dpix[p + 3] = 255; - } - } - else if (pixelformat == RGB || pixelformat == YUV) - { - for (int i = 0; i < Width * Height; i++) - { - int p = i * 4; - int q = i * 3; - dpix[p + 0] = spix[q + 2]; - dpix[p + 1] = spix[q + 1]; - dpix[p + 2] = spix[q]; - dpix[p + 3] = 255; - } - } - return bmp; + auto spix = Image.Data(); + auto dpix = bmp.GetPixels(); + if (pixelformat == Paletted) + { + for (int i = 0; i < Width * Height; i++) + { + int p = i * 4; + int index = spix[i]; + dpix[p + 0] = Palette[index * 3 + 2]; + dpix[p + 1] = Palette[index * 3 + 1]; + dpix[p + 2] = Palette[index * 3]; + dpix[p + 3] = 255; + } + } + else if (pixelformat == RGB || pixelformat == YUV) + { + for (int i = 0; i < Width * Height; i++) + { + int p = i * 4; + int q = i * 3; + dpix[p + 0] = spix[q + 2]; + dpix[p + 1] = spix[q + 1]; + dpix[p + 2] = spix[q]; + dpix[p + 3] = 255; + } + } + return bmp; } //========================================================================== @@ -131,36 +131,36 @@ FBitmap AnimTexture::GetBgraBitmap(const PalEntry* remap, int* trans) AnimTextures::AnimTextures() { - active = 1; - tex[0] = TexMan.FindGameTexture("AnimTextureFrame1", ETextureType::Override); - tex[1] = TexMan.FindGameTexture("AnimTextureFrame2", ETextureType::Override); + active = 1; + tex[0] = TexMan.FindGameTexture("AnimTextureFrame1", ETextureType::Override); + tex[1] = TexMan.FindGameTexture("AnimTextureFrame2", ETextureType::Override); } AnimTextures::~AnimTextures() { - Clean(); + Clean(); } void AnimTextures::Clean() { - if (tex[0]) tex[0]->CleanHardwareData(true); - if (tex[1]) tex[1]->CleanHardwareData(true); - tex[0] = tex[1] = nullptr; + if (tex[0]) tex[0]->CleanHardwareData(true); + if (tex[1]) tex[1]->CleanHardwareData(true); + tex[0] = tex[1] = nullptr; } void AnimTextures::SetSize(int format, int width, int height) { - static_cast(tex[0]->GetTexture())->SetFrameSize(format, width, height); - static_cast(tex[1]->GetTexture())->SetFrameSize(format, width, height); - tex[0]->SetSize(width, height); - tex[1]->SetSize(width, height); - tex[0]->CleanHardwareData(); - tex[1]->CleanHardwareData(); + static_cast(tex[0]->GetTexture())->SetFrameSize(format, width, height); + static_cast(tex[1]->GetTexture())->SetFrameSize(format, width, height); + tex[0]->SetSize(width, height); + tex[1]->SetSize(width, height); + tex[0]->CleanHardwareData(); + tex[1]->CleanHardwareData(); } void AnimTextures::SetFrame(const uint8_t* palette, const void* data) { - active ^= 1; - static_cast(tex[active]->GetTexture())->SetFrame(palette, data); - tex[active]->CleanHardwareData(); + active ^= 1; + static_cast(tex[active]->GetTexture())->SetFrame(palette, data); + tex[active]->CleanHardwareData(); } diff --git a/src/common/textures/bitmap.cpp b/src/common/textures/bitmap.cpp index 8c433d855..bfe79dbb4 100644 --- a/src/common/textures/bitmap.cpp +++ b/src/common/textures/bitmap.cpp @@ -97,7 +97,7 @@ void iCopyColors(uint8_t *pout, const uint8_t *pin, int count, int step, FCopyIn if (TBlend::ProcessAlpha0() || a) { int gray = TSrc::Gray(pin)>>4; - + TBlend::OpC(pout[TDest::RED], IcePalette[gray][0], a, inf); TBlend::OpC(pout[TDest::GREEN], IcePalette[gray][1], a, inf); TBlend::OpC(pout[TDest::BLUE], IcePalette[gray][2], a, inf); @@ -331,7 +331,7 @@ bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy, srcwidth = cr->x + cr->width - originx; if (srcwidth<=0) return false; } - + if (originy < cr->y) { int skip = cr->y - originy; diff --git a/src/common/textures/bitmap.h b/src/common/textures/bitmap.h index 88df40307..34fff5516 100644 --- a/src/common/textures/bitmap.h +++ b/src/common/textures/bitmap.h @@ -156,7 +156,7 @@ public: } } - + ~FBitmap() { Destroy(); diff --git a/src/common/textures/formats/anmtexture.cpp b/src/common/textures/formats/anmtexture.cpp index aa65dc693..3845bdc67 100644 --- a/src/common/textures/formats/anmtexture.cpp +++ b/src/common/textures/formats/anmtexture.cpp @@ -81,7 +81,7 @@ FImageSource *AnmImage_TryCreate(FileReader & file, int lumpnum) { return new FAnmTexture(lumpnum, 320, 200); } - + return nullptr; } @@ -132,7 +132,7 @@ TArray FAnmTexture::CreatePalettedPixels(int conversion) uint8_t buffer[64000]; uint8_t palette[768]; uint8_t remap[256]; - + ReadFrame(buffer, palette); for(int i=0;i<256;i++) { @@ -153,7 +153,7 @@ int FAnmTexture::CopyPixels(FBitmap *bmp, int conversion) uint8_t buffer[64000]; uint8_t palette[768]; ReadFrame(buffer, palette); - + auto dpix = bmp->GetPixels(); for (int i = 0; i < Width * Height; i++) { diff --git a/src/common/textures/formats/md5check.cpp b/src/common/textures/formats/md5check.cpp index 96e14b2f3..120371a8e 100644 --- a/src/common/textures/formats/md5check.cpp +++ b/src/common/textures/formats/md5check.cpp @@ -219,10 +219,10 @@ void makeMD5(const void *buffer, unsigned length, char *md5out) bool checkPatchForAlpha(const void *buffer, uint32_t length) { if (length > 10164) return false; // shortcut for anything too large - + char md5[33]; bool done = false; - + for(int i=0; alphapatches[i].length > 0; i++) { if (alphapatches[i].length == (int)length) // length check diff --git a/src/common/textures/formats/patchtexture.cpp b/src/common/textures/formats/patchtexture.cpp index f1f65291d..e680bf38a 100644 --- a/src/common/textures/formats/patchtexture.cpp +++ b/src/common/textures/formats/patchtexture.cpp @@ -76,15 +76,15 @@ public: static bool CheckIfPatch(FileReader & file, bool &isalpha) { if (file.GetLength() < 13) return false; // minimum length of a valid Doom patch - + file.Seek(0, FileReader::SeekSet); auto data = file.Read(file.GetLength()); - + const patch_t *foo = (const patch_t *)data.Data(); - + int height = LittleShort(foo->height); int width = LittleShort(foo->width); - + if (height > 0 && height <= 2048 && width > 0 && width <= 2048 && width < file.GetLength()/4) { // The dimensions seem like they might be valid for a patch, so @@ -93,7 +93,7 @@ static bool CheckIfPatch(FileReader & file, bool &isalpha) // and none of them must point past the end of the patch. bool gapAtStart = true; int x; - + for (x = 0; x < width; ++x) { uint32_t ofs = LittleLong(foo->columnofs[x]); diff --git a/src/common/textures/formats/pngtexture.cpp b/src/common/textures/formats/pngtexture.cpp index dd0976a8e..c91723b95 100644 --- a/src/common/textures/formats/pngtexture.cpp +++ b/src/common/textures/formats/pngtexture.cpp @@ -684,7 +684,7 @@ public: virtual FBitmap GetBgraBitmap(const PalEntry *remap, int *trans) override; protected: - + FileReader fr; uint8_t ColorType; int PaletteSize; @@ -703,7 +703,7 @@ FGameTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename) { return nullptr; } - + // Savegame images can only be either 8 bit paletted or 24 bit RGB auto &data = png->File; int width = data.ReadInt32BE(); @@ -713,7 +713,7 @@ FGameTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename) uint8_t compression = data.ReadUInt8(); uint8_t filter = data.ReadUInt8(); uint8_t interlace = data.ReadUInt8(); - + // Reject anything that cannot be put into a savegame picture by GZDoom itself. if (compression != 0 || filter != 0 || interlace > 0 || bitdepth != 8 || (colortype != 2 && colortype != 3)) return nullptr; else return MakeGameTexture(new FPNGFileTexture (png->File, width, height, colortype), nullptr, ETextureType::Override); @@ -748,9 +748,9 @@ FBitmap FPNGFileTexture::GetBgraBitmap(const PalEntry *remap, int *trans) PalEntry pe[256]; uint32_t len, id; int pixwidth = Width * (ColorType == 2? 3:1); - + FileReader *lump = &fr; - + bmp.Create(Width, Height); lump->Seek(33, FileReader::SeekSet); lump->Read(&len, 4); @@ -779,12 +779,12 @@ FBitmap FPNGFileTexture::GetBgraBitmap(const PalEntry *remap, int *trans) auto StartOfIDAT = (uint32_t)lump->Tell() - 8; TArray Pixels(pixwidth * Height); - + lump->Seek (StartOfIDAT, FileReader::SeekSet); lump->Read(&len, 4); lump->Read(&id, 4); M_ReadIDAT (*lump, Pixels.Data(), Width, Height, pixwidth, 8, ColorType, 0, BigLong((unsigned int)len)); - + if (ColorType == 3) { bmp.CopyPixelData(0, 0, Pixels.Data(), Width, Height, 1, Width, 0, pe); diff --git a/src/common/textures/formats/stb_image.h b/src/common/textures/formats/stb_image.h index 196dfd5cc..44117802a 100644 --- a/src/common/textures/formats/stb_image.h +++ b/src/common/textures/formats/stb_image.h @@ -1198,7 +1198,7 @@ static FILE *stbi__fopen(char const *filename, char const *mode) wchar_t wFilename[1024]; if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) return 0; - + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) return 0; @@ -1302,7 +1302,7 @@ STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int * unsigned char *result; stbi__context s; stbi__start_mem(&s,buffer,len); - + result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); if (stbi__vertically_flip_on_load) { stbi__vertical_flip_slices( result, *x, *y, *z, *comp ); @@ -6522,7 +6522,7 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i g->color_table = (stbi_uc *) g->pal; } else return stbi__errpuc("missing color table", "Corrupt GIF"); - + o = stbi__process_gif_raster(s, g); if (!o) return NULL; @@ -6608,7 +6608,7 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, *y = g.h; ++layers; stride = g.w * g.h * 4; - + if (out) { out = (stbi_uc*) STBI_REALLOC( out, layers * stride ); if (delays) { diff --git a/src/common/textures/formats/stbtexture.cpp b/src/common/textures/formats/stbtexture.cpp index bce080c62..7ffb6f01d 100644 --- a/src/common/textures/formats/stbtexture.cpp +++ b/src/common/textures/formats/stbtexture.cpp @@ -43,7 +43,7 @@ #define STBI_NO_HDR #define STBI_NO_PNM #include "stb_image.h" - + #include "files.h" #include "filesystem.h" @@ -92,7 +92,7 @@ FImageSource *StbImage_TryCreate(FileReader & file, int lumpnum) { return new FStbTexture(lumpnum, x, y); } - + return nullptr; } diff --git a/src/common/textures/formats/tgatexture.cpp b/src/common/textures/formats/tgatexture.cpp index d2e12e1aa..690c2bc29 100644 --- a/src/common/textures/formats/tgatexture.cpp +++ b/src/common/textures/formats/tgatexture.cpp @@ -57,7 +57,7 @@ struct TGAHeader int16_t cm_first; int16_t cm_length; uint8_t cm_size; - + int16_t x_origin; int16_t y_origin; int16_t width; @@ -97,12 +97,12 @@ FImageSource *TGAImage_TryCreate(FileReader & file, int lumpnum) TGAHeader hdr; if (file.GetLength() < (long)sizeof(hdr)) return NULL; - + file.Seek(0, FileReader::SeekSet); file.Read(&hdr, sizeof(hdr)); hdr.width = LittleShort(hdr.width); hdr.height = LittleShort(hdr.height); - + // Not much that can be done here because TGA does not have a proper // header to be identified with. if (hdr.has_cm != 0 && hdr.has_cm != 1) return NULL; @@ -145,7 +145,7 @@ void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytespe { uint8_t data[4]; int Size = Width * Height; - + while (Size > 0) { uint8_t b = lump.ReadUInt8(); @@ -188,7 +188,7 @@ TArray FTGATexture::CreatePalettedPixels(int conversion) TArray Pixels(Width*Height, true); lump.Read(&hdr, sizeof(hdr)); lump.Seek(hdr.id_len, FileReader::SeekCur); - + hdr.width = LittleShort(hdr.width); hdr.height = LittleShort(hdr.height); hdr.cm_first = LittleShort(hdr.cm_first); @@ -209,14 +209,14 @@ TArray FTGATexture::CreatePalettedPixels(int conversion) b = (w & 0x7C00) >> 7; a = 255; break; - + case 24: b = lump.ReadUInt8(); g = lump.ReadUInt8(); r = lump.ReadUInt8(); a=255; break; - + case 32: b = lump.ReadUInt8(); g = lump.ReadUInt8(); @@ -224,7 +224,7 @@ TArray FTGATexture::CreatePalettedPixels(int conversion) a = lump.ReadUInt8(); if ((hdr.img_desc&15)!=8) a=255; break; - + default: // should never happen r=g=b=a=0; break; @@ -232,10 +232,10 @@ TArray FTGATexture::CreatePalettedPixels(int conversion) PaletteMap[i] = ImageHelpers::RGBToPalettePrecise(conversion == luminance, r, g, b, a); } } - + int Size = Width * Height * (hdr.bpp>>3); TArray buffer(Size, true); - + if (hdr.img_type < 4) // uncompressed { lump.Read(buffer.Data(), Size); @@ -244,7 +244,7 @@ TArray FTGATexture::CreatePalettedPixels(int conversion) { ReadCompressed(lump, buffer.Data(), hdr.bpp>>3); } - + uint8_t * ptr = buffer.Data(); int step_x = (hdr.bpp>>3); int Pitch = Width * step_x; @@ -293,7 +293,7 @@ TArray FTGATexture::CreatePalettedPixels(int conversion) } } break; - + case 24: for(int y=0;y FTGATexture::CreatePalettedPixels(int conversion) } } break; - + case 32: if ((hdr.img_desc&15)!=8) // 32 bits without a valid alpha channel { @@ -332,12 +332,12 @@ TArray FTGATexture::CreatePalettedPixels(int conversion) } } break; - + default: break; } break; - + case 3: // Grayscale { auto remap = ImageHelpers::GetRemap(conversion == luminance, true); @@ -395,7 +395,7 @@ int FTGATexture::CopyPixels(FBitmap *bmp, int conversion) lump.Read(&hdr, sizeof(hdr)); lump.Seek(hdr.id_len, FileReader::SeekCur); - + hdr.width = LittleShort(hdr.width); hdr.height = LittleShort(hdr.height); hdr.cm_first = LittleShort(hdr.cm_first); @@ -440,10 +440,10 @@ int FTGATexture::CopyPixels(FBitmap *bmp, int conversion) pe[i] = PalEntry(a, r, g, b); } } - + int Size = Width * Height * (hdr.bpp>>3); TArray sbuffer(Size); - + if (hdr.img_type < 4) // uncompressed { lump.Read(sbuffer.Data(), Size); @@ -452,7 +452,7 @@ int FTGATexture::CopyPixels(FBitmap *bmp, int conversion) { ReadCompressed(lump, sbuffer.Data(), hdr.bpp>>3); } - + uint8_t * ptr = sbuffer.Data(); int step_x = (hdr.bpp>>3); int Pitch = Width * step_x; @@ -483,11 +483,11 @@ int FTGATexture::CopyPixels(FBitmap *bmp, int conversion) case 16: bmp->CopyPixelDataRGB(0, 0, ptr, Width, Height, step_x, Pitch, 0, CF_RGB555); break; - + case 24: bmp->CopyPixelDataRGB(0, 0, ptr, Width, Height, step_x, Pitch, 0, CF_BGR); break; - + case 32: if ((hdr.img_desc&15)!=8) // 32 bits without a valid alpha channel { @@ -499,12 +499,12 @@ int FTGATexture::CopyPixels(FBitmap *bmp, int conversion) transval = -1; } break; - + default: break; } break; - + case 3: // Grayscale switch (hdr.bpp) { @@ -512,11 +512,11 @@ int FTGATexture::CopyPixels(FBitmap *bmp, int conversion) for(int i=0;i<256;i++) pe[i]=PalEntry(255,i,i,i); // gray map bmp->CopyPixelData(0, 0, ptr, Width, Height, step_x, Pitch, 0, pe); break; - + case 16: bmp->CopyPixelDataRGB(0, 0, ptr, Width, Height, step_x, Pitch, 0, CF_I16); break; - + default: break; } diff --git a/src/common/textures/hires/hqnx_asm/hq4x_asm.cpp b/src/common/textures/hires/hqnx_asm/hq4x_asm.cpp index 7ce8a1621..5d22e1348 100644 --- a/src/common/textures/hires/hqnx_asm/hq4x_asm.cpp +++ b/src/common/textures/hires/hqnx_asm/hq4x_asm.cpp @@ -272,9 +272,9 @@ bool Diff(const unsigned int rgb1, const unsigned int rgb2) { return false; } - + static const hq_vec THRESHOLD = 0x00300706; - + const hq_vec yuv1 = RGBtoYUV[rgb1]; const hq_vec yuv2 = RGBtoYUV[rgb2]; diff --git a/src/common/textures/hires/hqresize.cpp b/src/common/textures/hires/hqresize.cpp index 16b2b4b13..9a6c42aa2 100644 --- a/src/common/textures/hires/hqresize.cpp +++ b/src/common/textures/hires/hqresize.cpp @@ -375,7 +375,7 @@ static unsigned char *xbrzHelper( void (*xbrzFunction) ( size_t, const uint32_t* outHeight = N *inHeight; unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; - + const int thresholdWidth = gl_texture_hqresize_mt_width; const int thresholdHeight = gl_texture_hqresize_mt_height; diff --git a/src/common/textures/hires/xbr/xbrz_old.h b/src/common/textures/hires/xbr/xbrz_old.h index 9a46f2a97..10e60dcfc 100644 --- a/src/common/textures/hires/xbr/xbrz_old.h +++ b/src/common/textures/hires/xbr/xbrz_old.h @@ -47,7 +47,7 @@ http://board.byuu.org/viewtopic.php?f=10&t=2248 THREAD-SAFETY: - parts of the same image may be scaled by multiple threads as long as the [yFirst, yLast) ranges do not overlap! - there is a minor inefficiency for the first row of a slice, so avoid processing single rows only - + */ void scale(size_t factor, //valid range: 2 - 5 const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, diff --git a/src/common/textures/hw_texcontainer.h b/src/common/textures/hw_texcontainer.h index 91afa526f..a4ff33f93 100644 --- a/src/common/textures/hw_texcontainer.h +++ b/src/common/textures/hw_texcontainer.h @@ -58,7 +58,7 @@ private: TranslatedTexture hwDefTex[4]; TArray hwTex_Translated; - + TranslatedTexture * GetTexID(int translation, int scaleflags) { // Allow negative indices to pass through unchanged. @@ -108,13 +108,13 @@ public: hwDefTex[1].Delete(); hwTex_Translated.Clear(); } - + IHardwareTexture * GetHardwareTexture(int translation, int scaleflags) { auto tt = GetTexID(translation, scaleflags); return tt->hwTexture; } - + void AddHardwareTexture(int translation, int scaleflags, IHardwareTexture *tex) { auto tt = GetTexID(translation, scaleflags); @@ -170,6 +170,6 @@ public: for (auto & t : hwTex_Translated) if (t.hwTexture) callback(t.hwTexture); } - + }; diff --git a/src/common/textures/image.cpp b/src/common/textures/image.cpp index df48a79f1..f8f480671 100644 --- a/src/common/textures/image.cpp +++ b/src/common/textures/image.cpp @@ -195,13 +195,13 @@ int FImageSource::CopyTranslatedPixels(FBitmap *bmp, const PalEntry *remap) FBitmap FImageSource::GetCachedBitmap(const PalEntry *remap, int conversion, int *ptrans) { FBitmap ret; - + FString name; int trans = -1; fileSystem.GetFileShortName(name, SourceLump); - + auto imageID = ImageID; - + if (remap != nullptr) { // Remapped images are never run through the cache because they would complicate matters too much for very little gain. @@ -218,7 +218,7 @@ FBitmap FImageSource::GetCachedBitmap(const PalEntry *remap, int conversion, int if (index < precacheDataRgba.Size()) { auto cache = &precacheDataRgba[index]; - + trans = cache->TransInfo; if (cache->RefCount > 1) { @@ -256,7 +256,7 @@ FBitmap FImageSource::GetCachedBitmap(const PalEntry *remap, int conversion, int //Printf("creating cached entry for %s, refcount = %d\n", name.GetChars(), info->first); // This is the first time it gets accessed and needs to be placed in the cache. PrecacheDataRgba *pdr = &precacheDataRgba[precacheDataRgba.Reserve(1)]; - + pdr->ImageID = imageID; pdr->RefCount = info->first - 1; info->first = 0; diff --git a/src/common/textures/image.h b/src/common/textures/image.h index 6ddd34bc2..0924fe97e 100644 --- a/src/common/textures/image.h +++ b/src/common/textures/image.h @@ -77,7 +77,7 @@ public: int8_t bTranslucent = -1; // Image has pixels with a non-0/1 value. (-1 means the user needs to do a real check) int GetId() const { return ImageID; } - + // 'noremap0' will only be looked at by FPatchTexture and forwarded by FMultipatchTexture. // Either returns a reference to the cache, or a newly created item. The return of this has to be considered transient. If you need to store the result, use GetPalettedPixels @@ -86,7 +86,7 @@ public: // tries to get a buffer from the cache. If not available, create a new one. If further references are pending, create a copy. TArray GetPalettedPixels(int conversion); - + // Unlile for paletted images there is no variant here that returns a persistent bitmap, because all users have to process the returned image into another format. FBitmap GetCachedBitmap(const PalEntry *remap, int conversion, int *trans = nullptr); @@ -102,25 +102,25 @@ public: luminance = 1, noremap0 = 2 }; - + FImageSource(int sourcelump = -1) : SourceLump(sourcelump) { ImageID = ++NextID; } virtual ~FImageSource() {} - + int GetWidth() const { return Width; } - + int GetHeight() const { return Height; } - + std::pair GetSize() const { return std::make_pair(Width, Height); } - + std::pair GetOffsets() const { return std::make_pair(LeftOffset, TopOffset); @@ -131,12 +131,12 @@ public: LeftOffset = x; TopOffset = y; } - + int LumpNum() const { return SourceLump; } - + bool UseGamePalette() const { return bUseGamePalette; diff --git a/src/common/textures/imagehelpers.h b/src/common/textures/imagehelpers.h index 8923f92db..a25187ef2 100644 --- a/src/common/textures/imagehelpers.h +++ b/src/common/textures/imagehelpers.h @@ -58,7 +58,7 @@ namespace ImageHelpers return srcisgrayscale ? GPalette.GrayMap : GPalette.Remap; } } - + inline uint8_t RGBToPalettePrecise(bool wantluminance, int r, int g, int b, int a = 255) { if (wantluminance) @@ -70,7 +70,7 @@ namespace ImageHelpers return ColorMatcher.Pick(r, g, b); } } - + inline uint8_t RGBToPalette(bool wantluminance, int r, int g, int b, int a = 255) { if (wantluminance) @@ -83,19 +83,19 @@ namespace ImageHelpers return a < 128? 0 : RGB256k.RGB[r >> 2][g >> 2][b >> 2]; } } - + inline uint8_t RGBToPalette(bool wantluminance, PalEntry pe, bool hasalpha = true) { return RGBToPalette(wantluminance, pe.r, pe.g, pe.b, hasalpha? pe.a : 255); } - + //========================================================================== // // Converts a texture between row-major and column-major format // by flipping it about the X=Y axis. // //========================================================================== - + template void FlipSquareBlock (T *block, int x) { @@ -109,7 +109,7 @@ namespace ImageHelpers } } } - + inline void FlipSquareBlockRemap (uint8_t *block, int x, const uint8_t *remap) { for (int i = 0; i < x; ++i) @@ -124,7 +124,7 @@ namespace ImageHelpers } } } - + template void FlipNonSquareBlock (T *dst, const T *src, int x, int y, int srcpitch) { @@ -136,7 +136,7 @@ namespace ImageHelpers } } } - + inline void FlipNonSquareBlockRemap (uint8_t *dst, const uint8_t *src, int x, int y, int srcpitch, const uint8_t *remap) { for (int i = 0; i < x; ++i) diff --git a/src/common/textures/multipatchtexturebuilder.cpp b/src/common/textures/multipatchtexturebuilder.cpp index f7684c6ce..2a8b77fea 100644 --- a/src/common/textures/multipatchtexturebuilder.cpp +++ b/src/common/textures/multipatchtexturebuilder.cpp @@ -612,7 +612,7 @@ void FMultipatchTextureBuilder::ParseTexture(FScanner &sc, ETextureType UseType, BuildInfo &buildinfo = BuiltTextures[BuiltTextures.Reserve(1)]; bool bSilent = false; - + buildinfo.textual = true; sc.SetCMode(true); sc.MustGetString(); diff --git a/src/common/textures/texture.cpp b/src/common/textures/texture.cpp index 5b88c3cef..db922a7b5 100644 --- a/src/common/textures/texture.cpp +++ b/src/common/textures/texture.cpp @@ -97,7 +97,7 @@ FBitmap FTexture::GetBgraBitmap(const PalEntry* remap, int* ptrans) int FTexture::CheckRealHeight() { auto pixels = Get8BitPixels(false); - + for(int h = GetHeight()-1; h>= 0; h--) { for(int w = 0; w < GetWidth(); w++) diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index 5d49c7a9a..c7b5fad3d 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -235,7 +235,7 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset } } - + if (!(flags & TEXMAN_ShortNameOnly)) { // We intentionally only look for textures in subdirectories. @@ -376,18 +376,18 @@ bool FTextureManager::OkForLocalization(FTextureID texnum, const char *substitut if (*substitute == '$') substitute = GStrings.GetString(substitute+1, &langtable); else return true; // String literals from the source data should never override graphics from the same definition. if (substitute == nullptr) return true; // The text does not exist. - + // Modes 2, 3 and 4 must not replace localized textures. int localizedTex = ResolveLocalizedTexture(texnum.GetIndex()); if (localizedTex != texnum.GetIndex()) return true; // Do not substitute a localized variant of the graphics patch. - + // For mode 4 we are done now. if (locmode == 4) return false; - + // Mode 2 and 3 must reject any text replacement from the default language tables. if ((langtable & MAKE_ID(255,0,0,0)) == MAKE_ID('*', 0, 0, 0)) return true; // Do not substitute if the string comes from the default table. if (locmode == 2) return false; - + // Mode 3 must also reject substitutions for non-IWAD content. int file = fileSystem.GetFileContainer(Textures[texnum.GetIndex()].Texture->GetSourceLump()); if (file > fileSystem.GetMaxIwadNum()) return true; @@ -771,7 +771,7 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build else if (sc.Compare("define")) // define a new "fake" texture { sc.GetString(); - + FString base = ExtractFileBase(sc.String, false); if (!base.IsEmpty()) { @@ -1402,7 +1402,7 @@ int FTextureManager::ResolveLocalizedTexture(int tex) int FTextureManager::GuesstimateNumTextures () { int numtex = 0; - + for(int i = fileSystem.GetNumEntries()-1; i>=0; i--) { int space = fileSystem.GetFileNamespace(i); diff --git a/src/common/textures/texturemanager.h b/src/common/textures/texturemanager.h index 076ee1769..54d4aa8b8 100644 --- a/src/common/textures/texturemanager.h +++ b/src/common/textures/texturemanager.h @@ -21,7 +21,7 @@ class FTextureManager public: FTextureManager (); ~FTextureManager (); - + private: int ResolveLocalizedTexture(int texnum); @@ -57,7 +57,7 @@ public: { return InternalGetTexture(texnum.GetIndex(), animate, true); } - + FGameTexture* GetPalettedTexture(FTextureID texnum, bool animate = false, bool allowsubstitute = true) { auto texid = ResolveTextureIndex(texnum.GetIndex(), animate, true); @@ -171,7 +171,7 @@ public: private: void InitPalettedVersions(); - + // Switches struct TextureHash diff --git a/src/common/textures/textures.h b/src/common/textures/textures.h index a24dba5fa..ffb79c3e2 100644 --- a/src/common/textures/textures.h +++ b/src/common/textures/textures.h @@ -249,10 +249,10 @@ public: int GetWidth() { return Width; } int GetHeight() { return Height; } - + bool isHardwareCanvas() const { return bHasCanvas; } // There's two here so that this can deal with software canvases in the hardware renderer later. 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); diff --git a/src/common/thirdparty/m_crc32.h b/src/common/thirdparty/m_crc32.h index ccc9fe712..2930b8cbd 100644 --- a/src/common/thirdparty/m_crc32.h +++ b/src/common/thirdparty/m_crc32.h @@ -50,3 +50,8 @@ inline uint32_t CRC1 (uint32_t crc, const uint8_t c, const uint32_t *crcTable) { return crcTable[(crc & 0xff) ^ c] ^ (crc >> 8); } + +inline uint32_t Bcrc32(const void* data, int length, uint32_t crc) +{ + return crc32(crc, (const Bytef*)data, length); +} diff --git a/src/common/utility/cmdlib.cpp b/src/common/utility/cmdlib.cpp index e47610cf6..0dd6f7750 100644 --- a/src/common/utility/cmdlib.cpp +++ b/src/common/utility/cmdlib.cpp @@ -557,7 +557,7 @@ void CreatePath(const char *fn) void CreatePath(const char *fn) { char *copy, *p; - + if (fn[0] == '/' && fn[1] == '\0') { return; diff --git a/src/common/utility/colormatcher.h b/src/common/utility/colormatcher.h index 6ec20879a..277505e81 100644 --- a/src/common/utility/colormatcher.h +++ b/src/common/utility/colormatcher.h @@ -58,7 +58,7 @@ public: return (uint8_t)BestColor ((uint32_t *)Pal, r, g, b, startindex, 255, indexmap); } - + uint8_t Pick (PalEntry pe) { return Pick(pe.r, pe.g, pe.b); diff --git a/src/common/utility/files_decompress.cpp b/src/common/utility/files_decompress.cpp index 7d7d65442..cd2e36ed7 100644 --- a/src/common/utility/files_decompress.cpp +++ b/src/common/utility/files_decompress.cpp @@ -107,7 +107,7 @@ class DecompressorZ : public DecompressorBase bool SawEOF; z_stream Stream; uint8_t InBuff[BUFF_SIZE]; - + public: DecompressorZ (FileReader *file, bool zip, const std::function& cb) : SawEOF(false) @@ -198,7 +198,7 @@ class DecompressorBZ2 : public DecompressorBase bool SawEOF; bz_stream Stream; uint8_t InBuff[BUFF_SIZE]; - + public: DecompressorBZ2 (FileReader *file, const std::function& cb) : SawEOF(false) @@ -627,7 +627,7 @@ bool FileReader::OpenDecompressor(FileReader &parent, Size length, int method, b case METHOD_LZSS: dec = new DecompressorLZSS(p, cb); break; - + // todo: METHOD_IMPLODE, METHOD_SHRINK default: return false; diff --git a/src/common/utility/findfile.cpp b/src/common/utility/findfile.cpp index 6006a34a1..bdfa865a8 100644 --- a/src/common/utility/findfile.cpp +++ b/src/common/utility/findfile.cpp @@ -128,7 +128,7 @@ int I_FindAttr(findstate_t *const fileinfo) } #else - + #include #include diff --git a/src/common/utility/findfile.h b/src/common/utility/findfile.h index 895bbde69..44bee1a35 100644 --- a/src/common/utility/findfile.h +++ b/src/common/utility/findfile.h @@ -43,7 +43,7 @@ inline const char *I_FindName(findstate_t *fileinfo) #else - + // Mirror WIN32_FIND_DATAW in struct findstate_t diff --git a/src/common/utility/matrix.cpp b/src/common/utility/matrix.cpp index 006a5fe5d..476d09b60 100644 --- a/src/common/utility/matrix.cpp +++ b/src/common/utility/matrix.cpp @@ -58,7 +58,7 @@ VSMatrix::loadIdentity() void VSMatrix::multMatrix(const FLOATTYPE *aMatrix) { - + FLOATTYPE res[16]; for (int i = 0; i < 4; ++i) @@ -164,19 +164,19 @@ VSMatrix::rotate(FLOATTYPE angle, FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) mat[4] = v[0] * v[1] * (1 - co) - v[2] * si; mat[8] = v[0] * v[2] * (1 - co) + v[1] * si; mat[12]= 0.0f; - + mat[1] = v[0] * v[1] * (1 - co) + v[2] * si; // mat[5] = y2 + (x2 + z2) * co; mat[5] = co + y2 * (1 - co); mat[9] = v[1] * v[2] * (1 - co) - v[0] * si; mat[13]= 0.0f; - + mat[2] = v[0] * v[2] * (1 - co) - v[1] * si; mat[6] = v[1] * v[2] * (1 - co) + v[0] * si; // mat[10]= z2 + (x2 + y2) * co; mat[10]= co + z2 * (1 - co); mat[14]= 0.0f; - + mat[3] = 0.0f; mat[7] = 0.0f; mat[11]= 0.0f; @@ -323,9 +323,9 @@ VSMatrix::multMatrixPoint(const FLOATTYPE *point, FLOATTYPE *res) { res[i] = 0.0f; - + for (int j = 0; j < 4; j++) { - + res[i] += point[j] * mMatrix[j*4 + i]; } } @@ -444,7 +444,7 @@ VSMatrix::computeNormalMatrix(const FLOATTYPE *aMatrix) void VSMatrix::multMatrix(FLOATTYPE *resMat, const FLOATTYPE *aMatrix) { - + FLOATTYPE res[16]; for (int i = 0; i < 4; ++i) diff --git a/src/common/utility/matrix.h b/src/common/utility/matrix.h index 81d7be6f2..c1c7c873c 100644 --- a/src/common/utility/matrix.h +++ b/src/common/utility/matrix.h @@ -34,7 +34,7 @@ class VSMatrix { public: VSMatrix() = default; - + VSMatrix(int) { loadIdentity(); @@ -135,11 +135,11 @@ public: m[0][0] *=x; m[1][0] *=x; m[2][0] *=x; - + m[0][1] *=y; m[1][1] *=y; m[2][1] *=y; - + m[0][2] *=z; m[1][2] *=z; m[2][2] *=z; diff --git a/src/common/utility/r_memory.cpp b/src/common/utility/r_memory.cpp index 383cdbeb4..8ff821c38 100644 --- a/src/common/utility/r_memory.cpp +++ b/src/common/utility/r_memory.cpp @@ -28,7 +28,7 @@ void *RenderMemory::AllocBytes(int size) { size = (size + 15) / 16 * 16; // 16-byte align - + if (UsedBlocks.empty() || UsedBlocks.back()->Position + size > BlockSize) { if (!FreeBlocks.empty()) @@ -43,14 +43,14 @@ void *RenderMemory::AllocBytes(int size) UsedBlocks.push_back(std::unique_ptr(new MemoryBlock())); } } - + auto &block = UsedBlocks.back(); void *data = block->Data + block->Position; block->Position += size; return data; } - + void RenderMemory::Clear() { while (!UsedBlocks.empty()) diff --git a/src/common/utility/r_memory.h b/src/common/utility/r_memory.h index 8007b6cc1..d9db538ca 100644 --- a/src/common/utility/r_memory.h +++ b/src/common/utility/r_memory.h @@ -8,33 +8,33 @@ class RenderMemory { public: void Clear(); - + template T *AllocMemory(int size = 1) { return (T*)AllocBytes(sizeof(T) * size); } - + template T *NewObject(Types &&... args) { void *ptr = AllocBytes(sizeof(T)); return new (ptr)T(std::forward(args)...); } - + private: void *AllocBytes(int size); - + enum { BlockSize = 1024 * 1024 }; - + struct MemoryBlock { MemoryBlock(); ~MemoryBlock(); - + MemoryBlock(const MemoryBlock &) = delete; MemoryBlock &operator=(const MemoryBlock &) = delete; - + uint8_t *Data; uint32_t Position; }; diff --git a/src/common/utility/refcounted.h b/src/common/utility/refcounted.h index 81ea3fc6d..f8643f080 100644 --- a/src/common/utility/refcounted.h +++ b/src/common/utility/refcounted.h @@ -26,7 +26,7 @@ public: RefCountedPtr() : ptr(nullptr) {} - + explicit RefCountedPtr(T* p) : ptr(p) { if (ptr) ptr->IncRef(); @@ -52,7 +52,7 @@ public: } return *this; } - + RefCountedPtr& operator=(T* r) { if (ptr != r) @@ -99,18 +99,18 @@ public: { return *ptr; } - + T* operator-> () const { return ptr; } - + T* get() const { return ptr; } - + private: - + T * ptr; }; \ No newline at end of file diff --git a/src/common/utility/tarray.h b/src/common/utility/tarray.h index 4a2285ca3..a8742a96b 100644 --- a/src/common/utility/tarray.h +++ b/src/common/utility/tarray.h @@ -165,7 +165,7 @@ public: { return &Array[Count]; } - + reverse_iterator rbegin() { return reverse_iterator(end()); @@ -919,7 +919,7 @@ public: LastFree = o.LastFree; /* any free position is before this position */ Size = o.Size; /* must be a power of 2 */ NumUsed = o.NumUsed; - + o.Size = 0; o.NumUsed = 0; o.SetNodeVector(1); diff --git a/src/common/utility/utf8.cpp b/src/common/utility/utf8.cpp index f8e7119d4..5ca3506ef 100644 --- a/src/common/utility/utf8.cpp +++ b/src/common/utility/utf8.cpp @@ -124,7 +124,7 @@ int utf8_decode(const uint8_t *src, int *size) } return -1; } - + int c3 = src[3]; if (c3 < 0x80 || c1 >= 0xc0) return -1; c3 &= 0x3f; @@ -200,7 +200,7 @@ int GetCharFromString(const uint8_t *&string) if (z < 192) { string++; - + // Handle Windows 1252 characters if (z >= 128 && z < 160) { @@ -353,7 +353,7 @@ int getAlternative(int code) { default: return code; - + case '{': return '('; case '}': return ')'; case 0x17f: return 's'; // The 'long s' can be safely remapped to the regular variant, not that this gets used in any real text... diff --git a/src/common/utility/x86.cpp b/src/common/utility/x86.cpp index 3312ff043..76e880834 100644 --- a/src/common/utility/x86.cpp +++ b/src/common/utility/x86.cpp @@ -164,7 +164,7 @@ void CheckCPUID(CPUInfo *cpu) FString DumpCPUInfo(const CPUInfo *cpu) { char cpustring[4*4*3+1]; - + // Why does Intel right-justify this string (on P4s) // or add extra spaces (on Cores)? const char *f = cpu->CPUString;