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.47 by root, Mon Apr 21 23:35:24 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,2008 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>
26#include <living.h> 25#include <living.h>
27#include <spells.h> 26#include <spells.h>
27
28const char *const coins[NUM_COINS + 1] = { "royalty", "platinacoin", "goldcoin", "silvercoin", 0 };
28 29
29/* the ordering of this is actually doesn't make a difference 30/* the ordering of this is actually doesn't make a difference
30 * However, for ease of use, new entries should go at the end 31 * 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 32 * so those people that debug the code that get used to something
32 * being in the location 4 don't get confused. 33 * being in the location 4 don't get confused.
417 */ 418 */
418const char * 419const char *
419query_weight (const object *op) 420query_weight (const object *op)
420{ 421{
421 static char buf[10]; 422 static char buf[10];
422 sint32 i = (op->nrof ? op->nrof : 1) * op->weight + op->carrying; 423 sint32 i = op->total_weight ();
423 424
424 if (op->weight < 0) 425 if (op->weight < 0)
425 return " "; 426 return " ";
426 427
427 if (i % 1000) 428 if (i % 1000)
536 * contain any information about object status (worn/cursed/etc.) 537 * contain any information about object status (worn/cursed/etc.)
537 */ 538 */
538const char * 539const char *
539query_short_name (const object *op) 540query_short_name (const object *op)
540{ 541{
542 if (op->name == 0)
543 return "(null)";
544
545 if (!op->nrof
546 && !op->weight
547 && !op->title
548 && !is_magical (op)
549 && op->slaying != shstr_money)
550 return op->name; /* To speed things up (or make things slower?) */
551
541 static dynbuf_text buf; buf.clear (); 552 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 553
549 buf << (op->nrof <= 1 ? op->name : op->name_pl); 554 buf << (op->nrof <= 1 ? op->name : op->name_pl);
550 555
551 if (op->title && QUERY_FLAG (op, FLAG_IDENTIFIED)) 556 if (op->title && QUERY_FLAG (op, FLAG_IDENTIFIED))
552 buf << ' ' << op->title; 557 buf << ' ' << op->title;
565 if (op->type != SPELLBOOK) 570 if (op->type != SPELLBOOK)
566 buf.printf (" (lvl %d)", op->level); 571 buf.printf (" (lvl %d)", op->level);
567 } 572 }
568 break; 573 break;
569 574
575 case ALTAR:
576 case TRIGGER_ALTAR:
577 case IDENTIFY_ALTAR:
578 case CONVERTER:
579 if (op->slaying == shstr_money)
580 {
581 bool wrap = !!buf.size ();
582
583 if (wrap) buf << " [";
584
585 archetype *coin = 0;
586
587 for (char const *const *c = coins; *coins; ++c)
588 if ((coin = archetype::find (*c)))
589 if (op->stats.food % coin->value == 0)
590 break;
591
592 sint32 coins = op->stats.food / coin->value;
593
594 buf.printf ("drop %d %s (or equivalent)", coins, coins == 1 ? &coin->name : &coin->name_pl);
595
596 if (wrap) buf << ']';
597 }
598 break;
599
570 case SKILL: 600 case SKILL:
571 case AMULET: 601 case AMULET:
572 case RING: 602 case RING:
573 if (!op->title) 603 if (!op->title)
574 { 604 {
577 607
578 if (s && *s) 608 if (s && *s)
579 buf << " " << s; 609 buf << " " << s;
580 } 610 }
581 break; 611 break;
612
582 default: 613 default:
583 if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) 614 if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED)))
584 buf.printf (" %+d", op->magic); 615 buf.printf (" %+d", op->magic);
585 } 616 }
586 617
1157 1188
1158std::string 1189std::string
1159object::describe_item (object *who) 1190object::describe_item (object *who)
1160{ 1191{
1161 return std::string (::describe_item (this, who)); 1192 return std::string (::describe_item (this, who));
1193}
1194
1195void
1196examine (object *op, object *tmp)
1197{
1198 std::string info = tmp->describe (op);
1199 op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ());
1200}
1201
1202/*
1203 * inventory prints object's inventory. If inv==NULL then print player's
1204 * inventory.
1205 * [ Only items which are applied are showed. Tero.Haatanen@lut.fi ]
1206 */
1207const char *
1208object::query_inventory (object *who, const char *indent)
1209{
1210 static dynbuf_text buf; buf.clear ();
1211
1212 for (object *tmp = inv; tmp; tmp = tmp->below)
1213 if (who && QUERY_FLAG (who, FLAG_WIZ))
1214 buf.printf ("%s- %-28.28s (%5d) %-8s\n", indent, query_name (tmp), tmp->count, query_weight (tmp));
1215 else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED)))
1216 buf.printf ("%s- %-36.36s %-8s\n", indent, query_name (tmp), query_weight (tmp));
1217
1218 if (buf.size ())
1219 buf.printf ("%s(total weight: %s)\n", indent, query_weight (this));
1220 else
1221 buf.printf ("%s(empty)\n", indent);
1222
1223 return buf;
1162} 1224}
1163 1225
1164/* Return true if the item is magical. A magical item is one that 1226/* Return true if the item is magical. A magical item is one that
1165 * increases/decreases any abilities, provides a resistance, 1227 * increases/decreases any abilities, provides a resistance,
1166 * has a generic magical bonus, or is an artifact. 1228 * has a generic magical bonus, or is an artifact.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines