--- deliantra/server/common/item.C 2010/04/04 02:57:10 1.80 +++ deliantra/server/common/item.C 2010/04/11 00:34:05 1.83 @@ -73,14 +73,14 @@ "eighty", "ninety" }; -static char levelnumbers[21][20] = { +static char ordnumbers[21][20] = { "zeroth", "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", - "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteen", - "nineteen", "twentieth" + "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", + "nineteenth", "twentieth" }; -static char levelnumbers_10[11][20] = { +static char ordnumbers_10[11][20] = { "zeroth", "tenth", "twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth", "seventieth", "eightieth", "ninetieth" }; @@ -153,7 +153,7 @@ {SHOP_FLOOR, "shop floor", "shop floors", 0, 0}, {SHOP_MAT, "shop mat", "shop mats", 0, 0}, {RING, "ring", "rings", SK_JEWELER, 0}, - {FLOOR, "floor", "floors", 0, 0}, +// {FLOOR, "floor", "floors", 0, 0}, {FLESH, "flesh", "flesh", SK_WOODSMAN, 0}, {INORGANIC, "inorganic", "inorganics", SK_ALCHEMY, 0}, {SKILL_TOOL, "skill tool", "skill tools", 0, 0}, @@ -389,25 +389,29 @@ * the number requested (of the form first, second, third...) */ const char * -get_levelnumber (int i) +ordinal (int i) { - static char buf[MAX_BUF]; - - if (i > 99) - { - sprintf (buf, "%d.", i); - return buf; - } + if (i < 0) + return format ("minus %s", ordinal (-i)); if (i < 21) - return levelnumbers[i]; + return ordnumbers[i]; - if (!(i % 10)) - return levelnumbers_10[i / 10]; + int digit = i % 10; - strcpy (buf, numbers_10[i / 10]); - strcat (buf, levelnumbers[i % 10]); - return buf; + if (i >= 100) + return format ( + digit == 1 ? "%dst" + : digit == 2 ? "%dnd" + : digit == 3 ? "%drd" + : "%dth", + i + ); + + if (digit == 0) + return ordnumbers_10[i / 10]; + else + return format ("%s%s", numbers_10[i / 10], ordnumbers[i % 10]); } /* @@ -429,7 +433,7 @@ static dynbuf_text buf; buf.clear (); int attr, val, len; - if (QUERY_FLAG (op, FLAG_IDENTIFIED)) + if (op->flag [FLAG_IDENTIFIED]) { for (attr = 0; attr < NUM_STATS; attr++) if ((val = op->stats.stat (attr))) @@ -448,10 +452,10 @@ if (op->stats.hp) buf.printf ("(regeneration%+d)", op->stats.hp); if (op->stats.luck) buf.printf ("(luck%+d)", op->stats.luck); - if (QUERY_FLAG (op, FLAG_LIFESAVE)) buf << "(lifesaving)"; - if (QUERY_FLAG (op, FLAG_REFL_SPELL)) buf << "(reflect spells)"; - if (QUERY_FLAG (op, FLAG_REFL_MISSILE)) buf << "(reflect missiles)"; - if (QUERY_FLAG (op, FLAG_STEALTH)) buf << "(stealth)"; + if (op->flag [FLAG_LIFESAVE]) buf << "(lifesaving)"; + if (op->flag [FLAG_REFL_SPELL]) buf << "(reflect spells)"; + if (op->flag [FLAG_REFL_MISSILE]) buf << "(reflect missiles)"; + if (op->flag [FLAG_STEALTH]) buf << "(stealth)"; buf.add_paths ("Attuned" , op->path_attuned); buf.add_paths ("Repelled", op->path_repelled); @@ -487,7 +491,7 @@ buf << (op->nrof <= 1 ? op->name : op->name_pl); - if (op->title && QUERY_FLAG (op, FLAG_IDENTIFIED)) + if (op->title && op->flag [FLAG_IDENTIFIED]) buf << ' ' << op->title; switch (op->type) @@ -496,7 +500,7 @@ case SCROLL: case WAND: case ROD: - if (QUERY_FLAG (op, FLAG_IDENTIFIED) || QUERY_FLAG (op, FLAG_BEEN_APPLIED)) + if (op->flag [FLAG_IDENTIFIED] || op->flag [FLAG_BEEN_APPLIED]) { if (!op->title) buf << " of " << (op->inv ? &op->inv->name : "bug, please report"); @@ -545,7 +549,7 @@ break; default: - if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) + if (op->magic && ((op->flag [FLAG_BEEN_APPLIED] && need_identify (op)) || op->flag [FLAG_IDENTIFIED])) buf.printf (" %+d", op->magic); } @@ -586,16 +590,16 @@ buf << query_short_name (op); - if (QUERY_FLAG (op, FLAG_INV_LOCKED)) + if (op->flag [FLAG_INV_LOCKED]) buf << " *"; if (op->is_open_container ()) buf << " (open)"; - if (QUERY_FLAG (op, FLAG_KNOWN_CURSED)) + if (op->flag [FLAG_KNOWN_CURSED]) { - if (QUERY_FLAG (op, FLAG_DAMNED)) + if (op->flag [FLAG_DAMNED]) buf << " (damned)"; - else if (QUERY_FLAG (op, FLAG_CURSED)) + else if (op->flag [FLAG_CURSED]) buf << " (cursed)"; } @@ -608,7 +612,7 @@ * if it has been applied. Equipping an item does not tell full * abilities, especially for artifact items. */ - if (QUERY_FLAG (op, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (op, FLAG_IDENTIFIED)) + if (op->flag [FLAG_KNOWN_MAGICAL] && !op->flag [FLAG_IDENTIFIED]) buf << " (magic)"; #if 0 @@ -620,7 +624,7 @@ #endif - if (QUERY_FLAG (op, FLAG_APPLIED)) + if (op->flag [FLAG_APPLIED]) { switch (op->type) { @@ -673,7 +677,7 @@ break; } - if (QUERY_FLAG (op, FLAG_UNPAID)) + if (op->flag [FLAG_UNPAID]) buf << " (unpaid)"; return buf; @@ -712,7 +716,7 @@ buf << (plural ? op->name_pl : op->name); - if (op->title && QUERY_FLAG (op, FLAG_IDENTIFIED)) + if (op->title && op->flag [FLAG_IDENTIFIED]) buf << ' ' << op->title; switch (op->type) @@ -721,7 +725,7 @@ case SCROLL: case WAND: case ROD: - if (QUERY_FLAG (op, FLAG_IDENTIFIED) || QUERY_FLAG (op, FLAG_BEEN_APPLIED)) + if (op->flag [FLAG_IDENTIFIED] || op->flag [FLAG_BEEN_APPLIED]) { if (!op->title) buf << " of " << (op->inv ? &op->inv->name : "bug, please report"); @@ -754,7 +758,7 @@ break; default: - if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) + if (op->magic && ((op->flag [FLAG_BEEN_APPLIED] && need_identify (op)) || op->flag [FLAG_IDENTIFIED])) buf.printf (" %+d", op->magic); } @@ -807,20 +811,20 @@ break; } - if (QUERY_FLAG (op, FLAG_UNDEAD)) buf << "(undead)"; - if (QUERY_FLAG (op, FLAG_SEE_INVISIBLE)) buf << "(see invisible)"; - if (QUERY_FLAG (op, FLAG_USE_WEAPON)) buf << "(wield weapon)"; - if (QUERY_FLAG (op, FLAG_USE_BOW)) buf << "(archer)"; - if (QUERY_FLAG (op, FLAG_USE_ARMOUR)) buf << "(wear armour)"; - if (QUERY_FLAG (op, FLAG_USE_RING)) buf << "(wear ring)"; - if (QUERY_FLAG (op, FLAG_USE_SCROLL)) buf << "(read scroll)"; - if (QUERY_FLAG (op, FLAG_USE_RANGE)) buf << "(fires wand/rod/horn)"; - if (QUERY_FLAG (op, FLAG_CAN_USE_SKILL)) buf << "(skill user)"; - if (QUERY_FLAG (op, FLAG_CAST_SPELL)) buf << "(spellcaster)"; - if (QUERY_FLAG (op, FLAG_FRIENDLY)) buf << "(friendly)"; - if (QUERY_FLAG (op, FLAG_UNAGGRESSIVE)) buf << "(unaggressive)"; - if (QUERY_FLAG (op, FLAG_HITBACK)) buf << "(hitback)"; - if (QUERY_FLAG (op, FLAG_STEALTH)) buf << "(stealthy)"; + if (op->flag [FLAG_UNDEAD]) buf << "(undead)"; + if (op->flag [FLAG_SEE_INVISIBLE]) buf << "(see invisible)"; + if (op->flag [FLAG_USE_WEAPON]) buf << "(wield weapon)"; + if (op->flag [FLAG_USE_BOW]) buf << "(archer)"; + if (op->flag [FLAG_USE_ARMOUR]) buf << "(wear armour)"; + if (op->flag [FLAG_USE_RING]) buf << "(wear ring)"; + if (op->flag [FLAG_USE_SCROLL]) buf << "(read scroll)"; + if (op->flag [FLAG_USE_RANGE]) buf << "(fires wand/rod/horn)"; + if (op->flag [FLAG_CAN_USE_SKILL]) buf << "(skill user)"; + if (op->flag [FLAG_CAST_SPELL]) buf << "(spellcaster)"; + if (op->flag [FLAG_FRIENDLY]) buf << "(friendly)"; + if (op->flag [FLAG_UNAGGRESSIVE]) buf << "(unaggressive)"; + if (op->flag [FLAG_HITBACK]) buf << "(hitback)"; + if (op->flag [FLAG_STEALTH]) buf << "(stealthy)"; if (op->randomitems) { @@ -912,7 +916,7 @@ const char * describe_item (const object *op, object *owner) { - if (QUERY_FLAG (op, FLAG_MONSTER) || op->type == PLAYER) + if (op->flag [FLAG_MONSTER] || op->type == PLAYER) return describe_monster (op); static dynbuf_text buf; buf.clear (); @@ -921,7 +925,7 @@ /* figure this out once, instead of making multiple calls to need_identify. * also makes the code easier to read. */ - identified = !need_identify (op) || QUERY_FLAG (op, FLAG_IDENTIFIED); + identified = !need_identify (op) || op->flag [FLAG_IDENTIFIED]; if (!identified) buf << "(unidentified)"; @@ -1001,14 +1005,14 @@ case FOOD: case FLESH: case DRINK: - if (identified || QUERY_FLAG (op, FLAG_BEEN_APPLIED)) + if (identified || op->flag [FLAG_BEEN_APPLIED]) { buf.printf ("(food+%d)", op->stats.food); if (op->type == FLESH && op->last_eat > 0 && atnr_is_dragon_enabled (op->last_eat)) buf.printf ("(%s metabolism)", change_resist_msg[op->last_eat]); - if (!QUERY_FLAG (op, FLAG_CURSED)) + if (!op->flag [FLAG_CURSED]) { if (op->stats.hp) buf << "(heals)"; if (op->stats.sp) buf << "(spellpoint regen)"; @@ -1039,7 +1043,7 @@ /* Down here, we more further describe equipment type items. * only describe them if they have been identified or the like. */ - if (identified || QUERY_FLAG (op, FLAG_BEEN_APPLIED)) + if (identified || op->flag [FLAG_BEEN_APPLIED]) { int attr, val; @@ -1080,8 +1084,8 @@ break; } - if (QUERY_FLAG (op, FLAG_XRAYS)) buf << "(xray-vision)"; - if (QUERY_FLAG (op, FLAG_SEE_IN_DARK)) buf << "(infravision)"; + if (op->flag [FLAG_XRAYS]) buf << "(xray-vision)"; + if (op->flag [FLAG_SEE_IN_DARK]) buf << "(infravision)"; /* levitate was what is was before, so we'll keep it */ if (op->move_type & MOVE_FLY_LOW) buf << "(levitate)"; @@ -1153,10 +1157,10 @@ if (op->stats.luck) buf.printf ("(luck%+d)", op->stats.luck); - if (QUERY_FLAG (op, FLAG_LIFESAVE)) buf << "(lifesaving)"; - if (QUERY_FLAG (op, FLAG_REFL_SPELL)) buf << "(reflect spells)"; - if (QUERY_FLAG (op, FLAG_REFL_MISSILE)) buf << "(reflect missiles)"; - if (QUERY_FLAG (op, FLAG_STEALTH)) buf << "(stealth)"; + if (op->flag [FLAG_LIFESAVE]) buf << "(lifesaving)"; + if (op->flag [FLAG_REFL_SPELL]) buf << "(reflect spells)"; + if (op->flag [FLAG_REFL_MISSILE]) buf << "(reflect missiles)"; + if (op->flag [FLAG_STEALTH]) buf << "(stealth)"; if (op->slaying && op->type != FOOD) buf.printf ("(slay %s)", &op->slaying); @@ -1210,7 +1214,7 @@ { case SPELLBOOK: if (flag [FLAG_IDENTIFIED] && inv) - buf.printf ("%s is a level %s %s spell.\r", &inv->name, get_levelnumber (inv->level), &inv->skill); + buf.printf ("%s is a %s level %s spell.\r", &inv->name, ordinal (inv->level), &inv->skill); break; case BOOK: @@ -1376,9 +1380,9 @@ static dynbuf_text buf; buf.clear (); for (object *tmp = inv; tmp; tmp = tmp->below) - if (who && QUERY_FLAG (who, FLAG_WIZ)) + if (who && who->flag [FLAG_WIZ]) buf.printf ("%s- %-28.28s %-8s (%9d) %s\n", indent, tmp->query_name (), tmp->query_weight (), tmp->count, tmp->uuid.c_str ()); - else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED))) + else if (!tmp->invisible && (type == CONTAINER || tmp->flag [FLAG_APPLIED])) buf.printf ("%s- %-36.36s %-8s\n", indent, tmp->query_name (), tmp->query_weight ()); if (buf.size ()) @@ -1401,7 +1405,7 @@ int i; /* living creatures are considered non magical */ - if (QUERY_FLAG (op, FLAG_ALIVE)) + if (op->flag [FLAG_ALIVE]) return 0; /* This is a test for it being an artifact, as artifacts have titles */ @@ -1417,15 +1421,15 @@ /* Check for stealty, speed, flying, or just plain magic in the boots */ /* Presume any boots that hvae a move_type are special. */ - if (op->type == BOOTS && ((QUERY_FLAG (op, FLAG_STEALTH) || op->move_type || op->stats.exp))) + if (op->type == BOOTS && ((op->flag [FLAG_STEALTH] || op->move_type || op->stats.exp))) return 1; /* Take care of amulet/shield that reflects spells/missiles */ - if ((op->type == AMULET || op->type == SHIELD) && (QUERY_FLAG (op, FLAG_REFL_SPELL) || QUERY_FLAG (op, FLAG_REFL_MISSILE))) + if ((op->type == AMULET || op->type == SHIELD) && (op->flag [FLAG_REFL_SPELL] || op->flag [FLAG_REFL_MISSILE])) return 1; /* Take care of helmet of xrays */ - if (op->type == HELMET && QUERY_FLAG (op, FLAG_XRAYS)) + if (op->type == HELMET && op->flag [FLAG_XRAYS]) return 1; /* Potions & rods are always magical. Wands/staves are also magical, @@ -1524,15 +1528,15 @@ void identify (object *op) { - SET_FLAG (op, FLAG_IDENTIFIED); - CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL); - CLEAR_FLAG (op, FLAG_NO_SKILL_IDENT); + op->set_flag (FLAG_IDENTIFIED); + op->clr_flag (FLAG_KNOWN_MAGICAL); + op->clr_flag (FLAG_NO_SKILL_IDENT); /* * We want autojoining of equal objects: */ - if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) - SET_FLAG (op, FLAG_KNOWN_CURSED); + if (op->flag [FLAG_CURSED] || op->flag [FLAG_DAMNED]) + op->set_flag (FLAG_KNOWN_CURSED); if (op->type == POTION) {