Added some typedefs for clarity, and also added a cAttack class.

git-svn-id: http://openexile.googlecode.com/svn/trunk@77 4ebdad44-0ea0-11de-aab3-ff745001d230
This commit is contained in:
2009-05-28 23:48:10 +00:00
parent 1af17438f3
commit eeaa9ca599
55 changed files with 289 additions and 272 deletions

View File

@@ -123,3 +123,12 @@ cCreature& cCreature::operator = (legacy::creature_data_type old){
facial_pic = old.monst_start.facial_pic;
return *this;
}
cMonster::cAttack::operator int(){
return dice * 100 + sides;
}
cMonster::cAttack& cMonster::cAttack::operator=(int n){
dice = n / 100;
sides = n % 100;
}

View File

@@ -19,7 +19,7 @@ namespace legacy {
};
/* Monsters Stuff */
/* Skills Same as PC */
typedef unsigned short m_num_t;
/* Monster Type */
enum eMonsterType {
@@ -113,19 +113,25 @@ enum eMonsterType {
class cMonster {
public:
unsigned short m_num;
struct cAttack{
unsigned char dice, sides, type;
// TODO: Remove the need for these operators by changing the code that uses them
operator int();
cAttack& operator=(int n);
};
m_num_t m_num; // TODO: This probably shouldn't be necessary. Consider why it is, and determine if it can be removed
unsigned char level;
std::string m_name;
short health,m_health,mp,max_mp;
short health,m_health,mp,max_mp; // TODO: Move health and mp to cCreature
unsigned char armor,skill;
short a[3];
unsigned char a1_type,a23_type;
cAttack a[3];
unsigned char a1_type,a23_type; // TODO: Delete in favour of type field of cAttack
eMonsterType m_type;
unsigned char speed,ap,mu,cl,breath,breath_type,treasure,spec_skill,poison;
short morale,m_morale;
unsigned char speed,ap,mu,cl,breath,breath_type,treasure,spec_skill,poison; // TODO: Move ap to cCreature
short morale,m_morale; // TODO: Move to cCreature (since these are calculated in-game based on the level)
short corpse_item,corpse_item_chance;
short status[15];
unsigned char direction,immunities,x_width,y_width,radiate_1;
short status[15]; // TODO: Move to cCreature
unsigned char direction,immunities,x_width,y_width,radiate_1; // TODO: Move direction to cCreature
unsigned short radiate_2; // I THINK this is the extra field for the second ability
unsigned char default_attitude,summon_type,default_facial_pic,res1,res2,res3;
short picture_num;
@@ -134,11 +140,11 @@ public:
void writeTo(std::ostream& file, std::string prefix);
};
class cCreature {
class cCreature : public cMonster {
public:
cMonster m_d;
cMonster m_d; // TODO: Delete this member in favour of the inherited fields
unsigned long id;
unsigned short number;
m_num_t number; // TODO: This appears to be a duplicate of cMonster::m_num (ie it's used for the same thing)
short active, attitude;
unsigned char start_attitude;
location start_loc, cur_loc;

View File

@@ -23,8 +23,8 @@ class cOutdoors {
public:
class cWandering { // formerly out_wandering_type
public:
unsigned short monst[7];
unsigned short friendly[3];
m_num_t monst[7];
m_num_t friendly[3];
short spec_on_meet,spec_on_win,spec_on_flee,cant_flee;
short end_spec1,end_spec2;
@@ -41,7 +41,7 @@ public:
cCreature& operator = (legacy::outdoor_creature_type old);
};
unsigned short terrain[48][48];
ter_num_t terrain[48][48];
location special_locs[18];
unsigned short special_id[18];
location exit_locs[8];

View File

@@ -143,7 +143,7 @@ void cBigTown::append(legacy::big_tr_type& old){
}
}
unsigned short& cTinyTown::terrain(size_t x, size_t y){
ter_num_t& cTinyTown::terrain(size_t x, size_t y){
return _terrain[x][y];
}
@@ -159,7 +159,7 @@ unsigned char& cTinyTown::lighting(size_t i, size_t r){
return _lighting[i][r];
}
unsigned short& cMedTown::terrain(size_t x, size_t y){
ter_num_t& cMedTown::terrain(size_t x, size_t y){
return _terrain[x][y];
}
@@ -175,7 +175,7 @@ unsigned char& cMedTown::lighting(size_t i, size_t r){
return _lighting[i][r];
}
unsigned short& cBigTown::terrain(size_t x, size_t y){
ter_num_t& cBigTown::terrain(size_t x, size_t y){
return _terrain[x][y];
}

View File

@@ -19,13 +19,13 @@ namespace legacy {
class cBigTown : public cTown { // formerly big_tr_type
protected:
unsigned short _terrain[64][64];
ter_num_t _terrain[64][64];
rectangle _room_rect[16];
cCreature _creatures[60];
unsigned char _lighting[8][64];
public:
void append(legacy::big_tr_type& old);
unsigned short& terrain(size_t x, size_t y);
ter_num_t& terrain(size_t x, size_t y);
rectangle& room_rect(size_t i);
cCreature& creatures(size_t i);
unsigned char& lighting(size_t i, size_t r);
@@ -39,13 +39,13 @@ public:
class cMedTown : public cTown { // formerly ave_tr_type
protected:
unsigned short _terrain[48][48];
ter_num_t _terrain[48][48];
rectangle _room_rect[16];
cCreature _creatures[40];
unsigned char _lighting[6][48];
public:
void append(legacy::ave_tr_type& old);
unsigned short& terrain(size_t x, size_t y);
ter_num_t& terrain(size_t x, size_t y);
rectangle& room_rect(size_t i);
cCreature& creatures(size_t i);
unsigned char& lighting(size_t i, size_t r);
@@ -59,13 +59,13 @@ public:
class cTinyTown : public cTown { // formerly tiny_tr_type
protected:
unsigned short _terrain[32][32];
ter_num_t _terrain[32][32];
rectangle _room_rect[16];
cCreature _creatures[30];
unsigned char _lighting[4][32];
public:
void append(legacy::tiny_tr_type& old);
unsigned short& terrain(size_t x, size_t y);
ter_num_t& terrain(size_t x, size_t y);
rectangle& room_rect(size_t i);
cCreature& creatures(size_t i);
unsigned char& lighting(size_t i, size_t r);

View File

@@ -16,6 +16,8 @@ namespace legacy { struct terrain_type_type; };
/* Terrains Specials Properties : scenario.ter_types[i].special */ //complete
typedef unsigned short ter_num_t;
enum eTerSpec {
// TER_SPEC_NONE = 0,
// TER_SPEC_CHANGE_WHEN_STEP_ON = 1,
@@ -112,7 +114,7 @@ public:
unsigned short flag2;
unsigned short flag3; // new additional flag for special properties
eTerSpec special;
unsigned short trans_to_what;
ter_num_t trans_to_what;
unsigned char fly_over;
unsigned char boat_over;
unsigned char block_horse;

View File

@@ -14,7 +14,7 @@
#include "classes.h"
unsigned short& cBigTemplTown::terrain(size_t x, size_t y){
ter_num_t& cBigTemplTown::terrain(size_t x, size_t y){
return _terrain[0][0]; // will need to calculate the terrain somehow
}

View File

@@ -24,7 +24,7 @@ public:
class cTerRect { // formerly city_ter_rect_type
public:
rectangle rect;
unsigned short ter_type;
ter_num_t ter_type;
unsigned char hollow;
};
cCityBlock blocks[15];
@@ -35,11 +35,11 @@ public:
class cBigTemplTown : public cBigTown, cTemplTown {
private:
//cCreature _creatures[60];
//unsigned short _terrain[64][64];
//ter_num_t _terrain[64][64];
//rectangle _room_rect[16];
//unsigned char _lighting[4][32];
public:
unsigned short& terrain(size_t x, size_t y);
ter_num_t& terrain(size_t x, size_t y);
rectangle& room_rect(size_t i);
cCreature& creatures(size_t i);
unsigned char& lighting(size_t i, size_t r);
@@ -52,11 +52,11 @@ public:
class cMedTemplTown : public cMedTown, cTemplTown {
private:
//cCreature _creatures[40];
//unsigned short _terrain[48][48];
//ter_num_t _terrain[48][48];
//rectangle _room_rect[16];
//unsigned char _lighting[4][32];
public:
unsigned short& terrain(size_t x, size_t y);
ter_num_t& terrain(size_t x, size_t y);
rectangle& room_rect(size_t i);
cCreature& creatures(size_t i);
unsigned char& lighting(size_t i, size_t r);
@@ -69,11 +69,11 @@ public:
class cTinyTemplTown : public cTinyTown, cTemplTown {
private:
//cCreature _creatures[30];
//unsigned short _terrain[32][32];
//ter_num_t _terrain[32][32];
//rectangle _room_rect[16];
//unsigned char _lighting[4][32];
public:
unsigned short& terrain(size_t x, size_t y);
ter_num_t& terrain(size_t x, size_t y);
rectangle& room_rect(size_t i);
cCreature& creatures(size_t i);
unsigned char& lighting(size_t i, size_t r);

View File

@@ -42,7 +42,7 @@ public:
// };
class cWandering { // formerly wandering_type
public:
unsigned short monst[4];
m_num_t monst[4];
cWandering& operator = (legacy::wandering_type old);
};
@@ -95,7 +95,7 @@ public:
virtual void append(legacy::big_tr_type& old);
virtual void append(legacy::ave_tr_type& old);
virtual void append(legacy::tiny_tr_type& old);
virtual unsigned short& terrain(size_t x, size_t y) = 0;
virtual ter_num_t& terrain(size_t x, size_t y) = 0;
virtual rectangle& room_rect(size_t i) = 0;
virtual cCreature& creatures(size_t i) = 0;
virtual unsigned char& lighting(size_t i, size_t r) = 0;

View File

@@ -663,7 +663,7 @@ unsigned char cCurTown::sfx(char x, char y) const{
return (fields[x][y] & 0x00FF0000) >> 16;
}
unsigned short(& cCurOut::operator [] (size_t i))[96]{
ter_num_t(& cCurOut::operator [] (size_t i))[96]{
return out[i];
}

View File

@@ -36,7 +36,7 @@ public:
cItemRec items[115]; // formerly town_item_list type
//unsigned short template_terrain[64][64];
//ter_num_t template_terrain[64][64];
unsigned long fields[64][64];
bool special_spot[64][64];
// unsigned char trim[64][64]; // transient
@@ -114,7 +114,7 @@ public:
class cCurOut {
public:
char expl[96][96]; // formerly out_info_type
unsigned short out[96][96];
ter_num_t out[96][96];
unsigned char out_e[96][96];
cOutdoors outdoors[2][2];
@@ -123,7 +123,7 @@ public:
void append(legacy::out_info_type& old);
unsigned short(& operator [] (size_t i))[96];
ter_num_t(& operator [] (size_t i))[96];
void writeTo(std::ostream& file);
void readFrom(std::istream& file);
};