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.39 by root, Tue Jul 10 05:51:37 2007 UTC vs.
Revision 1.46 by root, Sun Apr 20 22:03:21 2008 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#include <funcpoint.h> 25#include <funcpoint.h>
26#include <living.h> 26#include <living.h>
27#include <spells.h> 27#include <spells.h>
28
29const char *const coins[NUM_COINS + 1] = { "royalty", "platinacoin", "goldcoin", "silvercoin", 0 };
28 30
29/* the ordering of this is actually doesn't make a difference 31/* the ordering of this is actually doesn't make a difference
30 * However, for ease of use, new entries should go at the end 32 * However, for ease of use, new entries should go at the end
31 * so those people that debug the code that get used to something 33 * so those people that debug the code that get used to something
32 * being in the location 4 don't get confused. 34 * being in the location 4 don't get confused.
417 */ 419 */
418const char * 420const char *
419query_weight (const object *op) 421query_weight (const object *op)
420{ 422{
421 static char buf[10]; 423 static char buf[10];
422 sint32 i = (op->nrof ? op->nrof : 1) * op->weight + op->carrying; 424 sint32 i = op->total_weight ();
423 425
424 if (op->weight < 0) 426 if (op->weight < 0)
425 return " "; 427 return " ";
426 428
427 if (i % 1000) 429 if (i % 1000)
536 * contain any information about object status (worn/cursed/etc.) 538 * contain any information about object status (worn/cursed/etc.)
537 */ 539 */
538const char * 540const char *
539query_short_name (const object *op) 541query_short_name (const object *op)
540{ 542{
543 if (op->name == 0)
544 return "(null)";
545
546 if (!op->nrof
547 && !op->weight
548 && !op->title
549 && !is_magical (op)
550 && op->slaying != shstr_money)
551 return op->name; /* To speed things up (or make things slower?) */
552
541 static dynbuf_text buf; buf.clear (); 553 static dynbuf_text buf; buf.clear ();
542
543 if (op->name == NULL)
544 return "(null)";
545
546 if (!op->nrof && !op->weight && !op->title && !is_magical (op))
547 return op->name; /* To speed things up (or make things slower?) */
548 554
549 buf << (op->nrof <= 1 ? op->name : op->name_pl); 555 buf << (op->nrof <= 1 ? op->name : op->name_pl);
550 556
551 if (op->title && QUERY_FLAG (op, FLAG_IDENTIFIED)) 557 if (op->title && QUERY_FLAG (op, FLAG_IDENTIFIED))
552 buf << ' ' << op->title; 558 buf << ' ' << op->title;
565 if (op->type != SPELLBOOK) 571 if (op->type != SPELLBOOK)
566 buf.printf (" (lvl %d)", op->level); 572 buf.printf (" (lvl %d)", op->level);
567 } 573 }
568 break; 574 break;
569 575
576 case ALTAR:
577 case TRIGGER_ALTAR:
578 case IDENTIFY_ALTAR:
579 case CONVERTER:
580 if (op->slaying == shstr_money)
581 {
582 bool wrap = !!buf.size ();
583
584 if (wrap) buf << " [";
585
586 archetype *coin = 0;
587
588 for (char const *const *c = coins; *coins; ++c)
589 if ((coin = archetype::find (*c)))
590 if (op->stats.food % coin->value == 0)
591 break;
592
593 sint32 coins = op->stats.food / coin->value;
594
595 buf.printf ("drop %d %s (or equivalent)", coins, coins == 1 ? &coin->name : &coin->name_pl);
596
597 if (wrap) buf << ']';
598 }
599 break;
600
570 case SKILL: 601 case SKILL:
571 case AMULET: 602 case AMULET:
572 case RING: 603 case RING:
573 if (!op->title) 604 if (!op->title)
574 { 605 {
577 608
578 if (s && *s) 609 if (s && *s)
579 buf << " " << s; 610 buf << " " << s;
580 } 611 }
581 break; 612 break;
613
582 default: 614 default:
583 if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) 615 if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED)))
584 buf.printf (" %+d", op->magic); 616 buf.printf (" %+d", op->magic);
585 } 617 }
586 618
1157 1189
1158std::string 1190std::string
1159object::describe_item (object *who) 1191object::describe_item (object *who)
1160{ 1192{
1161 return std::string (::describe_item (this, who)); 1193 return std::string (::describe_item (this, who));
1194}
1195
1196void
1197examine (object *op, object *tmp)
1198{
1199 std::string info = tmp->describe (op);
1200 op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ());
1201}
1202
1203/*
1204 * inventory prints object's inventory. If inv==NULL then print player's
1205 * inventory.
1206 * [ Only items which are applied are showed. Tero.Haatanen@lut.fi ]
1207 */
1208const char *
1209object::query_inventory (object *who, const char *indent)
1210{
1211 static dynbuf_text buf; buf.clear ();
1212
1213 for (object *tmp = inv; tmp; tmp = tmp->below)
1214 if (who && QUERY_FLAG (who, FLAG_WIZ))
1215 buf.printf ("%s- %-28.28s (%5d) %-8s\n", indent, query_name (tmp), tmp->count, query_weight (tmp));
1216 else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED)))
1217 buf.printf ("%s- %-36.36s %-8s\n", indent, query_name (tmp), query_weight (tmp));
1218
1219 if (buf.size ())
1220 buf.printf ("%s(total weight: %s)\n", indent, query_weight (this));
1221 else
1222 buf.printf ("%s(empty)\n", indent);
1223
1224 return buf;
1162} 1225}
1163 1226
1164/* Return true if the item is magical. A magical item is one that 1227/* Return true if the item is magical. A magical item is one that
1165 * increases/decreases any abilities, provides a resistance, 1228 * increases/decreases any abilities, provides a resistance,
1166 * has a generic magical bonus, or is an artifact. 1229 * has a generic magical bonus, or is an artifact.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines