- 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.
This commit is contained in:
Christoph Oelckers 2016-11-30 10:55:03 +01:00
parent 014e04ce82
commit 78fa076079
16 changed files with 233 additions and 86 deletions

View file

@ -31,6 +31,7 @@
#include "templates.h" #include "templates.h"
#include "d_net.h" #include "d_net.h"
#include "d_event.h" #include "d_event.h"
#include "a_armor.h"
#define QUEUESIZE 128 #define QUEUESIZE 128
#define MESSAGESIZE 128 #define MESSAGESIZE 128

View file

@ -74,6 +74,7 @@
#include "info.h" #include "info.h"
#include "v_text.h" #include "v_text.h"
#include "vmbuilder.h" #include "vmbuilder.h"
#include "a_armor.h"
// [SO] Just the way Randy said to do it :) // [SO] Just the way Randy said to do it :)
// [RH] Made this CVAR_SERVERINFO // [RH] Made this CVAR_SERVERINFO

View file

@ -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 <assert.h> #include <assert.h>
#include "info.h" #include "info.h"
#include "gi.h" #include "gi.h"
#include "a_pickups.h" #include "a_pickups.h"
#include "a_armor.h"
#include "templates.h" #include "templates.h"
#include "g_level.h" #include "g_level.h"
#include "d_player.h" #include "d_player.h"
@ -15,6 +51,13 @@ IMPLEMENT_CLASS(ABasicArmorPickup, false, false)
IMPLEMENT_CLASS(ABasicArmorBonus, false, false) IMPLEMENT_CLASS(ABasicArmorBonus, false, false)
IMPLEMENT_CLASS(AHexenArmor, false, false) IMPLEMENT_CLASS(AHexenArmor, false, false)
//===========================================================================
//
//
// BasicArmor
//
//
//===========================================================================
DEFINE_FIELD(ABasicArmor, AbsorbCount) DEFINE_FIELD(ABasicArmor, AbsorbCount)
DEFINE_FIELD(ABasicArmor, SavePercent) 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, SavePercent)
DEFINE_FIELD(ABasicArmorPickup, MaxAbsorb) DEFINE_FIELD(ABasicArmorPickup, MaxAbsorb)
DEFINE_FIELD(ABasicArmorPickup, MaxFullAbsorb) DEFINE_FIELD(ABasicArmorPickup, MaxFullAbsorb)
@ -291,10 +343,13 @@ bool ABasicArmorPickup::Use (bool pickup)
//=========================================================================== //===========================================================================
// //
// ABasicArmorBonus //
// BasicArmorBonus
//
// //
//=========================================================================== //===========================================================================
DEFINE_FIELD(ABasicArmorBonus, SavePercent) DEFINE_FIELD(ABasicArmorBonus, SavePercent)
DEFINE_FIELD(ABasicArmorBonus, MaxSaveAmount) DEFINE_FIELD(ABasicArmorBonus, MaxSaveAmount)
DEFINE_FIELD(ABasicArmorBonus, MaxAbsorb) DEFINE_FIELD(ABasicArmorBonus, MaxAbsorb)
@ -406,6 +461,13 @@ bool ABasicArmorBonus::Use (bool pickup)
return true; return true;
} }
//===========================================================================
//
//
// HexenArmor
//
//
//===========================================================================
DEFINE_FIELD(AHexenArmor, Slots) DEFINE_FIELD(AHexenArmor, Slots)
DEFINE_FIELD(AHexenArmor, SlotsIncrement) DEFINE_FIELD(AHexenArmor, SlotsIncrement)
@ -573,6 +635,11 @@ void AHexenArmor::AbsorbDamage (int damage, FName damageType, int &newdamage)
} }
} }
//===========================================================================
//
// AHexenArmor :: DepleteOrDestroy
//
//===========================================================================
void AHexenArmor::DepleteOrDestroy() void AHexenArmor::DepleteOrDestroy()
{ {

89
src/g_inventory/a_armor.h Normal file
View file

@ -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);
};

View file

@ -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 "a_keys.h"
#include "tarray.h" #include "tarray.h"
#include "gi.h" #include "gi.h"
@ -12,6 +45,18 @@
#include "v_font.h" #include "v_font.h"
//===========================================================================
//
// Data for the LOCKDEFS
//
//===========================================================================
//===========================================================================
//
//
//===========================================================================
struct OneKey struct OneKey
{ {
PClassActor *key; PClassActor *key;
@ -45,6 +90,11 @@ struct OneKey
} }
}; };
//===========================================================================
//
//
//===========================================================================
struct Keygroup struct Keygroup
{ {
TArray<OneKey> anykeylist; TArray<OneKey> anykeylist;
@ -59,6 +109,11 @@ struct Keygroup
} }
}; };
//===========================================================================
//
//
//===========================================================================
struct Lock struct Lock
{ {
TArray<Keygroup *> keylist; TArray<Keygroup *> keylist;
@ -100,6 +155,10 @@ struct Lock
} }
}; };
//===========================================================================
//
//
//===========================================================================
static Lock *locks[256]; // all valid locks static Lock *locks[256]; // all valid locks
static bool keysdone=false; // have the locks been initialized? static bool keysdone=false; // have the locks been initialized?
@ -490,6 +549,11 @@ bool AKey::HandlePickup (AInventory *item)
return false; return false;
} }
//===========================================================================
//
//
//===========================================================================
bool AKey::ShouldStay () bool AKey::ShouldStay ()
{ {
return !!multiplayer; return !!multiplayer;

View file

@ -458,91 +458,6 @@ public:
virtual bool Use (bool pickup); 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 // PuzzleItems work in conjunction with the UsePuzzleItem special
class PClassPuzzleItem : public PClassInventory class PClassPuzzleItem : public PClassInventory
{ {

View file

@ -14,6 +14,7 @@
#include "serializer.h" #include "serializer.h"
#include "p_enemy.h" #include "p_enemy.h"
#include "d_player.h" #include "d_player.h"
#include "a_armor.h"
#include "r_data/sprites.h" #include "r_data/sprites.h"
static FRandom pr_morphmonst ("MorphMonster"); static FRandom pr_morphmonst ("MorphMonster");

View file

@ -45,6 +45,7 @@
#include "st_stuff.h" #include "st_stuff.h"
#include "m_swap.h" #include "m_swap.h"
#include "a_keys.h" #include "a_keys.h"
#include "a_armor.h"
#include "templates.h" #include "templates.h"
#include "i_system.h" #include "i_system.h"
#include "sbarinfo.h" #include "sbarinfo.h"

View file

@ -43,6 +43,7 @@
#include "c_cvars.h" #include "c_cvars.h"
#include "w_wad.h" #include "w_wad.h"
#include "a_keys.h" #include "a_keys.h"
#include "a_armor.h"
#include "sbar.h" #include "sbar.h"
#include "sc_man.h" #include "sc_man.h"
#include "templates.h" #include "templates.h"

View file

@ -12,6 +12,7 @@
#include "m_swap.h" #include "m_swap.h"
#include "templates.h" #include "templates.h"
#include "a_keys.h" #include "a_keys.h"
#include "a_armor.h"
#include "gi.h" #include "gi.h"
#include "g_level.h" #include "g_level.h"
#include "colormatcher.h" #include "colormatcher.h"

View file

@ -47,6 +47,7 @@
#include "serializer.h" #include "serializer.h"
#include "r_utility.h" #include "r_utility.h"
#include "a_morph.h" #include "a_morph.h"
#include "a_armor.h"
// [RH] Actually handle the cheat. The cheat code in st_stuff.c now just // [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 // writes some bytes to the network data stream, and the network code

View file

@ -83,6 +83,7 @@
#include "serializer.h" #include "serializer.h"
#include "thingdef.h" #include "thingdef.h"
#include "a_pickups.h" #include "a_pickups.h"
#include "a_armor.h"
extern FILE *Logfile; extern FILE *Logfile;

View file

@ -78,6 +78,7 @@
#include "v_text.h" #include "v_text.h"
#include "thingdef.h" #include "thingdef.h"
#include "math/cmath.h" #include "math/cmath.h"
#include "a_armor.h"
AActor *SingleActorFromTID(int tid, AActor *defactor); AActor *SingleActorFromTID(int tid, AActor *defactor);

View file

@ -69,6 +69,7 @@
#include "thingdef.h" #include "thingdef.h"
#include "d_player.h" #include "d_player.h"
#include "virtual.h" #include "virtual.h"
#include "a_armor.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------

View file

@ -59,6 +59,7 @@
#include "a_morph.h" #include "a_morph.h"
#include "p_spec.h" #include "p_spec.h"
#include "virtual.h" #include "virtual.h"
#include "a_armor.h"
static FRandom pr_skullpop ("SkullPop"); static FRandom pr_skullpop ("SkullPop");

View file

@ -46,6 +46,7 @@
#include "templates.h" #include "templates.h"
#include "r_defs.h" #include "r_defs.h"
#include "a_pickups.h" #include "a_pickups.h"
#include "a_armor.h"
#include "s_sound.h" #include "s_sound.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "p_lnspec.h" #include "p_lnspec.h"