Refactor the various special item arrays into a single structure array

This commit is contained in:
2014-11-29 12:02:28 -05:00
parent c5b1416c33
commit 7aa3ba3794
7 changed files with 20 additions and 16 deletions

View File

@@ -380,7 +380,7 @@ void init_party_scen_data()
// univ.party.party_event_timers[i] = 0;
univ.party.party_event_timers.clear();
for (i = 0; i < 50; i++)
univ.party.spec_items[i] = (scenario.special_items[i] >= 10) ? 1 : 0;
univ.party.spec_items[i] = (scenario.special_items[i].flags >= 10) ? 1 : 0;
for (i = 0; i < 200; i++)
univ.party.m_killed[i] = 0;
@@ -519,7 +519,7 @@ void put_party_in_scen(std::string scen_name)
// this is kludgy, put here to prevent problems
for (i = 0; i < 50; i++)
univ.party.spec_items[i] = (scenario.special_items[i] >= 10) ? 1 : 0;
univ.party.spec_items[i] = (scenario.special_items[i].flags >= 10) ? 1 : 0;
// Compatibility flags
if(scenario.format.prog_make_ver[0] < 2){

View File

@@ -571,7 +571,7 @@ void use_spec_item(short item)
short i,j,k;
location null_loc;
run_special(8,0,scenario.special_item_special[item],loc(),&i,&j,&k);
run_special(8,0,scenario.special_items[item].special,loc(),&i,&j,&k);
}

View File

@@ -292,7 +292,7 @@ void put_item_screen(short screen_num,short suppress_buttons)
win_draw_string(item_stats_gworld,item_buttons[i][0],scenario.scen_strs(60 + spec_item_array[i_num] * 2),0,style);
place_item_button(3,i,4,0);
if ((scenario.special_items[spec_item_array[i_num]] % 10 == 1)
if ((scenario.special_items[spec_item_array[i_num]].flags % 10 == 1)
&& (!(is_combat())))
place_item_button(0,i,3,0);
}

View File

@@ -84,6 +84,15 @@ std::istream& operator >> (std::istream& in, eWeapType& e);
std::istream& operator >> (std::istream& in, eItemType& e);
std::istream& operator >> (std::istream& in, eItemAbil& e);
class cSpecItem {
public:
short flags;
short special;
// TODO: Change to std::string
char name[256];
char descr[256];
};
/*
typedef struct {
short variety, item_level;

View File

@@ -70,9 +70,8 @@ cScenario& cScenario::operator = (legacy::scenario_data_type& old){
}
for(i = 0; i < 3; i++) store_item_towns[i] = old.store_item_towns[i];
flag_e = old.flag_e;
// TODO: Combine these two into a structure
for(i = 0; i < 50; i++) special_items[i] = old.special_items[i];
for(i = 0; i < 50; i++) special_item_special[i] = old.special_item_special[i];
for(i = 0; i < 50; i++) special_items[i].flags = old.special_items[i];
for(i = 0; i < 50; i++) special_items[i].special = old.special_item_special[i];
rating = old.rating;
// TODO: Is this used anywhere?
uses_custom_graphics = old.uses_custom_graphics;
@@ -126,8 +125,8 @@ char(& cScenario::scen_strs(short i))[256]{
if(i >= 4 && i < 10 ) return intro_strs[i - 4];
if(i >= 10 && i < 60 ) return journal_strs[i - 10];
if(i >= 60 && i < 160){
if(i % 2 == 0) return spec_item_names[(i - 60) / 2];
else return spec_item_strs[(i - 60) / 2];
if(i % 2 == 0) return special_items[(i - 60) / 2].name;
else return special_items[(i - 60) / 2].descr;
}
if(i >= 160 && i < 260) return spec_strs[i - 160];
return journal_strs[6]; // random unused slot

View File

@@ -62,8 +62,7 @@ public:
rectangle store_item_rects[3];
short store_item_towns[3];
short flag_e;
short special_items[50];
short special_item_special[50];
cSpecItem special_items[50];
short rating,uses_custom_graphics;
short flag_f;
cMonster scen_monsters[256];
@@ -93,9 +92,6 @@ public:
char contact_info[256];
char intro_strs[6][256];
char journal_strs[50][256];
//char spec_item_strs[100][256];
char spec_item_names[50][256];
char spec_item_strs[50][256];
char spec_strs[100][256];
char monst_strs[100][256];
bool adjust_diff : 1;

View File

@@ -89,8 +89,8 @@ void init_scenario() {
scenario.store_item_towns[i] = -1;
}
for (i = 0; i < 50; i++) {
scenario.special_items[i] = 0;
scenario.special_item_special[i] = -1;
scenario.special_items[i].flags = 0;
scenario.special_items[i].special = -1;
}
scenario.rating = 0;
scenario.uses_custom_graphics = 0;