Subversion Repositories eduke32

Rev

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

Rev 8716 Rev 8777
1
//-------------------------------------------------------------------------
1
//-------------------------------------------------------------------------
2
/*
2
/*
3
Copyright (C) 2016 EDuke32 developers and contributors
3
Copyright (C) 2016 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
#pragma once
23
#pragma once
24
24
25
#ifndef game_h_
25
#ifndef game_h_
26
#define game_h_
26
#define game_h_
27
27
28
#ifndef ONLY_USERDEFS
28
#ifndef ONLY_USERDEFS
29
#include "premap.h" // XXX
29
#include "premap.h" // XXX
30
#endif
30
#endif
31
31
32
#include "fix16.h"
32
#include "fix16.h"
33
#include "gamedefs.h"
33
#include "gamedefs.h"
34
#include "gamevars.h"
34
#include "gamevars.h"
35
#include "mmulti.h"
35
#include "mmulti.h"
36
#include "network.h"
36
#include "network.h"
37
37
38
#ifdef __cplusplus
38
#ifdef __cplusplus
39
extern "C" {
39
extern "C" {
40
#endif
40
#endif
41
41
42
#ifndef ONLY_USERDEFS
42
#ifndef ONLY_USERDEFS
43
43
44
// Compile game-side legacy Room over Room code?
44
// Compile game-side legacy Room over Room code?
45
#define LEGACY_ROR 1
45
#define LEGACY_ROR 1
46
46
47
#define USERQUOTE_LEFTOFFSET    5
47
#define USERQUOTE_LEFTOFFSET    5
48
#define USERQUOTE_RIGHTOFFSET   14
48
#define USERQUOTE_RIGHTOFFSET   14
49
49
50
#if defined(GEKKO) || defined(__OPENDINGUX__)
50
#if defined(GEKKO) || defined(__OPENDINGUX__)
51
# define VIEWSCREENFACTOR 0
51
# define VIEWSCREENFACTOR 0
52
#elif defined(__ANDROID__)
52
#elif defined(__ANDROID__)
53
# define VIEWSCREENFACTOR 1
53
# define VIEWSCREENFACTOR 1
54
#else
54
#else
55
# define VIEWSCREENFACTOR 2
55
# define VIEWSCREENFACTOR 2
56
#endif
56
#endif
57
57
58
enum GametypeFlags_t {
58
enum GametypeFlags_t {
59
    GAMETYPE_COOP                   = 0x00000001,
59
    GAMETYPE_COOP                   = 0x00000001,
60
    GAMETYPE_WEAPSTAY               = 0x00000002,
60
    GAMETYPE_WEAPSTAY               = 0x00000002,
61
    GAMETYPE_FRAGBAR                = 0x00000004,
61
    GAMETYPE_FRAGBAR                = 0x00000004,
62
    GAMETYPE_SCORESHEET             = 0x00000008,
62
    GAMETYPE_SCORESHEET             = 0x00000008,
63
    GAMETYPE_DMSWITCHES             = 0x00000010,
63
    GAMETYPE_DMSWITCHES             = 0x00000010,
64
    GAMETYPE_COOPSPAWN              = 0x00000020,
64
    GAMETYPE_COOPSPAWN              = 0x00000020,
65
    GAMETYPE_ACCESSCARDSPRITES      = 0x00000040,
65
    GAMETYPE_ACCESSCARDSPRITES      = 0x00000040,
66
    GAMETYPE_COOPVIEW               = 0x00000080,
66
    GAMETYPE_COOPVIEW               = 0x00000080,
67
    GAMETYPE_COOPSOUND              = 0x00000100,
67
    GAMETYPE_COOPSOUND              = 0x00000100,
68
    GAMETYPE_OTHERPLAYERSINMAP      = 0x00000200,
68
    GAMETYPE_OTHERPLAYERSINMAP      = 0x00000200,
69
    GAMETYPE_ITEMRESPAWN            = 0x00000400,
69
    GAMETYPE_ITEMRESPAWN            = 0x00000400,
70
    GAMETYPE_MARKEROPTION           = 0x00000800,
70
    GAMETYPE_MARKEROPTION           = 0x00000800,
71
    GAMETYPE_PLAYERSFRIENDLY        = 0x00001000,
71
    GAMETYPE_PLAYERSFRIENDLY        = 0x00001000,
72
    GAMETYPE_FIXEDRESPAWN           = 0x00002000,
72
    GAMETYPE_FIXEDRESPAWN           = 0x00002000,
73
    GAMETYPE_ACCESSATSTART          = 0x00004000,
73
    GAMETYPE_ACCESSATSTART          = 0x00004000,
74
    GAMETYPE_PRESERVEINVENTORYDEATH = 0x00008000,
74
    GAMETYPE_PRESERVEINVENTORYDEATH = 0x00008000,
75
    GAMETYPE_TDM                    = 0x00010000,
75
    GAMETYPE_TDM                    = 0x00010000,
76
    GAMETYPE_TDMSPAWN               = 0x00020000
76
    GAMETYPE_TDMSPAWN               = 0x00020000
77
};
77
};
78
78
79
// logo control
79
// logo control
80
enum LogoFlags_t {
80
enum LogoFlags_t {
81
    LOGO_ENABLED           = 0x00000001,
81
    LOGO_ENABLED           = 0x00000001,
82
    LOGO_PLAYANIM          = 0x00000002,
82
    LOGO_PLAYANIM          = 0x00000002,
83
    LOGO_PLAYMUSIC         = 0x00000004,
83
    LOGO_PLAYMUSIC         = 0x00000004,
84
    LOGO_3DRSCREEN         = 0x00000008,
84
    LOGO_3DRSCREEN         = 0x00000008,
85
    LOGO_TITLESCREEN       = 0x00000010,
85
    LOGO_TITLESCREEN       = 0x00000010,
86
    LOGO_DUKENUKEM         = 0x00000020,
86
    LOGO_DUKENUKEM         = 0x00000020,
87
    LOGO_THREEDEE          = 0x00000040,
87
    LOGO_THREEDEE          = 0x00000040,
88
    LOGO_PLUTOPAKSPRITE    = 0x00000080,
88
    LOGO_PLUTOPAKSPRITE    = 0x00000080,
89
    LOGO_SHAREWARESCREENS  = 0x00000100,
89
    LOGO_SHAREWARESCREENS  = 0x00000100,
90
    LOGO_TENSCREEN         = 0x00000200,
90
    LOGO_TENSCREEN         = 0x00000200,
91
    LOGO_STOPANIMSOUNDS    = 0x00000400,
91
    LOGO_STOPANIMSOUNDS    = 0x00000400,
92
    LOGO_NOE4CUTSCENE      = 0x00000800,
92
    LOGO_NOE4CUTSCENE      = 0x00000800,
93
    LOGO_NOE1BONUSSCENE    = 0x00001000,
93
    LOGO_NOE1BONUSSCENE    = 0x00001000,
94
    LOGO_NOE2BONUSSCENE    = 0x00002000,
94
    LOGO_NOE2BONUSSCENE    = 0x00002000,
95
    LOGO_NOE3BONUSSCENE    = 0x00004000,
95
    LOGO_NOE3BONUSSCENE    = 0x00004000,
96
    LOGO_NOE4BONUSSCENE    = 0x00008000,
96
    LOGO_NOE4BONUSSCENE    = 0x00008000,
97
    LOGO_NOE1ENDSCREEN     = 0x00010000,
97
    LOGO_NOE1ENDSCREEN     = 0x00010000,
98
    LOGO_NOE2ENDSCREEN     = 0x00020000,
98
    LOGO_NOE2ENDSCREEN     = 0x00020000,
99
    LOGO_NOE3RADLOGO       = 0x00040000,
99
    LOGO_NOE3RADLOGO       = 0x00040000,
100
    LOGO_NODUKETEAMTEXT    = 0x00080000,
100
    LOGO_NODUKETEAMTEXT    = 0x00080000,
101
    LOGO_NODUKETEAMPIC     = 0x00100000,
101
    LOGO_NODUKETEAMPIC     = 0x00100000,
102
    LOGO_STOPMISCSOUNDS    = 0x00200000,
102
    LOGO_STOPMISCSOUNDS    = 0x00200000,
103
    LOGO_NOGAMETITLE       = 0x00400000,
103
    LOGO_NOGAMETITLE       = 0x00400000,
104
    LOGO_NOTITLEBAR        = 0x00800000,
104
    LOGO_NOTITLEBAR        = 0x00800000,
105
    LOGO_HIDEEPISODE       = 0x01000000,
105
    LOGO_HIDEEPISODE       = 0x01000000,
106
    LOGO_NOHELP            = 0x02000000,
106
    LOGO_NOHELP            = 0x02000000,
107
    LOGO_NOCREDITS         = 0x04000000,
107
    LOGO_NOCREDITS         = 0x04000000,
108
};
108
};
109
109
110
enum {
110
enum {
111
    STATUSBAR_NONONE    = 0x00000001,
111
    STATUSBAR_NONONE    = 0x00000001,
112
    STATUSBAR_NOMINI    = 0x00000002,
112
    STATUSBAR_NOMINI    = 0x00000002,
113
    STATUSBAR_NOFULL    = 0x00000004,
113
    STATUSBAR_NOFULL    = 0x00000004,
114
    STATUSBAR_NOSHRINK  = 0x00000008,
114
    STATUSBAR_NOSHRINK  = 0x00000008,
115
    STATUSBAR_NOFRAGBAR = 0x00000010,
115
    STATUSBAR_NOFRAGBAR = 0x00000010,
116
    STATUSBAR_NOOVERLAY = 0x00000020,
116
    STATUSBAR_NOOVERLAY = 0x00000020,
117
    STATUSBAR_NOMODERN  = 0x00000040,
117
    STATUSBAR_NOMODERN  = 0x00000040,
118
};
118
};
119
119
120
enum {
120
enum {
121
    BENCHMARKMODE_OFF = 0x0,
121
    BENCHMARKMODE_OFF = 0x0,
122
    BENCHMARKMODE_PERFORMANCE = 0x1,
122
    BENCHMARKMODE_PERFORMANCE = 0x1,
123
    BENCHMARKMODE_GENERATE_REFERENCE = 0x2,
123
    BENCHMARKMODE_GENERATE_REFERENCE = 0x2,
124
};
124
};
125
125
126
void A_DeleteSprite(int spriteNum);
126
void A_DeleteSprite(int spriteNum);
127
127
128
static inline int32_t G_GetLogoFlags(void)
128
static inline int32_t G_GetLogoFlags(void)
129
{
129
{
130
#if !defined LUNATIC
130
#if !defined LUNATIC
131
    return Gv_GetVarByLabel("LOGO_FLAGS",255, -1, -1);
131
    return Gv_GetVarByLabel("LOGO_FLAGS",255, -1, -1);
132
#else
132
#else
133
    extern int32_t g_logoFlags;
133
    extern int32_t g_logoFlags;
134
    return g_logoFlags;
134
    return g_logoFlags;
135
#endif
135
#endif
136
}
136
}
137
137
138
#ifdef LUNATIC
138
#ifdef LUNATIC
139
typedef struct {
139
typedef struct {
140
    vec3_t pos;
140
    vec3_t pos;
141
    int32_t dist, clock;
141
    int32_t dist, clock;
142
    fix16_t q16horiz, q16ang;
142
    fix16_t q16horiz, q16ang;
143
    int16_t sect;
143
    int16_t sect;
144
} camera_t;
144
} camera_t;
145
145
146
extern camera_t g_camera;
146
extern camera_t g_camera;
147
147
148
# define CAMERA(Membname) (g_camera.Membname)
148
# define CAMERA(Membname) (g_camera.Membname)
149
# define CAMERADIST (g_camera.dist)
149
# define CAMERADIST (g_camera.dist)
150
# define CAMERACLOCK (g_camera.clock)
150
# define CAMERACLOCK (g_camera.clock)
151
#else
151
#else
152
# define CAMERA(Membname) (ud.camera ## Membname)
152
# define CAMERA(Membname) (ud.camera ## Membname)
153
# define CAMERADIST g_cameraDistance
153
# define CAMERADIST g_cameraDistance
154
# define CAMERACLOCK g_cameraClock
154
# define CAMERACLOCK g_cameraClock
155
#endif
155
#endif
156
156
157
#endif
157
#endif
158
158
159
#define MAXRIDECULE 10
159
#define MAXRIDECULE 10
160
#define MAXRIDECULELENGTH 40
160
#define MAXRIDECULELENGTH 40
161
#define MAXSAVEGAMENAMESTRUCT 32
161
#define MAXSAVEGAMENAMESTRUCT 32
162
#define MAXSAVEGAMENAME (MAXSAVEGAMENAMESTRUCT-1)
162
#define MAXSAVEGAMENAME (MAXSAVEGAMENAMESTRUCT-1)
163
#define MAXPWLOCKOUT 128
163
#define MAXPWLOCKOUT 128
164
#define MAXRTSNAME 128
164
#define MAXRTSNAME 128
165
165
166
#define MAX_RETURN_VALUES 6
166
#define MAX_RETURN_VALUES 6
167
167
168
#define MAX_ARRAYRANGE_VALUES 32
168
#define MAX_ARRAYRANGE_VALUES 32
169
169
170
// KEEPINSYNC lunatic/_defs_game.lua
170
// KEEPINSYNC lunatic/_defs_game.lua
171
typedef struct ud_setup_s {
171
typedef struct ud_setup_s {
172
    int32_t usejoystick;
172
    int32_t usejoystick;
173
    int32_t usemouse;
173
    int32_t usemouse;
174
    int32_t fullscreen;
174
    int32_t fullscreen;
175
    int32_t xdim;
175
    int32_t xdim;
176
    int32_t ydim;
176
    int32_t ydim;
177
    int32_t bpp;
177
    int32_t bpp;
178
    int32_t forcesetup;
178
    int32_t forcesetup;
179
    int32_t noautoload;
179
    int32_t noautoload;
180
} ud_setup_t;
180
} ud_setup_t;
181
181
182
typedef struct {
182
typedef struct {
183
#if !defined LUNATIC
183
#if !defined LUNATIC
184
    vec3_t camerapos;
184
    vec3_t camerapos;
185
#endif
185
#endif
186
    int32_t const_visibility,uw_framerate;
186
    int32_t const_visibility,uw_framerate;
187
    int32_t camera_time,folfvel,folavel,folx,foly,fola;
187
    int32_t camera_time,folfvel,folavel,folx,foly,fola;
188
    int32_t reccnt,crosshairscale;
188
    int32_t reccnt,crosshairscale;
189
189
190
    int32_t runkey_mode,statusbarscale,mouseaiming,weaponswitch,drawweapon;   // JBF 20031125
190
    int32_t runkey_mode,statusbarscale,mouseaiming,weaponswitch,drawweapon;   // JBF 20031125
191
    int32_t democams,color,msgdisptime,statusbarmode;
191
    int32_t democams,color,msgdisptime,statusbarmode;
192
    int32_t m_noexits,noexits,autovote,automsg,idplayers;
192
    int32_t m_noexits,noexits,autovote,automsg,idplayers;
193
    int32_t team, viewbob, weaponsway, althud, weaponscale, textscale;
193
    int32_t team, viewbob, weaponsway, althud, weaponscale, textscale;
194
    int32_t statusbarflags, statusbarrange, statusbarcustom;
194
    int32_t statusbarflags, statusbarrange, statusbarcustom;
195
    int32_t hudontop;
195
    int32_t hudontop;
196
    int32_t menu_slidebarz, menu_slidebarmargin, menu_slidecursorz;
196
    int32_t menu_slidebarz, menu_slidebarmargin, menu_slidecursorz;
197
    int32_t menu_scrollbartilenum, menu_scrollbarz, menu_scrollcursorz;
197
    int32_t menu_scrollbartilenum, menu_scrollbarz, menu_scrollcursorz;
198
198
199
    int32_t entered_name,screen_tilting,shadows,fta_on,executions,auto_run;
199
    int32_t entered_name,screen_tilting,shadows,fta_on,executions,auto_run;
200
    int32_t coords,showfps,levelstats,m_coop,coop,screen_size,lockout,crosshair;
200
    int32_t coords,showfps,levelstats,m_coop,coop,screen_size,lockout,crosshair;
201
    int32_t playerai,angleinterpolation,obituaries;
201
    int32_t playerai,angleinterpolation,obituaries;
202
202
203
    int32_t respawn_monsters,respawn_items,respawn_inventory,recstat,monsters_off,brightness;
203
    int32_t respawn_monsters,respawn_items,respawn_inventory,recstat,monsters_off,brightness;
204
    int32_t m_respawn_items,m_respawn_monsters,m_respawn_inventory,m_recstat,m_monsters_off,detail;
204
    int32_t m_respawn_items,m_respawn_monsters,m_respawn_inventory,m_recstat,m_monsters_off,detail;
205
    int32_t m_ffire,ffire,m_player_skill,m_level_number,m_volume_number,multimode;
205
    int32_t m_ffire,ffire,m_player_skill,m_level_number,m_volume_number,multimode;
206
    int32_t player_skill,level_number,volume_number,m_marker,marker,mouseflip;
206
    int32_t player_skill,level_number,volume_number,m_marker,marker,mouseflip;
207
    int32_t music_episode, music_level, skill_voice;
207
    int32_t music_episode, music_level, skill_voice;
208
208
209
    int32_t playerbest;
209
    int32_t playerbest;
210
210
211
    int32_t configversion, bgstretch, frameperiod;
211
    int32_t configversion, bgstretch, frameperiod;
212
212
213
    int32_t default_volume, default_skill;
213
    int32_t default_volume, default_skill;
214
214
215
    int32_t autosave;
215
    int32_t autosave;
216
    int32_t autosavedeletion, maxautosaves;
216
    int32_t autosavedeletion, maxautosaves;
217
217
218
    int32_t returnvar[MAX_RETURN_VALUES-1];
218
    int32_t returnvar[MAX_RETURN_VALUES-1];
219
219
220
    uint32_t userbytever;
220
    uint32_t userbytever;
221
221
222
    int32_t fov;
222
    int32_t fov;
223
223
224
#if !defined LUNATIC
224
#if !defined LUNATIC
225
    fix16_t cameraq16ang, cameraq16horiz;
225
    fix16_t cameraq16ang, cameraq16horiz;
226
    int16_t camerasect;
226
    int16_t camerasect;
227
#endif
227
#endif
228
    int16_t pause_on,from_bonus;
228
    int16_t pause_on,from_bonus;
229
    int16_t camerasprite,last_camsprite;
229
    int16_t camerasprite,last_camsprite;
230
    int16_t last_level,secretlevel;
230
    int16_t last_level,secretlevel;
231
231
232
    int8_t menutitle_pal, slidebar_palselected, slidebar_paldisabled;
232
    int8_t menutitle_pal, slidebar_palselected, slidebar_paldisabled;
233
233
234
    int32_t last_stateless_level, last_stateless_volume; // strictly internal
234
    int32_t last_stateless_level, last_stateless_volume; // strictly internal
235
235
236
    struct {
236
    struct {
237
        int32_t AutoAim;
237
        int32_t AutoAim;
238
        int32_t ShowWeapons;
238
        int32_t ShowWeapons;
239
        int32_t MouseBias;
239
        int32_t MouseBias;
240
240
241
        // JBF 20031211: Store the input settings because
241
        // JBF 20031211: Store the input settings because
242
        // (currently) mact can't regurgitate them
242
        // (currently) mact can't regurgitate them
243
        int32_t MouseFunctions[MAXMOUSEBUTTONS][2];
243
        int32_t MouseFunctions[MAXMOUSEBUTTONS][2];
244
        int32_t MouseDigitalFunctions[MAXMOUSEAXES][2];
-
 
245
        int32_t MouseAnalogueAxes[MAXMOUSEAXES];
244
        int32_t MouseAnalogueAxes[MAXMOUSEAXES];
246
        int32_t MouseAnalogueScale[MAXMOUSEAXES];
-
 
247
        int32_t JoystickFunctions[MAXJOYBUTTONSANDHATS][2];
245
        int32_t JoystickFunctions[MAXJOYBUTTONSANDHATS][2];
248
        int32_t JoystickDigitalFunctions[MAXJOYAXES][2];
246
        int32_t JoystickDigitalFunctions[MAXJOYAXES][2];
249
        int32_t JoystickAnalogueAxes[MAXJOYAXES];
247
        int32_t JoystickAnalogueAxes[MAXJOYAXES];
250
        int32_t JoystickAnalogueScale[MAXJOYAXES];
248
        int32_t JoystickAnalogueScale[MAXJOYAXES];
251
        int32_t JoystickAnalogueInvert[MAXJOYAXES];
249
        int32_t JoystickAnalogueInvert[MAXJOYAXES];
252
        int32_t JoystickAnalogueDead[MAXJOYAXES];
250
        int32_t JoystickAnalogueDead[MAXJOYAXES];
253
        int32_t JoystickAnalogueSaturate[MAXJOYAXES];
251
        int32_t JoystickAnalogueSaturate[MAXJOYAXES];
254
        uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2];
252
        uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2];
255
253
256
        //
254
        //
257
        // Sound variables
255
        // Sound variables
258
        //
256
        //
259
        int32_t FXVolume;
257
        int32_t FXVolume;
260
        int32_t MusicDevice;
258
        int32_t MusicDevice;
261
        int32_t MusicVolume;
259
        int32_t MusicVolume;
262
        int32_t SoundToggle;
260
        int32_t SoundToggle;
263
        int32_t MusicToggle;
261
        int32_t MusicToggle;
264
        int32_t VoiceToggle;
262
        int32_t VoiceToggle;
265
        int32_t AmbienceToggle;
263
        int32_t AmbienceToggle;
266
264
267
        int32_t NumVoices;
265
        int32_t NumVoices;
268
        int32_t NumChannels;
266
        int32_t NumChannels;
269
        int32_t NumBits;
267
        int32_t NumBits;
270
        int32_t MixRate;
268
        int32_t MixRate;
271
269
272
#ifdef ASS_REVERSESTEREO
270
#ifdef ASS_REVERSESTEREO
273
        int32_t ReverseStereo;
271
        int32_t ReverseStereo;
274
#endif
272
#endif
275
273
276
        int32_t scripthandle;
274
        int32_t scripthandle;
277
        int32_t setupread;
275
        int32_t setupread;
278
276
279
        int32_t CheckForUpdates;
277
        int32_t CheckForUpdates;
280
        int32_t LastUpdateCheck;
278
        int32_t LastUpdateCheck;
281
        int32_t useprecache;
279
        int32_t useprecache;
282
    } config;
280
    } config;
283
281
284
    ud_setup_t setup;
282
    ud_setup_t setup;
285
283
286
    char overhead_on,last_overhead,showweapons;
284
    char overhead_on,last_overhead,showweapons;
287
    char god,warp_on,cashman,eog,showallmap;
285
    char god,warp_on,cashman,eog,showallmap;
288
    char show_help,scrollmode,noclip;
286
    char show_help,scrollmode,noclip;
289
    char ridecule[MAXRIDECULE][MAXRIDECULELENGTH];
287
    char ridecule[MAXRIDECULE][MAXRIDECULELENGTH];
290
    char pwlockout[MAXPWLOCKOUT],rtsname[MAXRTSNAME];
288
    char pwlockout[MAXPWLOCKOUT],rtsname[MAXRTSNAME];
291
    char display_bonus_screen;
289
    char display_bonus_screen;
292
    char show_level_text;
290
    char show_level_text;
293
    char wchoice[MAX_WEAPONS];
291
    char wchoice[MAX_WEAPONS];
294
292
295
    uint8_t user_map;
293
    uint8_t user_map;
296
    uint8_t screenfade, menubackground;
294
    uint8_t screenfade, menubackground;
297
    uint8_t shadow_pal;
295
    uint8_t shadow_pal;
298
} user_defs;
296
} user_defs;
299
297
300
extern user_defs ud;
298
extern user_defs ud;
301
299
302
#ifndef ONLY_USERDEFS
300
#ifndef ONLY_USERDEFS
303
301
304
// this is checked against http://eduke32.com/VERSION
302
// this is checked against http://eduke32.com/VERSION
305
extern const char *s_buildDate;
303
extern const char *s_buildDate;
306
304
307
extern char boardfilename[BMAX_PATH], currentboardfilename[BMAX_PATH];
305
extern char boardfilename[BMAX_PATH], currentboardfilename[BMAX_PATH];
308
#define USERMAPMUSICFAKEVOLUME MAXVOLUMES
306
#define USERMAPMUSICFAKEVOLUME MAXVOLUMES
309
#define USERMAPMUSICFAKELEVEL (MAXLEVELS-1)
307
#define USERMAPMUSICFAKELEVEL (MAXLEVELS-1)
310
#define USERMAPMUSICFAKESLOT ((USERMAPMUSICFAKEVOLUME * MAXLEVELS) + USERMAPMUSICFAKELEVEL)
308
#define USERMAPMUSICFAKESLOT ((USERMAPMUSICFAKEVOLUME * MAXLEVELS) + USERMAPMUSICFAKELEVEL)
311
309
312
static inline int G_HaveUserMap(void)
310
static inline int G_HaveUserMap(void)
313
{
311
{
314
    return (boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0);
312
    return (boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0);
315
}
313
}
316
314
317
static inline int Menu_HaveUserMap(void)
315
static inline int Menu_HaveUserMap(void)
318
{
316
{
319
    return (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0);
317
    return (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0);
320
}
318
}
321
319
322
extern const char *G_DefaultRtsFile(void);
320
extern const char *G_DefaultRtsFile(void);
323
321
324
#ifdef LEGACY_ROR
322
#ifdef LEGACY_ROR
325
extern char ror_protectedsectors[MAXSECTORS];
323
extern char ror_protectedsectors[MAXSECTORS];
326
#endif
324
#endif
327
325
328
extern float r_ambientlight;
326
extern float r_ambientlight;
329
327
330
extern int32_t g_BenchmarkMode;
328
extern int32_t g_BenchmarkMode;
331
extern int32_t g_Debug;
329
extern int32_t g_Debug;
332
extern int32_t g_Shareware;
330
extern int32_t g_Shareware;
333
#if !defined LUNATIC
331
#if !defined LUNATIC
334
extern int32_t g_cameraClock;
332
extern int32_t g_cameraClock;
335
extern int32_t g_cameraDistance;
333
extern int32_t g_cameraDistance;
336
#endif
334
#endif
337
extern int32_t g_crosshairSum;
335
extern int32_t g_crosshairSum;
338
extern int32_t g_doQuickSave;
336
extern int32_t g_doQuickSave;
339
extern int32_t g_levelTextTime;
337
extern int32_t g_levelTextTime;
340
extern int32_t g_quitDeadline;
338
extern int32_t g_quitDeadline;
341
extern int32_t g_restorePalette;
339
extern int32_t g_restorePalette;
342
extern int32_t hud_glowingquotes;
340
extern int32_t hud_glowingquotes;
343
extern int32_t hud_showmapname;
341
extern int32_t hud_showmapname;
344
extern int32_t tempwallptr;
342
extern int32_t tempwallptr;
345
extern int32_t ticrandomseed;
343
extern int32_t ticrandomseed;
346
extern int32_t vote_map;
344
extern int32_t vote_map;
347
extern int32_t voting;
345
extern int32_t voting;
348
346
349
extern int32_t MAXCACHE1DSIZE;
347
extern int32_t MAXCACHE1DSIZE;
350
//extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen;
348
//extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen;
351
349
352
#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1)
350
#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1)
353
351
354
extern palette_t CrosshairColors;
352
extern palette_t CrosshairColors;
355
extern palette_t DefaultCrosshairColors;
353
extern palette_t DefaultCrosshairColors;
356
354
357
int32_t A_CheckInventorySprite(spritetype *s);
355
int32_t A_CheckInventorySprite(spritetype *s);
358
int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr,
356
int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr,
359
                       uint8_t s_yr, int16_t s_a, int16_t s_ve, int16_t s_zv, int16_t s_ow, int16_t s_ss);
357
                       uint8_t s_yr, int16_t s_a, int16_t s_ve, int16_t s_zv, int16_t s_ow, int16_t s_ss);
360
int A_Spawn(int spriteNum,int tileNum);
358
int A_Spawn(int spriteNum,int tileNum);
361
int G_DoMoveThings(void);
359
int G_DoMoveThings(void);
362
//int32_t G_EndOfLevel(void);
360
//int32_t G_EndOfLevel(void);
363
361
364
#ifdef YAX_ENABLE
362
#ifdef YAX_ENABLE
365
void Yax_SetBunchZs(int32_t sectnum, int32_t cf, int32_t daz);
363
void Yax_SetBunchZs(int32_t sectnum, int32_t cf, int32_t daz);
366
#else
364
#else
367
#define Yax_SetBunchZs(sectnum, cf, daz)
365
#define Yax_SetBunchZs(sectnum, cf, daz)
368
#endif
366
#endif
369
367
370
#ifdef LUNATIC
368
#ifdef LUNATIC
371
void El_CreateGameState(void);
369
void El_CreateGameState(void);
372
#endif
370
#endif
373
void G_PostCreateGameState(void);
371
void G_PostCreateGameState(void);
374
372
375
void A_SpawnCeilingGlass(int spriteNum,int sectNum,int glassCnt);
373
void A_SpawnCeilingGlass(int spriteNum,int sectNum,int glassCnt);
376
void A_SpawnGlass(int spriteNum,int glassCnt);
374
void A_SpawnGlass(int spriteNum,int glassCnt);
377
void A_SpawnRandomGlass(int spriteNum,int wallNum,int glassCnt);
375
void A_SpawnRandomGlass(int spriteNum,int wallNum,int glassCnt);
378
void A_SpawnWallGlass(int spriteNum,int wallnum,int glassCnt);
376
void A_SpawnWallGlass(int spriteNum,int wallnum,int glassCnt);
379
void G_AddUserQuote(const char *daquote);
377
void G_AddUserQuote(const char *daquote);
380
void G_BackToMenu(void);
378
void G_BackToMenu(void);
381
void G_DumpDebugInfo(void);
379
void G_DumpDebugInfo(void);
382
380
383
const char* G_PrintYourTime(void);
381
const char* G_PrintYourTime(void);
384
const char* G_PrintParTime(void);
382
const char* G_PrintParTime(void);
385
const char* G_PrintDesignerTime(void);
383
const char* G_PrintDesignerTime(void);
386
const char* G_PrintBestTime(void);
384
const char* G_PrintBestTime(void);
387
void G_BonusScreen(int32_t bonusonly);
385
void G_BonusScreen(int32_t bonusonly);
388
//void G_CheatGetInv(void);
386
//void G_CheatGetInv(void);
389
void G_DisplayRest(int32_t smoothratio);
387
void G_DisplayRest(int32_t smoothratio);
390
void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura, int32_t smoothratio);
388
void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura, int32_t smoothratio);
391
void G_DrawBackground(void);
389
void G_DrawBackground(void);
392
void G_DrawFrags(void);
390
void G_DrawFrags(void);
393
void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t horiz, int32_t smoothratio);
391
void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t horiz, int32_t smoothratio);
394
void G_DrawRooms(int32_t playerNum,int32_t smoothratio);
392
void G_DrawRooms(int32_t playerNum,int32_t smoothratio);
395
void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z);
393
void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z);
396
int engineFPSLimit(void);
394
int engineFPSLimit(void);
397
void G_GameExit(const char *msg) ATTRIBUTE((noreturn));
395
void G_GameExit(const char *msg) ATTRIBUTE((noreturn));
398
void G_GameQuit(void);
396
void G_GameQuit(void);
399
void G_GetCrosshairColor(void);
397
void G_GetCrosshairColor(void);
400
void G_HandleLocalKeys(void);
398
void G_HandleLocalKeys(void);
401
void G_HandleSpecialKeys(void);
399
void G_HandleSpecialKeys(void);
402
void G_UpdateAppTitle(void);
400
void G_UpdateAppTitle(void);
403
void G_PrintGameQuotes(int32_t snum);
401
void G_PrintGameQuotes(int32_t snum);
404
//void G_SE40(int32_t smoothratio);
402
//void G_SE40(int32_t smoothratio);
405
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
403
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
406
void G_Shutdown(void);
404
void G_Shutdown(void);
407
void G_UpdatePlayerFromMenu(void);
405
void G_UpdatePlayerFromMenu(void);
408
void M32RunScript(const char *s);
406
void M32RunScript(const char *s);
409
void P_DoQuote(int32_t q,DukePlayer_t *p);
407
void P_DoQuote(int32_t q,DukePlayer_t *p);
410
void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set);
408
void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set);
411
409
412
// Cstat protection mask for (currently) spawned MASKWALL* sprites.
410
// Cstat protection mask for (currently) spawned MASKWALL* sprites.
413
// TODO: look at more cases of cstat=(cstat&PROTECTED)|ADDED in A_Spawn()?
411
// TODO: look at more cases of cstat=(cstat&PROTECTED)|ADDED in A_Spawn()?
414
// 2048+(32+16)+8+4
412
// 2048+(32+16)+8+4
415
#define SPAWN_PROTECT_CSTAT_MASK (CSTAT_SPRITE_NOSHADE|CSTAT_SPRITE_ALIGNMENT_SLAB|CSTAT_SPRITE_XFLIP|CSTAT_SPRITE_YFLIP);
413
#define SPAWN_PROTECT_CSTAT_MASK (CSTAT_SPRITE_NOSHADE|CSTAT_SPRITE_ALIGNMENT_SLAB|CSTAT_SPRITE_XFLIP|CSTAT_SPRITE_YFLIP);
416
414
417
void fadepal(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step);
415
void fadepal(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step);
418
//void fadepaltile(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step,int32_t tile);
416
//void fadepaltile(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step,int32_t tile);
419
void G_InitTimer(int32_t ticspersec);
417
void G_InitTimer(int32_t ticspersec);
420
418
421
static inline int G_GetTeamPalette(int team)
419
static inline int G_GetTeamPalette(int team)
422
{
420
{
423
    static CONSTEXPR int8_t pal[] = { 3, 10, 11, 12 };
421
    static CONSTEXPR int8_t pal[] = { 3, 10, 11, 12 };
424
422
425
    if ((unsigned)team >= ARRAY_SIZE(pal))
423
    if ((unsigned)team >= ARRAY_SIZE(pal))
426
        return 0;
424
        return 0;
427
425
428
    return pal[team];
426
    return pal[team];
429
}
427
}
430
428
431
#define A_CheckSpriteFlags(spriteNum, iType) (((g_tile[sprite[spriteNum].picnum].flags^actor[spriteNum].flags) & iType) != 0)
429
#define A_CheckSpriteFlags(spriteNum, iType) (((g_tile[sprite[spriteNum].picnum].flags^actor[spriteNum].flags) & iType) != 0)
432
// (unsigned)iPicnum check: AMC TC Rusty Nails, bayonet MG alt. fire, iPicnum == -1 (via aplWeaponShoots)
430
// (unsigned)iPicnum check: AMC TC Rusty Nails, bayonet MG alt. fire, iPicnum == -1 (via aplWeaponShoots)
433
#define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (g_tile[iPicnum].flags & iType) != 0)
431
#define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (g_tile[iPicnum].flags & iType) != 0)
434
#define S_StopSound(num) S_StopEnvSound(num, -1)
432
#define S_StopSound(num) S_StopEnvSound(num, -1)
435
433
436
extern int G_StartRTS(int lumpNum, int localPlayer);
434
extern int G_StartRTS(int lumpNum, int localPlayer);
437
435
438
extern void G_MaybeAllocPlayer(int32_t pnum);
436
extern void G_MaybeAllocPlayer(int32_t pnum);
439
437
440
static inline int32_t gameHandleEvents(void)
438
static inline int32_t gameHandleEvents(void)
441
{
439
{
442
    Net_GetPackets();
440
    Net_GetPackets();
443
    return handleevents();
441
    return handleevents();
444
}
442
}
445
443
446
static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk)
444
static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk)
447
{
445
{
448
    int32_t rfreq = tabledivide64(refreshfreq * TICRATE, timerGetClockRate());
446
    int32_t rfreq = tabledivide64(refreshfreq * TICRATE, timerGetClockRate());
449
    uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*TICRATE);
447
    uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*TICRATE);
450
#if 0
448
#if 0
451
    //POGO: additional debug info for testing purposes
449
    //POGO: additional debug info for testing purposes
452
    OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq));
450
    OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq));
453
#endif
451
#endif
454
    return clamp(tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq), 0, 65536);
452
    return clamp(tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq), 0, 65536);
455
}
453
}
456
454
457
static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk)
455
static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk)
458
{
456
{
459
    if (!((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) ||
457
    if (!((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) ||
460
          (g_netServer || ud.multimode > 1) ||
458
          (g_netServer || ud.multimode > 1) ||
461
          ud.recstat == 2) ||
459
          ud.recstat == 2) ||
462
        ud.pause_on)
460
        ud.pause_on)
463
    {
461
    {
464
        return 65536;
462
        return 65536;
465
    }
463
    }
466
464
467
    return calc_smoothratio_demo(totalclk, ototalclk);
465
    return calc_smoothratio_demo(totalclk, ototalclk);
468
}
466
}
469
467
470
// sector effector lotags
468
// sector effector lotags
471
enum
469
enum
472
{
470
{
473
    SE_0_ROTATING_SECTOR              = 0,
471
    SE_0_ROTATING_SECTOR              = 0,
474
    SE_1_PIVOT                        = 1,
472
    SE_1_PIVOT                        = 1,
475
    SE_2_EARTHQUAKE                   = 2,
473
    SE_2_EARTHQUAKE                   = 2,
476
    SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT = 3,
474
    SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT = 3,
477
    SE_4_RANDOM_LIGHTS                = 4,
475
    SE_4_RANDOM_LIGHTS                = 4,
478
    SE_5                              = 5,
476
    SE_5                              = 5,
479
    SE_6_SUBWAY                       = 6,
477
    SE_6_SUBWAY                       = 6,
480
    // ^^ potentially incomplete substitution in code
478
    // ^^ potentially incomplete substitution in code
481
    // vv almost surely complete substitution
479
    // vv almost surely complete substitution
482
    SE_7_TELEPORT                      = 7,
480
    SE_7_TELEPORT                      = 7,
483
    SE_8_UP_OPEN_DOOR_LIGHTS           = 8,
481
    SE_8_UP_OPEN_DOOR_LIGHTS           = 8,
484
    SE_9_DOWN_OPEN_DOOR_LIGHTS         = 9,
482
    SE_9_DOWN_OPEN_DOOR_LIGHTS         = 9,
485
    SE_10_DOOR_AUTO_CLOSE              = 10,
483
    SE_10_DOOR_AUTO_CLOSE              = 10,
486
    SE_11_SWINGING_DOOR                = 11,
484
    SE_11_SWINGING_DOOR                = 11,
487
    SE_12_LIGHT_SWITCH                 = 12,
485
    SE_12_LIGHT_SWITCH                 = 12,
488
    SE_13_EXPLOSIVE                    = 13,
486
    SE_13_EXPLOSIVE                    = 13,
489
    SE_14_SUBWAY_CAR                   = 14,
487
    SE_14_SUBWAY_CAR                   = 14,
490
    SE_15_SLIDING_DOOR                 = 15,
488
    SE_15_SLIDING_DOOR                 = 15,
491
    SE_16_REACTOR                      = 16,
489
    SE_16_REACTOR                      = 16,
492
    SE_17_WARP_ELEVATOR                = 17,
490
    SE_17_WARP_ELEVATOR                = 17,
493
    SE_18_INCREMENTAL_SECTOR_RISE_FALL = 18,
491
    SE_18_INCREMENTAL_SECTOR_RISE_FALL = 18,
494
    SE_19_EXPLOSION_LOWERS_CEILING     = 19,
492
    SE_19_EXPLOSION_LOWERS_CEILING     = 19,
495
    SE_20_STRETCH_BRIDGE               = 20,
493
    SE_20_STRETCH_BRIDGE               = 20,
496
    SE_21_DROP_FLOOR                   = 21,
494
    SE_21_DROP_FLOOR                   = 21,
497
    SE_22_TEETH_DOOR                   = 22,
495
    SE_22_TEETH_DOOR                   = 22,
498
    SE_23_ONE_WAY_TELEPORT             = 23,
496
    SE_23_ONE_WAY_TELEPORT             = 23,
499
    SE_24_CONVEYOR                     = 24,
497
    SE_24_CONVEYOR                     = 24,
500
    SE_25_PISTON                       = 25,
498
    SE_25_PISTON                       = 25,
501
    SE_26                              = 26,
499
    SE_26                              = 26,
502
    SE_27_DEMO_CAM                     = 27,
500
    SE_27_DEMO_CAM                     = 27,
503
    SE_28_LIGHTNING                    = 28,
501
    SE_28_LIGHTNING                    = 28,
504
    SE_29_WAVES                        = 29,
502
    SE_29_WAVES                        = 29,
505
    SE_30_TWO_WAY_TRAIN                = 30,
503
    SE_30_TWO_WAY_TRAIN                = 30,
506
    SE_31_FLOOR_RISE_FALL              = 31,
504
    SE_31_FLOOR_RISE_FALL              = 31,
507
    SE_32_CEILING_RISE_FALL            = 32,
505
    SE_32_CEILING_RISE_FALL            = 32,
508
    SE_33_QUAKE_DEBRIS                 = 33,
506
    SE_33_QUAKE_DEBRIS                 = 33,
509
    SE_34                              = 34,  // XXX
507
    SE_34                              = 34,  // XXX
510
    SE_35                              = 35,  // XXX
508
    SE_35                              = 35,  // XXX
511
    SE_36_PROJ_SHOOTER                 = 36,
509
    SE_36_PROJ_SHOOTER                 = 36,
512
    SE_49_POINT_LIGHT                  = 49,
510
    SE_49_POINT_LIGHT                  = 49,
513
    SE_50_SPOT_LIGHT                   = 50,
511
    SE_50_SPOT_LIGHT                   = 50,
514
    SE_130                             = 130,
512
    SE_130                             = 130,
515
    SE_131                             = 131,
513
    SE_131                             = 131,
516
};
514
};
517
515
518
// sector lotags
516
// sector lotags
519
enum
517
enum
520
{
518
{
521
    ST_0_NO_EFFECT   = 0,
519
    ST_0_NO_EFFECT   = 0,
522
    ST_1_ABOVE_WATER = 1,
520
    ST_1_ABOVE_WATER = 1,
523
    ST_2_UNDERWATER  = 2,
521
    ST_2_UNDERWATER  = 2,
524
    ST_3             = 3,
522
    ST_3             = 3,
525
    // ^^^ maybe not complete substitution in code
523
    // ^^^ maybe not complete substitution in code
526
    ST_9_SLIDING_ST_DOOR     = 9,
524
    ST_9_SLIDING_ST_DOOR     = 9,
527
    ST_15_WARP_ELEVATOR      = 15,
525
    ST_15_WARP_ELEVATOR      = 15,
528
    ST_16_PLATFORM_DOWN      = 16,
526
    ST_16_PLATFORM_DOWN      = 16,
529
    ST_17_PLATFORM_UP        = 17,
527
    ST_17_PLATFORM_UP        = 17,
530
    ST_18_ELEVATOR_DOWN      = 18,
528
    ST_18_ELEVATOR_DOWN      = 18,
531
    ST_19_ELEVATOR_UP        = 19,
529
    ST_19_ELEVATOR_UP        = 19,
532
    ST_20_CEILING_DOOR       = 20,
530
    ST_20_CEILING_DOOR       = 20,
533
    ST_21_FLOOR_DOOR         = 21,
531
    ST_21_FLOOR_DOOR         = 21,
534
    ST_22_SPLITTING_DOOR     = 22,
532
    ST_22_SPLITTING_DOOR     = 22,
535
    ST_23_SWINGING_DOOR      = 23,
533
    ST_23_SWINGING_DOOR      = 23,
536
    ST_25_SLIDING_DOOR       = 25,
534
    ST_25_SLIDING_DOOR       = 25,
537
    ST_26_SPLITTING_ST_DOOR  = 26,
535
    ST_26_SPLITTING_ST_DOOR  = 26,
538
    ST_27_STRETCH_BRIDGE     = 27,
536
    ST_27_STRETCH_BRIDGE     = 27,
539
    ST_28_DROP_FLOOR         = 28,
537
    ST_28_DROP_FLOOR         = 28,
540
    ST_29_TEETH_DOOR         = 29,
538
    ST_29_TEETH_DOOR         = 29,
541
    ST_30_ROTATE_RISE_BRIDGE = 30,
539
    ST_30_ROTATE_RISE_BRIDGE = 30,
542
    ST_31_TWO_WAY_TRAIN      = 31,
540
    ST_31_TWO_WAY_TRAIN      = 31,
543
    // left: ST 32767, 65534, 65535
541
    // left: ST 32767, 65534, 65535
544
};
542
};
545
543
546
544
547
#define G_ModDirSnprintf(buf, size, basename, ...)                                                                                          \
545
#define G_ModDirSnprintf(buf, size, basename, ...)                                                                                          \
548
    (((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/" basename, g_modDir, ##__VA_ARGS__) : Bsnprintf(buf, size, basename, ##__VA_ARGS__)) \
546
    (((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/" basename, g_modDir, ##__VA_ARGS__) : Bsnprintf(buf, size, basename, ##__VA_ARGS__)) \
549
     >= ((int32_t)size) - 1)
547
     >= ((int32_t)size) - 1)
550
548
551
#define G_ModDirSnprintfLite(buf, size, basename) \
549
#define G_ModDirSnprintfLite(buf, size, basename) \
552
    ((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/%s", g_modDir, basename) : Bsnprintf(buf, size, basename))
550
    ((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/%s", g_modDir, basename) : Bsnprintf(buf, size, basename))
553
551
554
static inline void G_NewGame_EnterLevel(void)
552
static inline void G_NewGame_EnterLevel(void)
555
{
553
{
556
    G_NewGame(ud.m_volume_number, ud.m_level_number, ud.m_player_skill);
554
    G_NewGame(ud.m_volume_number, ud.m_level_number, ud.m_player_skill);
557
555
558
    if (G_EnterLevel(MODE_GAME))
556
    if (G_EnterLevel(MODE_GAME))
559
        G_BackToMenu();
557
        G_BackToMenu();
560
}
558
}
561
559
562
static inline int G_GetMusicIdx(const char *str)
560
static inline int G_GetMusicIdx(const char *str)
563
{
561
{
564
    int32_t lev, ep;
562
    int32_t lev, ep;
565
    signed char b1, b2;
563
    signed char b1, b2;
566
564
567
    int numMatches = sscanf(str, "%c%d%c%d", &b1,&ep, &b2,&lev);
565
    int numMatches = sscanf(str, "%c%d%c%d", &b1,&ep, &b2,&lev);
568
566
569
    if (numMatches != 4 || Btoupper(b1) != 'E' || Btoupper(b2) != 'L')
567
    if (numMatches != 4 || Btoupper(b1) != 'E' || Btoupper(b2) != 'L')
570
        return -1;
568
        return -1;
571
569
572
    if ((unsigned)--lev >= MAXLEVELS)
570
    if ((unsigned)--lev >= MAXLEVELS)
573
        return -2;
571
        return -2;
574
572
575
    if (ep == 0)
573
    if (ep == 0)
576
        return (MAXVOLUMES * MAXLEVELS) + lev;
574
        return (MAXVOLUMES * MAXLEVELS) + lev;
577
575
578
    if ((unsigned)--ep >= MAXVOLUMES)
576
    if ((unsigned)--ep >= MAXVOLUMES)
579
        return -2;
577
        return -2;
580
578
581
    return (ep * MAXLEVELS) + lev;
579
    return (ep * MAXLEVELS) + lev;
582
}
580
}
583
581
584
extern void G_PrintCurrentMusic(void);
582
extern void G_PrintCurrentMusic(void);
585
583
586
#ifdef LUNATIC
584
#ifdef LUNATIC
587
void El_SetCON(const char *conluacode);
585
void El_SetCON(const char *conluacode);
588
#endif
586
#endif
589
587
590
EXTERN_INLINE_HEADER void G_SetStatusBarScale(int32_t sc);
588
EXTERN_INLINE_HEADER void G_SetStatusBarScale(int32_t sc);
591
589
592
#endif
590
#endif
593
591
594
#ifdef __cplusplus
592
#ifdef __cplusplus
595
}
593
}
596
#endif
594
#endif
597
595
598
#ifndef ONLY_USERDEFS
596
#ifndef ONLY_USERDEFS
599
597
600
template <typename T>
598
template <typename T>
601
static inline int G_GetViewscreenSizeShift(T const * spr)
599
static inline int G_GetViewscreenSizeShift(T const * spr)
602
{
600
{
603
#if VIEWSCREENFACTOR == 0
601
#if VIEWSCREENFACTOR == 0
604
    UNREFERENCED_PARAMETER(spr);
602
    UNREFERENCED_PARAMETER(spr);
605
    return VIEWSCREENFACTOR;
603
    return VIEWSCREENFACTOR;
606
#else
604
#else
607
    static CONSTEXPR int const mask = (1<<VIEWSCREENFACTOR)-1;
605
    static CONSTEXPR int const mask = (1<<VIEWSCREENFACTOR)-1;
608
    const int rem = (spr->xrepeat & mask) | (spr->yrepeat & mask);
606
    const int rem = (spr->xrepeat & mask) | (spr->yrepeat & mask);
609
607
610
    for (int i=0; i < VIEWSCREENFACTOR; i++)
608
    for (int i=0; i < VIEWSCREENFACTOR; i++)
611
        if (rem & (1<<i))
609
        if (rem & (1<<i))
612
            return i;
610
            return i;
613
611
614
    return VIEWSCREENFACTOR;
612
    return VIEWSCREENFACTOR;
615
#endif
613
#endif
616
}
614
}
617
615
618
#if defined game_c_ || !defined DISABLE_INLINING
616
#if defined game_c_ || !defined DISABLE_INLINING
619
617
620
EXTERN_INLINE void G_SetStatusBarScale(int32_t sc)
618
EXTERN_INLINE void G_SetStatusBarScale(int32_t sc)
621
{
619
{
622
    ud.statusbarscale = clamp(sc, 50, 100);
620
    ud.statusbarscale = clamp(sc, 50, 100);
623
    G_UpdateScreenArea();
621
    G_UpdateScreenArea();
624
}
622
}
625
623
626
#endif
624
#endif
627
625
628
#endif
626
#endif
629
627
630
#endif
628
#endif
631
 
629