Strictify status types enum
This commit is contained in:
@@ -124,7 +124,8 @@ cCreature& cCreature::operator = (legacy::creature_data_type old){
|
||||
ap = old.m_d.ap;
|
||||
morale = old.m_d.morale;
|
||||
m_morale = old.m_d.m_morale;
|
||||
for(int i = 0; i < 15; i++) status[i] = old.m_d.status[i];
|
||||
for(int i = 0; i < 15; i++)
|
||||
status[(eStatus) i] = old.m_d.status[i];
|
||||
direction = old.m_d.direction;
|
||||
return *this;
|
||||
}
|
||||
@@ -148,12 +149,13 @@ std::ostream& operator << (std::ostream& out, eStatus& e){
|
||||
return out << (int) e;
|
||||
}
|
||||
|
||||
// TODO: This should probably understand symbolic names as well as the numbers?
|
||||
std::istream& operator >> (std::istream& in, eStatus& e){
|
||||
int i;
|
||||
in >> i;
|
||||
if(i > 0 && i < 14)
|
||||
if(i >= 0 && i < 14)
|
||||
e = (eStatus) i;
|
||||
else e = STATUS_POISONED_WEAPON;
|
||||
else e = eStatus::MAIN;
|
||||
return in;
|
||||
}
|
||||
|
||||
@@ -203,7 +205,7 @@ cCreature& cCreature::operator = (const cCreature& other){ // replaces return_mo
|
||||
if(level >= 20) m_morale += 10 * (level - 20);
|
||||
morale = m_morale;
|
||||
direction = 0;
|
||||
for(int i = 0; i < 15; i++) status[i] = 0;
|
||||
status.clear();
|
||||
attitude = start_attitude; // TODO: Is this right?
|
||||
cur_loc = start_loc;
|
||||
target = 6; // No target
|
||||
@@ -276,35 +278,35 @@ cMonster::cAbility::operator std::string(){
|
||||
break;
|
||||
case MONST_STATUS_RAY:
|
||||
case MONST_STATUS_TOUCH:
|
||||
switch(extra1){
|
||||
case STATUS_BLESS_CURSE:
|
||||
switch((eStatus)extra1){
|
||||
case eStatus::BLESS_CURSE:
|
||||
sout << "Curse";
|
||||
break;
|
||||
case STATUS_POISON:
|
||||
case eStatus::POISON:
|
||||
sout << "Poison";
|
||||
i = 1;
|
||||
break;
|
||||
case STATUS_HASTE_SLOW:
|
||||
case eStatus::HASTE_SLOW:
|
||||
sout << "Slowing";
|
||||
break;
|
||||
case STATUS_WEBS:
|
||||
case eStatus::WEBS:
|
||||
sout << "Glue";
|
||||
i = 1;
|
||||
break;
|
||||
case STATUS_DISEASE:
|
||||
case eStatus::DISEASE:
|
||||
sout << "Infectious";
|
||||
i = 1;
|
||||
break;
|
||||
case STATUS_DUMB:
|
||||
case eStatus::DUMB:
|
||||
sout << "Dumbfounding";
|
||||
break;
|
||||
case STATUS_ASLEEP:
|
||||
case eStatus::ASLEEP:
|
||||
sout << "Sleep";
|
||||
break;
|
||||
case STATUS_PARALYZED:
|
||||
case eStatus::PARALYZED:
|
||||
sout << "Paralysis";
|
||||
break;
|
||||
case STATUS_ACID:
|
||||
case eStatus::ACID:
|
||||
sout << "Acid";
|
||||
i = 1;
|
||||
break;
|
||||
@@ -522,9 +524,11 @@ void cCreature::writeTo(std::ostream& file) {
|
||||
file << "FACE " << facial_pic << '\n';
|
||||
file << "TARGET " << target << '\n';
|
||||
file << "TARGLOC " << targ_loc.x << ' ' << targ_loc.y << '\n';
|
||||
for(int i = 0; i < 15; i++)
|
||||
if(status[i] != 0)
|
||||
file << "STATUS " << i << ' ' << status[i] << '\n';
|
||||
for(int i = 0; i < 15; i++) {
|
||||
eStatus stat = (eStatus) i;
|
||||
if(status[stat] != 0)
|
||||
file << "STATUS " << i << ' ' << status[stat] << '\n';
|
||||
}
|
||||
file << "CURHP " << health << '\n';
|
||||
file << "CURSP " << mp << '\n';
|
||||
file << "MORALE " << morale << '\n';
|
||||
@@ -597,10 +601,8 @@ void cCreature::readFrom(std::istream& file) {
|
||||
else if(cur == "DIRECTION")
|
||||
line >> direction;
|
||||
else if(cur == "STATUS") {
|
||||
int i;
|
||||
line >> i;
|
||||
if(i >= 0 && i < 15)
|
||||
line >> status[i];
|
||||
eStatus i;
|
||||
line >> i >> status[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#define BOE_DATA_MONSTER_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <iosfwd>
|
||||
|
||||
#include "soundtool.h"
|
||||
@@ -168,7 +169,7 @@ public:
|
||||
short max_mp;
|
||||
unsigned char ap;
|
||||
short morale,m_morale; // these are calculated in-game based on the level
|
||||
short status[15];
|
||||
std::map<eStatus,short> status;
|
||||
unsigned char direction;
|
||||
|
||||
cCreature();
|
||||
|
@@ -27,8 +27,9 @@ cPlayer& cPlayer::operator = (legacy::pc_record_type old){
|
||||
experience = old.experience;
|
||||
skill_pts = old.skill_pts;
|
||||
level = old.level;
|
||||
// TODO: Why are advan and exp_adj commented out?
|
||||
for(i = 0; i < 15; i++){
|
||||
status[i] = old.status[i];
|
||||
status[(eStatus) i] = old.status[i];
|
||||
//advan[i] = old.advan[i];
|
||||
traits[i] = old.traits[i];
|
||||
}
|
||||
@@ -79,8 +80,6 @@ cPlayer::cPlayer(){
|
||||
experience = 0;
|
||||
skill_pts = 60;
|
||||
level = 1;
|
||||
for (i = 0; i < 15; i++)
|
||||
status[i] = 0;
|
||||
for (i = 0; i < 24; i++)
|
||||
items[i] = cItemRec();
|
||||
for (i = 0; i < 24; i++)
|
||||
@@ -135,8 +134,6 @@ cPlayer::cPlayer(long key,short slot){
|
||||
experience = 0;
|
||||
skill_pts = 60;
|
||||
level = 1;
|
||||
for (i = 0; i < 15; i++)
|
||||
status[i] = 0;
|
||||
for (i = 0; i < 24; i++)
|
||||
items[i] = cItemRec();
|
||||
for (i = 0; i < 24; i++)
|
||||
@@ -211,8 +208,6 @@ cPlayer::cPlayer(long key,short slot){
|
||||
skill_pts = 0;
|
||||
level = 1;
|
||||
|
||||
for (i = 0; i < 15; i++)
|
||||
status[i] = 0;
|
||||
for (i = 0; i < 24; i++)
|
||||
items[i] = cItemRec();
|
||||
for (i = 0; i < 24; i++)
|
||||
@@ -263,9 +258,11 @@ void cPlayer::writeTo(std::ostream& file){
|
||||
file << "EXPERIENCE " << experience << '\n';
|
||||
file << "SKILLPTS " << skill_pts << '\n';
|
||||
file << "LEVEL " << level << '\n';
|
||||
for(int i = 0; i < 15; i++)
|
||||
if(status[i] != 0)
|
||||
file << "STATUS " << i << ' ' << status[i] << '\n';
|
||||
for(int i = 0; i < 15; i++) {
|
||||
eStatus stat = (eStatus) i;
|
||||
if(status[stat] != 0)
|
||||
file << "STATUS " << i << ' ' << status[stat] << '\n';
|
||||
}
|
||||
for(int i = 0; i < 24; i++)
|
||||
if(equip[i])
|
||||
file << "EQUIP " << i << '\n';
|
||||
@@ -302,9 +299,9 @@ void cPlayer::readFrom(std::istream& file){
|
||||
sin.str(cur);
|
||||
sin >> cur;
|
||||
if(cur == "STATUS"){
|
||||
int i;
|
||||
eStatus i;
|
||||
sin >> i;
|
||||
if(i < 0) sin >> main_status;
|
||||
if(i == eStatus::MAIN) sin >> main_status;
|
||||
else sin >> status[i];
|
||||
}else if(cur == "NAME")
|
||||
sin >> name;
|
||||
@@ -332,7 +329,7 @@ void cPlayer::readFrom(std::istream& file){
|
||||
else if(cur == "LEVEL")
|
||||
sin >> level;
|
||||
else if(cur == "STATUS"){
|
||||
int i;
|
||||
eStatus i;
|
||||
sin >> i;
|
||||
sin >> status[i];
|
||||
}else if(cur == "EQUIP"){
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#define BOE_DATA_PC_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <iosfwd>
|
||||
|
||||
#include "simpletypes.h"
|
||||
@@ -31,7 +32,7 @@ public:
|
||||
unsigned short experience;
|
||||
short skill_pts;
|
||||
short level;
|
||||
short status[15];
|
||||
std::map<eStatus,short> status;
|
||||
cItemRec items[24];
|
||||
bool equip[24];
|
||||
bool priest_spells[62];
|
||||
|
@@ -87,21 +87,26 @@ inline bool isHumanoid(eRace race) {
|
||||
}
|
||||
|
||||
/* adven[i].status*/ //complete - assign a positive value for a help pc effect, a negative for harm pc
|
||||
enum eStatus {
|
||||
STATUS_POISONED_WEAPON = 0,
|
||||
STATUS_BLESS_CURSE = 1,
|
||||
STATUS_POISON = 2,
|
||||
STATUS_HASTE_SLOW = 3,
|
||||
STATUS_INVULNERABLE = 4,
|
||||
STATUS_MAGIC_RESISTANCE = 5,
|
||||
STATUS_WEBS = 6,
|
||||
STATUS_DISEASE = 7,
|
||||
STATUS_INVISIBLE = 8, //sanctuary
|
||||
STATUS_DUMB = 9,
|
||||
STATUS_MARTYRS_SHIELD = 10,
|
||||
STATUS_ASLEEP = 11,
|
||||
STATUS_PARALYZED = 12,
|
||||
STATUS_ACID = 13,
|
||||
enum class eStatus {
|
||||
MAIN = -1, // For saved games only
|
||||
POISONED_WEAPON = 0,
|
||||
BLESS_CURSE = 1,
|
||||
POISON = 2,
|
||||
HASTE_SLOW = 3,
|
||||
INVULNERABLE = 4,
|
||||
MAGIC_RESISTANCE = 5,
|
||||
WEBS = 6,
|
||||
DISEASE = 7,
|
||||
INVISIBLE = 8, //sanctuary
|
||||
DUMB = 9,
|
||||
MARTYRS_SHIELD = 10,
|
||||
ASLEEP = 11,
|
||||
PARALYZED = 12,
|
||||
ACID = 13,
|
||||
// This one is new
|
||||
// It's not quite a real status effect since it doesn't expire
|
||||
// We use 15 because 14 was technically a "reserved/unused" status, though I don't think it was ever used for anything
|
||||
CHARM = 15,
|
||||
};
|
||||
|
||||
/* Special Ability a.k.a spec_skill */
|
||||
|
@@ -163,11 +163,11 @@ cTerrain& cTerrain::operator = (legacy::terrain_type_type& old){
|
||||
break;
|
||||
case 5:
|
||||
special = TER_SPEC_DANGEROUS;
|
||||
flag3.u = STATUS_POISON;
|
||||
flag3.u = (int)eStatus::POISON;
|
||||
break;
|
||||
case 6:
|
||||
special = TER_SPEC_DANGEROUS;
|
||||
flag3.u = STATUS_DISEASE;
|
||||
flag3.u = (int)eStatus::DISEASE;
|
||||
break;
|
||||
case 7:
|
||||
special = TER_SPEC_CRUMBLING;
|
||||
|
Reference in New Issue
Block a user