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.54 by elmex, Mon Jan 12 00:17:22 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
750 * 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
751 * 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
752 * 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
753 * and sending to client. 750 * and sending to client.
754 * 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.
755 */ 755 */
756const char * 756const char *
757query_base_name (const object *op, int plural) 757query_base_name (const object *op, int plural)
758{ 758{
759 if ((!plural && !op->name) || (plural && !op->name_pl)) 759 if ((!plural && !op->name) || (plural && !op->name_pl))
954 * 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
955 * a dragon player examining food. Could have things like 955 * a dragon player examining food. Could have things like
956 * 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
957 * dwarves, etc. 957 * dwarves, etc.
958 * 958 *
959 * This function is really much more complicated than it should
960 * be, because different objects have different meanings
961 * for the same field (eg, wands use 'food' for charges). This
962 * means these special cases need to be worked out.
963 *
964 * Add 'owner' who is the person examining this object. 959 * Add 'owner' who is the person examining this object.
965 * 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
966 * item (eg, debug dump or the like) 961 * item (eg, debug dump or the like)
967 */ 962 */
968const char * 963const char *
1238 1233
1239void 1234void
1240examine (object *op, object *tmp) 1235examine (object *op, object *tmp)
1241{ 1236{
1242 std::string info = tmp->describe (op); 1237 std::string info = tmp->describe (op);
1238
1243 op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ()); 1239 op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ());
1244} 1240}
1245 1241
1246/* 1242/*
1247 * 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