… | |
… | |
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; |
… | |
… | |
1119 | * override values and in c_wiz to mutate values. |
1113 | * override values and in c_wiz to mutate values. |
1120 | */ |
1114 | */ |
1121 | int |
1115 | int |
1122 | set_variable (object *op, char *buf) |
1116 | set_variable (object *op, char *buf) |
1123 | { |
1117 | { |
1124 | object_thawer f (buf, (AV *)0); |
1118 | object_thawer f (format ("%s\nend", buf), (AV *)0); |
1125 | |
1119 | |
1126 | return op->parse_kv (f); |
1120 | return op->parse_kv (f); |
1127 | } |
1121 | } |
1128 | |
1122 | |
1129 | // compare *op against *arch and output differences |
1123 | // compare *op against *arch and output differences |
… | |
… | |
1451 | CMP_OUT (move_slow); |
1445 | CMP_OUT (move_slow); |
1452 | CMP_OUT (move_slow_penalty); |
1446 | CMP_OUT (move_slow_penalty); |
1453 | |
1447 | |
1454 | object::flags_t diff = (op->flag ^ arch->flag) & flagmask; |
1448 | object::flags_t diff = (op->flag ^ arch->flag) & flagmask; |
1455 | |
1449 | |
|
|
1450 | #if stdcpp // we need gcc, sorry |
1456 | if (diff [FLAG_OBJ_ORIGINAL]) |
1451 | if (diff [FLAG_OBJ_ORIGINAL]) |
1457 | f.put (flag_names [FLAG_OBJ_ORIGINAL], op->flag [FLAG_OBJ_ORIGINAL] ? CS(1) : CS(0)); |
1452 | f.put (flag_names [FLAG_OBJ_ORIGINAL], op->flag [FLAG_OBJ_ORIGINAL] ? CS(1) : CS(0)); |
1458 | |
1453 | |
1459 | diff.reset (FLAG_OBJ_ORIGINAL); |
1454 | diff.reset (FLAG_OBJ_ORIGINAL); |
1460 | |
1455 | |
1461 | // quickly test whether any other flags differ |
1456 | // quickly test whether any other flags differ |
1462 | if (expect_true (diff.any ())) |
1457 | if (expect_true (diff.any ())) |
1463 | for (int i = 0; i < NUM_FLAGS; i++) |
1458 | for (int i = 0; i < NUM_FLAGS; i++) |
1464 | if (expect_false (diff [i])) |
1459 | if (expect_false (diff [i])) |
1465 | f.put (flag_names [i], op->flag [i] ? CS(1) : CS(0)); |
1460 | f.put (flag_names [i], op->flag [i] ? CS(1) : CS(0)); |
|
|
1461 | #else |
|
|
1462 | // use sgi extensions |
|
|
1463 | for (int i = diff._Find_first (); i < diff.size (); i = diff._Find_next (i)) |
|
|
1464 | f.put (flag_names [i], op->flag [i] ? CS(1) : CS(0)); |
|
|
1465 | #endif |
1466 | |
1466 | |
1467 | // save body locations. gcc's memcmp does an abysmal job when used |
1467 | // save body locations. gcc's memcmp does an abysmal job when used |
1468 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1468 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1469 | if (expect_false (op->slot[i].info != arch->slot[i].info)) |
1469 | if (expect_false (op->slot[i].info != arch->slot[i].info)) |
1470 | f.put (body_locations[i].save_name, op->slot[i].info); |
1470 | f.put (body_locations[i].kw, op->slot[i].info); |
1471 | } |
1471 | } |
1472 | |
1472 | |
1473 | /* |
1473 | /* |
1474 | * Dumps all variables in an object to a file. |
1474 | * Dumps all variables in an object to a file. |
1475 | * If bit 0 of flag is set, unpaid objects will be saved. As of now, |
1475 | * If bit 0 of flag is set, unpaid objects will be saved. As of now, |
… | |
… | |
1507 | { |
1507 | { |
1508 | object_thawer f (filename); |
1508 | object_thawer f (filename); |
1509 | |
1509 | |
1510 | for (;;) |
1510 | for (;;) |
1511 | { |
1511 | { |
|
|
1512 | coroapi::cede_to_tick (); |
|
|
1513 | |
1512 | switch (f.kw) |
1514 | switch (f.kw) |
1513 | { |
1515 | { |
1514 | case KW_region: |
1516 | case KW_region: |
1515 | if (!region::read (f)) |
1517 | if (!region::read (f)) |
1516 | return false; |
1518 | return false; |