|
|
1.1 root 1: /*
2: * Copyright (c) 1983 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: static char sccsid[] = "@(#)save.c 5.2 (Berkeley) 6/19/88";
20: #endif /* not lint */
21:
22: #include "externs.h"
23:
24: restore()
25: {
26: char *getenv();
27: char *home;
28: char home1[100];
29: register int n;
30: int tmp;
31: register FILE *fp;
32:
33: home = getenv("HOME");
34: strcpy(home1, home);
35: strcat(home1, "/Bstar");
36: if ((fp = fopen(home1, "r")) == 0) {
37: perror(home1);
38: return;
39: }
40: fread(&WEIGHT, sizeof WEIGHT, 1, fp);
41: fread(&CUMBER, sizeof CUMBER, 1, fp);
42: fread(&clock, sizeof clock, 1, fp);
43: fread(&tmp, sizeof tmp, 1, fp);
44: location = tmp ? dayfile : nightfile;
45: for (n = 1; n <= NUMOFROOMS; n++) {
46: fread(location[n].link, sizeof location[n].link, 1, fp);
47: fread(location[n].objects, sizeof location[n].objects, 1, fp);
48: }
49: fread(inven, sizeof inven, 1, fp);
50: fread(wear, sizeof wear, 1, fp);
51: fread(injuries, sizeof injuries, 1, fp);
52: fread(notes, sizeof notes, 1, fp);
53: fread(&direction, sizeof direction, 1, fp);
54: fread(&position, sizeof position, 1, fp);
55: fread(&time, sizeof time, 1, fp);
56: fread(&fuel, sizeof fuel, 1, fp);
57: fread(&torps, sizeof torps, 1, fp);
58: fread(&carrying, sizeof carrying, 1, fp);
59: fread(&encumber, sizeof encumber, 1, fp);
60: fread(&rythmn, sizeof rythmn, 1, fp);
61: fread(&followfight, sizeof followfight, 1, fp);
62: fread(&ate, sizeof ate, 1, fp);
63: fread(&snooze, sizeof snooze, 1, fp);
64: fread(&meetgirl, sizeof meetgirl, 1, fp);
65: fread(&followgod, sizeof followgod, 1, fp);
66: fread(&godready, sizeof godready, 1, fp);
67: fread(&win, sizeof win, 1, fp);
68: fread(&wintime, sizeof wintime, 1, fp);
69: fread(&matchlight, sizeof matchlight, 1, fp);
70: fread(&matchcount, sizeof matchcount, 1, fp);
71: fread(&loved, sizeof loved, 1, fp);
72: fread(&pleasure, sizeof pleasure, 1, fp);
73: fread(&power, sizeof power, 1, fp);
74: fread(&ego, sizeof ego, 1, fp);
75: }
76:
77: save()
78: {
79: char *getenv();
80: char *home;
81: char home1[100];
82: register int n;
83: int tmp;
84: FILE *fp;
85:
86: home = getenv("HOME");
87: strcpy(home1, home);
88: strcat(home1, "/Bstar");
89: if ((fp = fopen(home1, "w")) == 0) {
90: perror(home1);
91: return;
92: }
93: printf("Saved in %s.\n", home1);
94: fwrite(&WEIGHT, sizeof WEIGHT, 1, fp);
95: fwrite(&CUMBER, sizeof CUMBER, 1, fp);
96: fwrite(&clock, sizeof clock, 1, fp);
97: tmp = location == dayfile;
98: fwrite(&tmp, sizeof tmp, 1, fp);
99: for (n = 1; n <= NUMOFROOMS; n++) {
100: fwrite(location[n].link, sizeof location[n].link, 1, fp);
101: fwrite(location[n].objects, sizeof location[n].objects, 1, fp);
102: }
103: fwrite(inven, sizeof inven, 1, fp);
104: fwrite(wear, sizeof wear, 1, fp);
105: fwrite(injuries, sizeof injuries, 1, fp);
106: fwrite(notes, sizeof notes, 1, fp);
107: fwrite(&direction, sizeof direction, 1, fp);
108: fwrite(&position, sizeof position, 1, fp);
109: fwrite(&time, sizeof time, 1, fp);
110: fwrite(&fuel, sizeof fuel, 1, fp);
111: fwrite(&torps, sizeof torps, 1, fp);
112: fwrite(&carrying, sizeof carrying, 1, fp);
113: fwrite(&encumber, sizeof encumber, 1, fp);
114: fwrite(&rythmn, sizeof rythmn, 1, fp);
115: fwrite(&followfight, sizeof followfight, 1, fp);
116: fwrite(&ate, sizeof ate, 1, fp);
117: fwrite(&snooze, sizeof snooze, 1, fp);
118: fwrite(&meetgirl, sizeof meetgirl, 1, fp);
119: fwrite(&followgod, sizeof followgod, 1, fp);
120: fwrite(&godready, sizeof godready, 1, fp);
121: fwrite(&win, sizeof win, 1, fp);
122: fwrite(&wintime, sizeof wintime, 1, fp);
123: fwrite(&matchlight, sizeof matchlight, 1, fp);
124: fwrite(&matchcount, sizeof matchcount, 1, fp);
125: fwrite(&loved, sizeof loved, 1, fp);
126: fwrite(&pleasure, sizeof pleasure, 1, fp);
127: fwrite(&power, sizeof power, 1, fp);
128: fwrite(&ego, sizeof ego, 1, fp);
129: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.