From 455e6cd21493f40b649be3ff5583b5a9a3986242 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Mon, 19 Jan 2015 23:57:15 +1300 Subject: [PATCH 01/50] Improved NewChaseDir performance by cutting repeats --- src/p_enemy.cpp | 59 +++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index ef6136fdc..a5d182471 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -670,33 +670,39 @@ bool P_TryWalk (AActor *actor) void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) { - dirtype_t d[3]; + dirtype_t d[2]; int tdir; dirtype_t olddir, turnaround; + bool attempts[NUMDIRS-1]; // We don't need to attempt DI_NODIR. + memset(&attempts, false, sizeof(attempts)); olddir = (dirtype_t)actor->movedir; turnaround = opposite[olddir]; if (deltax>10*FRACUNIT) - d[1]= DI_EAST; + d[0]= DI_EAST; else if (deltax<-10*FRACUNIT) - d[1]= DI_WEST; + d[0]= DI_WEST; + else + d[0]=DI_NODIR; + + if (deltay<-10*FRACUNIT) + d[1]= DI_SOUTH; + else if (deltay>10*FRACUNIT) + d[1]= DI_NORTH; else d[1]=DI_NODIR; - if (deltay<-10*FRACUNIT) - d[2]= DI_SOUTH; - else if (deltay>10*FRACUNIT) - d[2]= DI_NORTH; - else - d[2]=DI_NODIR; - // try direct route - if (d[1] != DI_NODIR && d[2] != DI_NODIR) + if (d[0] != DI_NODIR && d[1] != DI_NODIR) { actor->movedir = diags[((deltay<0)<<1) + (deltax>0)]; - if (actor->movedir != turnaround && P_TryWalk(actor)) - return; + if (actor->movedir != turnaround) + { + attempts[actor->movedir] = true; + if (P_TryWalk(actor)) + return; + } } // try other directions @@ -704,18 +710,19 @@ void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) { if ((pr_newchasedir() > 200 || abs(deltay) > abs(deltax))) { - swapvalues (d[1], d[2]); + swapvalues (d[0], d[1]); } + if (d[0] == turnaround) + d[0] = DI_NODIR; if (d[1] == turnaround) d[1] = DI_NODIR; - if (d[2] == turnaround) - d[2] = DI_NODIR; } - if (d[1] != DI_NODIR) + if (d[0] != DI_NODIR && attempts[d[0]] == false) { - actor->movedir = d[1]; + actor->movedir = d[0]; + attempts[d[0]] = true; if (P_TryWalk (actor)) { // either moved forward or attacked @@ -723,9 +730,10 @@ void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) } } - if (d[2] != DI_NODIR) + if (d[1] != DI_NODIR && attempts[d[1]] == false) { - actor->movedir = d[2]; + actor->movedir = d[1]; + attempts[d[1]] = true; if (P_TryWalk (actor)) return; } @@ -733,9 +741,10 @@ void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) if (!(actor->flags5 & MF5_AVOIDINGDROPOFF)) { // there is no direct path to the player, so pick another direction. - if (olddir != DI_NODIR) + if (olddir != DI_NODIR && attempts[olddir] == false) { actor->movedir = olddir; + attempts[olddir] = true; if (P_TryWalk (actor)) return; } @@ -746,9 +755,10 @@ void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) { for (tdir = DI_EAST; tdir <= DI_SOUTHEAST; tdir++) { - if (tdir != turnaround) + if (tdir != turnaround && attempts[tdir] == false) { actor->movedir = tdir; + attempts[tdir] = true; if ( P_TryWalk(actor) ) return; } @@ -758,16 +768,17 @@ void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) { for (tdir = DI_SOUTHEAST; tdir != (DI_EAST-1); tdir--) { - if (tdir != turnaround) + if (tdir != turnaround && attempts[tdir] == false) { actor->movedir = tdir; + attempts[tdir] = true; if ( P_TryWalk(actor) ) return; } } } - if (turnaround != DI_NODIR) + if (turnaround != DI_NODIR && attempts[turnaround] == false) { actor->movedir =turnaround; if ( P_TryWalk(actor) ) From b2fbeb24c42a7879b7b59a3ae454f0e21fbb9054 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Sat, 24 Jan 2015 16:09:15 +1300 Subject: [PATCH 02/50] DEM_CHANGEMAP2 wasn't properly skipped --- src/d_net.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index b3e70d410..8ad85d3f8 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2667,7 +2667,9 @@ void Net_SkipCommand (int type, BYTE **stream) case DEM_SUMMONFOE2: skip = strlen ((char *)(*stream)) + 26; break; - + case DEM_CHANGEMAP2: + skip = strlen((char *)(*stream + 1)) + 2; + break; case DEM_MUSICCHANGE: case DEM_PRINT: case DEM_CENTERPRINT: From 60b735dc6028b75fce7e66394b0415eff55de6c7 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 7 Feb 2015 15:03:16 +0100 Subject: [PATCH 03/50] Remove redundant code in polydoor swing code. 'Perpetual' check does not make sense for poly doors. --- src/po_man.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/po_man.cpp b/src/po_man.cpp index bb9b3ca46..4a3345d5b 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -679,10 +679,6 @@ void DPolyDoor::Tick () if (m_Dist <= 0 || poly->RotatePolyobj (m_Speed)) { absSpeed = abs (m_Speed); - if (m_Dist == -1) - { // perpetual polyobj - return; - } m_Dist -= absSpeed; if (m_Dist <= 0) { From 322742d4b11b66670a5f2021ef647a7ec87fa4cd Mon Sep 17 00:00:00 2001 From: ZzZombo Date: Sat, 7 Feb 2015 23:35:23 +0800 Subject: [PATCH 04/50] - Fixed various instances of unused variables, accessing arrays out of bounds, initialization of non-primitive members in constructor's body, dead code, passing parameters by value instead of reference, usage of uninitialized variables, as reported by cppcheck. --- src/am_map.cpp | 13 ++++++++++--- src/b_bot.cpp | 4 ++-- src/b_func.cpp | 2 +- src/c_cmds.cpp | 3 +-- src/c_console.cpp | 3 +-- src/c_cvars.cpp | 27 +++++++-------------------- src/c_dispatch.cpp | 2 +- src/compatibility.cpp | 2 +- src/compatibility.h | 4 ++-- src/configfile.cpp | 5 ++--- src/d_net.cpp | 3 ++- src/d_protocol.cpp | 2 +- src/decallib.cpp | 11 +++-------- src/dobjtype.h | 2 +- src/dsectoreffect.cpp | 3 +-- src/files.cpp | 2 +- src/g_game.cpp | 6 ++++++ src/g_level.cpp | 2 -- src/g_level.h | 2 +- src/g_mapinfo.cpp | 2 -- src/i_net.cpp | 3 +-- src/info.cpp | 9 ++++----- src/info.h | 8 ++++---- src/m_argv.cpp | 7 ++----- src/m_png.cpp | 1 - src/menu/menu.h | 3 +-- src/tarray.h | 30 +++++++++++++++--------------- src/thingdef/thingdef_exp.h | 3 +-- 28 files changed, 72 insertions(+), 92 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 29cd60793..1529b4740 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1234,9 +1234,16 @@ void AM_initVariables () for (pnum=0;pnumx >> FRACTOMAPBITS) - m_w/2; - m_y = (players[pnum].camera->y >> FRACTOMAPBITS) - m_h/2; + // [ZzZombo] no access out of bounds. + if(pnum>=MAXPLAYERS) + { + m_x=m_y=0; + } + else + { + m_x = (players[pnum].camera->x >> FRACTOMAPBITS) - m_w/2; + m_y = (players[pnum].camera->y >> FRACTOMAPBITS) - m_h/2; + } AM_changeWindowLoc(); // for saving & restoring diff --git a/src/b_bot.cpp b/src/b_bot.cpp index 05cac045b..548d10e2e 100644 --- a/src/b_bot.cpp +++ b/src/b_bot.cpp @@ -61,8 +61,8 @@ void DBot::Serialize (FArchive &arc) if (SaveVersion < 4515) { - angle_t savedyaw; - int savedpitch; + angle_t savedyaw=0; + int savedpitch=0; arc << savedyaw << savedpitch; } diff --git a/src/b_func.cpp b/src/b_func.cpp index 7165d2cc1..1c29c2cf6 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -513,7 +513,7 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd) bglobal.SetBodyAt (enemy->x + FixedMul(enemy->velx, (m+2*FRACUNIT)), enemy->y + FixedMul(enemy->vely, (m+2*FRACUNIT)), ONFLOORZ, 1); - dist = P_AproxDistance(actor->x-bglobal.body1->x, actor->y-bglobal.body1->y); + //try the predicted location if (P_CheckSight (actor, bglobal.body1, SF_IGNOREVISIBILITY)) //See the predicted location, so give a test missile { diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 9290c36c3..9c30c8f4f 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -1028,8 +1028,7 @@ CCMD(nextsecret) TEXTCOLOR_NORMAL " is for single-player only.\n"); return; } - char *next = NULL; - + if (level.NextSecretMap.Len() > 0 && level.NextSecretMap.Compare("enDSeQ", 6)) { G_DeferedInitNew(level.NextSecretMap); diff --git a/src/c_console.cpp b/src/c_console.cpp index e3e3d98fe..3be72d953 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -856,11 +856,10 @@ void C_DrawConsole (bool hw2d) } else if (ConBottom) { - int visheight, realheight; + int visheight; FTexture *conpic = TexMan[conback]; visheight = ConBottom; - realheight = (visheight * conpic->GetHeight()) / SCREENHEIGHT; screen->DrawTexture (conpic, 0, visheight - screen->GetHeight(), DTA_DestWidth, screen->GetWidth(), diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index c770bcbcf..c7a71197b 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -439,7 +439,7 @@ static BYTE HexToByte (const char *hex) UCVarValue FBaseCVar::FromString (const char *value, ECVarType type) { UCVarValue ret; - int i; + int i=0; switch (type) { @@ -475,39 +475,29 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type) // 0 1 2 3 ret.pGUID = NULL; - for (i = 0; i < 38; ++i) + if(value) + for (; i < 38; i++) { - if (value[i] == 0) - { - break; - } - bool goodv = true; switch (i) { case 0: if (value[i] != '{') - goodv = false; - break; + break; case 9: case 14: case 19: case 24: if (value[i] != '-') - goodv = false; - break; + break; case 37: if (value[i] != '}') - goodv = false; - break; + break; default: if (value[i] < '0' || (value[i] > '9' && value[i] < 'A') || (value[i] > 'F' && value[i] < 'a') || value[i] > 'f') - { - goodv = false; - } - break; + break; } } if (i == 38 && value[i] == 0) @@ -1673,9 +1663,6 @@ void FBaseCVar::ListVars (const char *filter, bool plain) if (CheckWildcards (filter, var->GetName())) { DWORD flags = var->GetFlags(); - UCVarValue val; - - val = var->GetGenericRep (CVAR_String); if (plain) { // plain formatting does not include user-defined cvars if (!(flags & CVAR_UNSETTABLE)) diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index 7a6748fdc..8755e81e1 100644 --- a/src/c_dispatch.cpp +++ b/src/c_dispatch.cpp @@ -1336,7 +1336,7 @@ CCMD (alias) } else { - alias = new FConsoleAlias (argv[1], argv[2], ParsingKeyConf); + new FConsoleAlias (argv[1], argv[2], ParsingKeyConf); } } } diff --git a/src/compatibility.cpp b/src/compatibility.cpp index 8a4341b76..4ddc670e9 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -448,7 +448,7 @@ void SetCompatibilityParams() { unsigned i = ii_compatparams; - while (CompatParams[i] != CP_END && i < CompatParams.Size()) + while (i < CompatParams.Size() && CompatParams[i] != CP_END) { switch (CompatParams[i]) { diff --git a/src/compatibility.h b/src/compatibility.h index cf4dce2f7..d37d25903 100644 --- a/src/compatibility.h +++ b/src/compatibility.h @@ -20,11 +20,11 @@ struct FCompatValues struct FMD5HashTraits { - hash_t Hash(const FMD5Holder key) + hash_t Hash(const FMD5Holder &key) { return key.Hash; } - int Compare(const FMD5Holder left, const FMD5Holder right) + int Compare(const FMD5Holder &left, const FMD5Holder &right) { return left.DWords[0] != right.DWords[0] || left.DWords[1] != right.DWords[1] || diff --git a/src/configfile.cpp b/src/configfile.cpp index b8e37d91c..4d642a81d 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -50,12 +50,11 @@ static FRandom pr_endtag; // //==================================================================== -FConfigFile::FConfigFile () +FConfigFile::FConfigFile () : PathName(NAME_None) { Sections = CurrentSection = NULL; LastSectionPtr = &Sections; CurrentEntry = NULL; - PathName = ""; OkayToWrite = true; FileExisted = true; } @@ -836,7 +835,7 @@ const char *FConfigFile::GenerateEndTag(const char *value) for (int i = 0; i < 5; ++i) { - DWORD three_bytes = (rand_bytes[i*3] << 16) | (rand_bytes[i*3+1] << 8) | (rand_bytes[i*3+2]); + //DWORD three_bytes = (rand_bytes[i*3] << 16) | (rand_bytes[i*3+1] << 8) | (rand_bytes[i*3+2]); // ??? EndTag[4+i*4 ] = Base64Table[rand_bytes[i*3] >> 2]; EndTag[4+i*4+1] = Base64Table[((rand_bytes[i*3] & 3) << 4) | (rand_bytes[i*3+1] >> 4)]; EndTag[4+i*4+2] = Base64Table[((rand_bytes[i*3+1] & 15) << 2) | (rand_bytes[i*3+2] >> 6)]; diff --git a/src/d_net.cpp b/src/d_net.cpp index b3e70d410..aa4c4ee1b 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2054,7 +2054,8 @@ void FDynamicBuffer::SetData (const BYTE *data, int len) } else { - len = 0; + m_Len = 0; + M_Free((void *)data); } } diff --git a/src/d_protocol.cpp b/src/d_protocol.cpp index 11e682cda..3613f84db 100644 --- a/src/d_protocol.cpp +++ b/src/d_protocol.cpp @@ -500,5 +500,5 @@ void SkipChunk (BYTE **stream) int len; len = ReadLong (stream); - stream += len + (len & 1); + *stream += len + (len & 1); } diff --git a/src/decallib.cpp b/src/decallib.cpp index 91827409b..79c961099 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -443,7 +443,6 @@ void FDecalLib::ParseDecal (FScanner &sc) FString decalName; WORD decalNum; FDecalTemplate newdecal; - int code; FTextureID picnum; int lumpnum; @@ -467,7 +466,7 @@ void FDecalLib::ParseDecal (FScanner &sc) AddDecal (decalName, decalNum, newdecal); break; } - switch ((code = sc.MustMatchString (DecalKeywords))) + switch (sc.MustMatchString (DecalKeywords)) { case DECAL_XSCALE: newdecal.ScaleX = ReadScale (sc); @@ -763,8 +762,6 @@ void FDecalLib::ParseSlider (FScanner &sc) } else if (sc.Compare ("DistX")) { - sc.MustGetFloat (); - distX = (fixed_t)(sc.Float * FRACUNIT); Printf ("DistX in slider decal %s is unsupported\n", sliderName.GetChars()); } else if (sc.Compare ("DistY")) @@ -1024,9 +1021,8 @@ FDecalLib::FTranslation *FDecalLib::GenerateTranslation (DWORD start, DWORD end) return trans; } -FDecalBase::FDecalBase () +FDecalBase::FDecalBase () : Name(NAME_None) { - Name = NAME_None; } FDecalBase::~FDecalBase () @@ -1139,9 +1135,8 @@ const FDecalTemplate *FDecalGroup::GetDecal () const return static_cast(remember); } -FDecalAnimator::FDecalAnimator (const char *name) +FDecalAnimator::FDecalAnimator (const char *name) : Name(name) { - Name = name; } FDecalAnimator::~FDecalAnimator () diff --git a/src/dobjtype.h b/src/dobjtype.h index 256e52ad8..252287e3e 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -24,7 +24,7 @@ struct PSymbol FName SymbolName; protected: - PSymbol(FName name, ESymbolType type) { SymbolType = type; SymbolName = name; } + PSymbol(FName name, ESymbolType type):SymbolName(name) { SymbolType = type; } }; // A constant value --------------------------------------------------------- diff --git a/src/dsectoreffect.cpp b/src/dsectoreffect.cpp index 6732a19dc..82a7deb6f 100644 --- a/src/dsectoreffect.cpp +++ b/src/dsectoreffect.cpp @@ -78,9 +78,8 @@ DMover::DMover () } DMover::DMover (sector_t *sector) - : DSectorEffect (sector) + : DSectorEffect (sector), interpolation(NULL) { - interpolation = NULL; } void DMover::Destroy() diff --git a/src/files.cpp b/src/files.cpp index d7dad642e..52aa891c9 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -53,7 +53,7 @@ //========================================================================== FileReader::FileReader () -: File(NULL), Length(0), StartPos(0), CloseOnDestruct(false) +: File(NULL), Length(0), StartPos(0), FilePos(0), CloseOnDestruct(false) { } diff --git a/src/g_game.cpp b/src/g_game.cpp index ba53254c2..e5df703ea 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -2589,6 +2589,12 @@ bool G_ProcessIFFDemo (FString &mapname) demo_p = nextchunk; } + if (!headerHit) + { + Printf ("Demo has no header!\n"); + return true; + } + if (!numPlayers) { Printf ("Demo has no players!\n"); diff --git a/src/g_level.cpp b/src/g_level.cpp index 713847b05..b6cc1cd84 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -367,7 +367,6 @@ static void InitPlayerClasses () void G_InitNew (const char *mapname, bool bTitleLevel) { - EGameSpeed oldSpeed; bool wantFast; int i; @@ -454,7 +453,6 @@ void G_InitNew (const char *mapname, bool bTitleLevel) I_Error ("Could not find map %s\n", mapname); } - oldSpeed = GameSpeed; wantFast = !!G_SkillProperty(SKILLP_FastMonsters); GameSpeed = wantFast ? SPEED_Fast : SPEED_Normal; diff --git a/src/g_level.h b/src/g_level.h index 6e07b0c74..aaddfce3c 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -241,7 +241,7 @@ struct FOptionalMapinfoData { FOptionalMapinfoData *Next; FName identifier; - FOptionalMapinfoData() { Next = NULL; identifier = NAME_None; } + FOptionalMapinfoData():identifier(NAME_None) { Next = NULL; } virtual ~FOptionalMapinfoData() {} virtual FOptionalMapinfoData *Clone() const = 0; }; diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index c44f81ab2..6d49b9c17 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -705,8 +705,6 @@ void FMapInfoParser::ParseCluster() } else if (sc.Compare("music")) { - int order = 0; - ParseAssign(); ParseMusic(clusterinfo->MessageMusic, clusterinfo->musicorder); } diff --git a/src/i_net.cpp b/src/i_net.cpp index 188d2871e..da1063bc9 100644 --- a/src/i_net.cpp +++ b/src/i_net.cpp @@ -238,7 +238,7 @@ void PacketSend (void) else { // Printf("send %d\n", doomcom.datalength); - c = sendto(mysocket, (char *)doomcom.data, doomcom.datalength, + /*c = */sendto(mysocket, (char *)doomcom.data, doomcom.datalength, 0, (sockaddr *)&sendaddress[doomcom.remotenode], sizeof(sendaddress[doomcom.remotenode])); } @@ -800,7 +800,6 @@ bool Guest_WaitForOthers (void *userdata) { int node; - packet.NumNodes = packet.NumNodes; doomcom.numnodes = packet.NumNodes + 2; sendplayer[0] = packet.ConsoleNum; // My player number doomcom.consoleplayer = packet.ConsoleNum; diff --git a/src/info.cpp b/src/info.cpp index 0a8d92217..1da057fe2 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -158,7 +158,6 @@ void FActorInfo::StaticSetActorNums () void FActorInfo::RegisterIDs () { const PClass *cls = PClass::FindClass(Class->TypeName); - bool set = false; if (GameFilter == GAME_Any || (GameFilter & gameinfo.gametype)) { @@ -578,17 +577,17 @@ CCMD (summonfoe) TMap GlobalDamageDefinitions; -void DamageTypeDefinition::Apply(FName const type) +void DamageTypeDefinition::Apply(FName const &type) { GlobalDamageDefinitions[type] = *this; } -DamageTypeDefinition *DamageTypeDefinition::Get(FName const type) +DamageTypeDefinition *DamageTypeDefinition::Get(FName const &type) { return GlobalDamageDefinitions.CheckKey(type); } -bool DamageTypeDefinition::IgnoreArmor(FName const type) +bool DamageTypeDefinition::IgnoreArmor(FName const &type) { DamageTypeDefinition *dtd = Get(type); if (dtd) return dtd->NoArmor; @@ -610,7 +609,7 @@ bool DamageTypeDefinition::IgnoreArmor(FName const type) // //========================================================================== -int DamageTypeDefinition::ApplyMobjDamageFactor(int damage, FName const type, DmgFactors const * const factors) +int DamageTypeDefinition::ApplyMobjDamageFactor(int damage, FName const &type, DmgFactors const * const factors) { if (factors) { diff --git a/src/info.h b/src/info.h index 51c4bd629..0a6326c9a 100644 --- a/src/info.h +++ b/src/info.h @@ -217,7 +217,7 @@ public: bool ReplaceFactor; bool NoArmor; - void Apply(FName const type); + void Apply(FName const &type); void Clear() { DefaultFactor = FRACUNIT; @@ -225,9 +225,9 @@ public: NoArmor = false; } - static DamageTypeDefinition *Get(FName const type); - static bool IgnoreArmor(FName const type); - static int ApplyMobjDamageFactor(int damage, FName const type, DmgFactors const * const factors); + static DamageTypeDefinition *Get(FName const &type); + static bool IgnoreArmor(FName const &type); + static int ApplyMobjDamageFactor(int damage, FName const &type, DmgFactors const * const factors); }; diff --git a/src/m_argv.cpp b/src/m_argv.cpp index 816a2d54c..ef3f59fef 100644 --- a/src/m_argv.cpp +++ b/src/m_argv.cpp @@ -55,10 +55,9 @@ DArgs::DArgs() // //=========================================================================== -DArgs::DArgs(const DArgs &other) -: DObject() +DArgs::DArgs(const DArgs &other):Argv(other.Argv), + DObject() { - Argv = other.Argv; } //=========================================================================== @@ -263,7 +262,6 @@ void DArgs::RemoveArgs(const char *check) const char *DArgs::GetArg(int arg) const { return ((unsigned)arg < Argv.Size()) ? Argv[arg].GetChars() : NULL; - return Argv[arg]; } //=========================================================================== @@ -351,7 +349,6 @@ void DArgs::RemoveArg(int argindex) void DArgs::CollectFiles(const char *param, const char *extension) { TArray work; - DArgs *out = new DArgs; unsigned int i; size_t extlen = extension == NULL ? 0 : strlen(extension); diff --git a/src/m_png.cpp b/src/m_png.cpp index 2bec48103..0c8b6ab18 100644 --- a/src/m_png.cpp +++ b/src/m_png.cpp @@ -1023,7 +1023,6 @@ bool M_SaveBitmap(const BYTE *from, ESSType color_type, int width, int height, i } } - y = sizeof(buffer) - stream.avail_out; deflateEnd (&stream); if (err != Z_STREAM_END) diff --git a/src/menu/menu.h b/src/menu/menu.h index 3712c9065..b256ccb2f 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -261,11 +261,10 @@ protected: public: bool mEnabled; - FListMenuItem(int xpos = 0, int ypos = 0, FName action = NAME_None) + FListMenuItem(int xpos = 0, int ypos = 0, FName action = NAME_None):mAction(action) { mXpos = xpos; mYpos = ypos; - mAction = action; mEnabled = true; } diff --git a/src/tarray.h b/src/tarray.h index d32a688df..790692e45 100644 --- a/src/tarray.h +++ b/src/tarray.h @@ -416,10 +416,10 @@ typedef unsigned int hash_t; template struct THashTraits { // Returns the hash value for a key. - hash_t Hash(const KT key) { return (hash_t)(intptr_t)key; } + hash_t Hash(const KT &key) { return (hash_t)(intptr_t)key; } // Compares two keys, returning zero if they are the same. - int Compare(const KT left, const KT right) { return left != right; } + int Compare(const KT &left, const KT &right) { return left != right; } }; template struct TValueTraits @@ -547,12 +547,12 @@ public: // //======================================================================= - VT &operator[] (const KT key) + VT &operator[] (const KT &key) { return GetNode(key)->Pair.Value; } - const VT &operator[] (const KT key) const + const VT &operator[] (const KT &key) const { return GetNode(key)->Pair.Value; } @@ -566,13 +566,13 @@ public: // //======================================================================= - VT *CheckKey (const KT key) + VT *CheckKey (const KT &key) { Node *n = FindKey(key); return n != NULL ? &n->Pair.Value : NULL; } - const VT *CheckKey (const KT key) const + const VT *CheckKey (const KT &key) const { const Node *n = FindKey(key); return n != NULL ? &n->Pair.Value : NULL; @@ -591,7 +591,7 @@ public: // //======================================================================= - VT &Insert(const KT key, const VT &value) + VT &Insert(const KT &key, const VT &value) { Node *n = FindKey(key); if (n != NULL) @@ -614,7 +614,7 @@ public: // //======================================================================= - void Remove(const KT key) + void Remove(const KT &key) { DelKey(key); } @@ -649,13 +649,13 @@ protected: hash_t Size; /* must be a power of 2 */ hash_t NumUsed; - const Node *MainPosition(const KT k) const + const Node *MainPosition(const KT &k) const { HashTraits Traits; return &Nodes[Traits.Hash(k) & (Size - 1)]; } - Node *MainPosition(const KT k) + Node *MainPosition(const KT &k) { HashTraits Traits; return &Nodes[Traits.Hash(k) & (Size - 1)]; @@ -736,7 +736,7 @@ protected: ** ** The Value field is left unconstructed. */ - Node *NewKey(const KT key) + Node *NewKey(const KT &key) { Node *mp = MainPosition(key); if (!mp->IsNil()) @@ -775,7 +775,7 @@ protected: return mp; } - void DelKey(const KT key) + void DelKey(const KT &key) { Node *mp = MainPosition(key), **mpp; HashTraits Traits; @@ -814,7 +814,7 @@ protected: } } - Node *FindKey(const KT key) + Node *FindKey(const KT &key) { HashTraits Traits; Node *n = MainPosition(key); @@ -825,7 +825,7 @@ protected: return n == NULL || n->IsNil() ? NULL : n; } - const Node *FindKey(const KT key) const + const Node *FindKey(const KT &key) const { HashTraits Traits; const Node *n = MainPosition(key); @@ -836,7 +836,7 @@ protected: return n == NULL || n->IsNil() ? NULL : n; } - Node *GetNode(const KT key) + Node *GetNode(const KT &key) { Node *n = FindKey(key); if (n != NULL) diff --git a/src/thingdef/thingdef_exp.h b/src/thingdef/thingdef_exp.h index 807ffcd87..1c46ab6b2 100644 --- a/src/thingdef/thingdef_exp.h +++ b/src/thingdef/thingdef_exp.h @@ -152,10 +152,9 @@ struct ExpVal class FxExpression { protected: - FxExpression(const FScriptPosition &pos) + FxExpression(const FScriptPosition &pos):ScriptPosition(pos) { isresolved = false; - ScriptPosition = pos; } public: virtual ~FxExpression() {} From c4f932022c58825fc7f2430397809454a12b56b8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 7 Feb 2015 16:44:24 +0100 Subject: [PATCH 05/50] - added 'listsoundchannels' CCMD for debugging. --- src/s_sound.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/s_sound.cpp b/src/s_sound.cpp index ccaebf610..5b3d5457b 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -2993,3 +2993,23 @@ CCMD (cachesound) } } } + + +CCMD(listsoundchannels) +{ + FSoundChan *chan; + int count = 0; + for (chan = Channels; chan != NULL; chan = chan->NextChan) + { + if (!(chan->ChanFlags & CHAN_EVICTED)) + { + FVector3 chanorigin; + + CalcPosVel(chan, &chanorigin, NULL); + + Printf("%s at (%1.5f, %1.5f, %1.5f)\n", (const char*)chan->SoundID, chanorigin.X, chanorigin.Y, chanorigin.Z); + count++; + } + } + Printf("%d sounds playing\n", count); +} From 7789975b6c3622c484745e9f392223e48f921d6b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 7 Feb 2015 17:02:46 +0100 Subject: [PATCH 06/50] - reverted a few of Zzombo's changes. --- src/d_net.cpp | 3 +-- src/decallib.cpp | 1 + src/info.cpp | 8 ++++---- src/info.h | 6 +++--- src/tarray.h | 30 +++++++++++++++--------------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index bf56895f6..b984799f6 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2048,7 +2048,7 @@ void FDynamicBuffer::SetData (const BYTE *data, int len) m_BufferLen = (len + 255) & ~255; m_Data = (BYTE *)M_Realloc (m_Data, m_BufferLen); } - if (data) + if (data != NULL) { m_Len = len; memcpy (m_Data, data, len); @@ -2056,7 +2056,6 @@ void FDynamicBuffer::SetData (const BYTE *data, int len) else { m_Len = 0; - M_Free((void *)data); } } diff --git a/src/decallib.cpp b/src/decallib.cpp index 79c961099..4da7ba92c 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -762,6 +762,7 @@ void FDecalLib::ParseSlider (FScanner &sc) } else if (sc.Compare ("DistX")) { + sc.MustGetFloat (); // must remain to avoid breaking definitions that accidentally used DistX Printf ("DistX in slider decal %s is unsupported\n", sliderName.GetChars()); } else if (sc.Compare ("DistY")) diff --git a/src/info.cpp b/src/info.cpp index 1da057fe2..e26ac3b8e 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -577,17 +577,17 @@ CCMD (summonfoe) TMap GlobalDamageDefinitions; -void DamageTypeDefinition::Apply(FName const &type) +void DamageTypeDefinition::Apply(FName type) { GlobalDamageDefinitions[type] = *this; } -DamageTypeDefinition *DamageTypeDefinition::Get(FName const &type) +DamageTypeDefinition *DamageTypeDefinition::Get(FName type) { return GlobalDamageDefinitions.CheckKey(type); } -bool DamageTypeDefinition::IgnoreArmor(FName const &type) +bool DamageTypeDefinition::IgnoreArmor(FName type) { DamageTypeDefinition *dtd = Get(type); if (dtd) return dtd->NoArmor; @@ -609,7 +609,7 @@ bool DamageTypeDefinition::IgnoreArmor(FName const &type) // //========================================================================== -int DamageTypeDefinition::ApplyMobjDamageFactor(int damage, FName const &type, DmgFactors const * const factors) +int DamageTypeDefinition::ApplyMobjDamageFactor(int damage, FName type, DmgFactors const * const factors) { if (factors) { diff --git a/src/info.h b/src/info.h index 0a6326c9a..19f03670d 100644 --- a/src/info.h +++ b/src/info.h @@ -225,9 +225,9 @@ public: NoArmor = false; } - static DamageTypeDefinition *Get(FName const &type); - static bool IgnoreArmor(FName const &type); - static int ApplyMobjDamageFactor(int damage, FName const &type, DmgFactors const * const factors); + static DamageTypeDefinition *Get(FName type); + static bool IgnoreArmor(FName type); + static int ApplyMobjDamageFactor(int damage, FName type, DmgFactors const * const factors); }; diff --git a/src/tarray.h b/src/tarray.h index 790692e45..d32a688df 100644 --- a/src/tarray.h +++ b/src/tarray.h @@ -416,10 +416,10 @@ typedef unsigned int hash_t; template struct THashTraits { // Returns the hash value for a key. - hash_t Hash(const KT &key) { return (hash_t)(intptr_t)key; } + hash_t Hash(const KT key) { return (hash_t)(intptr_t)key; } // Compares two keys, returning zero if they are the same. - int Compare(const KT &left, const KT &right) { return left != right; } + int Compare(const KT left, const KT right) { return left != right; } }; template struct TValueTraits @@ -547,12 +547,12 @@ public: // //======================================================================= - VT &operator[] (const KT &key) + VT &operator[] (const KT key) { return GetNode(key)->Pair.Value; } - const VT &operator[] (const KT &key) const + const VT &operator[] (const KT key) const { return GetNode(key)->Pair.Value; } @@ -566,13 +566,13 @@ public: // //======================================================================= - VT *CheckKey (const KT &key) + VT *CheckKey (const KT key) { Node *n = FindKey(key); return n != NULL ? &n->Pair.Value : NULL; } - const VT *CheckKey (const KT &key) const + const VT *CheckKey (const KT key) const { const Node *n = FindKey(key); return n != NULL ? &n->Pair.Value : NULL; @@ -591,7 +591,7 @@ public: // //======================================================================= - VT &Insert(const KT &key, const VT &value) + VT &Insert(const KT key, const VT &value) { Node *n = FindKey(key); if (n != NULL) @@ -614,7 +614,7 @@ public: // //======================================================================= - void Remove(const KT &key) + void Remove(const KT key) { DelKey(key); } @@ -649,13 +649,13 @@ protected: hash_t Size; /* must be a power of 2 */ hash_t NumUsed; - const Node *MainPosition(const KT &k) const + const Node *MainPosition(const KT k) const { HashTraits Traits; return &Nodes[Traits.Hash(k) & (Size - 1)]; } - Node *MainPosition(const KT &k) + Node *MainPosition(const KT k) { HashTraits Traits; return &Nodes[Traits.Hash(k) & (Size - 1)]; @@ -736,7 +736,7 @@ protected: ** ** The Value field is left unconstructed. */ - Node *NewKey(const KT &key) + Node *NewKey(const KT key) { Node *mp = MainPosition(key); if (!mp->IsNil()) @@ -775,7 +775,7 @@ protected: return mp; } - void DelKey(const KT &key) + void DelKey(const KT key) { Node *mp = MainPosition(key), **mpp; HashTraits Traits; @@ -814,7 +814,7 @@ protected: } } - Node *FindKey(const KT &key) + Node *FindKey(const KT key) { HashTraits Traits; Node *n = MainPosition(key); @@ -825,7 +825,7 @@ protected: return n == NULL || n->IsNil() ? NULL : n; } - const Node *FindKey(const KT &key) const + const Node *FindKey(const KT key) const { HashTraits Traits; const Node *n = MainPosition(key); @@ -836,7 +836,7 @@ protected: return n == NULL || n->IsNil() ? NULL : n; } - Node *GetNode(const KT &key) + Node *GetNode(const KT key) { Node *n = FindKey(key); if (n != NULL) From b37a98689ae01a369353d4609cc95824341583f7 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sat, 7 Feb 2015 10:04:33 -0600 Subject: [PATCH 07/50] - Added SXF_TRANSFERSPRITEFRAME. Now it's possible to make starting frames that start with "####" "#" 0 in Spawn. - Fixed a compile warning with FAF_NODISTFACTOR. --- src/p_enemy.cpp | 2 +- src/thingdef/thingdef_codeptr.cpp | 55 +++++++++++++++++------------- wadsrc/static/actors/constants.txt | 1 + 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 17af5c26d..618f50663 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2803,7 +2803,7 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a target_z = other->z + (other->height / 2) + other->GetBobOffset(); if (flags & FAF_TOP) target_z = other->z + (other->height) + other->GetBobOffset(); - if (!flags & FAF_NODISTFACTOR) + if (!(flags & FAF_NODISTFACTOR)) target_z += pitch_offset; double dist_z = target_z - source_z; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 9db52f728..fc157c92b 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1850,30 +1850,31 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TakeFromSiblings) enum SIX_Flags { - SIXF_TRANSFERTRANSLATION = 1 << 0, - SIXF_ABSOLUTEPOSITION = 1 << 1, - SIXF_ABSOLUTEANGLE = 1 << 2, - SIXF_ABSOLUTEVELOCITY = 1 << 3, - SIXF_SETMASTER = 1 << 4, - SIXF_NOCHECKPOSITION = 1 << 5, - SIXF_TELEFRAG = 1 << 6, - SIXF_CLIENTSIDE = 1 << 7, // only used by Skulldronum - SIXF_TRANSFERAMBUSHFLAG = 1 << 8, - SIXF_TRANSFERPITCH = 1 << 9, - SIXF_TRANSFERPOINTERS = 1 << 10, - SIXF_USEBLOODCOLOR = 1 << 11, - SIXF_CLEARCALLERTID = 1 << 12, - SIXF_MULTIPLYSPEED = 1 << 13, - SIXF_TRANSFERSCALE = 1 << 14, - SIXF_TRANSFERSPECIAL = 1 << 15, - SIXF_CLEARCALLERSPECIAL = 1 << 16, - SIXF_TRANSFERSTENCILCOL = 1 << 17, - SIXF_TRANSFERALPHA = 1 << 18, - SIXF_TRANSFERRENDERSTYLE = 1 << 19, - SIXF_SETTARGET = 1 << 20, - SIXF_SETTRACER = 1 << 21, - SIXF_NOPOINTERS = 1 << 22, - SIXF_ORIGINATOR = 1 << 23, + SIXF_TRANSFERTRANSLATION = 0x00000001, + SIXF_ABSOLUTEPOSITION = 0x00000002, + SIXF_ABSOLUTEANGLE = 0x00000004, + SIXF_ABSOLUTEVELOCITY = 0x00000008, + SIXF_SETMASTER = 0x00000010, + SIXF_NOCHECKPOSITION = 0x00000020, + SIXF_TELEFRAG = 0x00000040, + SIXF_CLIENTSIDE = 0x00000080, // only used by Skulldronum + SIXF_TRANSFERAMBUSHFLAG = 0x00000100, + SIXF_TRANSFERPITCH = 0x00000200, + SIXF_TRANSFERPOINTERS = 0x00000400, + SIXF_USEBLOODCOLOR = 0x00000800, + SIXF_CLEARCALLERTID = 0x00001000, + SIXF_MULTIPLYSPEED = 0x00002000, + SIXF_TRANSFERSCALE = 0x00004000, + SIXF_TRANSFERSPECIAL = 0x00008000, + SIXF_CLEARCALLERSPECIAL = 0x00010000, + SIXF_TRANSFERSTENCILCOL = 0x00020000, + SIXF_TRANSFERALPHA = 0x00040000, + SIXF_TRANSFERRENDERSTYLE = 0x00080000, + SIXF_SETTARGET = 0x00100000, + SIXF_SETTRACER = 0x00200000, + SIXF_NOPOINTERS = 0x00400000, + SIXF_ORIGINATOR = 0x00800000, + SIXF_TRANSFERSPRITEFRAME = 0x01000000, }; static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) @@ -2019,6 +2020,12 @@ static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) { mo->RenderStyle = self->RenderStyle; } + + if (flags & SIXF_TRANSFERSPRITEFRAME) + { + mo->sprite = self->sprite; + mo->frame = self->frame; + } return true; } diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index b4bb4c532..27f2d78d8 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -72,6 +72,7 @@ const int SXF_SETTARGET = 1 << 20; const int SXF_SETTRACER = 1 << 21; const int SXF_NOPOINTERS = 1 << 22; const int SXF_ORIGINATOR = 1 << 23; +const int SIXF_TRANSFERSPRITEFRAME = 1 << 24; // Flags for A_Chase const int CHF_FASTCHASE = 1; From 3a504da6756fcacb84937a293beff9105e9161bf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 7 Feb 2015 19:04:43 +0100 Subject: [PATCH 08/50] - forgot to save this before committing. --- src/info.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.h b/src/info.h index 19f03670d..13a8eb5e1 100644 --- a/src/info.h +++ b/src/info.h @@ -217,7 +217,7 @@ public: bool ReplaceFactor; bool NoArmor; - void Apply(FName const &type); + void Apply(FName type); void Clear() { DefaultFactor = FRACUNIT; From 2c06987f674125d97de7f05a59e2ed9b14398d25 Mon Sep 17 00:00:00 2001 From: ZzZombo Date: Sun, 8 Feb 2015 14:35:45 +0800 Subject: [PATCH 09/50] - Fixed the sanity commit. --- src/d_net.cpp | 1 + src/info.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index b984799f6..b973c2db0 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2056,6 +2056,7 @@ void FDynamicBuffer::SetData (const BYTE *data, int len) else { m_Len = 0; + M_Free(m_Data); } } diff --git a/src/info.h b/src/info.h index 19f03670d..680b6fcd8 100644 --- a/src/info.h +++ b/src/info.h @@ -217,7 +217,7 @@ public: bool ReplaceFactor; bool NoArmor; - void Apply(FName const &type); + void Apply(FName const type); void Clear() { DefaultFactor = FRACUNIT; From c4b742ebf0732928646363afd89655180c295c21 Mon Sep 17 00:00:00 2001 From: ZzZombo Date: Sun, 8 Feb 2015 17:03:49 +0800 Subject: [PATCH 10/50] - Part 2 of the sanity crusade. --- src/g_shared/a_pickups.h | 2 +- src/nodebuild.cpp | 5 +---- src/nodebuild_extract.cpp | 3 --- src/nodebuild_gl.cpp | 6 +++--- src/p_acs.cpp | 12 ++++-------- src/p_buildmap.cpp | 4 ++-- src/p_conversation.cpp | 21 ++++++++++----------- src/p_enemy.cpp | 2 -- src/p_floor.cpp | 6 +++--- src/p_interaction.cpp | 4 +--- src/p_map.cpp | 10 ++++------ src/p_mobj.cpp | 31 +++++++++++++++++++++++++------ src/p_setup.cpp | 12 +++--------- src/p_slopes.cpp | 2 -- src/p_teleport.cpp | 3 +-- src/p_usdf.cpp | 1 - src/p_user.cpp | 3 +-- src/r_plane.cpp | 1 - 18 files changed, 59 insertions(+), 69 deletions(-) diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index df0c94b46..968de8eac 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -16,7 +16,7 @@ class FWeaponSlot { public: FWeaponSlot() { Clear(); } - FWeaponSlot(const FWeaponSlot &other) { Weapons = other.Weapons; } + FWeaponSlot(const FWeaponSlot &other):Weapons(other.Weapons) {} FWeaponSlot &operator= (const FWeaponSlot &other) { Weapons = other.Weapons; return *this; } void Clear() { Weapons.Clear(); } bool AddWeapon (const char *type); diff --git a/src/nodebuild.cpp b/src/nodebuild.cpp index 210f0f3de..d39157aed 100644 --- a/src/nodebuild.cpp +++ b/src/nodebuild.cpp @@ -942,8 +942,6 @@ DWORD FNodeBuilder::SplitSeg (DWORD segnum, int splitvert, int v1InFront) int newnum = (int)Segs.Size(); newseg = Segs[segnum]; - dx = double(Vertices[splitvert].x - Vertices[newseg.v1].x); - dy = double(Vertices[splitvert].y - Vertices[newseg.v1].y); if (v1InFront > 0) { newseg.v1 = splitvert; @@ -1129,8 +1127,7 @@ int ClassifyLineBackpatchC (node_t &node, const FSimpleVert *v1, const FSimpleVe long pagesize = sysconf(_SC_PAGESIZE); char *callerpage = (char *)((intptr_t)calleroffset & ~(pagesize - 1)); size_t protectlen = (intptr_t)calleroffset + sizeof(void*) - (intptr_t)callerpage; - int ptect; - if (!(ptect = mprotect(callerpage, protectlen, PROT_READ|PROT_WRITE|PROT_EXEC))) + if (!mprotect(callerpage, protectlen, PROT_READ|PROT_WRITE|PROT_EXEC)) #endif { *calleroffset = diff; diff --git a/src/nodebuild_extract.cpp b/src/nodebuild_extract.cpp index c0f769873..04660f6d0 100644 --- a/src/nodebuild_extract.cpp +++ b/src/nodebuild_extract.cpp @@ -317,7 +317,6 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector, vertex_t { angle_t bestdiff = ANGLE_MAX; FPrivSeg *bestseg = NULL; - DWORD bestj = DWORD_MAX; j = first; do { @@ -328,14 +327,12 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector, vertex_t { bestdiff = diff; bestseg = seg; - bestj = j; break; } if (diff < bestdiff && diff > 0) { bestdiff = diff; bestseg = seg; - bestj = j; } } while (++j < max); diff --git a/src/nodebuild_gl.cpp b/src/nodebuild_gl.cpp index d029e7f69..8853a7eab 100644 --- a/src/nodebuild_gl.cpp +++ b/src/nodebuild_gl.cpp @@ -176,7 +176,7 @@ void FNodeBuilder::AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, { if (prev != NULL) { - DWORD fseg1, bseg1, fseg2, bseg2; + DWORD fseg1, bseg1; DWORD fnseg, bnseg; // Minisegs should only be added when they can create valid loops on both the front and @@ -186,8 +186,8 @@ void FNodeBuilder::AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, if ((fseg1 = CheckLoopStart (node.dx, node.dy, prev->Info.Vertex, event->Info.Vertex)) != DWORD_MAX && (bseg1 = CheckLoopStart (-node.dx, -node.dy, event->Info.Vertex, prev->Info.Vertex)) != DWORD_MAX && - (fseg2 = CheckLoopEnd (node.dx, node.dy, event->Info.Vertex)) != DWORD_MAX && - (bseg2 = CheckLoopEnd (-node.dx, -node.dy, prev->Info.Vertex)) != DWORD_MAX) + (CheckLoopEnd (node.dx, node.dy, event->Info.Vertex)) != DWORD_MAX && + (CheckLoopEnd (-node.dx, -node.dy, prev->Info.Vertex)) != DWORD_MAX) { // Add miniseg on the front side fnseg = AddMiniseg (prev->Info.Vertex, event->Info.Vertex, DWORD_MAX, fseg1, splitseg); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 4b9a8bbab..780495e76 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -660,10 +660,7 @@ void ACSStringPool::ReadStrings(PNGHandle *png, DWORD id) i++; j = arc.ReadCount(); } - if (str != NULL) - { - delete[] str; - } + delete[] str; FindFirstFreeEntry(0); } } @@ -2052,7 +2049,6 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len) } } } - i += 4+ArrayStore[arraynum].ArraySize; } } @@ -5846,13 +5842,13 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) } FActorIterator iterator(args[0]); - bool canraiseall = false; + bool canraiseall = true; while ((actor = iterator.Next())) { - canraiseall = !P_Thing_CanRaise(actor) | canraiseall; + canraiseall = P_Thing_CanRaise(actor) && canraiseall; } - return !canraiseall; + return canraiseall; } break; diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 2ee2ae83a..2c5c78921 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -249,7 +249,7 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * BYTE infoBlock[37]; int mapver = data[5]; DWORD matt; - int numRevisions, numWalls, numsprites, skyLen, visibility, parallaxType; + int numRevisions, numWalls, numsprites, skyLen, visibility; int i; int k; @@ -271,7 +271,7 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * } skyLen = 2 << LittleShort(*(WORD *)(infoBlock + 16)); visibility = LittleLong(*(DWORD *)(infoBlock + 18)); - parallaxType = infoBlock[26]; + numRevisions = LittleLong(*(DWORD *)(infoBlock + 27)); numsectors = LittleShort(*(WORD *)(infoBlock + 31)); numWalls = LittleShort(*(WORD *)(infoBlock + 33)); diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 09f2d49d6..ac59e6a4b 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -924,7 +924,7 @@ public: { const char *speakerName; int x, y, linesize; - int width, fontheight; + int width=screen->GetWidth(), height=screen->GetHeight(), fontheight; player_t *cp = &players[consoleplayer]; @@ -949,8 +949,8 @@ public: { screen->DrawTexture (TexMan(CurNode->Backdrop), 0, 0, DTA_320x200, true, TAG_DONE); } - x = 16 * screen->GetWidth() / 320; - y = 16 * screen->GetHeight() / 200; + x = 16 * width / 320; + y = 16 * height / 200; linesize = 10 * CleanYfac; // Who is talking to you? @@ -970,16 +970,16 @@ public: int i; for (i = 0; mDialogueLines[i].Width >= 0; ++i) { } - screen->Dim (0, 0.45f, 14 * screen->GetWidth() / 320, 13 * screen->GetHeight() / 200, - 308 * screen->GetWidth() / 320 - 14 * screen->GetWidth () / 320, + screen->Dim (0, 0.45f, 14 * width / 320, 13 * height / 200, + 308 * width / 320 - 14 * width / 320, speakerName == NULL ? linesize * i + 6 * CleanYfac : linesize * i + 6 * CleanYfac + linesize * 3/2); } // Dim the screen behind the PC's choices. - screen->Dim (0, 0.45f, (24-160) * CleanXfac + screen->GetWidth()/2, - (mYpos - 2 - 100) * CleanYfac + screen->GetHeight()/2, + screen->Dim (0, 0.45f, (24-160) * CleanXfac + width/2, + (mYpos - 2 - 100) * CleanYfac + height/2, 272 * CleanXfac, MIN(mResponseLines.Size() * OptionSettings.mLinespacing + 4, 200 - mYpos) * CleanYfac); @@ -989,7 +989,7 @@ public: DTA_CleanNoMove, true, TAG_DONE); y += linesize * 3 / 2; } - x = 24 * screen->GetWidth() / 320; + x = 24 * width / 320; for (int i = 0; mDialogueLines[i].Width >= 0; ++i) { screen->DrawText (SmallFont, CR_UNTRANSLATED, x, y, mDialogueLines[i].Text, @@ -1019,7 +1019,6 @@ public: int response = 0; for (unsigned i = 0; i < mResponseLines.Size(); i++, y += fontheight) { - width = SmallFont->StringWidth(mResponseLines[i]); x = 64; screen->DrawText (SmallFont, CR_GREEN, x, y, mResponseLines[i], DTA_Clean, true, TAG_DONE); @@ -1037,8 +1036,8 @@ public: { int color = ((DMenu::MenuTime%8) < 4) || DMenu::CurrentMenu != this ? CR_RED:CR_GREY; - x = (50 + 3 - 160) * CleanXfac + screen->GetWidth() / 2; - int yy = (y + fontheight/2 - 5 - 100) * CleanYfac + screen->GetHeight() / 2; + x = (50 + 3 - 160) * CleanXfac + width / 2; + int yy = (y + fontheight/2 - 5 - 100) * CleanYfac + height / 2; screen->DrawText (ConFont, color, x, yy, "\xd", DTA_CellX, 8 * CleanXfac, DTA_CellY, 8 * CleanYfac, diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 618f50663..1892d4488 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2533,8 +2533,6 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) // use the current actor's radius instead of the Arch Vile's default. fixed_t maxdist = corpsehit->GetDefault()->radius + self->radius; - maxdist = corpsehit->GetDefault()->radius + self->radius; - if (abs(corpsehit->x - viletryx) > maxdist || abs(corpsehit->y - viletryy) > maxdist) continue; // not actually touching diff --git a/src/p_floor.cpp b/src/p_floor.cpp index 9a5a6eaf8..9d47729ae 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -900,12 +900,12 @@ DElevator::DElevator () } DElevator::DElevator (sector_t *sec) - : Super (sec) + : m_Interp_Floor(sec->SetInterpolation(sector_t::FloorMove, true)), + m_Interp_Ceiling(sec->SetInterpolation(sector_t::CeilingMove, true)), + Super (sec) { sec->floordata = this; sec->ceilingdata = this; - m_Interp_Floor = sec->SetInterpolation(sector_t::FloorMove, true); - m_Interp_Ceiling = sec->SetInterpolation(sector_t::CeilingMove, true); } void DElevator::Serialize (FArchive &arc) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 7bf19a03b..5f5d728bc 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -366,7 +366,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags) if (debugfile && this->player) { - static int dieticks[MAXPLAYERS]; + static int dieticks[MAXPLAYERS]; // [ZzZombo] not used? Except if for peeking in debugger... int pnum = int(this->player-players); dieticks[pnum] = gametic; fprintf (debugfile, "died (%d) on tic %d (%s)\n", pnum, gametic, @@ -1716,14 +1716,12 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage, bool playPainSound) { AActor *target; - AActor *inflictor; if (player == NULL) { return; } target = player->mo; - inflictor = source; if (target->health <= 0) { return; diff --git a/src/p_map.cpp b/src/p_map.cpp index 68d0b21f0..a62f2e019 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -755,12 +755,14 @@ bool PIT_CheckLine(line_t *ld, const FBoundingBox &box, FCheckPosition &tm) if (!(tm.thing->flags & MF_DROPOFF) && !(tm.thing->flags & (MF_NOGRAVITY | MF_NOCLIP))) { - secplane_t frontplane = ld->frontsector->floorplane; - secplane_t backplane = ld->backsector->floorplane; + secplane_t frontplane, backplane; #ifdef _3DFLOORS // Check 3D floors as well frontplane = P_FindFloorPlane(ld->frontsector, tm.thing->x, tm.thing->y, tm.thing->floorz); backplane = P_FindFloorPlane(ld->backsector, tm.thing->x, tm.thing->y, tm.thing->floorz); +#else + frontplane = ld->frontsector->floorplane; + backplane = ld->backsector->floorplane; #endif if (frontplane.c < STEEPSLOPE || backplane.c < STEEPSLOPE) { @@ -2964,7 +2966,6 @@ bool FSlide::BounceWall(AActor *mo) deltaangle = (2 * lineangle) - moveangle; mo->angle = deltaangle; - lineangle >>= ANGLETOFINESHIFT; deltaangle >>= ANGLETOFINESHIFT; movelen = fixed_t(sqrt(double(mo->velx)*mo->velx + double(mo->vely)*mo->vely)); @@ -3151,9 +3152,6 @@ bool aim_t::AimTraverse3DFloors(const divline_t &trace, intercept_t * in) fixed_t trY = trace.y + FixedMul(trace.dy, in->frac); fixed_t dist = FixedMul(attackrange, in->frac); - - int dir = aimpitch < 0 ? 1 : aimpitch > 0 ? -1 : 0; - frontflag = P_PointOnLineSide(shootthing->x, shootthing->y, li); // 3D floor check. This is not 100% accurate but normally sufficient when diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index c61b77eba..5cb008bf1 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1979,11 +1979,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) bool blockingtg = (BlockingMobj->target != NULL); if (BlockingMobj->flags7 & MF7_AIMREFLECT && (tg || blockingtg)) { - AActor *origin; - if (tg) - origin = mo->target; - else if (blockingtg) - origin = BlockingMobj->target; + AActor *origin=tg ? mo->target : BlockingMobj->target; float speed = (float)(mo->Speed); //dest->x - source->x @@ -3496,11 +3492,13 @@ void AActor::Tick () velz <= 0 && floorz == z) { - secplane_t floorplane = floorsector->floorplane; + secplane_t floorplane; #ifdef _3DFLOORS // Check 3D floors as well floorplane = P_FindFloorPlane(floorsector, x, y, floorz); +#else + floorplane = floorsector->floorplane; #endif if (floorplane.c < STEEPSLOPE && @@ -5631,18 +5629,25 @@ static fixed_t GetDefaultSpeed(const PClass *type) AActor *P_SpawnMissile (AActor *source, AActor *dest, const PClass *type, AActor *owner) { + if(!source) + return NULL; return P_SpawnMissileXYZ (source->x, source->y, source->z + 32*FRACUNIT + source->GetBobOffset(), source, dest, type, true, owner); } AActor *P_SpawnMissileZ (AActor *source, fixed_t z, AActor *dest, const PClass *type) { + if(!source) + return NULL; return P_SpawnMissileXYZ (source->x, source->y, z, source, dest, type); } AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, AActor *source, AActor *dest, const PClass *type, bool checkspawn, AActor *owner) { + if(!source) + return NULL; + if (dest == NULL) { Printf ("P_SpawnMissilyXYZ: Tried to shoot %s from %s with no dest\n", @@ -5712,6 +5717,8 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, AActor * P_OldSpawnMissile(AActor * source, AActor * owner, AActor * dest, const PClass *type) { + if(!source) + return NULL; angle_t an; fixed_t dist; AActor *th = Spawn (type, source->x, source->y, source->z + 4*8*FRACUNIT, ALLOW_REPLACE); @@ -5753,6 +5760,8 @@ AActor * P_OldSpawnMissile(AActor * source, AActor * owner, AActor * dest, const AActor *P_SpawnMissileAngle (AActor *source, const PClass *type, angle_t angle, fixed_t velz) { + if(!source) + return NULL; return P_SpawnMissileAngleZSpeed (source, source->z + 32*FRACUNIT + source->GetBobOffset(), type, angle, velz, GetDefaultSpeed (type)); } @@ -5760,12 +5769,16 @@ AActor *P_SpawnMissileAngle (AActor *source, const PClass *type, AActor *P_SpawnMissileAngleZ (AActor *source, fixed_t z, const PClass *type, angle_t angle, fixed_t velz) { + if(!source) + return NULL; return P_SpawnMissileAngleZSpeed (source, z, type, angle, velz, GetDefaultSpeed (type)); } AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, const PClass *type) { + if(!source) + return NULL; angle_t an; fixed_t dist; fixed_t speed; @@ -5796,6 +5809,8 @@ AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, const PCl AActor *P_SpawnMissileAngleSpeed (AActor *source, const PClass *type, angle_t angle, fixed_t velz, fixed_t speed) { + if(!source) + return NULL; return P_SpawnMissileAngleZSpeed (source, source->z + 32*FRACUNIT + source->GetBobOffset(), type, angle, velz, speed); } @@ -5803,6 +5818,8 @@ AActor *P_SpawnMissileAngleSpeed (AActor *source, const PClass *type, AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, const PClass *type, angle_t angle, fixed_t velz, fixed_t speed, AActor *owner, bool checkspawn) { + if(!source) + return NULL; AActor *mo; if (z != ONFLOORZ && z != ONCEILINGZ && source != NULL) @@ -5840,6 +5857,8 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, AActor *P_SpawnPlayerMissile (AActor *source, const PClass *type) { + if(!source) + return NULL; return P_SpawnPlayerMissile (source, 0, 0, 0, type, source->angle); } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 6b5d9403f..9da28d9d8 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1362,7 +1362,7 @@ void P_LoadSegs (MapData * map) } } } - catch (badseg bad) + catch (const badseg &bad) // the preferred way is to catch by (const) reference. { switch (bad.badtype) { @@ -1467,7 +1467,6 @@ void P_LoadSubsectors (MapData * map) void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex) { - char fname[9]; int i; char *msp; mapsector_t *ms; @@ -1486,7 +1485,6 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex) defSeqType = -1; fogMap = normMap = NULL; - fname[8] = 0; msp = new char[lumplen]; map->Read(ML_SECTORS, msp); @@ -3044,16 +3042,14 @@ void P_LoadBlockMap (MapData * map) blockmap = blockmaplump+4; } - +line_t** linebuffer; // // P_GroupLines // Builds sector line lists and subsector sector numbers. // Finds block bounding boxes for sectors. -// [RH] Handles extra lights +// [RH] Handles extra lights. // -struct linf { short tag; WORD count; }; -line_t** linebuffer; static void P_GroupLines (bool buildmap) { @@ -3062,7 +3058,6 @@ static void P_GroupLines (bool buildmap) int i; int j; int total; - int totallights; line_t* li; sector_t* sector; FBoundingBox bbox; @@ -3095,7 +3090,6 @@ static void P_GroupLines (bool buildmap) // count number of lines in each sector times[1].Clock(); total = 0; - totallights = 0; for (i = 0, li = lines; i < numlines; i++, li++) { if (li->frontsector == NULL) diff --git a/src/p_slopes.cpp b/src/p_slopes.cpp index af0ad7a20..2cce53a92 100644 --- a/src/p_slopes.cpp +++ b/src/p_slopes.cpp @@ -529,11 +529,9 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which) FVector3 p, v1, v2, cross; - const secplane_t *refplane; secplane_t *srcplane; fixed_t srcheight, destheight; - refplane = (which == 0) ? &refsec->floorplane : &refsec->ceilingplane; srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane; srcheight = (which == 0) ? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling); destheight = (which == 0) ? refsec->GetPlaneTexZ(sector_t::floor) : refsec->GetPlaneTexZ(sector_t::ceiling); diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 40e432af0..e930ffd62 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -188,8 +188,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, // Spawn teleport fog at source and destination if (sourceFog && !predicting) { - fixed_t fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT; - P_SpawnTeleportFog(thing, oldx, oldy, oldz, true, true); //Passes the actor through which then pulls the TeleFog metadate types based on properties. + P_SpawnTeleportFog(thing, oldx, oldy, oldz, true, true); //Passes the actor through then pulls the TeleFog metadata types based on properties. } if (useFog) { diff --git a/src/p_usdf.cpp b/src/p_usdf.cpp index 2ab52e380..99ac071e8 100644 --- a/src/p_usdf.cpp +++ b/src/p_usdf.cpp @@ -135,7 +135,6 @@ class USDFParser : public UDMFParserBase while (!sc.CheckToken('}')) { bool block = false; - int costs = 0; FName key = ParseKey(true, &block); if (!block) { diff --git a/src/p_user.cpp b/src/p_user.cpp index e91766cf0..21ebf00a1 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -101,11 +101,10 @@ FPlayerClass::FPlayerClass () Flags = 0; } -FPlayerClass::FPlayerClass (const FPlayerClass &other) +FPlayerClass::FPlayerClass (const FPlayerClass &other) : Skins(other.Skins) { Type = other.Type; Flags = other.Flags; - Skins = other.Skins; } FPlayerClass::~FPlayerClass () diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 6572c1f0b..8c01a1c3e 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -438,7 +438,6 @@ void R_MapTiltedPlane (int y, int x1) } startu = endu; startv = endv; - startz = endz; width -= SPANSIZE; } if (width > 0) From 003817f415f414314ff0dc507658a07558a143ea Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 8 Feb 2015 11:08:02 +0200 Subject: [PATCH 11/50] Added customization of ammo display in alternative HUD Added hud_showammo CVAR with three states: * If value is 0, show ammo for current weapon only * If value is 1, show ammo for available weapons * If value is greater than 1, show ammo for all weapons Default value is 2, so initial ammo display behavior isn't changed --- src/g_shared/shared_hud.cpp | 41 +++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 110675791..89acd5fd2 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -73,6 +73,7 @@ CVAR (Bool, hud_showitems, false,CVAR_ARCHIVE); // Show item stats on HUD CVAR (Bool, hud_showstats, false, CVAR_ARCHIVE); // for stamina and accuracy. CVAR (Bool, hud_showscore, false, CVAR_ARCHIVE); // for user maintained score CVAR (Bool, hud_showweapons, true, CVAR_ARCHIVE); // Show weapons collected +CVAR (Int , hud_showammo, 2, CVAR_ARCHIVE); // Show ammo collected CVAR (Int , hud_showtime, 0, CVAR_ARCHIVE); // Show time on HUD CVAR (Int , hud_timecolor, CR_GOLD,CVAR_ARCHIVE); // Color of in-game time on HUD CVAR (Int , hud_showlag, 0, CVAR_ARCHIVE); // Show input latency (maketic - gametic difference) @@ -547,23 +548,37 @@ static int DrawAmmo(player_t *CPlayer, int x, int y) orderedammos.Clear(); - // Order ammo by use of weapons in the weapon slots - // Do not check for actual presence in the inventory! - // We want to show all ammo types that can be used by - // the weapons in the weapon slots. - for (k = 0; k < NUM_WEAPON_SLOTS; k++) for(j = 0; j < CPlayer->weapons.Slots[k].Size(); j++) + if (0 == hud_showammo) { - const PClass *weap = CPlayer->weapons.Slots[k].GetWeapon(j); - - if (weap) AddAmmoToList((AWeapon*)GetDefaultByType(weap)); + // Show ammo for current weapon if any + if (wi) AddAmmoToList(wi); } - - // Now check for the remaining weapons that are in the inventory but not in the weapon slots - for(inv=CPlayer->mo->Inventory;inv;inv=inv->Inventory) + else { - if (inv->IsKindOf(RUNTIME_CLASS(AWeapon))) + // Order ammo by use of weapons in the weapon slots + for (k = 0; k < NUM_WEAPON_SLOTS; k++) for(j = 0; j < CPlayer->weapons.Slots[k].Size(); j++) { - AddAmmoToList((AWeapon*)inv); + const PClass *weap = CPlayer->weapons.Slots[k].GetWeapon(j); + + if (weap) + { + // Show ammo for available weapons if hud_showammo CVAR is 1 + // or show ammo for all weapons if hud_showammo is greater than 1 + + if (hud_showammo > 1 || CPlayer->mo->FindInventory(weap)) + { + AddAmmoToList((AWeapon*)GetDefaultByType(weap)); + } + } + } + + // Now check for the remaining weapons that are in the inventory but not in the weapon slots + for(inv=CPlayer->mo->Inventory;inv;inv=inv->Inventory) + { + if (inv->IsKindOf(RUNTIME_CLASS(AWeapon))) + { + AddAmmoToList((AWeapon*)inv); + } } } From bd93ce63a9ea931c1adc1e903fe9623012210467 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 8 Feb 2015 11:08:52 +0200 Subject: [PATCH 12/50] Added menu option to customize ammo display in alternative HUD --- wadsrc/static/menudef.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 978480e4d..58240440d 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -795,6 +795,13 @@ OptionValue "AltHUDScale" 2, "Pixel double" } +OptionValue "AltHUDAmmo" +{ + 0, "Current weapon" + 1, "Available weapons" + 2, "All weapons" +} + OptionValue "AltHUDTime" { 0, "Off" @@ -828,6 +835,7 @@ OptionMenu "AltHUDOptions" Option "Show stamina and accuracy", "hud_showstats", "OnOff" Option "Show berserk", "hud_berserk_health", "OnOff" Option "Show weapons", "hud_showweapons", "OnOff" + Option "Show ammo for", "hud_showammo", "AltHUDAmmo" Option "Show time", "hud_showtime", "AltHUDTime" Option "Time color", "hud_timecolor", "TextColors" Option "Show network latency", "hud_showlag", "AltHUDLag" From 0be3341031f959158771eea650dd75da9e11e712 Mon Sep 17 00:00:00 2001 From: ZzZombo Date: Sun, 8 Feb 2015 18:04:11 +0800 Subject: [PATCH 13/50] - Missed some unused variables. --- src/nodebuild.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nodebuild.cpp b/src/nodebuild.cpp index d39157aed..081b42f3e 100644 --- a/src/nodebuild.cpp +++ b/src/nodebuild.cpp @@ -937,7 +937,6 @@ void FNodeBuilder::SetNodeFromSeg (node_t &node, const FPrivSeg *pseg) const DWORD FNodeBuilder::SplitSeg (DWORD segnum, int splitvert, int v1InFront) { - double dx, dy; FPrivSeg newseg; int newnum = (int)Segs.Size(); From ae78aeaacb3adac5e40673c62298d3829fbaf164 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 8 Feb 2015 11:48:41 +0100 Subject: [PATCH 14/50] - if this buffer is freed, the pointer referring to it must also be deleted. --- src/d_net.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_net.cpp b/src/d_net.cpp index cbce9d309..73ad037ce 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2057,6 +2057,7 @@ void FDynamicBuffer::SetData (const BYTE *data, int len) { m_Len = 0; M_Free(m_Data); + m_Data = NULL; } } From c93f96c303fbe12a1e39dcf06158b0337b263b09 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sun, 8 Feb 2015 08:54:55 -0600 Subject: [PATCH 15/50] Typo in SXF_TRANSFERSPRITEFRAME fixed. --- wadsrc/static/actors/constants.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 27f2d78d8..1604b5c83 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -72,7 +72,7 @@ const int SXF_SETTARGET = 1 << 20; const int SXF_SETTRACER = 1 << 21; const int SXF_NOPOINTERS = 1 << 22; const int SXF_ORIGINATOR = 1 << 23; -const int SIXF_TRANSFERSPRITEFRAME = 1 << 24; +const int SXF_TRANSFERSPRITEFRAME = 1 << 24; // Flags for A_Chase const int CHF_FASTCHASE = 1; From e047902d56a5d1d94f904ab8f6fcd31d78775614 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 8 Feb 2015 17:58:24 +0100 Subject: [PATCH 16/50] - resanitation of FDynamicBuffer::SetData. --- src/d_net.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 73ad037ce..4483f3cf9 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2053,11 +2053,9 @@ void FDynamicBuffer::SetData (const BYTE *data, int len) m_Len = len; memcpy (m_Data, data, len); } - else + else { m_Len = 0; - M_Free(m_Data); - m_Data = NULL; } } From 2d7592c2c34d5097302846098707b0f8c0418c8e Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 8 Feb 2015 19:49:08 -0600 Subject: [PATCH 17/50] Restore nodebuilder files to their previous versions - For easy comparison, changes between the built-in nodebuilder and ZDBSP must be kept to a minimum. --- src/nodebuild.cpp | 6 +++++- src/nodebuild_extract.cpp | 3 +++ src/nodebuild_gl.cpp | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/nodebuild.cpp b/src/nodebuild.cpp index 081b42f3e..210f0f3de 100644 --- a/src/nodebuild.cpp +++ b/src/nodebuild.cpp @@ -937,10 +937,13 @@ void FNodeBuilder::SetNodeFromSeg (node_t &node, const FPrivSeg *pseg) const DWORD FNodeBuilder::SplitSeg (DWORD segnum, int splitvert, int v1InFront) { + double dx, dy; FPrivSeg newseg; int newnum = (int)Segs.Size(); newseg = Segs[segnum]; + dx = double(Vertices[splitvert].x - Vertices[newseg.v1].x); + dy = double(Vertices[splitvert].y - Vertices[newseg.v1].y); if (v1InFront > 0) { newseg.v1 = splitvert; @@ -1126,7 +1129,8 @@ int ClassifyLineBackpatchC (node_t &node, const FSimpleVert *v1, const FSimpleVe long pagesize = sysconf(_SC_PAGESIZE); char *callerpage = (char *)((intptr_t)calleroffset & ~(pagesize - 1)); size_t protectlen = (intptr_t)calleroffset + sizeof(void*) - (intptr_t)callerpage; - if (!mprotect(callerpage, protectlen, PROT_READ|PROT_WRITE|PROT_EXEC)) + int ptect; + if (!(ptect = mprotect(callerpage, protectlen, PROT_READ|PROT_WRITE|PROT_EXEC))) #endif { *calleroffset = diff; diff --git a/src/nodebuild_extract.cpp b/src/nodebuild_extract.cpp index 04660f6d0..c0f769873 100644 --- a/src/nodebuild_extract.cpp +++ b/src/nodebuild_extract.cpp @@ -317,6 +317,7 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector, vertex_t { angle_t bestdiff = ANGLE_MAX; FPrivSeg *bestseg = NULL; + DWORD bestj = DWORD_MAX; j = first; do { @@ -327,12 +328,14 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector, vertex_t { bestdiff = diff; bestseg = seg; + bestj = j; break; } if (diff < bestdiff && diff > 0) { bestdiff = diff; bestseg = seg; + bestj = j; } } while (++j < max); diff --git a/src/nodebuild_gl.cpp b/src/nodebuild_gl.cpp index 8853a7eab..d029e7f69 100644 --- a/src/nodebuild_gl.cpp +++ b/src/nodebuild_gl.cpp @@ -176,7 +176,7 @@ void FNodeBuilder::AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, { if (prev != NULL) { - DWORD fseg1, bseg1; + DWORD fseg1, bseg1, fseg2, bseg2; DWORD fnseg, bnseg; // Minisegs should only be added when they can create valid loops on both the front and @@ -186,8 +186,8 @@ void FNodeBuilder::AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, if ((fseg1 = CheckLoopStart (node.dx, node.dy, prev->Info.Vertex, event->Info.Vertex)) != DWORD_MAX && (bseg1 = CheckLoopStart (-node.dx, -node.dy, event->Info.Vertex, prev->Info.Vertex)) != DWORD_MAX && - (CheckLoopEnd (node.dx, node.dy, event->Info.Vertex)) != DWORD_MAX && - (CheckLoopEnd (-node.dx, -node.dy, prev->Info.Vertex)) != DWORD_MAX) + (fseg2 = CheckLoopEnd (node.dx, node.dy, event->Info.Vertex)) != DWORD_MAX && + (bseg2 = CheckLoopEnd (-node.dx, -node.dy, prev->Info.Vertex)) != DWORD_MAX) { // Add miniseg on the front side fnseg = AddMiniseg (prev->Info.Vertex, event->Info.Vertex, DWORD_MAX, fseg1, splitseg); From fd7ed2bc25a732ca11c786be516a68242480309f Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 8 Feb 2015 20:39:55 -0600 Subject: [PATCH 18/50] Undo most of ZzZombo's changes - "If it ain't broke, don't fix it." - Some of the changes were downright wrong and some were pointless, so undo everything that doesn't look like an actual improvement. --- src/am_map.cpp | 13 +++------- src/b_bot.cpp | 4 ++-- src/c_cvars.cpp | 11 +++++---- src/compatibility.h | 4 ++-- src/configfile.cpp | 3 ++- src/decallib.cpp | 6 +++-- src/dobjtype.h | 2 +- src/dsectoreffect.cpp | 3 ++- src/g_level.h | 2 +- src/g_shared/a_pickups.h | 2 +- src/i_net.cpp | 2 +- src/m_argv.cpp | 4 ++-- src/menu/menu.h | 3 ++- src/p_acs.cpp | 7 ++++-- src/p_conversation.cpp | 21 ++++++++-------- src/p_floor.cpp | 6 ++--- src/p_mobj.cpp | 48 ++++++++++++++++++++++++------------- src/p_setup.cpp | 5 ++-- src/p_teleport.cpp | 2 +- src/p_user.cpp | 3 ++- src/thingdef/thingdef_exp.h | 4 +++- 21 files changed, 89 insertions(+), 66 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 1529b4740..0133a2493 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1234,16 +1234,9 @@ void AM_initVariables () for (pnum=0;pnum=MAXPLAYERS) - { - m_x=m_y=0; - } - else - { - m_x = (players[pnum].camera->x >> FRACTOMAPBITS) - m_w/2; - m_y = (players[pnum].camera->y >> FRACTOMAPBITS) - m_h/2; - } + assert(pnum >= 0 && pnum < MAXPLAYERS); + m_x = (players[pnum].camera->x >> FRACTOMAPBITS) - m_w/2; + m_y = (players[pnum].camera->y >> FRACTOMAPBITS) - m_h/2; AM_changeWindowLoc(); // for saving & restoring diff --git a/src/b_bot.cpp b/src/b_bot.cpp index 548d10e2e..05cac045b 100644 --- a/src/b_bot.cpp +++ b/src/b_bot.cpp @@ -61,8 +61,8 @@ void DBot::Serialize (FArchive &arc) if (SaveVersion < 4515) { - angle_t savedyaw=0; - int savedpitch=0; + angle_t savedyaw; + int savedpitch; arc << savedyaw << savedpitch; } diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index c7a71197b..2c6510219 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -439,7 +439,7 @@ static BYTE HexToByte (const char *hex) UCVarValue FBaseCVar::FromString (const char *value, ECVarType type) { UCVarValue ret; - int i=0; + int i; switch (type) { @@ -475,8 +475,11 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type) // 0 1 2 3 ret.pGUID = NULL; - if(value) - for (; i < 38; i++) + if (value == NULL) + { + break; + } + for (i = 0; value[i] != 0 && i < 38; i++) { switch (i) { @@ -1685,7 +1688,7 @@ void FBaseCVar::ListVars (const char *filter, bool plain) flags & CVAR_MOD ? 'M' : ' ', flags & CVAR_IGNORE ? 'X' : ' ', var->GetName(), - var->GetGenericRep (CVAR_String).String); + var->GetGenericRep(CVAR_String).String); } } var = var->m_Next; diff --git a/src/compatibility.h b/src/compatibility.h index d37d25903..cf4dce2f7 100644 --- a/src/compatibility.h +++ b/src/compatibility.h @@ -20,11 +20,11 @@ struct FCompatValues struct FMD5HashTraits { - hash_t Hash(const FMD5Holder &key) + hash_t Hash(const FMD5Holder key) { return key.Hash; } - int Compare(const FMD5Holder &left, const FMD5Holder &right) + int Compare(const FMD5Holder left, const FMD5Holder right) { return left.DWords[0] != right.DWords[0] || left.DWords[1] != right.DWords[1] || diff --git a/src/configfile.cpp b/src/configfile.cpp index 4d642a81d..177c019fb 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -50,11 +50,12 @@ static FRandom pr_endtag; // //==================================================================== -FConfigFile::FConfigFile () : PathName(NAME_None) +FConfigFile::FConfigFile () { Sections = CurrentSection = NULL; LastSectionPtr = &Sections; CurrentEntry = NULL; + PathName = ""; OkayToWrite = true; FileExisted = true; } diff --git a/src/decallib.cpp b/src/decallib.cpp index 4da7ba92c..0ea3423c4 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -1022,8 +1022,9 @@ FDecalLib::FTranslation *FDecalLib::GenerateTranslation (DWORD start, DWORD end) return trans; } -FDecalBase::FDecalBase () : Name(NAME_None) +FDecalBase::FDecalBase () { + Name = NAME_None; } FDecalBase::~FDecalBase () @@ -1136,8 +1137,9 @@ const FDecalTemplate *FDecalGroup::GetDecal () const return static_cast(remember); } -FDecalAnimator::FDecalAnimator (const char *name) : Name(name) +FDecalAnimator::FDecalAnimator (const char *name) { + Name = name; } FDecalAnimator::~FDecalAnimator () diff --git a/src/dobjtype.h b/src/dobjtype.h index 252287e3e..256e52ad8 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -24,7 +24,7 @@ struct PSymbol FName SymbolName; protected: - PSymbol(FName name, ESymbolType type):SymbolName(name) { SymbolType = type; } + PSymbol(FName name, ESymbolType type) { SymbolType = type; SymbolName = name; } }; // A constant value --------------------------------------------------------- diff --git a/src/dsectoreffect.cpp b/src/dsectoreffect.cpp index 82a7deb6f..6732a19dc 100644 --- a/src/dsectoreffect.cpp +++ b/src/dsectoreffect.cpp @@ -78,8 +78,9 @@ DMover::DMover () } DMover::DMover (sector_t *sector) - : DSectorEffect (sector), interpolation(NULL) + : DSectorEffect (sector) { + interpolation = NULL; } void DMover::Destroy() diff --git a/src/g_level.h b/src/g_level.h index aaddfce3c..6e07b0c74 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -241,7 +241,7 @@ struct FOptionalMapinfoData { FOptionalMapinfoData *Next; FName identifier; - FOptionalMapinfoData():identifier(NAME_None) { Next = NULL; } + FOptionalMapinfoData() { Next = NULL; identifier = NAME_None; } virtual ~FOptionalMapinfoData() {} virtual FOptionalMapinfoData *Clone() const = 0; }; diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 968de8eac..df0c94b46 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -16,7 +16,7 @@ class FWeaponSlot { public: FWeaponSlot() { Clear(); } - FWeaponSlot(const FWeaponSlot &other):Weapons(other.Weapons) {} + FWeaponSlot(const FWeaponSlot &other) { Weapons = other.Weapons; } FWeaponSlot &operator= (const FWeaponSlot &other) { Weapons = other.Weapons; return *this; } void Clear() { Weapons.Clear(); } bool AddWeapon (const char *type); diff --git a/src/i_net.cpp b/src/i_net.cpp index da1063bc9..d3958e1e1 100644 --- a/src/i_net.cpp +++ b/src/i_net.cpp @@ -238,7 +238,7 @@ void PacketSend (void) else { // Printf("send %d\n", doomcom.datalength); - /*c = */sendto(mysocket, (char *)doomcom.data, doomcom.datalength, + c = sendto(mysocket, (char *)doomcom.data, doomcom.datalength, 0, (sockaddr *)&sendaddress[doomcom.remotenode], sizeof(sendaddress[doomcom.remotenode])); } diff --git a/src/m_argv.cpp b/src/m_argv.cpp index ef3f59fef..004f7857d 100644 --- a/src/m_argv.cpp +++ b/src/m_argv.cpp @@ -55,8 +55,8 @@ DArgs::DArgs() // //=========================================================================== -DArgs::DArgs(const DArgs &other):Argv(other.Argv), - DObject() +DArgs::DArgs(const DArgs &other) +: DObject(), Argv(other.Argv) { } diff --git a/src/menu/menu.h b/src/menu/menu.h index b256ccb2f..3712c9065 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -261,10 +261,11 @@ protected: public: bool mEnabled; - FListMenuItem(int xpos = 0, int ypos = 0, FName action = NAME_None):mAction(action) + FListMenuItem(int xpos = 0, int ypos = 0, FName action = NAME_None) { mXpos = xpos; mYpos = ypos; + mAction = action; mEnabled = true; } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 780495e76..8c6631b5e 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -660,7 +660,10 @@ void ACSStringPool::ReadStrings(PNGHandle *png, DWORD id) i++; j = arc.ReadCount(); } - delete[] str; + if (str != NULL) + { + delete[] str; + } FindFirstFreeEntry(0); } } @@ -5845,7 +5848,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) bool canraiseall = true; while ((actor = iterator.Next())) { - canraiseall = P_Thing_CanRaise(actor) && canraiseall; + canraiseall = P_Thing_CanRaise(actor) & canraiseall; } return canraiseall; diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index ac59e6a4b..09f2d49d6 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -924,7 +924,7 @@ public: { const char *speakerName; int x, y, linesize; - int width=screen->GetWidth(), height=screen->GetHeight(), fontheight; + int width, fontheight; player_t *cp = &players[consoleplayer]; @@ -949,8 +949,8 @@ public: { screen->DrawTexture (TexMan(CurNode->Backdrop), 0, 0, DTA_320x200, true, TAG_DONE); } - x = 16 * width / 320; - y = 16 * height / 200; + x = 16 * screen->GetWidth() / 320; + y = 16 * screen->GetHeight() / 200; linesize = 10 * CleanYfac; // Who is talking to you? @@ -970,16 +970,16 @@ public: int i; for (i = 0; mDialogueLines[i].Width >= 0; ++i) { } - screen->Dim (0, 0.45f, 14 * width / 320, 13 * height / 200, - 308 * width / 320 - 14 * width / 320, + screen->Dim (0, 0.45f, 14 * screen->GetWidth() / 320, 13 * screen->GetHeight() / 200, + 308 * screen->GetWidth() / 320 - 14 * screen->GetWidth () / 320, speakerName == NULL ? linesize * i + 6 * CleanYfac : linesize * i + 6 * CleanYfac + linesize * 3/2); } // Dim the screen behind the PC's choices. - screen->Dim (0, 0.45f, (24-160) * CleanXfac + width/2, - (mYpos - 2 - 100) * CleanYfac + height/2, + screen->Dim (0, 0.45f, (24-160) * CleanXfac + screen->GetWidth()/2, + (mYpos - 2 - 100) * CleanYfac + screen->GetHeight()/2, 272 * CleanXfac, MIN(mResponseLines.Size() * OptionSettings.mLinespacing + 4, 200 - mYpos) * CleanYfac); @@ -989,7 +989,7 @@ public: DTA_CleanNoMove, true, TAG_DONE); y += linesize * 3 / 2; } - x = 24 * width / 320; + x = 24 * screen->GetWidth() / 320; for (int i = 0; mDialogueLines[i].Width >= 0; ++i) { screen->DrawText (SmallFont, CR_UNTRANSLATED, x, y, mDialogueLines[i].Text, @@ -1019,6 +1019,7 @@ public: int response = 0; for (unsigned i = 0; i < mResponseLines.Size(); i++, y += fontheight) { + width = SmallFont->StringWidth(mResponseLines[i]); x = 64; screen->DrawText (SmallFont, CR_GREEN, x, y, mResponseLines[i], DTA_Clean, true, TAG_DONE); @@ -1036,8 +1037,8 @@ public: { int color = ((DMenu::MenuTime%8) < 4) || DMenu::CurrentMenu != this ? CR_RED:CR_GREY; - x = (50 + 3 - 160) * CleanXfac + width / 2; - int yy = (y + fontheight/2 - 5 - 100) * CleanYfac + height / 2; + x = (50 + 3 - 160) * CleanXfac + screen->GetWidth() / 2; + int yy = (y + fontheight/2 - 5 - 100) * CleanYfac + screen->GetHeight() / 2; screen->DrawText (ConFont, color, x, yy, "\xd", DTA_CellX, 8 * CleanXfac, DTA_CellY, 8 * CleanYfac, diff --git a/src/p_floor.cpp b/src/p_floor.cpp index 9d47729ae..9a5a6eaf8 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -900,12 +900,12 @@ DElevator::DElevator () } DElevator::DElevator (sector_t *sec) - : m_Interp_Floor(sec->SetInterpolation(sector_t::FloorMove, true)), - m_Interp_Ceiling(sec->SetInterpolation(sector_t::CeilingMove, true)), - Super (sec) + : Super (sec) { sec->floordata = this; sec->ceilingdata = this; + m_Interp_Floor = sec->SetInterpolation(sector_t::FloorMove, true); + m_Interp_Ceiling = sec->SetInterpolation(sector_t::CeilingMove, true); } void DElevator::Serialize (FArchive &arc) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 5cb008bf1..ce9fe722a 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1977,9 +1977,9 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { bool tg = (mo->target != NULL); bool blockingtg = (BlockingMobj->target != NULL); - if (BlockingMobj->flags7 & MF7_AIMREFLECT && (tg || blockingtg)) + if ((BlockingMobj->flags7 & MF7_AIMREFLECT) && (tg | blockingtg)) { - AActor *origin=tg ? mo->target : BlockingMobj->target; + AActor *origin = tg ? mo->target : BlockingMobj->target; float speed = (float)(mo->Speed); //dest->x - source->x @@ -1991,7 +1991,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) } else { - if (BlockingMobj->flags7 & MF7_MIRRORREFLECT && (tg || blockingtg)) + if ((BlockingMobj->flags7 & MF7_MIRRORREFLECT) && (tg | blockingtg)) { mo->angle += ANGLE_180; mo->velx = -mo->velx / 2; @@ -3498,7 +3498,7 @@ void AActor::Tick () // Check 3D floors as well floorplane = P_FindFloorPlane(floorsector, x, y, floorz); #else - floorplane = floorsector->floorplane; + floorplane = floorsector->floorplane; #endif if (floorplane.c < STEEPSLOPE && @@ -5629,24 +5629,30 @@ static fixed_t GetDefaultSpeed(const PClass *type) AActor *P_SpawnMissile (AActor *source, AActor *dest, const PClass *type, AActor *owner) { - if(!source) + if (source == NULL) + { return NULL; + } return P_SpawnMissileXYZ (source->x, source->y, source->z + 32*FRACUNIT + source->GetBobOffset(), source, dest, type, true, owner); } AActor *P_SpawnMissileZ (AActor *source, fixed_t z, AActor *dest, const PClass *type) { - if(!source) + if (source == NULL) + { return NULL; + } return P_SpawnMissileXYZ (source->x, source->y, z, source, dest, type); } AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, AActor *source, AActor *dest, const PClass *type, bool checkspawn, AActor *owner) { - if(!source) + if (source == NULL) + { return NULL; + } if (dest == NULL) { @@ -5717,8 +5723,10 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, AActor * P_OldSpawnMissile(AActor * source, AActor * owner, AActor * dest, const PClass *type) { - if(!source) + if (source == NULL) + { return NULL; + } angle_t an; fixed_t dist; AActor *th = Spawn (type, source->x, source->y, source->z + 4*8*FRACUNIT, ALLOW_REPLACE); @@ -5760,8 +5768,10 @@ AActor * P_OldSpawnMissile(AActor * source, AActor * owner, AActor * dest, const AActor *P_SpawnMissileAngle (AActor *source, const PClass *type, angle_t angle, fixed_t velz) { - if(!source) + if (source == NULL) + { return NULL; + } return P_SpawnMissileAngleZSpeed (source, source->z + 32*FRACUNIT + source->GetBobOffset(), type, angle, velz, GetDefaultSpeed (type)); } @@ -5769,16 +5779,16 @@ AActor *P_SpawnMissileAngle (AActor *source, const PClass *type, AActor *P_SpawnMissileAngleZ (AActor *source, fixed_t z, const PClass *type, angle_t angle, fixed_t velz) { - if(!source) - return NULL; return P_SpawnMissileAngleZSpeed (source, z, type, angle, velz, GetDefaultSpeed (type)); } AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, const PClass *type) { - if(!source) + if (source == NULL) + { return NULL; + } angle_t an; fixed_t dist; fixed_t speed; @@ -5809,8 +5819,10 @@ AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, const PCl AActor *P_SpawnMissileAngleSpeed (AActor *source, const PClass *type, angle_t angle, fixed_t velz, fixed_t speed) { - if(!source) + if (source == NULL) + { return NULL; + } return P_SpawnMissileAngleZSpeed (source, source->z + 32*FRACUNIT + source->GetBobOffset(), type, angle, velz, speed); } @@ -5818,11 +5830,13 @@ AActor *P_SpawnMissileAngleSpeed (AActor *source, const PClass *type, AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, const PClass *type, angle_t angle, fixed_t velz, fixed_t speed, AActor *owner, bool checkspawn) { - if(!source) + if (source == NULL) + { return NULL; + } AActor *mo; - if (z != ONFLOORZ && z != ONCEILINGZ && source != NULL) + if (z != ONFLOORZ && z != ONCEILINGZ) { z -= source->floorclip; } @@ -5857,8 +5871,10 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, AActor *P_SpawnPlayerMissile (AActor *source, const PClass *type) { - if(!source) + if (source == NULL) + { return NULL; + } return P_SpawnPlayerMissile (source, 0, 0, 0, type, source->angle); } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 9da28d9d8..c0810cc29 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3042,14 +3042,13 @@ void P_LoadBlockMap (MapData * map) blockmap = blockmaplump+4; } -line_t** linebuffer; - // // P_GroupLines // Builds sector line lists and subsector sector numbers. // Finds block bounding boxes for sectors. -// [RH] Handles extra lights. +// [RH] Handles extra lights // +line_t** linebuffer; static void P_GroupLines (bool buildmap) { diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index e930ffd62..3e3b03c4e 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -188,7 +188,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, // Spawn teleport fog at source and destination if (sourceFog && !predicting) { - P_SpawnTeleportFog(thing, oldx, oldy, oldz, true, true); //Passes the actor through then pulls the TeleFog metadata types based on properties. + P_SpawnTeleportFog(thing, oldx, oldy, oldz, true, true); //Passes the actor through which then pulls the TeleFog metadata types based on properties. } if (useFog) { diff --git a/src/p_user.cpp b/src/p_user.cpp index 21ebf00a1..e91766cf0 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -101,10 +101,11 @@ FPlayerClass::FPlayerClass () Flags = 0; } -FPlayerClass::FPlayerClass (const FPlayerClass &other) : Skins(other.Skins) +FPlayerClass::FPlayerClass (const FPlayerClass &other) { Type = other.Type; Flags = other.Flags; + Skins = other.Skins; } FPlayerClass::~FPlayerClass () diff --git a/src/thingdef/thingdef_exp.h b/src/thingdef/thingdef_exp.h index 1c46ab6b2..d3ee57345 100644 --- a/src/thingdef/thingdef_exp.h +++ b/src/thingdef/thingdef_exp.h @@ -152,9 +152,11 @@ struct ExpVal class FxExpression { protected: - FxExpression(const FScriptPosition &pos):ScriptPosition(pos) + FxExpression(const FScriptPosition &pos) + : ScriptPosition(pos) { isresolved = false; + ScriptPosition = pos; } public: virtual ~FxExpression() {} From 711ac7791594eca2b0d4699ce5567ebdc8beb487 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 8 Feb 2015 20:51:14 -0600 Subject: [PATCH 19/50] defitem != NULL -> defitem == NULL --- src/p_user.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.cpp b/src/p_user.cpp index e91766cf0..4d05d2660 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1012,7 +1012,7 @@ void APlayerPawn::FilterCoopRespawnInventory (APlayerPawn *oldplayer) else if ((dmflags & DF_COOP_LOSE_ARMOR) && item->IsKindOf(RUNTIME_CLASS(AArmor))) { - if (defitem != NULL) + if (defitem == NULL) { item->Destroy(); } From c3227729e7fbc6e653cd91498ffeb6322fbe4861 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 8 Feb 2015 20:54:13 -0600 Subject: [PATCH 20/50] Remove superfluous if in DoGiveInv() - I'm assuming this check was here for a reason, but when both branches of the if do the same thing and it's been this way since before recorded history, it's not obvious what was intended here. --- src/p_acs.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 8c6631b5e..b5233bb70 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1066,14 +1066,7 @@ static void DoGiveInv (AActor *actor, const PClass *info, int amount) item->ClearCounters(); if (info->IsDescendantOf (RUNTIME_CLASS(ABasicArmorPickup))) { - if (static_cast(item)->SaveAmount != 0) - { - static_cast(item)->SaveAmount *= amount; - } - else - { - static_cast(item)->SaveAmount *= amount; - } + static_cast(item)->SaveAmount *= amount; } else if (info->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus))) { From a063b48d7a18d6c77d35faa1c9f568e55a6bb81b Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 8 Feb 2015 20:56:30 -0600 Subject: [PATCH 21/50] Add a needed break in FxAbs::Resolve() - Fixed: FxAbs could not resolve floating point constants because it fell through to the error case. --- src/thingdef/thingdef_expression.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 08b261bbf..85bc224b2 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -1576,6 +1576,7 @@ FxExpression *FxAbs::Resolve(FCompileContext &ctx) case VAL_Float: value.Float = fabs(value.Float); + break; default: // shouldn't happen From 79791629eca67e386b3e49258c1bfd1a91b526f5 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 8 Feb 2015 21:01:49 -0600 Subject: [PATCH 22/50] Add missing break to FxGlobalVariable::Resolve() - Not like it matters much when there are no global variables of types float, fixed, or angle. --- src/thingdef/thingdef_expression.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 85bc224b2..0011f4d95 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -2053,6 +2053,7 @@ FxExpression *FxGlobalVariable::Resolve(FCompileContext&) case VAL_Fixed: case VAL_Angle: ValueType = VAL_Float; + break; case VAL_Object: case VAL_Class: From 867bfd27513960a23130ce3e6da7d459e5b58208 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 8 Feb 2015 21:07:28 -0600 Subject: [PATCH 23/50] Typo fix: concidered -> considered --- src/p_acs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index b5233bb70..ecaecd2c9 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -217,7 +217,7 @@ FWorldGlobalArray ACS_GlobalArrays[NUM_GLOBALVARS]; // // When the string table needs to grow to hold more strings, a garbage // collection is first attempted to see if more room can be made to store -// strings without growing. A string is concidered in use if any value +// strings without growing. A string is considered in use if any value // in any of these variable blocks contains a valid ID in the global string // table: // * The active area of the ACS stack @@ -226,7 +226,7 @@ FWorldGlobalArray ACS_GlobalArrays[NUM_GLOBALVARS]; // * All world variables // * All global variables // It's not important whether or not they are really used as strings, only -// that they might be. A string is also concidered in use if its lock count +// that they might be. A string is also considered in use if its lock count // is non-zero, even if none of the above variable blocks referenced it. // // To keep track of local and map variables for nonresident maps in a hub, From 6423b2fece0e76b7a97c2613430684e0586f0dc9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 9 Feb 2015 10:15:11 +0100 Subject: [PATCH 24/50] - fixed: Dehacked text patching needs to alter all occurences of the source string. --- src/d_dehacked.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 8debb69a4..4a436c0a8 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -2190,24 +2190,25 @@ static int PatchText (int oldSize) } } - if (!good) - { - // Search through most other texts - const char *str; - str = EnglishStrings->MatchString (oldStr); + // Search through most other texts + const char *str; + do + { + str = EnglishStrings->MatchString(oldStr); if (str != NULL) { - GStrings.SetString (str, newStr); + GStrings.SetString(str, newStr); + EnglishStrings->SetString(str, "~~"); // set to something invalid so that it won't get found again by the next iteration or by another replacement later good = true; } + } + while (str != NULL); // repeat search until the text can no longer be found - if (!good) - { - DPrintf (" (Unmatched)\n"); - } + if (!good) + { + DPrintf (" (Unmatched)\n"); } - donewithtext: if (newStr) delete[] newStr; From 3d7934f1a10957a21b0d3d859c0280446e17fe0a Mon Sep 17 00:00:00 2001 From: ChillyDoom Date: Mon, 9 Feb 2015 20:16:57 +0000 Subject: [PATCH 25/50] - Fixed: Part of Net_CheckLastReceived treated Net_Arbitrator as a node number rather than a player number. --- src/d_net.cpp | 16 ++++++++-------- src/d_net.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 4483f3cf9..9ab4b6179 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -107,7 +107,7 @@ int resendcount[MAXNETNODES]; unsigned int lastrecvtime[MAXPLAYERS]; // [RH] Used for pings unsigned int currrecvtime[MAXPLAYERS]; -unsigned int lastglobalrecvtime; // Identify the last time a packet was recieved. +unsigned int lastglobalrecvtime; // Identify the last time a packet was received. bool hadlate; int netdelay[MAXNETNODES][BACKUPTICS]; // Used for storing network delay times. int lastaverage; @@ -1861,7 +1861,7 @@ void TryRunTics (void) if (counts == 0 && !doWait) { // Check possible stall conditions - Net_CheckLastRecieved(counts); + Net_CheckLastReceived(counts); if (realtics >= 1) { C_Ticker(); @@ -1897,7 +1897,7 @@ void TryRunTics (void) I_Error ("TryRunTics: lowtic < gametic"); // Check possible stall conditions - Net_CheckLastRecieved (counts); + Net_CheckLastReceived (counts); // don't stay in here forever -- give the menu a chance to work if (I_GetTime (false) - entertic >= 1) @@ -1945,9 +1945,9 @@ void TryRunTics (void) } } -void Net_CheckLastRecieved (int counts) +void Net_CheckLastReceived (int counts) { - // [Ed850] Check to see the last time a packet was recieved. + // [Ed850] Check to see the last time a packet was received. // If it's longer then 3 seconds, a node has likely stalled. if (I_GetTime(false) - lastglobalrecvtime >= TICRATE * 3) { @@ -1974,11 +1974,11 @@ void Net_CheckLastRecieved (int counts) } else { //Send a resend request to the Arbitrator, as it's obvious we are stuck here. - if (debugfile && !players[playerfornode[Net_Arbitrator]].waiting) + if (debugfile && !players[Net_Arbitrator].waiting) fprintf(debugfile, "Arbitrator is slow (%i to %i)\n", - nettics[Net_Arbitrator], gametic + counts); + nettics[nodeforplayer[Net_Arbitrator]], gametic + counts); //Send resend request to the Arbitrator. Also mark the Arbitrator as waiting to display it in the hud. - remoteresend[Net_Arbitrator] = players[playerfornode[Net_Arbitrator]].waiting = hadlate = true; + remoteresend[nodeforplayer[Net_Arbitrator]] = players[Net_Arbitrator].waiting = hadlate = true; } } } diff --git a/src/d_net.h b/src/d_net.h index 07921a301..f9c4f6106 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -115,7 +115,7 @@ void D_QuitNetGame (void); void TryRunTics (void); //Use for checking to see if the netgame has stalled -void Net_CheckLastRecieved(int); +void Net_CheckLastReceived(int); // [RH] Functions for making and using special "ticcmds" void Net_NewMakeTic (); From a3bdbff0527a6a79b514e9c2361181dcc4f05a86 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Feb 2015 21:30:52 +0100 Subject: [PATCH 26/50] - fixed: 3Dmidtex opening checks didn't take per-sidedef scaling into account. --- src/p_3dmidtex.cpp | 7 ++++--- src/textures/textures.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index ac6d7aca7..7f934e2f5 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -223,11 +223,12 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, f FTexture * tex= TexMan(texnum); if (!tex) return false; + fixed_t totalscale = FixedMul(side->GetTextureYScale(side_t::mid), tex->yScale); fixed_t y_offset = side->GetTextureYOffset(side_t::mid); - fixed_t textureheight = tex->GetScaledHeight() << FRACBITS; - if (tex->yScale != FRACUNIT && !tex->bWorldPanning) + fixed_t textureheight = tex->GetScaledHeight(totalscale) << FRACBITS; + if (totalscale != FRACUNIT && !tex->bWorldPanning) { - y_offset = FixedDiv(y_offset, tex->yScale); + y_offset = FixedDiv(y_offset, totalscale); } if(line->flags & ML_DONTPEGBOTTOM) diff --git a/src/textures/textures.h b/src/textures/textures.h index 9dbd85a55..cf3982fb3 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -233,6 +233,7 @@ public: int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); } int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); } + int GetScaledHeight(fixed_t scale) { int foo = (Height << 17) / scale; return (foo >> 1) + (foo & 1); } double GetScaledWidthDouble () { return (Width * 65536.) / xScale; } double GetScaledHeightDouble () { return (Height * 65536.) / yScale; } From 5fc6ff1303c144c1199eb622f157160672723a12 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Feb 2015 23:01:58 +0100 Subject: [PATCH 27/50] - fixed: invisible 3D floors were treated as solid, not translucent when building the sorted lists, resulting in the top plane not being rendered in case of an overlap. --- src/p_3dfloors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index fc35409dc..58c2dbde7 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -488,7 +488,7 @@ void P_Recalculate3DFloors(sector_t * sector) // by the clipping code below. ffloors.Push(pick); } - else if (pick->flags&(FF_SWIMMABLE|FF_TRANSLUCENT) && pick->flags&FF_EXISTS) + else if ((pick->flags&(FF_SWIMMABLE|FF_TRANSLUCENT) || (!(pick->flags&(FF_ALLSIDES|FF_BOTHPLANES)))) && pick->flags&FF_EXISTS) { // We must check if this nonsolid segment gets clipped from the top by another 3D floor if (solid != NULL && solid_bottom < height) From c0eb39ec728dbae4b495f26e87777c6d30af8596 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Feb 2015 23:09:57 +0100 Subject: [PATCH 28/50] - fixed: The exploding ArtiTimeBomb must disable movement interpolation for its position change needed to display the explosion frames correctly. --- src/g_heretic/a_hereticartifacts.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_heretic/a_hereticartifacts.cpp b/src/g_heretic/a_hereticartifacts.cpp index 1c9df572c..651e3609c 100644 --- a/src/g_heretic/a_hereticartifacts.cpp +++ b/src/g_heretic/a_hereticartifacts.cpp @@ -48,6 +48,7 @@ bool AArtiTomeOfPower::Use (bool pickup) DEFINE_ACTION_FUNCTION(AActor, A_TimeBomb) { self->z += 32*FRACUNIT; + self->PrevZ = self->z; // no interpolation! self->RenderStyle = STYLE_Add; self->alpha = FRACUNIT; P_RadiusAttack (self, self->target, 128, 128, self->DamageType, RADF_HURTSOURCE); From 337682934cb1017b26059abdd53ba6f132626fdd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 10 Feb 2015 23:40:53 +0100 Subject: [PATCH 29/50] - fixed: CF_FLY cannot be part of the player_t structure and be tracked properly. It needs to be part of the actor itself that has MF2_FLY set so it got moved to flags7. - removed some fudging code that tried to work around the shortcomings of CF_FLY but was ultimately causing more problems than it solved. --- src/actor.h | 1 + src/g_level.cpp | 9 --------- src/g_shared/a_artifacts.cpp | 3 ++- src/m_cheat.cpp | 3 +-- src/p_lnspec.cpp | 4 +++- src/p_mobj.cpp | 2 +- 6 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/actor.h b/src/actor.h index 0ab589107..b7a8614a7 100644 --- a/src/actor.h +++ b/src/actor.h @@ -353,6 +353,7 @@ enum MF7_HITTARGET = 0x00004000, // The actor the projectile dies on is set to target, provided it's targetable anyway. MF7_HITMASTER = 0x00008000, // Same as HITTARGET, except it's master instead of target. MF7_HITTRACER = 0x00010000, // Same as HITTARGET, but for tracer. + MF7_FLYCHEAT = 0x00020000, // must be part of the actor so that it can be tracked properly diff --git a/src/g_level.cpp b/src/g_level.cpp index b6cc1cd84..2d44bfc27 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1235,15 +1235,6 @@ void G_FinishTravel () pawn->AddToHash (); pawn->SetState(pawn->SpawnState); pawn->player->SendPitchLimits(); - // Sync the FLY flags. - if (pawn->flags2 & MF2_FLY) - { - pawn->player->cheats |= CF_FLY; - } - else - { - pawn->player->cheats &= ~CF_FLY; - } for (inv = pawn->Inventory; inv != NULL; inv = inv->Inventory) { diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 21006776e..14b270435 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -997,7 +997,8 @@ void APowerFlight::EndEffect () { return; } - if (!(Owner->player->cheats & CF_FLY)) + + if (!(Owner->flags7 & MF7_FLYCHEAT)) { if (Owner->z != Owner->floorz) { diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index e48b79980..f60131c8e 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -149,8 +149,7 @@ void cht_DoCheat (player_t *player, int cheat) case CHT_FLY: if (player->mo != NULL) { - player->cheats ^= CF_FLY; - if (player->cheats & CF_FLY) + if ((player->mo->flags7 ^= MF7_FLYCHEAT) != 0) { player->mo->flags |= MF_NOGRAVITY; player->mo->flags2 |= MF2_FLY; diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index c170cacd3..b550eeb77 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -2800,7 +2800,7 @@ FUNC(LS_SetPlayerProperty) mask = CF_INSTANTWEAPSWITCH; break; case PROP_FLY: - mask = CF_FLY; + //mask = CF_FLY; break; case PROP_TOTALLYFROZEN: mask = CF_TOTALLYFROZEN; @@ -2814,6 +2814,7 @@ FUNC(LS_SetPlayerProperty) it->player->cheats |= mask; if (arg2 == PROP_FLY) { + it->flags7 |= MF7_FLYCHEAT; it->flags2 |= MF2_FLY; it->flags |= MF_NOGRAVITY; } @@ -2823,6 +2824,7 @@ FUNC(LS_SetPlayerProperty) it->player->cheats &= ~mask; if (arg2 == PROP_FLY) { + it->flags7 &= ~MF7_FLYCHEAT; it->flags2 &= ~MF2_FLY; it->flags &= ~MF_NOGRAVITY; } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index ce9fe722a..b27c79d91 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4477,7 +4477,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) p->mo->ResetAirSupply(false); p->Uncrouch(); p->MinPitch = p->MaxPitch = 0; // will be filled in by PostBeginPlay()/netcode - p->cheats &= ~CF_FLY; + p->velx = p->vely = 0; // killough 10/98: initialize bobbing to 0. From 7db035abba4909703a89fa3082d7cd16e94ad0fe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Feb 2015 16:27:28 +0100 Subject: [PATCH 30/50] - undid NOGRAVITY for all floatbobbing items. I have no idea why this was ever deemed proper - but it clearly breaks some Hexen maps and it not even remotely mimics the original behavior. Even now, it's not the same but since the items fall down they at least end up where they are supposed to be. --- wadsrc/static/actors/heretic/hereticammo.txt | 1 - wadsrc/static/actors/heretic/hereticarmor.txt | 2 -- wadsrc/static/actors/heretic/hereticartifacts.txt | 4 ---- wadsrc/static/actors/hexen/blastradius.txt | 1 - wadsrc/static/actors/hexen/boostarmor.txt | 1 - wadsrc/static/actors/hexen/clericholy.txt | 1 - wadsrc/static/actors/hexen/fighterquietus.txt | 1 - wadsrc/static/actors/hexen/flechette.txt | 1 - wadsrc/static/actors/hexen/healingradius.txt | 1 - wadsrc/static/actors/hexen/magestaff.txt | 1 - wadsrc/static/actors/hexen/mana.txt | 3 --- wadsrc/static/actors/hexen/speedboots.txt | 1 - wadsrc/static/actors/hexen/summon.txt | 1 - wadsrc/static/actors/hexen/teleportother.txt | 1 - wadsrc/static/actors/raven/artiegg.txt | 2 -- wadsrc/static/actors/raven/artitele.txt | 1 - wadsrc/static/actors/raven/ravenartifacts.txt | 6 ------ wadsrc/static/actors/raven/ravenhealth.txt | 1 - 18 files changed, 30 deletions(-) diff --git a/wadsrc/static/actors/heretic/hereticammo.txt b/wadsrc/static/actors/heretic/hereticammo.txt index 8f02cce0a..96a20352b 100644 --- a/wadsrc/static/actors/heretic/hereticammo.txt +++ b/wadsrc/static/actors/heretic/hereticammo.txt @@ -221,7 +221,6 @@ ACTOR BagOfHolding : BackpackItem 8 Inventory.PickupMessage "$TXT_ITEMBAGOFHOLDING" +COUNTITEM +FLOATBOB - +NOGRAVITY States { Spawn: diff --git a/wadsrc/static/actors/heretic/hereticarmor.txt b/wadsrc/static/actors/heretic/hereticarmor.txt index 40ca671da..e027f4f47 100644 --- a/wadsrc/static/actors/heretic/hereticarmor.txt +++ b/wadsrc/static/actors/heretic/hereticarmor.txt @@ -6,7 +6,6 @@ Actor SilverShield : BasicArmorPickup 85 Game Heretic SpawnID 68 +FLOATBOB - +NOGRAVITY Inventory.Pickupmessage "$TXT_ITEMSHIELD1" Inventory.Icon "SHLDA0" Armor.Savepercent 50 @@ -26,7 +25,6 @@ Actor EnchantedShield : BasicArmorPickup 31 Game Heretic SpawnID 69 +FLOATBOB - +NOGRAVITY Inventory.Pickupmessage "$TXT_ITEMSHIELD2" Inventory.Icon "SHD2A0" Armor.Savepercent 75 diff --git a/wadsrc/static/actors/heretic/hereticartifacts.txt b/wadsrc/static/actors/heretic/hereticartifacts.txt index 404e5ba39..67d3946b9 100644 --- a/wadsrc/static/actors/heretic/hereticartifacts.txt +++ b/wadsrc/static/actors/heretic/hereticartifacts.txt @@ -7,7 +7,6 @@ ACTOR SuperMap : MapRevealer 35 +COUNTITEM +INVENTORY.ALWAYSPICKUP +FLOATBOB - +NOGRAVITY Inventory.MaxAmount 0 Inventory.PickupMessage "$TXT_ITEMSUPERMAP" States @@ -27,7 +26,6 @@ ACTOR ArtiInvisibility : PowerupGiver 75 SpawnID 135 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH RenderStyle Translucent Alpha 0.4 @@ -53,7 +51,6 @@ ACTOR ArtiTomeOfPower : PowerupGiver 86 native SpawnID 134 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH Inventory.Icon "ARTIPWBK" Powerup.Type Weaponlevel2 @@ -97,7 +94,6 @@ ACTOR ArtiTimeBomb : Inventory 34 native SpawnID 72 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH +INVENTORY.INVBAR +INVENTORY.FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/hexen/blastradius.txt b/wadsrc/static/actors/hexen/blastradius.txt index 28af3e698..ad98d7ecc 100644 --- a/wadsrc/static/actors/hexen/blastradius.txt +++ b/wadsrc/static/actors/hexen/blastradius.txt @@ -4,7 +4,6 @@ ACTOR ArtiBlastRadius : CustomInventory 10110 Game Hexen SpawnID 74 +FLOATBOB - +NOGRAVITY Inventory.DefMaxAmount Inventory.PickupFlash "PickupFlash" +INVBAR +FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/hexen/boostarmor.txt b/wadsrc/static/actors/hexen/boostarmor.txt index 8aa6b6eeb..607c8d66a 100644 --- a/wadsrc/static/actors/hexen/boostarmor.txt +++ b/wadsrc/static/actors/hexen/boostarmor.txt @@ -7,7 +7,6 @@ ACTOR ArtiBoostArmor : Inventory 8041 native SpawnID 22 +COUNTITEM +FLOATBOB - +NOGRAVITY Inventory.DefMaxAmount Inventory.PickupFlash "PickupFlash" +INVBAR +FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/hexen/clericholy.txt b/wadsrc/static/actors/hexen/clericholy.txt index cebc44610..e97be8b17 100644 --- a/wadsrc/static/actors/hexen/clericholy.txt +++ b/wadsrc/static/actors/hexen/clericholy.txt @@ -8,7 +8,6 @@ ACTOR ClericWeaponPiece : WeaponPiece Inventory.ForbiddenTo FighterPlayer, MagePlayer WeaponPiece.Weapon CWeapWraithverge +FLOATBOB - +NOGRAVITY } // Cleric Weapon Piece 1 ---------------------------------------------------- diff --git a/wadsrc/static/actors/hexen/fighterquietus.txt b/wadsrc/static/actors/hexen/fighterquietus.txt index b5ecd22e4..a77e851d8 100644 --- a/wadsrc/static/actors/hexen/fighterquietus.txt +++ b/wadsrc/static/actors/hexen/fighterquietus.txt @@ -8,7 +8,6 @@ ACTOR FighterWeaponPiece : WeaponPiece Inventory.ForbiddenTo ClericPlayer, MagePlayer WeaponPiece.Weapon FWeapQuietus +FLOATBOB - +NOGRAVITY } // Fighter Weapon Piece 1 --------------------------------------------------- diff --git a/wadsrc/static/actors/hexen/flechette.txt b/wadsrc/static/actors/hexen/flechette.txt index 74c7a0a6a..6e12bff53 100644 --- a/wadsrc/static/actors/hexen/flechette.txt +++ b/wadsrc/static/actors/hexen/flechette.txt @@ -99,7 +99,6 @@ ACTOR ArtiPoisonBag : Inventory 8000 native Game Hexen SpawnID 72 +FLOATBOB - +NOGRAVITY Inventory.DefMaxAmount Inventory.PickupFlash "PickupFlash" +INVBAR +FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/hexen/healingradius.txt b/wadsrc/static/actors/hexen/healingradius.txt index 97efc0449..e0556915b 100644 --- a/wadsrc/static/actors/hexen/healingradius.txt +++ b/wadsrc/static/actors/hexen/healingradius.txt @@ -6,7 +6,6 @@ ACTOR ArtiHealingRadius : Inventory 10120 native Game Hexen +COUNTITEM +FLOATBOB - +NOGRAVITY Inventory.DefMaxAmount +INVENTORY.INVBAR +INVENTORY.PICKUPFLASH diff --git a/wadsrc/static/actors/hexen/magestaff.txt b/wadsrc/static/actors/hexen/magestaff.txt index a8584aae7..aa75ed446 100644 --- a/wadsrc/static/actors/hexen/magestaff.txt +++ b/wadsrc/static/actors/hexen/magestaff.txt @@ -8,7 +8,6 @@ ACTOR MageWeaponPiece : WeaponPiece Inventory.ForbiddenTo FighterPlayer, ClericPlayer WeaponPiece.Weapon MWeapBloodscourge +FLOATBOB - +NOGRAVITY } // Mage Weapon Piece 1 ------------------------------------------------------ diff --git a/wadsrc/static/actors/hexen/mana.txt b/wadsrc/static/actors/hexen/mana.txt index 97bc419c8..a2e6ee4bc 100644 --- a/wadsrc/static/actors/hexen/mana.txt +++ b/wadsrc/static/actors/hexen/mana.txt @@ -11,7 +11,6 @@ ACTOR Mana1 : Ammo 122 Radius 8 Height 8 +FLOATBOB - +NOGRAVITY Inventory.Icon "MAN1I0" Inventory.PickupMessage "$TXT_MANA_1" States @@ -35,7 +34,6 @@ ACTOR Mana2 : Ammo 124 Radius 8 Height 8 +FLOATBOB - +NOGRAVITY Inventory.Icon "MAN2G0" Inventory.PickupMessage "$TXT_MANA_2" States @@ -55,7 +53,6 @@ ACTOR Mana3 : CustomInventory 8004 Radius 8 Height 8 +FLOATBOB - +NOGRAVITY Inventory.PickupMessage "$TXT_MANA_BOTH" States { diff --git a/wadsrc/static/actors/hexen/speedboots.txt b/wadsrc/static/actors/hexen/speedboots.txt index c22699b62..5fd6703b8 100644 --- a/wadsrc/static/actors/hexen/speedboots.txt +++ b/wadsrc/static/actors/hexen/speedboots.txt @@ -5,7 +5,6 @@ ACTOR ArtiSpeedBoots : PowerupGiver 8002 Game Hexen SpawnID 13 +FLOATBOB - +NOGRAVITY +COUNTITEM +INVENTORY.PICKUPFLASH Inventory.Icon ARTISPED diff --git a/wadsrc/static/actors/hexen/summon.txt b/wadsrc/static/actors/hexen/summon.txt index 28c3c3267..a4b3b8584 100644 --- a/wadsrc/static/actors/hexen/summon.txt +++ b/wadsrc/static/actors/hexen/summon.txt @@ -7,7 +7,6 @@ ACTOR ArtiDarkServant : Inventory 86 native SpawnID 16 +COUNTITEM +FLOATBOB - +NOGRAVITY Inventory.RespawnTics 4230 Inventory.DefMaxAmount Inventory.PickupFlash "PickupFlash" diff --git a/wadsrc/static/actors/hexen/teleportother.txt b/wadsrc/static/actors/hexen/teleportother.txt index 49b20a0bd..77a05f6af 100644 --- a/wadsrc/static/actors/hexen/teleportother.txt +++ b/wadsrc/static/actors/hexen/teleportother.txt @@ -7,7 +7,6 @@ ACTOR ArtiTeleportOther : Inventory 10040 native SpawnID 17 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.INVBAR +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/raven/artiegg.txt b/wadsrc/static/actors/raven/artiegg.txt index 2a9c6867e..d94f00151 100644 --- a/wadsrc/static/actors/raven/artiegg.txt +++ b/wadsrc/static/actors/raven/artiegg.txt @@ -31,7 +31,6 @@ ACTOR ArtiEgg : CustomInventory 30 SpawnID 14 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.INVBAR +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND @@ -86,7 +85,6 @@ ACTOR ArtiPork : CustomInventory 30 SpawnID 14 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.INVBAR +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/raven/artitele.txt b/wadsrc/static/actors/raven/artitele.txt index b0eedf1cd..79811fd53 100644 --- a/wadsrc/static/actors/raven/artitele.txt +++ b/wadsrc/static/actors/raven/artitele.txt @@ -7,7 +7,6 @@ ACTOR ArtiTeleport : Inventory 36 native SpawnID 18 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.INVBAR +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND diff --git a/wadsrc/static/actors/raven/ravenartifacts.txt b/wadsrc/static/actors/raven/ravenartifacts.txt index 4f31ad5fb..c02c19c3b 100644 --- a/wadsrc/static/actors/raven/ravenartifacts.txt +++ b/wadsrc/static/actors/raven/ravenartifacts.txt @@ -8,7 +8,6 @@ ACTOR ArtiHealth : HealthPickup 82 Health 25 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND Inventory.Icon ARTIPTN2 @@ -33,7 +32,6 @@ ACTOR ArtiSuperHealth : HealthPickup 32 Health 100 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH +INVENTORY.FANCYPICKUPSOUND Inventory.Icon ARTISPHL @@ -57,7 +55,6 @@ ACTOR ArtiFly : PowerupGiver 83 SpawnID 15 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH +INVENTORY.INTERHUBSTRIP Inventory.RespawnTics 4230 @@ -81,7 +78,6 @@ ACTOR ArtiInvulnerability : PowerupGiver 84 SpawnID 133 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH Inventory.RespawnTics 4230 Inventory.Icon ARTIINVU @@ -105,7 +101,6 @@ ACTOR ArtiInvulnerability2 : PowerupGiver 84 SpawnID 133 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH Inventory.RespawnTics 4230 Inventory.Icon ARTIDEFN @@ -128,7 +123,6 @@ ACTOR ArtiTorch : PowerupGiver 33 SpawnID 73 +COUNTITEM +FLOATBOB - +NOGRAVITY +INVENTORY.PICKUPFLASH Inventory.Icon ARTITRCH Inventory.PickupMessage "$TXT_ARTITORCH" diff --git a/wadsrc/static/actors/raven/ravenhealth.txt b/wadsrc/static/actors/raven/ravenhealth.txt index 45cbe59b9..af951be1b 100644 --- a/wadsrc/static/actors/raven/ravenhealth.txt +++ b/wadsrc/static/actors/raven/ravenhealth.txt @@ -3,7 +3,6 @@ ACTOR CrystalVial : Health 81 Game Raven SpawnID 23 +FLOATBOB - +NOGRAVITY Inventory.Amount 10 Inventory.PickupMessage "$TXT_ITEMHEALTH" States From c2e155bb9f044f81942820f0e9d055ea3e983452 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Feb 2015 16:29:08 +0100 Subject: [PATCH 31/50] - with floatbobbing items no longer having no gravity, we don't need the corresponding compatibility setting anymore. --- wadsrc/static/compatibility.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index d2bb85fd2..bd90342f2 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -198,14 +198,6 @@ E2B5D1400279335811C1C1C0B437D9C8 // Deathknights of the Dark Citadel, map54 clearlineflags 1069 0x200 } -CBDE77E3ACB4B166D53C1812E5C72F54 // Hexen IWAD map04 -{ - setthingz 49 0 - setthingz 50 0 - setthingz 51 0 - setthingz 52 0 -} - 3F249EDD62A3A08F53A6C53CB4C7ABE5 // Artica 3 map01 { clearlinespecial 66 From 93c12cf2595ac473061f83486139907d7c2c7bb0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 12 Feb 2015 18:57:06 +0100 Subject: [PATCH 32/50] - addressed the problem that prompted setting NOGRAVITY for all floatbobbing items for real: Hexen uses the spawn height value from the mapthing_t structure to offset the item when floatbobbing. With proper gravity handling enabled this method doesn't really work so as a workaround ZDoom will now enable a hidden compatibility option when playing any map with a Hexen format MAPINFO so that any positive value in this field will make P_ZMovement revert to the original method of setting the items height (excluding the floatbob offset, of course.) This also removes some code from P_NightmareRespawn that originate from the original Hexen method for floatbobbing which aren't needed anymore --- src/compatibility.cpp | 6 ++++++ src/doomdef.h | 1 + src/p_mobj.cpp | 24 +++++++++++++++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/compatibility.cpp b/src/compatibility.cpp index 4ddc670e9..da4ab4945 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -109,6 +109,7 @@ static FCompatOption Options[] = { "rebuildnodes", BCOMPATF_REBUILDNODES, SLOT_BCOMPAT }, { "linkfrozenprops", BCOMPATF_LINKFROZENPROPS, SLOT_BCOMPAT }, { "disablepushwindowcheck", BCOMPATF_NOWINDOWCHECK, SLOT_BCOMPAT }, + { "floatbob", BCOMPATF_FLOATBOB, SLOT_BCOMPAT }, // list copied from g_mapinfo.cpp { "shorttex", COMPATF_SHORTTEX, SLOT_COMPAT }, @@ -434,6 +435,11 @@ void CheckCompatibility(MapData *map) // Reset i_compatflags compatflags.Callback(); compatflags2.Callback(); + // Set floatbob compatibility for all maps with an original Hexen MAPINFO. + if (level.flags2 & LEVEL2_HEXENHACK) + { + ib_compatflags |= BCOMPATF_FLOATBOB; + } } //========================================================================== diff --git a/src/doomdef.h b/src/doomdef.h index 767f97661..c8aa66c17 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -354,6 +354,7 @@ enum BCOMPATF_REBUILDNODES = 1 << 5, // Force node rebuild BCOMPATF_LINKFROZENPROPS = 1 << 6, // Clearing PROP_TOTALLYFROZEN or PROP_FROZEN also clears the other BCOMPATF_NOWINDOWCHECK = 1 << 7, // Disable the window check in CheckForPushSpecial() + BCOMPATF_FLOATBOB = 1 << 8, // Use Hexen's original method of preventing floatbobbing items from falling down }; // phares 3/20/98: diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b27c79d91..2235c7820 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2314,6 +2314,16 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) } } + // Hexen compatibility handling for floatbobbing. Ugh... + // Hexen yanked all items to the floor, except those being spawned at map start in the air. + // Those were kept at their original height. + // Do this only if the item was actually spawned by the map above ground to avoid problems. + if (mo->special1 > 0 && (mo->flags2 & MF2_FLOATBOB) && (ib_compatflags & BCOMPATF_FLOATBOB)) + { + mo->z = mo->floorz + mo->special1; + } + + // // adjust height // @@ -2616,8 +2626,6 @@ void P_NightmareRespawn (AActor *mobj) z = ONCEILINGZ; else if (info->flags2 & MF2_SPAWNFLOAT) z = FLOATRANDZ; - else if (info->flags2 & MF2_FLOATBOB) - z = mobj->SpawnPoint[2]; else z = ONFLOORZ; @@ -4869,7 +4877,13 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) mobj = AActor::StaticSpawn (i, x, y, z, NO_REPLACE, true); if (z == ONFLOORZ) + { mobj->z += mthing->z; + if ((mobj->flags2 & MF2_FLOATBOB) && (ib_compatflags & BCOMPATF_FLOATBOB)) + { + mobj->special1 = mthing->z; + } + } else if (z == ONCEILINGZ) mobj->z -= mthing->z; @@ -4882,7 +4896,11 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) else if (mthing->gravity > 0) mobj->gravity = FixedMul(mobj->gravity, mthing->gravity); else mobj->flags &= ~MF_NOGRAVITY; - P_FindFloorCeiling(mobj, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); + // For Hexen floatbob 'compatibility' we do not really want to alter the floorz. + if (mobj->special1 == 0 || !(mobj->flags2 & MF2_FLOATBOB) || !(ib_compatflags & BCOMPATF_FLOATBOB)) + { + P_FindFloorCeiling(mobj, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); + } if (!(mobj->flags2 & MF2_ARGSDEFINED)) { From fa2e2a852891e2f8743582414e6027153bbcc2ed Mon Sep 17 00:00:00 2001 From: Alexey Khokholov Date: Sat, 14 Feb 2015 00:01:54 +0900 Subject: [PATCH 33/50] Update nukedopl3.cpp --- src/oplsynth/nukedopl3.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/oplsynth/nukedopl3.cpp b/src/oplsynth/nukedopl3.cpp index a520f68e1..4d143f4a5 100644 --- a/src/oplsynth/nukedopl3.cpp +++ b/src/oplsynth/nukedopl3.cpp @@ -98,8 +98,7 @@ Bit16s envelope_calcsin0(Bit16u phase, Bit16u envelope) { phase &= 0x3ff; Bit16u out = 0; Bit16u neg = 0; - if (phase & 0x200 && (phase & 0x1ff)) { - phase--; + if (phase & 0x200) { neg = ~0; } if (phase & 0x100) { @@ -154,8 +153,7 @@ Bit16s envelope_calcsin4(Bit16u phase, Bit16u envelope) { phase &= 0x3ff; Bit16u out = 0; Bit16u neg = 0; - if ((phase & 0x300) == 0x100 && (phase & 0xff)) { - phase--; + if ((phase & 0x300) == 0x100) { neg = ~0; } if (phase & 0x200) { @@ -188,8 +186,7 @@ Bit16s envelope_calcsin5(Bit16u phase, Bit16u envelope) { Bit16s envelope_calcsin6(Bit16u phase, Bit16u envelope) { phase &= 0x3ff; Bit16u neg = 0; - if (phase & 0x200 && (phase & 0x1ff)) { - phase--; + if (phase & 0x200) { neg = ~0; } return envelope_calcexp(envelope << 3) ^ neg; @@ -199,8 +196,7 @@ Bit16s envelope_calcsin7(Bit16u phase, Bit16u envelope) { phase &= 0x3ff; Bit16u out = 0; Bit16u neg = 0; - if (phase & 0x200 && (phase & 0x1ff)) { - phase--; + if (phase & 0x200) { neg = ~0; phase = (phase & 0x1ff) ^ 0x1ff; } @@ -976,4 +972,4 @@ NukedOPL3::NukedOPL3(bool stereo) { OPLEmul *NukedOPL3Create(bool stereo) { return new NukedOPL3(stereo); -} \ No newline at end of file +} From 7050d03222a239cf70ead2dad6d93180e1d278f7 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sat, 14 Feb 2015 15:58:39 -0600 Subject: [PATCH 34/50] Added A_QuakeEx(intensity x, y, z, duration, damrad, tremrad, sound, flags) - Unlocks the full potential of using quakes, including the Z axis. Each intensity applies to X/Y/Z planes whenever a player is experiencing it. - Flags: - QF_RELATIVE - Adjusts the quaking of the camera to go in the direction its aiming (X: forward/backward. Y: Left/right.) - Plans for including pitch will be implemented in the future for the Z axis with relativity. --- src/g_shared/a_quake.cpp | 86 +++++++++++++++++++++++++----- src/g_shared/a_sharedglobal.h | 14 +++-- src/p_spec.h | 3 +- src/r_utility.cpp | 32 +++++++++-- src/thingdef/thingdef_codeptr.cpp | 22 ++++++++ wadsrc/static/actors/actor.txt | 1 + wadsrc/static/actors/constants.txt | 5 ++ 7 files changed, 143 insertions(+), 20 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index c3a227b36..462deafb6 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -33,8 +33,8 @@ DEarthquake::DEarthquake() // //========================================================================== -DEarthquake::DEarthquake (AActor *center, int intensity, int duration, - int damrad, int tremrad, FSoundID quakesound) +DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int intensityZ, int duration, + int damrad, int tremrad, FSoundID quakesound, int flags) : DThinker(STAT_EARTHQUAKE) { m_QuakeSFX = quakesound; @@ -42,8 +42,12 @@ DEarthquake::DEarthquake (AActor *center, int intensity, int duration, // Radii are specified in tile units (64 pixels) m_DamageRadius = damrad << (FRACBITS); m_TremorRadius = tremrad << (FRACBITS); - m_Intensity = intensity; + m_Intensity = intensityX; m_Countdown = duration; + m_Flags = flags; + m_iX = intensityX; + m_iY = intensityY; + m_iZ = intensityZ; } //========================================================================== @@ -54,10 +58,10 @@ DEarthquake::DEarthquake (AActor *center, int intensity, int duration, void DEarthquake::Serialize (FArchive &arc) { - Super::Serialize (arc); + Super::Serialize (arc); //[MC] m_Intensity is unused now but I don't want to break compatibility... arc << m_Spot << m_Intensity << m_Countdown << m_TremorRadius << m_DamageRadius - << m_QuakeSFX; + << m_QuakeSFX << m_Flags << m_iX << m_iY << m_iZ; } //========================================================================== @@ -126,9 +130,10 @@ void DEarthquake::Tick () // //========================================================================== -int DEarthquake::StaticGetQuakeIntensity (AActor *victim) +int DEarthquake::StaticGetQuakeIntensity (AActor *victim, int selector) { int intensity = 0; + int quakeIntensity = 0; TThinkerIterator iterator (STAT_EARTHQUAKE); DEarthquake *quake; @@ -145,32 +150,84 @@ int DEarthquake::StaticGetQuakeIntensity (AActor *victim) victim->y - quake->m_Spot->y); if (dist < quake->m_TremorRadius) { - if (intensity < quake->m_Intensity) - intensity = quake->m_Intensity; + switch (selector) + { + default: + case 0: + quakeIntensity = quake->m_iX; + break; + case 1: + quakeIntensity = quake->m_iY; + break; + case 2: + quakeIntensity = quake->m_iZ; + break; + + } + + if (intensity < quakeIntensity) + intensity = quakeIntensity; } } } return intensity; } +//========================================================================== +// +// DEarthquake::StaticGetQuakeIntensity +// +// Searches for all quakes near the victim and returns their combined +// intensity. +// +//========================================================================== + +int DEarthquake::StaticGetQuakeFlags(AActor *victim) +{ + int flags = 0; + TThinkerIterator iterator(STAT_EARTHQUAKE); + DEarthquake *quake; + + if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) + { + return 0; + } + + while ((quake = iterator.Next()) != NULL) + { + if (quake->m_Spot != NULL) + { + fixed_t dist = P_AproxDistance(victim->x - quake->m_Spot->x, + victim->y - quake->m_Spot->y); + if (dist < quake->m_TremorRadius) + { + if (!(flags & QF_RELATIVE) && (quake->m_Flags & QF_RELATIVE)) + flags += QF_RELATIVE; + } + } + } + return flags; +} //========================================================================== // // P_StartQuake // //========================================================================== -bool P_StartQuake (AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx) +bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags) { AActor *center; bool res = false; - intensity = clamp (intensity, 1, 9); + if (intensityX) intensityX = clamp(intensityX, 1, 9); + if (intensityY) intensityY = clamp(intensityY, 1, 9); + if (intensityZ) intensityZ = clamp(intensityZ, 1, 9); if (tid == 0) { if (activator != NULL) { - new DEarthquake(activator, intensity, duration, damrad, tremrad, quakesfx); + new DEarthquake(activator, intensityX, intensityY, intensityZ, duration, damrad, tremrad, quakesfx, flags); return true; } } @@ -180,9 +237,14 @@ bool P_StartQuake (AActor *activator, int tid, int intensity, int duration, int while ( (center = iterator.Next ()) ) { res = true; - new DEarthquake (center, intensity, duration, damrad, tremrad, quakesfx); + new DEarthquake(center, intensityX, intensityY, intensityZ, duration, damrad, tremrad, quakesfx, flags); } } return res; } + +bool P_StartQuake(AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx) +{ //Maintains original behavior by passing 0 to intensityZ, and flags. + return P_StartQuakeXYZ(activator, tid, intensity, intensity, 0, duration, damrad, tremrad, quakesfx, 0); +} diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index a898433f0..a186fa010 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -131,23 +131,31 @@ protected: DFlashFader (); }; +enum +{ + QF_RELATIVE = 1, +}; + class DEarthquake : public DThinker { DECLARE_CLASS (DEarthquake, DThinker) HAS_OBJECT_POINTERS public: - DEarthquake (AActor *center, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx); + DEarthquake(AActor *center, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags); void Serialize (FArchive &arc); void Tick (); - TObjPtr m_Spot; fixed_t m_TremorRadius, m_DamageRadius; int m_Intensity; int m_Countdown; FSoundID m_QuakeSFX; + int m_Flags; + int m_iX, m_iY, m_iZ; - static int StaticGetQuakeIntensity (AActor *viewer); + static int StaticGetQuakeFlags(AActor *viewer); + static int StaticGetQuakeIntensity (AActor *viewer, int selector); + private: DEarthquake (); diff --git a/src/p_spec.h b/src/p_spec.h index 0d7ef4cff..2edfe6390 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -929,6 +929,7 @@ void P_DoDeferedScripts (void); // // [RH] p_quake.c // -bool P_StartQuake (AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx); +bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags); +bool P_StartQuake(AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx); #endif diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 585e3dcf3..f809a6800 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -875,13 +875,37 @@ void R_SetupFrame (AActor *actor) if (!paused) { - int intensity = DEarthquake::StaticGetQuakeIntensity (camera); - if (intensity != 0) + int intensityX = DEarthquake::StaticGetQuakeIntensity(camera, 0); + int intensityY = DEarthquake::StaticGetQuakeIntensity(camera, 1); + int intensityZ = DEarthquake::StaticGetQuakeIntensity(camera, 2); + int quakeflags = DEarthquake::StaticGetQuakeFlags(camera); + if (intensityX || intensityY || intensityZ) { fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity); - viewx += quakefactor * ((pr_torchflicker() % (intensity<<2)) - (intensity<<1)); - viewy += quakefactor * ((pr_torchflicker() % (intensity<<2)) - (intensity<<1)); + if ((quakeflags & QF_RELATIVE) && (intensityX != intensityY)) + { + if (intensityX) + { + int ang = (camera->angle) >> ANGLETOFINESHIFT; + int tflicker = pr_torchflicker(); + viewx += FixedMul(finecosine[ang], (quakefactor * ((tflicker % (intensityX << 2)) - (intensityX << 1)))); + viewy += FixedMul(finesine[ang], (quakefactor * ((tflicker % (intensityX << 2)) - (intensityX << 1)))); + } + if (intensityY) + { + int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; + int tflicker = pr_torchflicker(); + viewx += FixedMul(finecosine[ang], (quakefactor * ((tflicker % (intensityY << 2)) - (intensityY << 1)))); + viewy += FixedMul(finesine[ang], (quakefactor * ((tflicker % (intensityY << 2)) - (intensityY << 1)))); + } + } + else + { + if (intensityX) viewx += quakefactor * ((pr_torchflicker() % (intensityX << 2)) - (intensityX << 1)); + if (intensityY) viewy += quakefactor * ((pr_torchflicker() % (intensityY << 2)) - (intensityY << 1)); + } + if (intensityZ) viewz += quakefactor * ((pr_torchflicker() % (intensityZ << 2)) - (intensityZ << 1)); } } diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index fc157c92b..280f09fd6 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -4403,6 +4403,28 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Quake) P_StartQuake(self, 0, intensity, duration, damrad, tremrad, sound); } +//=========================================================================== +// +// A_QuakeEx +// +// Extended version of A_Quake. Takes individual axis into account and can +// take a flag. +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_QuakeEx) +{ + ACTION_PARAM_START(8); + ACTION_PARAM_INT(intensityX, 0); + ACTION_PARAM_INT(intensityY, 1); + ACTION_PARAM_INT(intensityZ, 2); + ACTION_PARAM_INT(duration, 3); + ACTION_PARAM_INT(damrad, 4); + ACTION_PARAM_INT(tremrad, 5); + ACTION_PARAM_SOUND(sound, 6); + ACTION_PARAM_INT(flags, 7); + P_StartQuakeXYZ(self, 0, intensityX, intensityY, intensityZ, duration, damrad, tremrad, sound, flags); +} + //=========================================================================== // // A_Weave diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index c03c86596..e8906af3f 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -299,6 +299,7 @@ ACTOR Actor native //: Thinker action native A_SetUserArray(name varname, int index, int value); action native A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0); action native A_Quake(int intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake"); + action native A_QuakeEx(int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0); action native A_SetTics(int tics); action native A_SetDamageType(name damagetype); action native A_DropItem(class item, int dropamount = -1, int chance = 256); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 1604b5c83..b3fd26ecb 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -457,6 +457,11 @@ enum FAF_NODISTFACTOR = 8, }; +// Flags for A_QuakeEx +enum +{ + QF_RELATIVE = 1, +}; // This is only here to provide one global variable for testing. native int testglobalvar; From 0f4bca86073ff316d920f6f6d6f7ecd2b767d3c0 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sat, 14 Feb 2015 16:51:05 -0600 Subject: [PATCH 35/50] - Added SXF_TRANSFERROLL. --- src/thingdef/thingdef_codeptr.cpp | 6 ++++++ wadsrc/static/actors/constants.txt | 1 + 2 files changed, 7 insertions(+) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index fc157c92b..117207302 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1875,6 +1875,7 @@ enum SIX_Flags SIXF_NOPOINTERS = 0x00400000, SIXF_ORIGINATOR = 0x00800000, SIXF_TRANSFERSPRITEFRAME = 0x01000000, + SIXF_TRANSFERROLL = 0x02000000, }; static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) @@ -2027,6 +2028,11 @@ static bool InitSpawnedItem(AActor *self, AActor *mo, int flags) mo->frame = self->frame; } + if (flags & SIXF_TRANSFERROLL) + { + mo->roll = self->roll; + } + return true; } diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 1604b5c83..aedd01284 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -73,6 +73,7 @@ const int SXF_SETTRACER = 1 << 21; const int SXF_NOPOINTERS = 1 << 22; const int SXF_ORIGINATOR = 1 << 23; const int SXF_TRANSFERSPRITEFRAME = 1 << 24; +const int SXF_TRANSFERROLL = 1 << 25; // Flags for A_Chase const int CHF_FASTCHASE = 1; From e377c2c4f867dbcbb701ba97384277ff9b3d1869 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 18 Feb 2015 14:48:52 -0600 Subject: [PATCH 36/50] Change XYZ Quaking from Major Cooke - Relative quakes are different from other quakes; all quakes affecting the camera do not become relative if one of them is relative. - Use a single function call to get quake visual parameters instead of four. - Thrust things in a psuedo-ellipse if they're inside a damaging quake whose IntensityX != IntensityY. - Don't break old savegames. --- src/g_shared/a_quake.cpp | 113 +++++++++++++++------------------- src/g_shared/a_sharedglobal.h | 7 +-- src/r_utility.cpp | 69 +++++++++++++-------- src/version.h | 2 +- 4 files changed, 96 insertions(+), 95 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 462deafb6..874ecbb51 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -42,12 +42,11 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in // Radii are specified in tile units (64 pixels) m_DamageRadius = damrad << (FRACBITS); m_TremorRadius = tremrad << (FRACBITS); - m_Intensity = intensityX; + m_IntensityX = intensityX; + m_IntensityY = intensityY; + m_IntensityZ = intensityZ; m_Countdown = duration; m_Flags = flags; - m_iX = intensityX; - m_iY = intensityY; - m_iZ = intensityZ; } //========================================================================== @@ -58,10 +57,20 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in void DEarthquake::Serialize (FArchive &arc) { - Super::Serialize (arc); //[MC] m_Intensity is unused now but I don't want to break compatibility... - arc << m_Spot << m_Intensity << m_Countdown + Super::Serialize (arc); + arc << m_Spot << m_IntensityX << m_Countdown << m_TremorRadius << m_DamageRadius - << m_QuakeSFX << m_Flags << m_iX << m_iY << m_iZ; + << m_QuakeSFX; + if (SaveVersion < 4519) + { + m_IntensityY = m_IntensityX; + m_IntensityZ = 0; + m_Flags = 0; + } + else + { + arc << m_IntensityY << m_IntensityZ << m_Flags; + } } //========================================================================== @@ -106,7 +115,18 @@ void DEarthquake::Tick () } // Thrust player around angle_t an = victim->angle + ANGLE_1*pr_quake(); - P_ThrustMobj (victim, an, m_Intensity << (FRACBITS-1)); + if (m_IntensityX == m_IntensityY) + { // Thrust in a circle + P_ThrustMobj (victim, an, m_IntensityX << (FRACBITS-1)); + } + else + { // Thrust in an ellipse + an >>= ANGLETOFINESHIFT; + // So this is actually completely wrong, but it ought to be good + // enough. Otherwise, I'd have to use tangents and square roots. + victim->velx += FixedMul(m_IntensityX << (FRACBITS-1), finecosine[an]); + victim->vely += FixedMul(m_IntensityY << (FRACBITS-1), finesine[an]); + } } } } @@ -130,18 +150,20 @@ void DEarthquake::Tick () // //========================================================================== -int DEarthquake::StaticGetQuakeIntensity (AActor *victim, int selector) +int DEarthquake::StaticGetQuakeIntensities(AActor *victim, + int &x, int &y, int &z, int &relx, int &rely, int &relz) { - int intensity = 0; - int quakeIntensity = 0; - TThinkerIterator iterator (STAT_EARTHQUAKE); - DEarthquake *quake; - if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) { return 0; } + x = y = z = relx = rely = 0; + + TThinkerIterator iterator(STAT_EARTHQUAKE); + DEarthquake *quake; + int count = 0; + while ( (quake = iterator.Next()) != NULL) { if (quake->m_Spot != NULL) @@ -150,64 +172,25 @@ int DEarthquake::StaticGetQuakeIntensity (AActor *victim, int selector) victim->y - quake->m_Spot->y); if (dist < quake->m_TremorRadius) { - switch (selector) + ++count; + if (quake->m_Flags & QF_RELATIVE) { - default: - case 0: - quakeIntensity = quake->m_iX; - break; - case 1: - quakeIntensity = quake->m_iY; - break; - case 2: - quakeIntensity = quake->m_iZ; - break; - + relx = MAX(relx, quake->m_IntensityX); + rely = MAX(rely, quake->m_IntensityY); + relz = MAX(relz, quake->m_IntensityZ); + } + else + { + x = MAX(x, quake->m_IntensityX); + y = MAX(y, quake->m_IntensityY); + z = MAX(z, quake->m_IntensityZ); } - - if (intensity < quakeIntensity) - intensity = quakeIntensity; } } } - return intensity; + return count; } -//========================================================================== -// -// DEarthquake::StaticGetQuakeIntensity -// -// Searches for all quakes near the victim and returns their combined -// intensity. -// -//========================================================================== - -int DEarthquake::StaticGetQuakeFlags(AActor *victim) -{ - int flags = 0; - TThinkerIterator iterator(STAT_EARTHQUAKE); - DEarthquake *quake; - - if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) - { - return 0; - } - - while ((quake = iterator.Next()) != NULL) - { - if (quake->m_Spot != NULL) - { - fixed_t dist = P_AproxDistance(victim->x - quake->m_Spot->x, - victim->y - quake->m_Spot->y); - if (dist < quake->m_TremorRadius) - { - if (!(flags & QF_RELATIVE) && (quake->m_Flags & QF_RELATIVE)) - flags += QF_RELATIVE; - } - } - } - return flags; -} //========================================================================== // // P_StartQuake diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index a186fa010..e153f7070 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -147,15 +147,12 @@ public: void Tick (); TObjPtr m_Spot; fixed_t m_TremorRadius, m_DamageRadius; - int m_Intensity; int m_Countdown; FSoundID m_QuakeSFX; int m_Flags; - int m_iX, m_iY, m_iZ; + int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeFlags(AActor *viewer); - static int StaticGetQuakeIntensity (AActor *viewer, int selector); - + static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz); private: DEarthquake (); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index f809a6800..a65c90d93 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -764,6 +764,23 @@ bool R_GetViewInterpolationStatus() return NoInterpolateView; } +//========================================================================== +// +// QuakePower +// +//========================================================================== + +static fixed_t QuakePower(fixed_t factor, int intensity) +{ + if (intensity == 0) + { + return 0; + } + else + { + return factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); + } +} //========================================================================== // @@ -875,37 +892,41 @@ void R_SetupFrame (AActor *actor) if (!paused) { - int intensityX = DEarthquake::StaticGetQuakeIntensity(camera, 0); - int intensityY = DEarthquake::StaticGetQuakeIntensity(camera, 1); - int intensityZ = DEarthquake::StaticGetQuakeIntensity(camera, 2); - int quakeflags = DEarthquake::StaticGetQuakeFlags(camera); - if (intensityX || intensityY || intensityZ) + int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; + if (DEarthquake::StaticGetQuakeIntensities(camera, + intensityX, intensityY, intensityZ, + relIntensityX, relIntensityY, relIntensityZ) > 0) { fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity); - if ((quakeflags & QF_RELATIVE) && (intensityX != intensityY)) + if (relIntensityX != 0) { - if (intensityX) - { - int ang = (camera->angle) >> ANGLETOFINESHIFT; - int tflicker = pr_torchflicker(); - viewx += FixedMul(finecosine[ang], (quakefactor * ((tflicker % (intensityX << 2)) - (intensityX << 1)))); - viewy += FixedMul(finesine[ang], (quakefactor * ((tflicker % (intensityX << 2)) - (intensityX << 1)))); - } - if (intensityY) - { - int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - int tflicker = pr_torchflicker(); - viewx += FixedMul(finecosine[ang], (quakefactor * ((tflicker % (intensityY << 2)) - (intensityY << 1)))); - viewy += FixedMul(finesine[ang], (quakefactor * ((tflicker % (intensityY << 2)) - (intensityY << 1)))); - } + int ang = (camera->angle) >> ANGLETOFINESHIFT; + fixed_t power = QuakePower(quakefactor, relIntensityX); + viewx += FixedMul(finecosine[ang], power); + viewy += FixedMul(finesine[ang], power); } - else + if (relIntensityY != 0) { - if (intensityX) viewx += quakefactor * ((pr_torchflicker() % (intensityX << 2)) - (intensityX << 1)); - if (intensityY) viewy += quakefactor * ((pr_torchflicker() % (intensityY << 2)) - (intensityY << 1)); + int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; + fixed_t power = QuakePower(quakefactor, relIntensityY); + viewx += FixedMul(finecosine[ang], power); + viewy += FixedMul(finesine[ang], power); + } + if (intensityX != 0) + { + viewx += QuakePower(quakefactor, intensityX); + } + if (intensityY != 0) + { + viewy += QuakePower(quakefactor, intensityY); + } + // FIXME: Relative Z is not relative + intensityZ = MAX(intensityZ, relIntensityZ); + if (intensityZ != 0) + { + viewz += QuakePower(quakefactor, intensityZ); } - if (intensityZ) viewz += quakefactor * ((pr_torchflicker() % (intensityZ << 2)) - (intensityZ << 1)); } } diff --git a/src/version.h b/src/version.h index 09b830438..2be4787ee 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4518 +#define SAVEVER 4519 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) From 284fd3e20f73103d431c88a60d26731954f702e7 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 19 Feb 2015 16:30:00 -0600 Subject: [PATCH 37/50] - Fixed: relz was never initialized. - This could cause problems in places like the GZDoom renderer in the odd circumstance, causing the camera to become stuck in the floor or ceiling until the quake expires. --- src/g_shared/a_quake.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 874ecbb51..044d51643 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -158,7 +158,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, return 0; } - x = y = z = relx = rely = 0; + x = y = z = relx = rely = relz = 0; TThinkerIterator iterator(STAT_EARTHQUAKE); DEarthquake *quake; From 51688fe1604eea45bba5d12b164067845769b211 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Fri, 20 Feb 2015 16:20:39 +1300 Subject: [PATCH 38/50] Cleanup Compatflags to make options easier to find --- wadsrc/static/menudef.txt | 72 ++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 58240440d..f84c3ceff 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1276,42 +1276,60 @@ OptionMenu "CompatibilityOptions" { Title "COMPATIBILITY OPTIONS" Option "Compatibility mode", "compatmode", "CompatModes", "", 1 + StaticText " " + StaticText "Actor Behavior",1 + Option "Crushed monsters can be resurrected", "compat_CORPSEGIBS", "YesNo" + Option "Friendly monsters aren't blocked", "compat_NOBLOCKFRIENDS", "YesNo" + Option "Limit Pain Elementals' Lost Souls", "compat_LIMITPAIN", "YesNo" + Option "Monster movement is affected by effects", "compat_MBFMONSTERMOVE", "YesNo" + Option "Monsters cannot cross dropoffs", "compat_CROSSDROPOFF", "YesNo" + Option "Monsters get stuck over dropoffs", "compat_DROPOFF", "YesNo" + Option "Monsters see invisible players", "compat_INVISIBILITY", "YesNo" + Option "No Minotaur floor flames in water", "compat_MINOTAUR", "YesNo" + Option "Spawn item drops on the floor", "compat_NOTOSSDROPS", "YesNo" + + StaticText " " + StaticText "DehackEd Behavior",1 + Option "DEH health settings like Doom2.exe", "compat_DEHHEALTH", "YesNo" + Option "Original A_Mushroom speed in DEH mods", "compat_MUSHROOM", "YesNo" + + StaticText " " + StaticText "Map/Action Behavior",1 + Option "All special lines can block ", "compat_USEBLOCKING", "YesNo" + Option "Allow any bossdeath for level special", "compat_ANYBOSSDEATH", "YesNo" + Option "Disable BOOM door light effect", "compat_NODOORLIGHT", "YesNo" + Option "Find neighboring light like Doom", "compat_LIGHT", "YesNo" Option "Find shortest textures like Doom", "compat_SHORTTEX", "YesNo" Option "Use buggier stair building", "compat_stairs", "YesNo" - Option "Find neighboring light like Doom", "compat_LIGHT", "YesNo" - Option "Limit Pain Elementals' Lost Souls", "compat_LIMITPAIN", "YesNo" - Option "Don't let others hear your pickups", "compat_SILENTPICKUP", "YesNo" + Option "Use Doom's floor motion behavior", "compat_floormove", "YesNo" + + StaticText " " + StaticText "Physics Behavior",1 Option "Actors are infinitely tall", "compat_nopassover", "YesNo" - Option "Enable wall running", "compat_WALLRUN", "YesNo" - Option "Spawn item drops on the floor", "compat_NOTOSSDROPS", "YesNo" - Option "All special lines can block ", "compat_USEBLOCKING", "YesNo" - Option "Disable BOOM door light effect", "compat_NODOORLIGHT", "YesNo" - Option "Raven scrollers use original speed", "compat_RAVENSCROLL", "YesNo" - Option "Use original sound target handling", "compat_SOUNDTARGET", "YesNo" - Option "DEH health settings like Doom2.exe", "compat_DEHHEALTH", "YesNo" - Option "Self ref. sectors don't block shots", "compat_TRACE", "YesNo" - Option "Monsters get stuck over dropoffs", "compat_DROPOFF", "YesNo" - Option "Monsters cannot cross dropoffs", "compat_CROSSDROPOFF", "YesNo" - Option "Monsters see invisible players", "compat_INVISIBILITY", "YesNo" Option "Boom scrollers are additive", "compat_BOOMSCROLL", "YesNo" - Option "Inst. moving floors are not silent", "compat_silentinstantfloors", "YesNo" - Option "Sector sounds use center as source", "compat_SECTORSOUNDS", "YesNo" - Option "Use Doom heights for missile clipping", "compat_MISSILECLIP", "YesNo" - Option "Allow any bossdeath for level special", "compat_ANYBOSSDEATH", "YesNo" - Option "No Minotaur floor flames in water", "compat_MINOTAUR", "YesNo" - Option "Original A_Mushroom speed in DEH mods", "compat_MUSHROOM", "YesNo" - Option "Monster movement is affected by effects", "compat_MBFMONSTERMOVE", "YesNo" - Option "Crushed monsters can be resurrected", "compat_CORPSEGIBS", "YesNo" - Option "Friendly monsters aren't blocked", "compat_NOBLOCKFRIENDS", "YesNo" - Option "Invert sprite sorting", "compat_SPRITESORT", "YesNo" + Option "Cannot travel straight NSEW", "compat_badangles", "YesNo" + Option "Enable wall running", "compat_WALLRUN", "YesNo" + Option "Raven scrollers use original speed", "compat_RAVENSCROLL", "YesNo" + Option "Self ref. sectors don't block shots", "compat_TRACE", "YesNo" Option "Use Doom code for hitscan checks", "compat_HITSCAN", "YesNo" - Option "Cripple sound for silent BFG trick", "compat_soundslots", "YesNo" + Option "Use Doom heights for missile clipping", "compat_MISSILECLIP", "YesNo" + + + StaticText " " + StaticText "Rendering Behavior",1 Option "Draw polyobjects like Hexen", "compat_POLYOBJ", "YesNo" Option "Ignore Y offsets on masked midtextures", "compat_MASKEDMIDTEX", "YesNo" - Option "Cannot travel straight NSEW", "compat_badangles", "YesNo" - Option "Use Doom's floor motion behavior", "compat_floormove", "YesNo" + Option "Invert sprite sorting", "compat_SPRITESORT", "YesNo" + + StaticText " " + StaticText "Sound Behavior",1 + Option "Cripple sound for silent BFG trick", "compat_soundslots", "YesNo" + Option "Don't let others hear your pickups", "compat_SILENTPICKUP", "YesNo" + Option "Inst. moving floors are not silent", "compat_silentinstantfloors", "YesNo" + Option "Sector sounds use center as source", "compat_SECTORSOUNDS", "YesNo" Option "Sounds stop when actor vanishes", "compat_soundcutoff", "YesNo" + Option "Use original sound target handling", "compat_SOUNDTARGET", "YesNo" Class "CompatibilityMenu" } From 045ab9fd5b3f1012698aff929cbe73f3e6837cb8 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 19 Feb 2015 21:42:32 -0600 Subject: [PATCH 39/50] Initial groundwork for QF_SCALEDOWN. --- src/g_shared/a_quake.cpp | 17 ++++++++++++++++- src/g_shared/a_sharedglobal.h | 8 ++++++-- src/r_utility.cpp | 25 ++++++++++++++++--------- wadsrc/static/actors/constants.txt | 4 +++- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 044d51643..368d65c53 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -46,6 +46,8 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in m_IntensityY = intensityY; m_IntensityZ = intensityZ; m_Countdown = duration; + m_Countup = 0; + m_ScaleDownStart = duration; m_Flags = flags; } @@ -131,6 +133,7 @@ void DEarthquake::Tick () } } } + ++m_Countup; if (--m_Countdown == 0) { if (S_IsActorPlayingSomething(m_Spot, CHAN_BODY, m_QuakeSFX)) @@ -151,7 +154,7 @@ void DEarthquake::Tick () //========================================================================== int DEarthquake::StaticGetQuakeIntensities(AActor *victim, - int &x, int &y, int &z, int &relx, int &rely, int &relz) + int &x, int &y, int &z, int &relx, int &rely, int &relz, int &scaleDown, int &scaleDownStart, int &scaleUp) { if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) { @@ -185,6 +188,18 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, y = MAX(y, quake->m_IntensityY); z = MAX(z, quake->m_IntensityZ); } + scaleDownStart = scaleDown = scaleUp = 1; + if (quake->m_Flags & QF_SCALEDOWN) + { + scaleDown = quake->m_Countdown; + } + else + { + scaleDownStart = 0; + scaleDown = 0; + } + if (quake->m_Flags & QF_SCALEUP) + scaleUp = quake->m_Countup; } } } diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index e153f7070..025582323 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -133,7 +133,9 @@ protected: enum { - QF_RELATIVE = 1, + QF_RELATIVE = 1, + QF_SCALEDOWN = 1 << 1, + QF_SCALEUP = 1 << 2, }; class DEarthquake : public DThinker @@ -147,12 +149,14 @@ public: void Tick (); TObjPtr m_Spot; fixed_t m_TremorRadius, m_DamageRadius; + int m_ScaleDownStart; int m_Countdown; + int m_Countup; FSoundID m_QuakeSFX; int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz); + static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, int &scaleDown, int &scaleDownStart, int &scaleUp); private: DEarthquake (); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index a65c90d93..006ce8b3f 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -770,16 +770,23 @@ bool R_GetViewInterpolationStatus() // //========================================================================== -static fixed_t QuakePower(fixed_t factor, int intensity) +static fixed_t QuakePower(fixed_t factor, int intensity, int scaleDown, int scaleDownStart, int scaleUp) { + //if (!scaledown) scaledown = 1; + //if (!scaleup) scaleup = 1; + //double sd = (scaledown / ((!scaledownstart) ? 1 : scaledownstart)); if (intensity == 0) { return 0; } - else + else if (!scaleDownStart) { return factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); } + else + { + return (factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)) * ((scaleDown / scaleDownStart) >> 3)); + } } //========================================================================== @@ -892,40 +899,40 @@ void R_SetupFrame (AActor *actor) if (!paused) { - int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; + int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp; if (DEarthquake::StaticGetQuakeIntensities(camera, intensityX, intensityY, intensityZ, - relIntensityX, relIntensityY, relIntensityZ) > 0) + relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp) > 0) { fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity); if (relIntensityX != 0) { int ang = (camera->angle) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityX); + fixed_t power = QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart, scaleUp); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (relIntensityY != 0) { int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityY); + fixed_t power = QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart, scaleUp); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (intensityX != 0) { - viewx += QuakePower(quakefactor, intensityX); + viewx += QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp); } if (intensityY != 0) { - viewy += QuakePower(quakefactor, intensityY); + viewy += QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp); } // FIXME: Relative Z is not relative intensityZ = MAX(intensityZ, relIntensityZ); if (intensityZ != 0) { - viewz += QuakePower(quakefactor, intensityZ); + viewz += QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp); } } } diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 3df42e0f8..19845b91d 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -461,7 +461,9 @@ enum // Flags for A_QuakeEx enum { - QF_RELATIVE = 1, + QF_RELATIVE = 1, + QF_SCALEDOWN = 1 << 1, + QF_SCALEUP = 1 << 2, }; // This is only here to provide one global variable for testing. From 0948b95e081d472ceca6aa5db022a3e89c2788f4 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 19 Feb 2015 23:19:24 -0600 Subject: [PATCH 40/50] - Changed QuakePower to take doubles on everything but intensity. This lets the camera shake until it truly reaches 0 as the limitations of integers were actually cutting it short. --- src/g_shared/a_quake.cpp | 10 +++++----- src/g_shared/a_sharedglobal.h | 2 +- src/r_utility.cpp | 26 +++++++++++++------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 368d65c53..d8e7a13a0 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -154,7 +154,7 @@ void DEarthquake::Tick () //========================================================================== int DEarthquake::StaticGetQuakeIntensities(AActor *victim, - int &x, int &y, int &z, int &relx, int &rely, int &relz, int &scaleDown, int &scaleDownStart, int &scaleUp) + int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart, double &scaleUp) { if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) { @@ -191,15 +191,15 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, scaleDownStart = scaleDown = scaleUp = 1; if (quake->m_Flags & QF_SCALEDOWN) { - scaleDown = quake->m_Countdown; + scaleDown = (double)quake->m_Countdown; } else { - scaleDownStart = 0; - scaleDown = 0; + scaleDownStart = 0.0; + scaleDown = 0.0; } if (quake->m_Flags & QF_SCALEUP) - scaleUp = quake->m_Countup; + scaleUp = (double)quake->m_Countup; } } } diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 025582323..3a8a2c011 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -156,7 +156,7 @@ public: int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, int &scaleDown, int &scaleDownStart, int &scaleUp); + static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart, double &scaleUp); private: DEarthquake (); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 006ce8b3f..bd3cd40e6 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -770,22 +770,20 @@ bool R_GetViewInterpolationStatus() // //========================================================================== -static fixed_t QuakePower(fixed_t factor, int intensity, int scaleDown, int scaleDownStart, int scaleUp) +static double QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart, double scaleUp) { - //if (!scaledown) scaledown = 1; - //if (!scaleup) scaleup = 1; - //double sd = (scaledown / ((!scaledownstart) ? 1 : scaledownstart)); + double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); if (intensity == 0) { return 0; } else if (!scaleDownStart) { - return factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); + return factor * ss; } else { - return (factor * ((pr_torchflicker() % (intensity << 2)) - (intensity << 1)) * ((scaleDown / scaleDownStart) >> 3)); + return ((factor * ss) * ((scaleDown / scaleDownStart) / 256.0f)); } } @@ -899,40 +897,42 @@ void R_SetupFrame (AActor *actor) if (!paused) { - int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp; + int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; + double scaleDown, scaleDownStart, scaleUp; + //double sdown = (double)scaleDown; double sdownstart = (double)scaleDownStart; if (DEarthquake::StaticGetQuakeIntensities(camera, intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp) > 0) { - fixed_t quakefactor = FLOAT2FIXED(r_quakeintensity); + double quakefactor = r_quakeintensity; if (relIntensityX != 0) { int ang = (camera->angle) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart, scaleUp); + fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart, scaleUp)); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (relIntensityY != 0) { int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart, scaleUp); + fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart, scaleUp)); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (intensityX != 0) { - viewx += QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp); + viewx += FLOAT2FIXED(QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp)); } if (intensityY != 0) { - viewy += QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp); + viewy += FLOAT2FIXED(QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp)); } // FIXME: Relative Z is not relative intensityZ = MAX(intensityZ, relIntensityZ); if (intensityZ != 0) { - viewz += QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp); + viewz += FLOAT2FIXED(QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp)); } } } From 9c5d90e4cbee1c10e3168938fc591862ffe12f86 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 01:33:30 -0600 Subject: [PATCH 41/50] - Removed QF_SCALEUP until I can figure out a proper way to implement it. --- src/g_shared/a_quake.cpp | 13 ++++--------- src/g_shared/a_sharedglobal.h | 6 +++--- src/r_utility.cpp | 33 +++++++++++++++++++-------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index d8e7a13a0..1f13ffd61 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -45,9 +45,8 @@ DEarthquake::DEarthquake (AActor *center, int intensityX, int intensityY, int in m_IntensityX = intensityX; m_IntensityY = intensityY; m_IntensityZ = intensityZ; + m_CountdownStart = (double)duration; m_Countdown = duration; - m_Countup = 0; - m_ScaleDownStart = duration; m_Flags = flags; } @@ -133,7 +132,6 @@ void DEarthquake::Tick () } } } - ++m_Countup; if (--m_Countdown == 0) { if (S_IsActorPlayingSomething(m_Spot, CHAN_BODY, m_QuakeSFX)) @@ -154,7 +152,7 @@ void DEarthquake::Tick () //========================================================================== int DEarthquake::StaticGetQuakeIntensities(AActor *victim, - int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart, double &scaleUp) + int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart) { if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) { @@ -188,18 +186,15 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, y = MAX(y, quake->m_IntensityY); z = MAX(z, quake->m_IntensityZ); } - scaleDownStart = scaleDown = scaleUp = 1; if (quake->m_Flags & QF_SCALEDOWN) { + scaleDownStart = quake->m_CountdownStart; scaleDown = (double)quake->m_Countdown; } else { - scaleDownStart = 0.0; - scaleDown = 0.0; + scaleDownStart = scaleDown = 0.0; } - if (quake->m_Flags & QF_SCALEUP) - scaleUp = (double)quake->m_Countup; } } } diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 3a8a2c011..f45005856 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -149,14 +149,14 @@ public: void Tick (); TObjPtr m_Spot; fixed_t m_TremorRadius, m_DamageRadius; - int m_ScaleDownStart; int m_Countdown; - int m_Countup; + double m_CountdownStart; + double m_Countup; FSoundID m_QuakeSFX; int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart, double &scaleUp); + static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart); private: DEarthquake (); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index bd3cd40e6..ca602a745 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -770,21 +770,26 @@ bool R_GetViewInterpolationStatus() // //========================================================================== -static double QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart, double scaleUp) +static double QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart) { - double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); + if (intensity == 0) { return 0; } - else if (!scaleDownStart) - { - return factor * ss; - } else { - return ((factor * ss) * ((scaleDown / scaleDownStart) / 256.0f)); + double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); + if (scaleDownStart == 0) + { + return factor * ss; + } + else + { + return ((factor * ss) * ((scaleDown / scaleDownStart))); + } } + } //========================================================================== @@ -898,41 +903,41 @@ void R_SetupFrame (AActor *actor) if (!paused) { int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; - double scaleDown, scaleDownStart, scaleUp; + double scaleDown, scaleDownStart; //double sdown = (double)scaleDown; double sdownstart = (double)scaleDownStart; if (DEarthquake::StaticGetQuakeIntensities(camera, intensityX, intensityY, intensityZ, - relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart, scaleUp) > 0) + relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart) > 0) { double quakefactor = r_quakeintensity; if (relIntensityX != 0) { int ang = (camera->angle) >> ANGLETOFINESHIFT; - fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart, scaleUp)); + fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart)); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (relIntensityY != 0) { int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart, scaleUp)); + fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart)); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (intensityX != 0) { - viewx += FLOAT2FIXED(QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart, scaleUp)); + viewx += FLOAT2FIXED(QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart)); } if (intensityY != 0) { - viewy += FLOAT2FIXED(QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart, scaleUp)); + viewy += FLOAT2FIXED(QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart)); } // FIXME: Relative Z is not relative intensityZ = MAX(intensityZ, relIntensityZ); if (intensityZ != 0) { - viewz += FLOAT2FIXED(QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart, scaleUp)); + viewz += FLOAT2FIXED(QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart)); } } } From 2939194ae34f81e3d1f1abe6bac3eed1f2b8e47d Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 01:36:53 -0600 Subject: [PATCH 42/50] - Forgot this tiny little one. --- src/g_shared/a_sharedglobal.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index f45005856..270f3102a 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -151,7 +151,6 @@ public: fixed_t m_TremorRadius, m_DamageRadius; int m_Countdown; double m_CountdownStart; - double m_Countup; FSoundID m_QuakeSFX; int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; From 3bf24204d838d87bc7f96a907c872a4a5871eea7 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 01:41:59 -0600 Subject: [PATCH 43/50] - Ensure save games don't break. --- src/g_shared/a_quake.cpp | 2 ++ src/version.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 1f13ffd61..8fe060cd7 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -68,6 +68,8 @@ void DEarthquake::Serialize (FArchive &arc) m_IntensityZ = 0; m_Flags = 0; } + if (SaveVersion < 4520) + m_CountdownStart = 0; else { arc << m_IntensityY << m_IntensityZ << m_Flags; diff --git a/src/version.h b/src/version.h index 2be4787ee..794bdcec8 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4519 +#define SAVEVER 4520 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) From d6e4a7a0816daad6366c403122470244fe52dd74 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 07:36:37 -0600 Subject: [PATCH 44/50] - Changed QuakePower back to fixed_t and just had it return FLOAT2FIXED instead. --- src/r_utility.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/r_utility.cpp b/src/r_utility.cpp index ca602a745..585d6e573 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -770,7 +770,7 @@ bool R_GetViewInterpolationStatus() // //========================================================================== -static double QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart) +static fixed_t QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart) { if (intensity == 0) @@ -782,11 +782,11 @@ static double QuakePower(double factor, int intensity, double scaleDown, double double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); if (scaleDownStart == 0) { - return factor * ss; + return FLOAT2FIXED(factor * ss); } else { - return ((factor * ss) * ((scaleDown / scaleDownStart))); + return FLOAT2FIXED(((factor * ss) * ((scaleDown / scaleDownStart)))); } } @@ -904,7 +904,6 @@ void R_SetupFrame (AActor *actor) { int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; double scaleDown, scaleDownStart; - //double sdown = (double)scaleDown; double sdownstart = (double)scaleDownStart; if (DEarthquake::StaticGetQuakeIntensities(camera, intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart) > 0) @@ -914,30 +913,30 @@ void R_SetupFrame (AActor *actor) if (relIntensityX != 0) { int ang = (camera->angle) >> ANGLETOFINESHIFT; - fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart)); + fixed_t power = QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (relIntensityY != 0) { int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = FLOAT2FIXED(QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart)); + fixed_t power = QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } if (intensityX != 0) { - viewx += FLOAT2FIXED(QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart)); + viewx += QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart); } if (intensityY != 0) { - viewy += FLOAT2FIXED(QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart)); + viewy += QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart); } // FIXME: Relative Z is not relative intensityZ = MAX(intensityZ, relIntensityZ); if (intensityZ != 0) { - viewz += FLOAT2FIXED(QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart)); + viewz += QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart); } } } From 49d948236327f2799136806e5cee5373daa1bcf9 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 08:26:45 -0600 Subject: [PATCH 45/50] - Cleaned out of the code and converted it to taking a struct instead. - This will make it much easier on me to add future changes. Big thanks to Graf for the idea. --- src/g_shared/a_quake.cpp | 23 +++++++++++------------ src/g_shared/a_sharedglobal.h | 8 +++++++- src/r_utility.cpp | 34 ++++++++++++++++------------------ 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 8fe060cd7..c7290830b 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -153,15 +153,14 @@ void DEarthquake::Tick () // //========================================================================== -int DEarthquake::StaticGetQuakeIntensities(AActor *victim, - int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart) +int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop) { if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP)) { return 0; } - x = y = z = relx = rely = relz = 0; + qprop.intensityX = qprop.intensityY = qprop.intensityZ = qprop.relIntensityX = qprop.relIntensityY = qprop.relIntensityZ = 0; TThinkerIterator iterator(STAT_EARTHQUAKE); DEarthquake *quake; @@ -178,24 +177,24 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, ++count; if (quake->m_Flags & QF_RELATIVE) { - relx = MAX(relx, quake->m_IntensityX); - rely = MAX(rely, quake->m_IntensityY); - relz = MAX(relz, quake->m_IntensityZ); + qprop.relIntensityX = MAX(qprop.relIntensityX, quake->m_IntensityX); + qprop.relIntensityY = MAX(qprop.relIntensityY, quake->m_IntensityY); + qprop.relIntensityZ = MAX(qprop.relIntensityZ, quake->m_IntensityZ); } else { - x = MAX(x, quake->m_IntensityX); - y = MAX(y, quake->m_IntensityY); - z = MAX(z, quake->m_IntensityZ); + qprop.intensityX = MAX(qprop.intensityX, quake->m_IntensityX); + qprop.intensityY = MAX(qprop.intensityY, quake->m_IntensityY); + qprop.intensityZ = MAX(qprop.intensityZ, quake->m_IntensityZ); } if (quake->m_Flags & QF_SCALEDOWN) { - scaleDownStart = quake->m_CountdownStart; - scaleDown = (double)quake->m_Countdown; + qprop.scaleDownStart = quake->m_CountdownStart; + qprop.scaleDown = quake->m_Countdown; } else { - scaleDownStart = scaleDown = 0.0; + qprop.scaleDownStart = qprop.scaleDown = 0.0; } } } diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 270f3102a..9a6f3925d 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -138,6 +138,12 @@ enum QF_SCALEUP = 1 << 2, }; +struct quakeInfo +{ + int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; + double scaleDown, scaleDownStart; +}; + class DEarthquake : public DThinker { DECLARE_CLASS (DEarthquake, DThinker) @@ -155,7 +161,7 @@ public: int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeIntensities(AActor *viewer, int &x, int &y, int &z, int &relx, int &rely, int &relz, double &scaleDown, double &scaleDownStart); + static int StaticGetQuakeIntensities(AActor *viewer, quakeInfo &a); private: DEarthquake (); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 585d6e573..d27eeaca8 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -770,9 +770,10 @@ bool R_GetViewInterpolationStatus() // //========================================================================== -static fixed_t QuakePower(double factor, int intensity, double scaleDown, double scaleDownStart) +static fixed_t QuakePower(double factor, int intensity, quakeInfo quake) { - + double scaleDownStart = quake.scaleDownStart; + double scaleDown = quake.scaleDown; if (intensity == 0) { return 0; @@ -902,41 +903,38 @@ void R_SetupFrame (AActor *actor) if (!paused) { - int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; - double scaleDown, scaleDownStart; - if (DEarthquake::StaticGetQuakeIntensities(camera, - intensityX, intensityY, intensityZ, - relIntensityX, relIntensityY, relIntensityZ, scaleDown, scaleDownStart) > 0) + quakeInfo quake; + if (DEarthquake::StaticGetQuakeIntensities(camera, quake) > 0) { double quakefactor = r_quakeintensity; - if (relIntensityX != 0) + if (quake.relIntensityX != 0) { int ang = (camera->angle) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityX, scaleDown, scaleDownStart); + fixed_t power = QuakePower(quakefactor, quake.relIntensityX, quake); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } - if (relIntensityY != 0) + if (quake.relIntensityY != 0) { int ang = (camera->angle + ANG90) >> ANGLETOFINESHIFT; - fixed_t power = QuakePower(quakefactor, relIntensityY, scaleDown, scaleDownStart); + fixed_t power = QuakePower(quakefactor, quake.relIntensityY, quake); viewx += FixedMul(finecosine[ang], power); viewy += FixedMul(finesine[ang], power); } - if (intensityX != 0) + if (quake.intensityX != 0) { - viewx += QuakePower(quakefactor, intensityX, scaleDown, scaleDownStart); + viewx += QuakePower(quakefactor, quake.intensityX, quake); } - if (intensityY != 0) + if (quake.intensityY != 0) { - viewy += QuakePower(quakefactor, intensityY, scaleDown, scaleDownStart); + viewy += QuakePower(quakefactor, quake.intensityY, quake); } // FIXME: Relative Z is not relative - intensityZ = MAX(intensityZ, relIntensityZ); - if (intensityZ != 0) + quake.intensityZ = MAX(quake.intensityZ, quake.relIntensityZ); + if (quake.intensityZ != 0) { - viewz += QuakePower(quakefactor, intensityZ, scaleDown, scaleDownStart); + viewz += QuakePower(quakefactor, quake.intensityZ, quake); } } } From 475bc65eba3bd587b34d59e6e981c8336b17ae78 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 08:35:42 -0600 Subject: [PATCH 46/50] - Better safe than sorry, even if it apparently had no effect. --- src/g_shared/a_sharedglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 9a6f3925d..3ae80040e 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -161,7 +161,7 @@ public: int m_Flags; int m_IntensityX, m_IntensityY, m_IntensityZ; - static int StaticGetQuakeIntensities(AActor *viewer, quakeInfo &a); + static int StaticGetQuakeIntensities(AActor *viewer, quakeInfo &qprop); private: DEarthquake (); From 3019f2cc237af2be6c6bee260910cc93130a2608 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Feb 2015 16:50:03 +0100 Subject: [PATCH 47/50] - fixed savegame code for quakes. --- src/g_shared/a_quake.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index c7290830b..38cff2d2d 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -68,12 +68,19 @@ void DEarthquake::Serialize (FArchive &arc) m_IntensityZ = 0; m_Flags = 0; } - if (SaveVersion < 4520) - m_CountdownStart = 0; else { arc << m_IntensityY << m_IntensityZ << m_Flags; } + if (SaveVersion < 4520) + { + m_CountdownStart = 0; + } + else + { + arc << m_CountdownStart; + } + } //========================================================================== From 140a6504424429908557f366921ea8a72564b3ba Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 10:46:37 -0600 Subject: [PATCH 48/50] - Added QF_SCALEUP and QF_MAX. - QF_SCALEUP behaves like QF_SCALEDOWN: it gradually scales the tremors, only going upwards. - QF_SCALEUP and QF_SCALEDOWN can be combined to make an earthquake that gradually smoothes in and out. - QF_MAX can be used to invert this behavior, where it starts at the peak of the amplitude, fades out half way, and then grows back to maximum. --- src/g_shared/a_quake.cpp | 11 +++++++---- src/g_shared/a_sharedglobal.h | 2 ++ src/r_utility.cpp | 24 +++++++++++++++++++++--- wadsrc/static/actors/constants.txt | 1 + 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 38cff2d2d..91d654d02 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -80,7 +80,6 @@ void DEarthquake::Serialize (FArchive &arc) { arc << m_CountdownStart; } - } //========================================================================== @@ -101,7 +100,7 @@ void DEarthquake::Tick () Destroy (); return; } - + if (!S_IsActorPlayingSomething (m_Spot, CHAN_BODY, m_QuakeSFX)) { S_Sound (m_Spot, CHAN_BODY | CHAN_LOOP, m_QuakeSFX, 1, ATTN_NORM); @@ -141,6 +140,7 @@ void DEarthquake::Tick () } } } + if (--m_Countdown == 0) { if (S_IsActorPlayingSomething(m_Spot, CHAN_BODY, m_QuakeSFX)) @@ -166,7 +166,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop) { return 0; } - + qprop.isScalingDown = qprop.isScalingUp = false, qprop.preferMaximum = false; qprop.intensityX = qprop.intensityY = qprop.intensityZ = qprop.relIntensityX = qprop.relIntensityY = qprop.relIntensityZ = 0; TThinkerIterator iterator(STAT_EARTHQUAKE); @@ -194,10 +194,13 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop) qprop.intensityY = MAX(qprop.intensityY, quake->m_IntensityY); qprop.intensityZ = MAX(qprop.intensityZ, quake->m_IntensityZ); } - if (quake->m_Flags & QF_SCALEDOWN) + if (quake->m_Flags) { qprop.scaleDownStart = quake->m_CountdownStart; qprop.scaleDown = quake->m_Countdown; + qprop.isScalingDown = (quake->m_Flags & QF_SCALEDOWN) ? true : false; + qprop.isScalingUp = (quake->m_Flags & QF_SCALEUP) ? true : false; + qprop.preferMaximum = (quake->m_Flags & QF_MAX) ? true : false; } else { diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 3ae80040e..2f34f9f5a 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -136,12 +136,14 @@ enum QF_RELATIVE = 1, QF_SCALEDOWN = 1 << 1, QF_SCALEUP = 1 << 2, + QF_MAX = 1 << 3, }; struct quakeInfo { int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; double scaleDown, scaleDownStart; + bool isScalingDown, isScalingUp, preferMaximum; }; class DEarthquake : public DThinker diff --git a/src/r_utility.cpp b/src/r_utility.cpp index d27eeaca8..42581add5 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -781,13 +781,31 @@ static fixed_t QuakePower(double factor, int intensity, quakeInfo quake) else { double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); - if (scaleDownStart == 0) + + if (quake.isScalingDown || quake.isScalingUp) { - return FLOAT2FIXED(factor * ss); + fixed_t result; + if (scaleDownStart == 0) scaleDownStart = 1; + + if (quake.isScalingDown && quake.isScalingUp) + { + if (quake.preferMaximum) + result = FLOAT2FIXED((factor * ss) * MAX((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart)); + else + result = FLOAT2FIXED((factor * ss) * MIN((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart)); + } + else if (quake.isScalingDown) + result = FLOAT2FIXED((factor * ss) * (scaleDown / scaleDownStart)); + else if (quake.isScalingUp) + result = FLOAT2FIXED((factor * ss) * ((scaleDownStart - scaleDown) / scaleDownStart)); + else + result = FLOAT2FIXED(factor * ss); + + return result; } else { - return FLOAT2FIXED(((factor * ss) * ((scaleDown / scaleDownStart)))); + return FLOAT2FIXED(factor * ss); } } diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 19845b91d..e245c37ef 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -464,6 +464,7 @@ enum QF_RELATIVE = 1, QF_SCALEDOWN = 1 << 1, QF_SCALEUP = 1 << 2, + QF_MAX = 1 << 3, }; // This is only here to provide one global variable for testing. From aa3c3d65461fd846442333026a128af718e0fabf Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 10:55:06 -0600 Subject: [PATCH 49/50] - Fixed: Smoothing in to out reached only half strength. --- src/r_utility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 42581add5..5d5dab2b8 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -792,7 +792,7 @@ static fixed_t QuakePower(double factor, int intensity, quakeInfo quake) if (quake.preferMaximum) result = FLOAT2FIXED((factor * ss) * MAX((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart)); else - result = FLOAT2FIXED((factor * ss) * MIN((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart)); + result = FLOAT2FIXED((factor * ss) * MIN(((scaleDown*2) / scaleDownStart), ((scaleDownStart - scaleDown)*2) / scaleDownStart)); } else if (quake.isScalingDown) result = FLOAT2FIXED((factor * ss) * (scaleDown / scaleDownStart)); From fb9231a38db2025eb77bfd246f36d985cbbccd2e Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 20 Feb 2015 11:06:41 -0600 Subject: [PATCH 50/50] - Added QF_FULLINTENSITY. - When using both scaling flags, by default, the effect only reaches half peak going either way. This forces it to go all the way to the top (or bottom if using QF_MAX) before scaling back to its original height.. --- src/g_shared/a_quake.cpp | 3 ++- src/g_shared/a_sharedglobal.h | 11 ++++++----- src/r_utility.cpp | 6 +++--- wadsrc/static/actors/constants.txt | 1 + 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 91d654d02..5cce4c371 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -166,7 +166,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop) { return 0; } - qprop.isScalingDown = qprop.isScalingUp = false, qprop.preferMaximum = false; + qprop.isScalingDown = qprop.isScalingUp = qprop.preferMaximum = qprop.fullIntensity = false; qprop.intensityX = qprop.intensityY = qprop.intensityZ = qprop.relIntensityX = qprop.relIntensityY = qprop.relIntensityZ = 0; TThinkerIterator iterator(STAT_EARTHQUAKE); @@ -201,6 +201,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, quakeInfo &qprop) qprop.isScalingDown = (quake->m_Flags & QF_SCALEDOWN) ? true : false; qprop.isScalingUp = (quake->m_Flags & QF_SCALEUP) ? true : false; qprop.preferMaximum = (quake->m_Flags & QF_MAX) ? true : false; + qprop.fullIntensity = (quake->m_Flags & QF_FULLINTENSITY) ? true : false; } else { diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 2f34f9f5a..00247c224 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -133,17 +133,18 @@ protected: enum { - QF_RELATIVE = 1, - QF_SCALEDOWN = 1 << 1, - QF_SCALEUP = 1 << 2, - QF_MAX = 1 << 3, + QF_RELATIVE = 1, + QF_SCALEDOWN = 1 << 1, + QF_SCALEUP = 1 << 2, + QF_MAX = 1 << 3, + QF_FULLINTENSITY = 1 << 4, }; struct quakeInfo { int intensityX, intensityY, intensityZ, relIntensityX, relIntensityY, relIntensityZ; double scaleDown, scaleDownStart; - bool isScalingDown, isScalingUp, preferMaximum; + bool isScalingDown, isScalingUp, preferMaximum, fullIntensity; }; class DEarthquake : public DThinker diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 5d5dab2b8..ebcff8af5 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -781,7 +781,7 @@ static fixed_t QuakePower(double factor, int intensity, quakeInfo quake) else { double ss = (double)((pr_torchflicker() % (intensity << 2)) - (intensity << 1)); - + double mtp = (quake.fullIntensity) ? 2.0 : 1.0; if (quake.isScalingDown || quake.isScalingUp) { fixed_t result; @@ -790,9 +790,9 @@ static fixed_t QuakePower(double factor, int intensity, quakeInfo quake) if (quake.isScalingDown && quake.isScalingUp) { if (quake.preferMaximum) - result = FLOAT2FIXED((factor * ss) * MAX((scaleDown / scaleDownStart), (scaleDownStart - scaleDown) / scaleDownStart)); + result = FLOAT2FIXED((factor * ss) * MAX(((scaleDown*mtp) / scaleDownStart), ((scaleDownStart - scaleDown)*mtp) / scaleDownStart)); else - result = FLOAT2FIXED((factor * ss) * MIN(((scaleDown*2) / scaleDownStart), ((scaleDownStart - scaleDown)*2) / scaleDownStart)); + result = FLOAT2FIXED((factor * ss) * MIN(((scaleDown*mtp) / scaleDownStart), ((scaleDownStart - scaleDown)*mtp) / scaleDownStart)); } else if (quake.isScalingDown) result = FLOAT2FIXED((factor * ss) * (scaleDown / scaleDownStart)); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index e245c37ef..78149430a 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -465,6 +465,7 @@ enum QF_SCALEDOWN = 1 << 1, QF_SCALEUP = 1 << 2, QF_MAX = 1 << 3, + QF_FULLINTENSITY = 1 << 4, }; // This is only here to provide one global variable for testing.