From e11cac7e893d1cf2792ce2195758456d7c4eb5ad Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Jun 2009 21:00:18 +0000 Subject: [PATCH] - Changed AWeaponGiver to keep the weapon actor around instead of respawning a new one for each call. - Fixed: AWeaponGiver::TryPickup checked the wrong item for ammo to give. - fixed: FRandom::Random2(int mask) must return the difference between 2 byte values for compatibility. - fixed: The sound name world/volcano/shoot was accidentally destroyed in the source. SVN r1671 (trunk) --- docs/rh-log.txt | 10 +++++++++- src/g_heretic/a_hereticmisc.cpp | 2 +- src/g_shared/a_weapons.cpp | 25 ++++++++++++++++--------- src/m_random.h | 4 ++-- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 8e2093780..b4f4d32e0 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,12 @@ -June 16, 2009 (Changes by Graf Zahl) +June 19, 2009 (Changes by Graf Zahl) +- Changed AWeaponGiver to keep the weapon actor around instead of respawning a new + one for each call. +- Fixed: AWeaponGiver::TryPickup checked the wrong item for ammo to give. +- fixed: FRandom::Random2(int mask) must return the difference between 2 byte values + for compatibility. +- fixed: The sound name world/volcano/shoot was accidentally destroyed in the source. + +June 16, 2009 (Changes by Graf Zahl) - Reintroduced damage thrust clamping but with a higher threshold. The clamping is now also done in floating point before any fixed point overflows can occur. diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp index d4ffc8798..67f2d4d0c 100644 --- a/src/g_heretic/a_hereticmisc.cpp +++ b/src/g_heretic/a_hereticmisc.cpp @@ -173,7 +173,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcanoBlast) blast->momx = FixedMul (1*FRACUNIT, finecosine[angle]); blast->momy = FixedMul (1*FRACUNIT, finesine[angle]); blast->momz = (FRACUNIT*5/2) + (pr_blast() << 10); - S_Sound (blast, CHAN_BODY, "world/self/shoot", 1, ATTN_NORM); + S_Sound (blast, CHAN_BODY, "world/volcano/shoot", 1, ATTN_NORM); P_CheckMissileSpawn (blast); } } diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 0bd4f6b54..8698c9342 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -618,23 +618,30 @@ IMPLEMENT_CLASS(AWeaponGiver) bool AWeaponGiver::TryPickup(AActor *&toucher) { FDropItem *di = GetDropItems(); + AWeapon *weap; if (di != NULL) { const PClass *ti = PClass::FindClass(di->Name); if (ti->IsDescendantOf(RUNTIME_CLASS(AWeapon))) { - AWeapon *weap = static_cast(Spawn(di->Name, 0, 0, 0, NO_REPLACE)); - if (weap != NULL) + if (master == NULL) { - weap->ItemFlags &= ~IF_ALWAYSPICKUP; // use the flag of this item only. - if (weap->AmmoGive1 >= 0) weap->AmmoGive1 = AmmoGive1; - if (weap->AmmoGive2 >= 0) weap->AmmoGive2 = AmmoGive2; - bool res = weap->CallTryPickup(toucher); - if (!res) weap->Destroy(); - else GoAwayAndDie(); - return res; + master = weap = static_cast(Spawn(di->Name, 0, 0, 0, NO_REPLACE)); + if (weap != NULL) + { + weap->ItemFlags &= ~IF_ALWAYSPICKUP; // use the flag of this item only. + if (AmmoGive1 >= 0) weap->AmmoGive1 = AmmoGive1; + if (AmmoGive2 >= 0) weap->AmmoGive2 = AmmoGive2; + weap->BecomeItem(); + } + else return false; } + + weap = barrier_cast(master); + bool res = weap->CallTryPickup(toucher); + if (res) GoAwayAndDie(); + return res; } } return false; diff --git a/src/m_random.h b/src/m_random.h index 6b00d72a7..5b124c50e 100644 --- a/src/m_random.h +++ b/src/m_random.h @@ -69,8 +69,8 @@ public: // Returns (rand# & mask) - (rand# & mask) int Random2(int mask) { - int t = GenRand32() & mask; - return t - (GenRand32() & mask); + int t = GenRand32() & mask & 255; + return t - (GenRand32() & mask & 255); } // HITDICE macro used in Heretic and Hexen