SAGA2: Eliminate global objects in weapons.cpp
This commit is contained in:
parent
24eb580ea3
commit
ffc0ed5fd2
9 changed files with 60 additions and 87 deletions
|
@ -39,7 +39,6 @@ enum weaponHitType {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
typedef uint16 weaponID;
|
|
||||||
#define nullWeapon 0
|
#define nullWeapon 0
|
||||||
|
|
||||||
enum combatSound {
|
enum combatSound {
|
||||||
|
|
|
@ -72,60 +72,10 @@ enum effectTypes {
|
||||||
effectTAG, // mana drain, money drain
|
effectTAG, // mana drain, money drain
|
||||||
effectLocation, // mana drain, money drain
|
effectLocation, // mana drain, money drain
|
||||||
effectSpecial,
|
effectSpecial,
|
||||||
effectStrike, // weapon strike effect
|
effectStrike // weapon strike effect
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Attribute effects - look familiar ?
|
|
||||||
//
|
|
||||||
/* all the skill* are now in the spellid enum
|
|
||||||
enum effectAttribTypes {
|
|
||||||
skillArchery = 0,
|
|
||||||
skillSwordcraft = 1,
|
|
||||||
skillShieldcraft = 2,
|
|
||||||
skillBludgeon = 3,
|
|
||||||
skillThrowing = 4,
|
|
||||||
skillSpellcraft = 5,
|
|
||||||
skillStealth = 6,
|
|
||||||
skillAgility = 7,
|
|
||||||
skillBrawn = 8,
|
|
||||||
skillLockpick = 9,
|
|
||||||
skillPilfer = 10,
|
|
||||||
skillFirstAid = 11,
|
|
||||||
skillSpotHidden = 12,
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
// Damage effects - these are the types of damage in the world
|
|
||||||
// Damage being defined as a change in effective vitality
|
|
||||||
// Note that healing is negative damage.
|
|
||||||
//
|
|
||||||
|
|
||||||
enum effectDamageTypes {
|
|
||||||
// Generic
|
|
||||||
damageOther = 0, // Healing, cause wounds
|
|
||||||
// Combat damage
|
|
||||||
damageImpact = 1, // hammers, maces
|
|
||||||
damageSlash = 2, // swords
|
|
||||||
damageProjectile = 3, // arrows, poin-ted sticks
|
|
||||||
// Magic damage
|
|
||||||
damageFire = 4, // Yellow
|
|
||||||
damageAcid = 5, // Violet
|
|
||||||
damageHeat = 6, // Red
|
|
||||||
damageCold = 7, // Blue
|
|
||||||
damageLightning = 8, // Orange
|
|
||||||
damagePoison = 9, // Green
|
|
||||||
// Other magic damage
|
|
||||||
damageMental = 10, // dain bramage
|
|
||||||
damageToUndead = 11, // undead take this damage
|
|
||||||
damageDirMagic = 12, // the plusses on swords etc.
|
|
||||||
// Physiological Damage
|
|
||||||
damageStarve = 13, // You must eat!
|
|
||||||
// other
|
|
||||||
damageEnergy = 14, // Generally hard to resist - god damage
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Resistance Effects - these correspond exactly to the Damage types
|
// Resistance Effects - these correspond exactly to the Damage types
|
||||||
// A separate enum is defined to permit differentiation between
|
// A separate enum is defined to permit differentiation between
|
||||||
|
|
|
@ -230,6 +230,38 @@ typedef uint8 ColorTable[256];
|
||||||
// number of containers
|
// number of containers
|
||||||
const int kNumViews = 3;
|
const int kNumViews = 3;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
kMaxWeapons = 256
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Damage effects - these are the types of damage in the world
|
||||||
|
// Damage being defined as a change in effective vitality
|
||||||
|
// Note that healing is negative damage.
|
||||||
|
//
|
||||||
|
enum effectDamageTypes {
|
||||||
|
// Generic
|
||||||
|
damageOther = 0, // Healing, cause wounds
|
||||||
|
// Combat damage
|
||||||
|
damageImpact = 1, // hammers, maces
|
||||||
|
damageSlash = 2, // swords
|
||||||
|
damageProjectile = 3, // arrows, poin-ted sticks
|
||||||
|
// Magic damage
|
||||||
|
damageFire = 4, // Yellow
|
||||||
|
damageAcid = 5, // Violet
|
||||||
|
damageHeat = 6, // Red
|
||||||
|
damageCold = 7, // Blue
|
||||||
|
damageLightning = 8, // Orange
|
||||||
|
damagePoison = 9, // Green
|
||||||
|
// Other magic damage
|
||||||
|
damageMental = 10, // dain bramage
|
||||||
|
damageToUndead = 11, // undead take this damage
|
||||||
|
damageDirMagic = 12, // the plusses on swords etc.
|
||||||
|
// Physiological Damage
|
||||||
|
damageStarve = 13, // You must eat!
|
||||||
|
// other
|
||||||
|
damageEnergy = 14 // Generally hard to resist - god damage
|
||||||
|
};
|
||||||
|
|
||||||
} // end of namespace Saga2
|
} // end of namespace Saga2
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "saga2/weapons.h"
|
#include "saga2/weapons.h"
|
||||||
#include "saga2/spellbuk.h"
|
#include "saga2/spellbuk.h"
|
||||||
#include "saga2/combat.h"
|
#include "saga2/combat.h"
|
||||||
|
#include "saga2/tile.h"
|
||||||
|
|
||||||
#include "saga2/methods.r"
|
#include "saga2/methods.r"
|
||||||
#include "saga2/pclass.r"
|
#include "saga2/pclass.r"
|
||||||
|
|
|
@ -63,7 +63,7 @@ Saga2Engine::Saga2Engine(OSystem *syst)
|
||||||
|
|
||||||
SearchMan.addSubDirectoryMatching(gameDataDir, "res");
|
SearchMan.addSubDirectoryMatching(gameDataDir, "res");
|
||||||
|
|
||||||
debug("Saga2Engine::Saga2Engine");
|
_loadedWeapons = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Saga2Engine::~Saga2Engine() {
|
Saga2Engine::~Saga2Engine() {
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "engines/engine.h"
|
#include "engines/engine.h"
|
||||||
|
|
||||||
|
#include "saga2/idtypes.h"
|
||||||
|
#include "saga2/weapons.h"
|
||||||
|
|
||||||
namespace Video {
|
namespace Video {
|
||||||
class SmackerDecoder;
|
class SmackerDecoder;
|
||||||
};
|
};
|
||||||
|
@ -74,6 +77,9 @@ public:
|
||||||
// We need random numbers
|
// We need random numbers
|
||||||
Common::RandomSource *_rnd;
|
Common::RandomSource *_rnd;
|
||||||
|
|
||||||
|
WeaponStuff _weaponRack[kMaxWeapons];
|
||||||
|
weaponID _loadedWeapons = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Video::SmackerDecoder *_smkDecoder;
|
Video::SmackerDecoder *_smkDecoder;
|
||||||
int _videoX, _videoY;
|
int _videoX, _videoY;
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "saga2/weapons.h"
|
#include "saga2/weapons.h"
|
||||||
#include "saga2/loadsave.h"
|
#include "saga2/loadsave.h"
|
||||||
#include "saga2/display.h"
|
#include "saga2/display.h"
|
||||||
|
#include "saga2/tile.h"
|
||||||
|
|
||||||
namespace Saga2 {
|
namespace Saga2 {
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include "saga2/std.h"
|
#include "saga2/std.h"
|
||||||
#include "saga2/weapons.h"
|
#include "saga2/weapons.h"
|
||||||
|
#include "saga2/spelshow.h"
|
||||||
#include "saga2/spellbuk.h"
|
#include "saga2/spellbuk.h"
|
||||||
#include "saga2/actor.h"
|
#include "saga2/actor.h"
|
||||||
#include "saga2/spellio.h"
|
#include "saga2/spellio.h"
|
||||||
|
@ -45,28 +46,8 @@ namespace Saga2 {
|
||||||
// which relate to spell casting
|
// which relate to spell casting
|
||||||
//
|
//
|
||||||
|
|
||||||
/* ===================================================================== *
|
|
||||||
Constants
|
|
||||||
* ===================================================================== */
|
|
||||||
|
|
||||||
const int32 maxWeapons = 256;
|
|
||||||
const int32 maxWeaponPrototypes = 256;
|
|
||||||
|
|
||||||
/* ===================================================================== *
|
|
||||||
Global data
|
|
||||||
* ===================================================================== */
|
|
||||||
|
|
||||||
WeaponStuff weaponRack[maxWeapons];
|
|
||||||
weaponID loadedWeapons = 0;
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// prototypes
|
|
||||||
|
|
||||||
static void loadWeaponData(void);
|
static void loadWeaponData(void);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie) {
|
ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie) {
|
||||||
ProtoEffect *pe = NULL;
|
ProtoEffect *pe = NULL;
|
||||||
|
|
||||||
|
@ -157,16 +138,16 @@ void initWeapons(void) {
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
void cleanupWeapons(void) {
|
void cleanupWeapons(void) {
|
||||||
for (int i = 0; i < maxWeapons; i++)
|
for (int i = 0; i < kMaxWeapons; i++)
|
||||||
weaponRack[i].killEffects();
|
g_vm->_weaponRack[i].killEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
WeaponStuff &getWeapon(weaponID i) {
|
WeaponStuff &getWeapon(weaponID i) {
|
||||||
if (i < loadedWeapons)
|
if (i < g_vm->_loadedWeapons)
|
||||||
return weaponRack[i];
|
return g_vm->_weaponRack[i];
|
||||||
return weaponRack[nullWeapon];
|
return g_vm->_weaponRack[nullWeapon];
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -184,7 +165,10 @@ GameObject *getShieldItem(GameObject *defender) {
|
||||||
WeaponProtoEffect member functions
|
WeaponProtoEffect member functions
|
||||||
* ===================================================================== */
|
* ===================================================================== */
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
WeaponProtoEffect::~WeaponProtoEffect(void) {
|
||||||
|
if (effect != NULL)
|
||||||
|
delete effect;
|
||||||
|
}
|
||||||
|
|
||||||
void WeaponProtoEffect::implement(
|
void WeaponProtoEffect::implement(
|
||||||
Actor *enactor,
|
Actor *enactor,
|
||||||
|
@ -338,14 +322,14 @@ static void loadWeaponData(void) {
|
||||||
error("Unable to load weapon effect %d", i);
|
error("Unable to load weapon effect %d", i);
|
||||||
|
|
||||||
if (rie->item) {
|
if (rie->item) {
|
||||||
weaponRack[rie->item].setID(rie->item);
|
g_vm->_weaponRack[rie->item].setID(rie->item);
|
||||||
weaponRack[rie->item].addEffect(rie);
|
g_vm->_weaponRack[rie->item].addEffect(rie);
|
||||||
}
|
}
|
||||||
|
|
||||||
RDisposePtr(rie);
|
RDisposePtr(rie);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
loadedWeapons = i;
|
g_vm->_loadedWeapons = i;
|
||||||
assert(i > 1);
|
assert(i > 1);
|
||||||
|
|
||||||
auxResFile->disposeContext(spellRes);
|
auxResFile->disposeContext(spellRes);
|
||||||
|
|
|
@ -27,12 +27,14 @@
|
||||||
#ifndef SAGA2_WEAPONS_H
|
#ifndef SAGA2_WEAPONS_H
|
||||||
#define SAGA2_WEAPONS_H
|
#define SAGA2_WEAPONS_H
|
||||||
|
|
||||||
#include "saga2/spelshow.h"
|
|
||||||
|
|
||||||
namespace Saga2 {
|
namespace Saga2 {
|
||||||
|
|
||||||
struct ResourceItemEffect;
|
struct ResourceItemEffect;
|
||||||
|
|
||||||
|
class Actor;
|
||||||
|
class GameObject;
|
||||||
|
class ProtoEffect;
|
||||||
|
|
||||||
ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie);
|
ProtoEffect *createNewProtoEffect(ResourceItemEffect *rie);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -59,9 +61,7 @@ public:
|
||||||
WeaponProtoEffect(ResourceItemEffect *rie) :
|
WeaponProtoEffect(ResourceItemEffect *rie) :
|
||||||
effect(createNewProtoEffect(rie)) {
|
effect(createNewProtoEffect(rie)) {
|
||||||
}
|
}
|
||||||
~WeaponProtoEffect(void) {
|
~WeaponProtoEffect(void);
|
||||||
if (effect != NULL) delete effect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void implement(
|
void implement(
|
||||||
Actor *enactor,
|
Actor *enactor,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue