From 78fa0760797b034c885ff90fb7a3441523ed64ff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Nov 2016 10:55:03 +0100 Subject: [PATCH] - moved armor class declarations to their own file and added necessary #includes only to those files actually using them. - added copyright headers to a_armor.cpp and a_keys.cpp. --- src/ct_chat.cpp | 1 + src/d_dehacked.cpp | 1 + src/g_inventory/a_armor.cpp | 69 ++++++++++++++++++++- src/g_inventory/a_armor.h | 89 +++++++++++++++++++++++++++ src/g_inventory/a_keys.cpp | 64 +++++++++++++++++++ src/g_inventory/a_pickups.h | 85 ------------------------- src/g_shared/a_morph.cpp | 1 + src/g_shared/sbarinfo.cpp | 1 + src/g_shared/shared_hud.cpp | 1 + src/g_strife/strife_sbar.cpp | 1 + src/m_cheat.cpp | 1 + src/p_acs.cpp | 1 + src/p_actionfunctions.cpp | 1 + src/p_mobj.cpp | 1 + src/p_user.cpp | 1 + src/scripting/thingdef_properties.cpp | 1 + 16 files changed, 233 insertions(+), 86 deletions(-) create mode 100644 src/g_inventory/a_armor.h diff --git a/src/ct_chat.cpp b/src/ct_chat.cpp index 3c0994a3b4..0a92a58b9c 100644 --- a/src/ct_chat.cpp +++ b/src/ct_chat.cpp @@ -31,6 +31,7 @@ #include "templates.h" #include "d_net.h" #include "d_event.h" +#include "a_armor.h" #define QUEUESIZE 128 #define MESSAGESIZE 128 diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index e9e5a58d0d..630586b0d3 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -74,6 +74,7 @@ #include "info.h" #include "v_text.h" #include "vmbuilder.h" +#include "a_armor.h" // [SO] Just the way Randy said to do it :) // [RH] Made this CVAR_SERVERINFO diff --git a/src/g_inventory/a_armor.cpp b/src/g_inventory/a_armor.cpp index 25d45d35db..ebe8f49f6b 100644 --- a/src/g_inventory/a_armor.cpp +++ b/src/g_inventory/a_armor.cpp @@ -1,8 +1,44 @@ +/* +** a_armor.cpp +** Implements all variations of armor objects +** +**--------------------------------------------------------------------------- +** Copyright 2002-2016 Randy Heit +** Copyright 2006-2016 Cheistoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + #include #include "info.h" #include "gi.h" #include "a_pickups.h" +#include "a_armor.h" #include "templates.h" #include "g_level.h" #include "d_player.h" @@ -15,6 +51,13 @@ IMPLEMENT_CLASS(ABasicArmorPickup, false, false) IMPLEMENT_CLASS(ABasicArmorBonus, false, false) IMPLEMENT_CLASS(AHexenArmor, false, false) +//=========================================================================== +// +// +// BasicArmor +// +// +//=========================================================================== DEFINE_FIELD(ABasicArmor, AbsorbCount) DEFINE_FIELD(ABasicArmor, SavePercent) @@ -198,6 +241,15 @@ void ABasicArmor::AbsorbDamage (int damage, FName damageType, int &newdamage) } } +//=========================================================================== +// +// +// BasicArmorPickup +// +// +//=========================================================================== + + DEFINE_FIELD(ABasicArmorPickup, SavePercent) DEFINE_FIELD(ABasicArmorPickup, MaxAbsorb) DEFINE_FIELD(ABasicArmorPickup, MaxFullAbsorb) @@ -291,10 +343,13 @@ bool ABasicArmorPickup::Use (bool pickup) //=========================================================================== // -// ABasicArmorBonus +// +// BasicArmorBonus +// // //=========================================================================== + DEFINE_FIELD(ABasicArmorBonus, SavePercent) DEFINE_FIELD(ABasicArmorBonus, MaxSaveAmount) DEFINE_FIELD(ABasicArmorBonus, MaxAbsorb) @@ -406,6 +461,13 @@ bool ABasicArmorBonus::Use (bool pickup) return true; } +//=========================================================================== +// +// +// HexenArmor +// +// +//=========================================================================== DEFINE_FIELD(AHexenArmor, Slots) DEFINE_FIELD(AHexenArmor, SlotsIncrement) @@ -573,6 +635,11 @@ void AHexenArmor::AbsorbDamage (int damage, FName damageType, int &newdamage) } } +//=========================================================================== +// +// AHexenArmor :: DepleteOrDestroy +// +//=========================================================================== void AHexenArmor::DepleteOrDestroy() { diff --git a/src/g_inventory/a_armor.h b/src/g_inventory/a_armor.h new file mode 100644 index 0000000000..b7b2dad3e1 --- /dev/null +++ b/src/g_inventory/a_armor.h @@ -0,0 +1,89 @@ +#pragma once + +#include "a_pickups.h" + +// Armor absorbs some damage for the player. +class AArmor : public AInventory +{ + DECLARE_CLASS (AArmor, AInventory) +}; + +// Basic armor absorbs a specific percent of the damage. You should +// never pickup a BasicArmor. Instead, you pickup a BasicArmorPickup +// or BasicArmorBonus and those gives you BasicArmor when it activates. +class ABasicArmor : public AArmor +{ + DECLARE_CLASS (ABasicArmor, AArmor) +public: + + virtual void Serialize(FSerializer &arc); + virtual void Tick (); + virtual AInventory *CreateCopy (AActor *other); + virtual bool HandlePickup (AInventory *item); + virtual void AbsorbDamage (int damage, FName damageType, int &newdamage); + + int AbsorbCount; + double SavePercent; + int MaxAbsorb; + int MaxFullAbsorb; + int BonusCount; + FNameNoInit ArmorType; + int ActualSaveAmount; +}; + +// BasicArmorPickup replaces the armor you have. +class ABasicArmorPickup : public AArmor +{ + DECLARE_CLASS (ABasicArmorPickup, AArmor) +public: + + virtual void Serialize(FSerializer &arc); + virtual AInventory *CreateCopy (AActor *other); + virtual bool Use (bool pickup); + + double SavePercent; + int MaxAbsorb; + int MaxFullAbsorb; + int SaveAmount; +}; + +// BasicArmorBonus adds to the armor you have. +class ABasicArmorBonus : public AArmor +{ + DECLARE_CLASS (ABasicArmorBonus, AArmor) +public: + + virtual void Serialize(FSerializer &arc); + virtual AInventory *CreateCopy (AActor *other); + virtual bool Use (bool pickup); + + double SavePercent; // The default, for when you don't already have armor + int MaxSaveAmount; + int MaxAbsorb; + int MaxFullAbsorb; + int SaveAmount; + int BonusCount; + int BonusMax; +}; + +// Hexen armor consists of four separate armor types plus a conceptual armor +// type (the player himself) that work together as a single armor. +class AHexenArmor : public AArmor +{ + DECLARE_CLASS (AHexenArmor, AArmor) +public: + + virtual void Serialize(FSerializer &arc); + virtual AInventory *CreateCopy (AActor *other); + virtual AInventory *CreateTossable (); + virtual bool HandlePickup (AInventory *item); + virtual void AbsorbDamage (int damage, FName damageType, int &newdamage); + void DepleteOrDestroy(); + + double Slots[5]; + double SlotsIncrement[4]; + +protected: + bool AddArmorToSlot (AActor *actor, int slot, int amount); +}; + diff --git a/src/g_inventory/a_keys.cpp b/src/g_inventory/a_keys.cpp index fc9363be58..a2b5b308a5 100644 --- a/src/g_inventory/a_keys.cpp +++ b/src/g_inventory/a_keys.cpp @@ -1,3 +1,36 @@ +/* +** a_keys.cpp +** Implements all keys and associated data +** +**--------------------------------------------------------------------------- +** Copyright 2005-2016 Cheistoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ #include "a_keys.h" #include "tarray.h" #include "gi.h" @@ -12,6 +45,18 @@ #include "v_font.h" +//=========================================================================== +// +// Data for the LOCKDEFS +// +//=========================================================================== + + +//=========================================================================== +// +// +//=========================================================================== + struct OneKey { PClassActor *key; @@ -45,6 +90,11 @@ struct OneKey } }; +//=========================================================================== +// +// +//=========================================================================== + struct Keygroup { TArray anykeylist; @@ -59,6 +109,11 @@ struct Keygroup } }; +//=========================================================================== +// +// +//=========================================================================== + struct Lock { TArray keylist; @@ -100,6 +155,10 @@ struct Lock } }; +//=========================================================================== +// +// +//=========================================================================== static Lock *locks[256]; // all valid locks static bool keysdone=false; // have the locks been initialized? @@ -490,6 +549,11 @@ bool AKey::HandlePickup (AInventory *item) return false; } +//=========================================================================== +// +// +//=========================================================================== + bool AKey::ShouldStay () { return !!multiplayer; diff --git a/src/g_inventory/a_pickups.h b/src/g_inventory/a_pickups.h index 48afac2268..56caabf3cb 100644 --- a/src/g_inventory/a_pickups.h +++ b/src/g_inventory/a_pickups.h @@ -458,91 +458,6 @@ public: virtual bool Use (bool pickup); }; -// Armor absorbs some damage for the player. -class AArmor : public AInventory -{ - DECLARE_CLASS (AArmor, AInventory) -}; - -// Basic armor absorbs a specific percent of the damage. You should -// never pickup a BasicArmor. Instead, you pickup a BasicArmorPickup -// or BasicArmorBonus and those gives you BasicArmor when it activates. -class ABasicArmor : public AArmor -{ - DECLARE_CLASS (ABasicArmor, AArmor) -public: - - virtual void Serialize(FSerializer &arc); - virtual void Tick (); - virtual AInventory *CreateCopy (AActor *other); - virtual bool HandlePickup (AInventory *item); - virtual void AbsorbDamage (int damage, FName damageType, int &newdamage); - - int AbsorbCount; - double SavePercent; - int MaxAbsorb; - int MaxFullAbsorb; - int BonusCount; - FNameNoInit ArmorType; - int ActualSaveAmount; -}; - -// BasicArmorPickup replaces the armor you have. -class ABasicArmorPickup : public AArmor -{ - DECLARE_CLASS (ABasicArmorPickup, AArmor) -public: - - virtual void Serialize(FSerializer &arc); - virtual AInventory *CreateCopy (AActor *other); - virtual bool Use (bool pickup); - - double SavePercent; - int MaxAbsorb; - int MaxFullAbsorb; - int SaveAmount; -}; - -// BasicArmorBonus adds to the armor you have. -class ABasicArmorBonus : public AArmor -{ - DECLARE_CLASS (ABasicArmorBonus, AArmor) -public: - - virtual void Serialize(FSerializer &arc); - virtual AInventory *CreateCopy (AActor *other); - virtual bool Use (bool pickup); - - double SavePercent; // The default, for when you don't already have armor - int MaxSaveAmount; - int MaxAbsorb; - int MaxFullAbsorb; - int SaveAmount; - int BonusCount; - int BonusMax; -}; - -// Hexen armor consists of four separate armor types plus a conceptual armor -// type (the player himself) that work together as a single armor. -class AHexenArmor : public AArmor -{ - DECLARE_CLASS (AHexenArmor, AArmor) -public: - - virtual void Serialize(FSerializer &arc); - virtual AInventory *CreateCopy (AActor *other); - virtual AInventory *CreateTossable (); - virtual bool HandlePickup (AInventory *item); - virtual void AbsorbDamage (int damage, FName damageType, int &newdamage); - void DepleteOrDestroy(); - - double Slots[5]; - double SlotsIncrement[4]; - -protected: - bool AddArmorToSlot (AActor *actor, int slot, int amount); -}; - // PuzzleItems work in conjunction with the UsePuzzleItem special class PClassPuzzleItem : public PClassInventory { diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index 2f986c201b..ad15cb081c 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -14,6 +14,7 @@ #include "serializer.h" #include "p_enemy.h" #include "d_player.h" +#include "a_armor.h" #include "r_data/sprites.h" static FRandom pr_morphmonst ("MorphMonster"); diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index 4bb9d5b81b..f2852919d8 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -45,6 +45,7 @@ #include "st_stuff.h" #include "m_swap.h" #include "a_keys.h" +#include "a_armor.h" #include "templates.h" #include "i_system.h" #include "sbarinfo.h" diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 4733c6e41b..c6e12918d5 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -43,6 +43,7 @@ #include "c_cvars.h" #include "w_wad.h" #include "a_keys.h" +#include "a_armor.h" #include "sbar.h" #include "sc_man.h" #include "templates.h" diff --git a/src/g_strife/strife_sbar.cpp b/src/g_strife/strife_sbar.cpp index c12c7a7237..3a242f80c3 100644 --- a/src/g_strife/strife_sbar.cpp +++ b/src/g_strife/strife_sbar.cpp @@ -12,6 +12,7 @@ #include "m_swap.h" #include "templates.h" #include "a_keys.h" +#include "a_armor.h" #include "gi.h" #include "g_level.h" #include "colormatcher.h" diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index f5cd568482..6bd6b3862a 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -47,6 +47,7 @@ #include "serializer.h" #include "r_utility.h" #include "a_morph.h" +#include "a_armor.h" // [RH] Actually handle the cheat. The cheat code in st_stuff.c now just // writes some bytes to the network data stream, and the network code diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 96949dd965..93d0cd45b3 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -83,6 +83,7 @@ #include "serializer.h" #include "thingdef.h" #include "a_pickups.h" +#include "a_armor.h" extern FILE *Logfile; diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 99d38b2c1c..8981538e77 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -78,6 +78,7 @@ #include "v_text.h" #include "thingdef.h" #include "math/cmath.h" +#include "a_armor.h" AActor *SingleActorFromTID(int tid, AActor *defactor); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 78487185cd..7c7d97cf2c 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -69,6 +69,7 @@ #include "thingdef.h" #include "d_player.h" #include "virtual.h" +#include "a_armor.h" // MACROS ------------------------------------------------------------------ diff --git a/src/p_user.cpp b/src/p_user.cpp index 66437d4308..e92b560db3 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -59,6 +59,7 @@ #include "a_morph.h" #include "p_spec.h" #include "virtual.h" +#include "a_armor.h" static FRandom pr_skullpop ("SkullPop"); diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index cfadc53bf3..e85b6a1d9f 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -46,6 +46,7 @@ #include "templates.h" #include "r_defs.h" #include "a_pickups.h" +#include "a_armor.h" #include "s_sound.h" #include "cmdlib.h" #include "p_lnspec.h"