Subversion Repositories eduke32

Rev

Rev 8716 | Details | Compare with Previous | Last modification | View Log | RSS feed

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