summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2b481ae)
raw | patch | inline | side by side (parent: 2b481ae)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 21 Apr 2020 11:09:08 +0000 (15:09 +0400) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 21 Apr 2020 11:09:08 +0000 (15:09 +0400) |
25 files changed:
src/dots.c | patch | blob | history | |
src/dots.h | patch | blob | history | |
src/files.c | patch | blob | history | |
src/files.h | patch | blob | history | |
src/fx.c | patch | blob | history | |
src/fx.h | patch | blob | history | |
src/game.c | patch | blob | history | |
src/game.h | patch | blob | history | |
src/items.c | patch | blob | history | |
src/items.h | patch | blob | history | |
src/menu.c | patch | blob | history | |
src/monster.c | patch | blob | history | |
src/monster.h | patch | blob | history | |
src/player.c | patch | blob | history | |
src/player.h | patch | blob | history | |
src/save.c | [new file with mode: 0644] | patch | blob |
src/save.h | [new file with mode: 0644] | patch | blob |
src/smoke.c | patch | blob | history | |
src/smoke.h | patch | blob | history | |
src/switch.c | patch | blob | history | |
src/switch.h | patch | blob | history | |
src/view.c | patch | blob | history | |
src/view.h | patch | blob | history | |
src/weapons.c | patch | blob | history | |
src/weapons.h | patch | blob | history |
diff --git a/src/dots.c b/src/dots.c
index b9ca8ec7104913b821402546238821ead00226a9..cd89a2bc7c40cdc2ae869b6c143e79c2e5b71879 100644 (file)
--- a/src/dots.c
+++ b/src/dots.c
static int bl_r,sp_r,sr_r,sxr[MAXSR],syr[MAXSR];
static int ldot;
-void DOT_savegame (FILE *h) {
- int i, n;
- for (i = n = 0; i < MAXDOT; ++i) {
- if (dot[i].t) {
- ++n;
- }
- }
- myfwrite32(n, h);
- for (i = 0; i < MAXDOT; ++i) {
- if (dot[i].t) {
- myfwrite32(dot[i].o.x, h);
- myfwrite32(dot[i].o.y, h);
- myfwrite32(dot[i].o.xv, h);
- myfwrite32(dot[i].o.yv, h);
- myfwrite32(dot[i].o.vx, h);
- myfwrite32(dot[i].o.vy, h);
- myfwrite32(dot[i].o.r, h);
- myfwrite32(dot[i].o.h, h);
- myfwrite8(dot[i].c, h);
- myfwrite8(dot[i].t, h);
- }
- }
-}
-
-void DOT_loadgame (FILE *h) {
- int i, n;
- n = myfread32(h);
- for (i = 0; i < n; i++) {
- dot[i].o.x = myfread32(h);
- dot[i].o.y = myfread32(h);
- dot[i].o.xv = myfread32(h);
- dot[i].o.yv = myfread32(h);
- dot[i].o.vx = myfread32(h);
- dot[i].o.vy = myfread32(h);
- dot[i].o.r = myfread32(h);
- dot[i].o.h = myfread32(h);
- dot[i].c = myfread8(h);
- dot[i].t = myfread8(h);
- }
-}
-
void DOT_init(void) {
int i;
diff --git a/src/dots.h b/src/dots.h
index c3a930aa1529840656def5f12405e6f7e2663d90..ae40ce5afd87ae47d1bff3a56cd89fe8069b4d5e 100644 (file)
--- a/src/dots.h
+++ b/src/dots.h
#include "glob.h"
#include "view.h" // obj_t
-#include <stdio.h> // FILE
#define MAXDOT 400
extern dot_t dot[MAXDOT];
-void DOT_savegame (FILE *h);
-void DOT_loadgame (FILE *h);
void DOT_init (void);
void DOT_alloc (void);
void DOT_act (void);
diff --git a/src/files.c b/src/files.c
index dc897ed23cb0fd1daa2c2fd96dc19cc890dc0c3c..47aaa71eb1a65a2b2997471566b3fa3795f5456d 100644 (file)
--- a/src/files.c
+++ b/src/files.c
} dmv;
int d_start, d_end;
-byte savname[7][24];
-byte savok[7];
mwad_t wad[MAX_WAD];
map_block_t blk;
memset(wads,0,sizeof(wads));
}
-static char *getsavfpname (int n, int ro) {
- static char fn[]="savgame0.dat";
- fn[7]=n+'0';
-#ifndef WIN32
- static char p[100];
- char *e = getenv("HOME");
- strncpy(p,e,60);
- strcat(p,"/.doom2d-rembo");
- if (!ro) mkdir(p, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
- strcat(p,"/");
- strcat(p,fn);
-#else
- strcpy(p,fn);
-#endif
- return p;
-}
-
-void F_getsavnames (void) {
- int i;
- FILE *h;
- short ver;
- char *p;
- for (i = 0; i < 7; ++i) {
- p = getsavfpname(i, 1);
- memset(savname[i], 0, 24);
- savok[i] = 0;
- h = fopen(p, "rb");
- if (h != NULL) {
- ver = -1;
- myfread(savname[i], 24, 1, h);
- ver = myfread16(h);
- savname[i][23] = 0;
- savok[i] = (ver == 3) ? 1 : 0;
- fclose(h);
- }
- }
-}
-
-void F_savegame (int n, char *s) {
- char *p = getsavfpname(n, 0);
- FILE *h = fopen(p, "wb");
- if (h != NULL) {
- myfwrite(s, 24, 1, h); // slot name
- myfwrite16(3, h); // version
- G_savegame(h);
- W_savegame(h);
- DOT_savegame(h);
- SMK_savegame(h);
- FX_savegame(h);
- IT_savegame(h);
- MN_savegame(h);
- PL_savegame(h);
- SW_savegame(h);
- WP_savegame(h);
- fclose(h);
- }
-}
-
-void F_loadgame (int n) {
- short ver;
- char *p = getsavfpname(n, 1);
- FILE *h = fopen(p, "rb");
- if (h != NULL) {
- fseek(h, 24, SEEK_SET); // skip name
- ver = myfread16(h); // version
- if (ver == 3) {
- G_loadgame(h);
- W_loadgame(h);
- DOT_loadgame(h);
- SMK_loadgame(h);
- FX_loadgame(h);
- IT_loadgame(h);
- MN_loadgame(h);
- PL_loadgame(h);
- SW_loadgame(h);
- WP_loadgame(h);
- }
- fclose(h);
- }
-}
-
void F_addwad (const char *fn) {
int i;
diff --git a/src/files.h b/src/files.h
index 01f2087968a1862f9cad1642a4d4faf00c98bf83..ee1b8bb67e4e979b758b62eb4a0f0783ab073aca 100644 (file)
--- a/src/files.h
+++ b/src/files.h
} mwad_t;
extern int d_start, d_end;
-extern byte savname[7][24];
-extern byte savok[7];
extern mwad_t wad[MAX_WAD];
extern map_block_t blk;
void F_startup (void);
-void F_getsavnames (void);
-void F_savegame (int n, char *s);
-void F_loadgame (int n);
void F_addwad (const char *fn);
void F_initwads (void);
void F_allocres (void);
diff --git a/src/fx.c b/src/fx.c
index cea21f88d93bef50d403041e64db6865819f00e1..252eb8ae61b14e46cf454b50a98fbc03471f182b 100644 (file)
--- a/src/fx.c
+++ b/src/fx.c
}
}
-void FX_savegame (FILE *h) {
- int i, n;
- for (i = n = 0; i < MAXFX; ++i) {
- if (fx[i].t) {
- ++n;
- }
- }
- myfwrite32(n, h);
- for (i = 0; i < MAXFX; ++i) {
- if (fx[i].t) {
- myfwrite32(fx[i].x, h);
- myfwrite32(fx[i].y, h);
- myfwrite32(fx[i].xv, h);
- myfwrite32(fx[i].yv, h);
- myfwrite8(fx[i].t, h);
- myfwrite8(fx[i].s, h);
- }
- }
-}
-
-void FX_loadgame (FILE *h) {
- int i, n;
- n = myfread32(h);
- for (i = 0; i < n; i++) {
- fx[i].x = myfread32(h);
- fx[i].y = myfread32(h);
- fx[i].xv = myfread32(h);
- fx[i].yv = myfread32(h);
- fx[i].t = myfread8(h);
- fx[i].s = myfread8(h);
- }
-}
-
void FX_alloc (void) {
bsnd[0]=Z_getsnd("BUBL1");
bsnd[1]=Z_getsnd("BUBL2");
diff --git a/src/fx.h b/src/fx.h
index 2ec7ff468a0ad15a93341f03dba25063b093980b..f86ca9de2f8040e34fbfa474aaf4f18ba66bf97a 100644 (file)
--- a/src/fx.h
+++ b/src/fx.h
#ifndef FX_H_INLUDED
#define FX_H_INLUDED
-#include <stdio.h> // FILE
-
#define MAXFX 300
typedef struct {
extern fx_t fx[MAXFX];
-void FX_savegame (FILE *h);
-void FX_loadgame (FILE *h);
void FX_alloc (void);
void FX_init (void);
void FX_act (void);
diff --git a/src/game.c b/src/game.c
index eba57b827eb251a2447bf4872c6c8b22a2113c1e..3ba9f4118e6b3f98ea54492830bf21bba3760faf 100644 (file)
--- a/src/game.c
+++ b/src/game.c
#include "error.h"
#include "input.h"
+#include "save.h"
#define LT_DELAY 8
#define LT_HITTIME 6
g_trans=1;g_transt=0;
}
-void G_savegame (FILE* h) {
- myfwrite8(_2pl, h);
- myfwrite8(g_dm, h);
- myfwrite8(g_exit, h);
- myfwrite8(g_map, h);
- myfwrite32(g_time, h);
- myfwrite32(dm_pl1p, h);
- myfwrite32(dm_pl2p, h);
- myfwrite32(dm_pnum, h);
- int i = 0;
- while (i < dm_pnum) {
- myfwrite32(dm_pos[i].x, h);
- myfwrite32(dm_pos[i].y, h);
- myfwrite8(dm_pos[i].d, h);
- i += 1;
- }
- myfwrite8(cheat, h);
- myfwrite(g_music, 8, 1, h);
-}
-
-void G_loadgame (FILE* h) {
- _2pl = myfread8(h);
- g_dm = myfread8(h);
- g_exit = myfread8(h);
- g_map = myfread8(h);
- g_time = myfread32(h);
- dm_pl1p = myfread32(h);
- dm_pl2p = myfread32(h);
- dm_pnum = myfread32(h);
- int i = 0;
- while (i < dm_pnum) {
- dm_pos[i].x = myfread32(h);
- dm_pos[i].y = myfread32(h);
- dm_pos[i].d = myfread8(h);
- i += 1;
- }
- cheat = myfread8(h);
- myfread(g_music, 8, 1, h);
- F_loadmus(g_music);
-}
-
int G_load (FILE *h) {
switch (blk.t) {
case MB_MUSIC:
diff --git a/src/game.h b/src/game.h
index 03aff95032fd3bea718a57dc2cef0b16a2b3281b..f4f1a7033caff5a5c9e31bebb5805132f1b2fe04 100644 (file)
--- a/src/game.h
+++ b/src/game.h
extern int g_trans;
-void G_savegame (FILE* h);
-void G_loadgame (FILE* h);
int G_load (FILE *h);
void load_game (int n);
void G_start (void);
diff --git a/src/items.c b/src/items.c
index b0f079a715fef9fcd7bb9f2375bfa63d4cb5ccbe..65f39e2bb5f5437a02ff017ead6f102bc9003776 100644 (file)
--- a/src/items.c
+++ b/src/items.c
int itm_rtime = 1092;
-void IT_savegame (FILE *h) {
- int i, n;
- for (n = MAXITEM - 1; n >= 0 && it[n].t == 0; n--) {
- // empty
- }
- n += 1;
- myfwrite32(n, h);
- for (i = 0; i < n; i++) {
- myfwrite32(it[i].o.x, h);
- myfwrite32(it[i].o.y, h);
- myfwrite32(it[i].o.xv, h);
- myfwrite32(it[i].o.yv, h);
- myfwrite32(it[i].o.vx, h);
- myfwrite32(it[i].o.vy, h);
- myfwrite32(it[i].o.r, h);
- myfwrite32(it[i].o.h, h);
- myfwrite32(it[i].t, h);
- myfwrite32(it[i].s, h);
- }
- myfwrite32(itm_rtime, h);
-}
-
-void IT_loadgame (FILE *h) {
- int i, n;
- n = myfread32(h);
- for (i = 0; i < n; i++) {
- it[i].o.x = myfread32(h);
- it[i].o.y = myfread32(h);
- it[i].o.xv = myfread32(h);
- it[i].o.yv = myfread32(h);
- it[i].o.vx = myfread32(h);
- it[i].o.vy = myfread32(h);
- it[i].o.r = myfread32(h);
- it[i].o.h = myfread32(h);
- it[i].t = myfread32(h);
- it[i].s = myfread32(h);
- }
- itm_rtime = myfread32(h);
-}
-
void IT_alloc (void) {
int i, j, n;
static char nm[][6] = {
diff --git a/src/items.h b/src/items.h
index c2be467f83556b6fe20478c32424c37a2bf2075d..011188ad0db51662efb6cfecf88157ff6b2a9228 100644 (file)
--- a/src/items.h
+++ b/src/items.h
#define ITEMS_H_INCLUDED
#include "view.h" // obj_t
-#include <stdio.h> // FILE
#define MAXITEM 300
extern item_t it[MAXITEM];
extern int itm_rtime;
-void IT_savegame (FILE *h);
-void IT_loadgame (FILE *h);
void IT_alloc (void);
void IT_init (void);
int IT_load (FILE *h);
diff --git a/src/menu.c b/src/menu.c
index 4a15ede8a4cce10306f652f8ed3a719d32ca08c7..4205285ea1f5436574805f05ad61325c19694784 100644 (file)
--- a/src/menu.c
+++ b/src/menu.c
#include "input.h"
#include "system.h"
+#include "save.h"
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
diff --git a/src/monster.c b/src/monster.c
index e895a3827709675ab06c0b93361e1d26f4a89222..3a5efd44a165ff0d6f9c6c59f2ee1f9c8dd571cf 100644 (file)
--- a/src/monster.c
+++ b/src/monster.c
int hit_xv, hit_yv;
mn_t mn[MAXMN];
+int mnum, gsndt;
static void *fsnd,*pauksnd,*trupsnd;
static void *snd[MN_TN][5],*impsitsnd[2],*impdthsnd[2],*firsnd,*slopsnd,*gsnd[4];
static void *swgsnd,*pchsnd,*telesnd;
static void *positsnd[3],*podthsnd[3];
-static int mnum,gsndt;
static mnsz_t mnsz[MN_TN+1]={
//rad ht life pain rv jv slop min_pn
0, 0, 0, 0, 0, 0, 0, 0, // none
8, 26, 400, 70, 8,10, 30, 50 // man
};
-static void setst(int i,int st) {
+void setst (int i, int st) {
char *a;
int t;
mn[i].ap=a;
}
-void MN_savegame (FILE *h) {
- int i, n;
- for (n = MAXMN - 1; n >= 0 && mn[n].t == 0; n--) {
- // empty
- }
- n += 1;
- myfwrite32(n, h);
- for (i = 0; i < n; i++) {
- myfwrite32(mn[i].o.x, h);
- myfwrite32(mn[i].o.y, h);
- myfwrite32(mn[i].o.xv, h);
- myfwrite32(mn[i].o.yv, h);
- myfwrite32(mn[i].o.vx, h);
- myfwrite32(mn[i].o.vy, h);
- myfwrite32(mn[i].o.r, h);
- myfwrite32(mn[i].o.h, h);
- myfwrite8(mn[i].t, h);
- myfwrite8(mn[i].d, h);
- myfwrite8(mn[i].st, h);
- myfwrite8(mn[i].ftime, h);
- myfwrite32(mn[i].fobj, h);
- myfwrite32(mn[i].s, h);
- myfwrite32(0, h); // mn[i].ap useless, changed after load
- myfwrite32(mn[i].aim, h);
- myfwrite32(mn[i].life, h);
- myfwrite32(mn[i].pain, h);
- myfwrite32(mn[i].ac, h);
- myfwrite32(mn[i].tx, h);
- myfwrite32(mn[i].ty, h);
- myfwrite32(mn[i].ammo, h);
- myfwrite16(mn[i].atm, h);
- }
- myfwrite32(mnum, h);
- myfwrite32(gsndt, h);
-}
-
-void MN_loadgame (FILE *h) {
- int i, n, c;
- n = myfread32(h);
- for (i = 0; i < n; i++) {
- mn[i].o.x = myfread32(h);
- mn[i].o.y = myfread32(h);
- mn[i].o.xv = myfread32(h);
- mn[i].o.yv = myfread32(h);
- mn[i].o.vx = myfread32(h);
- mn[i].o.vy = myfread32(h);
- mn[i].o.r = myfread32(h);
- mn[i].o.h = myfread32(h);
- mn[i].t = myfread8(h);
- mn[i].d = myfread8(h);
- mn[i].st = myfread8(h);
- mn[i].ftime = myfread8(h);
- mn[i].fobj = myfread32(h);
- mn[i].s = myfread32(h);
- mn[i].ap = NULL; myfread32(h); // useless, changed after loading
- mn[i].aim = myfread32(h);
- mn[i].life = myfread32(h);
- mn[i].pain = myfread32(h);
- mn[i].ac = myfread32(h);
- mn[i].tx = myfread32(h);
- mn[i].ty = myfread32(h);
- mn[i].ammo = myfread32(h);
- mn[i].atm = myfread16(h);
- }
- mnum = myfread32(h);
- gsndt = myfread32(h);
- for (n = 0; n < MAXMN; ++n) {
- if (mn[n].t) {
- c = mn[n].ac;
- setst(n, mn[n].st);
- mn[n].ac = c;
- }
- }
-}
-
#define GGAS_TOTAL (MN__LAST-MN_DEMON+16+10)
void MN_alloc (void) {
diff --git a/src/monster.h b/src/monster.h
index 022962f9bf042c9ed6cf411a4028e0a68904745a..30edf1dfd8a4b91e22f6ed337751f3be585b8915 100644 (file)
--- a/src/monster.h
+++ b/src/monster.h
extern byte nomon;
extern int hit_xv, hit_yv;
extern mn_t mn[MAXMN];
+extern int mnum, gsndt;
+
+void setst (int i, int st);
-void MN_savegame (FILE *h);
-void MN_loadgame (FILE *h);
void MN_alloc (void);
void MN_init (void);
int MN_spawn (int x, int y, byte d, int t);
diff --git a/src/player.c b/src/player.c
index 2d781a33716c1c36f7fb29154749b485fb3698bd..79a5a98968cbd0b2009b80dab942b99362dd2403 100644 (file)
--- a/src/player.c
+++ b/src/player.c
byte plr_dieanim[]="HHHHIIIIJJJJKKKKLLLLMMMM";
byte plr_slopanim[]="OOPPQQRRSSTTUUVVWW";
-static void PL_save_player (player_t *p, FILE *h) {
- myfwrite32(p->o.x, h);
- myfwrite32(p->o.y, h);
- myfwrite32(p->o.xv, h);
- myfwrite32(p->o.yv, h);
- myfwrite32(p->o.vx, h);
- myfwrite32(p->o.vy, h);
- myfwrite32(p->o.r, h);
- myfwrite32(p->o.h, h);
- myfwrite32(p->looky, h);
- myfwrite32(p->st, h);
- myfwrite32(p->s, h);
- myfwrite32(p->life, h);
- myfwrite32(p->armor, h);
- myfwrite32(p->hit, h);
- myfwrite32(p->hito, h);
- myfwrite32(p->pain, h);
- myfwrite32(p->air, h);
- myfwrite32(p->invl, h);
- myfwrite32(p->suit, h);
- myfwrite8(p->d, h);
- myfwrite32(p->frag, h);
- myfwrite32(p->ammo, h);
- myfwrite32(p->shel, h);
- myfwrite32(p->rock, h);
- myfwrite32(p->cell, h);
- myfwrite32(p->fuel, h);
- myfwrite32(p->kills, h);
- myfwrite32(p->secrets, h);
- myfwrite8(p->fire, h);
- myfwrite8(p->cwpn, h);
- myfwrite8(p->csnd, h);
- myfwrite8(p->amul, h);
- myfwrite16(p->wpns, h);
- myfwrite8(p->wpn, h);
- myfwrite8(p->f, h);
- myfwrite8(p->drawst, h);
- myfwrite8(p->color, h);
- myfwrite32(p->id, h);
- myfwrite8(p->keys, h);
- myfwrite8(p->lives, h);
- // k* not saved
-}
-
-void PL_savegame (FILE *h) {
- PL_save_player(&pl1, h);
- if (_2pl) {
- PL_save_player(&pl2, h);
- }
- myfwrite32(PL_JUMP, h);
- myfwrite32(PL_RUN, h);
- myfwrite8(p_immortal, h);
-}
-
-static void PL_load_player (player_t *p, FILE *h) {
- p->o.x = myfread32(h);
- p->o.y = myfread32(h);
- p->o.xv = myfread32(h);
- p->o.yv = myfread32(h);
- p->o.vx = myfread32(h);
- p->o.vy = myfread32(h);
- p->o.r = myfread32(h);
- p->o.h = myfread32(h);
- p->looky = myfread32(h);
- p->st = myfread32(h);
- p->s = myfread32(h);
- p->life = myfread32(h);
- p->armor = myfread32(h);
- p->hit = myfread32(h);
- p->hito = myfread32(h);
- p->pain = myfread32(h);
- p->air = myfread32(h);
- p->invl = myfread32(h);
- p->suit = myfread32(h);
- p->d = myfread8(h);
- p->frag = myfread32(h);
- p->ammo = myfread32(h);
- p->shel = myfread32(h);
- p->rock = myfread32(h);
- p->cell = myfread32(h);
- p->fuel = myfread32(h);
- p->kills = myfread32(h);
- p->secrets = myfread32(h);
- p->fire = myfread8(h);
- p->cwpn = myfread8(h);
- p->csnd = myfread8(h);
- p->amul = myfread8(h);
- p->wpns = myfread16(h);
- p->wpn = myfread8(h);
- p->f = myfread8(h);
- p->drawst = myfread8(h);
- p->color = myfread8(h);
- p->id = myfread32(h);
- p->keys = myfread8(h);
- p->lives = myfread8(h);
- // k* not saved
-}
-
-void PL_loadgame (FILE *h) {
- PL_load_player(&pl1, h);
- if (_2pl) {
- PL_load_player(&pl2, h);
- }
- PL_JUMP = myfread32(h);
- PL_RUN = myfread32(h);
- p_immortal = myfread8(h);
-}
-
static int nonz (int a) {
return a ? a : 1;
}
diff --git a/src/player.h b/src/player.h
index 48c49abd25f7d7b88b53e79b34f9488f8419e6b2..056397a50399f491d081b5b959e40bee7bce9989 100644 (file)
--- a/src/player.h
+++ b/src/player.h
#include "glob.h"
#include "view.h" // obj_t
-#include <stdio.h> // FILE
#define PL_DRAWLIFE 1
#define PL_DRAWARMOR 2
extern byte plr_dieanim[];
extern byte plr_slopanim[];
-void PL_savegame (FILE *h);
-void PL_loadgame (FILE *h);
int PL_isdead (player_t *p);
void PL_init (void);
void PL_alloc (void);
diff --git a/src/save.c b/src/save.c
--- /dev/null
+++ b/src/save.c
@@ -0,0 +1,603 @@
+#include "save.h"
+
+#include "dots.h"
+#include "fx.h"
+#include "game.h"
+#include "items.h"
+#include "monster.h"
+#include "player.h"
+#include "smoke.h"
+#include "switch.h"
+#include "view.h"
+#include "weapons.h"
+
+#include "render.h"
+#include "music.h"
+
+#include <stdio.h> // FILE
+#include <string.h>
+#include <sys/stat.h>
+#include "files.h"
+#include "my.h"
+
+char savname[SAVE_MAX][SAVE_MAXLEN];
+char savok[SAVE_MAX];
+
+static void DOT_savegame (FILE *h) {
+ int i, n;
+ for (i = n = 0; i < MAXDOT; ++i) {
+ if (dot[i].t) {
+ ++n;
+ }
+ }
+ myfwrite32(n, h);
+ for (i = 0; i < MAXDOT; ++i) {
+ if (dot[i].t) {
+ myfwrite32(dot[i].o.x, h);
+ myfwrite32(dot[i].o.y, h);
+ myfwrite32(dot[i].o.xv, h);
+ myfwrite32(dot[i].o.yv, h);
+ myfwrite32(dot[i].o.vx, h);
+ myfwrite32(dot[i].o.vy, h);
+ myfwrite32(dot[i].o.r, h);
+ myfwrite32(dot[i].o.h, h);
+ myfwrite8(dot[i].c, h);
+ myfwrite8(dot[i].t, h);
+ }
+ }
+}
+
+static void DOT_loadgame (FILE *h) {
+ int i, n;
+ n = myfread32(h);
+ for (i = 0; i < n; i++) {
+ dot[i].o.x = myfread32(h);
+ dot[i].o.y = myfread32(h);
+ dot[i].o.xv = myfread32(h);
+ dot[i].o.yv = myfread32(h);
+ dot[i].o.vx = myfread32(h);
+ dot[i].o.vy = myfread32(h);
+ dot[i].o.r = myfread32(h);
+ dot[i].o.h = myfread32(h);
+ dot[i].c = myfread8(h);
+ dot[i].t = myfread8(h);
+ }
+}
+
+static void FX_savegame (FILE *h) {
+ int i, n;
+ for (i = n = 0; i < MAXFX; ++i) {
+ if (fx[i].t) {
+ ++n;
+ }
+ }
+ myfwrite32(n, h);
+ for (i = 0; i < MAXFX; ++i) {
+ if (fx[i].t) {
+ myfwrite32(fx[i].x, h);
+ myfwrite32(fx[i].y, h);
+ myfwrite32(fx[i].xv, h);
+ myfwrite32(fx[i].yv, h);
+ myfwrite8(fx[i].t, h);
+ myfwrite8(fx[i].s, h);
+ }
+ }
+}
+
+static void FX_loadgame (FILE *h) {
+ int i, n;
+ n = myfread32(h);
+ for (i = 0; i < n; i++) {
+ fx[i].x = myfread32(h);
+ fx[i].y = myfread32(h);
+ fx[i].xv = myfread32(h);
+ fx[i].yv = myfread32(h);
+ fx[i].t = myfread8(h);
+ fx[i].s = myfread8(h);
+ }
+}
+
+static void G_savegame (FILE *h) {
+ myfwrite8(_2pl, h);
+ myfwrite8(g_dm, h);
+ myfwrite8(g_exit, h);
+ myfwrite8(g_map, h);
+ myfwrite32(g_time, h);
+ myfwrite32(dm_pl1p, h);
+ myfwrite32(dm_pl2p, h);
+ myfwrite32(dm_pnum, h);
+ int i = 0;
+ while (i < dm_pnum) {
+ myfwrite32(dm_pos[i].x, h);
+ myfwrite32(dm_pos[i].y, h);
+ myfwrite8(dm_pos[i].d, h);
+ i += 1;
+ }
+ myfwrite8(cheat, h);
+ myfwrite(g_music, 8, 1, h);
+}
+
+static void G_loadgame (FILE *h) {
+ _2pl = myfread8(h);
+ g_dm = myfread8(h);
+ g_exit = myfread8(h);
+ g_map = myfread8(h);
+ g_time = myfread32(h);
+ dm_pl1p = myfread32(h);
+ dm_pl2p = myfread32(h);
+ dm_pnum = myfread32(h);
+ int i = 0;
+ while (i < dm_pnum) {
+ dm_pos[i].x = myfread32(h);
+ dm_pos[i].y = myfread32(h);
+ dm_pos[i].d = myfread8(h);
+ i += 1;
+ }
+ cheat = myfread8(h);
+ myfread(g_music, 8, 1, h);
+ F_loadmus(g_music);
+}
+
+static void IT_savegame (FILE *h) {
+ int i, n;
+ for (n = MAXITEM - 1; n >= 0 && it[n].t == 0; n--) {
+ // empty
+ }
+ n += 1;
+ myfwrite32(n, h);
+ for (i = 0; i < n; i++) {
+ myfwrite32(it[i].o.x, h);
+ myfwrite32(it[i].o.y, h);
+ myfwrite32(it[i].o.xv, h);
+ myfwrite32(it[i].o.yv, h);
+ myfwrite32(it[i].o.vx, h);
+ myfwrite32(it[i].o.vy, h);
+ myfwrite32(it[i].o.r, h);
+ myfwrite32(it[i].o.h, h);
+ myfwrite32(it[i].t, h);
+ myfwrite32(it[i].s, h);
+ }
+ myfwrite32(itm_rtime, h);
+}
+
+static void IT_loadgame (FILE *h) {
+ int i, n;
+ n = myfread32(h);
+ for (i = 0; i < n; i++) {
+ it[i].o.x = myfread32(h);
+ it[i].o.y = myfread32(h);
+ it[i].o.xv = myfread32(h);
+ it[i].o.yv = myfread32(h);
+ it[i].o.vx = myfread32(h);
+ it[i].o.vy = myfread32(h);
+ it[i].o.r = myfread32(h);
+ it[i].o.h = myfread32(h);
+ it[i].t = myfread32(h);
+ it[i].s = myfread32(h);
+ }
+ itm_rtime = myfread32(h);
+}
+
+static void MN_savegame (FILE *h) {
+ int i, n;
+ for (n = MAXMN - 1; n >= 0 && mn[n].t == 0; n--) {
+ // empty
+ }
+ n += 1;
+ myfwrite32(n, h);
+ for (i = 0; i < n; i++) {
+ myfwrite32(mn[i].o.x, h);
+ myfwrite32(mn[i].o.y, h);
+ myfwrite32(mn[i].o.xv, h);
+ myfwrite32(mn[i].o.yv, h);
+ myfwrite32(mn[i].o.vx, h);
+ myfwrite32(mn[i].o.vy, h);
+ myfwrite32(mn[i].o.r, h);
+ myfwrite32(mn[i].o.h, h);
+ myfwrite8(mn[i].t, h);
+ myfwrite8(mn[i].d, h);
+ myfwrite8(mn[i].st, h);
+ myfwrite8(mn[i].ftime, h);
+ myfwrite32(mn[i].fobj, h);
+ myfwrite32(mn[i].s, h);
+ myfwrite32(0, h); // mn[i].ap useless, changed after load
+ myfwrite32(mn[i].aim, h);
+ myfwrite32(mn[i].life, h);
+ myfwrite32(mn[i].pain, h);
+ myfwrite32(mn[i].ac, h);
+ myfwrite32(mn[i].tx, h);
+ myfwrite32(mn[i].ty, h);
+ myfwrite32(mn[i].ammo, h);
+ myfwrite16(mn[i].atm, h);
+ }
+ myfwrite32(mnum, h);
+ myfwrite32(gsndt, h);
+}
+
+static void MN_loadgame (FILE *h) {
+ int i, n, c;
+ n = myfread32(h);
+ for (i = 0; i < n; i++) {
+ mn[i].o.x = myfread32(h);
+ mn[i].o.y = myfread32(h);
+ mn[i].o.xv = myfread32(h);
+ mn[i].o.yv = myfread32(h);
+ mn[i].o.vx = myfread32(h);
+ mn[i].o.vy = myfread32(h);
+ mn[i].o.r = myfread32(h);
+ mn[i].o.h = myfread32(h);
+ mn[i].t = myfread8(h);
+ mn[i].d = myfread8(h);
+ mn[i].st = myfread8(h);
+ mn[i].ftime = myfread8(h);
+ mn[i].fobj = myfread32(h);
+ mn[i].s = myfread32(h);
+ mn[i].ap = NULL; myfread32(h); // useless, changed after loading
+ mn[i].aim = myfread32(h);
+ mn[i].life = myfread32(h);
+ mn[i].pain = myfread32(h);
+ mn[i].ac = myfread32(h);
+ mn[i].tx = myfread32(h);
+ mn[i].ty = myfread32(h);
+ mn[i].ammo = myfread32(h);
+ mn[i].atm = myfread16(h);
+ }
+ mnum = myfread32(h);
+ gsndt = myfread32(h);
+ for (n = 0; n < MAXMN; n++) {
+ if (mn[n].t) {
+ c = mn[n].ac;
+ setst(n, mn[n].st);
+ mn[n].ac = c;
+ }
+ }
+}
+
+static void PL_save_player (player_t *p, FILE *h) {
+ myfwrite32(p->o.x, h);
+ myfwrite32(p->o.y, h);
+ myfwrite32(p->o.xv, h);
+ myfwrite32(p->o.yv, h);
+ myfwrite32(p->o.vx, h);
+ myfwrite32(p->o.vy, h);
+ myfwrite32(p->o.r, h);
+ myfwrite32(p->o.h, h);
+ myfwrite32(p->looky, h);
+ myfwrite32(p->st, h);
+ myfwrite32(p->s, h);
+ myfwrite32(p->life, h);
+ myfwrite32(p->armor, h);
+ myfwrite32(p->hit, h);
+ myfwrite32(p->hito, h);
+ myfwrite32(p->pain, h);
+ myfwrite32(p->air, h);
+ myfwrite32(p->invl, h);
+ myfwrite32(p->suit, h);
+ myfwrite8(p->d, h);
+ myfwrite32(p->frag, h);
+ myfwrite32(p->ammo, h);
+ myfwrite32(p->shel, h);
+ myfwrite32(p->rock, h);
+ myfwrite32(p->cell, h);
+ myfwrite32(p->fuel, h);
+ myfwrite32(p->kills, h);
+ myfwrite32(p->secrets, h);
+ myfwrite8(p->fire, h);
+ myfwrite8(p->cwpn, h);
+ myfwrite8(p->csnd, h);
+ myfwrite8(p->amul, h);
+ myfwrite16(p->wpns, h);
+ myfwrite8(p->wpn, h);
+ myfwrite8(p->f, h);
+ myfwrite8(p->drawst, h);
+ myfwrite8(p->color, h);
+ myfwrite32(p->id, h);
+ myfwrite8(p->keys, h);
+ myfwrite8(p->lives, h);
+ // k* not saved
+}
+
+static void PL_savegame (FILE *h) {
+ PL_save_player(&pl1, h);
+ if (_2pl) {
+ PL_save_player(&pl2, h);
+ }
+ myfwrite32(PL_JUMP, h);
+ myfwrite32(PL_RUN, h);
+ myfwrite8(p_immortal, h);
+}
+
+static void PL_load_player (player_t *p, FILE *h) {
+ p->o.x = myfread32(h);
+ p->o.y = myfread32(h);
+ p->o.xv = myfread32(h);
+ p->o.yv = myfread32(h);
+ p->o.vx = myfread32(h);
+ p->o.vy = myfread32(h);
+ p->o.r = myfread32(h);
+ p->o.h = myfread32(h);
+ p->looky = myfread32(h);
+ p->st = myfread32(h);
+ p->s = myfread32(h);
+ p->life = myfread32(h);
+ p->armor = myfread32(h);
+ p->hit = myfread32(h);
+ p->hito = myfread32(h);
+ p->pain = myfread32(h);
+ p->air = myfread32(h);
+ p->invl = myfread32(h);
+ p->suit = myfread32(h);
+ p->d = myfread8(h);
+ p->frag = myfread32(h);
+ p->ammo = myfread32(h);
+ p->shel = myfread32(h);
+ p->rock = myfread32(h);
+ p->cell = myfread32(h);
+ p->fuel = myfread32(h);
+ p->kills = myfread32(h);
+ p->secrets = myfread32(h);
+ p->fire = myfread8(h);
+ p->cwpn = myfread8(h);
+ p->csnd = myfread8(h);
+ p->amul = myfread8(h);
+ p->wpns = myfread16(h);
+ p->wpn = myfread8(h);
+ p->f = myfread8(h);
+ p->drawst = myfread8(h);
+ p->color = myfread8(h);
+ p->id = myfread32(h);
+ p->keys = myfread8(h);
+ p->lives = myfread8(h);
+ // k* not saved
+}
+
+static void PL_loadgame (FILE *h) {
+ PL_load_player(&pl1, h);
+ if (_2pl) {
+ PL_load_player(&pl2, h);
+ }
+ PL_JUMP = myfread32(h);
+ PL_RUN = myfread32(h);
+ p_immortal = myfread8(h);
+}
+
+static void SMK_savegame (FILE *h) {
+ int i, n;
+ for (i = n = 0; i < MAXSMOK; ++i) {
+ if (sm[i].t) {
+ ++n;
+ }
+ }
+ myfwrite32(n, h);
+ for (i = 0; i < MAXSMOK; ++i) {
+ if (sm[i].t) {
+ myfwrite32(sm[i].x, h);
+ myfwrite32(sm[i].y, h);
+ myfwrite32(sm[i].xv, h);
+ myfwrite32(sm[i].xv, h);
+ myfwrite8(sm[i].t, h);
+ myfwrite8(sm[i].s, h);
+ myfwrite16(sm[i].o, h);
+ }
+ }
+}
+
+static void SMK_loadgame (FILE *h) {
+ int i, n;
+ n = myfread32(h);
+ for (i = 0; i < n; ++i) {
+ sm[i].x = myfread32(h);
+ sm[i].y = myfread32(h);
+ sm[i].xv = myfread32(h);
+ sm[i].xv = myfread32(h);
+ sm[i].t = myfread8(h);
+ sm[i].s = myfread8(h);
+ sm[i].o = myfread16(h);
+ }
+}
+
+static void SW_savegame (FILE *h) {
+ int i, n;
+ for (n = MAXSW - 1; n >= 0 && sw[n].t == 0; n--) {
+ // empty
+ }
+ n += 1;
+ myfwrite32(n, h);
+ for (i = 0; i < n; i++) {
+ myfwrite8(sw[i].x, h);
+ myfwrite8(sw[i].y, h);
+ myfwrite8(sw[i].t, h);
+ myfwrite8(sw[i].tm, h);
+ myfwrite8(sw[i].a, h);
+ myfwrite8(sw[i].b, h);
+ myfwrite8(sw[i].c, h);
+ myfwrite8(sw[i].d, h);
+ myfwrite8(sw[i].f, h);
+ }
+ myfwrite32(sw_secrets, h);
+}
+
+static void SW_loadgame (FILE *h) {
+ int i, n;
+ n = myfread32(h);
+ for (i = 0; i < n; i++) {
+ sw[i].x = myfread8(h);
+ sw[i].y = myfread8(h);
+ sw[i].t = myfread8(h);
+ sw[i].tm = myfread8(h);
+ sw[i].a = myfread8(h);
+ sw[i].b = myfread8(h);
+ sw[i].c = myfread8(h);
+ sw[i].d = myfread8(h);
+ sw[i].f = myfread8(h);
+ }
+ sw_secrets = myfread32(h);
+}
+
+static void W_savegame (FILE* h) {
+ char s[8];
+ int i;
+ myfwrite32(sky_type, h);
+ for(i = 1; i < 256; ++i) {
+ R_get_name(i, s);
+ myfwrite(s, 8, 1, h);
+ }
+ for (i = 0; i < 256; i++) {
+ myfwrite32(walf[i], h);
+ }
+ for (i = 0; i < 256; i++) {
+ myfwrite8(R_get_swp(i), h);
+ }
+ myfwrite(fldb, FLDW*FLDH, 1, h);
+ myfwrite(fld, FLDW*FLDH, 1, h);
+ myfwrite(fldf, FLDW*FLDH, 1, h);
+}
+
+static void W_loadgame (FILE* h) {
+ int i;
+ char s[8];
+ sky_type = myfread32(h);
+ R_loadsky(sky_type);
+ R_begin_load();
+ for (i = 1; i < 256; ++i) {
+ myfread(s, 8, 1, h);
+ if (s[0]) {
+ R_load(s);
+ }
+ }
+ R_end_load();
+ for (i = 0; i < 256; i++) {
+ myfread32(h); // useless
+ }
+ for (i = 0; i < 256; i++) {
+ walf[i] = myfread8(h);
+ }
+ myfread(fldb, FLDW*FLDH, 1, h);
+ myfread(fld, FLDW*FLDH, 1, h);
+ myfread(fldf, FLDW*FLDH, 1, h);
+}
+
+static void WP_savegame (FILE *h) {
+ int i, n;
+ for (n = MAXWPN - 1; n >= 0 && wp[n].t == 0; n--) {
+ // empty
+ }
+ n += 1;
+ myfwrite32(n, h);
+ for (i = 0; i < n; i++) {
+ myfwrite32(wp[i].o.x, h);
+ myfwrite32(wp[i].o.y, h);
+ myfwrite32(wp[i].o.xv, h);
+ myfwrite32(wp[i].o.yv, h);
+ myfwrite32(wp[i].o.vx, h);
+ myfwrite32(wp[i].o.vy, h);
+ myfwrite32(wp[i].o.r, h);
+ myfwrite32(wp[i].o.h, h);
+ myfwrite8(wp[i].t, h);
+ myfwrite8(wp[i].s, h);
+ myfwrite32(wp[i].own, h);
+ myfwrite16(wp[i].target, h);
+ }
+}
+
+static void WP_loadgame (FILE *h) {
+ int i, n;
+ n = myfread32(h);
+ for (i = 0; i < n; i++) {
+ wp[i].o.x = myfread32(h);
+ wp[i].o.y = myfread32(h);
+ wp[i].o.xv = myfread32(h);
+ wp[i].o.yv = myfread32(h);
+ wp[i].o.vx = myfread32(h);
+ wp[i].o.vy = myfread32(h);
+ wp[i].o.r = myfread32(h);
+ wp[i].o.h = myfread32(h);
+ wp[i].t = myfread8(h);
+ wp[i].s = myfread8(h);
+ wp[i].own = myfread32(h);
+ wp[i].target = myfread16(h);
+ }
+}
+
+static char *getsavfpname (int n, int ro) {
+ static char fn[] = "savgame0.dat";
+ fn[7] = n + '0';
+#ifndef WIN32
+ static char p[100];
+ char *e = getenv("HOME");
+ strncpy(p, e, 60);
+ strcat(p, "/.doom2d-rembo");
+ if (!ro) {
+ mkdir(p, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+ }
+ strcat(p, "/");
+ strcat(p, fn);
+#else
+ strcpy(p, fn);
+#endif
+ return p;
+}
+
+void F_getsavnames (void) {
+ int i;
+ FILE *h;
+ short ver;
+ char *p;
+ for (i = 0; i < 7; ++i) {
+ p = getsavfpname(i, 1);
+ memset(savname[i], 0, 24);
+ savok[i] = 0;
+ h = fopen(p, "rb");
+ if (h != NULL) {
+ ver = -1;
+ myfread(savname[i], 24, 1, h);
+ ver = myfread16(h);
+ savname[i][23] = 0;
+ savok[i] = (ver == 3) ? 1 : 0;
+ fclose(h);
+ }
+ }
+}
+
+void F_savegame (int n, char *s) {
+ char *p = getsavfpname(n, 0);
+ FILE *h = fopen(p, "wb");
+ if (h != NULL) {
+ myfwrite(s, 24, 1, h); // slot name
+ myfwrite16(3, h); // version
+ G_savegame(h);
+ W_savegame(h);
+ DOT_savegame(h);
+ SMK_savegame(h);
+ FX_savegame(h);
+ IT_savegame(h);
+ MN_savegame(h);
+ PL_savegame(h);
+ SW_savegame(h);
+ WP_savegame(h);
+ fclose(h);
+ }
+}
+
+void F_loadgame (int n) {
+ short ver;
+ char *p = getsavfpname(n, 1);
+ FILE *h = fopen(p, "rb");
+ if (h != NULL) {
+ fseek(h, 24, SEEK_SET); // skip name
+ ver = myfread16(h); // version
+ if (ver == 3) {
+ G_loadgame(h);
+ W_loadgame(h);
+ DOT_loadgame(h);
+ SMK_loadgame(h);
+ FX_loadgame(h);
+ IT_loadgame(h);
+ MN_loadgame(h);
+ PL_loadgame(h);
+ SW_loadgame(h);
+ WP_loadgame(h);
+ }
+ fclose(h);
+ }
+}
diff --git a/src/save.h b/src/save.h
--- /dev/null
+++ b/src/save.h
@@ -0,0 +1,16 @@
+#ifndef SAVE_H_INCLUDED
+#define SAVE_H_INCLUDED
+
+#include "glob.h"
+
+#define SAVE_MAX 7
+#define SAVE_MAXLEN 24
+
+extern char savname[SAVE_MAX][SAVE_MAXLEN];
+extern char savok[SAVE_MAX];
+
+void F_getsavnames (void);
+void F_savegame (int n, char *s);
+void F_loadgame (int n);
+
+#endif /* SAVE_H_INCLUDED */
diff --git a/src/smoke.c b/src/smoke.c
index 19bf714fb4f5393a7bdd4c5081dc026d6fcdcfc5..8512e482c6c3e8cca001d8436cd0cd44654517e2 100644 (file)
--- a/src/smoke.c
+++ b/src/smoke.c
static void *burnsnd;
static int burntm=0;
-void SMK_savegame (FILE *h) {
- int i, n;
- for (i = n = 0; i < MAXSMOK; ++i) {
- if (sm[i].t) {
- ++n;
- }
- }
- myfwrite32(n, h);
- for (i = 0; i < MAXSMOK; ++i) {
- if (sm[i].t) {
- myfwrite32(sm[i].x, h);
- myfwrite32(sm[i].y, h);
- myfwrite32(sm[i].xv, h);
- myfwrite32(sm[i].xv, h);
- myfwrite8(sm[i].t, h);
- myfwrite8(sm[i].s, h);
- myfwrite16(sm[i].o, h);
- }
- }
-}
-
-void SMK_loadgame (FILE *h) {
- int i, n;
- n = myfread32(h);
- for (i = 0; i < n; ++i) {
- sm[i].x = myfread32(h);
- sm[i].y = myfread32(h);
- sm[i].xv = myfread32(h);
- sm[i].xv = myfread32(h);
- sm[i].t = myfread8(h);
- sm[i].s = myfread8(h);
- sm[i].o = myfread16(h);
- }
-}
-
void SMK_init (void) {
int i;
diff --git a/src/smoke.h b/src/smoke.h
index f68ae94f5da30edf14a992f6e104de17647af1bf..04087bcea147fadaef8a95e3dac9d77d0e645753 100644 (file)
--- a/src/smoke.h
+++ b/src/smoke.h
#define SMOKE_H_INLUDED
#include "glob.h"
-#include <stdio.h> // FILE
#define MAXSMOK 500
extern smoke_t sm[MAXSMOK];
-void SMK_savegame (FILE *h);
-void SMK_loadgame (FILE *h);
void SMK_init (void);
void SMK_alloc (void);
void SMK_act (void);
diff --git a/src/switch.c b/src/switch.c
index 79f15c02fc38aef8840ca6f2f5658faec2611372..d95e152e0cf07bb3bc7902a33dcb4f7936988a2c 100644 (file)
--- a/src/switch.c
+++ b/src/switch.c
#include "game.h"
#include "my.h"
#include "monster.h"
-
-#define MAXSW 100
-
-typedef struct {
- byte x, y;
- byte t, tm;
- byte a, b, c, d;
- byte f;
-} sw_t;
+#include "render.h"
int sw_secrets;
+sw_t sw[MAXSW];
-static sw_t sw[MAXSW];
static void *sndswn, *sndswx, *sndnoway, *sndbdo, *sndbdc, *sndnotele;
static int swsnd;
static byte cht, chto, chf, f_ch;
-void SW_savegame (FILE *h) {
- int i, n;
- for (n = MAXSW - 1; n >= 0 && sw[n].t == 0; n--) {
- // empty
- }
- n += 1;
- myfwrite32(n, h);
- for (i = 0; i < n; i++) {
- myfwrite8(sw[i].x, h);
- myfwrite8(sw[i].y, h);
- myfwrite8(sw[i].t, h);
- myfwrite8(sw[i].tm, h);
- myfwrite8(sw[i].a, h);
- myfwrite8(sw[i].b, h);
- myfwrite8(sw[i].c, h);
- myfwrite8(sw[i].d, h);
- myfwrite8(sw[i].f, h);
- }
- myfwrite32(sw_secrets, h);
-}
-
-void SW_loadgame (FILE *h) {
- int i, n;
- n = myfread32(h);
- for (i = 0; i < n; i++) {
- sw[i].x = myfread8(h);
- sw[i].y = myfread8(h);
- sw[i].t = myfread8(h);
- sw[i].tm = myfread8(h);
- sw[i].a = myfread8(h);
- sw[i].b = myfread8(h);
- sw[i].c = myfread8(h);
- sw[i].d = myfread8(h);
- sw[i].f = myfread8(h);
- }
- sw_secrets = myfread32(h);
-}
-
int SW_load (FILE *h) {
int i;
switch(blk.t) {
diff --git a/src/switch.h b/src/switch.h
index 621df40eb687468efa78238593f81300509c6c5f..d0d586c89257b8e4a0962dfa3e2a3630d98a16a7 100644 (file)
--- a/src/switch.h
+++ b/src/switch.h
#include <stdio.h> // FILE
#include "view.h" // obj_t
+#define MAXSW 100
+
enum {
SW_NONE, SW_EXIT, SW_EXITS, SW_OPENDOOR, SW_SHUTDOOR, SW_SHUTTRAP,
SW_DOOR, SW_DOOR5, SW_PRESS, SW_TELE, SW_SECRET, SW_LIFTUP, SW_LIFTDOWN,
SW_TRAP, SW_LIFT
};
+typedef struct {
+ byte x, y;
+ byte t, tm;
+ byte a, b, c, d;
+ byte f;
+} sw_t;
+
extern int sw_secrets;
+extern sw_t sw[MAXSW];
-void SW_savegame (FILE *h);
-void SW_loadgame (FILE *h);
int SW_load (FILE *h);
void SW_alloc (void);
void SW_init (void);
diff --git a/src/view.c b/src/view.c
index f902e23648dbe7727678f94a702feda84f22d4d9..6a8132996c3d632302621c66cd908bde5c45453a 100644 (file)
--- a/src/view.c
+++ b/src/view.c
byte fldf[FLDH][FLDW];
byte fld[FLDH][FLDW];
-void W_savegame (FILE* h) {
- char s[8];
- int i;
- myfwrite32(sky_type, h);
- for(i = 1; i < 256; ++i) {
- R_get_name(i, s);
- myfwrite(s, 8, 1, h);
- }
- for (i = 0; i < 256; i++) {
- myfwrite32(walf[i], h);
- }
- for (i = 0; i < 256; i++) {
- myfwrite8(R_get_swp(i), h);
- }
- myfwrite(fldb, FLDW*FLDH, 1, h);
- myfwrite(fld, FLDW*FLDH, 1, h);
- myfwrite(fldf, FLDW*FLDH, 1, h);
-}
-
-void W_loadgame (FILE* h) {
- int i;
- char s[8];
- sky_type = myfread32(h);
- R_loadsky(sky_type);
- R_begin_load();
- for (i = 1; i < 256; ++i) {
- myfread(s, 8, 1, h);
- if (s[0]) {
- R_load(s);
- }
- }
- R_end_load();
- for (i = 0; i < 256; i++) {
- myfread32(h); // useless
- }
- for (i = 0; i < 256; i++) {
- walf[i] = myfread8(h);
- }
- myfread(fldb, FLDW*FLDH, 1, h);
- myfread(fld, FLDW*FLDH, 1, h);
- myfread(fldf, FLDW*FLDH, 1, h);
-}
-
void W_init (void) {
DOT_init();
SMK_init();
diff --git a/src/view.h b/src/view.h
index d64512c66b00b0cbf464fd77f4cccf535f495533..a88e0f69b60caebe91f87476c41768762d5bc942 100644 (file)
--- a/src/view.h
+++ b/src/view.h
extern byte fldf[FLDH][FLDW];
extern byte fld[FLDH][FLDW];
-void W_savegame (FILE *h);
-void W_loadgame (FILE *h);
void W_init (void);
int W_load (FILE *h);
diff --git a/src/weapons.c b/src/weapons.c
index b3b757dc11724122aefce6874e89f6074a199b8f..4162ae283ff1c39e9eb01f51dcdb4f594e3c8806 100644 (file)
--- a/src/weapons.c
+++ b/src/weapons.c
static void *snd[14];
static void throw(int,int,int,int,int,int,int,int);
-void WP_savegame (FILE *h) {
- int i, n;
- for (n = MAXWPN - 1; n >= 0 && wp[n].t == 0; n--) {
- // empty
- }
- n += 1;
- myfwrite32(n, h);
- for (i = 0; i < n; i++) {
- myfwrite32(wp[i].o.x, h);
- myfwrite32(wp[i].o.y, h);
- myfwrite32(wp[i].o.xv, h);
- myfwrite32(wp[i].o.yv, h);
- myfwrite32(wp[i].o.vx, h);
- myfwrite32(wp[i].o.vy, h);
- myfwrite32(wp[i].o.r, h);
- myfwrite32(wp[i].o.h, h);
- myfwrite8(wp[i].t, h);
- myfwrite8(wp[i].s, h);
- myfwrite32(wp[i].own, h);
- myfwrite16(wp[i].target, h);
- }
-}
-
-void WP_loadgame (FILE *h) {
- int i, n;
- n = myfread32(h);
- for (i = 0; i < n; i++) {
- wp[i].o.x = myfread32(h);
- wp[i].o.y = myfread32(h);
- wp[i].o.xv = myfread32(h);
- wp[i].o.yv = myfread32(h);
- wp[i].o.vx = myfread32(h);
- wp[i].o.vy = myfread32(h);
- wp[i].o.r = myfread32(h);
- wp[i].o.h = myfread32(h);
- wp[i].t = myfread8(h);
- wp[i].s = myfread8(h);
- wp[i].own = myfread32(h);
- wp[i].target = myfread16(h);
- }
-}
-
void WP_alloc (void) {
int i;
static char nm[14][6]={
diff --git a/src/weapons.h b/src/weapons.h
index fc4f7a3cec3603640374181b7bc4695a8d9fef24..62b2a345e09a52a900176ee593eda4b94148b8c6 100644 (file)
--- a/src/weapons.h
+++ b/src/weapons.h
#ifndef WEAPONS_H_INLUDED
#define WEAPONS_H_INLUDED
-#include <stdio.h> // FILE
-
#define MAXWPN 300
typedef struct {
extern weapon_t wp[MAXWPN];
-void WP_savegame (FILE *h);
-void WP_loadgame (FILE *h);
void WP_alloc (void);
void WP_init (void);
void WP_act (void);