Mercurial > hg > early-roguelike
annotate xrogue/state.c @ 212:12e070d1a780
rogue3: replace alarm() calls with a portable function.
Calls to alarm() in main.c are replaced with md_start_checkout_timer(),
so the #ifdefs around nonportable code can be confined to mdport.c.
author | John "Elwin" Edwards |
---|---|
date | Fri, 22 Jan 2016 19:19:48 -0500 |
parents | 3def5e487faa |
children | f54901b9c39b |
rev | line source |
---|---|
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
1 /* |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
2 state.c - Portable Rogue Save State Code |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
3 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
4 Copyright (C) 2000 Nicholas J. Kisseberth |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
5 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
6 Redistribution and use in source and binary forms, with or without |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
7 modification, are permitted provided that the following conditions |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
8 are met: |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
9 1. Redistributions of source code must retain the above copyright |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
10 notice, this list of conditions and the following disclaimer. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
11 2. Redistributions in binary form must reproduce the above copyright |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
12 notice, this list of conditions and the following disclaimer in the |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
13 documentation and/or other materials provided with the distribution. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
14 3. Neither the name(s) of the author(s) nor the names of other contributors |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
15 may be used to endorse or promote products derived from this software |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
16 without specific prior written permission. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
17 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
18 THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
21 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
24 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
26 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
27 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
28 SUCH DAMAGE. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
29 */ |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
30 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
31 #define RSXR_STATS 0xABCD0001 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
32 #define RSXR_THING 0xABCD0002 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
33 #define RSXR_OBJECT 0xABCD0003 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
34 #define RSXR_MAGICITEMS 0xABCD0004 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
35 #define RSXR_KNOWS 0xABCD0005 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
36 #define RSXR_GUESSES 0xABCD0006 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
37 #define RSXR_OBJECTLIST 0xABCD0007 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
38 #define RSXR_BAGOBJECT 0xABCD0008 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
39 #define RSXR_MONSTERLIST 0xABCD0009 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
40 #define RSXR_MONSTERSTATS 0xABCD000A |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
41 #define RSXR_MONSTERS 0xABCD000B |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
42 #define RSXR_TRAP 0xABCD000C |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
43 #define RSXR_WINDOW 0xABCD000D |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
44 #define RSXR_DAEMONS 0xABCD000E |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
45 #define RSXR_IWEAPS 0xABCD000F |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
46 #define RSXR_IARMOR 0xABCD0010 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
47 #define RSXR_SPELLS 0xABCD0011 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
48 #define RSXR_ILIST 0xABCD0012 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
49 #define RSXR_HLIST 0xABCD0013 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
50 #define RSXR_DEATHTYPE 0xABCD0014 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
51 #define RSXR_CTYPES 0XABCD0015 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
52 #define RSXR_COORDLIST 0XABCD0016 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
53 #define RSXR_ROOMS 0XABCD0017 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
54 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
55 #if defined(_WIN32) |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
56 #include <Windows.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
57 #include <Lmcons.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
58 #include <shlobj.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
59 #include <Shlwapi.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
60 #undef VOID |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
61 #undef MOUSE_MOVED |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
62 #elif defined(__DJGPP__) |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
63 #include <process.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
64 #else |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
65 #include <pwd.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
66 #include <sys/utsname.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
67 #include <unistd.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
68 #endif |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
69 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
70 #include <stdlib.h> |
135 | 71 #include <string.h> |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
72 #include <curses.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
73 #include <sys/stat.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
74 #include <stdio.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
75 #include <stdarg.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
76 #include <assert.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
77 #include <fcntl.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
78 #include <limits.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
79 #include <time.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
80 #include <signal.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
81 #include "rogue.h" |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
82 #include "mach_dep.h" |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
83 |
205 | 84 #if defined(_WIN32) |
85 #include <process.h> | |
86 #endif | |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
87 |
206
a3d90e31a001
XRogue: add and use more md_ functions.
John "Elwin" Edwards
parents:
205
diff
changeset
|
88 int md_fileno(FILE *fp); |
a3d90e31a001
XRogue: add and use more md_ functions.
John "Elwin" Edwards
parents:
205
diff
changeset
|
89 |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
90 #define READSTAT ((format_error == 0) && (read_error == 0)) |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
91 #define WRITESTAT (write_error == 0) |