comparison rogue5/state.c @ 111:7f8f43943b1f

Fix some terribly depressing corruption during restore. In rogue5/state.c, rs_read_daemons() zeroes out the argument and delay if the daemon slot is empty. Unfortunately that code ended up on the wrong side of the brace that closes the for loop, so instead of running after each daemon, it got run once after the loop exited, when the index was of course out of bounds. This tended to manifest, when compiled with -O2, by overwriting hw and setting it to NULL. When inventory() next ran, hw would be passed to wgetch(), which returns ERR when it gets a NULL argument. This made md_readchar() think something was wrong and autosave the game. Upon investigation, rogue3 was found to commit the same mistake. rogue4 and srogue don't zero the data. arogue5 already does it properly. Someday I am going to run all this through Valgrind. Someday when I am a kinder person who will not be driven to invoke hordes of trolls and centaurs upon the original authors.
author John "Elwin" Edwards
date Wed, 08 Jan 2014 16:44:16 -0500
parents 09db0cf536af
children d10fc4a065ac
comparison
equal deleted inserted replaced
110:5f51f7d9805f 111:7f8f43943b1f
658 case 9: dlist[i].d_func = sight; 658 case 9: dlist[i].d_func = sight;
659 break; 659 break;
660 default:dlist[i].d_func = NULL; 660 default:dlist[i].d_func = NULL;
661 break; 661 break;
662 } 662 }
663 } 663
664 664 if (dlist[i].d_func == NULL)
665 if (dlist[i].d_func == NULL) 665 {
666 { 666 dlist[i].d_type = 0;
667 dlist[i].d_type = 0; 667 dlist[i].d_arg = 0;
668 dlist[i].d_arg = 0; 668 dlist[i].d_time = 0;
669 dlist[i].d_time = 0; 669 }
670 } 670 }
671
671 } 672 }
672 673
673 void 674 void
674 rs_write_obj_info(FILE *savef, struct obj_info *i, int cnt) 675 rs_write_obj_info(FILE *savef, struct obj_info *i, int cnt)
675 { 676 {