Subversion Repositories eduke32

Rev

Rev 8650 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8650 Rev 8716
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];
244
        int32_t MouseDigitalFunctions[MAXMOUSEAXES][2];
245
        int32_t MouseAnalogueAxes[MAXMOUSEAXES];
245
        int32_t MouseAnalogueAxes[MAXMOUSEAXES];
246
        int32_t MouseAnalogueScale[MAXMOUSEAXES];
246
        int32_t MouseAnalogueScale[MAXMOUSEAXES];
247
        int32_t JoystickFunctions[MAXJOYBUTTONSANDHATS][2];
247
        int32_t JoystickFunctions[MAXJOYBUTTONSANDHATS][2];
248
        int32_t JoystickDigitalFunctions[MAXJOYAXES][2];
248
        int32_t JoystickDigitalFunctions[MAXJOYAXES][2];
249
        int32_t JoystickAnalogueAxes[MAXJOYAXES];
249
        int32_t JoystickAnalogueAxes[MAXJOYAXES];
250
        int32_t JoystickAnalogueScale[MAXJOYAXES];
250
        int32_t JoystickAnalogueScale[MAXJOYAXES];
251
        int32_t JoystickAnalogueInvert[MAXJOYAXES];
251
        int32_t JoystickAnalogueInvert[MAXJOYAXES];
252
        int32_t JoystickAnalogueDead[MAXJOYAXES];
252
        int32_t JoystickAnalogueDead[MAXJOYAXES];
253
        int32_t JoystickAnalogueSaturate[MAXJOYAXES];
253
        int32_t JoystickAnalogueSaturate[MAXJOYAXES];
254
        uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2];
254
        uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2];
255
255
256
        //
256
        //
257
        // Sound variables
257
        // Sound variables
258
        //
258
        //
259
        int32_t FXVolume;
259
        int32_t FXVolume;
260
        int32_t MusicDevice;
260
        int32_t MusicDevice;
261
        int32_t MusicVolume;
261
        int32_t MusicVolume;
262
        int32_t SoundToggle;
262
        int32_t SoundToggle;
263
        int32_t MusicToggle;
263
        int32_t MusicToggle;
264
        int32_t VoiceToggle;
264
        int32_t VoiceToggle;
265
        int32_t AmbienceToggle;
265
        int32_t AmbienceToggle;
266
266
267
        int32_t NumVoices;
267
        int32_t NumVoices;
268
        int32_t NumChannels;
268
        int32_t NumChannels;
269
        int32_t NumBits;
269
        int32_t NumBits;
270
        int32_t MixRate;
270
        int32_t MixRate;
271
271
272
#ifdef ASS_REVERSESTEREO
272
#ifdef ASS_REVERSESTEREO
273
        int32_t ReverseStereo;
273
        int32_t ReverseStereo;
274
#endif
274
#endif
275
275
276
        int32_t scripthandle;
276
        int32_t scripthandle;
277
        int32_t setupread;
277
        int32_t setupread;
278
278
279
        int32_t CheckForUpdates;
279
        int32_t CheckForUpdates;
280
        int32_t LastUpdateCheck;
280
        int32_t LastUpdateCheck;
281
        int32_t useprecache;
281
        int32_t useprecache;
282
    } config;
282
    } config;
283
283
284
    ud_setup_t setup;
284
    ud_setup_t setup;
285
285
286
    char overhead_on,last_overhead,showweapons;
286
    char overhead_on,last_overhead,showweapons;
287
    char god,warp_on,cashman,eog,showallmap;
287
    char god,warp_on,cashman,eog,showallmap;
288
    char show_help,scrollmode,noclip;
288
    char show_help,scrollmode,noclip;
289
    char ridecule[MAXRIDECULE][MAXRIDECULELENGTH];
289
    char ridecule[MAXRIDECULE][MAXRIDECULELENGTH];
290
    char pwlockout[MAXPWLOCKOUT],rtsname[MAXRTSNAME];
290
    char pwlockout[MAXPWLOCKOUT],rtsname[MAXRTSNAME];
291
    char display_bonus_screen;
291
    char display_bonus_screen;
292
    char show_level_text;
292
    char show_level_text;
293
    char wchoice[MAX_WEAPONS];
293
    char wchoice[MAX_WEAPONS];
294
294
295
    uint8_t user_map;
295
    uint8_t user_map;
296
    uint8_t screenfade, menubackground;
296
    uint8_t screenfade, menubackground;
297
    uint8_t shadow_pal;
297
    uint8_t shadow_pal;
298
} user_defs;
298
} user_defs;
299
299
300
extern user_defs ud;
300
extern user_defs ud;
301
301
302
#ifndef ONLY_USERDEFS
302
#ifndef ONLY_USERDEFS
303
303
304
// this is checked against http://eduke32.com/VERSION
304
// this is checked against http://eduke32.com/VERSION
305
extern const char *s_buildDate;
305
extern const char *s_buildDate;
306
306
307
extern char boardfilename[BMAX_PATH], currentboardfilename[BMAX_PATH];
307
extern char boardfilename[BMAX_PATH], currentboardfilename[BMAX_PATH];
308
#define USERMAPMUSICFAKEVOLUME MAXVOLUMES
308
#define USERMAPMUSICFAKEVOLUME MAXVOLUMES
309
#define USERMAPMUSICFAKELEVEL (MAXLEVELS-1)
309
#define USERMAPMUSICFAKELEVEL (MAXLEVELS-1)
310
#define USERMAPMUSICFAKESLOT ((USERMAPMUSICFAKEVOLUME * MAXLEVELS) + USERMAPMUSICFAKELEVEL)
310
#define USERMAPMUSICFAKESLOT ((USERMAPMUSICFAKEVOLUME * MAXLEVELS) + USERMAPMUSICFAKELEVEL)
311
311
312
static inline int G_HaveUserMap(void)
312
static inline int G_HaveUserMap(void)
313
{
313
{
314
    return (boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0);
314
    return (boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0);
315
}
315
}
316
316
317
static inline int Menu_HaveUserMap(void)
317
static inline int Menu_HaveUserMap(void)
318
{
318
{
319
    return (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0);
319
    return (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0);
320
}
320
}
321
321
322
extern const char *G_DefaultRtsFile(void);
322
extern const char *G_DefaultRtsFile(void);
323
323
324
#ifdef LEGACY_ROR
324
#ifdef LEGACY_ROR
325
extern char ror_protectedsectors[MAXSECTORS];
325
extern char ror_protectedsectors[MAXSECTORS];
326
#endif
326
#endif
327
327
328
extern float r_ambientlight;
328
extern float r_ambientlight;
329
329
330
extern int32_t g_BenchmarkMode;
330
extern int32_t g_BenchmarkMode;
331
extern int32_t g_Debug;
331
extern int32_t g_Debug;
332
extern int32_t g_Shareware;
332
extern int32_t g_Shareware;
333
#if !defined LUNATIC
333
#if !defined LUNATIC
334
extern int32_t g_cameraClock;
334
extern int32_t g_cameraClock;
335
extern int32_t g_cameraDistance;
335
extern int32_t g_cameraDistance;
336
#endif
336
#endif
337
extern int32_t g_crosshairSum;
337
extern int32_t g_crosshairSum;
338
extern int32_t g_doQuickSave;
338
extern int32_t g_doQuickSave;
339
extern int32_t g_levelTextTime;
339
extern int32_t g_levelTextTime;
340
extern int32_t g_quitDeadline;
340
extern int32_t g_quitDeadline;
341
extern int32_t g_restorePalette;
341
extern int32_t g_restorePalette;
342
extern int32_t hud_glowingquotes;
342
extern int32_t hud_glowingquotes;
343
extern int32_t hud_showmapname;
343
extern int32_t hud_showmapname;
344
extern int32_t r_maxfps;
-
 
345
extern int32_t r_maxfpsoffset;
-
 
346
extern int32_t tempwallptr;
344
extern int32_t tempwallptr;
347
extern int32_t ticrandomseed;
345
extern int32_t ticrandomseed;
348
extern int32_t vote_map;
346
extern int32_t vote_map;
349
extern int32_t voting;
347
extern int32_t voting;
350
348
351
extern int32_t MAXCACHE1DSIZE;
349
extern int32_t MAXCACHE1DSIZE;
352
//extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen;
350
//extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen;
353
351
354
#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1)
352
#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1)
355
353
356
extern palette_t CrosshairColors;
354
extern palette_t CrosshairColors;
357
extern palette_t DefaultCrosshairColors;
355
extern palette_t DefaultCrosshairColors;
358
356
359
extern uint64_t g_frameDelay;
-
 
360
static inline uint64_t calcFrameDelay(int const maxFPS, int const offset)
-
 
361
{
-
 
362
    uint64_t const perfFreq = timerGetPerformanceFrequency();
-
 
363
-
 
364
    if (maxFPS == -1)
-
 
365
        return perfFreq / (refreshfreq - ceil(refreshfreq / 60.0));
-
 
366
-
 
367
    return maxFPS ? perfFreq / (maxFPS + offset) : 0;
-
 
368
}
-
 
369
-
 
370
int32_t A_CheckInventorySprite(spritetype *s);
357
int32_t A_CheckInventorySprite(spritetype *s);
371
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,
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,
372
                       uint8_t s_yr, int16_t s_a, int16_t s_ve, int16_t s_zv, int16_t s_ow, int16_t s_ss);
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);
373
int A_Spawn(int spriteNum,int tileNum);
360
int A_Spawn(int spriteNum,int tileNum);
374
int G_DoMoveThings(void);
361
int G_DoMoveThings(void);
375
//int32_t G_EndOfLevel(void);
362
//int32_t G_EndOfLevel(void);
376
363
377
#ifdef YAX_ENABLE
364
#ifdef YAX_ENABLE
378
void Yax_SetBunchZs(int32_t sectnum, int32_t cf, int32_t daz);
365
void Yax_SetBunchZs(int32_t sectnum, int32_t cf, int32_t daz);
379
#else
366
#else
380
#define Yax_SetBunchZs(sectnum, cf, daz)
367
#define Yax_SetBunchZs(sectnum, cf, daz)
381
#endif
368
#endif
382
369
383
#ifdef LUNATIC
370
#ifdef LUNATIC
384
void El_CreateGameState(void);
371
void El_CreateGameState(void);
385
#endif
372
#endif
386
void G_PostCreateGameState(void);
373
void G_PostCreateGameState(void);
387
374
388
void A_SpawnCeilingGlass(int spriteNum,int sectNum,int glassCnt);
375
void A_SpawnCeilingGlass(int spriteNum,int sectNum,int glassCnt);
389
void A_SpawnGlass(int spriteNum,int glassCnt);
376
void A_SpawnGlass(int spriteNum,int glassCnt);
390
void A_SpawnRandomGlass(int spriteNum,int wallNum,int glassCnt);
377
void A_SpawnRandomGlass(int spriteNum,int wallNum,int glassCnt);
391
void A_SpawnWallGlass(int spriteNum,int wallnum,int glassCnt);
378
void A_SpawnWallGlass(int spriteNum,int wallnum,int glassCnt);
392
void G_AddUserQuote(const char *daquote);
379
void G_AddUserQuote(const char *daquote);
393
void G_BackToMenu(void);
380
void G_BackToMenu(void);
394
void G_DumpDebugInfo(void);
381
void G_DumpDebugInfo(void);
395
382
396
const char* G_PrintYourTime(void);
383
const char* G_PrintYourTime(void);
397
const char* G_PrintParTime(void);
384
const char* G_PrintParTime(void);
398
const char* G_PrintDesignerTime(void);
385
const char* G_PrintDesignerTime(void);
399
const char* G_PrintBestTime(void);
386
const char* G_PrintBestTime(void);
400
void G_BonusScreen(int32_t bonusonly);
387
void G_BonusScreen(int32_t bonusonly);
401
//void G_CheatGetInv(void);
388
//void G_CheatGetInv(void);
402
void G_DisplayRest(int32_t smoothratio);
389
void G_DisplayRest(int32_t smoothratio);
403
void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura, int32_t smoothratio);
390
void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura, int32_t smoothratio);
404
void G_DrawBackground(void);
391
void G_DrawBackground(void);
405
void G_DrawFrags(void);
392
void G_DrawFrags(void);
406
void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t horiz, int32_t smoothratio);
393
void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t horiz, int32_t smoothratio);
407
void G_DrawRooms(int32_t playerNum,int32_t smoothratio);
394
void G_DrawRooms(int32_t playerNum,int32_t smoothratio);
408
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);
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);
409
int G_FPSLimit(void);
396
int engineFPSLimit(void);
410
void G_GameExit(const char *msg) ATTRIBUTE((noreturn));
397
void G_GameExit(const char *msg) ATTRIBUTE((noreturn));
411
void G_GameQuit(void);
398
void G_GameQuit(void);
412
void G_GetCrosshairColor(void);
399
void G_GetCrosshairColor(void);
413
void G_HandleLocalKeys(void);
400
void G_HandleLocalKeys(void);
414
void G_HandleSpecialKeys(void);
401
void G_HandleSpecialKeys(void);
415
void G_UpdateAppTitle(void);
402
void G_UpdateAppTitle(void);
416
void G_PrintGameQuotes(int32_t snum);
403
void G_PrintGameQuotes(int32_t snum);
417
//void G_SE40(int32_t smoothratio);
404
//void G_SE40(int32_t smoothratio);
418
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
405
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
419
void G_Shutdown(void);
406
void G_Shutdown(void);
420
void G_UpdatePlayerFromMenu(void);
407
void G_UpdatePlayerFromMenu(void);
421
void M32RunScript(const char *s);
408
void M32RunScript(const char *s);
422
void P_DoQuote(int32_t q,DukePlayer_t *p);
409
void P_DoQuote(int32_t q,DukePlayer_t *p);
423
void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set);
410
void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set);
424
411
425
// Cstat protection mask for (currently) spawned MASKWALL* sprites.
412
// Cstat protection mask for (currently) spawned MASKWALL* sprites.
426
// TODO: look at more cases of cstat=(cstat&PROTECTED)|ADDED in A_Spawn()?
413
// TODO: look at more cases of cstat=(cstat&PROTECTED)|ADDED in A_Spawn()?
427
// 2048+(32+16)+8+4
414
// 2048+(32+16)+8+4
428
#define SPAWN_PROTECT_CSTAT_MASK (CSTAT_SPRITE_NOSHADE|CSTAT_SPRITE_ALIGNMENT_SLAB|CSTAT_SPRITE_XFLIP|CSTAT_SPRITE_YFLIP);
415
#define SPAWN_PROTECT_CSTAT_MASK (CSTAT_SPRITE_NOSHADE|CSTAT_SPRITE_ALIGNMENT_SLAB|CSTAT_SPRITE_XFLIP|CSTAT_SPRITE_YFLIP);
429
416
430
void fadepal(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step);
417
void fadepal(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step);
431
//void fadepaltile(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step,int32_t tile);
418
//void fadepaltile(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step,int32_t tile);
432
void G_InitTimer(int32_t ticspersec);
419
void G_InitTimer(int32_t ticspersec);
433
420
434
static inline int G_GetTeamPalette(int team)
421
static inline int G_GetTeamPalette(int team)
435
{
422
{
436
    static CONSTEXPR int8_t pal[] = { 3, 10, 11, 12 };
423
    static CONSTEXPR int8_t pal[] = { 3, 10, 11, 12 };
437
424
438
    if ((unsigned)team >= ARRAY_SIZE(pal))
425
    if ((unsigned)team >= ARRAY_SIZE(pal))
439
        return 0;
426
        return 0;
440
427
441
    return pal[team];
428
    return pal[team];
442
}
429
}
443
430
444
#define A_CheckSpriteFlags(spriteNum, iType) (((g_tile[sprite[spriteNum].picnum].flags^actor[spriteNum].flags) & iType) != 0)
431
#define A_CheckSpriteFlags(spriteNum, iType) (((g_tile[sprite[spriteNum].picnum].flags^actor[spriteNum].flags) & iType) != 0)
445
// (unsigned)iPicnum check: AMC TC Rusty Nails, bayonet MG alt. fire, iPicnum == -1 (via aplWeaponShoots)
432
// (unsigned)iPicnum check: AMC TC Rusty Nails, bayonet MG alt. fire, iPicnum == -1 (via aplWeaponShoots)
446
#define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (g_tile[iPicnum].flags & iType) != 0)
433
#define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (g_tile[iPicnum].flags & iType) != 0)
447
#define S_StopSound(num) S_StopEnvSound(num, -1)
434
#define S_StopSound(num) S_StopEnvSound(num, -1)
448
435
449
extern int G_StartRTS(int lumpNum, int localPlayer);
436
extern int G_StartRTS(int lumpNum, int localPlayer);
450
437
451
extern void G_MaybeAllocPlayer(int32_t pnum);
438
extern void G_MaybeAllocPlayer(int32_t pnum);
452
439
453
static inline int32_t gameHandleEvents(void)
440
static inline int32_t gameHandleEvents(void)
454
{
441
{
455
    Net_GetPackets();
442
    Net_GetPackets();
456
    return handleevents();
443
    return handleevents();
457
}
444
}
458
445
459
static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk)
446
static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk)
460
{
447
{
461
    int32_t rfreq = tabledivide64(refreshfreq * TICRATE, timerGetClockRate());
448
    int32_t rfreq = tabledivide64(refreshfreq * TICRATE, timerGetClockRate());
462
    uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*TICRATE);
449
    uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*TICRATE);
463
#if 0
450
#if 0
464
    //POGO: additional debug info for testing purposes
451
    //POGO: additional debug info for testing purposes
465
    OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq));
452
    OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq));
466
#endif
453
#endif
467
    return clamp(tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq), 0, 65536);
454
    return clamp(tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq), 0, 65536);
468
}
455
}
469
456
470
static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk)
457
static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk)
471
{
458
{
472
    if (!((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) ||
459
    if (!((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) ||
473
          (g_netServer || ud.multimode > 1) ||
460
          (g_netServer || ud.multimode > 1) ||
474
          ud.recstat == 2) ||
461
          ud.recstat == 2) ||
475
        ud.pause_on)
462
        ud.pause_on)
476
    {
463
    {
477
        return 65536;
464
        return 65536;
478
    }
465
    }
479
466
480
    return calc_smoothratio_demo(totalclk, ototalclk);
467
    return calc_smoothratio_demo(totalclk, ototalclk);
481
}
468
}
482
469
483
// sector effector lotags
470
// sector effector lotags
484
enum
471
enum
485
{
472
{
486
    SE_0_ROTATING_SECTOR              = 0,
473
    SE_0_ROTATING_SECTOR              = 0,
487
    SE_1_PIVOT                        = 1,
474
    SE_1_PIVOT                        = 1,
488
    SE_2_EARTHQUAKE                   = 2,
475
    SE_2_EARTHQUAKE                   = 2,
489
    SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT = 3,
476
    SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT = 3,
490
    SE_4_RANDOM_LIGHTS                = 4,
477
    SE_4_RANDOM_LIGHTS                = 4,
491
    SE_5                              = 5,
478
    SE_5                              = 5,
492
    SE_6_SUBWAY                       = 6,
479
    SE_6_SUBWAY                       = 6,
493
    // ^^ potentially incomplete substitution in code
480
    // ^^ potentially incomplete substitution in code
494
    // vv almost surely complete substitution
481
    // vv almost surely complete substitution
495
    SE_7_TELEPORT                      = 7,
482
    SE_7_TELEPORT                      = 7,
496
    SE_8_UP_OPEN_DOOR_LIGHTS           = 8,
483
    SE_8_UP_OPEN_DOOR_LIGHTS           = 8,
497
    SE_9_DOWN_OPEN_DOOR_LIGHTS         = 9,
484
    SE_9_DOWN_OPEN_DOOR_LIGHTS         = 9,
498
    SE_10_DOOR_AUTO_CLOSE              = 10,
485
    SE_10_DOOR_AUTO_CLOSE              = 10,
499
    SE_11_SWINGING_DOOR                = 11,
486
    SE_11_SWINGING_DOOR                = 11,
500
    SE_12_LIGHT_SWITCH                 = 12,
487
    SE_12_LIGHT_SWITCH                 = 12,
501
    SE_13_EXPLOSIVE                    = 13,
488
    SE_13_EXPLOSIVE                    = 13,
502
    SE_14_SUBWAY_CAR                   = 14,
489
    SE_14_SUBWAY_CAR                   = 14,
503
    SE_15_SLIDING_DOOR                 = 15,
490
    SE_15_SLIDING_DOOR                 = 15,
504
    SE_16_REACTOR                      = 16,
491
    SE_16_REACTOR                      = 16,
505
    SE_17_WARP_ELEVATOR                = 17,
492
    SE_17_WARP_ELEVATOR                = 17,
506
    SE_18_INCREMENTAL_SECTOR_RISE_FALL = 18,
493
    SE_18_INCREMENTAL_SECTOR_RISE_FALL = 18,
507
    SE_19_EXPLOSION_LOWERS_CEILING     = 19,
494
    SE_19_EXPLOSION_LOWERS_CEILING     = 19,
508
    SE_20_STRETCH_BRIDGE               = 20,
495
    SE_20_STRETCH_BRIDGE               = 20,
509
    SE_21_DROP_FLOOR                   = 21,
496
    SE_21_DROP_FLOOR                   = 21,
510
    SE_22_TEETH_DOOR                   = 22,
497
    SE_22_TEETH_DOOR                   = 22,
511
    SE_23_ONE_WAY_TELEPORT             = 23,
498
    SE_23_ONE_WAY_TELEPORT             = 23,
512
    SE_24_CONVEYOR                     = 24,
499
    SE_24_CONVEYOR                     = 24,
513
    SE_25_PISTON                       = 25,
500
    SE_25_PISTON                       = 25,
514
    SE_26                              = 26,
501
    SE_26                              = 26,
515
    SE_27_DEMO_CAM                     = 27,
502
    SE_27_DEMO_CAM                     = 27,
516
    SE_28_LIGHTNING                    = 28,
503
    SE_28_LIGHTNING                    = 28,
517
    SE_29_WAVES                        = 29,
504
    SE_29_WAVES                        = 29,
518
    SE_30_TWO_WAY_TRAIN                = 30,
505
    SE_30_TWO_WAY_TRAIN                = 30,
519
    SE_31_FLOOR_RISE_FALL              = 31,
506
    SE_31_FLOOR_RISE_FALL              = 31,
520
    SE_32_CEILING_RISE_FALL            = 32,
507
    SE_32_CEILING_RISE_FALL            = 32,
521
    SE_33_QUAKE_DEBRIS                 = 33,
508
    SE_33_QUAKE_DEBRIS                 = 33,
522
    SE_34                              = 34,  // XXX
509
    SE_34                              = 34,  // XXX
523
    SE_35                              = 35,  // XXX
510
    SE_35                              = 35,  // XXX
524
    SE_36_PROJ_SHOOTER                 = 36,
511
    SE_36_PROJ_SHOOTER                 = 36,
525
    SE_49_POINT_LIGHT                  = 49,
512
    SE_49_POINT_LIGHT                  = 49,
526
    SE_50_SPOT_LIGHT                   = 50,
513
    SE_50_SPOT_LIGHT                   = 50,
527
    SE_130                             = 130,
514
    SE_130                             = 130,
528
    SE_131                             = 131,
515
    SE_131                             = 131,
529
};
516
};
530
517
531
// sector lotags
518
// sector lotags
532
enum
519
enum
533
{
520
{
534
    ST_0_NO_EFFECT   = 0,
521
    ST_0_NO_EFFECT   = 0,
535
    ST_1_ABOVE_WATER = 1,
522
    ST_1_ABOVE_WATER = 1,
536
    ST_2_UNDERWATER  = 2,
523
    ST_2_UNDERWATER  = 2,
537
    ST_3             = 3,
524
    ST_3             = 3,
538
    // ^^^ maybe not complete substitution in code
525
    // ^^^ maybe not complete substitution in code
539
    ST_9_SLIDING_ST_DOOR     = 9,
526
    ST_9_SLIDING_ST_DOOR     = 9,
540
    ST_15_WARP_ELEVATOR      = 15,
527
    ST_15_WARP_ELEVATOR      = 15,
541
    ST_16_PLATFORM_DOWN      = 16,
528
    ST_16_PLATFORM_DOWN      = 16,
542
    ST_17_PLATFORM_UP        = 17,
529
    ST_17_PLATFORM_UP        = 17,
543
    ST_18_ELEVATOR_DOWN      = 18,
530
    ST_18_ELEVATOR_DOWN      = 18,
544
    ST_19_ELEVATOR_UP        = 19,
531
    ST_19_ELEVATOR_UP        = 19,
545
    ST_20_CEILING_DOOR       = 20,
532
    ST_20_CEILING_DOOR       = 20,
546
    ST_21_FLOOR_DOOR         = 21,
533
    ST_21_FLOOR_DOOR         = 21,
547
    ST_22_SPLITTING_DOOR     = 22,
534
    ST_22_SPLITTING_DOOR     = 22,
548
    ST_23_SWINGING_DOOR      = 23,
535
    ST_23_SWINGING_DOOR      = 23,
549
    ST_25_SLIDING_DOOR       = 25,
536
    ST_25_SLIDING_DOOR       = 25,
550
    ST_26_SPLITTING_ST_DOOR  = 26,
537
    ST_26_SPLITTING_ST_DOOR  = 26,
551
    ST_27_STRETCH_BRIDGE     = 27,
538
    ST_27_STRETCH_BRIDGE     = 27,
552
    ST_28_DROP_FLOOR         = 28,
539
    ST_28_DROP_FLOOR         = 28,
553
    ST_29_TEETH_DOOR         = 29,
540
    ST_29_TEETH_DOOR         = 29,
554
    ST_30_ROTATE_RISE_BRIDGE = 30,
541
    ST_30_ROTATE_RISE_BRIDGE = 30,
555
    ST_31_TWO_WAY_TRAIN      = 31,
542
    ST_31_TWO_WAY_TRAIN      = 31,
556
    // left: ST 32767, 65534, 65535
543
    // left: ST 32767, 65534, 65535
557
};
544
};
558
545
559
546
560
#define G_ModDirSnprintf(buf, size, basename, ...)                                                                                          \
547
#define G_ModDirSnprintf(buf, size, basename, ...)                                                                                          \
561
    (((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/" basename, g_modDir, ##__VA_ARGS__) : Bsnprintf(buf, size, basename, ##__VA_ARGS__)) \
548
    (((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/" basename, g_modDir, ##__VA_ARGS__) : Bsnprintf(buf, size, basename, ##__VA_ARGS__)) \
562
     >= ((int32_t)size) - 1)
549
     >= ((int32_t)size) - 1)
563
550
564
#define G_ModDirSnprintfLite(buf, size, basename) \
551
#define G_ModDirSnprintfLite(buf, size, basename) \
565
    ((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/%s", g_modDir, basename) : Bsnprintf(buf, size, basename))
552
    ((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/%s", g_modDir, basename) : Bsnprintf(buf, size, basename))
566
553
567
static inline void G_NewGame_EnterLevel(void)
554
static inline void G_NewGame_EnterLevel(void)
568
{
555
{
569
    G_NewGame(ud.m_volume_number, ud.m_level_number, ud.m_player_skill);
556
    G_NewGame(ud.m_volume_number, ud.m_level_number, ud.m_player_skill);
570
557
571
    if (G_EnterLevel(MODE_GAME))
558
    if (G_EnterLevel(MODE_GAME))
572
        G_BackToMenu();
559
        G_BackToMenu();
573
}
560
}
574
561
575
static inline int G_GetMusicIdx(const char *str)
562
static inline int G_GetMusicIdx(const char *str)
576
{
563
{
577
    int32_t lev, ep;
564
    int32_t lev, ep;
578
    signed char b1, b2;
565
    signed char b1, b2;
579
566
580
    int numMatches = sscanf(str, "%c%d%c%d", &b1,&ep, &b2,&lev);
567
    int numMatches = sscanf(str, "%c%d%c%d", &b1,&ep, &b2,&lev);
581
568
582
    if (numMatches != 4 || Btoupper(b1) != 'E' || Btoupper(b2) != 'L')
569
    if (numMatches != 4 || Btoupper(b1) != 'E' || Btoupper(b2) != 'L')
583
        return -1;
570
        return -1;
584
571
585
    if ((unsigned)--lev >= MAXLEVELS)
572
    if ((unsigned)--lev >= MAXLEVELS)
586
        return -2;
573
        return -2;
587
574
588
    if (ep == 0)
575
    if (ep == 0)
589
        return (MAXVOLUMES * MAXLEVELS) + lev;
576
        return (MAXVOLUMES * MAXLEVELS) + lev;
590
577
591
    if ((unsigned)--ep >= MAXVOLUMES)
578
    if ((unsigned)--ep >= MAXVOLUMES)
592
        return -2;
579
        return -2;
593
580
594
    return (ep * MAXLEVELS) + lev;
581
    return (ep * MAXLEVELS) + lev;
595
}
582
}
596
583
597
extern void G_PrintCurrentMusic(void);
584
extern void G_PrintCurrentMusic(void);
598
585
599
#ifdef LUNATIC
586
#ifdef LUNATIC
600
void El_SetCON(const char *conluacode);
587
void El_SetCON(const char *conluacode);
601
#endif
588
#endif
602
589
603
EXTERN_INLINE_HEADER void G_SetStatusBarScale(int32_t sc);
590
EXTERN_INLINE_HEADER void G_SetStatusBarScale(int32_t sc);
604
591
605
#endif
592
#endif
606
593
607
#ifdef __cplusplus
594
#ifdef __cplusplus
608
}
595
}
609
#endif
596
#endif
610
597
611
#ifndef ONLY_USERDEFS
598
#ifndef ONLY_USERDEFS
612
599
613
template <typename T>
600
template <typename T>
614
static inline int G_GetViewscreenSizeShift(T const * spr)
601
static inline int G_GetViewscreenSizeShift(T const * spr)
615
{
602
{
616
#if VIEWSCREENFACTOR == 0
603
#if VIEWSCREENFACTOR == 0
617
    UNREFERENCED_PARAMETER(spr);
604
    UNREFERENCED_PARAMETER(spr);
618
    return VIEWSCREENFACTOR;
605
    return VIEWSCREENFACTOR;
619
#else
606
#else
620
    static CONSTEXPR int const mask = (1<<VIEWSCREENFACTOR)-1;
607
    static CONSTEXPR int const mask = (1<<VIEWSCREENFACTOR)-1;
621
    const int rem = (spr->xrepeat & mask) | (spr->yrepeat & mask);
608
    const int rem = (spr->xrepeat & mask) | (spr->yrepeat & mask);
622
609
623
    for (int i=0; i < VIEWSCREENFACTOR; i++)
610
    for (int i=0; i < VIEWSCREENFACTOR; i++)
624
        if (rem & (1<<i))
611
        if (rem & (1<<i))
625
            return i;
612
            return i;
626
613
627
    return VIEWSCREENFACTOR;
614
    return VIEWSCREENFACTOR;
628
#endif
615
#endif
629
}
616
}
630
617
631
#if defined game_c_ || !defined DISABLE_INLINING
618
#if defined game_c_ || !defined DISABLE_INLINING
632
619
633
EXTERN_INLINE void G_SetStatusBarScale(int32_t sc)
620
EXTERN_INLINE void G_SetStatusBarScale(int32_t sc)
634
{
621
{
635
    ud.statusbarscale = clamp(sc, 50, 100);
622
    ud.statusbarscale = clamp(sc, 50, 100);
636
    G_UpdateScreenArea();
623
    G_UpdateScreenArea();
637
}
624
}
638
625
639
#endif
626
#endif
640
627
641
#endif
628
#endif
642
629
643
#endif
630
#endif
644
 
631