Mercurial > hg > early-roguelike
comparison urogue/state.c @ 262:c7c6c5a7d840
UltraRogue: fix a segfault related to restoring monsters.
The functions for restoring saved games failed to properly correct the
t_chasee pointer of monsters chasing the player. Such monsters would
attempt to chase NULL instead, with predictable results.
author | John "Elwin" Edwards |
---|---|
date | Tue, 14 Feb 2017 20:42:33 -0500 |
parents | b80e1bf4eaec |
children | 08057be02f47 |
comparison
equal
deleted
inserted
replaced
261:ac42afd962e4 | 262:c7c6c5a7d840 |
---|---|
676 void | 676 void |
677 ur_fixup_monsters(struct linked_list *l) | 677 ur_fixup_monsters(struct linked_list *l) |
678 { | 678 { |
679 while(l != NULL) | 679 while(l != NULL) |
680 { | 680 { |
681 if (l->data.th->t_chasee == (void *) -1L) | 681 if (l->data.th->chasee_index == -1L) |
682 l->data.th->t_chasee = &player; | 682 l->data.th->t_chasee = &player; |
683 else | 683 else |
684 l->data.th->t_chasee = find_thing(mlist, l->data.th->chasee_index); | 684 l->data.th->t_chasee = find_thing(mlist, l->data.th->chasee_index); |
685 | 685 |
686 l->data.th->t_horde = find_object(lvl_obj, l->data.th->horde_index); | 686 l->data.th->t_horde = find_object(lvl_obj, l->data.th->horde_index); |
1338 mlist = ur_read_monsters(savef); | 1338 mlist = ur_read_monsters(savef); |
1339 i = ur_read_int(savef); | 1339 i = ur_read_int(savef); |
1340 beast = find_thing(mlist, i); | 1340 beast = find_thing(mlist, i); |
1341 | 1341 |
1342 ur_fixup_monsters(fam_ptr); | 1342 ur_fixup_monsters(fam_ptr); |
1343 ur_fixup_monsters(fam_ptr); | 1343 ur_fixup_monsters(mlist); |
1344 | 1344 |
1345 DUMPSTRING | 1345 DUMPSTRING |
1346 i = ur_read_int(savef); | 1346 i = ur_read_int(savef); |
1347 cur_weapon = find_object(player.t_pack, i); | 1347 cur_weapon = find_object(player.t_pack, i); |
1348 | 1348 |