]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/save.c
2 * Copyright (c) 1983 Regents of the University of California.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 /*static char sccsid[] = "from: @(#)save.c 5.3 (Berkeley) 6/1/90";*/
36 static char rcsid
[] = "$Id: save.c,v 1.2 1993/08/01 18:55:52 mycroft Exp $";
50 home
= getenv("HOME");
52 strcat(home1
, "/Bstar");
53 if ((fp
= fopen(home1
, "r")) == 0) {
57 fread(&WEIGHT
, sizeof WEIGHT
, 1, fp
);
58 fread(&CUMBER
, sizeof CUMBER
, 1, fp
);
59 fread(&clock
, sizeof clock
, 1, fp
);
60 fread(&tmp
, sizeof tmp
, 1, fp
);
61 location
= tmp
? dayfile
: nightfile
;
62 for (n
= 1; n
<= NUMOFROOMS
; n
++) {
63 fread(location
[n
].link
, sizeof location
[n
].link
, 1, fp
);
64 fread(location
[n
].objects
, sizeof location
[n
].objects
, 1, fp
);
66 fread(inven
, sizeof inven
, 1, fp
);
67 fread(wear
, sizeof wear
, 1, fp
);
68 fread(injuries
, sizeof injuries
, 1, fp
);
69 fread(notes
, sizeof notes
, 1, fp
);
70 fread(&direction
, sizeof direction
, 1, fp
);
71 fread(&position
, sizeof position
, 1, fp
);
72 fread(&time
, sizeof time
, 1, fp
);
73 fread(&fuel
, sizeof fuel
, 1, fp
);
74 fread(&torps
, sizeof torps
, 1, fp
);
75 fread(&carrying
, sizeof carrying
, 1, fp
);
76 fread(&encumber
, sizeof encumber
, 1, fp
);
77 fread(&rythmn
, sizeof rythmn
, 1, fp
);
78 fread(&followfight
, sizeof followfight
, 1, fp
);
79 fread(&ate
, sizeof ate
, 1, fp
);
80 fread(&snooze
, sizeof snooze
, 1, fp
);
81 fread(&meetgirl
, sizeof meetgirl
, 1, fp
);
82 fread(&followgod
, sizeof followgod
, 1, fp
);
83 fread(&godready
, sizeof godready
, 1, fp
);
84 fread(&win
, sizeof win
, 1, fp
);
85 fread(&wintime
, sizeof wintime
, 1, fp
);
86 fread(&matchlight
, sizeof matchlight
, 1, fp
);
87 fread(&matchcount
, sizeof matchcount
, 1, fp
);
88 fread(&loved
, sizeof loved
, 1, fp
);
89 fread(&pleasure
, sizeof pleasure
, 1, fp
);
90 fread(&power
, sizeof power
, 1, fp
);
91 fread(&ego
, sizeof ego
, 1, fp
);
103 home
= getenv("HOME");
105 strcat(home1
, "/Bstar");
106 if ((fp
= fopen(home1
, "w")) == 0) {
110 printf("Saved in %s.\n", home1
);
111 fwrite(&WEIGHT
, sizeof WEIGHT
, 1, fp
);
112 fwrite(&CUMBER
, sizeof CUMBER
, 1, fp
);
113 fwrite(&clock
, sizeof clock
, 1, fp
);
114 tmp
= location
== dayfile
;
115 fwrite(&tmp
, sizeof tmp
, 1, fp
);
116 for (n
= 1; n
<= NUMOFROOMS
; n
++) {
117 fwrite(location
[n
].link
, sizeof location
[n
].link
, 1, fp
);
118 fwrite(location
[n
].objects
, sizeof location
[n
].objects
, 1, fp
);
120 fwrite(inven
, sizeof inven
, 1, fp
);
121 fwrite(wear
, sizeof wear
, 1, fp
);
122 fwrite(injuries
, sizeof injuries
, 1, fp
);
123 fwrite(notes
, sizeof notes
, 1, fp
);
124 fwrite(&direction
, sizeof direction
, 1, fp
);
125 fwrite(&position
, sizeof position
, 1, fp
);
126 fwrite(&time
, sizeof time
, 1, fp
);
127 fwrite(&fuel
, sizeof fuel
, 1, fp
);
128 fwrite(&torps
, sizeof torps
, 1, fp
);
129 fwrite(&carrying
, sizeof carrying
, 1, fp
);
130 fwrite(&encumber
, sizeof encumber
, 1, fp
);
131 fwrite(&rythmn
, sizeof rythmn
, 1, fp
);
132 fwrite(&followfight
, sizeof followfight
, 1, fp
);
133 fwrite(&ate
, sizeof ate
, 1, fp
);
134 fwrite(&snooze
, sizeof snooze
, 1, fp
);
135 fwrite(&meetgirl
, sizeof meetgirl
, 1, fp
);
136 fwrite(&followgod
, sizeof followgod
, 1, fp
);
137 fwrite(&godready
, sizeof godready
, 1, fp
);
138 fwrite(&win
, sizeof win
, 1, fp
);
139 fwrite(&wintime
, sizeof wintime
, 1, fp
);
140 fwrite(&matchlight
, sizeof matchlight
, 1, fp
);
141 fwrite(&matchcount
, sizeof matchcount
, 1, fp
);
142 fwrite(&loved
, sizeof loved
, 1, fp
);
143 fwrite(&pleasure
, sizeof pleasure
, 1, fp
);
144 fwrite(&power
, sizeof power
, 1, fp
);
145 fwrite(&ego
, sizeof ego
, 1, fp
);