Mercurial > hg > early-roguelike
annotate srogue/acinclude.m4 @ 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 | 15f8229f38c1 |
children | 029c1f5c5588 |
rev | line source |
---|---|
101 | 1 AC_DEFUN([MP_WITH_CURSES], |
2 [AC_ARG_WITH(ncurses, [ --with-ncurses Force the use of ncurses over curses],,) | |
3 mp_save_LIBS="$LIBS" | |
4 CURSES_LIB="" | |
5 if test "$with_ncurses" != yes | |
6 then | |
7 AC_CACHE_CHECK([for working curses], mp_cv_curses, | |
8 [LIBS="$LIBS -lcurses" | |
9 AC_TRY_LINK( | |
10 [#include <curses.h>], | |
11 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
12 mp_cv_curses=yes, mp_cv_curses=no)]) | |
13 if test "$mp_cv_curses" = yes | |
14 then | |
15 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
16 #AC_DEFINE(HAVE_CURSES_H) | |
17 CURSES_LIB="-lcurses" | |
18 fi | |
19 fi | |
20 if test ! "$CURSES_LIB" | |
21 then | |
22 AC_CACHE_CHECK([for working ncurses], mp_cv_ncurses, | |
23 [LIBS="$mp_save_LIBS -lncurses" | |
24 AC_TRY_LINK( | |
25 [#include <ncurses.h>], | |
26 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
27 mp_cv_ncurses=yes, mp_cv_ncurses=no)]) | |
28 if test "$mp_cv_ncurses" = yes | |
29 then | |
30 AC_DEFINE(HAVE_NCURSES_H, 1, [Define to 1 if libncurses is requested]) | |
31 CURSES_LIB="-lncurses" | |
32 fi | |
33 fi | |
34 if test ! "$CURSES_LIB" | |
35 then | |
36 AC_CACHE_CHECK([for working pdcurses], mp_cv_pdcurses, | |
37 [LIBS="$mp_save_LIBS -lpdcurses" | |
38 AC_TRY_LINK( | |
39 [#include <curses.h>], | |
40 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
41 mp_cv_pdcurses=yes, mp_cv_pdcurses=no)]) | |
42 if test "$mp_cv_pdcurses" = yes | |
43 then | |
44 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
45 CURSES_LIB="-lpdcurses" | |
46 fi | |
47 fi | |
48 if test ! "$CURSES_LIB" | |
49 then | |
50 AC_CACHE_CHECK([for working pdcur], mp_cv_pdcur, | |
51 [LIBS="$mp_save_LIBS -lpdcur" | |
52 AC_TRY_LINK( | |
53 [#include <curses.h>], | |
54 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
55 mp_cv_pdcur=yes, mp_cv_pdcur=no)]) | |
56 if test "$mp_cv_pdcur" = yes | |
57 then | |
58 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
59 CURSES_LIB="-lpdcur" | |
60 fi | |
61 fi | |
62 if test ! "$CURSES_LIB" | |
63 then | |
64 AC_CACHE_CHECK([for working peer pdcurses], mp_cv_lpdcurses, | |
65 [LIBS="$mp_save_LIBS ../pdcurses/pdcurses.a" | |
66 AC_TRY_LINK( | |
67 [#include "../pdcurses/curses.h"], | |
68 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ], | |
69 mp_cv_lpdcurses=yes, mp_cv_lpdcurses=no)]) | |
70 if test "$mp_cv_lpdcurses" = yes | |
71 then | |
72 AC_DEFINE(HAVE_CURSES_H, 1, [Define to 1 if libcurses is requested]) | |
73 CURSES_LIB="../pdcurses/pdcurses.a" | |
74 RF_ADDTO(CPPFLAGS,"-I../pdcurses") | |
75 fi | |
76 fi | |
77 AC_CACHE_CHECK([for ESCDELAY variable], | |
78 [mc_cv_ncurses_escdelay], | |
79 [AC_TRY_LINK([], [ | |
80 extern int ESCDELAY; | |
81 ESCDELAY = 0; | |
82 ], | |
83 [mc_cv_ncurses_escdelay=yes], | |
84 [mc_cv_ncurses_escdelay=no]) | |
85 ]) | |
86 if test "$mc_cv_ncurses_escdelay" = yes; then | |
87 AC_DEFINE(HAVE_ESCDELAY, 1, | |
88 [Define if ncurses has ESCDELAY variable]) | |
89 fi | |
90 if test ! "$CURSES_LIB" ; then | |
91 LIBS="$mp_save_LIBS" | |
92 fi | |
93 ])dnl | |
94 | |
15f8229f38c1
srogue: begin porting to autoconf.
John "Elwin" Edwards |