Strictify item weapon type enum

This commit is contained in:
2014-12-01 14:57:18 -05:00
parent 3a1de0c890
commit afd45b3774
6 changed files with 36 additions and 32 deletions

View File

@@ -640,7 +640,8 @@ void pc_attack(short who_att,short target)////
// Don't forget awkward and stat adj.
if (weap1 < 24) {
what_skill1 = 2 + univ.party[who_att].items[weap1].type;
// TODO: Find a way to remove this cast
what_skill1 = 2 + (int)univ.party[who_att].items[weap1].type;
// safety valve
if (what_skill1 == 2)
@@ -657,7 +658,7 @@ void pc_attack(short who_att,short target)////
r1 += 25;
// race adj.
if ((univ.party[who_att].race == 2) && (univ.party[who_att].items[weap1].type == 3))
if ((univ.party[who_att].race == 2) && (univ.party[who_att].items[weap1].type == eWeapType::POLE))
r1 -= 10;
r2 = get_ran(1,1,univ.party[who_att].items[weap1].item_level) + dam_adj + 2 + univ.party[who_att].items[weap1].bonus;
@@ -722,7 +723,8 @@ void pc_attack(short who_att,short target)////
}
}
if ((weap2 < 24) && (which_m->active > 0)) {
what_skill2 = 2 + univ.party[who_att].items[weap2].type;
// TODO: Find a way to remove this cast
what_skill2 = 2 + (int)univ.party[who_att].items[weap2].type;
// safety valve
if (what_skill2 == 2)

View File

@@ -262,16 +262,16 @@ static void put_item_info(cDialog& me,short pc,short item)////
case eItemType::ONE_HANDED:
case eItemType::TWO_HANDED:
switch (s_i.type) {
case ITEM_EDGED:
case eWeapType::EDGED:
sprintf((char *) store_text, "Edged weapon");
break;
case ITEM_BASHING:
case eWeapType::BASHING:
sprintf((char *) store_text, "Bashing weapon");
break;
case ITEM_POLE:
case eWeapType::POLE:
sprintf((char *) store_text, "Pole weapon");
break;
case ITEM_NOT_MELEE:
case eWeapType::NOT_MELEE:
default:
sprintf((char*)store_text, "Error weapon"); // should never be reached
}

View File

@@ -341,7 +341,8 @@ void put_item_screen(short screen_num,short suppress_buttons)
sout << univ.party[pc].items[i_num].name << " ";
else { /// Don't place # of charges when Sell button up and space tight
sout << univ.party[pc].items[i_num].full_name << ' ';
if ((univ.party[pc].items[i_num].charges > 0) && (univ.party[pc].items[i_num].type != 2)
// TODO: Why are bashing weapons excluded from this?
if(univ.party[pc].items[i_num].charges > 0 && univ.party[pc].items[i_num].type != eWeapType::BASHING
&& (stat_screen_mode <= 1))
sout << '(' << int(univ.party[pc].items[i_num].charges) << ')';
}

View File

@@ -111,7 +111,7 @@ cItemRec::cItemRec(){
bonus = 0;
protection = 0;
charges = 0;
type = ITEM_NOT_MELEE;
type = eWeapType::NOT_MELEE;
magic_use_type = 0;
graphic_num = 0;
ability = ITEM_NO_ABILITY;
@@ -153,7 +153,7 @@ cItemRec::cItemRec(long preset){
bonus = 1;
protection = 0;
charges = 0;
type = ITEM_EDGED;
type = eWeapType::EDGED;
magic_use_type = 0;
graphic_num = 45;
value = 2;
@@ -169,7 +169,7 @@ cItemRec::cItemRec(long preset){
bonus = 0;
protection = 0;
charges = 0;
type = ITEM_NOT_MELEE;
type = eWeapType::NOT_MELEE;
magic_use_type = 0;
graphic_num = 65;
value = 2;
@@ -185,7 +185,7 @@ cItemRec::cItemRec(long preset){
bonus = 0;
protection = 0;
charges = 0;
type = ITEM_NOT_MELEE;
type = eWeapType::NOT_MELEE;
magic_use_type = 0;
graphic_num = 10;
value = 15;
@@ -201,7 +201,7 @@ cItemRec::cItemRec(long preset){
bonus = 0;
protection = 0;
charges = 12;
type = ITEM_NOT_MELEE;
type = eWeapType::NOT_MELEE;
magic_use_type = 0;
graphic_num = 47;
value = 1;
@@ -217,7 +217,7 @@ cItemRec::cItemRec(long preset){
bonus = 0;
protection = 0;
charges = 0;
type = ITEM_POLE;
type = eWeapType::POLE;
magic_use_type = 0;
graphic_num = 4;
value = 10;
@@ -233,7 +233,7 @@ cItemRec::cItemRec(long preset){
bonus = 0;
protection = 0;
charges = 0;
type = ITEM_NOT_MELEE;
type = eWeapType::NOT_MELEE;
magic_use_type = 0;
graphic_num = 66;
value = 6;
@@ -249,7 +249,7 @@ cItemRec::cItemRec(long preset){
bonus = 0;
protection = 0;
charges = 0;
type = ITEM_NOT_MELEE;
type = eWeapType::NOT_MELEE;
magic_use_type = 0;
graphic_num = 62;
value = 0;
@@ -265,7 +265,7 @@ cItemRec::cItemRec(long preset){
bonus = 0;
protection = 0;
charges = 0;
type = ITEM_NOT_MELEE;
type = eWeapType::NOT_MELEE;
magic_use_type = 0;
graphic_num = 53;
value = 0;
@@ -281,7 +281,7 @@ cItemRec::cItemRec(long preset){
bonus = 0;
protection = 0;
charges = 1;
type = ITEM_NOT_MELEE;
type = eWeapType::NOT_MELEE;
magic_use_type = 0;
graphic_num = 50;
value = 0;
@@ -418,12 +418,13 @@ std::ostream& operator << (std::ostream& out, eItemAbil& e){
return out << (int) e;
}
// TODO: Perhaps this should understand symbolic names as well?
std::istream& operator >> (std::istream& in, eWeapType& e){
int i;
in >> i;
if(i > 0 && i < 4)
e = (eWeapType) i;
else e = ITEM_NOT_MELEE;
else e = eWeapType::NOT_MELEE;
return in;
}

View File

@@ -242,11 +242,11 @@ enum eTrimType {
/* items[i].type a.k.a type of weapon */
enum eWeapType {
ITEM_NOT_MELEE = 0,
ITEM_EDGED = 1,
ITEM_BASHING = 2,
ITEM_POLE = 3,
enum class eWeapType {
NOT_MELEE = 0,
EDGED = 1,
BASHING = 2,
POLE = 3,
};
/* items[i].variety a.k.a item type (in editor) */

View File

@@ -882,14 +882,14 @@ void put_item_info_in_dlog(cDialog& me, cItemRec& store_item, short which_item)
cLedGroup& weapType = dynamic_cast<cLedGroup&>(me["melee-type"]);
switch(store_item.type) {
case ITEM_NOT_MELEE:
case ITEM_EDGED:
case eWeapType::NOT_MELEE:
case eWeapType::EDGED:
weapType.setSelected("edge");
break;
case ITEM_BASHING:
case eWeapType::BASHING:
weapType.setSelected("bash");
break;
case ITEM_POLE:
case eWeapType::POLE:
weapType.setSelected("pole");
break;
}
@@ -939,12 +939,12 @@ bool save_item_info(cDialog& me, cItemRec& store_item, short which_item) {
else if(variety == "missile") store_item.variety = eItemType::MISSILE_NO_AMMO;
else if(variety == "unused1") store_item.variety = eItemType::UNUSED1;
else if(variety == "unused2") store_item.variety = eItemType::UNUSED2;
store_item.type = ITEM_NOT_MELEE;
store_item.type = eWeapType::NOT_MELEE;
if(store_item.variety == eItemType::ONE_HANDED || store_item.variety == eItemType::TWO_HANDED) {
std::string weapType = dynamic_cast<cLedGroup&>(me["melee-type"]).getSelected();
if(weapType == "edge") store_item.type = ITEM_EDGED;
else if(weapType == "bash") store_item.type = ITEM_BASHING;
else if(weapType == "pole") store_item.type = ITEM_POLE;
if(weapType == "edge") store_item.type = eWeapType::EDGED;
else if(weapType == "bash") store_item.type = eWeapType::BASHING;
else if(weapType == "pole") store_item.type = eWeapType::POLE;
}
store_item.item_level = me["level"].getTextAsNum();