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.62 by root, Mon Feb 19 19:10:31 2007 UTC vs.
Revision 1.67 by root, Sun Mar 18 03:05:39 2007 UTC

29#include <global.h> 29#include <global.h>
30#include <loader.h> 30#include <loader.h>
31#include <sproto.h> 31#include <sproto.h>
32 32
33///////////////////////////////////////////////////////////////////////////// 33/////////////////////////////////////////////////////////////////////////////
34
35/* Maps the MOVE_* values to names */
36static const char *const move_name[] = { "walk", "fly_low", "fly_high", "swim", "boat", NULL };
37 34
38/* This table is only necessary to convert objects that existed before the 35/* This table is only necessary to convert objects that existed before the
39 * spell object conversion to the new object. It was not practical 36 * spell object conversion to the new object. It was not practical
40 * to go through every mapping looking for every potion, rod, wand, etc 37 * to go through every mapping looking for every potion, rod, wand, etc
41 * that had a sp set and update to the new value. So this maps the 38 * that had a sp set and update to the new value. So this maps the
409 } 406 }
410 407
411} 408}
412 409
413static void 410static void
414set_move (MoveType & mt, const char *str) 411set_move (MoveType &mt, const char *str)
415{ 412{
413 static const struct flagstr {
414 const char *name;
415 MoveType flags;
416 } move_flags[] = {
417 { "walk" , MOVE_WALK },
418 { "flying" , MOVE_FLY_LOW | MOVE_FLY_HIGH },
419 { "fly_low" , MOVE_FLY_LOW },
420 { "fly_high", MOVE_FLY_HIGH },
421 { "swim" , MOVE_SWIM },
422 { "boat" , MOVE_BOAT },
423 { "all" , MOVE_ALL },
424 };
425
416 if (!str) 426 if (!str)
417 { 427 {
418 mt = 0; 428 mt = 0;
419 return; 429 return;
420 } 430 }
427 437
428 mt = 0; 438 mt = 0;
429 439
430 for (str = strtok ((char *) str, " "); str; str = strtok (0, " ")) 440 for (str = strtok ((char *) str, " "); str; str = strtok (0, " "))
431 { 441 {
432 if (!strcasecmp (str, "all")) 442 bool negate = 0;
433 mt |= MOVE_ALL; 443
434 else 444 if (*str == '-')
435 { 445 {
436 int i, negate = 0; 446 negate = 1;
447 str++;
448 }
437 449
438 if (*str == '-') 450 for (const flagstr *f = move_flags; f < move_flags + sizeof (move_flags) / sizeof (move_flags [0]); ++f)
451 {
452 if (!strcmp (f->name, str))
439 { 453 {
440 negate = 1;
441 str++;
442 }
443
444 for (i = 0; move_name[i]; i++)
445 {
446 if (!strcasecmp (move_name[i], str))
447 {
448 if (negate) 454 if (negate)
449 mt &= ~(1 << i); 455 mt &= ~f->flags;
450 else
451 mt |= (1 << i);
452
453 break;
454 }
455 }
456
457 if (!move_name[i])
458 {
459 /* fly is a special case - covers both fly_low and
460 * fly_high - since it doesn't match to a specific
461 * single bit, have to special case it.
462 */
463 if (!strcasecmp (str, "flying"))
464 {
465 if (negate)
466 mt &= ~MOVE_FLYING;
467 else
468 mt |= MOVE_FLYING;
469 }
470 else 456 else
471 LOG (llevDebug, "common/loader.l: set_move - unknown move string '%s'\n", str); 457 mt |= f->flags;
458
459 goto next;
472 } 460 }
473 } 461 }
462
463 LOG (llevDebug, "common/loader.C: set_move - unknown move string '%s'\n", str);
464
465next: ;
474 } 466 }
475} 467}
476 468
477#define GET_FLAG(op,flag) \ 469#define GET_FLAG(op,flag) \
478 if (f.get_sint32 ()) \ 470 if (f.get_sint32 ()) \
595 move_slow |= MOVE_WALK; 587 move_slow |= MOVE_WALK;
596 f.get (move_slow_penalty); 588 f.get (move_slow_penalty);
597 break; 589 break;
598 590
599 case KW_face: 591 case KW_face:
600 face = &new_faces[FindFace (f.get_str (), 0)]; 592 face = face_find (f.get_str ());
601 break; 593 break;
602 594
603 case KW_x: f.get (x); break; 595 case KW_x: f.get (x); break;
604 case KW_y: f.get (y); break; 596 case KW_y: f.get (y); break;
605 597
886 case KW_glow_radius: f.get (glow_radius); break; 878 case KW_glow_radius: f.get (glow_radius); break;
887 case KW_weapontype: f.get (weapontype); break; 879 case KW_weapontype: f.get (weapontype); break;
888 case KW_tooltype: f.get (tooltype); break; 880 case KW_tooltype: f.get (tooltype); break;
889 case KW_casting_time: f.get (casting_time); break; 881 case KW_casting_time: f.get (casting_time); break;
890 case KW_elevation: f.get (elevation); break; 882 case KW_elevation: f.get (elevation); break;
891 case KW_smoothlevel: f.get (smoothlevel); break; 883 case KW_smoothlevel: f.get (smoothlevel); smoothlevel = clamp (smoothlevel, 0, 255); break;
892 case KW_client_type: f.get (client_type); break; 884 case KW_client_type: f.get (client_type); break;
893 case KW_duration: f.get (duration); break; 885 case KW_duration: f.get (duration); break;
894 case KW_range: f.get (range); break; 886 case KW_range: f.get (range); break;
895 case KW_range_modifier: f.get (range_modifier); break; 887 case KW_range_modifier: f.get (range_modifier); break;
896 case KW_dam_modifier: f.get (dam_modifier); break; 888 case KW_dam_modifier: f.get (dam_modifier); break;
1251 f.put (KW_msg, KW_endmsg, op->msg); 1243 f.put (KW_msg, KW_endmsg, op->msg);
1252 if (op->lore != tmp->lore) 1244 if (op->lore != tmp->lore)
1253 f.put (KW_lore, KW_endlore, op->lore); 1245 f.put (KW_lore, KW_endlore, op->lore);
1254 1246
1255 CMP_OUT (other_arch); 1247 CMP_OUT (other_arch);
1256 CMP_OUT (face); 1248
1249 if (op->face != tmp->face) f.put (KW_face, op->face ? &faces [op->face] : 0);
1257 1250
1258 if (op->animation_id != tmp->animation_id) 1251 if (op->animation_id != tmp->animation_id)
1259 if (op->animation_id) 1252 if (op->animation_id)
1260 { 1253 {
1261 f.put (KW_animation, animations[GET_ANIM_ID (op)].name); 1254 f.put (KW_animation, animations[GET_ANIM_ID (op)].name);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines