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,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 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 |
… | |
… | |
265 | type = 0; |
265 | type = 0; |
266 | } |
266 | } |
267 | |
267 | |
268 | switch (type) |
268 | switch (type) |
269 | { |
269 | { |
|
|
270 | case RANGED: |
270 | case BOW: |
271 | case BOW: |
271 | case WAND: |
272 | case WAND: |
272 | case ROD: |
273 | case ROD: |
273 | case HORN: |
274 | case HORN: |
274 | if (slot [body_range].info != -1) |
275 | if (slot [body_range].info != -1) |
… | |
… | |
522 | { |
523 | { |
523 | negate = 1; |
524 | negate = 1; |
524 | str++; |
525 | str++; |
525 | } |
526 | } |
526 | |
527 | |
527 | for (const flagstr *f = move_flags; f < move_flags + sizeof (move_flags) / sizeof (move_flags [0]); ++f) |
528 | for (const flagstr *f = move_flags; f < move_flags + array_length (move_flags); ++f) |
528 | { |
529 | { |
529 | if (!strcmp (f->name, str)) |
530 | if (!strcmp (f->name, str)) |
530 | { |
531 | { |
531 | if (negate) |
532 | if (negate) |
532 | mt &= ~f->flags; |
533 | mt &= ~f->flags; |
… | |
… | |
736 | case KW_invisible: f.get (invisible); break; |
737 | case KW_invisible: f.get (invisible); break; |
737 | case KW_magic: f.get (magic); break; |
738 | case KW_magic: f.get (magic); break; |
738 | case KW_state: f.get (state); break; |
739 | case KW_state: f.get (state); break; |
739 | case KW_move_slow_penalty: f.get (move_slow_penalty); break; |
740 | case KW_move_slow_penalty: f.get (move_slow_penalty); break; |
740 | case KW_material: f.get (materials); break; //TODO: nuke |
741 | case KW_material: f.get (materials); break; //TODO: nuke |
741 | |
742 | case KW_materialname: f.get (material); break; |
742 | case KW_materialname: |
|
|
743 | { |
|
|
744 | shstr sh; |
|
|
745 | f.get (sh); |
|
|
746 | material = name_to_material (sh); |
|
|
747 | } |
|
|
748 | break; |
|
|
749 | |
743 | |
750 | /* These are the new values */ |
744 | /* These are the new values */ |
751 | case KW_move_block: set_move (move_block, f); break; |
745 | case KW_move_block: set_move (move_block, f); break; |
752 | case KW_move_allow: set_move (move_allow, f); break; |
746 | case KW_move_allow: set_move (move_allow, f); break; |
753 | case KW_move_type: set_move (move_type , f); break; |
747 | case KW_move_type: set_move (move_type , f); break; |
… | |
… | |
924 | case KW_is_buildable: GET_FLAG (this, FLAG_IS_BUILDABLE); break; |
918 | case KW_is_buildable: GET_FLAG (this, FLAG_IS_BUILDABLE); break; |
925 | case KW_destroy_on_death: GET_FLAG (this, FLAG_DESTROY_ON_DEATH); break; |
919 | case KW_destroy_on_death: GET_FLAG (this, FLAG_DESTROY_ON_DEATH); break; |
926 | case KW_treasure_env: GET_FLAG (this, FLAG_TREASURE_ENV); break; |
920 | case KW_treasure_env: GET_FLAG (this, FLAG_TREASURE_ENV); break; |
927 | case KW_precious: GET_FLAG (this, FLAG_PRECIOUS); break; |
921 | case KW_precious: GET_FLAG (this, FLAG_PRECIOUS); break; |
928 | case KW_random_speed: GET_FLAG (this, FLAG_RANDOM_SPEED); break; |
922 | case KW_random_speed: GET_FLAG (this, FLAG_RANDOM_SPEED); break; |
|
|
923 | case KW_is_quad: GET_FLAG (this, FLAG_IS_QUAD); break; |
929 | |
924 | |
930 | case KW_armour: f.get (resist[ATNR_PHYSICAL]); break; |
925 | case KW_armour: f.get (resist[ATNR_PHYSICAL]); break; |
931 | case KW_resist_physical: f.get (resist[ATNR_PHYSICAL]); break; |
926 | case KW_resist_physical: f.get (resist[ATNR_PHYSICAL]); break; |
932 | case KW_resist_magic: f.get (resist[ATNR_MAGIC]); break; |
927 | case KW_resist_magic: f.get (resist[ATNR_MAGIC]); break; |
933 | case KW_resist_fire: f.get (resist[ATNR_FIRE]); break; |
928 | case KW_resist_fire: f.get (resist[ATNR_FIRE]); break; |
… | |
… | |
1087 | |
1082 | |
1088 | archetype *arch = archetype::find (f.get_str ()); |
1083 | archetype *arch = archetype::find (f.get_str ()); |
1089 | |
1084 | |
1090 | if (!arch) |
1085 | if (!arch) |
1091 | { |
1086 | { |
1092 | LOG (llevError, "object refering to nonexistant archetype '%s'.\n", f.get_str ()); |
1087 | LOG (llevError, "object referring to nonexistent archetype '%s'.\n", f.get_str ()); |
1093 | arch = archetype::find (shstr_earthwall); |
1088 | arch = archetype::find (shstr_earthwall); |
1094 | } |
1089 | } |
1095 | |
1090 | |
1096 | assert (arch); //D maybe use exception handling of sorts? |
1091 | assert (arch); //D maybe use exception handling of sorts? |
1097 | |
1092 | |
… | |
… | |
1119 | * override values and in c_wiz to mutate values. |
1114 | * override values and in c_wiz to mutate values. |
1120 | */ |
1115 | */ |
1121 | int |
1116 | int |
1122 | set_variable (object *op, char *buf) |
1117 | set_variable (object *op, char *buf) |
1123 | { |
1118 | { |
1124 | object_thawer f (buf, (AV *)0); |
1119 | object_thawer f (format ("%s\nend", buf), (AV *)0); |
1125 | |
1120 | |
1126 | return op->parse_kv (f); |
1121 | return op->parse_kv (f); |
1127 | } |
1122 | } |
1128 | |
1123 | |
1129 | // compare *op against *arch and output differences |
1124 | // compare *op against *arch and output differences |
… | |
… | |
1471 | #endif |
1466 | #endif |
1472 | |
1467 | |
1473 | // save body locations. gcc's memcmp does an abysmal job when used |
1468 | // save body locations. gcc's memcmp does an abysmal job when used |
1474 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1469 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1475 | if (expect_false (op->slot[i].info != arch->slot[i].info)) |
1470 | if (expect_false (op->slot[i].info != arch->slot[i].info)) |
1476 | f.put (body_locations[i].save_name, op->slot[i].info); |
1471 | f.put (body_locations[i].kw, op->slot[i].info); |
1477 | } |
1472 | } |
1478 | |
1473 | |
1479 | /* |
1474 | /* |
1480 | * Dumps all variables in an object to a file. |
1475 | * Dumps all variables in an object to a file. |
1481 | * If bit 0 of flag is set, unpaid objects will be saved. As of now, |
1476 | * If bit 0 of flag is set, unpaid objects will be saved. As of now, |
… | |
… | |
1513 | { |
1508 | { |
1514 | object_thawer f (filename); |
1509 | object_thawer f (filename); |
1515 | |
1510 | |
1516 | for (;;) |
1511 | for (;;) |
1517 | { |
1512 | { |
|
|
1513 | coroapi::cede_to_tick (); |
|
|
1514 | |
1518 | switch (f.kw) |
1515 | switch (f.kw) |
1519 | { |
1516 | { |
1520 | case KW_region: |
1517 | case KW_region: |
1521 | if (!region::read (f)) |
1518 | if (!region::read (f)) |
1522 | return false; |
1519 | return false; |