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.53 by root, Sun Jan 11 06:08:40 2009 UTC vs.
Revision 1.55 by root, Wed Sep 16 22:50:50 2009 UTC

327 enc -= 2; 327 enc -= 2;
328 else if (op->path_repelled & (1 << i)) 328 else if (op->path_repelled & (1 << i))
329 enc--; 329 enc--;
330 } 330 }
331 331
332 if (QUERY_FLAG (op, FLAG_LIFESAVE)) 332 if (op->flag [FLAG_LIFESAVE ]) enc += 5;
333 enc += 5; 333 if (op->flag [FLAG_REFL_SPELL ]) enc += 3;
334 if (QUERY_FLAG (op, FLAG_REFL_SPELL)) 334 if (op->flag [FLAG_REFL_MISSILE]) enc += 2;
335 enc += 3; 335 if (op->flag [FLAG_XRAYS ]) enc += 2;
336 if (QUERY_FLAG (op, FLAG_REFL_MISSILE)) 336 if (op->flag [FLAG_STEALTH ]) enc += 1;
337 enc += 2; 337 if (op->flag [FLAG_SEE_IN_DARK ]) enc += 1;
338 if (QUERY_FLAG (op, FLAG_STEALTH)) 338 if (op->flag [FLAG_MAKE_INVIS ]) enc += 1;
339 enc += 1;
340 if (QUERY_FLAG (op, FLAG_XRAYS))
341 enc += 2;
342 if (QUERY_FLAG (op, FLAG_SEE_IN_DARK))
343 enc += 1;
344 if (QUERY_FLAG (op, FLAG_MAKE_INVIS))
345 enc += 1;
346 339
347 return get_power_from_ench (enc); 340 return get_power_from_ench (enc);
348} 341}
349 342
350/* returns the typedata that has a number equal to itemtype, if there 343/* returns the typedata that has a number equal to itemtype, if there
351 * isn't one, returns NULL */ 344 * isn't one, returns NULL */
352const typedata * 345const typedata *
353get_typedata (int itemtype) 346get_typedata (int itemtype)
354{ 347{
355 int i;
356
357 for (i = 0; i < item_types_size; i++) 348 for (int i = 0; i < item_types_size; i++)
358 if (item_types[i].number == itemtype) 349 if (item_types[i].number == itemtype)
359 return &item_types[i]; 350 return &item_types[i];
360 351
361 return NULL; 352 return NULL;
362} 353}
365 * isn't one, return the plural name that matches, if there still isn't 356 * isn't one, return the plural name that matches, if there still isn't
366 * one return NULL */ 357 * one return NULL */
367const typedata * 358const typedata *
368get_typedata_by_name (const char *name) 359get_typedata_by_name (const char *name)
369{ 360{
370 int i;
371
372 for (i = 0; i < item_types_size; i++) 361 for (int i = 0; i < item_types_size; i++)
373 if (!strcmp (item_types[i].name, name)) 362 if (!strcmp (item_types[i].name, name))
374 return &item_types[i]; 363 return &item_types[i];
375 364
376 for (i = 0; i < item_types_size; i++) 365 for (int i = 0; i < item_types_size; i++)
377 if (!strcmp (item_types[i].name_pl, name)) 366 if (!strcmp (item_types[i].name_pl, name))
378 { 367 {
379 LOG (llevInfo, 368 LOG (llevInfo,
380 "get_typedata_by_name: I have been sent the plural %s, the singular form %s is prefered\n", name, item_types[i].name); 369 "get_typedata_by_name: I have been sent the plural %s, the singular form %s is prefered\n", name, item_types[i].name);
381 return &item_types[i]; 370 return &item_types[i];
382 } 371 }
383 372
384 return NULL; 373 return 0;
385} 374}
386 375
387/* describe_resistance generates the visible naming for resistances. 376/* describe_resistance generates the visible naming for resistances.
388 * returns a static array of the description. This can return 377 * returns a static array of the description. This can return
389 * a big buffer. 378 * a big buffer.
408 sprintf (buf1, "%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]); 397 sprintf (buf1, "%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]);
409 398
410 strcat (buf, buf1); 399 strcat (buf, buf1);
411 } 400 }
412 } 401 }
402
413 return buf; 403 return buf;
414} 404}
415 405
416 406
417/* 407/*
418 * query_weight(object) returns a character pointer to a static buffer 408 * query_weight(object) returns a character pointer to a static buffer
419 * containing the text-representation of the weight of the given object. 409 * containing the text-representation of the weight of the given object.
420 * The buffer will be overwritten by the next call to query_weight(). 410 * The buffer will be overwritten by the next call to query_weight().
411 *
412 * Seems to be used only by unimportant stuff. Remove?
421 */ 413 */
422const char * 414const char *
423query_weight (const object *op) 415query_weight (const object *op)
424{ 416{
425 static char buf[10]; 417 static char buf[10];
451 return buf; 443 return buf;
452 } 444 }
453 445
454 if (i < 21) 446 if (i < 21)
455 return levelnumbers[i]; 447 return levelnumbers[i];
448
456 if (!(i % 10)) 449 if (!(i % 10))
457 return levelnumbers_10[i / 10]; 450 return levelnumbers_10[i / 10];
458 451
459 strcpy (buf, numbers_10[i / 10]); 452 strcpy (buf, numbers_10[i / 10]);
460 strcat (buf, levelnumbers[i % 10]); 453 strcat (buf, levelnumbers[i % 10]);
536} 529}
537 530
538/* 531/*
539 * query_short_name(object) is similar to query_name, but doesn't 532 * query_short_name(object) is similar to query_name, but doesn't
540 * contain any information about object status (worn/cursed/etc.) 533 * contain any information about object status (worn/cursed/etc.)
534 *
535 * It is sometimes used when printing messages, so should fit well into a sentence.
541 */ 536 */
542const char * 537const char *
543query_short_name (const object *op) 538query_short_name (const object *op)
544{ 539{
545 if (!op->name) 540 if (!op->name)
629 * you can make several calls to query_name before the bufs start getting 624 * you can make several calls to query_name before the bufs start getting
630 * overwritten. This may be a bad thing (it may be easier to assume the value 625 * overwritten. This may be a bad thing (it may be easier to assume the value
631 * returned is good forever.) However, it makes printing statements that 626 * returned is good forever.) However, it makes printing statements that
632 * use several names much easier (don't need to store them to temp variables.) 627 * use several names much easier (don't need to store them to temp variables.)
633 * 628 *
629 * It is used extensively within messages, so should return only a prose
630 * and short description of the item.
634 */ 631 */
635const char * 632const char *
636query_name (const object *op) 633query_name (const object *op)
637{ 634{
638 int len = 0; 635 int len = 0;
675 */ 672 */
676 if (QUERY_FLAG (op, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (op, FLAG_IDENTIFIED)) 673 if (QUERY_FLAG (op, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (op, FLAG_IDENTIFIED))
677 buf << " (magic)"; 674 buf << " (magic)";
678 675
679#if 0 676#if 0
680 /* item_power will be returned in desribe_item - it shouldn't really 677 /* item_power will be returned in describe_item - it shouldn't really
681 * be returned in the name. 678 * be returned in the name.
682 */ 679 */
683 if (op->item_power) 680 if (op->item_power)
684 sprintf (buf[use_buf] + strlen (buf[use_buf]), "(item_power %+d)", op->item_power); 681 sprintf (buf[use_buf] + strlen (buf[use_buf]), "(item_power %+d)", op->item_power);
685 682
717 default: 714 default:
718 buf << " (applied)"; 715 buf << " (applied)";
719 } 716 }
720 } 717 }
721 718
719 switch (op->type)
720 {
721 case LAMP:
722 if (op->glow_radius)
723 buf << " (on)";
724 else if (op->stats.food <= 0)
725 buf << " (empty)";
726 else
727 buf << " (off)";
728 break;
729
730 case TORCH:
731 if (op->glow_radius)
732 buf << " (burning)";
733 else if (op->stats.food <= 0)
734 buf << " (burned out)";
735 break;
736 }
737
722 if (QUERY_FLAG (op, FLAG_UNPAID)) 738 if (QUERY_FLAG (op, FLAG_UNPAID))
723 buf << " (unpaid)"; 739 buf << " (unpaid)";
724 740
725 return buf; 741 return buf;
726} 742}
731 * of the given object. The buffer will be overwritten at the next 747 * of the given object. The buffer will be overwritten at the next
732 * call to query_base_name(). This is a lot like query_name, but we 748 * call to query_base_name(). This is a lot like query_name, but we
733 * don't include the item count or item status. Used for inventory sorting 749 * don't include the item count or item status. Used for inventory sorting
734 * and sending to client. 750 * and sending to client.
735 * If plural is set, we generate the plural name of this. 751 * If plural is set, we generate the plural name of this.
752 *
753 * It is sometimes used to display messages, and usually only used to match stuff,
754 * so maybe this function should be removed.
736 */ 755 */
737const char * 756const char *
738query_base_name (const object *op, int plural) 757query_base_name (const object *op, int plural)
739{ 758{
740 if ((!plural && !op->name) || (plural && !op->name_pl)) 759 if ((!plural && !op->name) || (plural && !op->name_pl))
935 * wouldn't need to use the SEE_INVISIBLE flag to know it is 954 * wouldn't need to use the SEE_INVISIBLE flag to know it is
936 * a dragon player examining food. Could have things like 955 * a dragon player examining food. Could have things like
937 * a dwarven axe, in which the full abilities are only known to 956 * a dwarven axe, in which the full abilities are only known to
938 * dwarves, etc. 957 * dwarves, etc.
939 * 958 *
940 * This function is really much more complicated than it should
941 * be, because different objects have different meanings
942 * for the same field (eg, wands use 'food' for charges). This
943 * means these special cases need to be worked out.
944 *
945 * Add 'owner' who is the person examining this object. 959 * Add 'owner' who is the person examining this object.
946 * owner can be null if no one is being associated with this 960 * owner can be null if no one is being associated with this
947 * item (eg, debug dump or the like) 961 * item (eg, debug dump or the like)
948 */ 962 */
949const char * 963const char *
1007 buf << "well charged."; 1021 buf << "well charged.";
1008 else if (op->stats.sp == op->stats.maxsp) 1022 else if (op->stats.sp == op->stats.maxsp)
1009 buf << "fully charged."; 1023 buf << "fully charged.";
1010 else 1024 else
1011 buf << "almost full."; 1025 buf << "almost full.";
1026 break;
1027
1028 case LAMP:
1029 {
1030 int percent = ((double) 100 / op->arch->stats.food) * op->stats.food;
1031 buf << "(fuel: ";
1032 if (percent == 0)
1033 buf << "empty";
1034 else if (percent < 10)
1035 buf << "very low";
1036 else if (percent < 25)
1037 buf << "low";
1038 else if (percent < 50)
1039 buf << "half empty";
1040 else if (percent < 75)
1041 buf << "half full";
1042 else if (percent < 95)
1043 buf << "well filled";
1044 else if (percent <= 100)
1045 buf << "full";
1046 buf << ")";
1047 }
1012 break; 1048 break;
1013 1049
1014 case FOOD: 1050 case FOOD:
1015 case FLESH: 1051 case FLESH:
1016 case DRINK: 1052 case DRINK:
1197 1233
1198void 1234void
1199examine (object *op, object *tmp) 1235examine (object *op, object *tmp)
1200{ 1236{
1201 std::string info = tmp->describe (op); 1237 std::string info = tmp->describe (op);
1238
1202 op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ()); 1239 op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ());
1203} 1240}
1204 1241
1205/* 1242/*
1206 * inventory prints object's inventory. If inv==NULL then print player's 1243 * inventory prints object's inventory. If inv==NULL then print player's

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines