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