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.66 by root, Sun Nov 8 20:55:39 2009 UTC vs.
Revision 1.76 by root, Fri Mar 26 15:18:46 2010 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
203 {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0}, 203 {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0},
204}; 204};
205 205
206static const int item_types_size = sizeof (item_types) / sizeof (*item_types); 206static const int item_types_size = sizeof (item_types) / sizeof (*item_types);
207 207
208materialtype_t *materialt;
209
210/*
211materialtype material[NROFMATERIALS] = {
212 * P M F E C C A D W G P S P T F C D D C C G H B I *
213 * H A I L O O C R E H O L A U E A E E H O O O L N *
214 * Y G R E L N I A A O I O R R A N P A A U D L I T *
215 * S I E C D F D I P S S W A N R C L T O N Y N R *
216 * I C T U N O T O L E E H S T P D N *
217 {"paper", {15,10,17, 9, 5, 7,13, 0,20,15, 0,0,0,0,0,10,0,0,0,0,0,0,0,0}},
218 {"metal", { 2,12, 3,12, 2,10, 7, 0,20,15, 0,0,0,0,0,10,0,0,0,0,0,0,0,0}},
219 {"glass", {14,11, 8, 3,10, 5, 1, 0,20,15, 0,0,0,0,0, 0,0,0,0,0,0,0,0,0}},
220 {"leather", { 5,10,10, 3, 3,10,10, 0,20,15, 0,0,0,0,0,12,0,0,0,0,0,0,0,0}},
221 {"wood", {10,11,13, 2, 2,10, 9, 0,20,15, 0,0,0,0,0,12,0,0,0,0,0,0,0,0}},
222 {"organics", { 3,12, 9,11, 3,10, 9, 0,20,15, 0,0,0,0,0, 0,0,0,0,0,0,0,0,0}},
223 {"stone", { 2, 5, 2, 2, 2, 2, 1, 0,20,15, 0,0,0,0,0, 5,0,0,0,0,0,0,0,0}},
224 {"cloth", {14,11,13, 4, 4, 5,10, 0,20,15, 0,0,0,0,0, 5,0,0,0,0,0,0,0,0}},
225 {"adamant", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0,0, 0,0,0,0,0,0,0,0,0}},
226 {"liquid", { 0, 8, 9, 6,17, 0,15, 0,20,15,12,0,0,0,0,11,0,0,0,0,0,0,0,0}},
227 {"soft metal",{ 6,12, 6,14, 2,10, 1, 0,20,15, 0,0,0,0,0,10,0,0,0,0,0,0,0,0}},
228 {"bone", {10, 9, 4, 5, 3,10,10, 0,20,15, 0,0,0,0,0, 2,0,0,0,0,0,0,0,0}},
229 {"ice", {14,11,16, 5, 0, 5, 6, 0,20,15, 0,0,0,0,0, 7,0,0,0,0,0,0,0,0}}
230};
231*/
232
233/* This curve may be too steep. But the point is that there should 208/* This curve may be too steep. But the point is that there should
234 * be tough choices - there is no real point to this if everyone can 209 * be tough choices - there is no real point to this if everyone can
235 * wear whatever they want with no worries. Perhaps having the steep 210 * wear whatever they want with no worries. Perhaps having the steep
236 * curve is good (maybe even steeper), but allowing players to 211 * curve is good (maybe even steeper), but allowing players to
237 * have 2 * level instead. Ideally, top level characters should only be 212 * have 2 * level instead. Ideally, top level characters should only be
586 * returned is good forever.) However, it makes printing statements that 561 * returned is good forever.) However, it makes printing statements that
587 * use several names much easier (don't need to store them to temp variables.) 562 * use several names much easier (don't need to store them to temp variables.)
588 * 563 *
589 * It is used extensively within messages, so should return only a prose 564 * It is used extensively within messages, so should return only a prose
590 * and short description of the item. 565 * and short description of the item.
566 * It is also used by examine/ex and similar functions.
591 */ 567 */
592const char * 568const char *
593query_name (const object *op) 569query_name (const object *op)
594{ 570{
595 int len = 0; 571 int len = 0;
600 use_buf %= 5; 576 use_buf %= 5;
601 577
602 dynbuf_text &buf = bufs [use_buf]; 578 dynbuf_text &buf = bufs [use_buf];
603 buf.clear (); 579 buf.clear ();
604 580
581#if 0
605 if ((op->is_armor () || op->is_weapon ()) && op->materialname) 582 if ((op->is_armor () || op->is_weapon ()) && op->material)
606 if (materialtype_t *mt = name_to_material (op->materialname))
607 buf << mt->description << ' '; 583 buf << op->material->description << ' ';
584#endif
608 585
609 buf << query_short_name (op); 586 buf << query_short_name (op);
610 587
611 if (QUERY_FLAG (op, FLAG_INV_LOCKED)) 588 if (QUERY_FLAG (op, FLAG_INV_LOCKED))
612 buf << " *"; 589 buf << " *";
710 * and sending to client. 687 * and sending to client.
711 * If plural is set, we generate the plural name of this. 688 * If plural is set, we generate the plural name of this.
712 * 689 *
713 * It is sometimes used to display messages, and usually only used to match stuff, 690 * It is sometimes used to display messages, and usually only used to match stuff,
714 * so maybe this function should be removed. 691 * so maybe this function should be removed.
692 * It is also used for client-side inventory/item descriptions.
715 */ 693 */
716const char * 694const char *
717query_base_name (const object *op, int plural) 695query_base_name (const object *op, int plural)
718{ 696{
719 if ((!plural && !op->name) || (plural && !op->name_pl)) 697 if ((!plural && !op->name) || (plural && !op->name_pl))
720 return "(null)"; 698 return "(null)";
721 699
722 if (!op->nrof && !op->weight && !op->title && !is_magical (op)) 700 if (!op->nrof && !op->weight && !op->title && !is_magical (op)
701 && op->type != EXIT)
723 return op->name; /* To speed things up (or make things slower?) */ 702 return op->name; /* To speed things up (or make things slower?) */
724 703
725 static dynbuf_text buf; buf.clear (); 704 static dynbuf_text buf; buf.clear ();
726 705
706#if 0
727 if ((op->is_armor () || op->is_weapon ()) && op->materialname) 707 if ((op->is_armor () || op->is_weapon ()) && op->material)
728 if (materialtype_t *mt = name_to_material (op->materialname))
729 if (op->arch->materialname != mt->name) 708 if (op->arch->material != op->material)
730 buf << mt->description << ' '; 709 buf << op->material->description << ' ';
710#endif
731 711
732 buf << (plural ? op->name_pl : op->name); 712 buf << (plural ? op->name_pl : op->name);
733 713
734 if (op->title && QUERY_FLAG (op, FLAG_IDENTIFIED)) 714 if (op->title && QUERY_FLAG (op, FLAG_IDENTIFIED))
735 buf << ' ' << op->title; 715 buf << ' ' << op->title;
762 if (s && *s) 742 if (s && *s)
763 buf << ' ' << s; 743 buf << ' ' << s;
764 } 744 }
765 break; 745 break;
766 746
747 case EXIT:
748 // random map exits "unfortunately" get patched, so this only works before entering
749 if (EXIT_PATH (op) == shstr_random_map_exit)
750 buf << " (random map)";
751 else if (!EXIT_PATH (op))
752 buf << " (closed)";
753 break;
754
767 default: 755 default:
768 if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) 756 if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED)))
769 buf.printf (" %+d", op->magic); 757 buf.printf (" %+d", op->magic);
770 } 758 }
771 759
786 /* Note that the resolution this provides for players really isn't 774 /* Note that the resolution this provides for players really isn't
787 * very good. Any player with a speed greater than .67 will 775 * very good. Any player with a speed greater than .67 will
788 * fall into the 'lightning fast movement' category. 776 * fall into the 'lightning fast movement' category.
789 */ 777 */
790 if (op->has_active_speed ()) 778 if (op->has_active_speed ())
791 switch ((int)((fabs (op->speed)) * 15.)) 779 switch ((int)(op->speed * 15.))
792 { 780 {
793 case 0: 781 case 0:
794 buf << "(very slow movement)"; 782 buf << "(very slow movement)";
795 break; 783 break;
796 case 1: 784 case 1:
866 if (op->stats.luck) 854 if (op->stats.luck)
867 buf.printf ("(luck%+d)", op->stats.luck); 855 buf.printf ("(luck%+d)", op->stats.luck);
868 } 856 }
869 857
870 /* describe attacktypes */ 858 /* describe attacktypes */
871 if (is_dragon_pl (op)) 859 if (op->is_dragon ())
872 { 860 {
873 /* for dragon players display the attacktypes from clawing skill 861 /* for dragon players display the attacktypes from clawing skill
874 * Break apart the for loop - move the comparison checking down - 862 * Break apart the for loop - move the comparison checking down -
875 * this makes it more readable. 863 * this makes it more readable.
876 */ 864 */
1175 1163
1176 buf.add_abilities ("Attacks", op->attacktype); 1164 buf.add_abilities ("Attacks", op->attacktype);
1177 /* resistance on flesh is only visible for quetzals. If 1165 /* resistance on flesh is only visible for quetzals. If
1178 * non flesh, everyone can see its resistances 1166 * non flesh, everyone can see its resistances
1179 */ 1167 */
1180 if (op->type != FLESH || (owner && is_dragon_pl (owner))) 1168 if (op->type != FLESH || (owner && owner->is_dragon ()))
1181 buf << describe_resistance (op, 0); 1169 buf << describe_resistance (op, 0);
1182 1170
1183 buf.add_paths ("Attuned", op->path_attuned); 1171 buf.add_paths ("Attuned", op->path_attuned);
1184 buf.add_paths ("Repelled", op->path_repelled); 1172 buf.add_paths ("Repelled", op->path_repelled);
1185 buf.add_paths ("Denied", op->path_denied); 1173 buf.add_paths ("Denied", op->path_denied);
1212{ 1200{
1213 static dynbuf_text buf; buf.clear (); 1201 static dynbuf_text buf; buf.clear ();
1214 1202
1215 for (object *tmp = inv; tmp; tmp = tmp->below) 1203 for (object *tmp = inv; tmp; tmp = tmp->below)
1216 if (who && QUERY_FLAG (who, FLAG_WIZ)) 1204 if (who && QUERY_FLAG (who, FLAG_WIZ))
1217 buf.printf ("%s- %-28.28s (%5d) %-8s\n", indent, tmp->query_name (), tmp->count, tmp->query_weight ()); 1205 buf.printf ("%s- %-28.28s %-8s (%9d) %s\n", indent, tmp->query_name (), tmp->query_weight (), tmp->count, tmp->uuid.c_str ());
1218 else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED))) 1206 else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED)))
1219 buf.printf ("%s- %-36.36s %-8s\n", indent, tmp->query_name (), tmp->query_weight ()); 1207 buf.printf ("%s- %-36.36s %-8s\n", indent, tmp->query_name (), tmp->query_weight ());
1220 1208
1221 if (buf.size ()) 1209 if (buf.size ())
1222 buf.printf ("%s(total weight: %s)\n", indent, query_weight ()); 1210 buf.printf ("%s(total weight: %s)\n", indent, query_weight ());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines