From b15767c26fc73d1b6843381b9fb223637236116f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 29 Oct 2007 20:27:40 +0000 Subject: [PATCH] - Fixed: The pointer cleanup code must also check a sector's sky box pointers. - Fixed: Right after teleporting P_SlideMove could cause player movement. Added a check for reactiontime to prevent that. - Fixed: PainChances and Damagefactors were never freed. - Added option to A_Chase that prevents the monster from moving. - Fixed: The stained glass shards were missing the HEXENBOUNCE flag. - Added some NULL pointer checks to AActor::GiveAmmo. - Fixed: The FSwordMissile was missing the special damage handling that reduces damage when hitting a player. SVN r555 (trunk) --- docs/rh-log.txt | 16 ++++++++++++++++ src/b_bot.cpp | 26 +++++++++++++------------- src/d_protocol.h | 1 + src/dobject.cpp | 9 +++++++++ src/dobjtype.cpp | 10 ++++++++++ src/g_game.cpp | 4 ++-- src/g_hexen/a_fighterquietus.cpp | 11 +++++++++++ src/g_hexen/a_serpent.cpp | 6 +++--- src/m_cheat.cpp | 13 +++++++++++++ src/p_acs.cpp | 27 ++++++++++++++++++--------- src/p_enemy.cpp | 21 +++++++++++---------- src/p_map.cpp | 3 +++ src/p_mobj.cpp | 21 ++++++++++++++------- src/p_user.cpp | 23 +++++++++++++---------- src/thingdef_codeptr.cpp | 1 + wadsrc/decorate/constants.txt | 1 + wadsrc/decorate/shared/debris.txt | 10 ++++++++++ 17 files changed, 149 insertions(+), 54 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index b069981e2..e5070138b 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,20 @@ +October 28, 2007 (Changes by Graf Zahl) +- Fixed: The pointer cleanup code must also check a sector's sky box pointers. + +October 27, 2007 (Changes by Graf Zahl) +- Fixed: Right after teleporting P_SlideMove could cause player movement. + Added a check for reactiontime to prevent that. +- Fixed: PainChances and Damagefactors were never freed. +- Added option to A_Chase that prevents the monster from moving. + +October 20, 2007 (Changes by Graf Zahl) +- Added some NULL pointer checks to AActor::GiveAmmo. +- Fixed: The FSwordMissile was missing the special damage handling that + reduces damage when hitting a player. + October 19, 2007 (Changes by Graf Zahl) +- Fixed: APlayerPawn::UpdateWaterLevel must check if the actor is still + connected to a player. - Fixed: POwered up weapons with a different ready state than their base weapon didn't change back when the powerup expired. - Fixed: The powered up version of Heretic's Gauntlets missed the proper diff --git a/src/b_bot.cpp b/src/b_bot.cpp index b3f4b181d..c812ef2df 100644 --- a/src/b_bot.cpp +++ b/src/b_bot.cpp @@ -74,21 +74,21 @@ CCMD (removebots) Net_WriteByte (DEM_KILLBOTS); } +extern bool CheckCheatmode (); + CCMD (freeze) { - if (!netgame) - { - if (bglobal.freeze) - { - bglobal.freeze = false; - Printf ("Freeze mode off\n"); - } - else - { - bglobal.freeze = true; - Printf ("Freeze mode on\n"); - } - } + if (CheckCheatmode ()) + return; + + if (netgame && consoleplayer != Net_Arbitrator) + { + Printf ("Only player %d can use freeze mode\n", Net_Arbitrator + 1); + return; + } + + Net_WriteByte (DEM_GENERICCHEAT); + Net_WriteByte (CHT_FREEZE); } CCMD (listbots) diff --git a/src/d_protocol.h b/src/d_protocol.h index 24c21c3dd..f6a7a735e 100644 --- a/src/d_protocol.h +++ b/src/d_protocol.h @@ -188,6 +188,7 @@ enum ECheatCommand CHT_LEGO, CHT_RESSURECT, // [GRB] CHT_CLEARFROZENPROPS, + CHT_FREEZE, }; void StartChunk (int id, BYTE **stream); diff --git a/src/dobject.cpp b/src/dobject.cpp index 90c2e021a..ebce10838 100644 --- a/src/dobject.cpp +++ b/src/dobject.cpp @@ -46,6 +46,7 @@ #include "i_system.h" #include "r_state.h" #include "stats.h" +#include "a_sharedglobal.h" #include "autosegs.h" @@ -507,6 +508,14 @@ void DObject::PointerSubstitution (DObject *old, DObject *notOld) { sectors[i].SoundTarget = static_cast(notOld); } + if (sectors[i].CeilingSkyBox == old) + { + sectors[i].CeilingSkyBox = static_cast(notOld); + } + if (sectors[i].FloorSkyBox == old) + { + sectors[i].FloorSkyBox = static_cast(notOld); + } } } } diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index ff4afc30c..dbcda05c2 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -96,6 +96,16 @@ void PClass::StaticFreeData (PClass *type) delete[] type->ActorInfo->OwnedStates; type->ActorInfo->OwnedStates = NULL; } + if (type->ActorInfo->DamageFactors != NULL) + { + delete type->ActorInfo->DamageFactors; + type->ActorInfo->DamageFactors = NULL; + } + if (type->ActorInfo->PainChances != NULL) + { + delete type->ActorInfo->PainChances; + type->ActorInfo->PainChances = NULL; + } delete type->ActorInfo; type->ActorInfo = NULL; } diff --git a/src/g_game.cpp b/src/g_game.cpp index 5f75d8d42..37ea5408e 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -370,7 +370,7 @@ CCMD (invuse) { if (players[consoleplayer].inventorytics == 0 || gameinfo.gametype == GAME_Strife) { - SendItemUse = players[consoleplayer].mo->InvSel; + if (players[consoleplayer].mo) SendItemUse = players[consoleplayer].mo->InvSel; } players[consoleplayer].inventorytics = 0; } @@ -385,7 +385,7 @@ CCMD (use) CCMD (invdrop) { - SendItemDrop = players[consoleplayer].mo->InvSel; + if (players[consoleplayer].mo) SendItemDrop = players[consoleplayer].mo->InvSel; } CCMD (drop) diff --git a/src/g_hexen/a_fighterquietus.cpp b/src/g_hexen/a_fighterquietus.cpp index cafd4106e..5cee8bac3 100644 --- a/src/g_hexen/a_fighterquietus.cpp +++ b/src/g_hexen/a_fighterquietus.cpp @@ -213,6 +213,7 @@ class AFSwordMissile : public AActor DECLARE_ACTOR (AFSwordMissile, AActor) public: void GetExplodeParms (int &damage, int &dist, bool &hurtSource); + int DoSpecialDamage(AActor *victim, AActor *source, int damage); }; FState AFSwordMissile::States[] = @@ -257,6 +258,16 @@ void AFSwordMissile::GetExplodeParms (int &damage, int &dist, bool &hurtSource) hurtSource = false; } +int AFSwordMissile::DoSpecialDamage(AActor *victim, AActor *source, int damage) +{ + if (victim->player) + { + damage -= damage >> 2; + } + return damage; +} + + // Fighter Sword Flame ------------------------------------------------------ class AFSwordFlame : public AActor diff --git a/src/g_hexen/a_serpent.cpp b/src/g_hexen/a_serpent.cpp index e8c60a138..8973eb7e3 100644 --- a/src/g_hexen/a_serpent.cpp +++ b/src/g_hexen/a_serpent.cpp @@ -14,7 +14,7 @@ static FRandom pr_serpentmeattack ("SerpentMeAttack"); static FRandom pr_serpentgibs ("SerpentGibs"); static FRandom pr_delaygib ("DelayGib"); -void A_DoChase(AActor * actor, bool fastchase, FState * meleestate, FState * missilestate, bool playactive, bool nightmarefast); +void A_DoChase(AActor * actor, bool fastchase, FState * meleestate, FState * missilestate, bool playactive, bool nightmarefast,bool dontmove); void A_SerpentChase (AActor *); void A_SerpentHumpDecide (AActor *); @@ -403,7 +403,7 @@ void A_SerpentHide (AActor *actor) void A_SerpentChase (AActor *actor) { - A_DoChase (actor, false, actor->MeleeState, NULL, false, true); + A_DoChase (actor, false, actor->MeleeState, NULL, false, true, false); } //============================================================================ @@ -501,7 +501,7 @@ void A_SerpentDiveSound (AActor *actor) void A_SerpentWalk (AActor *actor) { - A_DoChase (actor, false, &ASerpent::States[S_SERPENT_ATK1], NULL, true, true); + A_DoChase (actor, false, &ASerpent::States[S_SERPENT_ATK1], NULL, true, true, false); } //============================================================================ diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 57e0f93cb..d81496eee 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -399,6 +399,19 @@ void cht_DoCheat (player_t *player, int cheat) player->cheats &= ~(CF_FROZEN|CF_TOTALLYFROZEN); msg = "Frozen player properties turned off"; break; + + case CHT_FREEZE: + if (bglobal.freeze) + { + bglobal.freeze = false; + msg = "Freeze mode off\n"; + } + else + { + bglobal.freeze = true; + msg = "Freeze mode on\n"; + } + break; } if (!*msg) // [SO] Don't print blank lines! diff --git a/src/p_acs.cpp b/src/p_acs.cpp index ec35a4896..bd5107e8a 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -693,13 +693,29 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len) Arrays = NULL; ArrayStore = NULL; Chunks = NULL; + Data = NULL; Format = ACS_Unknown; LumpNum = lumpnum; memset (MapVarStore, 0, sizeof(MapVarStore)); ModuleName[0] = 0; + + // Now that everything is set up, record this module as being among the loaded modules. + // We need to do this before resolving any imports, because an import might (indirectly) + // need to resolve exports in this module. The only things that can be exported are + // functions and map variables, which must already be present if they're exported, so + // this is okay. + + // This must be done first for 2 reasons: + // 1. If not, corrupt modules cause memory leaks + // 2. Corrupt modules won't be reported when a level is being loaded if this function quits before + // adding it to the list. + LibraryID = StaticModules.Push (this) << 16; + if (fr == NULL) len = Wads.LumpLength (lumpnum); + + // Any behaviors smaller than 32 bytes cannot possibly contain anything useful. // (16 bytes for a completely empty behavior + 12 bytes for one script header // + 4 bytes for PCD_TERMINATE for an old-style object. A new-style object @@ -802,7 +818,7 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len) { MapVars[i] = &MapVarStore[i]; } - LibraryID = StaticModules.Push (this) << 16; + //LibraryID = StaticModules.Push (this) << 16; } else { @@ -885,13 +901,6 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len) } } - // Now that everything is set up, record this module as being among the loaded modules. - // We need to do this before resolving any imports, because an import might (indirectly) - // need to resolve exports in this module. The only things that can be exported are - // functions and map variables, which must already be present if they're exported, so - // this is okay. - LibraryID = StaticModules.Push (this) << 16; - // Tag the library ID to any map variables that are initialized with strings if (LibraryID != 0) { @@ -941,7 +950,7 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len) { module = StaticLoadModule (lump); } - Imports.Push (module); + if (module != NULL) Imports.Push (module); do ; while (parse[++i]); } ++i; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 1b9320b10..ed7765abd 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -1766,7 +1766,7 @@ nosee: //============================================================================= #define CLASS_BOSS_STRAFE_RANGE 64*10*FRACUNIT -void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast) +void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove) { int delta; @@ -1879,7 +1879,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi A_Look (actor); if (actor->target == NULL) { - A_Wander (actor); + if (!dontmove) A_Wander (actor); actor->flags &= ~MF_INCHASE; return; } @@ -1961,7 +1961,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi // it can be just as easily handled by a simple flag so the monsters // can take advantage of all the other enhancements of A_Chase. - if (fastchase) + if (fastchase && !dontmove) { if (actor->special2 > 0) { @@ -2057,7 +2057,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi // // class bosses don't do this when strafing - if (!fastchase || !actor->special2) + if ((!fastchase || !actor->special2) && !dontmove) { // CANTLEAVEFLOORPIC handling was completely missing in the non-serpent functions. fixed_t oldX = actor->x; @@ -2274,7 +2274,8 @@ enum ChaseFlags CHF_FASTCHASE = 1, CHF_NOPLAYACTIVE = 2, CHF_NIGHTMAREFAST = 4, - CHF_RESURRECT = 8 + CHF_RESURRECT = 8, + CHF_DONTMOVE = 16, }; void A_Chase (AActor *actor) @@ -2289,23 +2290,23 @@ void A_Chase (AActor *actor) FState *missile = StateParameters[index+1]==0? NULL : P_GetState(actor, CallingState, StateParameters[index+1]); A_DoChase(actor, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE), - !!(flags&CHF_NIGHTMAREFAST)); + !!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE)); } else // this is the old default A_Chase { - A_DoChase (actor, false, actor->MeleeState, actor->MissileState, true, !!(gameinfo.gametype & GAME_Raven)); + A_DoChase (actor, false, actor->MeleeState, actor->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false); } } void A_FastChase (AActor *actor) { - A_DoChase (actor, true, actor->MeleeState, actor->MissileState, true, true); + A_DoChase (actor, true, actor->MeleeState, actor->MissileState, true, true, false); } void A_VileChase (AActor *actor) { if (!P_CheckForResurrection(actor, true)) - A_DoChase (actor, false, actor->MeleeState, actor->MissileState, true, !!(gameinfo.gametype & GAME_Raven)); + A_DoChase (actor, false, actor->MeleeState, actor->MissileState, true, !!(gameinfo.gametype & GAME_Raven), false); } void A_ExtChase(AActor * self) @@ -2318,7 +2319,7 @@ void A_ExtChase(AActor * self) EvalExpressionI (StateParameters[index], self) ? self->MeleeState:NULL, EvalExpressionI (StateParameters[index+1], self) ? self->MissileState:NULL, EvalExpressionN (StateParameters[index+2], self), - !!EvalExpressionI (StateParameters[index+3], self)); + !!EvalExpressionI (StateParameters[index+3], self), false); } //============================================================================= diff --git a/src/p_map.cpp b/src/p_map.cpp index d82a3014e..7b5601e16 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2151,6 +2151,9 @@ void P_SlideMove (AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) slidemo = mo; hitcount = 3; + + if (mo->player && mo->reactiontime > 0) + return; // player coming right out of a teleporter. retry: if (!--hitcount) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 70b41ea9c..19db53564 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -838,15 +838,22 @@ AInventory *AActor::GiveInventoryType (const PClass *type) bool AActor::GiveAmmo (const PClass *type, int amount) { - AInventory *item = static_cast(Spawn (type, 0, 0, 0, NO_REPLACE)); - item->Amount = amount; - item->flags |= MF_DROPPED; - if (!item->TryPickup (this)) + if (type != NULL) { - item->Destroy (); - return false; + AInventory *item = static_cast(Spawn (type, 0, 0, 0, NO_REPLACE)); + if (item) + { + item->Amount = amount; + item->flags |= MF_DROPPED; + if (!item->TryPickup (this)) + { + item->Destroy (); + return false; + } + return true; + } } - return true; + return false; } //============================================================================ diff --git a/src/p_user.cpp b/src/p_user.cpp index b4d4d70ee..19b883444 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -844,17 +844,20 @@ bool APlayerPawn::UpdateWaterLevel (fixed_t oldz, bool splash) { int oldlevel = waterlevel; bool retval = Super::UpdateWaterLevel (oldz, splash); - if (oldlevel < 3 && waterlevel == 3) - { // Our head just went under. - S_Sound (this, CHAN_VOICE, "*dive", 1, ATTN_NORM); - } - else if (oldlevel == 3 && waterlevel < 3) - { // Our head just came up. - if (player->air_finished > level.time) - { // We hadn't run out of air yet. - S_Sound (this, CHAN_VOICE, "*surface", 1, ATTN_NORM); + if (player != NULL) + { + if (oldlevel < 3 && waterlevel == 3) + { // Our head just went under. + S_Sound (this, CHAN_VOICE, "*dive", 1, ATTN_NORM); + } + else if (oldlevel == 3 && waterlevel < 3) + { // Our head just came up. + if (player->air_finished > level.time) + { // We hadn't run out of air yet. + S_Sound (this, CHAN_VOICE, "*surface", 1, ATTN_NORM); + } + // If we were running out of air, then ResetAirSupply() will play *gasp. } - // If we were running out of air, then ResetAirSupply() will play *gasp. } return retval; } diff --git a/src/thingdef_codeptr.cpp b/src/thingdef_codeptr.cpp index 2a230b249..bc1c08a95 100644 --- a/src/thingdef_codeptr.cpp +++ b/src/thingdef_codeptr.cpp @@ -1964,6 +1964,7 @@ void A_Burst (AActor *actor) mo->momy = pr_burst.Random2 () << (FRACBITS-7); mo->RenderStyle = actor->RenderStyle; mo->alpha = actor->alpha; + mo->CopyFriendliness(actor, true); } } diff --git a/wadsrc/decorate/constants.txt b/wadsrc/decorate/constants.txt index 779530240..51d213954 100644 --- a/wadsrc/decorate/constants.txt +++ b/wadsrc/decorate/constants.txt @@ -19,4 +19,5 @@ const int CHF_FASTCHASE = 1; const int CHF_NOPLAYACTIVE = 2; const int CHF_NIGHTMAREFAST = 4; const int CHF_RESURRECT = 8; +const int CHF_DONTMOVE = 16; diff --git a/wadsrc/decorate/shared/debris.txt b/wadsrc/decorate/shared/debris.txt index 12a5a9658..e34c55f53 100644 --- a/wadsrc/decorate/shared/debris.txt +++ b/wadsrc/decorate/shared/debris.txt @@ -178,6 +178,7 @@ ACTOR SGShard1 : GlassShard Projectile -ACTIVATEMCROSS -ACTIVATEIMPACT + +HEXENBOUNCE BounceFactor 0.3 States { @@ -198,6 +199,7 @@ ACTOR SGShard2 : GlassShard Projectile -ACTIVATEMCROSS -ACTIVATEIMPACT + +HEXENBOUNCE BounceFactor 0.3 States { @@ -218,6 +220,7 @@ ACTOR SGShard3 : GlassShard Projectile -ACTIVATEMCROSS -ACTIVATEIMPACT + +HEXENBOUNCE BounceFactor 0.3 States { @@ -238,6 +241,7 @@ ACTOR SGShard4 : GlassShard Projectile -ACTIVATEMCROSS -ACTIVATEIMPACT + +HEXENBOUNCE BounceFactor 0.3 States { @@ -258,6 +262,7 @@ ACTOR SGShard5 : GlassShard Projectile -ACTIVATEMCROSS -ACTIVATEIMPACT + +HEXENBOUNCE BounceFactor 0.3 States { @@ -278,6 +283,7 @@ ACTOR SGShard6 : GlassShard Projectile -ACTIVATEMCROSS -ACTIVATEIMPACT + +HEXENBOUNCE BounceFactor 0.3 States { @@ -298,6 +304,7 @@ ACTOR SGShard7 : GlassShard Projectile -ACTIVATEMCROSS -ACTIVATEIMPACT + +HEXENBOUNCE BounceFactor 0.3 States { @@ -318,6 +325,7 @@ ACTOR SGShard8 : GlassShard Projectile -ACTIVATEMCROSS -ACTIVATEIMPACT + +HEXENBOUNCE BounceFactor 0.3 States { @@ -338,6 +346,7 @@ ACTOR SGShard9 : GlassShard Projectile -ACTIVATEMCROSS -ACTIVATEIMPACT + +HEXENBOUNCE BounceFactor 0.3 States { @@ -358,6 +367,7 @@ ACTOR SGShard0 : GlassShard Projectile -ACTIVATEMCROSS -ACTIVATEIMPACT + +HEXENBOUNCE BounceFactor 0.3 States {