From dd695c352f27764a0c4f1efee5ee1676678162c2 Mon Sep 17 00:00:00 2001 From: haranp Date: Thu, 26 Apr 2007 15:31:53 +0000 Subject: Made item_def::base_type into object_class_type, instead of unsigned char. Flushed out a few bugs as a result, specifically: 1. Some monsters (e.g., orcs) can now get blowguns as they were intended to (look at the makeitem.cc change); 2. Acquirement will no longer attempt to give you the books of minor magic if you've found them (look at the effects.cc change.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1374 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/clua.cc | 2 ++ crawl-ref/source/debug.cc | 2 +- crawl-ref/source/dungeon.cc | 16 ++++++++-------- crawl-ref/source/effects.cc | 14 +++++++------- crawl-ref/source/effects.h | 2 +- crawl-ref/source/externs.h | 2 +- crawl-ref/source/fight.cc | 2 +- crawl-ref/source/fight.h | 2 +- crawl-ref/source/food.cc | 6 ++---- crawl-ref/source/item_use.cc | 1 + crawl-ref/source/itemname.cc | 12 +++++++----- crawl-ref/source/itemname.h | 5 +++-- crawl-ref/source/itemprop.cc | 7 ++++--- crawl-ref/source/itemprop.h | 7 ++++--- crawl-ref/source/items.cc | 11 ++++++----- crawl-ref/source/items.h | 2 +- crawl-ref/source/makeitem.cc | 21 ++++++++++----------- crawl-ref/source/makeitem.h | 2 +- crawl-ref/source/mapdef.cc | 4 ++-- crawl-ref/source/mapdef.h | 3 ++- crawl-ref/source/misc.cc | 8 +++++--- crawl-ref/source/newgame.cc | 1 - crawl-ref/source/randart.cc | 2 +- crawl-ref/source/shopping.cc | 2 ++ crawl-ref/source/stash.cc | 18 +++++------------- crawl-ref/source/stash.h | 2 +- crawl-ref/source/tags.cc | 5 +++-- crawl-ref/source/unrand.h | 4 ++-- 28 files changed, 84 insertions(+), 81 deletions(-) diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 634d4e2740..5a870cd330 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -1313,6 +1313,8 @@ static int l_item_branded(lua_State *ls) case OBJ_MISSILES: branded = get_ammo_brand(*item) != SPMSL_NORMAL; break; + default: + break; } lua_pushboolean(ls, branded); return (1); diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 8469f76639..2af2c160e6 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -496,7 +496,7 @@ void create_spec_object() int mon; int i; - int class_wanted = OBJ_UNASSIGNED; + object_class_type class_wanted = OBJ_UNASSIGNED; int type_wanted = -1; int special_wanted = 0; diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 1e13ea91c4..47382f5090 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -161,7 +161,7 @@ static bool build_vaults(int level_number, int vault_number, int rune_subst = -1 static void build_minivaults(int level_number, int force_vault); static int vault_grid( vault_placement &, int level_number, int vx, int vy, int altar_count, - FixedVector < char, 7 > &acq_item_class, + FixedVector < object_class_type, 7 > &acq_item_class, int vgrid, std::vector &targets, int &num_runes, int rune_subst = -1, bool foll = false); @@ -2045,7 +2045,7 @@ static void builder_items(int level_number, char level_type, int items_wanted) UNUSED( level_type ); int i = 0; - unsigned char specif_type = OBJ_RANDOM; + object_class_type specif_type = OBJ_RANDOM; int items_levels = level_number; int item_no; @@ -2282,7 +2282,7 @@ static void special_room(int level_number, spec_room &sr) int thing_created = 0; int x, y; - unsigned char obj_type = OBJ_RANDOM; // used in calling items() {dlb} + object_class_type obj_type = OBJ_RANDOM; // used in calling items() {dlb} unsigned char i; // general purpose loop variable {dlb} int temp_rand = 0; // probability determination {dlb} @@ -2546,7 +2546,7 @@ static void build_minivaults(int level_number, int force_vault) // isn't generated. int altar_count = 0; - FixedVector < char, 7 > acq_item_class; + FixedVector < object_class_type, 7 > acq_item_class; // hack - passing chars through '...' promotes them to ints, which // barfs under gcc in fixvec.h. So don't. acq_item_class[0] = OBJ_WEAPONS; @@ -2974,7 +2974,7 @@ static bool build_vaults(int level_number, int force_vault, int rune_subst, FixedVector < char, 10 > stair_exist; char stx, sty; - FixedVector < char, 7 > acq_item_class; + FixedVector < object_class_type, 7 > acq_item_class; // hack - passing chars through '...' promotes them to ints, which // barfs under gcc in fixvec.h. So don't. -- GDL acq_item_class[0] = OBJ_WEAPONS; @@ -3255,7 +3255,7 @@ static int vault_grid( vault_placement &place, int level_number, int vx, int vy, int altar_count, - FixedVector < char, 7 > &acq_item_class, + FixedVector < object_class_type, 7 > &acq_item_class, int vgrid, std::vector &targets, int &num_runes, @@ -3378,7 +3378,7 @@ static int vault_grid( vault_placement &place, case 'Z': // definite orb { int item_made = NON_ITEM; - unsigned char which_class = OBJ_RANDOM; + object_class_type which_class = OBJ_RANDOM; unsigned char which_type = OBJ_RANDOM; int which_depth; bool possible_rune = one_chance_in(3); // lame, I know {dlb} @@ -4758,7 +4758,7 @@ static void labyrinth_level(int level_number) finishing: start_point_x = 10 + random2(GXM - 20); - int glopop = OBJ_RANDOM; // used in calling items() {dlb} + object_class_type glopop = OBJ_RANDOM; // used in calling items() {dlb} int num_items = 8 + random2avg(9, 2); for (int i = 0; i < num_items; i++) diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 7e0ade7933..c475b580e2 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -475,13 +475,13 @@ void random_uselessness(unsigned char ru, unsigned char sc_read_2) return; } // end random_uselessness() -bool acquirement(unsigned char force_class, int agent) +bool acquirement(object_class_type force_class, int agent) { int thing_created = 0; int iteration = 0; // Remember lava! - unsigned char class_wanted = OBJ_RANDOM; + object_class_type class_wanted = OBJ_RANDOM; unsigned char type_wanted = OBJ_RANDOM; unsigned char unique = 1; @@ -1202,16 +1202,16 @@ bool acquirement(unsigned char force_class, int agent) if (thing.base_type == OBJ_BOOKS) { - if (thing.base_type == BOOK_MINOR_MAGIC_I - || thing.base_type == BOOK_MINOR_MAGIC_II - || thing.base_type == BOOK_MINOR_MAGIC_III) + if (thing.sub_type == BOOK_MINOR_MAGIC_I + || thing.sub_type == BOOK_MINOR_MAGIC_II + || thing.sub_type == BOOK_MINOR_MAGIC_III) { you.had_book[ BOOK_MINOR_MAGIC_I ] = 1; you.had_book[ BOOK_MINOR_MAGIC_II ] = 1; you.had_book[ BOOK_MINOR_MAGIC_III ] = 1; } - else if (thing.base_type == BOOK_CONJURATIONS_I - || thing.base_type == BOOK_CONJURATIONS_II) + else if (thing.sub_type == BOOK_CONJURATIONS_I + || thing.sub_type == BOOK_CONJURATIONS_II) { you.had_book[ BOOK_CONJURATIONS_I ] = 1; you.had_book[ BOOK_CONJURATIONS_II ] = 1; diff --git a/crawl-ref/source/effects.h b/crawl-ref/source/effects.h index c9817d2f4d..21aa5bdd24 100644 --- a/crawl-ref/source/effects.h +++ b/crawl-ref/source/effects.h @@ -52,7 +52,7 @@ void random_uselessness(unsigned char ru, unsigned char sc_read_2); /* *********************************************************************** * called from: acr - decks - item_use - religion * *********************************************************************** */ -bool acquirement(unsigned char force_class, int agent); +bool acquirement(object_class_type force_class, int agent); // last updated 12may2000 {dlb} diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index c4c737e5a2..de6fabbdeb 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -404,7 +404,7 @@ struct delay_queue_item struct item_def { - unsigned char base_type; // basic class (ie OBJ_WEAPON) + object_class_type base_type; // basic class (ie OBJ_WEAPON) unsigned char sub_type; // type within that class (ie WPN_DAGGER) short plus; // +to hit, charges, corpse mon id short plus2; // +to dam, sub-sub type for boots and helms diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 577b3afdbf..406078c3b0 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -3226,7 +3226,7 @@ bool monsters_fight(int monster_attacking, int monster_attacked) */ // Returns a value between 0 and 10 representing the weight given to str -int weapon_str_weight( int wpn_class, int wpn_type ) +int weapon_str_weight( object_class_type wpn_class, int wpn_type ) { int ret; diff --git a/crawl-ref/source/fight.h b/crawl-ref/source/fight.h index f10d5391d6..8e5a92017c 100644 --- a/crawl-ref/source/fight.h +++ b/crawl-ref/source/fight.h @@ -28,7 +28,7 @@ int effective_stat_bonus( int wepType = -1 ); /* *********************************************************************** * called from: describe.cc * *********************************************************************** */ -int weapon_str_weight( int wpn_class, int wpn_type ); +int weapon_str_weight( object_class_type wpn_class, int wpn_type ); // last updated: 08jun2000 {dlb} diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index 07f03f5dc7..4f81eb3ee5 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -125,10 +125,8 @@ void weapon_switch( int targ ) } else { - // XXX XXX FIXME Why not just use DESC_INVENTORY? - mprf("Switching back to %c - %s.", - index_to_letter(targ), - you.inv[targ].name(DESC_NOCAP_A).c_str()); + mprf("Switching back to %s.", + you.inv[targ].name(DESC_INVENTORY).c_str()); } // unwield the old weapon and wield the new. diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 7de4459216..7460d1baa2 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -1424,6 +1424,7 @@ bool throw_it(struct bolt &pbolt, int throw_2, monsters *dummy_target) // this does not seem right, but value was 11 {dlb} // notice how the .type does not match the class -- hmmm... {dlb} case OBJ_STAVES: pbolt.type = SYM_CHUNK; break; + default: break; } pbolt.source_x = you.x_pos; diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 059d2877e8..14719bd5da 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -1780,6 +1780,8 @@ void item_def::name_aux( char* buff, bool terse, bool ident ) const name_append(" [ice]"); break; } + default: + break; } #undef name_append } @@ -1822,7 +1824,7 @@ void item_def::name_aux( char* buff, bool terse, bool ident ) const } } -item_type_id_type objtype_to_idtype(int base_type) +static item_type_id_type objtype_to_idtype(object_class_type base_type) { switch (base_type) { @@ -1851,7 +1853,7 @@ id_arr& get_typeid_array() return type_ids; } -void set_ident_type( int basetype, int subtype, +void set_ident_type( object_class_type basetype, int subtype, item_type_id_state_type setting, bool force ) { // Don't allow overwriting of known type with tried unless forced. @@ -1868,7 +1870,7 @@ void set_ident_type( int basetype, int subtype, type_ids[idt][subtype] = setting; } -item_type_id_state_type get_ident_type(int basetype, int subtype) +item_type_id_state_type get_ident_type(object_class_type basetype, int subtype) { const item_type_id_type idt = objtype_to_idtype(basetype); if ( idt != NUM_IDTYPE && subtype < type_ids.height() ) @@ -1892,8 +1894,8 @@ void check_item_knowledge() { std::vector items; - const int idx_to_objtype[4] = { OBJ_WANDS, OBJ_SCROLLS, - OBJ_JEWELLERY, OBJ_POTIONS }; + const object_class_type idx_to_objtype[4] = { OBJ_WANDS, OBJ_SCROLLS, + OBJ_JEWELLERY, OBJ_POTIONS }; const int idx_to_maxtype[4] = { NUM_WANDS, NUM_SCROLLS, NUM_JEWELLERY, NUM_POTIONS }; diff --git a/crawl-ref/source/itemname.h b/crawl-ref/source/itemname.h index 915b070fb2..6cc279ecd9 100644 --- a/crawl-ref/source/itemname.h +++ b/crawl-ref/source/itemname.h @@ -60,8 +60,9 @@ int make_name( unsigned long seed, bool all_caps, char buff[ ITEMNAME_SIZE ] ); void init_properties(); id_arr& get_typeid_array(); -item_type_id_state_type get_ident_type(int basetype, int subtype); -void set_ident_type( int basetype, int subtype, +item_type_id_state_type get_ident_type(object_class_type basetype, + int subtype); +void set_ident_type( object_class_type basetype, int subtype, item_type_id_state_type setting, bool force = false); diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 4f37cf22b7..06d048d4a2 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -1216,7 +1216,8 @@ bool does_damage_type( const item_def &item, int dam_type ) } // end does_damage_type() -hands_reqd_type hands_reqd(int base_type, int sub_type, size_type size) +hands_reqd_type hands_reqd(object_class_type base_type, int sub_type, + size_type size) { item_def item; item.base_type = base_type; @@ -1394,7 +1395,7 @@ skill_type weapon_skill( const item_def &item ) } // front function for the above when we don't have a physical item to check -skill_type weapon_skill( int wclass, int wtype ) +skill_type weapon_skill( object_class_type wclass, int wtype ) { item_def wpn; @@ -1416,7 +1417,7 @@ skill_type range_skill( const item_def &item ) } // front function for the above when we don't have a physical item to check -skill_type range_skill( int wclass, int wtype ) +skill_type range_skill( object_class_type wclass, int wtype ) { item_def wpn; diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h index 5536355779..df106f9a1d 100644 --- a/crawl-ref/source/itemprop.h +++ b/crawl-ref/source/itemprop.h @@ -88,7 +88,8 @@ int get_inv_hand_tool( void ); int get_inv_in_hand( void ); hands_reqd_type hands_reqd( const item_def &item, size_type size ); -hands_reqd_type hands_reqd(int base_type, int sub_type, size_type size); +hands_reqd_type hands_reqd(object_class_type base_type, int sub_type, + size_type size); bool is_double_ended( const item_def &item ); int double_wpn_awkward_speed( const item_def &item ); @@ -105,10 +106,10 @@ int weapon_impact_mass( const item_def &wpn ); int weapon_str_required( const item_def &wpn, bool half ); skill_type weapon_skill( const item_def &item ); -skill_type weapon_skill( int wclass, int wtype ); +skill_type weapon_skill( object_class_type wclass, int wtype ); skill_type range_skill( const item_def &item ); -skill_type range_skill( int wclass, int wtype ); +skill_type range_skill( object_class_type wclass, int wtype ); // launcher and ammo functions: bool is_range_weapon( const item_def &item ); diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index af953b7d15..6a7a5098cc 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2960,7 +2960,7 @@ int inv_count(void) } static bool find_subtype_by_name(item_def &item, - int base_type, int ntypes, + object_class_type base_type, int ntypes, const std::string &name) { // In order to get the sub-type, we'll fill out the base type... @@ -3031,7 +3031,7 @@ static bool find_subtype_by_name(item_def &item, // Returns an incomplete item_def with base_type and sub_type set correctly // for the given item name. If the name is not found, sets sub_type to // OBJ_RANDOM. -item_def find_item_type(int base_type, std::string name) +item_def find_item_type(object_class_type base_type, std::string name) { item_def item; item.base_type = OBJ_RANDOM; @@ -3039,7 +3039,7 @@ item_def find_item_type(int base_type, std::string name) lowercase(name); if (base_type == OBJ_RANDOM || base_type == OBJ_UNASSIGNED) - base_type = -1; + base_type = OBJ_UNASSIGNED; static int max_subtype[] = { @@ -3062,14 +3062,15 @@ item_def find_item_type(int base_type, std::string name) 0, // "gemstones" -- no items of type }; - if (base_type == -1) + if (base_type == OBJ_UNASSIGNED) { for (unsigned i = 0; i < sizeof(max_subtype) / sizeof(*max_subtype); ++i) { if (!max_subtype[i]) continue; - if (find_subtype_by_name(item, i, max_subtype[i], name)) + if (find_subtype_by_name(item, static_cast(i), + max_subtype[i], name)) break; } } diff --git a/crawl-ref/source/items.h b/crawl-ref/source/items.h index a209c10515..2c96eab936 100644 --- a/crawl-ref/source/items.h +++ b/crawl-ref/source/items.h @@ -31,7 +31,7 @@ int move_item_to_player( int obj, int quant_got, bool quiet = false ); bool is_stackable_item( const item_def &item ); bool items_stack( const item_def &item1, const item_def &item2 ); -item_def find_item_type(int base_type, std::string name); +item_def find_item_type(object_class_type base_type, std::string name); void init_item( int item ); diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index e0ea2b9e14..71ef9de5ef 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -820,13 +820,15 @@ void item_colour( item_def &item ) case OBJ_GOLD: item.colour = YELLOW; break; + default: + break; } } // end item_colour() // Returns item slot or NON_ITEM if it fails int items( int allow_uniques, // not just true-false, // because of BCR acquirement hack - int force_class, // desired OBJECTS class {dlb} + object_class_type force_class, // desired OBJECTS class {dlb} int force_type, // desired SUBTYPE - enum varies by OBJ bool dont_place, // don't randomly place item on level int item_level, // level of the item, can differ from global @@ -3045,7 +3047,7 @@ static int give_weapon(monsters *mon, int level) int item_race = MAKE_ITEM_RANDOM_RACE; // this flags things to "goto give_armour" below ... {dlb} - item.base_type = 101; + item.base_type = OBJ_UNASSIGNED; if (mon->type == MONS_DANCING_WEAPON && player_in_branch( BRANCH_HALL_OF_BLADES )) @@ -3109,7 +3111,7 @@ static int give_weapon(monsters *mon, int level) if (one_chance_in(12) && level > 1) { item.base_type = OBJ_WEAPONS; - item.base_type = WPN_BLOWGUN; + item.sub_type = WPN_BLOWGUN; break; } // deliberate fall through {dlb} @@ -3169,7 +3171,7 @@ static int give_weapon(monsters *mon, int level) if (one_chance_in(15) && level > 1) { item.base_type = OBJ_WEAPONS; - item.base_type = WPN_BLOWGUN; + item.sub_type = WPN_BLOWGUN; break; } // deliberate fall through {gdl} @@ -3606,11 +3608,8 @@ static int give_weapon(monsters *mon, int level) } // end "switch(mon->type)" // only happens if something in above switch doesn't set it {dlb} - if (item.base_type == 101) - { - item.base_type = OBJ_UNASSIGNED; + if (item.base_type == OBJ_UNASSIGNED) return (item_race); - } item.x = 0; item.y = 0; @@ -3626,7 +3625,7 @@ static int give_weapon(monsters *mon, int level) level += 5; } - const int xitc = item.base_type; + const object_class_type xitc = item.base_type; const int xitt = item.sub_type; // Note this mess, all the work above doesn't mean much unless @@ -3651,7 +3650,7 @@ static void give_ammo(monsters *mon, int level, int item_race) if (mon->inv[MSLOT_WEAPON] != NON_ITEM && is_range_weapon( mitm[mon->inv[MSLOT_WEAPON]] )) { - const int xitc = OBJ_MISSILES; + const object_class_type xitc = OBJ_MISSILES; const int xitt = fires_ammo_type(mitm[mon->inv[MSLOT_WEAPON]]); const int thing_created = @@ -3839,7 +3838,7 @@ void give_armour(monsters *mon, int level) return; } // end of switch(menv [mid].type) - const int xitc = mitm[bp].base_type; + const object_class_type xitc = mitm[bp].base_type; const int xitt = mitm[bp].sub_type; if (mons_is_unique( mon->type ) && level != MAKE_GOOD_ITEM) diff --git a/crawl-ref/source/makeitem.h b/crawl-ref/source/makeitem.h index d0f1236034..62d0ee1db3 100644 --- a/crawl-ref/source/makeitem.h +++ b/crawl-ref/source/makeitem.h @@ -10,7 +10,7 @@ #include "dungeon.h" -int items( int allow_uniques, int force_class, int force_type, +int items( int allow_uniques, object_class_type force_class, int force_type, bool dont_place, int item_level, int item_race, const dgn_region_list &forbidden = dgn_region_list() ); diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 42849a8a17..1535b2ffa0 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -1174,7 +1174,7 @@ void item_list::parse_random_by_class(std::string c, item_spec &spec) { if (c == item_class_name(type, true)) { - spec.base_type = type; + spec.base_type = static_cast(type); return; } } @@ -1191,7 +1191,7 @@ void item_list::parse_raw_name(std::string name, item_spec &spec) return ; } - item_def parsed = find_item_type(-1, name); + item_def parsed = find_item_type(OBJ_UNASSIGNED, name); if (parsed.sub_type != OBJ_RANDOM) { spec.base_type = parsed.base_type; diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h index 8a9762e3fa..20940a0c77 100644 --- a/crawl-ref/source/mapdef.h +++ b/crawl-ref/source/mapdef.h @@ -221,7 +221,8 @@ struct item_spec { int genweight; - int base_type, sub_type; + object_class_type base_type; + int sub_type; int allow_uniques; int level; int race; diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 59325a947f..dbc1d633cb 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -70,7 +70,8 @@ #include "view.h" bool scramble(void); -bool trap_item(char base_type, char sub_type, char beam_x, char beam_y); +static bool trap_item(object_class_type base_type, char sub_type, + char beam_x, char beam_y); static void dart_trap(bool trap_known, int trapped, struct bolt &pbolt, bool poison); // void place_chunks(int mcls, unsigned char rot_status, unsigned char chx, @@ -1257,7 +1258,7 @@ static void dart_trap( bool trap_known, int trapped, struct bolt &pbolt, void itrap( struct bolt &pbolt, int trapped ) { - int base_type = OBJ_MISSILES; + object_class_type base_type = OBJ_MISSILES; int sub_type = MI_DART; switch (env.trap[trapped].type) @@ -1694,7 +1695,8 @@ bool go_berserk(bool intentional) return true; } // end go_berserk() -bool trap_item(char base_type, char sub_type, char beam_x, char beam_y) +bool trap_item(object_class_type base_type, char sub_type, + char beam_x, char beam_y) { item_def item; diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index b936b6d44a..47a6e58fb6 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -72,7 +72,6 @@ #include "abl-show.h" #include "branch.h" #include "command.h" -//#include "dungeon.h" #include "files.h" #include "fight.h" #include "initfile.h" diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc index d0a6775ab3..55884bcdad 100644 --- a/crawl-ref/source/randart.cc +++ b/crawl-ref/source/randart.cc @@ -632,7 +632,7 @@ struct unrandart_entry const char *name; // true name of unrandart (max 31 chars) const char *unid_name; // un-id'd name of unrandart (max 31 chars) - int ura_cl; // class of ura + object_class_type ura_cl; // class of ura int ura_ty; // type of ura int ura_pl; // plus of ura int ura_pl2; // plus2 of ura diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc index 9d27d4d898..7644b93220 100644 --- a/crawl-ref/source/shopping.cc +++ b/crawl-ref/source/shopping.cc @@ -1493,6 +1493,8 @@ unsigned int item_value( item_def item, bool ident ) case OBJ_ORBS: valued = 250000; break; + default: + break; } // end switch if (valued < 1) diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index 92b400cc33..3d874cd044 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -143,7 +143,7 @@ static void save_item(FILE *file, const item_def &item) static void load_item(FILE *file, item_def &item) { - item.base_type = readByte(file); + item.base_type = static_cast(readByte(file)); item.sub_type = readByte(file); item.plus = readShort(file); item.plus2 = readShort(file); @@ -212,11 +212,12 @@ void Stash::filter(const std::string &str) base = base.substr(0, cpos); } - unsigned char basec = atoi(base.c_str()); + const object_class_type basec = + static_cast(atoi(base.c_str())); filter(basec, subc); } -void Stash::filter(unsigned char base, unsigned char sub) +void Stash::filter(object_class_type base, unsigned char sub) { item_def item; item.base_type = base; @@ -353,16 +354,7 @@ void Stash::update() // stash-tracking pre/suffixes. std::string Stash::stash_item_name(const item_def &item) { - char buf[ITEMNAME_SIZE]; - - // XXX XXX FIXME why the special-casing? - if (item.base_type == OBJ_GOLD) - snprintf(buf, sizeof buf, "%d gold piece%s", item.quantity, - (item.quantity > 1? "s" : "")); - else - return item.name(DESC_NOCAP_A); - - return buf; + return item.name(DESC_NOCAP_A); } class StashMenu : public InvMenu diff --git a/crawl-ref/source/stash.h b/crawl-ref/source/stash.h index 2a8becbce6..af11c6389e 100644 --- a/crawl-ref/source/stash.h +++ b/crawl-ref/source/stash.h @@ -36,7 +36,7 @@ class Stash public: Stash(int xp = -1, int yp = -1); - static void filter(unsigned char base_type, unsigned char sub_type); + static void filter(object_class_type base_type, unsigned char sub_type); static void filter(const std::string &filt); static std::string stash_item_name(const item_def &item); diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 767675f544..695f602437 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -1148,7 +1148,8 @@ static void tag_read_you_items(struct tagHeader &th, char minorVersion) { you.inv[i].orig_monnum = you.inv[i].orig_place = 0; you.inv[i].inscription.clear(); - you.inv[i].base_type = (unsigned char) unmarshallByte(th); + you.inv[i].base_type = + static_cast(unmarshallByte(th)); you.inv[i].sub_type = (unsigned char) unmarshallByte(th); you.inv[i].plus = unmarshallShort(th); you.inv[i].special = unmarshallLong(th); @@ -1362,7 +1363,7 @@ static void marshall_item(tagHeader &th, const item_def &item) static void unmarshall_item(tagHeader &th, item_def &item) { - item.base_type = (unsigned char) unmarshallByte(th); + item.base_type = static_cast(unmarshallByte(th)); item.sub_type = (unsigned char) unmarshallByte(th); item.plus = unmarshallShort(th); item.plus2 = unmarshallShort(th); diff --git a/crawl-ref/source/unrand.h b/crawl-ref/source/unrand.h index 73e8bfa60e..4548652883 100644 --- a/crawl-ref/source/unrand.h +++ b/crawl-ref/source/unrand.h @@ -134,7 +134,7 @@ { "Dum", "", /* class, type, plus (to-hit), plus2 (depends on class), colour */ - 250, 250, 250, 250, 0, + OBJ_UNASSIGNED, 250, 250, 250, 0, /* Properties, all approx thirty of them: */ { /* brand, +/- to AC, +/- to ev, +/- to str, +/- to int, +/- to dex */ @@ -1134,7 +1134,7 @@ { "Dum", "", /* class, type, plus (to-hit), plus2 (depends on class), colour */ - 250, 250, 250, 250, 0, + OBJ_UNASSIGNED, 250, 250, 250, 0, /* Properties, all approx thirty of them: */ { /* brand, +/- to AC, +/- to ev, +/- to str, +/- to int, +/- to dex */ -- cgit v1.2.3-54-g00ecf