annotate srogue/rogue.ext @ 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 34d7a614855e
children 94a0d9dd5ce1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
1 EXTTHG player;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
2 EXTWEP weaps[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
3 EXTARM armors[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
4 EXTMON monsters[], *mtlev[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
5 EXTTRAP *trap_at(), traps[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
6 EXTROOM *roomin(), *oldrp, rooms[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
7 EXTCORD *rndmove(), *rnd_pos(), delta, stairs, oldpos, rndspot;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
8 EXTLKL *mlist, *lvl_obj, *new_item(), *new_thing(), *new_monster();
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
9 EXTLKL *find_mons(), *wake_monster(), *find_obj(), *get_item();
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
10 EXTOBJ *cur_armor, *cur_weapon, *cur_ring[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
11 EXTMAG r_magic[], s_magic[], ws_magic[], p_magic[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
12 EXTMAG things[], a_magic[], w_magic[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
13 EXTINT max_hp, quiet, food_left, hungry_state, level, max_level;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
14 EXTINT foodlev, total, count, demoncnt, fung_hit, ntraps;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
15 EXTINT lastscore, purse, mpos, seed, dnum, no_food, packvol, playuid;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
16 EXTINT curprice, trader, group, levcount, levtype, ringfood, playgid;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
17 EXTINT chkstairs(), rollwand(), swander(), notslow(), notfight(), rnd();
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
18 EXTINT rchg_str(), wghtchk(), stomach(), doctor(), runners(), status(), sight();
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
19 extern void quit(), auto_save(), endit(), byebye(), game_err();
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
20 EXTINT prntfile(), unconfuse(), sapem();
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
21 EXTINT noteth(), notregen(), notinvinc(), unsee(), nohaste(), npch();
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
22 EXTBOOL running, nochange, after, inwhgt, isfight, firstmove, nlmove;
37
34d7a614855e srogue: add support for SAVEDIR
elwin
parents: 36
diff changeset
23 EXTBOOL wizard, waswizard, in_shell, amulet, door_stop, playing, use_savedir;
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
24 EXTBOOL notify, ws_know[], p_know[], s_know[], r_know[], inpool;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
25 EXTCHAR home[], file_name[], whoami[], fruit[], curpurch[], scorefile[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
26 EXTCHAR *r_stones[], *p_colors[], *s_names[], *ws_type[], *ws_made[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
27 EXTCHAR *ws_guess[], *s_guess[], *r_guess[], *p_guess[];/*, *unctrl();*/
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
28 EXTCHAR morestr[], prbuf[], huh[], *identify(), *vowelstr();
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
29 EXTCHAR *new(), *strcpy(), *strcat(), *inv_name(), pack_char(), *prname();
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
30 EXTCHAR *num(), *getenv(), *tr_name(), *release, take, runch;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
31 EXTCHAR retstr[], wizstr[], spacemsg[], illegal[], callit[], starlist[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
32 EXTSTAT max_stats, *him;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
33 extern struct magic_info thnginfo[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
34 extern struct real re_stats;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
35 extern long e_levels[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
36 extern struct rod ws_stuff[];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
37 extern struct sgttyb _tty;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
38
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
39 extern struct coord nh;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
40 extern struct delayed_action d_list[MAXDAEMONS];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
41 extern int between;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
42
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
43 extern char *rainbow[NCOLORS];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
44 extern char *sylls[NSYLS];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
45 extern char *stones[NSTONES];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
46 extern char *wood[NWOOD];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
47 extern char *metal[NMETAL];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
48