From 28ac65b25b1ebef5045d1193399f0876b3798bd1 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 2 Apr 2016 23:01:32 +0200 Subject: [PATCH 01/12] - Fixed GCC and Clang compilation errors. --- src/c_cmds.cpp | 2 +- src/p_map.cpp | 6 ++++-- src/r_segs.cpp | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index aed83658b..d72fc79a2 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -1086,7 +1086,7 @@ CCMD(currentpos) if(mo) { Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, lightlevel: %d\n", - mo->X(), mo->Y(), mo->Z(), mo->Angles.Yaw, mo->floorz, mo->Sector->sectornum, mo->Sector->lightlevel); + mo->X(), mo->Y(), mo->Z(), mo->Angles.Yaw.Normalized360().Degrees, mo->floorz, mo->Sector->sectornum, mo->Sector->lightlevel); } else { diff --git a/src/p_map.cpp b/src/p_map.cpp index f757f089c..564b79b93 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2122,8 +2122,10 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, // it slopes or the player's eyes are bobbing in and out. bool oldAboveFakeFloor, oldAboveFakeCeiling; - double viewheight = thing->player ? thing->player->viewheight : thing->Height / 2; - oldAboveFakeFloor = oldAboveFakeCeiling = false; // pacify GCC + double viewheight; + // pacify GCC + viewheight = thing->player ? thing->player->viewheight : thing->Height / 2; + oldAboveFakeFloor = oldAboveFakeCeiling = false; if (oldsec->heightsec) { diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 0c645f14a..3acc90993 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -3169,7 +3169,8 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, break; } - fixed_t fzpos = FLOAT2FIXED(zpos); + fixed_t fzpos; + fzpos = FLOAT2FIXED(zpos); // pacify GCC topoff = WallSpriteTile->TopOffset << FRACBITS; dc_texturemid = topoff + FixedDiv (fzpos - viewz, yscale); From f36489098f5a6eaeaff6d6cc3bde219a8250cbac Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 2 Apr 2016 23:01:51 +0200 Subject: [PATCH 02/12] - Fixed one GCC/Clang warning. --- src/portal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/portal.cpp b/src/portal.cpp index b8e0f80e5..f0c5b8962 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -1054,7 +1054,7 @@ void P_CreateLinkedPortals() if (cz < fz) { // This is a fatal condition. We have to remove one of the two portals. Choose the one that doesn't match the current plane - Printf("Error in sector %d: Ceiling portal at z=%d is below floor portal at z=%d\n", i, cz, fz); + Printf("Error in sector %d: Ceiling portal at z=%f is below floor portal at z=%f\n", i, cz, fz); double cp = -sectors[i].ceilingplane.fD(); double fp = -sectors[i].ceilingplane.fD(); if (cp < fp || fz == fp) From 81f29556bf3493da8e290442082ae01c627aefc3 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Sat, 2 Apr 2016 23:11:59 -0400 Subject: [PATCH 03/12] - Refactored SBarInfo flow control so negatable commands are handled statically. - Made TArray movable and TDeletingArray a move only type. --- src/g_shared/sbarinfo.cpp | 112 ++++++++++++--------- src/g_shared/sbarinfo_commands.cpp | 151 ++++++++--------------------- src/tarray.h | 34 ++++++- src/templates.h | 3 +- 4 files changed, 137 insertions(+), 163 deletions(-) diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index 23733efcf..2fcc29b05 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -206,67 +206,31 @@ class SBarInfoCommandFlowControl : public SBarInfoCommand { public: SBarInfoCommandFlowControl(SBarInfo *script) : SBarInfoCommand(script), truth(false) {} - ~SBarInfoCommandFlowControl() - { - for(unsigned int i = 0;i < 2;i++) - { - for(unsigned int j = 0;j < commands[i].Size();j++) - delete commands[i][j]; - } - } void Draw(const SBarInfoMainBlock *block, const DSBarInfo *statusBar) { - for(unsigned int i = 0;i < commands[truth].Size();i++) - commands[truth][i]->Draw(block, statusBar); + for(auto command : commands[truth]) + command->Draw(block, statusBar); } int NumCommands() const { return commands[truth].Size(); } void Parse(FScanner &sc, bool fullScreenOffsets) { - bool elseBlock = false; - SBarInfoCommand *cmd = NULL; - // Should loop no more than twice. - while(true) - { - if(sc.CheckToken('{')) - { - while((cmd = NextCommand(sc)) != NULL) - { - cmd->Parse(sc, fullScreenOffsets); - commands[!elseBlock].Push(cmd); - } - } - else - { - if((cmd = NextCommand(sc)) != NULL) - { - cmd->Parse(sc, fullScreenOffsets); - commands[!elseBlock].Push(cmd); - } - else - sc.ScriptError("Missing command for flow control statement."); - } - - if(!elseBlock && sc.CheckToken(TK_Else)) - { - elseBlock = true; - continue; - } - break; - } + ParseBlock(commands[1], sc, fullScreenOffsets); + if(sc.CheckToken(TK_Else)) + ParseBlock(commands[0], sc, fullScreenOffsets); } void Reset() { for(unsigned int i = 0;i < 2;i++) { - for(unsigned int j = 0;j < commands[i].Size();j++) - commands[i][j]->Reset(); + for(auto command : commands[i]) + command->Reset(); } } void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) { - for(unsigned int i = 0;i < commands[truth].Size();i++) - commands[truth][i]->Tick(block, statusBar, hudChanged); + for(auto command : commands[truth]) + command->Tick(block, statusBar, hudChanged); } protected: @@ -283,11 +247,65 @@ class SBarInfoCommandFlowControl : public SBarInfoCommand Tick(block, statusBar, true); } + void Negate() + { + swapvalues(commands[0], commands[1]); + } + private: + void ParseBlock(TDeletingArray &commands, FScanner &sc, bool fullScreenOffsets) + { + if(sc.CheckToken('{')) + { + while(SBarInfoCommand *cmd = NextCommand(sc)) + { + cmd->Parse(sc, fullScreenOffsets); + commands.Push(cmd); + } + } + else + { + if(SBarInfoCommand *cmd = NextCommand(sc)) + { + cmd->Parse(sc, fullScreenOffsets); + commands.Push(cmd); + } + else + sc.ScriptError("Missing command for flow control statement."); + } + } + SBarInfoCommand *NextCommand(FScanner &sc); - bool truth; - TArray commands[2]; + TDeletingArray commands[2]; + bool truth; +}; + +class SBarInfoNegatableFlowControl : public SBarInfoCommandFlowControl +{ + public: + SBarInfoNegatableFlowControl(SBarInfo *script) : SBarInfoCommandFlowControl(script) {} + + void Parse(FScanner &sc, bool fullScreenOffsets) + { + bool negate = false; + if(sc.CheckToken(TK_Identifier)) + { + if(sc.Compare("not")) + negate = true; + else + sc.UnGet(); + } + + ParseNegatable(sc, fullScreenOffsets); + + SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets); + + if(negate) + Negate(); + } + + virtual void ParseNegatable(FScanner &sc, bool fullScreenOffsets) {} }; class SBarInfoMainBlock : public SBarInfoCommandFlowControl diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index e08fb1a20..dcb0cd544 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -1830,33 +1830,17 @@ const char* const CommandGameMode::modeNames[] = //////////////////////////////////////////////////////////////////////////////// -class CommandUsesAmmo : public SBarInfoCommandFlowControl +class CommandUsesAmmo : public SBarInfoNegatableFlowControl { public: - CommandUsesAmmo(SBarInfo *script) : SBarInfoCommandFlowControl(script), - negate(false) - { - } + CommandUsesAmmo(SBarInfo *script) : SBarInfoNegatableFlowControl(script) {} - void Parse(FScanner &sc, bool fullScreenOffsets) - { - if(sc.CheckToken(TK_Identifier)) - { - if(sc.Compare("not")) - negate = true; - else - sc.ScriptError("Expected 'not', but got '%s' instead.", sc.String); - } - SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets); - } void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) { - SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); + SBarInfoNegatableFlowControl::Tick(block, statusBar, hudChanged); - SetTruth((statusBar->CPlayer->ReadyWeapon != NULL && (statusBar->CPlayer->ReadyWeapon->AmmoType1 != NULL || statusBar->CPlayer->ReadyWeapon->AmmoType2 != NULL)) ^ negate, block, statusBar); + SetTruth(statusBar->CPlayer->ReadyWeapon != NULL && (statusBar->CPlayer->ReadyWeapon->AmmoType1 != NULL || statusBar->CPlayer->ReadyWeapon->AmmoType2 != NULL), block, statusBar); } - protected: - bool negate; }; //////////////////////////////////////////////////////////////////////////////// @@ -1872,7 +1856,7 @@ class CommandUsesSecondaryAmmo : public CommandUsesAmmo { SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); - SetTruth((statusBar->CPlayer->ReadyWeapon != NULL && statusBar->CPlayer->ReadyWeapon->AmmoType2 != NULL && statusBar->CPlayer->ReadyWeapon->AmmoType1 != statusBar->CPlayer->ReadyWeapon->AmmoType2) ^ negate, block, statusBar); + SetTruth(statusBar->CPlayer->ReadyWeapon != NULL && statusBar->CPlayer->ReadyWeapon->AmmoType2 != NULL && statusBar->CPlayer->ReadyWeapon->AmmoType1 != statusBar->CPlayer->ReadyWeapon->AmmoType2, block, statusBar); } }; @@ -2890,28 +2874,18 @@ class CommandDrawBar : public SBarInfoCommand //////////////////////////////////////////////////////////////////////////////// -class CommandIsSelected : public SBarInfoCommandFlowControl +class CommandIsSelected : public SBarInfoNegatableFlowControl { public: - CommandIsSelected(SBarInfo *script) : SBarInfoCommandFlowControl(script), - negate(false) + CommandIsSelected(SBarInfo *script) : SBarInfoNegatableFlowControl(script) { weapon[0] = NULL; weapon[1] = NULL; } - void Parse(FScanner &sc, bool fullScreenOffsets) + void ParseNegatable(FScanner &sc, bool fullScreenOffsets) { - if(sc.CheckToken(TK_Identifier)) - { - if(sc.Compare("not")) - { - negate = true; - if(!sc.CheckToken(TK_StringConst)) - sc.MustGetToken(TK_Identifier); - } - } - else + if(!sc.CheckToken(TK_Identifier)) sc.MustGetToken(TK_StringConst); for(int i = 0;i < 2;i++) { @@ -2930,24 +2904,18 @@ class CommandIsSelected : public SBarInfoCommandFlowControl else break; } - SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets); } void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) { - SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); + SBarInfoNegatableFlowControl::Tick(block, statusBar, hudChanged); if(statusBar->CPlayer->ReadyWeapon != NULL) { const PClass *readyWeapon = statusBar->CPlayer->ReadyWeapon->GetClass(); - SetTruth(((weapon[1] != NULL) && - ((negate && (weapon[0] != readyWeapon && weapon[1] != readyWeapon)) || - (!negate && (weapon[0] == readyWeapon || weapon[1] == readyWeapon)))) || - ((weapon[1] == NULL) && - ((!negate && weapon[0] == readyWeapon) || (negate && weapon[0] != readyWeapon))), block, statusBar); + SetTruth(weapon[0] == readyWeapon || (weapon[1] && weapon[1] == readyWeapon), block, statusBar); } } protected: - bool negate; const PClass *weapon[2]; }; @@ -3245,26 +3213,20 @@ FRandom CommandDrawGem::pr_chainwiggle; //use the same method of chain wiggling //////////////////////////////////////////////////////////////////////////////// -class CommandWeaponAmmo : public SBarInfoCommandFlowControl +class CommandWeaponAmmo : public SBarInfoNegatableFlowControl { public: - CommandWeaponAmmo(SBarInfo *script) : SBarInfoCommandFlowControl(script), - conditionAnd(false), negate(false) + CommandWeaponAmmo(SBarInfo *script) : SBarInfoNegatableFlowControl(script), + conditionAnd(false) { ammo[0] = NULL; ammo[1] = NULL; } - void Parse(FScanner &sc, bool fullScreenOffsets) + void ParseNegatable(FScanner &sc, bool fullScreenOffsets) { if(!sc.CheckToken(TK_StringConst)) sc.MustGetToken(TK_Identifier); - if(sc.Compare("not") && sc.TokenType == TK_Identifier) - { - negate = true; - if(!sc.CheckToken(TK_StringConst)) - sc.MustGetToken(TK_Identifier); - } for(int i = 0;i < 2;i++) { ammo[i] = PClass::FindClass(sc.String); @@ -3289,11 +3251,10 @@ class CommandWeaponAmmo : public SBarInfoCommandFlowControl else break; } - SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets); } void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) { - SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); + SBarInfoNegatableFlowControl::Tick(block, statusBar, hudChanged); if(statusBar->CPlayer->ReadyWeapon != NULL) { @@ -3301,41 +3262,25 @@ class CommandWeaponAmmo : public SBarInfoCommandFlowControl const PClass *AmmoType2 = statusBar->CPlayer->ReadyWeapon->AmmoType2; bool usesammo1 = (AmmoType1 != NULL); bool usesammo2 = (AmmoType2 != NULL); - if(negate && !usesammo1 && !usesammo2) //if the weapon doesn't use ammo don't go though the trouble. - { - SetTruth(true, block, statusBar); - return; - } + //if(!usesammo1 && !usesammo2) //if the weapon doesn't use ammo don't go though the trouble. + //{ + // SetTruth(false, block, statusBar); + // return; + //} //Or means only 1 ammo type needs to match and means both need to match. if(ammo[1] != NULL) { bool match1 = ((usesammo1 && (AmmoType1 == ammo[0] || AmmoType1 == ammo[1])) || !usesammo1); bool match2 = ((usesammo2 && (AmmoType2 == ammo[0] || AmmoType2 == ammo[1])) || !usesammo2); if((!conditionAnd && (match1 || match2)) || (conditionAnd && (match1 && match2))) - { - if(!negate) - { - SetTruth(true, block, statusBar); - return; - } - } - else if(negate) { SetTruth(true, block, statusBar); return; } } - else //Every thing here could probably be one long if statement but then it would be more confusing. + else { if((usesammo1 && (AmmoType1 == ammo[0])) || (usesammo2 && (AmmoType2 == ammo[0]))) - { - if(!negate) - { - SetTruth(true, block, statusBar); - return; - } - } - else if(negate) { SetTruth(true, block, statusBar); return; @@ -3345,33 +3290,26 @@ class CommandWeaponAmmo : public SBarInfoCommandFlowControl SetTruth(false, block, statusBar); } protected: - bool conditionAnd; - bool negate; const PClass *ammo[2]; + bool conditionAnd; }; //////////////////////////////////////////////////////////////////////////////// -class CommandInInventory : public SBarInfoCommandFlowControl +class CommandInInventory : public SBarInfoNegatableFlowControl { public: - CommandInInventory(SBarInfo *script) : SBarInfoCommandFlowControl(script), - conditionAnd(false), negate(false) + CommandInInventory(SBarInfo *script) : SBarInfoNegatableFlowControl(script), + conditionAnd(false) { item[0] = item[1] = NULL; amount[0] = amount[1] = 0; } - void Parse(FScanner &sc, bool fullScreenOffsets) + void ParseNegatable(FScanner &sc, bool fullScreenOffsets) { if(!sc.CheckToken(TK_StringConst)) sc.MustGetToken(TK_Identifier); - if(sc.Compare("not") && sc.TokenType == TK_Identifier) - { - negate = true; - if(!sc.CheckToken(TK_StringConst)) - sc.MustGetToken(TK_Identifier); - } for(int i = 0;i < 2;i++) { item[i] = PClass::FindActor(sc.String); @@ -3402,11 +3340,10 @@ class CommandInInventory : public SBarInfoCommandFlowControl else break; } - SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets); } void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) { - SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); + SBarInfoNegatableFlowControl::Tick(block, statusBar, hudChanged); AInventory *invItem[2] = { statusBar->CPlayer->mo->FindInventory(item[0]), statusBar->CPlayer->mo->FindInventory(item[1]) }; if (invItem[0] != NULL && amount[0] > 0 && invItem[0]->Amount < amount[0]) invItem[0] = NULL; @@ -3415,16 +3352,15 @@ class CommandInInventory : public SBarInfoCommandFlowControl if (item[1]) { if (conditionAnd) - SetTruth((invItem[0] && invItem[1]) != negate, block, statusBar); + SetTruth(invItem[0] && invItem[1], block, statusBar); else - SetTruth((invItem[0] || invItem[1]) != negate, block, statusBar); + SetTruth(invItem[0] || invItem[1], block, statusBar); } else - SetTruth((invItem[0] != NULL) != negate, block, statusBar); + SetTruth(invItem[0] != NULL, block, statusBar); } protected: bool conditionAnd; - bool negate; PClassActor *item[2]; int amount[2]; }; @@ -3459,42 +3395,31 @@ class CommandAlpha : public SBarInfoMainBlock //////////////////////////////////////////////////////////////////////////////// -class CommandIfHealth : public SBarInfoCommandFlowControl +class CommandIfHealth : public SBarInfoNegatableFlowControl { public: - CommandIfHealth(SBarInfo *script) : SBarInfoCommandFlowControl(script), - negate(false), percentage(false) + CommandIfHealth(SBarInfo *script) : SBarInfoNegatableFlowControl(script), + percentage(false) { } - void Parse(FScanner &sc, bool fullScreenOffsets) + void ParseNegatable(FScanner &sc, bool fullScreenOffsets) { - if (sc.CheckToken(TK_Identifier)) - { - if (sc.Compare("not")) - negate = true; - else - sc.ScriptError("Expected 'not', but got '%s' instead.", sc.String); - } - sc.MustGetToken(TK_IntConst); percentage = sc.CheckToken('%'); hpamount = sc.Number; - - SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets); } void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) { - SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); + SBarInfoNegatableFlowControl::Tick(block, statusBar, hudChanged); int phealth = percentage ? statusBar->CPlayer->mo->health * 100 / statusBar->CPlayer->mo->GetMaxHealth() : statusBar->CPlayer->mo->health; - SetTruth((phealth >= hpamount) ^ negate, block, statusBar); + SetTruth(phealth >= hpamount, block, statusBar); } protected: - bool negate; - bool percentage; int hpamount; + bool percentage; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/tarray.h b/src/tarray.h index 7b9d5970b..3ef4f2d99 100644 --- a/src/tarray.h +++ b/src/tarray.h @@ -39,6 +39,7 @@ #include #include #include +#include #if !defined(_WIN32) #include // for intptr_t @@ -137,11 +138,17 @@ public: Count = 0; Array = (T *)M_Malloc (sizeof(T)*max); } - TArray (const TArray &other) + TArray (const TArray &other) { DoCopy (other); } - TArray &operator= (const TArray &other) + TArray (TArray &&other) + { + Array = other.Array; other.Array = NULL; + Most = other.Most; other.Most = 0; + Count = other.Count; other.Count = 0; + } + TArray &operator= (const TArray &other) { if (&other != this) { @@ -157,6 +164,21 @@ public: } return *this; } + TArray &operator= (TArray &&other) + { + if (Array) + { + if (Count > 0) + { + DoDelete (0, Count-1); + } + M_Free (Array); + } + Array = other.Array; other.Array = NULL; + Most = other.Most; other.Most = 0; + Count = other.Count; other.Count = 0; + return *this; + } ~TArray () { if (Array) @@ -417,6 +439,14 @@ template class TDeletingArray : public TArray { public: + TDeletingArray() : TArray() {} + TDeletingArray(TDeletingArray &&other) : TArray(std::move(other)) {} + TDeletingArray &operator=(TDeletingArray &&other) + { + TArray::operator=(std::move(other)); + return *this; + } + ~TDeletingArray () { for (unsigned int i = 0; i < TArray::Size(); ++i) diff --git a/src/templates.h b/src/templates.h index 4f75a961a..0737fc4e9 100644 --- a/src/templates.h +++ b/src/templates.h @@ -40,6 +40,7 @@ #endif #include +#include //========================================================================== // @@ -204,7 +205,7 @@ template inline void swapvalues (T &a, T &b) { - T temp = a; a = b; b = temp; + T temp = std::move(a); a = std::move(b); b = std::move(temp); } #endif //__TEMPLATES_H__ From 42edd7db2264622b034c21db32e762957ef64972 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Sat, 2 Apr 2016 23:47:15 -0400 Subject: [PATCH 04/12] - Added IfInvulnerable SBARINFO command (modified from Blue-Shadow's pull request) --- src/g_shared/sbarinfo_commands.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index dcb0cd544..a471ff8b2 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -3424,6 +3424,23 @@ class CommandIfHealth : public SBarInfoNegatableFlowControl //////////////////////////////////////////////////////////////////////////////// +class CommandIfInvulnerable : public SBarInfoNegatableFlowControl +{ + public: + CommandIfInvulnerable(SBarInfo *script) : SBarInfoNegatableFlowControl(script) + { + } + + void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) + { + SBarInfoNegatableFlowControl::Tick(block, statusBar, hudChanged); + + SetTruth((statusBar->CPlayer->mo->flags2 & MF2_INVULNERABLE) || (statusBar->CPlayer->cheats & (CF_GODMODE | CF_GODMODE2)), block, statusBar); + } +}; + +//////////////////////////////////////////////////////////////////////////////// + static const char *SBarInfoCommandNames[] = { "drawimage", "drawnumber", "drawswitchableimage", @@ -3434,6 +3451,7 @@ static const char *SBarInfoCommandNames[] = "isselected", "usesammo", "usessecondaryammo", "hasweaponpiece", "inventorybarnotvisible", "weaponammo", "ininventory", "alpha", "ifhealth", + "ifinvulnerable", NULL }; @@ -3447,6 +3465,7 @@ enum SBarInfoCommands SBARINFO_ISSELECTED, SBARINFO_USESAMMO, SBARINFO_USESSECONDARYAMMO, SBARINFO_HASWEAPONPIECE, SBARINFO_INVENTORYBARNOTVISIBLE, SBARINFO_WEAPONAMMO, SBARINFO_ININVENTORY, SBARINFO_ALPHA, SBARINFO_IFHEALTH, + SBARINFO_IFINVULNERABLE, }; SBarInfoCommand *SBarInfoCommandFlowControl::NextCommand(FScanner &sc) @@ -3480,6 +3499,7 @@ SBarInfoCommand *SBarInfoCommandFlowControl::NextCommand(FScanner &sc) case SBARINFO_ININVENTORY: return new CommandInInventory(script); case SBARINFO_ALPHA: return new CommandAlpha(script); case SBARINFO_IFHEALTH: return new CommandIfHealth(script); + case SBARINFO_IFINVULNERABLE: return new CommandIfInvulnerable(script); } sc.ScriptError("Unknown command '%s'.\n", sc.String); From 7a6039b44cea1d336284ac150c208b151d2df8ce Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 11:53:31 +0200 Subject: [PATCH 05/12] - floatified vertex coordinates. Making these double or float doesn't seem to matter at all performance-wise so they use the more precise double format. --- src/r_defs.h | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/r_defs.h b/src/r_defs.h index d2202f4e7..d47e82386 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -102,55 +102,60 @@ typedef double vtype; struct vertex_t { private: - fixed_t x, y; + DVector2 p; public: void set(fixed_t x, fixed_t y) { - this->x = x; - this->y = y; + p.X = x / 65536.; + p.Y = y / 65536.; } void set(double x, double y) { - this->x = FLOAT2FIXED(x); - this->y = FLOAT2FIXED(y); + p.X = x; + p.Y = y; } double fX() const { - return FIXED2DBL(x); + return p.X; } double fY() const { - return FIXED2DBL(y); + return p.Y; } fixed_t fixX() const { - return x; + return FLOAT2FIXED(p.X); } fixed_t fixY() const { - return y; + return FLOAT2FIXED(p.Y); } DVector2 fPos() { - return{ fX(), fY() }; + return { p.X, p.Y }; } bool operator== (const vertex_t &other) { - return x == other.x && y == other.y; + return p == other.p; + } + + bool operator!= (const vertex_t &other) + { + return p != other.p; } void clear() { - x = y = 0; + p.Zero(); } }; @@ -366,12 +371,12 @@ public: // This is for the software renderer fixed_t ZatPointFixed(const DVector2 &pos) const { - return xs_CRoundToInt((d + a*pos.X + b*pos.Y) * ic / (-65536.0)); + return FLOAT2FIXED(ZatPoint(pos)); } fixed_t ZatPointFixed(const vertex_t *v) const { - return FixedMul(ic, -d - DMulScale16(a, v->fixX(), b, v->fixY())); + return FLOAT2FIXED(ZatPoint(v)); } @@ -389,7 +394,7 @@ public: double ZatPoint(const vertex_t *v) const { - return FIXED2DBL(FixedMul(ic, -d - DMulScale16(a, v->fixX(), b, v->fixY()))); + return (d + a*v->fX() + b*v->fY()) * ic / (-65536.0 * 65536.0); } double ZatPoint(const AActor *ac) const @@ -400,7 +405,7 @@ public: // Returns the value of z at vertex v if d is equal to dist double ZatPointDist(const vertex_t *v, double dist) { - return FIXED2DBL(FixedMul(ic, -FLOAT2FIXED(dist) - DMulScale16(a, v->fixX(), b, v->fixY()))); + return (dist + a*v->fX() + b*v->fY()) * ic / (-65536.0 * 65536.0); } // Flips the plane's vertical orientiation, so that if it pointed up, // it will point down, and vice versa. From fede16ce68f3d9a21cf529396bf22e7914daecd5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 13:15:02 +0200 Subject: [PATCH 06/12] - fixed PointOnSide checks. - optimized some ZatPoint calls for floating point planes. --- src/p_maputl.h | 8 ++++---- src/r_things.cpp | 15 +++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/p_maputl.h b/src/p_maputl.h index e075f5f6d..d53ab49a7 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -38,12 +38,12 @@ struct intercept_t inline int P_PointOnLineSidePrecise(double x, double y, const line_t *line) { - return (y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - x) * line->Delta().Y > EQUAL_EPSILON; + return (y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - x) * line->Delta().Y > -EQUAL_EPSILON; } inline int P_PointOnLineSidePrecise(const DVector2 &pt, const line_t *line) { - return (pt.Y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - pt.X) * line->Delta().Y > EQUAL_EPSILON; + return (pt.Y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - pt.X) * line->Delta().Y > -EQUAL_EPSILON; } inline int P_PointOnLineSide (double x, double y, const line_t *line) @@ -73,12 +73,12 @@ inline int P_PointOnLineSide(const DVector2 & p, const line_t *line) inline int P_PointOnDivlineSide(double x, double y, const divline_t *line) { - return (y - line->y) * line->dx + (line->x - x) * line->dy > EQUAL_EPSILON; + return (y - line->y) * line->dx + (line->x - x) * line->dy > -EQUAL_EPSILON; } inline int P_PointOnDivlineSide(const DVector2 &pos, const divline_t *line) { - return (pos.Y - line->y) * line->dx + (line->x - pos.X) * line->dy > EQUAL_EPSILON; + return (pos.Y - line->y) * line->dx + (line->x - pos.X) * line->dy > -EQUAL_EPSILON; } //========================================================================== diff --git a/src/r_things.cpp b/src/r_things.cpp index 7eb1095da..465b6c30f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -728,7 +728,6 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop // void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling) { - fixed_t fx, fy, fz; fixed_t tr_x; fixed_t tr_y; @@ -768,9 +767,9 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor // [RH] Interpolate the sprite's position to make it look smooth DVector3 pos = thing->InterpolatedPosition(r_TicFracF); - fx = FLOAT2FIXED(pos.X); - fy = FLOAT2FIXED(pos.Y); - fz = FLOAT2FIXED(pos.Z + thing->GetBobOffset(r_TicFracF)); + const fixed_t fx = FLOAT2FIXED(pos.X); + const fixed_t fy = FLOAT2FIXED(pos.Y); + fixed_t fz = FLOAT2FIXED(pos.Z + thing->GetBobOffset(r_TicFracF)); tex = NULL; voxel = NULL; @@ -937,19 +936,19 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor { if (fakeside == FAKED_AboveCeiling) { - if (gzt < heightsec->ceilingplane.ZatPointFixed(fx, fy)) + if (gzt < heightsec->ceilingplane.ZatPointFixed(pos)) return; } else if (fakeside == FAKED_BelowFloor) { - if (gzb >= heightsec->floorplane.ZatPointFixed(fx, fy)) + if (gzb >= heightsec->floorplane.ZatPointFixed(pos)) return; } else { - if (gzt < heightsec->floorplane.ZatPointFixed(fx, fy)) + if (gzt < heightsec->floorplane.ZatPointFixed(pos)) return; - if (!(heightsec->MoreFlags & SECF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPointFixed(fx, fy)) + if (!(heightsec->MoreFlags & SECF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPointFixed(pos)) return; } } From fc5f98a0be0ef2374c6295beede78a0d46d571c2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 19:28:53 +0200 Subject: [PATCH 07/12] - floatified the sector planes. This should conclude the floating point conversions for now. --- src/p_sectors.cpp | 8 ++-- src/r_defs.h | 102 +++++++++++++++++++--------------------------- src/r_plane.cpp | 2 +- 3 files changed, 47 insertions(+), 65 deletions(-) diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index e5f837ad3..55625c9c5 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -1112,11 +1112,11 @@ bool secplane_t::CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) cons FArchive &operator<< (FArchive &arc, secplane_t &plane) { - arc << plane.a << plane.b << plane.c << plane.d; - //if (plane.c != 0) + arc << plane.normal << plane.D; + if (plane.normal.Z != 0) { // plane.c should always be non-0. Otherwise, the plane - // would be perfectly vertical. - plane.ic = DivScale32 (1, plane.c); + // would be perfectly vertical. (But then, don't let this crash on a broken savegame...) + plane.negiC = -1 / plane.normal.Z; } return arc; } diff --git a/src/r_defs.h b/src/r_defs.h index d47e82386..81e6ec4b9 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -284,80 +284,67 @@ struct secplane_t // ic is 1/c, for faster Z calculations private: - fixed_t a, b, c, d, ic; + DVector3 normal; + double D, negiC; // negative iC because that also saves a negation in all methods using this. public: void set(double aa, double bb, double cc, double dd) { - a = FLOAT2FIXED(aa); - b = FLOAT2FIXED(bb); - c = FLOAT2FIXED(cc); - d = FLOAT2FIXED(dd); - ic = FixedDiv(FRACUNIT, c); - } - - void setD(fixed_t dd) - { - d = dd; - } - - void changeD(fixed_t dd) - { - d += dd; + normal.X = aa; + normal.Y = bb; + normal.Z = cc; + D = dd; + negiC = -1 / cc; } void setD(double dd) { - d = FLOAT2FIXED(dd); + D = dd; } double fA() const { - return FIXED2DBL(a); + return normal.X; } double fB() const { - return FIXED2DBL(b); + return normal.Y; } double fC() const { - return FIXED2DBL(c); + return normal.Z; } double fD() const { - return FIXED2DBL(d); + return D; } - double fiC() const - { - return FIXED2DBL(ic); - } - + bool isSlope() const { - return a != 0 || b != 0; + return !normal.XY().isZero(); } DVector3 Normal() const { - return{ fA(), fB(), fC() }; + return normal; } // Returns < 0 : behind; == 0 : on; > 0 : in front int PointOnSide (fixed_t x, fixed_t y, fixed_t z) const { - return TMulScale16(a,x, b,y, c,z) + d; + return PointOnSide(DVector3(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z))); } int PointOnSide(const DVector3 &pos) const { - double v = a * pos.X + b * pos.Y + c * pos.Z + d; + double v = (normal | pos) + D; return v < -EQUAL_EPSILON ? -1 : v > EQUAL_EPSILON ? 1 : 0; } // Returns the value of z at (0,0) This is used by the 3D floor code which does not handle slopes fixed_t Zat0 () const { - return ic < 0 ? d : -d; + return FLOAT2FIXED(negiC*D); } // Returns the value of z at (x,y) @@ -365,7 +352,7 @@ public: fixed_t ZatPointFixed(fixed_t x, fixed_t y) const { - return FixedMul (ic, -d - DMulScale16 (a, x, b, y)); + return FLOAT2FIXED(ZatPoint(FIXED2DBL(x), FIXED2DBL(y))); } // This is for the software renderer @@ -383,106 +370,101 @@ public: // Returns the value of z at (x,y) as a double double ZatPoint (double x, double y) const { - return (d + a*x + b*y) * ic / (-65536.0 * 65536.0); + return (D + normal.X*x + normal.Y*y) * negiC; } double ZatPoint(const DVector2 &pos) const { - return (d + a*pos.X + b*pos.Y) * ic / (-65536.0 * 65536.0); + return (D + normal.X*pos.X + normal.Y*pos.Y) * negiC; } double ZatPoint(const vertex_t *v) const { - return (d + a*v->fX() + b*v->fY()) * ic / (-65536.0 * 65536.0); + return (D + normal.X*v->fX() + normal.Y*v->fY()) * negiC; } double ZatPoint(const AActor *ac) const { - return (d + a*ac->X() + b*ac->Y()) * ic / (-65536.0 * 65536.0); + return (D + normal.X*ac->X() + normal.Y*ac->Y()) * negiC; } // Returns the value of z at vertex v if d is equal to dist double ZatPointDist(const vertex_t *v, double dist) { - return (dist + a*v->fX() + b*v->fY()) * ic / (-65536.0 * 65536.0); + return (dist + normal.X*v->fX() + normal.Y*v->fY()) * negiC; } // Flips the plane's vertical orientiation, so that if it pointed up, // it will point down, and vice versa. void FlipVert () { - a = -a; - b = -b; - c = -c; - d = -d; - ic = -ic; + normal = -normal; + D = -D; + negiC = -negiC; } // Returns true if 2 planes are the same bool operator== (const secplane_t &other) const { - return a == other.a && b == other.b && c == other.c && d == other.d; + return normal == other.normal && D == other.D; } // Returns true if 2 planes are different bool operator!= (const secplane_t &other) const { - return a != other.a || b != other.b || c != other.c || d != other.d; + return normal != other.normal || D != other.D; } // Moves a plane up/down by hdiff units void ChangeHeight(double hdiff) { - d = d - fixed_t(hdiff * c); + D = D - hdiff * normal.Z; } // Moves a plane up/down by hdiff units double GetChangedHeight(double hdiff) { - return fD() - hdiff * fC(); + return D - hdiff * normal.Z; } // Returns how much this plane's height would change if d were set to oldd double HeightDiff(double oldd) const { - return (oldd - fD()) * fiC(); + return (D - oldd) * negiC; } // Returns how much this plane's height would change if d were set to oldd double HeightDiff(double oldd, double newd) const { - return (oldd - newd) * fiC(); + return (newd - oldd) * negiC; } double PointToDist(const DVector2 &xy, double z) const { - return -(a * xy.X + b * xy.Y + c * z) / 65536.; + return -(normal.X * xy.X + normal.Y * xy.Y + normal.Z * z); } double PointToDist(const vertex_t *v, double z) const { - return -(a * v->fX() + b * v->fY() + c * z) / 65536.; + return -(normal.X * v->fX() + normal.Y * v->fY() + normal.Z * z); } - void SetAtHeight(fixed_t height, int ceiling) + void SetAtHeight(double height, int ceiling) { - a = b = 0; + normal.X = normal.Y = 0; if (ceiling) { - c = ic = -FRACUNIT; - d = height; + normal.Z = negiC = 1; + D = height; } else { - c = ic = FRACUNIT; - d = -height; + normal.Z = negiC = -1; + D = -height; } } - inline void SetAtHeight(double height, int ceiling) - { - SetAtHeight(FLOAT2FIXED(clamp(height, -32767., 32767.)), ceiling); - } + inline void SetAtHeight(fixed_t height, int ceiling) = delete; bool CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) const; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 61b969a4e..e24bbe0b6 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1568,7 +1568,7 @@ void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske basexfrac = FixedMul (xscale, finecosine[planeang]) + x*xstepscale; baseyfrac = FixedMul (yscale, -finesine[planeang]) + x*ystepscale; - planeheight = abs (int(pl->height.fD() * -pl->height.fiC() * 65536) - viewz); + planeheight = abs (pl->height.Zat0() - viewz); GlobVis = FixedDiv (r_FloorVisibility, planeheight); if (fixedlightlev >= 0) From 4e5ba49acafeca2fd2e6d04bb06d121ac29eef04 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 19:46:00 +0200 Subject: [PATCH 08/12] - got rid of secplane_t::fA and fB. All uses could be replaced by other functions. --- src/p_map.cpp | 13 ++++++------- src/p_sectors.cpp | 4 ++-- src/p_trace.cpp | 4 ++-- src/r_defs.h | 8 -------- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 564b79b93..9700eda4e 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2945,7 +2945,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move) double t; dest = actor->Pos() + move; - t = plane->fA() * dest.X + plane->fB() * dest.Y + plane->fC() * actor->Z() + plane->fD(); + t = (plane->Normal() | DVector3(dest, actor->Z())) + plane->fD(); if (t < 0) { // Desired location is behind (below) the plane // (i.e. Walking up the plane) @@ -2979,16 +2979,16 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move) } if (dopush) { - actor->Vel.X = move.X = plane->fA() * 2; - actor->Vel.Y = move.Y = plane->fB() * 2; + move = plane->Normal() * 2; + actor->Vel.X = move.X; + actor->Vel.Y = move.Y; } return (actor->floorsector == actor->Sector) ? plane : NULL; } } // Slide the desired location along the plane's normal // so that it lies on the plane's surface - dest.X -= plane->fA() * t; - dest.Y -= plane->fB() * t; + dest -= plane->Normal() * t; move = dest - actor->Pos().XY(); return (actor->floorsector == actor->Sector) ? plane : NULL; } @@ -2998,8 +2998,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move) { // Actor's current spot is on/in the plane, so walk down it // Same principle as walking up, except reversed - dest.X += plane->fA() * t; - dest.Y += plane->fB() * t; + dest += plane->Normal() * t; move = dest - actor->Pos().XY(); return (actor->floorsector == actor->Sector) ? plane : NULL; } diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 55625c9c5..11ee3178e 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -1086,11 +1086,11 @@ bool secplane_t::CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) cons // If the planes do not have matching slopes, then always copy them // because clipping would require creating new sectors. - if (fA() != dest->fA() || fB() != dest->fB() || fC() != dest->fC()) + if (Normal() != dest->Normal()) { copy = true; } - else if (opp->fA() != -dest->fA() || opp->fB() != -dest->fB() || opp->fC() != -dest->fC()) + else if (opp->Normal() != -dest->Normal()) { if (fD() < dest->fD()) { diff --git a/src/p_trace.cpp b/src/p_trace.cpp index b5346d96d..dabc92110 100644 --- a/src/p_trace.cpp +++ b/src/p_trace.cpp @@ -877,11 +877,11 @@ bool FTraceInfo::TraceTraverse (int ptflags) bool FTraceInfo::CheckPlane (const secplane_t &plane) { - double den = plane.fA() * Vec.X + plane.fB() * Vec.Y + plane.fC() * Vec.Z; + double den = plane.Normal() | Vec; if (den != 0) { - double num = plane.fA() * Start.X + plane.fB() * Start.Y + plane.fC() * Start.Z + plane.fD(); + double num = (plane.Normal() | Start) + plane.fD(); double hitdist = -num / den; diff --git a/src/r_defs.h b/src/r_defs.h index 81e6ec4b9..c70cd1b5e 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -302,14 +302,6 @@ public: D = dd; } - double fA() const - { - return normal.X; - } - double fB() const - { - return normal.Y; - } double fC() const { return normal.Z; From 3ee42f6aa663b9cc3b2fab4729a84b20e36ea1c7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 20:55:23 +0200 Subject: [PATCH 09/12] - removed all savegame compatibility handling, since the data is just too different from what it was before to try to convert it. --- src/g_game.cpp | 7 -- src/g_level.cpp | 96 ++++--------------------- src/g_shared/a_armor.cpp | 7 +- src/g_shared/a_artifacts.cpp | 9 +-- src/g_shared/a_lightning.cpp | 20 ------ src/g_shared/a_weapons.cpp | 20 ++---- src/g_shared/hudmessages.cpp | 52 +++----------- src/g_shared/shared_sbar.cpp | 12 +--- src/p_acs.cpp | 133 +++++++++++++---------------------- src/p_mobj.cpp | 101 ++++++-------------------- src/p_saveg.cpp | 93 +++--------------------- src/p_sectors.cpp | 24 ++----- src/p_spec.cpp | 59 +++++----------- src/p_user.cpp | 123 ++++---------------------------- src/version.h | 4 +- 15 files changed, 153 insertions(+), 607 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 2334c1ec1..7c31e09c0 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1929,13 +1929,6 @@ void G_DoLoadGame () BYTE *vars_p = (BYTE *)text; C_ReadCVars (&vars_p); delete[] text; - if (SaveVersion <= 4509) - { - // account for the flag shuffling for making freelook a 3-state option - INTBOOL flag = dmflags & DF_YES_FREELOOK; - dmflags = dmflags & ~DF_YES_FREELOOK; - if (flag) dmflags2 = dmflags2 | DF2_RESPAWN_SUPER; - } } // dearchive all the modifications diff --git a/src/g_level.cpp b/src/g_level.cpp index 5bacb9cf0..9d4069a9a 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1493,26 +1493,11 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad) << level.maptime << i; - if (SaveVersion >= 3313) - { - // This is a player property now - int nextmusic; - arc << nextmusic; - } - // Hub transitions must keep the current total time if (!hubLoad) level.totaltime = i; - if (SaveVersion >= 4507) - { - arc << level.skytexture1 << level.skytexture2; - } - else - { - level.skytexture1 = TexMan.GetTexture(arc.ReadName(), FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst); - level.skytexture2 = TexMan.GetTexture(arc.ReadName(), FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst); - } + arc << level.skytexture1 << level.skytexture2; if (arc.IsLoading()) { sky1texture = level.skytexture1; @@ -1553,12 +1538,7 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad) P_SerializeSubsectors(arc); StatusBar->Serialize (arc); - if (SaveVersion >= 4222) - { // This must be done *after* thinkers are serialized. - arc << level.DefaultSkybox; - } - - arc << level.total_monsters << level.total_items << level.total_secrets; + arc << level.DefaultSkybox << level.total_monsters << level.total_items << level.total_secrets; // Does this level have custom translations? FRemapTable *trans; @@ -1788,8 +1768,6 @@ void G_WriteSnapshots (FILE *file) void G_ReadSnapshots (PNGHandle *png) { DWORD chunkLen; - BYTE namelen; - char mapname[256]; FString MapName; level_info_t *i; @@ -1802,14 +1780,7 @@ void G_ReadSnapshots (PNGHandle *png) DWORD snapver; arc << snapver; - if (SaveVersion < 4508) - { - arc << namelen; - arc.Read(mapname, namelen); - mapname[namelen] = 0; - MapName = mapname; - } - else arc << MapName; + arc << MapName; i = FindLevelInfo (MapName); i->snapshotVer = snapver; i->snapshot = new FCompressedMemFile; @@ -1824,14 +1795,7 @@ void G_ReadSnapshots (PNGHandle *png) DWORD snapver; arc << snapver; - if (SaveVersion < 4508) - { - arc << namelen; - arc.Read(mapname, namelen); - mapname[namelen] = 0; - MapName = mapname; - } - else arc << MapName; + arc << MapName; TheDefaultLevelInfo.snapshotVer = snapver; TheDefaultLevelInfo.snapshot = new FCompressedMemFile; TheDefaultLevelInfo.snapshot->Serialize (arc); @@ -1842,25 +1806,10 @@ void G_ReadSnapshots (PNGHandle *png) { FPNGChunkArchive arc (png->File->GetFile(), VIST_ID, chunkLen); - if (SaveVersion < 4508) + while (arc << MapName, MapName.Len() > 0) { - arc << namelen; - while (namelen != 0) - { - arc.Read(mapname, namelen); - mapname[namelen] = 0; - i = FindLevelInfo(mapname); - i->flags |= LEVEL_VISITED; - arc << namelen; - } - } - else - { - while (arc << MapName, MapName.Len() > 0) - { - i = FindLevelInfo(MapName); - i->flags |= LEVEL_VISITED; - } + i = FindLevelInfo(MapName); + i->flags |= LEVEL_VISITED; } } @@ -1956,8 +1905,6 @@ void P_WriteACSDefereds (FILE *file) void P_ReadACSDefereds (PNGHandle *png) { - BYTE namelen; - char mapname[256]; FString MapName; size_t chunklen; @@ -1967,33 +1914,14 @@ void P_ReadACSDefereds (PNGHandle *png) { FPNGChunkArchive arc (png->File->GetFile(), ACSD_ID, chunklen); - if (SaveVersion < 4508) + while (arc << MapName, MapName.Len() > 0) { - arc << namelen; - while (namelen != 0) + level_info_t *i = FindLevelInfo(MapName); + if (i == NULL) { - arc.Read(mapname, namelen); - mapname[namelen] = 0; - level_info_t *i = FindLevelInfo(mapname); - if (i == NULL) - { - I_Error("Unknown map '%s' in savegame", mapname); - } - arc << i->defered; - arc << namelen; - } - } - else - { - while (arc << MapName, MapName.Len() > 0) - { - level_info_t *i = FindLevelInfo(MapName); - if (i == NULL) - { - I_Error("Unknown map '%s' in savegame", MapName.GetChars()); - } - arc << i->defered; + I_Error("Unknown map '%s' in savegame", MapName.GetChars()); } + arc << i->defered; } } png->File->ResetFilePtr(); diff --git a/src/g_shared/a_armor.cpp b/src/g_shared/a_armor.cpp index 8b911ce28..2b783e380 100644 --- a/src/g_shared/a_armor.cpp +++ b/src/g_shared/a_armor.cpp @@ -24,12 +24,7 @@ IMPLEMENT_CLASS (AHexenArmor) void ABasicArmor::Serialize (FArchive &arc) { Super::Serialize (arc); - arc << SavePercent << BonusCount << MaxAbsorb << MaxFullAbsorb << AbsorbCount << ArmorType; - - if (SaveVersion >= 4511) - { - arc << ActualSaveAmount; - } + arc << SavePercent << BonusCount << MaxAbsorb << MaxFullAbsorb << AbsorbCount << ArmorType << ActualSaveAmount; } //=========================================================================== diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 7a615b0c4..1efb4e8ee 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1205,14 +1205,7 @@ IMPLEMENT_CLASS (APowerSpeed) void APowerSpeed::Serialize(FArchive &arc) { Super::Serialize (arc); - if (SaveVersion < 4146) - { - SpeedFlags = 0; - } - else - { - arc << SpeedFlags; - } + arc << SpeedFlags; } //=========================================================================== diff --git a/src/g_shared/a_lightning.cpp b/src/g_shared/a_lightning.cpp index 5a53bea37..2f2c4e235 100644 --- a/src/g_shared/a_lightning.cpp +++ b/src/g_shared/a_lightning.cpp @@ -44,26 +44,6 @@ void DLightningThinker::Serialize (FArchive &arc) arc << Stopped << NextLightningFlash << LightningFlashCount; - if (SaveVersion < 3243) - { - // Do nothing with old savegames and just keep whatever the constructor made - // but read the obsolete data from the savegame - for (i = (numsectors + (numsectors+7)/8); i > 0; --i) - { - if (SaveVersion < 3223) - { - BYTE bytelight; - arc << bytelight; - } - else - { - short shortlight; - arc << shortlight; - } - } - return; - } - if (arc.IsLoading ()) { if (LightningLightLevels != NULL) diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 9afa850bd..971d974de 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -90,16 +90,11 @@ void AWeapon::Serialize (FArchive &arc) << MoveCombatDist << Ammo1 << Ammo2 << SisterWeapon << GivenAsMorphWeapon << bAltFire - << ReloadCounter; - if (SaveVersion >= 3615) { - arc << BobStyle << BobSpeed << BobRangeX << BobRangeY; - } - arc << FOVScale - << Crosshair; - if (SaveVersion >= 4203) - { - arc << MinSelAmmo1 << MinSelAmmo2; - } + << ReloadCounter + << BobStyle << BobSpeed << BobRangeX << BobRangeY + << FOVScale + << Crosshair + << MinSelAmmo1 << MinSelAmmo2; } //=========================================================================== @@ -731,10 +726,7 @@ IMPLEMENT_CLASS(AWeaponGiver) void AWeaponGiver::Serialize(FArchive &arc) { Super::Serialize(arc); - if (SaveVersion >= 4246) - { - arc << DropAmmoFactor; - } + arc << DropAmmoFactor; } bool AWeaponGiver::TryPickup(AActor *&toucher) diff --git a/src/g_shared/hudmessages.cpp b/src/g_shared/hudmessages.cpp index 8f8100cdc..0ee61f942 100644 --- a/src/g_shared/hudmessages.cpp +++ b/src/g_shared/hudmessages.cpp @@ -179,53 +179,23 @@ DHUDMessage::~DHUDMessage () // //============================================================================ -void DHUDMessage::Serialize (FArchive &arc) +void DHUDMessage::Serialize(FArchive &arc) { - Super::Serialize (arc); + Super::Serialize(arc); arc << Left << Top << CenterX << HoldTics << Tics << State << TextColor << SBarID << SourceText << Font << Next - << HUDWidth << HUDHeight; - if (SaveVersion >= 3960) - { - arc << NoWrap; - arc << ClipX << ClipY << ClipWidth << ClipHeight; - arc << WrapWidth; - } - else - { - NoWrap = false; - ClipX = ClipY = ClipWidth = ClipHeight = WrapWidth = 0; - } - if (SaveVersion >= 4525) - { - arc << HandleAspect; - } - else - { - HandleAspect = true; - } - if (arc.IsLoading ()) + << HUDWidth << HUDHeight + << NoWrap + << ClipX << ClipY << ClipWidth << ClipHeight + << WrapWidth + << HandleAspect + << VisibilityFlags + << Style << Alpha; + if (arc.IsLoading()) { Lines = NULL; - ResetText (SourceText); - } - if (SaveVersion < 3821) - { - VisibilityFlags = 0; - } - else - { - arc << VisibilityFlags; - } - if (SaveVersion < 3824) - { - Style = STYLE_Translucent; - Alpha = 1.; - } - else - { - arc << Style << Alpha; + ResetText(SourceText); } } diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index c1d7bfda1..b48c04893 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -1651,17 +1651,9 @@ void DBaseStatusBar::ReceivedWeapon (AWeapon *weapon) void DBaseStatusBar::Serialize (FArchive &arc) { - if (SaveVersion < 3821) + for (size_t i = 0; i < countof(Messages); ++i) { - memset(Messages, 0, sizeof(Messages)); - arc << Messages[HUDMSGLayer_Default]; - } - else - { - for (size_t i = 0; i < countof(Messages); ++i) - { - arc << Messages[i]; - } + arc << Messages[i]; } } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 89aaea088..ac5988a77 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1654,13 +1654,13 @@ void FBehavior::StaticSerializeModuleStates (FArchive &arc) if (arc.IsStoring()) { arc.WriteString (module->ModuleName); - if (SaveVersion >= 4516) arc << ModSize; + arc << ModSize; } else { char *modname = NULL; arc << modname; - if (SaveVersion >= 4516) arc << ModSize; + arc << ModSize; if (stricmp (modname, module->ModuleName) != 0) { delete[] modname; @@ -2899,35 +2899,19 @@ void FBehavior::StaticStopMyScripts (AActor *actor) void P_SerializeACSScriptNumber(FArchive &arc, int &scriptnum, bool was2byte) { - if (SaveVersion < 3359) + arc << scriptnum; + // If the script number is negative, then it's really a name. + // So read/store the name after it. + if (scriptnum < 0) { - if (was2byte) + if (arc.IsStoring()) { - WORD oldver; - arc << oldver; - scriptnum = oldver; + arc.WriteName(FName(ENamedName(-scriptnum)).GetChars()); } else { - arc << scriptnum; - } - } - else - { - arc << scriptnum; - // If the script number is negative, then it's really a name. - // So read/store the name after it. - if (scriptnum < 0) - { - if (arc.IsStoring()) - { - arc.WriteName(FName(ENamedName(-scriptnum)).GetChars()); - } - else - { - const char *nam = arc.ReadName(); - scriptnum = -FName(nam); - } + const char *nam = arc.ReadName(); + scriptnum = -FName(nam); } } } @@ -2969,52 +2953,47 @@ void DACSThinker::Serialize (FArchive &arc) int scriptcount = 0; Super::Serialize (arc); - if (SaveVersion < 4515) - arc << Scripts << LastScript; + if (arc.IsStoring()) + { + DLevelScript *script; + script = Scripts; + while (script) + { + scriptcount++; + + // We want to store this list backwards, so we can't loose the last pointer + if (script->next == NULL) + break; + script = script->next; + } + arc << scriptcount; + + while (script) + { + arc << script; + script = script->prev; + } + } else { - if (arc.IsStoring()) + // We are running through this list backwards, so the next entry is the last processed + DLevelScript *next = NULL; + arc << scriptcount; + Scripts = NULL; + LastScript = NULL; + for (int i = 0; i < scriptcount; i++) { - DLevelScript *script; - script = Scripts; - while (script) - { - scriptcount++; + arc << Scripts; - // We want to store this list backwards, so we can't loose the last pointer - if (script->next == NULL) - break; - script = script->next; - } - arc << scriptcount; + Scripts->next = next; + Scripts->prev = NULL; + if (next != NULL) + next->prev = Scripts; - while (script) - { - arc << script; - script = script->prev; - } - } - else - { - // We are running through this list backwards, so the next entry is the last processed - DLevelScript *next = NULL; - arc << scriptcount; - Scripts = NULL; - LastScript = NULL; - for (int i = 0; i < scriptcount; i++) - { - arc << Scripts; + next = Scripts; - Scripts->next = next; - Scripts->prev = NULL; - if (next != NULL) - next->prev = Scripts; - - next = Scripts; - - if (i == 0) - LastScript = Scripts; - } + if (i == 0) + LastScript = Scripts; } } if (arc.IsStoring ()) @@ -3102,8 +3081,6 @@ void DLevelScript::Serialize (FArchive &arc) DWORD i; Super::Serialize (arc); - if (SaveVersion < 4515) - arc << next << prev; P_SerializeACSScriptNumber(arc, script, false); @@ -3140,23 +3117,9 @@ void DLevelScript::Serialize (FArchive &arc) arc << activefont << hudwidth << hudheight; - if (SaveVersion >= 3960) - { - arc << ClipRectLeft << ClipRectTop << ClipRectWidth << ClipRectHeight - << WrapWidth; - } - else - { - ClipRectLeft = ClipRectTop = ClipRectWidth = ClipRectHeight = WrapWidth = 0; - } - if (SaveVersion >= 4058) - { - arc << InModuleScriptNumber; - } - else - { // Don't worry about locating profiling info for old saves. - InModuleScriptNumber = -1; - } + arc << ClipRectLeft << ClipRectTop << ClipRectWidth << ClipRectHeight + << WrapWidth; + arc << InModuleScriptNumber; } DLevelScript::DLevelScript () diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index a05c7ca6d..0bbda1568 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -275,29 +275,17 @@ void AActor::Serialize(FArchive &arc) arc << dmg; Damage = UncalcDamageValue(dmg, GetDefault()->Damage); } - if (SaveVersion >= 4530) - { - P_SerializeTerrain(arc, floorterrain); - } - if (SaveVersion >= 3227) - { - arc << projectileKickback; - } - arc << flags + P_SerializeTerrain(arc, floorterrain); + arc << projectileKickback + << flags << flags2 << flags3 << flags4 << flags5 - << flags6; - if (SaveVersion >= 4504) - { - arc << flags7; - } - if (SaveVersion >= 4512) - { - arc << weaponspecial; - } - arc << special1 + << flags6 + << flags7 + << weaponspecial + << special1 << special2 << specialf1 << specialf2 @@ -313,12 +301,9 @@ void AActor::Serialize(FArchive &arc) << threshold << player << SpawnPoint - << SpawnAngle; - if (SaveVersion >= 4506) - { - arc << StartHealth; - } - arc << skillrespawncount + << SpawnAngle + << StartHealth + << skillrespawncount << tracer << Floorclip << tid @@ -332,21 +317,13 @@ void AActor::Serialize(FArchive &arc) arc << args[0]; } arc << args[1] << args[2] << args[3] << args[4]; - if (SaveVersion >= 3427) - { - arc << accuracy << stamina; - } + arc << accuracy << stamina; arc << goal << waterlevel << MinMissileChance << SpawnFlags << Inventory << InventoryID; - if (SaveVersion < 4513) - { - SDWORD id; - arc << id; - } arc << FloatBobPhase << Translation << SeeSound @@ -376,16 +353,9 @@ void AActor::Serialize(FArchive &arc) << meleethreshold << meleerange << DamageType; - if (SaveVersion >= 4501) - { - arc << DamageTypeReceived; - } - if (SaveVersion >= 3237) - { - arc - << PainType + arc << DamageTypeReceived; + arc << PainType << DeathType; - } arc << Gravity << FastChaseStrafeCount << master @@ -396,48 +366,23 @@ void AActor::Serialize(FArchive &arc) << pushfactor << Species << Score; - if (SaveVersion >= 3113) - { - arc << DesignatedTeam; - } + arc << DesignatedTeam; arc << lastpush << lastbump << PainThreshold << DamageFactor; - if (SaveVersion >= 4516) - { - arc << DamageMultiply; - } - else - { - DamageMultiply = 1.; - } + arc << DamageMultiply; arc << WeaveIndexXY << WeaveIndexZ << PoisonDamageReceived << PoisonDurationReceived << PoisonPeriodReceived << Poisoner << PoisonDamage << PoisonDuration << PoisonPeriod; - if (SaveVersion >= 3235) - { - arc << PoisonDamageType << PoisonDamageTypeReceived; - } + arc << PoisonDamageType << PoisonDamageTypeReceived; arc << ConversationRoot << Conversation; - if (SaveVersion >= 4509) - { - arc << FriendPlayer; - } - if (SaveVersion >= 4517) - { - arc << TeleFogSourceType - << TeleFogDestType; - } - if (SaveVersion >= 4518) - { - arc << RipperLevel - << RipLevelMin - << RipLevelMax; - } - if (SaveVersion >= 4533) - { - arc << DefThreshold; - } + arc << FriendPlayer; + arc << TeleFogSourceType + << TeleFogDestType; + arc << RipperLevel + << RipLevelMin + << RipLevelMax; + arc << DefThreshold; { FString tagstr; diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index d16b76457..38122b977 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -341,22 +341,8 @@ void P_SerializeWorld (FArchive &arc) { arc << sec->floorplane << sec->ceilingplane; - if (SaveVersion < 3223) - { - BYTE bytelight; - arc << bytelight; - sec->lightlevel = bytelight; - } - else - { - arc << sec->lightlevel; - } + arc << sec->lightlevel; arc << sec->special; - if (SaveVersion < 4523) - { - short tag; - arc << tag; - } arc << sec->soundtraversed << sec->seqType << sec->friction @@ -372,49 +358,12 @@ void P_SerializeWorld (FArchive &arc) << sec->heightsec << sec->bottommap << sec->midmap << sec->topmap << sec->gravity; - if (SaveVersion >= 4530) - { - P_SerializeTerrain(arc, sec->terrainnum[0]); - P_SerializeTerrain(arc, sec->terrainnum[1]); - } - if (SaveVersion >= 4529) - { - arc << sec->damageamount; - } - else - { - short dmg; - arc << dmg; - sec->damageamount = dmg; - } - if (SaveVersion >= 4528) - { - arc << sec->damageinterval - << sec->leakydamage - << sec->damagetype; - } - else - { - short damagemod; - arc << damagemod; - sec->damagetype = MODtoDamageType(damagemod); - if (sec->damageamount < 20) - { - sec->leakydamage = 0; - sec->damageinterval = 32; - } - else if (sec->damageamount < 50) - { - sec->leakydamage = 5; - sec->damageinterval = 32; - } - else - { - sec->leakydamage = 256; - sec->damageinterval = 1; - } - } - + P_SerializeTerrain(arc, sec->terrainnum[0]); + P_SerializeTerrain(arc, sec->terrainnum[1]); + arc << sec->damageamount; + arc << sec->damageinterval + << sec->leakydamage + << sec->damagetype; arc << sec->SoundTarget << sec->SecActTarget << sec->sky @@ -422,13 +371,6 @@ void P_SerializeWorld (FArchive &arc) << sec->Flags << sec->SkyBoxes[sector_t::floor] << sec->SkyBoxes[sector_t::ceiling] << sec->ZoneNumber; - if (SaveVersion < 4529) - { - short secretsector; - arc << secretsector; - if (secretsector) sec->Flags |= SECF_WASSECRET; - P_InitSectorSpecial(sec, sec->special, true); - } arc << sec->interpolations[0] << sec->interpolations[1] << sec->interpolations[2] @@ -461,11 +403,6 @@ void P_SerializeWorld (FArchive &arc) << li->special << li->Alpha; - if (SaveVersion < 4523) - { - int id; - arc << id; - } if (P_IsACSSpecial(li->special)) { P_SerializeACSScriptNumber(arc, li->args[0], false); @@ -476,12 +413,7 @@ void P_SerializeWorld (FArchive &arc) } arc << li->args[1] << li->args[2] << li->args[3] << li->args[4]; - if (SaveVersion >= 4532) - { - arc << li->portalindex; - } - else li->portalindex = UINT_MAX; - + arc << li->portalindex; for (j = 0; j < 2; j++) { if (li->sidedef[j] == NULL) @@ -517,14 +449,7 @@ void P_SerializeWorld (FArchive &arc) arc << zn->Environment; } - if (SaveVersion >= 4532) - { - arc << linePortals; - } - else - { - linePortals.Clear(); - } + arc << linePortals; P_CollectLinkedPortals(); } diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 11ee3178e..87c0c45bd 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -1052,24 +1052,12 @@ double sector_t::NextLowestFloorAt(double x, double y, double z, int flags, doub FArchive &operator<< (FArchive &arc, secspecial_t &p) { - if (SaveVersion < 4529) - { - int special; - arc << special; - sector_t sec; - memset(&sec, 0, sizeof(sec)); - P_InitSectorSpecial(&sec, special, true); - sec.GetSpecial(&p); - } - else - { - arc << p.special - << p.damageamount - << p.damagetype - << p.damageinterval - << p.leakydamage - << p.Flags; - } + arc << p.special + << p.damageamount + << p.damagetype + << p.damageinterval + << p.leakydamage + << p.Flags; return arc; } diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 9a575912b..c39b3ba69 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -665,16 +665,7 @@ IMPLEMENT_CLASS (DLightTransfer) void DLightTransfer::Serialize (FArchive &arc) { Super::Serialize (arc); - if (SaveVersion < 3223) - { - BYTE bytelight; - arc << bytelight; - LastLight = bytelight; - } - else - { - arc << LastLight; - } + arc << LastLight; arc << Source << TargetTag << CopyFloor; } @@ -762,16 +753,7 @@ IMPLEMENT_CLASS (DWallLightTransfer) void DWallLightTransfer::Serialize (FArchive &arc) { Super::Serialize (arc); - if (SaveVersion < 3223) - { - BYTE bytelight; - arc << bytelight; - LastLight = bytelight; - } - else - { - arc << LastLight; - } + arc << LastLight; arc << Source << TargetID << Flags; } @@ -1058,7 +1040,7 @@ static void P_SetupSectorDamage(sector_t *sector, int damage, int interval, int // ('fromload' is necessary to allow conversion upon savegame load.) // -void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) +void P_InitSectorSpecial(sector_t *sector, int special) { // [RH] All secret sectors are marked with a BOOM-ish bitfield if (sector->special & SECRET_MASK) @@ -1093,28 +1075,28 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) switch (sector->special) { case Light_Phased: - if (!nothinkers) new DPhased (sector, 48, 63 - (sector->lightlevel & 63)); + new DPhased (sector, 48, 63 - (sector->lightlevel & 63)); break; // [RH] Hexen-like phased lighting case LightSequenceStart: - if (!nothinkers) new DPhased (sector); + new DPhased (sector); break; case dLight_Flicker: - if (!nothinkers) new DLightFlash (sector); + new DLightFlash (sector); break; case dLight_StrobeFast: - if (!nothinkers) new DStrobe (sector, STROBEBRIGHT, FASTDARK, false); + new DStrobe (sector, STROBEBRIGHT, FASTDARK, false); break; case dLight_StrobeSlow: - if (!nothinkers) new DStrobe (sector, STROBEBRIGHT, SLOWDARK, false); + new DStrobe (sector, STROBEBRIGHT, SLOWDARK, false); break; case dLight_Strobe_Hurt: - if (!nothinkers) new DStrobe (sector, STROBEBRIGHT, FASTDARK, false); + new DStrobe (sector, STROBEBRIGHT, FASTDARK, false); P_SetupSectorDamage(sector, 20, 32, 5, NAME_Slime, 0); break; @@ -1127,7 +1109,7 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) break; case dLight_Glow: - if (!nothinkers) new DGlow (sector); + new DGlow (sector); break; case dSector_DoorCloseIn30: @@ -1139,11 +1121,11 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) break; case dLight_StrobeSlowSync: - if (!nothinkers) new DStrobe (sector, STROBEBRIGHT, SLOWDARK, true); + new DStrobe (sector, STROBEBRIGHT, SLOWDARK, true); break; case dLight_StrobeFastSync: - if (!nothinkers) new DStrobe (sector, STROBEBRIGHT, FASTDARK, true); + new DStrobe (sector, STROBEBRIGHT, FASTDARK, true); break; case dSector_DoorRaiseIn5Mins: @@ -1161,7 +1143,7 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) break; case dLight_FireFlicker: - if (!nothinkers) new DFireFlicker (sector); + new DFireFlicker (sector); break; case dDamage_LavaWimpy: @@ -1174,11 +1156,8 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) case dScroll_EastLavaDamage: P_SetupSectorDamage(sector, 5, 32, 256, NAME_Fire, SECF_DMGTERRAINFX); - if (!nothinkers) - { - new DStrobe(sector, STROBEBRIGHT, FASTDARK, false); - P_CreateScroller(EScroll::sc_floor, -4., 0, -1, int(sector - sectors), 0); - } + new DStrobe(sector, STROBEBRIGHT, FASTDARK, false); + P_CreateScroller(EScroll::sc_floor, -4., 0, -1, int(sector - sectors), 0); keepspecial = true; break; @@ -1188,7 +1167,7 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) case sLight_Strobe_Hurt: P_SetupSectorDamage(sector, 5, 32, 0, NAME_Slime, 0); - if (!nothinkers) new DStrobe (sector, STROBEBRIGHT, FASTDARK, false); + new DStrobe (sector, STROBEBRIGHT, FASTDARK, false); break; case sDamage_Hellslime: @@ -1237,13 +1216,13 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) int i = sector->special - Scroll_North_Slow; double dx = hexenScrollies[i][0] / 2.; double dy = hexenScrollies[i][1] / 2.; - if (!nothinkers) P_CreateScroller(EScroll::sc_floor, dx, dy, -1, int(sector-sectors), 0); + P_CreateScroller(EScroll::sc_floor, dx, dy, -1, int(sector-sectors), 0); } else if (sector->special >= Carry_East5 && sector->special <= Carry_East35) { // Heretic scroll special // Only east scrollers also scroll the texture - if (!nothinkers) P_CreateScroller(EScroll::sc_floor, + P_CreateScroller(EScroll::sc_floor, -0.5 * (1 << ((sector->special & 0xff) - Carry_East5)), 0, -1, int(sector-sectors), 0); } keepspecial = true; @@ -1272,7 +1251,7 @@ void P_SpawnSpecials (void) if (sector->special == 0) continue; - P_InitSectorSpecial(sector, sector->special, false); + P_InitSectorSpecial(sector, sector->special); } #ifndef NO_EDATA diff --git a/src/p_user.cpp b/src/p_user.cpp index 07b9ca20d..63f05ef32 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -643,28 +643,10 @@ void APlayerPawn::Serialize (FArchive &arc) << DamageFade << PlayerFlags << FlechetteType; - if (SaveVersion < 3829) - { - GruntSpeed = 12; - FallingScreamMinSpeed = 35; - FallingScreamMaxSpeed = 40; - } - else - { - arc << GruntSpeed << FallingScreamMinSpeed << FallingScreamMaxSpeed; - } - if (SaveVersion >= 4502) - { - arc << UseRange; - } - if (SaveVersion >= 4503) - { - arc << AirCapacity; - } - if (SaveVersion >= 4526) - { - arc << ViewHeight; - } + arc << GruntSpeed << FallingScreamMinSpeed << FallingScreamMaxSpeed; + arc << UseRange; + arc << AirCapacity; + arc << ViewHeight; } //=========================================================================== @@ -3039,11 +3021,6 @@ void player_t::Serialize (FArchive &arc) << centering << health << inventorytics; - if (SaveVersion < 4513) - { - bool backpack; - arc << backpack; - } arc << fragcount << spreecount << multicount @@ -3074,50 +3051,14 @@ void player_t::Serialize (FArchive &arc) << air_finished << turnticks << oldbuttons; - if (SaveVersion >= 4929) - { - arc << hazardtype - << hazardinterval; - } - bool IsBot = false; - if (SaveVersion >= 4514) - { - arc << Bot; - } - else - { - arc << IsBot; - } + arc << hazardtype + << hazardinterval; + arc << Bot; arc << BlendR << BlendG << BlendB << BlendA; - if (SaveVersion < 3427) - { - WORD oldaccuracy, oldstamina; - arc << oldaccuracy << oldstamina; - if (mo != NULL) - { - mo->accuracy = oldaccuracy; - mo->stamina = oldstamina; - } - } - if (SaveVersion < 4041) - { - // Move weapon state flags from cheats and into WeaponState. - WeaponState = ((cheats >> 14) & 1) | ((cheats & (0x37 << 24)) >> (24 - 1)); - cheats &= ~((1 << 14) | (0x37 << 24)); - } - if (SaveVersion < 4527) - { - BYTE oldWeaponState; - arc << oldWeaponState; - WeaponState = oldWeaponState; - } - else - { - arc << WeaponState; - } + arc << WeaponState; arc << LogText << ConversationNPC << ConversationPC @@ -3137,45 +3078,10 @@ void player_t::Serialize (FArchive &arc) << crouchviewdelta << original_cmd << original_oldbuttons; - - if (SaveVersion >= 3475) - { - arc << poisontype << poisonpaintype; - } - else if (poisoner != NULL) - { - poisontype = poisoner->DamageType; - poisonpaintype = poisoner->PainType != NAME_None ? poisoner->PainType : poisoner->DamageType; - } - - if (SaveVersion >= 3599) - { - arc << timefreezer; - } - else - { - cheats &= ~(1 << 15); // make sure old CF_TIMEFREEZE bit is cleared - } - if (SaveVersion < 3640) - { - cheats &= ~(1 << 17); // make sure old CF_REGENERATION bit is cleared - } - if (SaveVersion >= 3780) - { - arc << settings_controller; - } - else - { - settings_controller = (this - players == Net_Arbitrator); - } - if (SaveVersion >= 4505) - { - arc << onground; - } - else - { - onground = (mo->Z() <= mo->floorz) || (mo->flags2 & MF2_ONMOBJ) || (mo->BounceFlags & BOUNCE_MBF) || (cheats & CF_NOCLIP2); - } + arc << poisontype << poisonpaintype; + arc << timefreezer; + arc << settings_controller; + arc << onground; if (arc.IsLoading ()) { @@ -3188,10 +3094,7 @@ void player_t::Serialize (FArchive &arc) { userinfo.SkinChanged(skinname, CurrentPlayerClass); } - if (SaveVersion >= 4522) - { - arc << MUSINFOactor << MUSINFOtics; - } + arc << MUSINFOactor << MUSINFOtics; } bool P_IsPlayerTotallyFrozen(const player_t *player) diff --git a/src/version.h b/src/version.h index 1d0e7506c..3a79f24c7 100644 --- a/src/version.h +++ b/src/version.h @@ -72,11 +72,11 @@ const char *GetVersionString(); // SAVESIG should match SAVEVER. // MINSAVEVER is the minimum level snapshot version that can be loaded. -#define MINSAVEVER 4535 +#define MINSAVEVER 4536 // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4535 +#define SAVEVER 4536 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) From 02a586e6b212594ededbbfea521fad3cd69d14cd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 21:03:49 +0200 Subject: [PATCH 10/12] - removed a redundant Vec3Offset call in A_SpawnParticle. --- src/p_spec.h | 2 +- src/thingdef/thingdef_codeptr.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_spec.h b/src/p_spec.h index 7cabf0ad3..c934d7312 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -87,7 +87,7 @@ const double CARRYFACTOR = 3 / 32.; bool CheckIfExitIsGood (AActor *self, level_info_t *info); // at map load -void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers); +void P_InitSectorSpecial(sector_t *sector, int special); void P_SpawnSpecials (void); // every tic diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 14afa7114..4024b85bc 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3038,7 +3038,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle) acc.X = accelx * c + accely * s; acc.Y = accelx * s - accely * c; } - pos = self->Vec3Offset(xoff, yoff, zoff); P_SpawnParticle(self->Vec3Offset(pos), vel, acc, color, !!(flags & SPF_FULLBRIGHT), startalpha, lifetime, size, fadestep); } return 0; From 70b8afc5ec560b579c4d1c00503df0fa5e90adc0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 21:26:57 +0200 Subject: [PATCH 11/12] - fixed: A_CheckLOF did the trace pitch calculation wrong. --- src/thingdef/thingdef_codeptr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 4024b85bc..3adaf5a99 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3705,7 +3705,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) { offsetforward *= self->radius; offsetwidth *= self->radius; - } +} pos = self->PosPlusZ(offsetheight - self->Floorclip); @@ -3762,7 +3762,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) } else { - pitch -= VecToAngle(xydist, target->Center()); + pitch -= VecToAngle(xydist, target->Center() - pos.Z); } } else if (flags & CLOFF_ALLOWNULL) From 3f5e0c682eab9e369f65667a43ae86cf35ad5118 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 3 Apr 2016 21:41:58 +0200 Subject: [PATCH 12/12] - fixed: Due to the iteration limit of 100 in the path traverse code, running a trace was effectively limited to somewhere around 12800 map units. Also added the safer exit condition checks from the sight checking code to FPathTraverse. --- src/p_maputl.cpp | 21 +++++++++++++++------ src/p_sight.cpp | 4 ++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 6279a054f..f51baac16 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -1545,7 +1545,7 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags, // we want to use one list of checked actors for the entire operation FBlockThingsIterator btit; - for (count = 0 ; count < 100 ; count++) + for (count = 0 ; count < 1000 ; count++) { if (flags & PT_ADDLINES) { @@ -1557,26 +1557,30 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags, AddThingIntercepts(mapx, mapy, btit, compatible); } - if (mapx == xt2 && mapy == yt2) - { + // both coordinates reached the end, so end the traversing. + if ((mapxstep | mapystep) == 0) break; - } + // [RH] Handle corner cases properly instead of pretending they don't exist. switch (((xs_FloorToInt(yintercept) == mapy) << 1) | (xs_FloorToInt(xintercept) == mapx)) { case 0: // neither xintercept nor yintercept match! - count = 100; // Stop traversing, because somebody screwed up. + count = 1000; // Stop traversing, because somebody screwed up. break; case 1: // xintercept matches xintercept += xstep; mapy += mapystep; + if (mapy == mapey) + mapystep = 0; break; case 2: // yintercept matches yintercept += ystep; mapx += mapxstep; + if (mapx == mapex) + mapxstep = 0; break; case 3: // xintercept and yintercept both match @@ -1584,6 +1588,7 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags, // being entered need to be checked (which will happen when this loop // continues), but the other two blocks adjacent to the corner also need to // be checked. + // Since Doom.exe did not do this, this code won't either if run in compatibility mode. if (!compatible) { if (flags & PT_ADDLINES) @@ -1601,10 +1606,14 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags, yintercept += ystep; mapx += mapxstep; mapy += mapystep; + if (mapx == mapex) + mapxstep = 0; + if (mapy == mapey) + mapystep = 0; } else { - count = 100; // Doom originally did not handle this case so do the same in compatibility mode. + count = 1000; // Doom originally did not handle this case so do the same in compatibility mode. } break; } diff --git a/src/p_sight.cpp b/src/p_sight.cpp index b69daa0cf..57106b2cf 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -713,7 +713,7 @@ bool SightCheck::P_SightPathTraverse () // step through map blocks // Count is present to prevent a round off error from skipping the break - for (count = 0 ; count < 100 ; count++) + for (count = 0 ; count < 1000 ; count++) { // end traversing when reaching the end of the blockmap // an early out is not possible because with portals a trace can easily land outside the map's bounds. @@ -737,7 +737,7 @@ bool SightCheck::P_SightPathTraverse () case 0: // neither xintercept nor yintercept match! sightcounts[5]++; // Continuing won't make things any better, so we might as well stop right here - count = 100; + count = 1000; break; case 1: // xintercept matches