annotate xrogue/state.c @ 205:6e6fb0955095

XRogue: fix some header includes.
author John "Elwin" Edwards
date Thu, 13 Aug 2015 14:57:26 -0400
parents 9b5f1e6aa35a
children a3d90e31a001
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
ce0cf824c192 xrogue: add missing includes.
John "Elwin" Edwards
parents: 134
diff changeset
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
6e6fb0955095 XRogue: fix some header includes.
John "Elwin" Edwards
parents: 166
diff changeset
84 #if defined(_WIN32)
6e6fb0955095 XRogue: fix some header includes.
John "Elwin" Edwards
parents: 166
diff changeset
85 #include <process.h>
6e6fb0955095 XRogue: fix some header includes.
John "Elwin" Edwards
parents: 166
diff changeset
86 #endif
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
87
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
88 #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
89 #define WRITESTAT (write_error == 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
90
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
91 int read_error = FALSE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
92 int write_error = FALSE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
93 int format_error = FALSE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
94
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
95 int save_debug = FALSE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
96 #define DBG(x) {if (save_debug) rsPrintf x;}
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
97
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
98 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
99 rsPrintf(char *fmt, ...)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
100 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
101 va_list ap;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
102
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
103 va_start(ap, fmt);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
104 vfprintf(stderr,fmt, ap);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
105 va_end(ap);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
106
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
107 return(0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
108 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
109
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
110
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
111 void *
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
112 get_list_item(struct linked_list *l, int i)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
113 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
114 int count = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
115
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
116 while(l != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
117 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
118 if (count == i)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
119 return(l->l_data);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
120
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
121 l = l->l_next;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
122
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
123 count++;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
124 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
125
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
126 return(NULL);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
127 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
128
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
129 rs_write(FILE *savef, void *ptr, size_t size)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
130 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
131 size_t i = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
132
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
133 if (!write_error)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
134 i = ENCWRITE(ptr,size,savef);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
135 if (i != size)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
136 write_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
137
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
138 assert(write_error == 0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
139 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
140 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
141
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
142 int end_of_file = FALSE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
143
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
144 rs_read(int inf, void *ptr, size_t size)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
145 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
146 int actual;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
147 end_of_file =FALSE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
148 if (!read_error && !format_error)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
149 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
150 actual = ENCREAD(ptr, size, inf);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
151
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
152 if ((actual == 0) && (size != 0))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
153 end_of_file = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
154 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
155
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
156 if (read_error){
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
157 printf("read error has occurred. restore short-circuited.\n");abort();}
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
158 if (format_error)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
159 {printf("game format invalid. restore short-circuited.\n");abort();}
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
160
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
161 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
162 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
163
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
164 int big_endian = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
165
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
166 rs_write_uint(FILE *savef, unsigned int c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
167 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
168 char bytes[4];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
169 char *buf = (char *) &c;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
170
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
171 if (big_endian)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
172 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
173 bytes[3] = buf[0];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
174 bytes[2] = buf[1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
175 bytes[1] = buf[2];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
176 bytes[0] = buf[3];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
177 buf = bytes;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
178 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
179
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
180 rs_write(savef, buf, 4);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
181
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
182 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
183 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
184
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
185 rs_write_int(FILE *savef, int c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
186 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
187 char bytes[4];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
188 char *buf = (char *) &c;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
189
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
190 if (big_endian)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
191 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
192 bytes[3] = buf[0];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
193 bytes[2] = buf[1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
194 bytes[1] = buf[2];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
195 bytes[0] = buf[3];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
196 buf = bytes;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
197 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
198
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
199 rs_write(savef, buf, 4);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
200
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
201 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
202 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
203
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
204 rs_write_ulong(FILE *savef, unsigned long c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
205 {
166
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
206 unsigned int c2;
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
207 char bytes[4];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
208 char *buf = (char *)&c;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
209
166
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
210 if ( (sizeof(long) == 8) && (sizeof(int) == 4) )
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
211 {
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
212 c2 = c;
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
213 buf = (char *) &c2;
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
214 }
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
215
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
216 if (big_endian)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
217 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
218 bytes[3] = buf[0];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
219 bytes[2] = buf[1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
220 bytes[1] = buf[2];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
221 bytes[0] = buf[3];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
222 buf = bytes;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
223 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
224
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
225 rs_write(savef, buf, 4);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
226
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
227 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
228 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
229
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
230 rs_write_long(FILE *savef, long c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
231 {
166
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
232 int c2;
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
233 char bytes[4];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
234 char *buf = (char *)&c;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
235
166
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
236 if ( (sizeof(long) == 8) && (sizeof(int) == 4) )
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
237 {
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
238 c2 = c;
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
239 buf = (char *) &c2;
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
240 }
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
241
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
242 if (big_endian)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
243 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
244 bytes[3] = buf[0];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
245 bytes[2] = buf[1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
246 bytes[1] = buf[2];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
247 bytes[0] = buf[3];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
248 buf = bytes;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
249 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
250
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
251 rs_write(savef, buf, 4);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
252
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
253 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
254 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
255
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
256 rs_write_boolean(FILE *savef, bool c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
257 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
258 char buf;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
259
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
260 if (c == 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
261 buf = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
262 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
263 buf = 1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
264
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
265 rs_write(savef, &buf, 1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
266
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
267 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
268 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
269
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
270 rs_read_int(int inf, int *i)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
271 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
272 char bytes[4];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
273 int input;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
274 char *buf = (char *)&input;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
275
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
276 rs_read(inf, &input, 4);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
277
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
278 if (big_endian)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
279 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
280 bytes[3] = buf[0];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
281 bytes[2] = buf[1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
282 bytes[1] = buf[2];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
283 bytes[0] = buf[3];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
284 buf = bytes;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
285 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
286
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
287 *i = *((int *) buf);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
288
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
289 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
290 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
291
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
292 rs_read_uint(int inf, unsigned int *i)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
293 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
294 char bytes[4];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
295 int input;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
296 char *buf = (char *)&input;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
297
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
298 rs_read(inf, &input, 4);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
299
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
300 if (big_endian)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
301 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
302 bytes[3] = buf[0];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
303 bytes[2] = buf[1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
304 bytes[1] = buf[2];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
305 bytes[0] = buf[3];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
306 buf = bytes;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
307 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
308
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
309 *i = *((int *) buf);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
310
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
311 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
312 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
313
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
314 rs_read_ulong(int inf, unsigned long *i)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
315 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
316 char bytes[4];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
317 unsigned long input;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
318 char *buf = (char *) &input;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
319
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
320 rs_read(inf, &input, 4);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
321
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
322 if (big_endian)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
323 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
324 bytes[3] = buf[0];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
325 bytes[2] = buf[1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
326 bytes[1] = buf[2];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
327 bytes[0] = buf[3];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
328 buf = bytes;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
329 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
330
166
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
331 if ( (sizeof(long) == 8) && (sizeof(int) == 4) )
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
332 *i = *((unsigned int *) buf);
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
333 else
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
334 *i = *((unsigned long *) buf);
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
335 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
336 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
337
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
338 rs_read_long(int inf, long *i)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
339 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
340 char bytes[4];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
341 long input;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
342 char *buf = (char *) &input;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
343
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
344 rs_read(inf, &input, 4);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
345
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
346 if (big_endian)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
347 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
348 bytes[3] = buf[0];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
349 bytes[2] = buf[1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
350 bytes[1] = buf[2];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
351 bytes[0] = buf[3];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
352 buf = bytes;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
353 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
354
166
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
355 if ( (sizeof(long) == 8) && (sizeof(int) == 4) )
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
356 *i = *((int *) buf);
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
357 else
9b5f1e6aa35a arogue7, xrogue: fix uninitialized variables when restoring.
John "Elwin" Edwards
parents: 155
diff changeset
358 *i = *((long *) buf);
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
359 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
360 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
361
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
362 rs_read_boolean(int inf, bool *i)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
363 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
364 char buf;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
365
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
366 rs_read(inf, &buf, 1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
367
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
368 *i = buf;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
369
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
370 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
371 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
372
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
373 rs_write_ints(FILE *savef, int *c, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
374 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
375 int n=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
376
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
377 rs_write_int(savef,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
378
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
379 for(n=0;n<count;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
380 rs_write_int(savef,c[n]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
381
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
382 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
383 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
384
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
385 rs_write_short(FILE *savef, short c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
386 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
387 char bytes[2];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
388 char *buf = (char *) &c;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
389
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
390 if (big_endian)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
391 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
392 bytes[1] = buf[0];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
393 bytes[0] = buf[1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
394 buf = bytes;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
395 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
396
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
397 rs_write(savef, buf, 2);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
398
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
399 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
400 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
401
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
402 rs_read_short(int inf, short *s)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
403 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
404 char bytes[2];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
405 short input;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
406 char *buf = (char *)&input;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
407
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
408 rs_read(inf, &input, 2);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
409
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
410 if (big_endian)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
411 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
412 bytes[1] = buf[0];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
413 bytes[0] = buf[1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
414 buf = bytes;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
415 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
416
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
417 *s = *((short *) buf);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
418 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
419 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
420
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
421
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
422 rs_write_shorts(FILE *savef, short *c, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
423 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
424 int n=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
425
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
426 rs_write_int(savef,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
427
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
428 for(n=0;n<count;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
429 rs_write_short(savef,c[n]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
430
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
431 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
432 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
433
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
434 rs_write_longs(FILE *savef, long *c, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
435 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
436 int n=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
437
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
438 rs_write_int(savef,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
439
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
440 for(n=0;n<count;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
441 rs_write_long(savef,c[n]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
442
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
443 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
444 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
445
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
446 rs_write_ulongs(FILE *savef, unsigned long *c, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
447 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
448 int n=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
449
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
450 rs_write_int(savef,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
451
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
452 for(n=0;n<count;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
453 rs_write_ulong(savef,c[n]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
454
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
455 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
456 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
457
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
458 rs_write_booleans(FILE *savef, bool *c, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
459 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
460 int n=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
461
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
462 rs_write_int(savef,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
463
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
464 for(n=0;n<count;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
465 rs_write_boolean(savef,c[n]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
466
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
467 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
468 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
469
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
470 rs_read_ints(int inf, int *i, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
471 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
472 int n=0,value=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
473
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
474 if (rs_read_int(inf,&value) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
475 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
476 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
477 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
478 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
479 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
480 for(n=0;n<value;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
481 rs_read_int(inf, &i[n]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
482 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
483 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
484
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
485 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
486 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
487
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
488 rs_read_shorts(int inf, short *i, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
489 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
490 int n=0,value=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
491
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
492 if (rs_read_int(inf,&value) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
493 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
494 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
495 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
496 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
497 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
498 for(n=0;n<value;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
499 rs_read_short(inf, &i[n]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
500 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
501 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
502
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
503 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
504 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
505
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
506 rs_read_longs(int inf, long *i, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
507 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
508 int n=0,value=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
509
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
510 if (rs_read_int(inf,&value) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
511 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
512 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
513 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
514 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
515 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
516 for(n=0;n<value;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
517 rs_read_long(inf, &i[n]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
518 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
519 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
520
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
521 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
522 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
523
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
524 rs_read_ulongs(int inf, unsigned long *i, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
525 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
526 int n=0,value=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
527
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
528 if (rs_read_int(inf,&value) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
529 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
530 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
531 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
532 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
533 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
534 for(n=0;n<value;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
535 rs_read_ulong(inf, &i[n]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
536 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
537 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
538
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
539 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
540 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
541
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
542 rs_read_booleans(int inf, bool *i, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
543 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
544 int n=0,value=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
545
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
546 if (rs_read_int(inf,&value) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
547 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
548 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
549 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
550 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
551 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
552 for(n=0;n<value;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
553 rs_read_boolean(inf, &i[n]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
554 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
555 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
556
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
557 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
558 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
559
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
560 rs_write_levtype(FILE *savef, LEVTYPE c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
561 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
562 int lt;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
563
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
564 switch(c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
565 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
566 case NORMLEV: lt = 1; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
567 case POSTLEV: lt = 2; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
568 case MAZELEV: lt = 3; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
569 case OUTSIDE: lt = 4; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
570 case STARTLEV: lt = 5; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
571 default: lt = -1; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
572 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
573
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
574 rs_write_int(savef,lt);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
575
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
576 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
577 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
578
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
579 rs_read_levtype(int inf, LEVTYPE *l)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
580 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
581 int lt;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
582
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
583 rs_read_int(inf, &lt);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
584
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
585 switch(lt)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
586 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
587 case 1: *l = NORMLEV; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
588 case 2: *l = POSTLEV; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
589 case 3: *l = MAZELEV; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
590 case 4: *l = OUTSIDE; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
591 case 5: *l = STARTLEV; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
592 default: *l = NORMLEV; break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
593 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
594
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
595 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
596 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
597
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
598 rs_write_char(FILE *savef, char c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
599 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
600 rs_write(savef, &c, 1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
601 DBG(("%c",c));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
602
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
603 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
604 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
605
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
606 rs_read_char(int inf, char *c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
607 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
608 rs_read(inf, c, 1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
609
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
610 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
611 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
612
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
613 rs_write_uchar(FILE *savef, unsigned char c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
614 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
615 rs_write(savef, &c, 1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
616 DBG(("%c",c));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
617
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
618 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
619 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
620
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
621 rs_read_uchar(int inf, unsigned char *c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
622 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
623 rs_read(inf, c, 1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
624
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
625 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
626 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
627
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
628 rs_write_string(FILE *savef, char *s)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
629 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
630 int len = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
631
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
632 len = (s == NULL) ? 0 : (int) strlen(s) + 1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
633
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
634 rs_write_uint(savef, (unsigned int) len);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
635 rs_write(savef, s, len);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
636
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
637 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
638 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
639
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
640 rs_read_string_index(int inf, struct words master[], int maxindex, char **str)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
641 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
642 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
643
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
644 if (rs_read_int(inf,&i) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
645 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
646 if (i > maxindex)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
647 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
648 printf("String index is out of range. %d > %d\n",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
649 i, maxindex);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
650 printf("Sorry, invalid save game format\n");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
651 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
652 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
653 else if (i >= 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
654 *str = master[i].w_string;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
655 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
656 *str = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
657 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
658 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
659 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
660
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
661 rs_write_string_index(FILE *savef, struct words master[], int maxindex, char *str)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
662 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
663 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
664
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
665 for(i = 0; i < maxindex; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
666 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
667 if (str == master[i].w_string)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
668 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
669 rs_write_int(savef,i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
670 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
671 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
672 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
673
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
674 rs_write_int(savef,-1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
675 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
676 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
677
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
678 rs_read_scrolls(int inf)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
679 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
680 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
681
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
682 for(i = 0; i < MAXSCROLLS; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
683 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
684 rs_read_new_string(inf,&s_names[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
685 rs_read_boolean(inf,&s_know[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
686 rs_read_new_string(inf,&s_guess[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
687 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
688
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
689 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
690 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
691
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
692 rs_write_scrolls(FILE *savef)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
693 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
694 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
695
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
696 for(i = 0; i < MAXSCROLLS; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
697 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
698 rs_write_string(savef,s_names[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
699 rs_write_boolean(savef,s_know[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
700 rs_write_string(savef,s_guess[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
701 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
702 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
703 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
704
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
705 rs_read_potions(int inf)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
706 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
707 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
708
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
709 for(i = 0; i < MAXPOTIONS; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
710 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
711 rs_read_string_index(inf,rainbow,NCOLORS,&p_colors[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
712 rs_read_boolean(inf,&p_know[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
713 rs_read_new_string(inf,&p_guess[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
714 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
715
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
716 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
717 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
718
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
719 rs_write_potions(FILE *savef)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
720 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
721 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
722
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
723 for(i = 0; i < MAXPOTIONS; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
724 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
725 rs_write_string_index(savef,rainbow,NCOLORS,p_colors[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
726 rs_write_boolean(savef,p_know[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
727 rs_write_string(savef,p_guess[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
728 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
729
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
730 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
731 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
732
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
733 rs_read_rings(int inf)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
734 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
735 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
736
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
737 for(i = 0; i < MAXRINGS; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
738 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
739 rs_read_string_index(inf,stones,NSTONES,&r_stones[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
740 rs_read_boolean(inf,&r_know[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
741 rs_read_new_string(inf,&r_guess[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
742 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
743
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
744 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
745 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
746
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
747 rs_write_rings(FILE *savef)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
748 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
749 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
750
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
751 for(i = 0; i < MAXRINGS; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
752 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
753 rs_write_string_index(savef,stones,NSTONES,r_stones[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
754 rs_write_boolean(savef,r_know[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
755 rs_write_string(savef,r_guess[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
756 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
757
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
758 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
759 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
760
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
761 rs_read_misc(int inf)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
762 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
763 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
764
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
765 for(i = 0; i < MAXMM; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
766 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
767 rs_read_boolean(inf,&m_know[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
768 rs_read_new_string(inf,&m_guess[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
769 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
770
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
771 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
772 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
773
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
774 rs_write_misc(FILE *savef)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
775 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
776 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
777
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
778 for(i = 0; i < MAXMM; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
779 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
780 rs_write_boolean(savef,m_know[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
781 rs_write_string(savef,m_guess[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
782 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
783
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
784 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
785 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
786
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
787 rs_write_sticks(FILE *savef)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
788 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
789 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
790
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
791 for (i = 0; i < MAXSTICKS; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
792 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
793 if (strcmp(ws_type[i],"staff") == 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
794 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
795 rs_write_int(savef,0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
796 rs_write_string_index(savef, wood, NWOOD, ws_made[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
797 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
798 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
799 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
800 rs_write_int(savef,1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
801 rs_write_string_index(savef, metal, NMETAL, ws_made[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
802 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
803 rs_write_boolean(savef, ws_know[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
804 rs_write_string(savef, ws_guess[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
805 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
806
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
807 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
808 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
809
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
810 rs_read_sticks(int inf)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
811 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
812 int i = 0, list = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
813
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
814 for(i = 0; i < MAXSTICKS; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
815 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
816 rs_read_int(inf,&list);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
817 if (list == 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
818 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
819 rs_read_string_index(inf,wood,NWOOD,&ws_made[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
820 ws_type[i] = "staff";
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
821 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
822 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
823 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
824 rs_read_string_index(inf,metal,NMETAL,&ws_made[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
825 ws_type[i] = "wand";
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
826 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
827 rs_read_boolean(inf, &ws_know[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
828 rs_read_new_string(inf, &ws_guess[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
829 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
830
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
831 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
832 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
833
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
834 rs_read_string(int inf, char *s, int max)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
835 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
836 int len = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
837
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
838 if (rs_read_int(inf, &len) != FALSE)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
839 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
840 if (len > max)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
841 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
842 printf("String too long to restore. %d > %d\n",len,max);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
843 printf("Sorry, invalid save game format\n");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
844 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
845 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
846
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
847 rs_read(inf, s, len);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
848 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
849
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
850 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
851 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
852
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
853 rs_read_new_string(int inf, char **s)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
854 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
855 int len=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
856 char *buf=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
857
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
858 if (rs_read_int(inf, &len) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
859 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
860 if (len == 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
861 *s = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
862 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
863 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
864 buf = malloc(len);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
865
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
866 if (buf == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
867 read_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
868 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
869 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
870 rs_read(inf, buf, len);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
871 *s = buf;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
872 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
873 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
874 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
875
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
876 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
877 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
878
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
879 rs_write_strings(FILE *savef, char *s[], int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
880 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
881 int len = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
882 int n = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
883
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
884 rs_write_int(savef,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
885
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
886 for(n = 0; n < count; n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
887 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
888 len = (s[n] == NULL) ? 0L : (int) strlen(s[n]) + 1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
889 rs_write_int(savef, len);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
890 rs_write(savef, s[n], len);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
891 DBG(("%s",s[n]));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
892 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
893
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
894 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
895 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
896
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
897 rs_write_words(FILE *savef, struct words *w, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
898 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
899 int n = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
900
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
901 rs_write_int(savef,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
902
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
903 for(n = 0; n < count; n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
904 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
905 rs_write(savef, w[n].w_string, sizeof(w[n].w_string));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
906 DBG(("%s",w[n].w_string));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
907 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
908
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
909 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
910 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
911
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
912 rs_read_words(int inf, struct words *w, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
913 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
914 int n = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
915 int value = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
916
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
917 rs_read_int(inf,&value);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
918
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
919 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
920 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
921 printf("Incorrect number of words in block. %d != %d.",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
922 value,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
923 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
924 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
925 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
926 else for(n = 0; n < count; n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
927 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
928 rs_read(inf, w[n].w_string, sizeof(w[n].w_string));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
929 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
930
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
931 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
932 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
933
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
934 rs_read_new_strings(int inf, char **s, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
935 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
936 int len = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
937 int n = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
938 int value = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
939
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
940 if (rs_read_int(inf,&value) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
941 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
942 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
943 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
944 printf("Incorrect number of strings in block. %d > %d.",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
945 value,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
946 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
947 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
948 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
949 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
950 for(n=0; n<value; n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
951 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
952 rs_read_int(inf, &len);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
953
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
954 if (len == 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
955 s[n]=0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
956 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
957 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
958 s[n] = malloc(len);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
959 rs_read(inf,s[n],len);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
960 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
961 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
962 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
963
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
964 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
965 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
966
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
967 rs_write_coord(FILE *savef, coord *c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
968 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
969 DBG(("X ="));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
970 rs_write_int(savef, c->x);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
971 DBG(("Y ="));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
972 rs_write_int(savef, c->y);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
973
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
974 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
975 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
976
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
977 rs_read_coord(int inf, coord *c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
978 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
979 rs_read_int(inf,&c->x);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
980 rs_read_int(inf,&c->y);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
981
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
982 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
983 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
984
155
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
985 /* Assigns a number to an alchemy jug associated with a fuse, so it can be
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
986 * found and reassociated when restoring.
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
987 * 1 - 31: slot in pack
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
988 * 32+ : on floor
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
989 * Hopefully monsters do not pick them up.
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
990 */
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
991 int number_alchemy_jug(struct object *obj) {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
992 struct object *tobj = NULL;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
993 struct linked_list *item;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
994 int i = 1;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
995 for (item = pack; item != NULL; item = next(item), i++) {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
996 tobj = OBJPTR(item);
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
997 if (tobj == obj &&
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
998 tobj->o_type == MM &&
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
999 tobj->o_which== MM_JUG)
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1000 break;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1001 }
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1002 if (item == NULL) {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1003 for (item = lvl_obj, i = 32; item != NULL; item = next(item), i++) {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1004 tobj = OBJPTR(item);
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1005 if (tobj == obj &&
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1006 tobj->o_type == MM &&
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1007 tobj->o_which== MM_JUG)
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1008 break;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1009 }
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1010 }
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1011 if (item == NULL)
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1012 return 0;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1013 return i;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1014 }
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1015
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1016 /* Takes an alchemy jug number and tracks down the object. */
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1017 struct object *find_alchemy_jug(int n) {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1018 struct object *tobj;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1019 struct linked_list *item;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1020
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1021 if (n <= 0) {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1022 return NULL;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1023 }
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1024 else if (n < 32) {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1025 item = pack;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1026 n -= 1;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1027 }
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1028 else if (n < 1024) {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1029 item = lvl_obj;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1030 n -= 32;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1031 }
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1032 else {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1033 /* This is likely a bug, not 1024 actual items on the floor. */
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1034 return NULL;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1035 }
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1036 while (item != NULL && n > 0) {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1037 item = next(item);
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1038 n--;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1039 }
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1040 if (item == NULL)
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1041 return NULL;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1042 tobj = OBJPTR(item);
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1043 if (tobj->o_type != MM || tobj->o_which != MM_JUG)
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1044 return NULL;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1045 return tobj;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1046 }
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1047
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1048 rs_write_daemons(FILE *savef, struct delayed_action *d_list,int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1049 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1050 int i = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1051 int func = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1052
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1053 DBG(("Daemons\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1054 rs_write_int(savef, RSXR_DAEMONS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1055 rs_write_int(savef, count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1056
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1057 for(i=0; i < count; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1058 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1059 if (d_list[i].d_func == rollwand)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1060 func = 1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1061 else if (d_list[i].d_func == doctor)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1062 func = 2;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1063 else if (d_list[i].d_func == stomach)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1064 func = 3;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1065 else if (d_list[i].d_func == trap_look)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1066 func = 4;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1067 else if (d_list[i].d_func == eat_gold)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1068 func = 5;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1069 else if (d_list[i].d_func == ring_search)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1070 func = 6;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1071 else if (d_list[i].d_func == ring_teleport)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1072 func = 7;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1073 else if (d_list[i].d_func == fumble)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1074 func = 8;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1075 else if (d_list[i].d_func == strangle)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1076 func = 9;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1077 else if (d_list[i].d_func == unconfuse)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1078 func = 10;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1079 else if (d_list[i].d_func == swander)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1080 func = 11;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1081 else if (d_list[i].d_func == spell_recovery)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1082 func = 12;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1083 else if (d_list[i].d_func == chant_recovery)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1084 func = 13;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1085 else if (d_list[i].d_func == prayer_recovery)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1086 func = 14;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1087 else if (d_list[i].d_func == cure_disease)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1088 func = 15;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1089 else if (d_list[i].d_func == unstink)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1090 func = 16;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1091 else if (d_list[i].d_func == res_strength)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1092 func = 17;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1093 else if (d_list[i].d_func == undance)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1094 func = 18;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1095 else if (d_list[i].d_func == suffocate)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1096 func = 19;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1097 else if (d_list[i].d_func == wghtchk)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1098 func = 20;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1099 else if (d_list[i].d_func == dust_appear)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1100 func = 21;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1101 else if (d_list[i].d_func == unchoke)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1102 func = 22;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1103 else if (d_list[i].d_func == sight)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1104 func = 23;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1105 else if (d_list[i].d_func == changeclass)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1106 func = 24;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1107 else if (d_list[i].d_func == cloak_charge)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1108 func = 25;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1109 else if (d_list[i].d_func == quill_charge)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1110 func = 26;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1111 else if (d_list[i].d_func == nohaste)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1112 func = 27;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1113 else if (d_list[i].d_func == noslow)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1114 func = 28;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1115 else if (d_list[i].d_func == unclrhead)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1116 func = 29;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1117 else if (d_list[i].d_func == unsee)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1118 func = 30;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1119 else if (d_list[i].d_func == unphase)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1120 func = 31;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1121 else if (d_list[i].d_func == land)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1122 func = 32;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1123 else if (d_list[i].d_func == appear)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1124 func = 33;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1125 else if (d_list[i].d_func == unskill)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1126 func = 34;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1127 else if (d_list[i].d_func == nofire)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1128 func = 35;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1129 else if (d_list[i].d_func == nocold)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1130 func = 36;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1131 else if (d_list[i].d_func == nobolt)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1132 func = 37;
155
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1133 else if (d_list[i].d_func == alchemy)
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1134 func = 38;
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1135 else if (d_list[i].d_func == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1136 func = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1137 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1138 func = -1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1139
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1140 rs_write_int(savef, d_list[i].d_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1141 rs_write_int(savef, func);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1142
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1143 if (d_list[i].d_func == doctor)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1144 rs_write_int(savef, 1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1145 else if (d_list[i].d_func == eat_gold)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1146 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1147 int index;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1148 index = find_list_ptr(player.t_pack,d_list[i].d_arg.vp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1149 rs_write_int(savef,index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1150 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1151 else if (d_list[i].d_func == changeclass)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1152 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1153 rs_write_int(savef, d_list[i].d_arg.i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1154 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1155 else if (d_list[i].d_func == cloak_charge)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1156 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1157 int index;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1158 index = find_list_ptr(player.t_pack,d_list[i].d_arg.vp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1159 rs_write_int(savef,index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1160 }
155
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1161 else if (d_list[i].d_func == alchemy)
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1162 {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1163 rs_write_int(savef, number_alchemy_jug((void *) d_list[i].d_arg.vp));
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1164 }
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1165 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1166 rs_write_int(savef, d_list[i].d_arg.i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1167
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1168 rs_write_int(savef, d_list[i].d_time);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1169 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1170
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1171 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1172 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1173
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1174 rs_read_daemons(int inf, struct delayed_action *d_list, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1175 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1176 int i = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1177 int func = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1178 int value = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1179 int id = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1180 int dummy = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1181
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1182 if (d_list == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1183 printf("HELP THERE ARE NO DAEMONS\n");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1184
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1185 if (rs_read_int(inf, &id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1186 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1187 if (id != RSXR_DAEMONS)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1188 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1189 printf("Invalid id. %x != %x(RSXR_DAEMONS)\n",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1190 id,RSXR_DAEMONS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1191 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1192 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1193 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1194 else if (rs_read_int(inf, &value) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1195 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1196 if (value > count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1197 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1198 printf("Incorrect number of daemons in block. %d > %d.",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1199 value,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1200 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1201 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1202 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1203 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1204 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1205 for(i=0; i < value; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1206 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1207 func = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1208 rs_read_int(inf, &d_list[i].d_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1209 rs_read_int(inf, &func);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1210
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1211 switch(func)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1212 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1213 case 1: d_list[i].d_func = rollwand;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1214 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1215 case 2: d_list[i].d_func = doctor;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1216 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1217 case 3: d_list[i].d_func = stomach;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1218 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1219 case 4: d_list[i].d_func = trap_look;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1220 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1221 case 5: d_list[i].d_func = eat_gold;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1222 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1223 case 6: d_list[i].d_func = ring_search;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1224 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1225 case 7: d_list[i].d_func = ring_teleport;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1226 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1227 case 8: d_list[i].d_func = fumble;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1228 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1229 case 9: d_list[i].d_func = strangle;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1230 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1231 case 10: d_list[i].d_func = unconfuse;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1232 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1233 case 11: d_list[i].d_func = swander;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1234 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1235 case 12: d_list[i].d_func = spell_recovery;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1236 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1237 case 13: d_list[i].d_func = chant_recovery;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1238 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1239 case 14: d_list[i].d_func = prayer_recovery;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1240 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1241 case 15: d_list[i].d_func = cure_disease;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1242 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1243 case 16: d_list[i].d_func = unstink;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1244 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1245 case 17: d_list[i].d_func = res_strength;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1246 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1247 case 18: d_list[i].d_func = undance;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1248 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1249 case 19: d_list[i].d_func = suffocate;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1250 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1251 case 20: d_list[i].d_func = wghtchk;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1252 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1253 case 21: d_list[i].d_func = dust_appear;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1254 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1255 case 22: d_list[i].d_func = unchoke;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1256 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1257 case 23: d_list[i].d_func = sight;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1258 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1259 case 24: d_list[i].d_func = changeclass;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1260 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1261 case 25: d_list[i].d_func = cloak_charge;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1262 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1263 case 26: d_list[i].d_func = quill_charge;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1264 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1265 case 27: d_list[i].d_func = nohaste;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1266 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1267 case 28: d_list[i].d_func = noslow;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1268 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1269 case 29: d_list[i].d_func = unclrhead;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1270 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1271 case 30: d_list[i].d_func = unsee;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1272 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1273 case 31: d_list[i].d_func = unphase;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1274 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1275 case 32: d_list[i].d_func = land;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1276 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1277 case 33: d_list[i].d_func = appear;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1278 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1279 case 34: d_list[i].d_func = unskill;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1280 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1281 case 35: d_list[i].d_func = nofire;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1282 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1283 case 36: d_list[i].d_func = nocold;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1284 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1285 case 37: d_list[i].d_func = nobolt;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1286 break;
155
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1287 case 38: d_list[i].d_func = alchemy;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1288 break;
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1289 case 0:
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1290 case -1:
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1291 default: d_list[i].d_func = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1292 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1293 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1294
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1295 if (d_list[i].d_func == doctor)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1296 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1297 rs_read_int(inf, &dummy);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1298 d_list[i].d_arg.vp = (void *)&player;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1299 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1300 else if (d_list[i].d_func == eat_gold)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1301 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1302 rs_read_int(inf, &dummy);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1303 d_list[i].d_arg.vp = get_list_item(player.t_pack,dummy);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1304 if (d_list[i].d_arg.vp == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1305 d_list[i].d_type = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1306 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1307 else if (d_list[i].d_func == changeclass)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1308 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1309 rs_read_int(inf, &d_list[i].d_arg.i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1310 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1311 else if (d_list[i].d_func == cloak_charge)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1312 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1313 rs_read_int(inf, &dummy);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1314 d_list[i].d_arg.vp = get_list_item(player.t_pack,dummy);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1315 if (d_list[i].d_arg.vp == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1316 d_list[i].d_type = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1317 }
155
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1318 else if (d_list[i].d_func == alchemy)
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1319 {
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1320 rs_read_int(inf, &dummy);
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1321 d_list[i].d_arg.vp = (void *) find_alchemy_jug(dummy);
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1322 if (d_list[i].d_arg.vp == NULL)
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1323 d_list[i].d_type = 0;
1af259ac4ed2 arogue7, xrogue: fix save/restore of alchemy jugs.
John "Elwin" Edwards
parents: 144
diff changeset
1324 }
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1325 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1326 rs_read_int(inf, &d_list[i].d_arg.i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1327
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1328 rs_read_int(inf, &d_list[i].d_time);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1329
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1330 if (d_list[i].d_func == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1331 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1332 d_list[i].d_time = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1333 d_list[i].d_arg.vp = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1334 d_list[i].d_type = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1335 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1336
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1337 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1338 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1339 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1340 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1341
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1342 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1343 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1344
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1345 rs_write_rooms(FILE *savef, struct room r[], int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1346 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1347 int n = 0,i = -1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1348 struct linked_list *l;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1349
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1350 DBG(("Rooms\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1351 rs_write_int(savef, RSXR_ROOMS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1352 rs_write_int(savef, count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1353
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1354 for(n=0; n<count; n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1355 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1356 rs_write_coord(savef, &r[n].r_pos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1357 rs_write_coord(savef, &r[n].r_max);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1358 rs_write_long(savef, r[n].r_flags);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1359 rs_write_coord_list(savef, r[n].r_exit);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1360
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1361 l = r[n].r_fires;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1362 i = list_size(l);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1363
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1364 rs_write_int(savef, i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1365
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1366 if (i >0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1367 while (l != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1368 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1369 i = find_list_ptr(mlist,l->l_data);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1370 rs_write_int(savef,i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1371 l = l->l_next;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1372 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1373 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1374 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1375 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1376
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1377 rs_read_rooms(int inf, struct room *r, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1378 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1379 int value = 0, n = 0, i = 0, index = 0, id = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1380 struct linked_list *fires=NULL, *item = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1381
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1382 if (rs_read_int(inf,&id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1383 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1384 if (id != RSXR_ROOMS)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1385 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1386 printf("Invalid id. %x != %x(RSXR_ROOMS)\n",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1387 id,RSXR_ROOMS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1388 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1389 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1390 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1391 else if (rs_read_int(inf,&value) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1392 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1393 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1394 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1395 printf("Incorrect number of rooms in block. %d > %d.",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1396 value,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1397 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1398 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1399 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1400 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1401 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1402 for(n=0; n<value; n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1403 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1404 rs_read_coord(inf,&r[n].r_pos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1405 rs_read_coord(inf,&r[n].r_max);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1406 rs_read_long(inf,&r[n].r_flags);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1407 rs_read_coord_list(inf, &r[n].r_exit);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1408
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1409 rs_read_int(inf, &i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1410 fires = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1411 while (i>0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1412 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1413 rs_read_int(inf,&index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1414
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1415 if (index >= 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1416 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1417 void *data;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1418 data = get_list_item(mlist,index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1419 item = creat_item();
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1420 item->l_data = data;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1421 if (fires == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1422 fires = item;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1423 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1424 attach(fires,item);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1425 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1426 i--;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1427 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1428 r[n].r_fires=fires;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1429 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1430 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1431 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1432 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1433
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1434 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1435 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1436
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1437 rs_write_object(FILE *savef, struct object *o)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1438 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1439 rs_write_int(savef, RSXR_OBJECT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1440 rs_write_int(savef, o->o_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1441 rs_write_coord(savef, &o->o_pos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1442 rs_write_char(savef, o->o_launch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1443 rs_write(savef, o->o_damage, sizeof(o->o_damage));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1444 rs_write(savef, o->o_hurldmg, sizeof(o->o_hurldmg));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1445 rs_write_int(savef, o->o_count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1446 rs_write_int(savef, o->o_which);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1447 rs_write_int(savef, o->o_hplus);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1448 rs_write_int(savef, o->o_dplus);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1449 rs_write_int(savef, o->o_ac);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1450 rs_write_long(savef, o->o_flags);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1451 rs_write_int(savef, o->o_group);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1452 rs_write_int(savef, o->o_weight);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1453 rs_write(savef, o->o_mark, MARKLEN);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1454
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1455 DBG(("Object\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1456 DBG((" SaveID : %X\n",RSXR_OBJECT));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1457 DBG((" Type : %d\n",o->o_type));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1458 DBG((" Pos : %d %d\n",o->o_pos.x,o->o_pos.y));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1459 DBG((" Launch : %c\n",o->o_launch));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1460 DBG((" Damage : %s\n",o->o_damage));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1461 DBG((" Hurl : %s\n",o->o_hurldmg));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1462 DBG((" Count : %d\n",o->o_count));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1463 DBG((" Which : %d\n",o->o_which));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1464 DBG((" HPlus : %d\n",o->o_hplus));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1465 DBG((" DPlus : %d\n",o->o_dplus));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1466 DBG((" AC : %d\n",o->o_ac));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1467 DBG((" Flags : %X\n",o->o_flags));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1468 DBG((" Group : %d\n",o->o_group));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1469 DBG((" Weight : %d\n",o->o_weight));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1470 DBG((" Mark : %s\n",o->o_mark));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1471 if (o->contents == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1472 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1473 DBG((" Contents: None\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1474 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1475 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1476 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1477 DBG((" CONTENTS\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1478 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1479
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1480 rs_write_object_list(savef, o->contents);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1481
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1482 if (o->contents != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1483 DBG((" END_CONTENTS\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1484
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1485 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1486 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1487
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1488 rs_read_object(int inf, struct object *o)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1489 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1490 int id;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1491
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1492 if (rs_read_int(inf, &id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1493 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1494 if (id != RSXR_OBJECT)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1495 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1496 printf("Invalid id. %x != %x(RSXR_OBJECT)\n", id,RSXR_OBJECT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1497 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1498 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1499 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1500 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1501 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1502 rs_read_int(inf, &o->o_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1503 rs_read_coord(inf, &o->o_pos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1504 rs_read_char(inf, &o->o_launch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1505 rs_read(inf, o->o_damage,sizeof(o->o_damage));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1506 rs_read(inf, o->o_hurldmg,sizeof(o->o_hurldmg));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1507 rs_read_int(inf, &o->o_count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1508 rs_read_int(inf, &o->o_which);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1509 rs_read_int(inf, &o->o_hplus);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1510 rs_read_int(inf, &o->o_dplus);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1511 rs_read_int(inf,&o->o_ac);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1512 rs_read_long(inf,&o->o_flags);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1513 rs_read_int(inf,&o->o_group);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1514 rs_read_int(inf, &o->o_weight);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1515 rs_read(inf, o->o_mark, MARKLEN);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1516 rs_read_object_list(inf,&o->contents);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1517
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1518 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1519 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1520
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1521 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1522 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1523
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1524 rs_write_stats(FILE *savef, struct stats *s)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1525 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1526 DBG(("Stats\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1527 rs_write_int(savef, RSXR_STATS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1528
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1529 rs_write_short(savef, s->s_str);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1530 rs_write_short(savef, s->s_intel);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1531 rs_write_short(savef, s->s_wisdom);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1532 rs_write_short(savef, s->s_dext);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1533 rs_write_short(savef, s->s_const);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1534 rs_write_short(savef, s->s_charisma);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1535 rs_write_ulong(savef, s->s_exp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1536 rs_write_int(savef, s->s_lvladj);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1537 rs_write_int(savef, s->s_lvl);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1538 rs_write_int(savef, s->s_arm);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1539 rs_write_int(savef, s->s_hpt);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1540 rs_write_int(savef, s->s_pack);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1541 rs_write_int(savef, s->s_carry);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1542 rs_write(savef, s->s_dmg, sizeof(s->s_dmg));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1543
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1544 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1545 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1546
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1547 rs_read_stats(int inf, struct stats *s)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1548 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1549 int id;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1550
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1551 if (rs_read_int(inf, &id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1552 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1553 if (id != RSXR_STATS)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1554 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1555 printf("Invalid id. %x != %x(RSXR_STATS)\n", id,RSXR_STATS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1556 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1557 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1558 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1559 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1560 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1561 rs_read_short(inf,&s->s_str);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1562 rs_read_short(inf,&s->s_intel);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1563 rs_read_short(inf,&s->s_wisdom);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1564 rs_read_short(inf,&s->s_dext);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1565 rs_read_short(inf,&s->s_const);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1566 rs_read_short(inf,&s->s_charisma);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1567 rs_read_ulong(inf,&s->s_exp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1568 rs_read_int(inf,&s->s_lvladj);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1569 rs_read_int(inf,&s->s_lvl);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1570 rs_read_int(inf,&s->s_arm);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1571 rs_read_int(inf,&s->s_hpt);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1572 rs_read_int(inf,&s->s_pack);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1573 rs_read_int(inf,&s->s_carry);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1574 rs_read(inf,s->s_dmg,sizeof(s->s_dmg));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1575 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1576 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1577
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1578 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1579 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1580
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1581 rs_write_mstats(FILE *savef, struct mstats *s)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1582 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1583 DBG(("M-Stats\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1584 rs_write_int(savef, RSXR_STATS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1585 rs_write_short(savef, s->ms_str);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1586 /*printf(" Strength: %d\n",s->ms_str);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1587 rs_write_short(savef, s->ms_dex);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1588 rs_write_short(savef, s->ms_move);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1589 rs_write_ulong(savef, s->ms_exp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1590 rs_write_short(savef, s->ms_lvl);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1591 rs_write_short(savef, s->ms_arm);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1592 rs_write(savef, s->ms_hpt, sizeof(s->ms_hpt));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1593 rs_write(savef, s->ms_dmg, sizeof(s->ms_dmg));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1594 /*printf(" Damage: %s\n",s->ms_dmg);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1595
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1596 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1597 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1598
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1599 rs_read_mstats(int inf, struct mstats *s)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1600 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1601 int id;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1602
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1603 if (rs_read_int(inf, &id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1604 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1605 if (id != RSXR_STATS)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1606 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1607 printf("Invalid id. %x != %x(RSXR_STATS)\n", id,RSXR_STATS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1608 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1609 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1610 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1611 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1612 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1613 rs_read_short(inf,&s->ms_str);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1614 /*printf(" Strength: %d\n",s->ms_str);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1615 rs_read_short(inf,&s->ms_dex);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1616 /*printf(" Dexterity: %d\n",s->ms_dex);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1617 rs_read_short(inf,&s->ms_move);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1618 /*printf(" Moves: %d\n",s->ms_move);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1619 rs_read_ulong(inf,&s->ms_exp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1620 /*printf(" Experience: %d\n",s->ms_exp);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1621 rs_read_short(inf,&s->ms_lvl);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1622 /*printf(" Level: %d\n",s->ms_lvl);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1623 rs_read_short(inf,&s->ms_arm);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1624 /*printf(" Armor: %d\n",s->ms_arm);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1625 rs_read(inf,s->ms_hpt,sizeof(s->ms_hpt));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1626 /*printf(" HP: %s\n",s->ms_hpt);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1627 rs_read(inf,s->ms_dmg,sizeof(s->ms_dmg));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1628 /*printf(" Damage: %s\n",s->ms_dmg);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1629 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1630 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1631
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1632 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1633 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1634
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1635 rs_write_init_weps(FILE *savef, struct init_weps *w, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1636 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1637 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1638
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1639 DBG(("Init-Weps\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1640 rs_write_int(savef, RSXR_IWEAPS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1641 rs_write_int(savef, count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1642
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1643 for(i=0;i<count;i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1644 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1645 rs_write(savef, w[i].w_name, sizeof(w[i].w_name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1646 rs_write(savef, w[i].w_dam, sizeof(w[i].w_dam));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1647 rs_write(savef, w[i].w_hrl, sizeof(w[i].w_hrl));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1648 rs_write_char(savef, w[i].w_launch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1649 rs_write_int(savef, w[i].w_flags);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1650 rs_write_int(savef, w[i].w_rate);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1651 rs_write_int(savef, w[i].w_wght);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1652 rs_write_int(savef, w[i].w_worth);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1653 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1654 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1655 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1656
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1657 rs_read_init_weps(int inf, struct init_weps *w,int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1658 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1659 int id,value,i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1660
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1661 rs_read_int(inf, &id);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1662 rs_read_int(inf, &value);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1663
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1664 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1665 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1666 printf("Incorrect number of init_weps in block. %d != %d.",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1667 value,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1668 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1669 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1670 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1671 else for (i = 0; i < count; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1672 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1673 rs_read(inf, w[i].w_name, sizeof(w[i].w_name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1674 rs_read(inf, w[i].w_dam, sizeof(w[i].w_dam));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1675 rs_read(inf, w[i].w_hrl, sizeof(w[i].w_hrl));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1676 rs_read_char(inf, &w[i].w_launch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1677 rs_read_int(inf, &w[i].w_flags);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1678 rs_read_int(inf, &w[i].w_rate);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1679 rs_read_int(inf, &w[i].w_wght);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1680 rs_read_int(inf, &w[i].w_worth);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1681 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1682 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1683 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1684
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1685 rs_write_init_armor(FILE *savef, struct init_armor *a, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1686 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1687 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1688 DBG(("Init-Armor\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1689 rs_write_int(savef, RSXR_IARMOR);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1690 rs_write_int(savef, count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1691 for(i=0;i<count;i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1692 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1693 rs_write(savef, a[i].a_name, sizeof(a[i].a_name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1694 rs_write_int(savef, a[i].a_prob);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1695 rs_write_int(savef, a[i].a_class);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1696 rs_write_int(savef, a[i].a_worth);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1697 rs_write_int(savef, a[i].a_wght);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1698 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1699 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1700 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1701
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1702 rs_read_init_armor(int inf, struct init_armor *a,int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1703 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1704 int id,value,i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1705
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1706 rs_read_int(inf, &id);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1707 rs_read_int(inf, &value);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1708
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1709 for(i=0;i<count;i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1710 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1711 rs_read(inf, a[i].a_name, sizeof(a[i].a_name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1712 rs_read_int(inf, &a[i].a_prob);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1713 rs_read_int(inf, &a[i].a_class);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1714 rs_read_int(inf, &a[i].a_worth);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1715 rs_read_int(inf, &a[i].a_wght);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1716 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1717
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1718 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1719 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1720
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1721 rs_write_spells(FILE *savef, struct spells *s, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1722 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1723 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1724 DBG(("Spells\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1725 rs_write_int(savef, RSXR_SPELLS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1726 rs_write_int(savef, count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1727 for(i=0;i<count;i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1728 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1729 rs_write_short(savef, s[i].s_which);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1730 rs_write_short(savef, s[i].s_cost);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1731 rs_write_short(savef, s[i].s_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1732 rs_write_int(savef, s[i].s_flag);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1733 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1734 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1735 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1736
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1737 rs_read_spells(int inf, struct spells *s,int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1738 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1739 int id,value,i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1740
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1741 rs_read_int(inf, &id);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1742 rs_read_int(inf, &value);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1743
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1744 for(i=0;i<count;i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1745 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1746 rs_read_short(inf, &s[i].s_which);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1747 rs_read_short(inf, &s[i].s_cost);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1748 rs_read_short(inf, &s[i].s_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1749 rs_read_int(inf, &s[i].s_flag);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1750 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1751 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1752 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1753
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1754 rs_write_item_list(FILE *savef, struct item_list *i)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1755 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1756 DBG(("Item List\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1757 rs_write_int(savef, RSXR_ILIST);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1758 rs_write_char(savef, i->item_ch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1759 rs_write(savef, i->item_desc, sizeof(i->item_desc));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1760 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1761 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1762 rs_read_item_list(int inf, struct item_list *i)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1763 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1764 int id;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1765
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1766 rs_read_int(inf, &id);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1767
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1768 rs_read_uchar(inf, &i->item_ch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1769 rs_read(inf, i->item_desc,sizeof(i->item_desc));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1770 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1771 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1772
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1773 rs_write_h_list(FILE *savef, struct h_list *h)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1774 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1775 DBG(("H List\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1776 rs_write_int(savef, RSXR_HLIST);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1777 rs_write_char(savef, h->h_ch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1778 rs_write(savef, h->h_desc, sizeof(h->h_desc));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1779 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1780 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1781
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1782 rs_read_h_list(int inf, struct h_list *h)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1783 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1784 int id;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1785
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1786 rs_read_int(inf, &id);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1787
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1788 rs_read_char(inf, &h->h_ch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1789 rs_read(inf, h->h_desc,sizeof(h->h_desc));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1790 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1791 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1792
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1793 rs_write_death_types(FILE *savef, struct death_type *d,int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1794 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1795 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1796
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1797 DBG(("Death Types\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1798 rs_write_int(savef, RSXR_DEATHTYPE);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1799 rs_write_int(savef, count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1800
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1801 for(i=0; i < count; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1802 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1803 rs_write_int(savef, d[i].reason);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1804 rs_write(savef, d[i].name, sizeof(d[i].name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1805 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1806 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1807 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1808 rs_read_death_types(int inf, struct death_type *d, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1809 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1810 int id,value,i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1811
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1812 rs_read_int(inf, &id);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1813 rs_read_int(inf, &value);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1814 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1815 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1816 printf("Incorrect number of death_types in block. %d > %d.",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1817 value,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1818 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1819 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1820 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1821 else for(i=0;i < count;i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1822 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1823 rs_read_int(inf, &d[i].reason);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1824 rs_read(inf, d[i].name,sizeof(d[i].name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1825 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1826 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1827 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1828
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1829 rs_write_character_types(FILE *savef, struct character_types *c, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1830 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1831 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1832
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1833 DBG(("Character Types\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1834 rs_write_int(savef, RSXR_CTYPES);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1835 rs_write_int(savef,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1836
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1837 for(i=0;i<count;i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1838 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1839 rs_write(savef, c[i].name, sizeof(c[i].name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1840 rs_write_long(savef, c[i].start_exp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1841 rs_write_long(savef, c[i].cap);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1842 rs_write_int(savef, c[i].hit_pts);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1843 rs_write_int(savef, c[i].base);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1844 rs_write_int(savef, c[i].max_lvl);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1845 rs_write_int(savef, c[i].factor);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1846 rs_write_int(savef, c[i].offset);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1847 rs_write_int(savef, c[i].range);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1848 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1849 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1850 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1851
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1852 rs_read_character_types(int inf, struct character_types *c,int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1853 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1854 int id,value,i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1855
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1856 rs_read_int(inf, &id);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1857 rs_read_int(inf, &value);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1858
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1859 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1860 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1861 printf("Incorrect number of character types in block. %d > %d.",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1862 value,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1863 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1864 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1865 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1866 else for (i = 0; i < count; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1867 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1868 rs_read(inf, c[i].name,sizeof(c[i].name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1869 rs_read_long(inf, &c[i].start_exp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1870 rs_read_long(inf, &c[i].cap);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1871 rs_read_int(inf, &c[i].hit_pts);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1872 rs_read_int(inf, &c[i].base);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1873 rs_read_int(inf, &c[i].max_lvl);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1874 rs_read_int(inf, &c[i].factor);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1875 rs_read_int(inf, &c[i].offset);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1876 rs_read_int(inf, &c[i].range);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1877 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1878 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1879 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1880
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1881 rs_write_traps(FILE *savef, struct trap *trap,int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1882 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1883 int n;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1884
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1885 DBG(("Traps\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1886 rs_write_int(savef, RSXR_TRAP);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1887 rs_write_int(savef, count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1888
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1889 for(n=0; n<count; n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1890 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1891 rs_write_char(savef, trap[n].tr_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1892 rs_write_char(savef, trap[n].tr_show);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1893 rs_write_coord(savef, &trap[n].tr_pos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1894 rs_write_long(savef, trap[n].tr_flags);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1895 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1896 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1897
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1898 rs_read_traps(int inf, struct trap *trap, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1899 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1900 int id = 0, value = 0, n = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1901
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1902 if (rs_read_int(inf,&id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1903 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1904 if (id != RSXR_TRAP)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1905 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1906 printf("Invalid id. %x != %x(RSXR_TRAP)\n",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1907 id,RSXR_TRAP);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1908 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1909 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1910 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1911 else if (rs_read_int(inf,&value) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1912 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1913 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1914 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1915 printf("Incorrect number of traps in block. %d > %d.",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1916 value,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1917 printf("Sorry, invalid save game format\n");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1918 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1919 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1920 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1921 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1922 for(n=0;n<value;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1923 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1924 rs_read_uchar(inf,&trap[n].tr_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1925 rs_read_uchar(inf,&trap[n].tr_show);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1926 rs_read_coord(inf,&trap[n].tr_pos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1927 rs_read_long(inf,&trap[n].tr_flags);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1928 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1929 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1930 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1931 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1932 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1933 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1934
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1935 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1936 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1937
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1938 rs_write_monsters(FILE * savef, struct monster * m, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1939 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1940 int n;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1941
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1942 DBG(("Monsters\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1943 rs_write_int(savef, RSXR_MONSTERS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1944 rs_write_int(savef, count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1945
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1946 for(n=0;n<count;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1947 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1948 rs_write(savef, m[n].m_name, sizeof(m[n].m_name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1949 /*printf("Monster: %s/%d/%d\n",m[n].m_name,sizeof(m[n].m_name),strlen(m[n].m_name));*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1950 rs_write_short(savef, m[n].m_carry);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1951 rs_write_boolean(savef, m[n].m_normal);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1952 rs_write_boolean(savef, m[n].m_wander);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1953 rs_write_char(savef, m[n].m_appear);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1954 rs_write(savef, m[n].m_intel,sizeof(m[n].m_intel));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1955 rs_write_longs(savef, m[n].m_flags, MAXFLAGS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1956 rs_write(savef, m[n].m_typesum,sizeof(m[n].m_typesum));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1957 rs_write_short(savef, m[n].m_numsum);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1958 rs_write_short(savef, m[n].m_add_exp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1959
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1960 rs_write_mstats(savef, &m[n].m_stats);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1961 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1962
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1963 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1964 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1965
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1966 rs_read_monsters(int inf, struct monster *m, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1967 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1968 int id = 0, value = 0, n = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1969 char buffer[1024];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1970
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1971 if (rs_read_int(inf, &id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1972 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1973 if (id != RSXR_MONSTERS)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1974 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1975 printf("Invalid id. %x != %x(RSXR_MONSTERS)\n",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1976 id,RSXR_MONSTERS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1977 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1978 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1979 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1980 else if (rs_read_int(inf, &value) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1981 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1982 if (value != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1983 { printf("Incorrect number of monsters in block. %d != %d.",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1984 value,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1985 printf("Sorry, invalid save game format\n");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1986 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1987
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1988 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1989 else for(n=0;n<value;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1990 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1991 rs_read(inf, buffer,sizeof(m[n].m_name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1992 assert( strcmp(buffer,m[n].m_name) == 0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1993 /*printf("Monster: %s\n",m[n].m_name);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1994 rs_read_short(inf, &m[n].m_carry);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1995 /*printf(" Carry: %d\n",m[n].m_carry); */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1996 rs_read_boolean(inf, &m[n].m_normal);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1997 /*printf(" Normal: %d\n",m[n].m_normal);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1998 rs_read_boolean(inf, &m[n].m_wander);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1999 /*printf(" Wander: %d\n",m[n].m_wander);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2000 rs_read_char(inf, &m[n].m_appear);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2001 /*printf(" Appears: %c\n",m[n].m_appear);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2002 rs_read(inf, m[n].m_intel,sizeof(m[n].m_intel));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2003 /*printf(" Intelligence: %s\n",m[n].m_intel);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2004 rs_read_longs(inf, m[n].m_flags, MAXFLAGS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2005 /*printf(" Flags: %X\n",m[n].m_flags);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2006 rs_read(inf, m[n].m_typesum, sizeof(m[n].m_typesum));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2007 /*printf(" Summons: %s\n",m[n].m_typesum);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2008 rs_read_short(inf, &m[n].m_numsum);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2009 /*printf(" # Summons: %d\n",m[n].m_numsum);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2010 rs_read_short(inf, &m[n].m_add_exp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2011 /*printf(" Experience: %d\n",m[n].m_add_exp);*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2012 rs_read_mstats(inf, &m[n].m_stats);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2013
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2014 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2015 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2016 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2017 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2018 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2019
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2020 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2021 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2022
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2023 /*****************************************************************************/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2024
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2025 rs_write_coord_list(FILE *savef, struct linked_list *l)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2026 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2027 DBG(("Coordinate List\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2028 rs_write_int(savef, RSXR_COORDLIST);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2029 rs_write_int(savef, list_size(l));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2030
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2031 while (l != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2032 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2033 rs_write_coord(savef, (coord *) l->l_data);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2034 l = l->l_next;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2035 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2036
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2037 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2038 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2039
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2040 rs_read_coord_list(int inf, struct linked_list **list)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2041 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2042 int id;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2043 int i, cnt;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2044 struct linked_list *l = NULL, *previous = NULL, *head = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2045
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2046 if (rs_read_int(inf,&id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2047 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2048 if (id != RSXR_COORDLIST)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2049 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2050 printf("Invalid id. %x != %x(RSXR_COORDLIST)\n",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2051 id,RSXR_COORDLIST);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2052 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2053 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2054 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2055 else if (rs_read_int(inf,&cnt) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2056 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2057 for (i = 0; i < cnt; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2058 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2059 l = new_item(sizeof(coord));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2060 l->l_prev = previous;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2061 if (previous != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2062 previous->l_next = l;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2063 rs_read_coord(inf,(coord *) l->l_data);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2064 if (previous == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2065 head = l;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2066 previous = l;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2067 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2068
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2069 if (l != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2070 l->l_next = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2071
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2072 *list = head;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2073 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2074 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2075 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2076 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2077 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2078 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2079
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2080 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2081 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2082
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2083 rs_write_object_list(FILE *savef, struct linked_list *l)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2084 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2085 DBG(("Object List\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2086 rs_write_int(savef, RSXR_OBJECTLIST);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2087 rs_write_int(savef, list_size(l));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2088
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2089 while (l != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2090 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2091 rs_write_object(savef, (struct object *) l->l_data);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2092 l = l->l_next;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2093 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2094
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2095 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2096 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2097
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2098 rs_read_object_list(int inf, struct linked_list **list)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2099 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2100 int id;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2101 int i, cnt;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2102 struct linked_list *l = NULL, *previous = NULL, *head = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2103
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2104 if (rs_read_int(inf,&id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2105 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2106 if (rs_read_int(inf,&cnt) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2107 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2108 for (i = 0; i < cnt; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2109 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2110 l = new_item(sizeof(struct object));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2111 memset(l->l_data,0,sizeof(struct object));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2112 l->l_prev = previous;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2113 if (previous != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2114 previous->l_next = l;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2115 rs_read_object(inf,(struct object *) l->l_data);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2116 if (previous == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2117 head = l;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2118 previous = l;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2119 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2120
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2121 if (l != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2122 l->l_next = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2123
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2124 *list = head;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2125 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2126 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2127 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2128 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2129 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2130 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2131
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2132
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2133 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2134 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2135
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2136 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2137 find_thing_coord(monlist, c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2138 struct linked_list *monlist;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2139 coord *c;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2140 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2141 struct linked_list *mitem;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2142 struct thing *tp;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2143 int i = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2144
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2145 for(mitem = monlist; mitem != NULL; mitem = mitem->l_next)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2146 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2147 tp = THINGPTR(mitem);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2148 if (c == &tp->t_pos)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2149 return(i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2150 i++;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2151 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2152
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2153 return(-1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2154 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2155
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2156 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2157 find_object_coord(objlist, c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2158 struct linked_list *objlist;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2159 coord *c;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2160 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2161 struct linked_list *oitem;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2162 struct object *obj;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2163 int i = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2164
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2165 for(oitem = objlist; oitem != NULL; oitem = oitem->l_next)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2166 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2167 obj = OBJPTR(oitem);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2168 if (c == &obj->o_pos)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2169 return(i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2170 i++;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2171 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2172
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2173 return(-1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2174 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2175
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2176 rs_write_thing(FILE *savef, struct thing *t)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2177 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2178 int i = -1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2179
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2180 DBG(("Thing\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2181 rs_write_int(savef, RSXR_THING);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2182 rs_write_boolean(savef,t->t_wasshot);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2183 rs_write_char(savef, t->t_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2184 rs_write_char(savef, t->t_disguise);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2185 rs_write_char(savef, t->t_oldch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2186 rs_write_short(savef, t->t_ctype);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2187 rs_write_short(savef, t->t_index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2188 rs_write_short(savef, t->t_no_move);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2189 rs_write_short(savef, t->t_quiet);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2190 rs_write_short(savef, t->t_movement);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2191 rs_write_short(savef, t->t_action);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2192 rs_write_short(savef, t->t_artifact);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2193 rs_write_short(savef, t->t_wand);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2194 rs_write_short(savef, t->t_summon);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2195 rs_write_short(savef, t->t_cast);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2196 rs_write_short(savef, t->t_breathe);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2197
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2198 rs_write_string(savef,t->t_name);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2199 rs_write_coord(savef, &t->t_doorgoal);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2200
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2201 if (t->t_dest == &hero)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2202 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2203 rs_write_int(savef,0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2204 rs_write_int(savef,1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2205 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2206 else if (t->t_dest != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2207 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2208 i = find_thing_coord(mlist, t->t_dest);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2209
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2210 if (i >= 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2211 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2212 rs_write_int(savef,1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2213 rs_write_int(savef,i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2214 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2215 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2216 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2217 i = find_object_coord(lvl_obj, t->t_dest);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2218
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2219 if (i >= 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2220 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2221 rs_write_int(savef,2);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2222 rs_write_int(savef,i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2223 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2224 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2225 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2226 rs_write_int(savef,0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2227 rs_write_int(savef,1); /* chase the hero anyway */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2228 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2229 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2230 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2231 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2232 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2233 rs_write_int(savef,0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2234 rs_write_int(savef,0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2235 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2236
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2237 rs_write_coord(savef, &t->t_pos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2238 rs_write_coord(savef, &t->t_oldpos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2239 rs_write_coord(savef, &t->t_newpos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2240 rs_write_ulongs(savef, t->t_flags, 16);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2241
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2242 DBG(("Thing\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2243 DBG((" SaveID : %X\n",RSXR_THING));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2244 DBG((" Name : %s\n",t->t_name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2245 DBG((" WasShot : %d\n",t->t_wasshot));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2246 DBG((" Type : %c(%d)\n",t->t_type,t->t_type));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2247 DBG((" Disguise: %c(%d)\n",t->t_disguise,t->t_disguise));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2248 DBG((" OldCh : %c(%d)\n",t->t_oldch,t->t_oldch));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2249 DBG((" CType : %d\n",t->t_ctype));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2250 DBG((" Index : %d\n",t->t_index));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2251 DBG((" NoMove : %d\n",t->t_no_move));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2252 DBG((" Quiet : %d\n",t->t_quiet));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2253 DBG((" Movement: %d\n",t->t_movement));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2254 DBG((" Action : %d\n",t->t_action));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2255 DBG((" Artifact: %d\n",t->t_artifact));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2256 DBG((" Wand : %d\n",t->t_wand));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2257 DBG((" Summon : %d\n",t->t_summon));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2258 DBG((" Cast : %d\n",t->t_cast));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2259 DBG((" Breathe : %d\n",t->t_breathe));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2260 DBG((" DoorGoal: %d %d\n",t->t_doorgoal.x,t->t_doorgoal.y));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2261 if (t->t_dest)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2262 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2263 DBG((" Dest : %d %d\n",t->t_dest->x,t->t_dest->y));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2264 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2265 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2266 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2267 DBG((" Dest : None\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2268 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2269 DBG((" Pos : %d %d\n",t->t_pos.x,t->t_pos.y));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2270 DBG((" OldPos : %d %d\n",t->t_oldpos.x,t->t_oldpos.y));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2271 DBG((" NewPos : %d %d\n",t->t_newpos.x,t->t_newpos.y));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2272 DBG((" Flags : "));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2273 { int i; for(i=0;i<16;i++) {DBG(("%d ",t->t_flags[i]));} DBG(("\n")); }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2274
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2275 rs_write_object_list(savef, t->t_pack);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2276 i = -1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2277 if (t->t_using != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2278 i = find_list_ptr(t->t_pack, t->t_using->l_data);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2279 rs_write_int(savef, i);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2280 rs_write_stats(savef, &t->t_stats);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2281 rs_write_stats(savef, &t->maxstats);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2282
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2283 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2284 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2285
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2286 rs_fix_thing(struct thing *t)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2287 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2288 struct linked_list *item;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2289 struct thing *tp;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2290
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2291 if (t->t_reserved < 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2292 return;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2293
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2294 item = get_list_item(mlist,t->t_reserved);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2295
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2296 if (item != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2297 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2298 tp = THINGPTR(item);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2299 t->t_dest = &tp->t_pos;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2300 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2301 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2302
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2303 rs_read_thing(int inf, struct thing *t)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2304 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2305 int id;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2306 int listid = 0, index = -1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2307 struct linked_list *item;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2308
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2309 if (rs_read_int(inf, &id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2310 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2311 if (id != RSXR_THING)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2312 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2313 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2314 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2315 rs_read_boolean(inf,&t->t_wasshot);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2316 rs_read_uchar(inf, &t->t_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2317 rs_read_uchar(inf, &t->t_disguise);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2318 rs_read_uchar(inf, &t->t_oldch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2319 rs_read_short(inf, &t->t_ctype);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2320 rs_read_short(inf, &t->t_index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2321 rs_read_short(inf, &t->t_no_move);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2322 rs_read_short(inf, &t->t_quiet);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2323 rs_read_short(inf, &t->t_movement);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2324 rs_read_short(inf, &t->t_action);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2325 rs_read_short(inf, &t->t_artifact);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2326 rs_read_short(inf, &t->t_wand);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2327 rs_read_short(inf, &t->t_summon);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2328 rs_read_short(inf, &t->t_cast);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2329 rs_read_short(inf, &t->t_breathe);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2330 rs_read_new_string(inf,&t->t_name);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2331 rs_read_coord(inf,&t->t_doorgoal);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2332
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2333 rs_read_int(inf,&listid);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2334 rs_read_int(inf,&index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2335 t->t_reserved = -1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2336 if (listid == 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2337 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2338 if (index == 1)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2339 t->t_dest = &hero;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2340 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2341 t->t_dest = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2342 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2343 else if (listid == 1)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2344 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2345 t->t_dest = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2346 t->t_reserved = index;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2347 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2348 else if (listid == 2)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2349 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2350 struct object *obj;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2351 item = get_list_item(lvl_obj,index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2352 if (item != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2353 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2354 obj = OBJPTR(item);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2355 t->t_dest = &obj->o_pos;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2356 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2357 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2358 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2359 t->t_dest = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2360
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2361 rs_read_coord(inf,&t->t_pos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2362 rs_read_coord(inf,&t->t_oldpos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2363 rs_read_coord(inf,&t->t_newpos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2364 rs_read_ulongs(inf,t->t_flags,16);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2365 rs_read_object_list(inf,&t->t_pack);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2366 rs_read_int(inf,&index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2367 t->t_using = get_list_item(t->t_pack, index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2368 rs_read_stats(inf,&t->t_stats);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2369 rs_read_stats(inf,&t->maxstats);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2370 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2371 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2372 else format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2373
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2374 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2375 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2376
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2377 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2378 find_list_ptr(struct linked_list *l, void *ptr)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2379 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2380 int count = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2381
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2382 while(l != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2383 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2384 if (l->l_data == ptr)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2385 return(count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2386
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2387 l = l->l_next;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2388 count++;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2389 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2390
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2391 return(-1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2392 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2393
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2394
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2395 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2396 list_size(struct linked_list *l)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2397 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2398 int count = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2399
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2400 while(l != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2401 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2402 if (l->l_data == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2403 return(count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2404
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2405 count++;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2406
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2407 l = l->l_next;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2408 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2409
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2410 return(count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2411 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2412
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2413
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2414 rs_write_monster_list(FILE *savef, struct linked_list *l)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2415 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2416 int cnt = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2417
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2418 DBG(("Monster List\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2419 rs_write_int(savef, RSXR_MONSTERLIST);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2420
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2421 cnt = list_size(l);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2422
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2423 rs_write_int(savef, cnt);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2424
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2425 if (cnt < 1)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2426 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2427
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2428 while (l != NULL) {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2429 rs_write_thing(savef, (struct thing *)l->l_data);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2430 l = l->l_next;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2431 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2432
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2433 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2434 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2435
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2436 rs_fix_monster_list(list)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2437 struct linked_list *list;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2438 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2439 struct linked_list *item;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2440
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2441 for(item = list; item != NULL; item = item->l_next)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2442 rs_fix_thing(THINGPTR(item));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2443 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2444
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2445 rs_read_monster_list(int inf, struct linked_list **list)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2446 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2447 int id;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2448 int i, cnt;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2449 struct linked_list *l = NULL, *previous = NULL, *head = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2450
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2451 if (rs_read_int(inf,&id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2452 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2453 if (id != RSXR_MONSTERLIST)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2454 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2455 printf("Invalid id. %x != %x(RSXR_MONSTERLIST)\n",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2456 id,RSXR_MONSTERLIST);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2457 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2458 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2459 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2460 else if (rs_read_int(inf,&cnt) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2461 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2462 for (i = 0; i < cnt; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2463 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2464 l = new_item(sizeof(struct thing));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2465 l->l_prev = previous;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2466 if (previous != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2467 previous->l_next = l;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2468 rs_read_thing(inf,(struct thing *)l->l_data);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2469 if (previous == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2470 head = l;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2471 previous = l;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2472 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2473
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2474
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2475 if (l != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2476 l->l_next = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2477
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2478 *list = head;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2479 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2480 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2481 else format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2482
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2483 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2484 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2485
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2486 rs_write_magic_items(FILE *savef, struct magic_item *i, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2487 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2488 int n;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2489
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2490 DBG(("Magic Items\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2491 rs_write_int(savef, RSXR_MAGICITEMS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2492 rs_write_int(savef, count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2493
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2494 for(n=0;n<count;n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2495 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2496 rs_write(savef,i[n].mi_name,sizeof(i[n].mi_name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2497 rs_write_int(savef,i[n].mi_prob);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2498 rs_write_int(savef,i[n].mi_worth);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2499 rs_write_int(savef,i[n].mi_curse);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2500 rs_write_int(savef,i[n].mi_bless);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2501 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2502
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2503 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2504 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2505
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2506 rs_read_magic_items(int inf, struct magic_item *mi, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2507 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2508 int id;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2509 int n;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2510 int value;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2511
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2512 if (rs_read_int(inf, &id) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2513 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2514 if (id != RSXR_MAGICITEMS)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2515 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2516 printf("Invalid id. %x != %x(RSXR_MAGICITEMS)\n",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2517 id,RSXR_MAGICITEMS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2518 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2519 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2520 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2521 else if (rs_read_int(inf, &value) != 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2522 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2523 if (value > count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2524 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2525 printf("Incorrect number of magic items in block. %d > %d.",
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2526 value,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2527 printf("Sorry, invalid save game format");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2528 format_error = TRUE;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2529 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2530 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2531 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2532 for(n = 0; n < value; n++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2533 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2534 rs_read(inf,mi[n].mi_name,sizeof(mi[n].mi_name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2535 rs_read_int(inf,&mi[n].mi_prob);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2536 rs_read_int(inf,&mi[n].mi_worth);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2537 rs_read_int(inf,&mi[n].mi_curse);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2538 rs_read_int(inf,&mi[n].mi_bless);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2539 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2540 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2541 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2542 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2543
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2544 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2545 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2546
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2547 rs_write_window(FILE *savef, WINDOW *win)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2548 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2549 int row,col,height,width;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2550 width = getmaxx(win);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2551 height = getmaxy(win);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2552 DBG(("Window\n"));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2553 rs_write_int(savef,height);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2554 rs_write_int(savef,width);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2555
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2556 for(row=0;row<height;row++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2557 for(col=0;col<width;col++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2558 rs_write_int(savef, mvwinch(win,row,col));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2559 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2560
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2561 rs_read_window(int inf, WINDOW *win)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2562 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2563 int row,col,maxlines,maxcols,value,width,height;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2564
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2565 width = getmaxx(win);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2566 height = getmaxy(win);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2567
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2568 rs_read_int(inf,&maxlines);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2569 rs_read_int(inf,&maxcols);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2570 if (maxlines > height)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2571 abort();
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2572 if (maxcols > width)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2573 abort();
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2574
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2575 for(row=0;row<maxlines;row++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2576 for(col=0;col<maxcols;col++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2577 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2578 rs_read_int(inf, &value);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2579 if ((value == '-') || (value == 196))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2580 value = HORZWALL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2581 else if ((value == '|') || (value == 179))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2582 value = VERTWALL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2583 mvwaddch(win,row,col,value);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2584 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2585
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2586 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2587 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2588
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2589 rs_save_file(FILE *savef)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2590 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2591 int i, weapon, armor, ring, misc, room = -1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2592 int endian = 0x01020304;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2593 big_endian = ( *((char *)&endian) == 0x01 );
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2594
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2595 rs_write_thing(savef, &player); /* rogue.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2596 rs_write_object_list(savef, lvl_obj); /* rogue.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2597 rs_write_monster_list(savef, mlist); /* rogue.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2598 rs_write_monster_list(savef, tlist); /* rogue.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2599
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2600 rs_write_traps(savef, traps, MAXTRAPS); /* rogue.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2601
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2602 armor = find_list_ptr(player.t_pack, cur_armor);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2603 rs_write_int(savef, armor); /* rogue.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2604
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2605 for (i = 0; i < NUM_FINGERS; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2606 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2607 ring = find_list_ptr(player.t_pack, cur_ring[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2608 rs_write_int(savef, ring); /* rogue.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2609 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2610
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2611 for (i = 0; i < NUM_MM; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2612 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2613 misc = find_list_ptr(player.t_pack, cur_misc[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2614 rs_write_int(savef, misc); /* rogue.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2615 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2616
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2617 for (i=0; i<MAXRELIC; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2618 rs_write_int(savef,cur_relic[i]); /* rogue.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2619
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2620
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2621 rs_write_rooms(savef, rooms, MAXROOMS); /* rogue.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2622
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2623 for (i = 0; i < MAXROOMS; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2624 if (&rooms[i] == oldrp)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2625 room = i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2626 rs_write_int(savef, room); /* rogue.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2627
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2628 weapon = find_list_ptr(player.t_pack, cur_weapon);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2629 rs_write_int(savef, weapon); /* rogue..c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2630 rs_write_int(savef,char_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2631 rs_write_int(savef,foodlev);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2632 rs_write_int(savef,ntraps);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2633 rs_write_int(savef,trader);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2634 rs_write_int(savef,curprice);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2635 rs_write_int(savef,seed);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2636 rs_write_int(savef,max_level);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2637 rs_write_int(savef,cur_max);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2638 rs_write_int(savef,prev_max);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2639 rs_write_int(savef,move_free);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2640 rs_write_int(savef,mpos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2641 rs_write_int(savef,level);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2642 rs_write_long(savef,purse);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2643 rs_write_int(savef,inpack);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2644 rs_write_int(savef,total);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2645 rs_write_int(savef,no_food);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2646 rs_write_int(savef,foods_this_level);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2647 rs_write_int(savef,count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2648 rs_write_int(savef,food_left);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2649 rs_write_int(savef,group);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2650 rs_write_int(savef,hungry_state);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2651 rs_write_int(savef,infest_dam);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2652 rs_write_int(savef,lost_str);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2653 rs_write_int(savef,lastscore);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2654 rs_write_int(savef,hold_count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2655 rs_write_int(savef,trap_tries);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2656 rs_write_int(savef,chant_time);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2657 rs_write_int(savef,pray_time);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2658 rs_write_int(savef,spell_power);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2659 rs_write_long(savef,turns);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2660 rs_write_int(savef,quest_item);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2661 rs_write_int(savef,cols);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2662 rs_write_int(savef,lines);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2663 rs_write_int(savef,nfloors);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2664 rs_write(savef,curpurch,LINELEN);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2665 rs_write_char(savef,PLAYER);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2666 rs_write_char(savef,take);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2667 rs_write_int(savef,1234);/*checkpoint*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2668 rs_write(savef,prbuf,LINELEN*2);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2669 rs_write_int(savef,1234);/*checkpoint*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2670 rs_write_char(savef,runch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2671 rs_write_int(savef,1234);/*checkpoint*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2672 rs_write_scrolls(savef);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2673 rs_write_potions(savef);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2674 rs_write_rings(savef);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2675 rs_write_sticks(savef);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2676 rs_write_misc(savef);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2677 rs_write_int(savef,1234);/*checkpoint*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2678 rs_write(savef,whoami,LINELEN);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2679 rs_write_window(savef, cw);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2680 rs_write_window(savef, hw);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2681 rs_write_window(savef, mw);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2682 rs_write_window(savef, msgw);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2683 rs_write_window(savef, stdscr);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2684 rs_write_boolean(savef,pool_teleport);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2685 rs_write_boolean(savef,inwhgt);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2686 rs_write_boolean(savef,after);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2687 rs_write_boolean(savef,waswizard);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2688 rs_write_boolean(savef, playing); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2689 rs_write_boolean(savef, running); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2690 rs_write_boolean(savef, wizard); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2691 rs_write_boolean(savef, notify); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2692 rs_write_boolean(savef, fight_flush); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2693 rs_write_boolean(savef, terse); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2694 rs_write_boolean(savef, auto_pickup); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2695 rs_write_boolean(savef, def_attr); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2696 rs_write_boolean(savef, menu_overlay); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2697 rs_write_boolean(savef, door_stop); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2698 rs_write_boolean(savef, jump); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2699 rs_write_boolean(savef, slow_invent); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2700 rs_write_boolean(savef, firstmove); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2701 rs_write_boolean(savef, askme); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2702 rs_write_boolean(savef, in_shell); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2703 rs_write_boolean(savef, daytime); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2704 rs_write_boolean(savef, funfont); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2705 rs_write_levtype(savef,levtype);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2706 rs_write_character_types(savef,char_class,NUM_CHARTYPES);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2707 rs_write_words(savef,abilities,NUMABILITIES);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2708 for(i=0;i<9;i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2709 rs_write_coord(savef,&grid[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2710 rs_write_death_types(savef,deaths,DEATHNUM);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2711 rs_write_init_weps(savef,weaps,MAXWEAPONS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2712 rs_write_init_armor(savef,armors,MAXARMORS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2713 rs_write_magic_items(savef, things, NUMTHINGS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2714 rs_write_magic_items(savef, s_magic, MAXSCROLLS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2715 rs_write_magic_items(savef, p_magic, MAXPOTIONS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2716 rs_write_magic_items(savef, r_magic, MAXRINGS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2717 rs_write_magic_items(savef, ws_magic, MAXSTICKS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2718 rs_write_magic_items(savef, m_magic, MAXMM); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2719 rs_write_magic_items(savef, rel_magic, MAXRELIC); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2720 rs_write_magic_items(savef, foods, MAXFOODS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2721 rs_write_spells(savef,magic_spells,MAXSPELLS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2722 rs_write_spells(savef,cleric_spells,MAXPRAYERS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2723 rs_write_spells(savef,druid_spells,MAXCHANTS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2724 rs_write_spells(savef,quill_scrolls,MAXQUILL);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2725
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2726 rs_write_int(savef,mf_count); /* actions.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2727 rs_write_int(savef,mf_jmpcnt); /* actions.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2728 rs_write_daemons(savef, d_list, MAXDAEMONS); /* daemon.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2729 rs_write_daemons(savef, f_list, MAXFUSES); /* daemon.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2730 rs_write_int(savef,demoncnt); /* daemon.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2731 rs_write_int(savef,fusecnt); /* daemon.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2732 rs_write_int(savef,killed_chance); /* fight.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2733 rs_write_words(savef,rainbow,NCOLORS); /* init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2734 rs_write_words(savef,sylls,NSYLLS); /* init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2735 rs_write_words(savef,stones,NSTONES); /* init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2736 rs_write_words(savef,wood,NWOOD); /* init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2737 rs_write_words(savef,metal,NMETAL); /* init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2738 rs_write_monsters(savef,monsters,
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2739 sizeof(monsters)/sizeof(struct monster)); /* mons_def.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2740 rs_write_coord(savef,&move_nh); /* move.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2741 return(WRITESTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2742 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2743
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2744 rs_restore_file(int inf)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2745 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2746 int weapon, armor, ring, misc, room = -1,i,checkpoint;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2747 int endian = 0x01020304;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2748 big_endian = ( *((char *)&endian) == 0x01 );
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2749
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2750 rs_read_thing(inf, &player); /* rogue.h */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2751 rs_read_object_list(inf, &lvl_obj); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2752 rs_read_monster_list(inf, &mlist); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2753 rs_read_monster_list(inf, &tlist); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2754 rs_fix_thing(&player);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2755 rs_fix_monster_list(mlist);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2756 rs_read_traps(inf, traps, MAXTRAPS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2757
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2758
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2759 rs_read_int(inf, &armor); /* rogue.h */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2760 cur_armor = get_list_item(player.t_pack,armor);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2761
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2762 for(i = 0; i < NUM_FINGERS; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2763 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2764 rs_read_int(inf,&ring);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2765 cur_ring[i] = get_list_item(player.t_pack,ring);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2766 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2767
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2768 for(i = 0; i < NUM_MM; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2769 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2770 rs_read_int(inf,&misc);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2771 cur_misc[i] = get_list_item(player.t_pack,misc);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2772 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2773
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2774 for(i=0;i<MAXRELIC;i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2775 rs_read_int(inf,&cur_relic[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2776
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2777 rs_read_rooms(inf, rooms, MAXROOMS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2778 rs_read_int(inf, &room);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2779
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2780 oldrp = &rooms[room];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2781
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2782 rs_read_int(inf,&weapon);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2783 cur_weapon = get_list_item(player.t_pack,weapon);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2784
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2785 rs_read_int(inf,&char_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2786 rs_read_int(inf,&foodlev);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2787 rs_read_int(inf,&ntraps);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2788 rs_read_int(inf,&trader);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2789 rs_read_int(inf,&curprice);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2790 rs_read_int(inf,&seed);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2791 rs_read_int(inf,&max_level);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2792 rs_read_int(inf,&cur_max);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2793 rs_read_int(inf,&prev_max);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2794 rs_read_int(inf,&move_free);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2795 rs_read_int(inf,&mpos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2796 rs_read_int(inf,&level);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2797 rs_read_long(inf,&purse);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2798 rs_read_int(inf,&inpack);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2799 rs_read_int(inf,&total);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2800 rs_read_int(inf,&no_food);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2801 rs_read_int(inf,&foods_this_level);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2802 rs_read_int(inf,&count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2803 rs_read_int(inf,&food_left);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2804 rs_read_int(inf,&group);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2805 rs_read_int(inf,&hungry_state);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2806 rs_read_int(inf,&infest_dam);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2807 rs_read_int(inf,&lost_str);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2808 rs_read_int(inf,&lastscore);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2809 rs_read_int(inf,&hold_count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2810 rs_read_int(inf,&trap_tries);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2811 rs_read_int(inf,&chant_time);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2812 rs_read_int(inf,&pray_time);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2813 rs_read_int(inf,&spell_power);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2814 rs_read_long(inf,&turns);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2815 rs_read_int(inf,&quest_item);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2816 rs_read_int(inf,&cols);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2817 rs_read_int(inf,&lines);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2818 rs_read_int(inf,&nfloors);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2819 rs_read(inf,curpurch,LINELEN);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2820 rs_read_char(inf,&PLAYER);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2821 rs_read_char(inf,&take);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2822 rs_read_int(inf,&checkpoint);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2823 if (checkpoint != 1234){printf("Checkpoint failed");abort();}
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2824 rs_read(inf,prbuf,LINELEN*2);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2825 rs_read_int(inf,&checkpoint);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2826 if (checkpoint != 1234){printf("Checkpoint failed");abort();}
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2827 rs_read_char(inf,&runch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2828 rs_read_int(inf,&checkpoint);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2829 if (checkpoint != 1234){printf("Checkpoint failed");abort();}
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2830 rs_read_scrolls(inf);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2831 rs_read_potions(inf);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2832 rs_read_rings(inf);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2833 rs_read_sticks(inf);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2834 rs_read_misc(inf);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2835 rs_read_int(inf,&checkpoint);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2836 if (checkpoint != 1234){printf("Checkpoint failed");abort();}
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2837 rs_read(inf,whoami,LINELEN);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2838 rs_read_window(inf, cw);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2839 rs_read_window(inf, hw);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2840 rs_read_window(inf, mw);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2841 rs_read_window(inf, msgw);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2842 rs_read_window(inf, stdscr);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2843 rs_read_boolean(inf,&pool_teleport);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2844 rs_read_boolean(inf,&inwhgt);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2845 rs_read_boolean(inf,&after);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2846 rs_read_boolean(inf,&waswizard);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2847 rs_read_boolean(inf, &playing); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2848 rs_read_boolean(inf, &running); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2849 rs_read_boolean(inf, &wizard); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2850 rs_read_boolean(inf, &notify); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2851 rs_read_boolean(inf, &fight_flush); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2852 rs_read_boolean(inf, &terse); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2853 rs_read_boolean(inf, &auto_pickup); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2854 rs_read_boolean(inf, &def_attr); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2855 rs_read_boolean(inf, &menu_overlay); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2856 rs_read_boolean(inf, &door_stop); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2857 rs_read_boolean(inf, &jump); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2858 rs_read_boolean(inf, &slow_invent); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2859 rs_read_boolean(inf, &firstmove); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2860 rs_read_boolean(inf, &askme); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2861 rs_read_boolean(inf, &in_shell); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2862 rs_read_boolean(inf, &daytime); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2863 rs_read_boolean(inf, &funfont); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2864 rs_read_levtype(inf,&levtype);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2865 rs_read_character_types(inf,char_class,NUM_CHARTYPES);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2866 rs_read_words(inf,abilities,NUMABILITIES);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2867 for(i=0;i<9;i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2868 rs_read_coord(inf,&grid[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2869 rs_read_death_types(inf,deaths,DEATHNUM);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2870 rs_read_init_weps(inf,weaps,MAXWEAPONS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2871 rs_read_init_armor(inf,armors,MAXARMORS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2872 rs_read_magic_items(inf, things,NUMTHINGS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2873 rs_read_magic_items(inf, s_magic,MAXSCROLLS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2874 rs_read_magic_items(inf, p_magic,MAXPOTIONS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2875 rs_read_magic_items(inf, r_magic,MAXRINGS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2876 rs_read_magic_items(inf, ws_magic,MAXSTICKS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2877 rs_read_magic_items(inf, m_magic,MAXMM); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2878 rs_read_magic_items(inf, rel_magic,MAXRELIC); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2879 rs_read_magic_items(inf, foods,MAXFOODS); /* rogue.h/init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2880 rs_read_spells(inf,magic_spells,MAXSPELLS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2881 rs_read_spells(inf,cleric_spells,MAXPRAYERS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2882 rs_read_spells(inf,druid_spells,MAXCHANTS);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2883 rs_read_spells(inf,quill_scrolls,MAXQUILL);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2884
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2885 rs_read_int(inf,&mf_count); /* actions.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2886 rs_read_int(inf,&mf_jmpcnt); /* actions.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2887 rs_read_daemons(inf, d_list, MAXDAEMONS); /* daemon.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2888 rs_read_daemons(inf, f_list, MAXFUSES); /* daemon.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2889 rs_read_int(inf,&demoncnt); /* daemon.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2890 rs_read_int(inf,&fusecnt); /* daemon.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2891 rs_read_int(inf,&killed_chance); /* fight.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2892 rs_read_words(inf,rainbow,NCOLORS); /* init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2893 rs_read_words(inf,sylls,NSYLLS); /* init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2894 rs_read_words(inf,stones,NSTONES); /* init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2895 rs_read_words(inf,wood,NWOOD); /* init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2896 rs_read_words(inf,metal,NMETAL); /* init.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2897
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2898 rs_read_monsters(inf,monsters,
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2899 sizeof(monsters)/sizeof(struct monster)); /* mons_def.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2900 rs_read_coord(inf,&move_nh); /* move.c */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2901
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2902 return(READSTAT);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2903 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2904
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2905 rs_write_scorefile(FILE *savef, struct sc_ent *entries, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2906 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2907 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2908
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2909 rs_write_int(savef, count);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2910 for(i = 0; i < count; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2911 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2912 rs_write_ulong(savef, entries[i].sc_score);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2913 rs_write(savef, entries[i].sc_name, sizeof(entries[i].sc_name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2914 rs_write(savef, entries[i].sc_system, sizeof(entries[i].sc_system));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2915 rs_write(savef, entries[i].sc_login, sizeof(entries[i].sc_login));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2916 rs_write_short(savef, entries[i].sc_flags);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2917 rs_write_short(savef, entries[i].sc_level);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2918 rs_write_short(savef, entries[i].sc_ctype);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2919 rs_write_short(savef, entries[i].sc_monster);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2920 rs_write_short(savef, entries[i].sc_quest);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2921 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2922 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2923
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2924 rs_read_scorefile(FILE *savef, struct sc_ent *entries, int count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2925 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2926 int i,available = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2927
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2928 rs_read_int(fileno(savef), &available);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2929
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2930 if (end_of_file)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2931 return(-1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2932
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2933 if (available != count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2934 return(-2);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2935
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2936 for(i = 0; i < count; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2937 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2938 rs_read_ulong(fileno(savef), &entries[i].sc_score);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2939 rs_read(fileno(savef), entries[i].sc_name, sizeof(entries[i].sc_name));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2940 rs_read(fileno(savef), entries[i].sc_system, sizeof(entries[i].sc_system));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2941 rs_read(fileno(savef), entries[i].sc_login, sizeof(entries[i].sc_login));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2942 rs_read_short(fileno(savef), &entries[i].sc_flags);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2943 rs_read_short(fileno(savef), &entries[i].sc_level);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2944 rs_read_short(fileno(savef), &entries[i].sc_ctype);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2945 rs_read_short(fileno(savef), &entries[i].sc_monster);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2946 rs_read_short(fileno(savef), &entries[i].sc_quest);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2947 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2948
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2949 return(0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2950 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2951
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2952
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2953
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2954 rs_print_thing(FILE *outf, struct thing *thing, char *prefix, int list, int index)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2955 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2956 int i;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2957
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2958 fprintf(outf,"%sList Ident : %d\n", prefix, list);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2959 fprintf(outf,"%sList Index : %d\n", prefix, index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2960 fprintf(outf,"%st_wasshot : %d\n", prefix, thing->t_wasshot);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2961 fprintf(outf,"%st_type : %c\n", prefix, thing->t_type);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2962 fprintf(outf,"%st_disguise : %c\n", prefix, thing->t_disguise);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2963 fprintf(outf,"%st_oldch : %c\n", prefix, thing->t_oldch);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2964 fprintf(outf,"%st_ctype : %d\n", prefix, thing->t_ctype);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2965 fprintf(outf,"%st_index : %d\n", prefix, thing->t_index);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2966 fprintf(outf,"%st_no_move : %d\n", prefix, thing->t_no_move);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2967 fprintf(outf,"%st_quiet : %d\n", prefix, thing->t_quiet);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2968 fprintf(outf,"%st_movement : %d\n", prefix, thing->t_movement);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2969 fprintf(outf,"%st_action : %d\n", prefix, thing->t_action);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2970 fprintf(outf,"%st_artificat: %d\n", prefix, thing->t_artifact);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2971 fprintf(outf,"%st_wand : %d\n", prefix, thing->t_wand);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2972 fprintf(outf,"%st_summon : %d\n", prefix, thing->t_summon);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2973 fprintf(outf,"%st_cast : %d\n", prefix, thing->t_cast);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2974 fprintf(outf,"%st_breathe : %d\n", prefix, thing->t_breathe);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2975 fprintf(outf,"%st_name : %s\n", prefix, (thing->t_name == NULL) ? "none" :
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2976 thing->t_name);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2977 fprintf(outf,"%st_doorgoal : %d %d\n", prefix, thing->t_doorgoal.x, thing->t_doorgoal.y);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2978 fprintf(outf,"%st_dest : %p\n", prefix, thing->t_dest);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2979 fprintf(outf,"%st_pos : %d %d (%p)\n", prefix, thing->t_pos.x, thing->t_pos.y,&thing->t_pos);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2980 fprintf(outf,"%st_oldpos : %d %d\n", prefix, thing->t_oldpos.x, thing->t_oldpos.y);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2981 fprintf(outf,"%st_newpos : %d %d\n", prefix, thing->t_newpos.x, thing->t_newpos.y);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2982 fprintf(outf,"%st_flags : ", prefix);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2983
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2984 for(i = 0; i<16; i++)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2985 fprintf(outf,"%X ",thing->t_flags[i]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2986 fprintf(outf,"\n");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2987
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2988 fprintf(outf,"%st_pack : %p\n",prefix,thing->t_pack);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2989 fprintf(outf,"%st_using : %p\n",prefix,thing->t_using);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2990 fprintf(outf,"%st_stats : Not Implemented\n",prefix);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2991 fprintf(outf,"%st_maxstats : Not Implemented\n",prefix);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2992 fprintf(outf,"%st_reserved : %d\n",prefix,thing->t_reserved);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2993 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2994
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2995 rs_print_game_state(FILE *outf)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2996 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2997 fprintf(outf, "Player\n");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2998
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2999 rs_print_thing(outf, &player, " ", 0, 0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3000 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3001
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3002 /****
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3003 Machine Dependent Functions
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3004
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3005 md_getuid()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3006 md_memused()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3007 md_getusername()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3008 md_gethostname()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3009 md_gethomedir()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3010 md_getroguedir()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3011 md_getshell()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3012 md_shellescape()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3013 md_getpass()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3014 md_crypt()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3015 md_htons()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3016 md_nstoh()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3017 md_unlink()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3018 md_isdir()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3019 md_ntohl()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3020 md_htonl()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3021
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3022 ****/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3023
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3024 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3025 md_rand(range)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3026 register int range;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3027 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3028 #ifdef _WIN32
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3029 return(range <= 0 ? 0 : rand() % range);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3030 #else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3031 return(range <= 0 ? 0 : random() % range);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3032 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3033 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3034
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3035 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3036 md_srand(seed)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3037 register int seed;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3038 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3039 #ifdef _WIN32
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3040 srand(seed);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3041 #else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3042 srandom(seed);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3043 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3044 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3045
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3046 void
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3047 md_flushinp()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3048 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3049 /* ioctl(0,TIOCFLUSH) */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3050 /* ioctl(_tty_ch,TCFLSH,0) */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3051 flushinp();
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3052 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3053
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3054 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3055 md_getuid()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3056 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3057 #ifdef _WIN32
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3058 return(42);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3059 #else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3060 return(getuid());
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3061 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3062 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3063
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3064 long
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3065 md_memused()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3066 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3067 #ifdef _WIN32
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3068 MEMORYSTATUS stat;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3069
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3070 GlobalMemoryStatus(&stat);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3071
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3072 return((long)stat.dwTotalPageFile);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3073 #else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3074 return( (long)sbrk(0) );
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3075 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3076 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3077
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3078 char *
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3079 md_getusername()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3080 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3081 static char login[80];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3082 char *l = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3083 #ifdef _WIN32
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3084 LPSTR mybuffer;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3085 DWORD size = UNLEN + 1;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3086 TCHAR buffer[UNLEN + 1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3087
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3088 mybuffer = buffer;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3089 GetUserName(mybuffer,&size);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3090 l = mybuffer;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3091 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3092 #if !defined(_WIN32) && !defined(DJGPP)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3093 struct passwd *pw;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3094
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3095 pw = getpwuid(getuid());
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3096
144
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 143
diff changeset
3097 if (pw != NULL)
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 143
diff changeset
3098 l = pw->pw_name;
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3099 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3100
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3101 if ((l == NULL) || (*l == '\0'))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3102 if ( (l = getenv("USERNAME")) == NULL )
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3103 if ( (l = getenv("LOGNAME")) == NULL )
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3104 if ( (l = getenv("USER")) == NULL )
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3105 l = "nobody";
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3106
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3107 strncpy(login,l,80);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3108 login[79] = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3109
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3110 return(login);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3111 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3112
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3113 char *
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3114 md_gethomedir()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3115 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3116 static char homedir[PATH_MAX];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3117 char *h = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3118 size_t len;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3119 #if defined(_WIN32)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3120 TCHAR szPath[MAX_PATH];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3121 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3122 #if defined(_WIN32) || defined(DJGPP)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3123 char slash = '\\';
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3124 #else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3125 char slash = '/';
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3126 struct passwd *pw;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3127 pw = getpwuid(getuid());
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3128
144
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 143
diff changeset
3129 if (pw != NULL)
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 143
diff changeset
3130 {
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 143
diff changeset
3131 h = pw->pw_dir;
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 143
diff changeset
3132 if (strcmp(h,"/") == 0)
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 143
diff changeset
3133 h = NULL;
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 143
diff changeset
3134 }
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3135 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3136 homedir[0] = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3137
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3138 #ifdef _WIN32
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3139 if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, szPath)))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3140 h = szPath;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3141 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3142
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3143 if ( (h == NULL) || (*h == '\0') )
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3144 if ( (h = getenv("HOME")) == NULL )
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3145 if ( (h = getenv("HOMEDRIVE")) == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3146 h = "";
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3147 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3148 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3149 strncpy(homedir,h,PATH_MAX-1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3150 homedir[PATH_MAX-1] = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3151
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3152 if ( (h = getenv("HOMEPATH")) == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3153 h = "";
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3154 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3155
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3156
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3157 len = strlen(homedir);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3158 strncat(homedir,h,PATH_MAX-len-1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3159 len = strlen(homedir);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3160
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3161 if ((len > 0) && (homedir[len-1] != slash)) {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3162 homedir[len] = slash;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3163 homedir[len+1] = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3164 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3165
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3166 return(homedir);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3167 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3168
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3169 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3170 directory_exists(char *dirname)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3171 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3172 struct stat sb;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3173
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3174 if (stat(dirname, &sb) == 0) /* path exists */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3175 return (sb.st_mode & S_IFDIR);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3176
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3177 return(0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3178 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3179
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3180 char *
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3181 md_getroguedir()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3182 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3183 static char path[1024];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3184 char *end,*home;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3185
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3186 if ( (home = getenv("ROGUEHOME")) != NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3187 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3188 if (*home)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3189 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3190 strncpy(path, home, PATH_MAX - 20);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3191
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3192 end = &path[strlen(path)-1];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3193
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3194
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3195 while( (end >= path) && ((*end == '/') || (*end == '\\')))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3196 *end-- = '\0';
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3197
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3198 if (directory_exists(path))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3199 return(path);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3200 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3201 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3202
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3203 if (directory_exists("/var/games/roguelike"))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3204 return("/var/games/roguelike");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3205 if (directory_exists("/var/lib/roguelike"))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3206 return("/var/lib/roguelike");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3207 if (directory_exists("/var/roguelike"))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3208 return("/var/roguelike");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3209 if (directory_exists("/usr/games/lib"))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3210 return("/usr/games/lib");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3211 if (directory_exists("/games/roguelik"))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3212 return("/games/roguelik");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3213
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3214 return("");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3215 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3216
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3217 char *
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3218 md_getshell()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3219 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3220 static char shell[PATH_MAX];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3221 char *s = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3222 #ifdef _WIN32
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3223 char *def = "C:\\WINDOWS\\SYSTEM32\\CMD.EXE";
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3224 #elif defined(__DJGPP__)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3225 char *def = "C:\\COMMAND.COM";
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3226 #else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3227 char *def = "/bin/sh";
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3228 struct passwd *pw;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3229 pw = getpwuid(getuid());
144
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 143
diff changeset
3230 if (pw != NULL)
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 143
diff changeset
3231 s = pw->pw_shell;
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3232 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3233 if ((s == NULL) || (*s == '\0'))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3234 if ( (s = getenv("COMSPEC")) == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3235 if ( (s = getenv("SHELL")) == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3236 if ( (s = getenv("SystemRoot")) == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3237 s = def;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3238
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3239 strncpy(shell,s,PATH_MAX);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3240 shell[PATH_MAX-1] = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3241
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3242 return(shell);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3243 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3244
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3245 char *
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3246 md_gethostname()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3247 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3248 static char nodename[80];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3249 char *n = NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3250 #if !defined(_WIN32) && !defined(__DJGPP__)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3251 struct utsname ourname;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3252
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3253 if (uname(&ourname) == 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3254 n = ourname.nodename;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3255 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3256 if ((n == NULL) || (*n == '\0'))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3257 if ( (n = getenv("COMPUTERNAME")) == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3258 if ( (n = getenv("HOSTNAME")) == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3259 n = "localhost";
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3260
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3261 strncpy(nodename, n, 80);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3262 nodename[79] = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3263
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3264 return(nodename);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3265 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3266
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3267 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3268 md_shellescape()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3269 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3270 #if (!defined(_WIN32) && !defined(__DJGPP__))
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3271 int ret_status;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3272 int pid;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3273 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3274 char *sh;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3275
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3276 sh = md_getshell();
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3277
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3278 #if defined(_WIN32)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3279 return(_spawnl(_P_WAIT,sh,"shell",NULL,0));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3280 #elif defined(__DJGPP__)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3281 return ( spawnl(P_WAIT,sh,"shell",NULL,0) );
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3282 #else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3283 while((pid = fork()) < 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3284 sleep(1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3285
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3286 if (pid == 0) /* Shell Process */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3287 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3288 /*
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3289 * Set back to original user, just in case
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3290 */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3291 setuid(getuid());
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3292 setgid(getgid());
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3293 execl(sh == NULL ? "/bin/sh" : sh, "shell", "-i", 0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3294 perror("No shelly");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3295 _exit(-1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3296 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3297 else /* Application */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3298 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3299 while (wait(&ret_status) != pid)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3300 continue;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3301 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3302
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3303 return(ret_status);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3304 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3305 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3306
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3307 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3308 md_erasechar()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3309 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3310 /*
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3311 return(_tty.sg_erase);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3312 return(_tty.c_cc[VERASE]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3313 */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3314 return(erasechar());
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3315 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3316
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3317 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3318 md_killchar()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3319 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3320 /*
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3321 return(_tty.sg_kill);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3322 return(_tty.c_cc[VKILL]);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3323 */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3324 return(killchar());
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3325 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3326
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3327 long
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3328 md_ntohl(netlong)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3329 long netlong;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3330 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3331 return( ntohl(netlong) );
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3332 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3333
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3334 long
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3335 md_htonl(netlong)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3336 long netlong;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3337 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3338 return(htonl(netlong));
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3339 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3340
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3341 void
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3342 md_init()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3343 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3344 #ifdef __INTERIX
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3345 char *term;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3346
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3347 term = getenv("TERM");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3348
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3349 if (term == NULL)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3350 setenv("TERM","interix");
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3351 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3352 #if defined(__DJGPP__) || defined(_WIN32)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3353 _fmode = _O_BINARY;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3354 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3355 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3356
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3357 char *
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3358 md_getpass(prompt)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3359 char *prompt;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3360 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3361 #ifdef _WIN32
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3362 static char password_buffer[9];
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3363 char *p = password_buffer;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3364 int c, count = 0;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3365 int max_length = 9;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3366
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3367 fflush(stdout);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3368 /* If we can't prompt, abort */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3369 if (fputs(prompt, stderr) < 0)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3370 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3371 *p = '\0';
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3372 return NULL;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3373 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3374
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3375 for(;;)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3376 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3377 /* Get a character with no echo */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3378 c = _getch();
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3379
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3380 /* Exit on interrupt (^c or ^break) */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3381 if (c == '\003' || c == 0x100)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3382 exit(1);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3383
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3384 /* Terminate on end of line or file (^j, ^m, ^d, ^z) */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3385 if (c == '\r' || c == '\n' || c == '\004' || c == '\032')
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3386 break;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3387
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3388 /* Back up on backspace */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3389 if (c == '\b')
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3390 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3391 if (count)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3392 count--;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3393 else if (p > password_buffer)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3394 p--;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3395 continue;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3396 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3397
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3398 /* Ignore DOS extended characters */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3399 if ((c & 0xff) != c)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3400 continue;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3401
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3402 /* Add to password if it isn't full */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3403 if (p < password_buffer + max_length - 1)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3404 *p++ = c;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3405 else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3406 count++;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3407 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3408 *p = '\0';
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3409
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3410 fputc('\n', stderr);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3411
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3412 return password_buffer;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3413 #else
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3414 return( (char *) getpass(prompt) );
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3415 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3416 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3417
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3418 #ifdef SIGTSTP
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3419
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3420 /*
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3421 * handle stop and start signals
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3422 */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3423
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3424 /*UNUSED*/
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3425 void
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3426 tstp(a)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3427 int a;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3428 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3429 mvcur(0, cols - 1, lines - 1, 0);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3430 fflush(stdout);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3431 kill(0, SIGTSTP);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3432 signal(SIGTSTP, tstp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3433 crmode();
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3434 noecho();
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3435 clearok(curscr, TRUE);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3436 touchwin(cw);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3437 draw(cw);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3438 flushinp();
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3439 }
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3440 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3441
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3442 int
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3443 md_setup()
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3444 {
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3445 #ifdef SIGTSTP
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3446 signal(SIGTSTP, tstp);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3447 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3448 #ifdef SIGHUP
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3449 signal(SIGHUP, auto_save);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3450 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3451 signal(SIGTERM, auto_save);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3452 signal(SIGINT, quit);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3453 #ifdef SIGQUIT
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3454 signal(SIGQUIT, endit);
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3455 #endif
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3456 #if defined(__CYGWIN__) || defined(__MSYS__)
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3457 ESCDELAY = 250;
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3458 #endif
141
cc5148bdf345 xrogue: call nonl() during initialization.
John "Elwin" Edwards
parents: 135
diff changeset
3459 nonl();
133
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3460 crmode(); /* Cbreak mode */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3461 noecho(); /* Echo off */
e6179860cb76 Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3462 }
143
7faf4568c295 Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents: 141
diff changeset
3463
7faf4568c295 Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents: 141
diff changeset
3464 int
7faf4568c295 Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents: 141
diff changeset
3465 md_normaluser(void)
7faf4568c295 Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents: 141
diff changeset
3466 {
7faf4568c295 Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents: 141
diff changeset
3467 #ifndef _WIN32
7faf4568c295 Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents: 141
diff changeset
3468 setuid(getuid());
7faf4568c295 Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents: 141
diff changeset
3469 setgid(getgid());
7faf4568c295 Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents: 141
diff changeset
3470 #endif
7faf4568c295 Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents: 141
diff changeset
3471 }