From 6e5b1f118248af5c97f2ca715fb57085983057fe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Apr 2007 08:44:32 +0000 Subject: [PATCH] - Added a simple check for abstract weapon classes so that I can properly define the DoomWeapon base class. - Fixed: When the Tome of Power runs out it must also set any pending weapon back to their regular state. SVN r521 (trunk) --- docs/rh-log.txt | 6 ++++++ src/g_shared/a_artifacts.cpp | 18 +++++++++++++----- src/g_shared/a_weapons.cpp | 3 ++- src/thingdef.cpp | 20 +++++++++++++++----- wadsrc/decorate/doom/doomweapons.txt | 6 ------ 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 9fdc38fe8c..c87ebe2aeb 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,9 @@ +April 29, 2007 (Changes by Graf Zahl) +- Added a simple check for abstract weapon classes so that I can properly define + the DoomWeapon base class. +- Fixed: When the Tome of Power runs out it must also set any pending weapon + back to their regular state. + April 27, 2007 (Changes by Graf Zahl) - Added damage factors that allows to make monsters more or less resistant to specific damage types. diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 28ea3a76ad..46287e68d8 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1108,13 +1108,21 @@ void APowerWeaponLevel2::EndEffect () { player_t *player = Owner != NULL ? Owner->player : NULL; - if (player != NULL && - player->ReadyWeapon != NULL && - player->ReadyWeapon->WeaponFlags & WIF_POWERED_UP) + if (player != NULL) { - player->ReadyWeapon->EndPowerup (); + + if (player->ReadyWeapon != NULL && + player->ReadyWeapon->WeaponFlags & WIF_POWERED_UP) + { + player->ReadyWeapon->EndPowerup (); + } + if (player->PendingWeapon != NULL && + player->PendingWeapon->WeaponFlags & WIF_POWERED_UP && + player->PendingWeapon->SisterWeapon != NULL) + { + player->PendingWeapon = player->PendingWeapon->SisterWeapon; + } } -// BorderTopRefresh = screen->GetPageCount (); } // Player Speed Trail (used by the Speed Powerup) ---------------------------- diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 0cb9ae49b8..bff055eb47 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -486,7 +486,8 @@ void AWeapon::EndPowerup () { if (GetReadyState() != SisterWeapon->GetReadyState()) { - Owner->player->PendingWeapon = SisterWeapon; + if (Owner->player->PendingWeapon != NULL) + Owner->player->PendingWeapon = SisterWeapon; } else { diff --git a/src/thingdef.cpp b/src/thingdef.cpp index e3291ab0e8..7b7e5c2037 100644 --- a/src/thingdef.cpp +++ b/src/thingdef.cpp @@ -4362,11 +4362,21 @@ void FinishThingdef() if (isRuntimeActor) { - // Do some consistency checks. If these states are undefined the weapon cannot work! - if (!ti->ActorInfo->FindState(NAME_Ready)) I_Error("Weapon %s doesn't define a ready state.\n", ti->TypeName.GetChars()); - if (!ti->ActorInfo->FindState(NAME_Select)) I_Error("Weapon %s doesn't define a select state.\n", ti->TypeName.GetChars()); - if (!ti->ActorInfo->FindState(NAME_Deselect)) I_Error("Weapon %s doesn't define a deselect state.\n", ti->TypeName.GetChars()); - if (!ti->ActorInfo->FindState(NAME_Fire)) I_Error("Weapon %s doesn't define a fire state.\n", ti->TypeName.GetChars()); + FState * ready = ti->ActorInfo->FindState(NAME_Ready); + FState * select = ti->ActorInfo->FindState(NAME_Select); + FState * deselect = ti->ActorInfo->FindState(NAME_Deselect); + FState * fire = ti->ActorInfo->FindState(NAME_Fire); + + // Consider any weapon without any valid state abstract and don't output a warning + // This is for creating base classes for weapon groups that only set up some properties. + if (ready || select || deselect || fire) + { + // Do some consistency checks. If these states are undefined the weapon cannot work! + if (!ready) I_Error("Weapon %s doesn't define a ready state.\n", ti->TypeName.GetChars()); + if (!select) I_Error("Weapon %s doesn't define a select state.\n", ti->TypeName.GetChars()); + if (!deselect) I_Error("Weapon %s doesn't define a deselect state.\n", ti->TypeName.GetChars()); + if (!fire) I_Error("Weapon %s doesn't define a fire state.\n", ti->TypeName.GetChars()); + } } } diff --git a/wadsrc/decorate/doom/doomweapons.txt b/wadsrc/decorate/doom/doomweapons.txt index a0dbf85dfd..2021cfad7c 100644 --- a/wadsrc/decorate/doom/doomweapons.txt +++ b/wadsrc/decorate/doom/doomweapons.txt @@ -12,12 +12,6 @@ ACTOR DoomWeapon : Weapon LightDone: SHTG E 0 A_Light0 Stop - Ready: // get around the consistency checks - Deselect: - Select: - Fire: - TNT1 A 0 - Stop } }