ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/loader.C
(Generate patch)

Comparing deliantra/server/common/loader.C (file contents):
Revision 1.80 by root, Sat May 12 16:06:41 2007 UTC vs.
Revision 1.89 by root, Wed Jun 6 05:41:25 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game 2 * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software; you can redistribute it and/or modify it
9 * it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
10 * the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
11 * (at your option) any later version. 11 * 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, but
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * GNU General Public License for more details. 16 * 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 along
19 * along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * 21 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 23 */
24 24
25/* Eneq(@csd.uu.se): Added weight-modifiers in environment of objects. 25/* Eneq(@csd.uu.se): Added weight-modifiers in environment of objects.
26 sub/add_weight will transcend the environment updating the carrying 26 sub/add_weight will transcend the environment updating the carrying
27 variable. */ 27 variable. */
260 * to check for objects to make sure there are no common errors. 260 * to check for objects to make sure there are no common errors.
261 */ 261 */
262void 262void
263object::post_load_check () 263object::post_load_check ()
264{ 264{
265 if (type >= NUM_TYPES)
266 {
267 LOG (llevError, "%s: type out of range, resetting to 0.\n", debug_desc ());
268 type = 0;
269 }
270
265 switch (type) 271 switch (type)
266 { 272 {
267 case BOW: 273 case BOW:
268 case WAND: 274 case WAND:
269 case ROD: 275 case ROD:
270 case HORN: 276 case HORN:
271 case SKILL_TOOL:
272 if (slot [body_range].info != -1) 277 if (slot [body_range].info != -1)
273 { 278 {
274 LOG (llevError, "%s: body_range %d != -1\n", debug_desc (), slot [body_range].info); 279 LOG (llevError, "%s: body_range %d != -1\n", debug_desc (), slot [body_range].info);
275 slot [body_range].info = -1; 280 slot [body_range].info = -1;
276 } 281 }
320 * also have to catch is if this object is not using the normal name for 325 * also have to catch is if this object is not using the normal name for
321 * the object. In that case, we also want to use the loaded name. 326 * the object. In that case, we also want to use the loaded name.
322 * Otherwise, what happens is that the the plural name will lose 327 * Otherwise, what happens is that the the plural name will lose
323 * information (appear as just 'hearts' and not 'goblins heart') 328 * information (appear as just 'hearts' and not 'goblins heart')
324 */ 329 */
325 if (arch && name != arch->clone.name && name_pl == arch->clone.name_pl) 330 if (arch && name != arch->object::name && name_pl == arch->object::name_pl)
326 name_pl = 0; 331 name_pl = 0;
327 332
328 if (!name_pl) 333 if (!name_pl)
329 name_pl = name; 334 name_pl = name;
330 335
379 * something that has item_power 1 is probably just fine if our calculated 384 * something that has item_power 1 is probably just fine if our calculated
380 * value is 1 or 2 - these values are small enough that hard to be precise. 385 * value is 1 or 2 - these values are small enough that hard to be precise.
381 * similarly, it item_power is 0, the first check will always pass, 386 * similarly, it item_power is 0, the first check will always pass,
382 * but not the second one. 387 * but not the second one.
383 */ 388 */
389#if 0 //TODO
384 if (ip > 2 * item_power && ip > (item_power + 3)) 390 if (ip > 2 * item_power && ip > (item_power + 3))
385 LOG (llevDebug, "Object %s seems to have too low item power? %d > %d\n", debug_desc (), ip, item_power); 391 LOG (llevDebug, "Object %s seems to have too low item power? %d > %d\n", debug_desc (), ip, item_power);
392#endif
386 } 393 }
387 394
388 /* Old spellcasting object - need to load in the appropiate object */ 395 /* Old spellcasting object - need to load in the appropiate object */
389 if ((type == ROD || type == WAND || type == SCROLL || type == HORN || type == FIREWALL || 396 if ((type == ROD || type == WAND || type == SCROLL || type == HORN || type == FIREWALL ||
390 /* POTIONS and ALTARS don't always cast spells, but if they do, update them */ 397 /* POTIONS and ALTARS don't always cast spells, but if they do, update them */
403 { 410 {
404 object *tmp = get_archetype_by_object_name (slaying); 411 object *tmp = get_archetype_by_object_name (slaying);
405 insert_ob_in_ob (tmp, this); 412 insert_ob_in_ob (tmp, this);
406 randomitems = NULL; /* So another spell isn't created for this object */ 413 randomitems = NULL; /* So another spell isn't created for this object */
407 /* without this, value is all screwed up */ 414 /* without this, value is all screwed up */
408 value = arch->clone.value * inv->value; 415 value = arch->value * inv->value;
409 } 416 }
410 417
411 if (QUERY_FLAG (this, FLAG_MONSTER)) 418 if (QUERY_FLAG (this, FLAG_MONSTER))
412 { 419 {
413 if (stats.hp > stats.maxhp) 420 if (stats.hp > stats.maxhp)
510 517
511next: ; 518next: ;
512 } 519 }
513} 520}
514 521
515#define GET_FLAG(op,flag) \ 522#define GET_FLAG(op,flg) op->flag [flg] = f.get_bool ()
516 if (f.get_sint32 ()) \
517 SET_FLAG (op, flag); \
518 else \
519 CLEAR_FLAG (op, flag) \
520 523
521bool 524bool
522object::parse_kv (object_thawer &f) 525object::parse_kv (object_thawer &f)
523{ 526{
524 object *op_inv = inv; 527 object *op_inv = inv;
769 if (QUERY_FLAG (this, FLAG_IDENTIFIED)) 772 if (QUERY_FLAG (this, FLAG_IDENTIFIED))
770 CLEAR_FLAG (this, FLAG_KNOWN_MAGICAL); 773 CLEAR_FLAG (this, FLAG_KNOWN_MAGICAL);
771 774
772 break; 775 break;
773 776
774 case KW_wiz:
775 GET_FLAG (this, FLAG_WIZ);
776 //TODO: move to check_object
777 if (QUERY_FLAG (this, FLAG_WIZ))
778 {
779 SET_FLAG (this, FLAG_WAS_WIZ);
780 SET_FLAG (this, FLAG_WIZPASS);
781 SET_FLAG (this, FLAG_WIZCAST);
782 }
783 else
784 {
785 CLEAR_FLAG (this, FLAG_WIZPASS);
786 CLEAR_FLAG (this, FLAG_WIZCAST);
787 }
788 break;
789
790 case KW_friendly: 777 case KW_friendly:
791 if (f.get_sint32 ()) 778 if (f.get_bool ())
792 if (type != PLAYER) 779 if (type != PLAYER)
793 add_friendly_object (this); 780 add_friendly_object (this);
794 781
795 break; 782 break;
796 783
825 case KW_reflect_missile: GET_FLAG (this, FLAG_REFL_MISSILE); break; 812 case KW_reflect_missile: GET_FLAG (this, FLAG_REFL_MISSILE); break;
826 case KW_reflect_spell: GET_FLAG (this, FLAG_REFL_SPELL); break; 813 case KW_reflect_spell: GET_FLAG (this, FLAG_REFL_SPELL); break;
827 case KW_no_magic: GET_FLAG (this, FLAG_NO_MAGIC); break; 814 case KW_no_magic: GET_FLAG (this, FLAG_NO_MAGIC); break;
828 case KW_no_drop: GET_FLAG (this, FLAG_NO_DROP); break; 815 case KW_no_drop: GET_FLAG (this, FLAG_NO_DROP); break;
829 case KW_random_movement: GET_FLAG (this, FLAG_RANDOM_MOVE); break; 816 case KW_random_movement: GET_FLAG (this, FLAG_RANDOM_MOVE); break;
830 case KW_was_wiz: GET_FLAG (this, FLAG_WAS_WIZ); break;
831 case KW_no_fix_player: GET_FLAG (this, FLAG_NO_FIX_PLAYER); break; 817 case KW_no_fix_player: GET_FLAG (this, FLAG_NO_FIX_PLAYER); break;
832 case KW_is_lightable: GET_FLAG (this, FLAG_IS_LIGHTABLE); break; 818 case KW_is_lightable: GET_FLAG (this, FLAG_IS_LIGHTABLE); break;
833 case KW_tear_down: GET_FLAG (this, FLAG_TEAR_DOWN); break; 819 case KW_tear_down: GET_FLAG (this, FLAG_TEAR_DOWN); break;
834 case KW_can_use_shield: GET_FLAG (this, FLAG_USE_SHIELD); break; 820 case KW_can_use_shield: GET_FLAG (this, FLAG_USE_SHIELD); break;
835 case KW_can_cast_spell: GET_FLAG (this, FLAG_CAST_SPELL); break; 821 case KW_can_cast_spell: GET_FLAG (this, FLAG_CAST_SPELL); break;
1038 f.next (); 1024 f.next ();
1039 1025
1040 object *op = object::create (); 1026 object *op = object::create ();
1041 1027
1042 op->map = map; 1028 op->map = map;
1043 arch->clone.copy_to (op); 1029 arch->copy_to (op);
1044 // copy_to activates, this should be fixed properly 1030 // copy_to activates, this should be fixed properly
1045 op->deactivate (); 1031 op->deactivate ();
1046 1032
1047 if (!op->parse_kv (f)) 1033 if (!op->parse_kv (f))
1048 { 1034 {
1135 * the 15'th element of this array should match that name. 1121 * the 15'th element of this array should match that name.
1136 * If an entry is NULL, that is a flag not to loaded/saved. 1122 * If an entry is NULL, that is a flag not to loaded/saved.
1137 */ 1123 */
1138 static const keyword flag_names [NUM_FLAGS] = { 1124 static const keyword flag_names [NUM_FLAGS] = {
1139 KW_alive, 1125 KW_alive,
1140 KW_wiz,
1141 KW_NULL, 1126 KW_NULL,
1142 KW_NULL, 1127 KW_NULL,
1143 KW_was_wiz, 1128 KW_NULL,
1129 KW_NULL,
1144 KW_applied, 1130 KW_applied,
1145 KW_unpaid, 1131 KW_unpaid,
1146 KW_can_use_shield, 1132 KW_can_use_shield,
1147 KW_no_pick, 1133 KW_no_pick,
1148 KW_NULL, // walk_on 1134 KW_NULL, // walk_on
1431 if (owner) 1417 if (owner)
1432 return true; 1418 return true;
1433 1419
1434 archetype *at = arch ? (archetype *)arch : empty_archetype; 1420 archetype *at = arch ? (archetype *)arch : empty_archetype;
1435 1421
1436 f.put (KW_arch, at->name); 1422 f.put (KW_arch, at->archname);
1437 write_diff (f, this, &at->clone); 1423 write_diff (f, this, at);
1438 1424
1439 for (object *tmp = inv; tmp; tmp = tmp->below) 1425 for (object *tmp = inv; tmp; tmp = tmp->below)
1440 tmp->write (f); 1426 tmp->write (f);
1441 1427
1442 f.put (this); 1428 f.put (this);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines