From 455e6cd21493f40b649be3ff5583b5a9a3986242 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Mon, 19 Jan 2015 23:57:15 +1300 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 ec5817869592660af6837b9f4e20ed140972a2b2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 7 Feb 2015 15:27:31 +0100 Subject: [PATCH 4/9] - replace all \0 characters in Dehacked patches with spaces. This is needed to make some old and broken patches in some WolfenDoom mods load. --- src/c_dispatch.cpp | 2 +- src/d_dehacked.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index 7a6748fdc..06bcf6b58 100644 --- a/src/c_dispatch.cpp +++ b/src/c_dispatch.cpp @@ -694,7 +694,7 @@ void C_DoCommand (const char *cmd, int keynum) } else { - Printf ("Unknown command \"%.*s\"\n", len, beg); + Printf ("Unknown command \"%.*s\"\n", (int)len, beg); } } } diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 41ad71472..8debb69a4 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -2455,6 +2455,12 @@ static bool DoDehPatch() Printf (PRINT_BOLD, "\"%s\" is an old and unsupported DeHackEd patch\n", PatchFile); return false; } + // fix for broken WolfenDoom patches which contain \0 characters in some places. + for (int i = 0; i < PatchSize; i++) + { + if (PatchFile[i] == 0) PatchFile[i] = ' '; + } + PatchPt = strchr (PatchFile, '\n'); while ((cont = GetLine()) == 1) { From 322742d4b11b66670a5f2021ef647a7ec87fa4cd Mon Sep 17 00:00:00 2001 From: ZzZombo Date: Sat, 7 Feb 2015 23:35:23 +0800 Subject: [PATCH 5/9] - 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 6/9] - 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 7/9] - 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 8/9] - 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 9/9] - 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;