ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/item.C
(Generate patch)

Comparing deliantra/server/common/item.C (file contents):
Revision 1.83 by root, Sun Apr 11 00:34:05 2010 UTC vs.
Revision 1.84 by root, Thu Apr 15 02:51:39 2010 UTC

226get_power_from_ench (int ench) 226get_power_from_ench (int ench)
227{ 227{
228 return enc_to_item_power [clamp (ench, 0, 20)]; 228 return enc_to_item_power [clamp (ench, 0, 20)];
229} 229}
230 230
231static const struct need_identify_types : typeset
232{
233 need_identify_types ()
234 {
235 set (RING);
236 set (WAND);
237 set (ROD);
238 set (HORN);
239 set (SCROLL);
240 set (SKILL);
241 set (SKILLSCROLL);
242 set (SPELLBOOK);
243 set (FOOD);
244 set (POTION);
245 set (BOW);
246 set (ARROW);
247 set (WEAPON);
248 set (ARMOUR);
249 set (SHIELD);
250 set (HELMET);
251 set (AMULET);
252 set (BOOTS);
253 set (GLOVES);
254 set (BRACERS);
255 set (GIRDLE);
256 set (CONTAINER);
257 set (DRINK);
258 set (FLESH);
259 set (INORGANIC);
260 set (CLOSE_CON);
261 set (CLOAK);
262 set (GEM);
263 set (POWER_CRYSTAL);
264 set (POISON);
265 set (BOOK);
266 set (SKILL_TOOL);
267 }
268} need_identify_types;
269
270bool
271object::need_identify () const
272{
273 return need_identify_types [type];
274}
275
231/* This takes an object 'op' and figures out what its item_power 276/* This takes an object 'op' and figures out what its item_power
232 * rating should be. This should only really be used by the treasure 277 * rating should be. This should only really be used by the treasure
233 * generation code, and when loading legacy objects. It returns 278 * generation code, and when loading legacy objects. It returns
234 * the item_power it calculates. 279 * the item_power it calculates.
235 * If flag is 1, we return the number of enchantment, and not the 280 * If flag is 1, we return the number of enchantment, and not the
547 buf << " " << s; 592 buf << " " << s;
548 } 593 }
549 break; 594 break;
550 595
551 default: 596 default:
552 if (op->magic && ((op->flag [FLAG_BEEN_APPLIED] && need_identify (op)) || op->flag [FLAG_IDENTIFIED])) 597 if (op->magic
598 && ((op->flag [FLAG_BEEN_APPLIED] && op->need_identify ())
599 || op->flag [FLAG_IDENTIFIED]))
553 buf.printf (" %+d", op->magic); 600 buf.printf (" %+d", op->magic);
554 } 601 }
555 602
556 return buf; 603 return buf;
557} 604}
756 else if (!EXIT_PATH (op)) 803 else if (!EXIT_PATH (op))
757 buf << " (closed)"; 804 buf << " (closed)";
758 break; 805 break;
759 806
760 default: 807 default:
761 if (op->magic && ((op->flag [FLAG_BEEN_APPLIED] && need_identify (op)) || op->flag [FLAG_IDENTIFIED])) 808 if (op->magic
809 && ((op->flag [FLAG_BEEN_APPLIED] && op->need_identify ())
810 || op->flag [FLAG_IDENTIFIED]))
762 buf.printf (" %+d", op->magic); 811 buf.printf (" %+d", op->magic);
763 } 812 }
764 813
765 return buf; 814 return buf;
766} 815}
923 int identified, i; 972 int identified, i;
924 973
925 /* figure this out once, instead of making multiple calls to need_identify. 974 /* figure this out once, instead of making multiple calls to need_identify.
926 * also makes the code easier to read. 975 * also makes the code easier to read.
927 */ 976 */
928 identified = !need_identify (op) || op->flag [FLAG_IDENTIFIED]; 977 identified = !op->need_identify () || op->flag [FLAG_IDENTIFIED];
929 if (!identified) 978 if (!identified)
930 buf << "(unidentified)"; 979 buf << "(unidentified)";
931 980
932 switch (op->type) 981 switch (op->type)
933 { 982 {
1291 */ 1340 */
1292 if (msg) 1341 if (msg)
1293 { 1342 {
1294 if (type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ()) 1343 if (type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ())
1295 { 1344 {
1296 buf << '\r'; 1345 if (!need_identify ())
1297 1346 buf << '\r' << msg << '\n';
1298 /* This is just a hack so when identifying the items, we print 1347 else if (flag [FLAG_IDENTIFIED])
1299 * out the extra message
1300 */
1301 if (need_identify (this) && flag [FLAG_IDENTIFIED])
1302 buf << "The object has a story:\r"; 1348 buf << '\r' << "The object has a story:\r" << msg;
1303
1304 buf << msg << '\n';
1305 } 1349 }
1306 } 1350 }
1307 else if (inv && inv->type == SPELL && flag [FLAG_IDENTIFIED] 1351 else if (inv
1352 && inv->msg
1353 && inv->type == SPELL
1354 && flag [FLAG_IDENTIFIED]
1308 && (type == SPELLBOOK || type == ROD || type == WAND 1355 && (type == SPELLBOOK || type == ROD || type == WAND
1309 || type == ROD || type == POTION || type == SCROLL)) 1356 || type == ROD || type == POTION || type == SCROLL))
1310 // for spellbooks and other stuff that contains spells, print the spell message, 1357 // for spellbooks and other stuff that contains spells, print the spell message,
1311 // unless the object has a custom message handled above. 1358 // unless the object has a custom message handled above.
1312 buf << '\r' << inv->msg << '\n'; 1359 buf << '\r' << inv->msg << '\n';
1466 * be non magical. 1513 * be non magical.
1467 */ 1514 */
1468 return 0; 1515 return 0;
1469} 1516}
1470 1517
1471/* need_identify returns true if the item should be identified. This
1472 * function really should not exist - by default, any item not identified
1473 * should need it.
1474 */
1475
1476int
1477need_identify (const object *op)
1478{
1479 switch (op->type)
1480 {
1481 case RING:
1482 case WAND:
1483 case ROD:
1484 case HORN:
1485 case SCROLL:
1486 case SKILL:
1487 case SKILLSCROLL:
1488 case SPELLBOOK:
1489 case FOOD:
1490 case POTION:
1491 case BOW:
1492 case ARROW:
1493 case WEAPON:
1494 case ARMOUR:
1495 case SHIELD:
1496 case HELMET:
1497 case AMULET:
1498 case BOOTS:
1499 case GLOVES:
1500 case BRACERS:
1501 case GIRDLE:
1502 case CONTAINER:
1503 case DRINK:
1504 case FLESH:
1505 case INORGANIC:
1506 case CLOSE_CON:
1507 case CLOAK:
1508 case GEM:
1509 case POWER_CRYSTAL:
1510 case POISON:
1511 case BOOK:
1512 case SKILL_TOOL:
1513 return 1;
1514 }
1515
1516 /* Try to track down some stuff that may show up here. Thus, the
1517 * archetype file can be updated, and this function removed.
1518 */
1519#if 0
1520 LOG (llevDebug, "need_identify: %s does not need to be id'd\n", op->name);
1521#endif
1522 return 0;
1523}
1524
1525/* 1518/*
1526 * Supposed to fix face-values as well here, but later. 1519 * Supposed to fix face-values as well here, but later.
1527 */ 1520 */
1528void 1521void
1529identify (object *op) 1522identify (object *op)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines