… | |
… | |
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 */ |
|
|
36 | static 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 | |
413 | static void |
410 | static void |
414 | set_move (MoveType & mt, const char *str) |
411 | set_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 | |
|
|
465 | next: ; |
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; |
… | |
… | |
976 | object::read (object_thawer &f, maptile *map) |
968 | object::read (object_thawer &f, maptile *map) |
977 | { |
969 | { |
978 | assert (f.kw == KW_arch); |
970 | assert (f.kw == KW_arch); |
979 | |
971 | |
980 | archetype *arch = archetype::find (f.get_str ()); |
972 | archetype *arch = archetype::find (f.get_str ()); |
|
|
973 | |
|
|
974 | if (!arch) |
|
|
975 | { |
|
|
976 | LOG (llevError, "object refering to nonexistant archetype '%s'.\n", f.get_str ()); |
|
|
977 | arch = archetype::find ("earthwall"); |
|
|
978 | } |
|
|
979 | |
981 | assert (arch); //D maybe use exception handling of sorts? |
980 | assert (arch); //D maybe use exception handling of sorts? |
982 | |
981 | |
983 | object *op = object::create (); |
982 | object *op = object::create (); |
984 | |
983 | |
985 | op->map = map; |
984 | op->map = map; |
… | |
… | |
1006 | int |
1005 | int |
1007 | set_variable (object *op, char *buf) |
1006 | set_variable (object *op, char *buf) |
1008 | { |
1007 | { |
1009 | object_thawer f (buf, (AV *)0); |
1008 | object_thawer f (buf, (AV *)0); |
1010 | |
1009 | |
|
|
1010 | f.kw = KW_arch; // special hack so that parse_kv skips |
1011 | return op->parse_kv (f); |
1011 | return op->parse_kv (f); |
1012 | } |
1012 | } |
1013 | |
1013 | |
1014 | /* This returns a string of the integer movement type */ |
1014 | /* This returns a string of the integer movement type */ |
1015 | #if 0 |
1015 | #if 0 |
… | |
… | |
1243 | f.put (KW_msg, KW_endmsg, op->msg); |
1243 | f.put (KW_msg, KW_endmsg, op->msg); |
1244 | if (op->lore != tmp->lore) |
1244 | if (op->lore != tmp->lore) |
1245 | f.put (KW_lore, KW_endlore, op->lore); |
1245 | f.put (KW_lore, KW_endlore, op->lore); |
1246 | |
1246 | |
1247 | CMP_OUT (other_arch); |
1247 | CMP_OUT (other_arch); |
1248 | CMP_OUT (face); |
1248 | |
|
|
1249 | if (op->face != tmp->face) f.put (KW_face, op->face ? &faces [op->face] : 0); |
1249 | |
1250 | |
1250 | if (op->animation_id != tmp->animation_id) |
1251 | if (op->animation_id != tmp->animation_id) |
1251 | if (op->animation_id) |
1252 | if (op->animation_id) |
1252 | { |
1253 | { |
1253 | f.put (KW_animation, animations[GET_ANIM_ID (op)].name); |
1254 | f.put (KW_animation, animations[GET_ANIM_ID (op)].name); |