Subversion Repositories eduke32

Rev

Rev 4990 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4990 Rev 5069
1
//-------------------------------------------------------------------------
1
//-------------------------------------------------------------------------
2
/*
2
/*
3
Copyright (C) 2010 EDuke32 developers and contributors
3
Copyright (C) 2010 EDuke32 developers and contributors
4

4

5
This file is part of EDuke32.
5
This file is part of EDuke32.
6

6

7
EDuke32 is free software; you can redistribute it and/or
7
EDuke32 is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License version 2
8
modify it under the terms of the GNU General Public License version 2
9
as published by the Free Software Foundation.
9
as published by the Free Software Foundation.
10

10

11
This program is distributed in the hope that it will be useful,
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14

14

15
See the GNU General Public License for more details.
15
See the GNU General Public License for more details.
16

16

17
You should have received a copy of the GNU General Public License
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
*/
20
*/
21
//-------------------------------------------------------------------------
21
//-------------------------------------------------------------------------
22
22
23
#ifndef savegame_h_
23
#ifndef savegame_h_
24
#define savegame_h_
24
#define savegame_h_
25
25
26
#include "game.h"
26
#include "game.h"
27
27
28
#ifdef __cplusplus
28
#ifdef __cplusplus
29
extern "C" {
29
extern "C" {
30
#endif
30
#endif
31
31
32
#ifdef LUNATIC
32
#ifdef LUNATIC
33
# define SV_MAJOR_VER 2
33
# define SV_MAJOR_VER 2
34
#else
34
#else
35
# define SV_MAJOR_VER 1
35
# define SV_MAJOR_VER 1
36
#endif
36
#endif
37
#define SV_MINOR_VER 3
37
#define SV_MINOR_VER 3
38
38
39
#pragma pack(push,1)
39
#pragma pack(push,1)
40
typedef struct
40
typedef struct
41
{
41
{
42
    char headerstr[11];
42
    char headerstr[11];
43
    uint8_t majorver, minorver, ptrsize;
43
    uint8_t majorver, minorver, ptrsize;
44
    uint16_t bytever;
44
    uint16_t bytever;
45
    // 16 bytes
45
    // 16 bytes
46
46
47
    uint8_t comprthres;
47
    uint8_t comprthres;
48
    uint8_t recdiffsp, diffcompress, synccompress;
48
    uint8_t recdiffsp, diffcompress, synccompress;
49
    // 4 bytes
49
    // 4 bytes
50
50
51
    int32_t reccnt, snapsiz;
51
    int32_t reccnt, snapsiz;
52
    // 8 bytes
52
    // 8 bytes
53
53
54
    char savename[MAXSAVEGAMENAME];
54
    char savename[MAXSAVEGAMENAME];
55
    uint8_t numplayers, volnum, levnum, skill;
55
    uint8_t numplayers, volnum, levnum, skill;
56
    char boardfn[BMAX_PATH];
56
    char boardfn[BMAX_PATH];
57
    // 282 bytes
57
    // 282 bytes
58
#ifdef __ANDROID__
58
#ifdef __ANDROID__
59
    char skillname[32], volname[32];
59
    char skillname[32], volname[32];
60
#endif
60
#endif
61
} savehead_t;
61
} savehead_t;
62
#pragma pack(pop)
62
#pragma pack(pop)
63
63
64
#ifdef __ANDROID__
64
#ifdef __ANDROID__
65
#define SAVEHEAD_SIZE 374
65
#define SAVEHEAD_SIZE 374
66
#else
66
#else
67
#define SAVEHEAD_SIZE 310
67
#define SAVEHEAD_SIZE 310
68
#endif
68
#endif
69
69
70
EDUKE32_STATIC_ASSERT(sizeof(savehead_t) == SAVEHEAD_SIZE);
70
EDUKE32_STATIC_ASSERT(sizeof(savehead_t) == SAVEHEAD_SIZE);
71
71
72
int32_t sv_updatestate(int32_t frominit);
72
int32_t sv_updatestate(int32_t frominit);
73
int32_t sv_readdiff(int32_t fil);
73
int32_t sv_readdiff(int32_t fil);
74
uint32_t sv_writediff(FILE *fil);
74
uint32_t sv_writediff(FILE *fil);
75
int32_t sv_loadheader(int32_t fil, int32_t spot, savehead_t *h);
75
int32_t sv_loadheader(int32_t fil, int32_t spot, savehead_t *h);
76
int32_t sv_loadsnapshot(int32_t fil, int32_t spot, savehead_t *h);
76
int32_t sv_loadsnapshot(int32_t fil, int32_t spot, savehead_t *h);
77
int32_t sv_saveandmakesnapshot(FILE *fil, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress);
77
int32_t sv_saveandmakesnapshot(FILE *fil, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress);
78
void sv_freemem();
78
void sv_freemem();
79
int32_t G_SavePlayer(int32_t spot);
79
int32_t G_SavePlayer(int32_t spot);
80
int32_t G_LoadPlayer(int32_t spot);
80
int32_t G_LoadPlayer(int32_t spot);
81
int32_t G_LoadSaveHeaderNew(int32_t spot, savehead_t *saveh);
81
int32_t G_LoadSaveHeaderNew(int32_t spot, savehead_t *saveh);
82
void ReadSaveGameHeaders(void);
82
void ReadSaveGameHeaders(void);
83
void G_SavePlayerMaybeMulti(int32_t slot);
83
void G_SavePlayerMaybeMulti(int32_t slot);
84
void G_LoadPlayerMaybeMulti(int32_t slot);
84
void G_LoadPlayerMaybeMulti(int32_t slot);
85
85
86
#ifdef YAX_ENABLE
86
#ifdef YAX_ENABLE
87
extern void sv_postyaxload(void);
87
extern void sv_postyaxload(void);
88
#endif
88
#endif
89
89
90
// XXX: The 'bitptr' decl really belongs into gamedef.h, but we don't want to
90
// XXX: The 'bitptr' decl really belongs into gamedef.h, but we don't want to
91
// pull all of it in savegame.c?
91
// pull all of it in savegame.c?
92
extern char *bitptr;
92
extern char *bitptr;
93
extern uint8_t g_oldverSavegame[MAXSAVEGAMES];
93
extern uint8_t g_oldverSavegame[MAXSAVEGAMES];
94
94
95
enum
95
enum
96
{
96
{
97
    P2I_BACK_BIT = 1,
97
    P2I_BACK_BIT = 1,
98
    P2I_ONLYNON0_BIT = 2,
98
    P2I_ONLYNON0_BIT = 2,
99
99
100
    P2I_FWD = 0,
100
    P2I_FWD = 0,
101
    P2I_BACK = 1,
101
    P2I_BACK = 1,
102
102
103
    P2I_FWD_NON0 = 0+2,
103
    P2I_FWD_NON0 = 0+2,
104
    P2I_BACK_NON0 = 1+2,
104
    P2I_BACK_NON0 = 1+2,
105
};
105
};
106
void G_Util_PtrToIdx(void *ptr, int32_t count, const void *base, int32_t mode);
106
void G_Util_PtrToIdx(void *ptr, int32_t const count, const void *base, int32_t const mode);
107
void G_Util_PtrToIdx2(void *ptr, int32_t count, size_t stride, const void *base, int32_t mode);
107
void G_Util_PtrToIdx2(void *ptr, int32_t const count, size_t const stride, const void *base, int32_t const mode);
108
108
109
#ifdef LUNATIC
109
#ifdef LUNATIC
110
extern const char *(*El_SerializeGamevars)(int32_t *slenptr, int32_t levelnum);
110
extern const char *(*El_SerializeGamevars)(int32_t *slenptr, int32_t levelnum);
111
void El_FreeSaveCode(void);
111
void El_FreeSaveCode(void);
112
#endif
112
#endif
113
113
114
#ifdef __ANDROID__
114
#ifdef __ANDROID__
115
char const * G_GetStringFromSavegame(const char *filename, int type);
115
char const * G_GetStringFromSavegame(const char *filename, int type);
116
int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data);
116
int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data);
117
#endif
117
#endif
118
118
119
#ifdef __cplusplus
119
#ifdef __cplusplus
120
}
120
}
121
#endif
121
#endif
122
122
123
#endif
123
#endif
124
 
124