Subversion Repositories eduke32

Rev

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

Rev Author Line No. Line
1677 terminx 1
//-------------------------------------------------------------------------
2
/*
3
Copyright (C) 2010 EDuke32 developers and contributors
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
19
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
*/
21
//-------------------------------------------------------------------------
22
 
23
#ifndef __game_h__
24
#define __game_h__
25
 
26
#define USERQUOTE_LEFTOFFSET    5
27
#define USERQUOTE_RIGHTOFFSET   14
28
 
29
enum GametypeFlags_t {
30
    GAMETYPE_COOP                   = 0x00000001,
31
    GAMETYPE_WEAPSTAY               = 0x00000002,
32
    GAMETYPE_FRAGBAR                = 0x00000004,
33
    GAMETYPE_SCORESHEET             = 0x00000008,
34
    GAMETYPE_DMSWITCHES             = 0x00000010,
35
    GAMETYPE_COOPSPAWN              = 0x00000020,
36
    GAMETYPE_ACCESSCARDSPRITES      = 0x00000040,
37
    GAMETYPE_COOPVIEW               = 0x00000080,
38
    GAMETYPE_COOPSOUND              = 0x00000100,
39
    GAMETYPE_OTHERPLAYERSINMAP      = 0x00000200,
40
    GAMETYPE_ITEMRESPAWN            = 0x00000400,
41
    GAMETYPE_MARKEROPTION           = 0x00000800,
42
    GAMETYPE_PLAYERSFRIENDLY        = 0x00001000,
43
    GAMETYPE_FIXEDRESPAWN           = 0x00002000,
44
    GAMETYPE_ACCESSATSTART          = 0x00004000,
45
    GAMETYPE_PRESERVEINVENTORYDEATH = 0x00008000,
46
    GAMETYPE_TDM                    = 0x00010000,
47
    GAMETYPE_TDMSPAWN               = 0x00020000
48
};
49
 
50
// logo control
51
enum LogoFlags_t {
52
    LOGO_ENABLED           = 0x00000001,
53
    LOGO_PLAYANIM          = 0x00000002,
54
    LOGO_PLAYMUSIC         = 0x00000004,
55
    LOGO_3DRSCREEN         = 0x00000008,
56
    LOGO_TITLESCREEN       = 0x00000010,
57
    LOGO_DUKENUKEM         = 0x00000020,
58
    LOGO_THREEDEE          = 0x00000040,
59
    LOGO_PLUTOPAKSPRITE    = 0x00000080,
60
    LOGO_SHAREWARESCREENS  = 0x00000100,
61
    LOGO_TENSCREEN         = 0x00000200
62
};
63
 
1802 terminx 64
typedef enum basepal_ {
65
    BASEPAL = 0,
66
    WATERPAL,
67
    SLIMEPAL,
68
    DREALMSPAL,
69
    TITLEPAL,
2223 helixhorne 70
    ENDINGPAL,  // 5
1802 terminx 71
    ANIMPAL,
72
    BASEPALCOUNT
73
} basepal_t;
74
 
1677 terminx 75
void A_DeleteSprite(int32_t s);
76
 
77
typedef struct {
78
    vec3_t camera;
79
    int32_t const_visibility,uw_framerate;
80
    int32_t camera_time,folfvel,folavel,folx,foly,fola;
81
    int32_t reccnt,crosshairscale;
82
 
83
    int32_t runkey_mode,statusbarscale,mouseaiming,weaponswitch,drawweapon;   // JBF 20031125
84
    int32_t democams,color,msgdisptime,statusbarmode;
85
    int32_t m_noexits,noexits,autovote,automsg,idplayers;
86
    int32_t team, viewbob, weaponsway, althud, weaponscale, textscale;
87
 
88
    int32_t entered_name,screen_tilting,shadows,fta_on,executions,auto_run;
89
    int32_t coords,tickrate,levelstats,m_coop,coop,screen_size,lockout,crosshair;
90
    int32_t playerai,angleinterpolation,obituaries;
91
 
92
    int32_t respawn_monsters,respawn_items,respawn_inventory,recstat,monsters_off,brightness;
93
    int32_t m_respawn_items,m_respawn_monsters,m_respawn_inventory,m_recstat,m_monsters_off,detail;
94
    int32_t m_ffire,ffire,m_player_skill,m_level_number,m_volume_number,multimode;
95
    int32_t player_skill,level_number,volume_number,m_marker,marker,mouseflip;
96
 
97
    int32_t configversion;
98
 
99
    int16_t cameraang, camerasect, camerahoriz;
100
    int16_t pause_on,from_bonus;
101
    int16_t camerasprite,last_camsprite;
102
    int16_t last_level,secretlevel, bgstretch;
103
 
104
    struct {
105
        int32_t UseJoystick;
106
        int32_t UseMouse;
107
        int32_t AutoAim;
108
        int32_t ShowOpponentWeapons;
109
        int32_t MouseDeadZone,MouseBias;
110
        int32_t SmoothInput;
111
 
112
        // JBF 20031211: Store the input settings because
113
        // (currently) jmact can't regurgitate them
114
        int32_t MouseFunctions[MAXMOUSEBUTTONS][2];
115
        int32_t MouseDigitalFunctions[MAXMOUSEAXES][2];
116
        int32_t MouseAnalogueAxes[MAXMOUSEAXES];
117
        int32_t MouseAnalogueScale[MAXMOUSEAXES];
118
        int32_t JoystickFunctions[MAXJOYBUTTONS][2];
119
        int32_t JoystickDigitalFunctions[MAXJOYAXES][2];
120
        int32_t JoystickAnalogueAxes[MAXJOYAXES];
121
        int32_t JoystickAnalogueScale[MAXJOYAXES];
122
        int32_t JoystickAnalogueDead[MAXJOYAXES];
123
        int32_t JoystickAnalogueSaturate[MAXJOYAXES];
124
        uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2];
125
 
126
        //
127
        // Sound variables
128
        //
129
        int32_t FXDevice;
130
        int32_t MusicDevice;
131
        int32_t FXVolume;
132
        int32_t MusicVolume;
133
        int32_t SoundToggle;
134
        int32_t MusicToggle;
135
        int32_t VoiceToggle;
136
        int32_t AmbienceToggle;
137
 
138
        int32_t NumVoices;
139
        int32_t NumChannels;
140
        int32_t NumBits;
141
        int32_t MixRate;
142
 
143
        int32_t ReverseStereo;
144
 
145
        //
146
        // Screen variables
147
        //
148
 
149
        int32_t ScreenMode;
150
 
151
        int32_t ScreenWidth;
152
        int32_t ScreenHeight;
153
        int32_t ScreenBPP;
154
 
155
        int32_t ForceSetup;
156
        int32_t NoAutoLoad;
157
 
158
        int32_t scripthandle;
159
        int32_t setupread;
160
 
161
        int32_t CheckForUpdates;
162
        int32_t LastUpdateCheck;
163
        int32_t useprecache;
164
    } config;
165
 
166
    char overhead_on,last_overhead,showweapons;
167
    char god,warp_on,cashman,eog,showallmap;
2454 helixhorne 168
    char show_help,scrollmode,noclip;
1677 terminx 169
    char ridecule[10][40];
170
    char savegame[10][22];
171
    char pwlockout[128],rtsname[128];
172
    char display_bonus_screen;
173
    char show_level_text;
174
} user_defs;
175
 
176
 
177
extern cactype cac[];
178
 
179
// this is checked against http://eduke32.com/VERSION
180
extern const char *s_buildDate;
2561 helixhorne 181
extern const char *g_gameNamePtr;
182
extern const char *g_rtsNamePtr;
2726 hendricks2 183
 
1937 hendricks2 184
extern char **g_scriptModules;
2495 hendricks2 185
extern int32_t g_scriptModulesNum;
2726 hendricks2 186
 
1677 terminx 187
extern char CheatStrings[][MAXCHEATLEN];
188
extern char boardfilename[BMAX_PATH], currentboardfilename[BMAX_PATH];
189
extern char boardfilename[BMAX_PATH];
2726 hendricks2 190
 
191
extern const char *defaultrtsfilename[GAMECOUNT];
192
extern const char *G_DefaultRtsFile(void);
193
 
1677 terminx 194
extern char g_modDir[BMAX_PATH];
195
extern char inputloc;
196
extern char ror_protectedsectors[MAXSECTORS];
197
 
198
extern float r_ambientlight;
199
 
200
extern int32_t althud_flashing;
201
extern int32_t althud_numberpal;
202
extern int32_t althud_numbertile;
203
extern int32_t althud_shadows;
204
extern int32_t cacnum;
2265 helixhorne 205
//extern int32_t drawing_ror;
1677 terminx 206
extern int32_t g_Shareware;
207
extern int32_t g_cameraClock;
208
extern int32_t g_cameraDistance;
209
extern int32_t g_cameraDistance;
210
extern int32_t g_crosshairSum;
211
extern int32_t g_doQuickSave;
212
extern int32_t g_forceWeaponChoice;
2879 helixhorne 213
extern int32_t g_fakeMultiMode;
1677 terminx 214
extern int32_t g_levelTextTime;
215
extern int32_t g_noSetup;
216
extern int32_t g_quitDeadline;
217
extern int32_t g_restorePalette;
218
extern int32_t hud_glowingquotes;
219
extern int32_t hud_showmapname;
220
extern int32_t lastvisinc;
221
extern int32_t rts_numlumps;
222
extern int32_t qsetmode;
223
extern int32_t quotebot;
224
extern int32_t quotebotgoal;
225
extern int32_t r_maxfps;
226
extern int32_t tempwallptr;
227
extern int32_t ticrandomseed;
228
extern int32_t vote_map;
229
extern int32_t voting;
230
 
2265 helixhorne 231
//extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen;
1677 terminx 232
 
233
extern palette_t CrosshairColors;
234
extern palette_t DefaultCrosshairColors;
235
 
236
extern uint32_t g_frameDelay;
237
 
2518 helixhorne 238
extern uint8_t water_pal[768],slime_pal[768],title_pal[768],dre_alms[768],ending_pal[768];
1772 plagman 239
extern uint8_t *basepaltable[BASEPALCOUNT];
2518 helixhorne 240
extern int8_t g_noFloorPal[MAXPALOOKUPS];
1772 plagman 241
 
1677 terminx 242
extern user_defs ud;
243
 
244
int32_t A_CheckInventorySprite(spritetype *s);
245
int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int32_t s_pn,int32_t s_s,int32_t s_xr,int32_t s_yr,int32_t s_a,int32_t s_ve,int32_t s_zv,int32_t s_ow,int32_t s_ss);
246
int32_t A_Spawn(int32_t j,int32_t pn);
247
int32_t G_DoMoveThings(void);
2265 helixhorne 248
//int32_t G_EndOfLevel(void);
1677 terminx 249
int32_t G_GameTextLen(int32_t x,const char *t);
250
int32_t G_PrintGameText(int32_t f,int32_t tile,int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t o,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z);
251
int32_t GetTime(void);
1712 helixhorne 252
int32_t kopen4loadfrommod(const char *filename,char searchfirst);
1677 terminx 253
int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t sb);
2640 helixhorne 254
int32_t mpgametext(int32_t y,const char *t,int32_t s,int32_t dabits);
1677 terminx 255
int32_t startwin_run(void);
256
 
1924 helixhorne 257
#ifdef YAX_ENABLE
258
void Yax_SetBunchZs(int32_t sectnum, int32_t cf, int32_t daz);
259
#else
260
#define Yax_SetBunchZs(sectnum, cf, daz)
261
#endif
262
 
1677 terminx 263
void A_SpawnCeilingGlass(int32_t i,int32_t sectnum,int32_t n);
264
void A_SpawnGlass(int32_t i,int32_t n);
265
void A_SpawnRandomGlass(int32_t i,int32_t wallnum,int32_t n);
266
void A_SpawnWallGlass(int32_t i,int32_t wallnum,int32_t n);
267
void G_AddUserQuote(const char *daquote);
268
void G_BackToMenu(void);
269
void G_BonusScreen(int32_t bonusonly);
2265 helixhorne 270
//void G_CheatGetInv(void);
1677 terminx 271
void G_DisplayRest(int32_t smoothratio);
2881 helixhorne 272
void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothratio);
1677 terminx 273
void G_DrawBackground(void);
274
void G_DrawFrags(void);
2217 helixhorne 275
void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, int32_t smoothratio);
1677 terminx 276
void G_DrawRooms(int32_t snum,int32_t smoothratio);
277
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);
278
void G_DrawTile(int32_t x,int32_t y,int32_t tilenum,int32_t shade,int32_t orientation);
279
void G_DrawTilePal(int32_t x,int32_t y,int32_t tilenum,int32_t shade,int32_t orientation,int32_t p);
280
void G_DrawTilePalSmall(int32_t x,int32_t y,int32_t tilenum,int32_t shade,int32_t orientation,int32_t p);
281
void G_DrawTileSmall(int32_t x,int32_t y,int32_t tilenum,int32_t shade,int32_t orientation);
282
void G_FadePalette(int32_t r,int32_t g,int32_t b,int32_t e);
1740 helixhorne 283
void G_GameExit(const char *t) ATTRIBUTE((noreturn));
1677 terminx 284
void G_GameQuit(void);
285
void G_GetCrosshairColor(void);
286
void G_HandleLocalKeys(void);
287
void G_HandleSpecialKeys(void);
2948 helixhorne 288
void G_PrintGameQuotes(int32_t snum);
2265 helixhorne 289
//void G_SE40(int32_t smoothratio);
1677 terminx 290
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
291
void G_SetStatusBarScale(int32_t sc);
292
void G_Shutdown(void);
293
void G_UpdatePlayerFromMenu(void);
294
void M32RunScript(const char *s);
295
void P_DoQuote(int32_t q,DukePlayer_t *p);
2728 hendricks2 296
extern int32_t textsc(int32_t sc);
1772 plagman 297
void P_SetGamePalette(DukePlayer_t *player,uint8_t palid,int32_t set);
1712 helixhorne 298
int32_t app_main(int32_t argc,const char **argv);
1677 terminx 299
void fadepal(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step);
2265 helixhorne 300
//void fadepaltile(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step,int32_t tile);
1677 terminx 301
 
302
static inline int32_t G_GetTeamPalette(int32_t team)
303
{
304
    int8_t pal[] = { 3, 10, 11, 12 };
305
 
2266 helixhorne 306
    if ((unsigned)team >= (sizeof(pal)/sizeof(pal[0])))
1677 terminx 307
        return 0;
308
 
309
    return pal[team];
310
}
311
 
312
#if defined(_WIN32)
313
int32_t G_GetVersionFromWebsite(char *buffer);
314
#endif
315
 
1802 terminx 316
#ifdef RENDERTYPEWIN
317
void app_crashhandler(void);
318
#ifdef USE_OPENGL
1677 terminx 319
extern char forcegl;
320
#endif
321
#endif
322
 
323
#define minitextshade(x, y, t, s, p, sb) minitext_(x,y,t,s,p,sb)
324
#define minitext(x, y, t, p, sb) minitext_(x,y,t,0,p,sb)
325
#define menutext(x,y,s,p,t) menutext_(x,y,s,p,(char *)OSD_StripColors(menutextbuf,t),10+16)
326
#define gametext(x,y,t,s,dabits) G_PrintGameText(0,STARTALPHANUM, x,y,t,s,0,dabits,0, 0, xdim-1, ydim-1, 65536)
327
#define gametextscaled(x,y,t,s,dabits) G_PrintGameText(1,STARTALPHANUM, x,y,t,s,0,dabits,0, 0, xdim-1, ydim-1, 65536)
328
#define gametextpal(x,y,t,s,p) G_PrintGameText(0,STARTALPHANUM, x,y,t,s,p,26,0, 0, xdim-1, ydim-1, 65536)
329
#define gametextpalbits(x,y,t,s,p,dabits) G_PrintGameText(0,STARTALPHANUM, x,y,t,s,p,dabits,0, 0, xdim-1, ydim-1, 65536)
330
#define A_CheckSpriteFlags(iActor, iType) (((SpriteFlags[sprite[iActor].picnum]^actor[iActor].flags) & iType) != 0)
2268 helixhorne 331
// (unsigned)iPicnum check: AMC TC Rusty Nails, bayonet MG alt. fire, iPicnum == -1 (via aplWeaponShoots)
332
#define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (SpriteFlags[iPicnum] & iType) != 0)
1677 terminx 333
#define G_EnterText(x, y, t, dalen, c) _EnterText(0,x,y,t,dalen,c)
334
#define Net_EnterText(x, y, t, dalen, c) _EnterText(1,x,y,t,dalen,c)
335
#define S_StopSound(num) S_StopEnvSound(num, -1)
336
 
2996 helixhorne 337
static inline void G_HandleAsync(void)
338
{
339
    handleevents();
340
    Net_GetPackets();
341
}
342
 
3007 helixhorne 343
static inline int32_t calc_smoothratio(int32_t totalclk, int32_t ototalclk)
344
{
345
    return clamp((totalclk-ototalclk)*(65536/TICSPERFRAME), 0, 65536);
346
}
347
 
2970 helixhorne 348
// sector effector lotags
349
enum {
3008 helixhorne 350
    SE_0_ROTATING_SECTOR = 0,
351
    SE_1_PIVOT = 1,
352
    SE_2_EARTHQUAKE = 2,
353
    SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT = 3,
354
    SE_4_RANDOM_LIGHTS = 4,
355
    SE_5 = 5,
356
    SE_6_SUBWAY = 6,
357
    // ^^ potentially incomplete substitution in code
358
    // vv almost surely complete substitution
359
    SE_7_TELEPORT = 7,
360
    SE_8_UP_OPEN_DOOR_LIGHTS = 8,
361
    SE_9_DOWN_OPEN_DOOR_LIGHTS = 9,
362
    SE_10_DOOR_AUTO_CLOSE = 10,
363
    SE_11_SWINGING_DOOR = 11,
364
    SE_12_LIGHT_SWITCH = 12,
365
    SE_13_EXPLOSIVE = 13,
366
    SE_14_SUBWAY_CAR = 14,
367
    SE_15_SLIDING_DOOR = 15,
2970 helixhorne 368
    SE_16_REACTOR = 16,
369
    SE_17_WARP_ELEVATOR = 17,
3008 helixhorne 370
    SE_18_INCREMENTAL_SECTOR_RISE_FALL = 18,
371
    SE_19_EXPLOSION_LOWERS_CEILING = 19,
372
    SE_20_STRETCH_BRIDGE = 20,
2970 helixhorne 373
    SE_21_DROP_FLOOR = 21,
3008 helixhorne 374
    SE_22_TEETH_DOOR = 22,
375
    SE_23_ONE_WAY_TELEPORT = 23,
2970 helixhorne 376
    SE_24_CONVEYOR = 24,
377
    SE_25_PISTON = 25,
378
    SE_26 = 26,
379
    SE_27_DEMO_CAM = 27,
380
    SE_28_LIGHTNING = 28,
381
    SE_29_WAVES = 29,
382
    SE_30_TWO_WAY_TRAIN = 30,
383
    SE_31_FLOOR_RISE_FALL = 31,
384
    SE_32_CEILING_RISE_FALL = 32,
385
    SE_33_QUAKE_DEBRIS = 33,
3008 helixhorne 386
    SE_34 = 34,  // XXX
387
    SE_35 = 35,  // XXX
2970 helixhorne 388
    SE_36_PROJ_SHOOTER = 36,
3053 terminx 389
    SE_49_POINT_LIGHT = 49,
390
    SE_50_SPOT_LIGHT = 50,
2970 helixhorne 391
};
392
 
393
// sector lotags
394
enum {
3008 helixhorne 395
    // left: ST 1 and 2
396
    ST_9_SLIDING_ST_DOOR = 9,
2970 helixhorne 397
    ST_15_WARP_ELEVATOR = 15,
3008 helixhorne 398
    ST_16_PLATFORM_DOWN = 16,
399
    ST_17_PLATFORM_UP = 17,
400
    ST_18_ELEVATOR_DOWN = 18,
401
    ST_19_ELEVATOR_UP = 19,
2970 helixhorne 402
    ST_20_CEILING_DOOR = 20,
403
    ST_21_FLOOR_DOOR = 21,
404
    ST_22_SPLITTING_DOOR = 22,
3008 helixhorne 405
    ST_23_SWINGING_DOOR = 23,
406
    ST_25_SLIDING_DOOR = 25,
2970 helixhorne 407
    ST_26_SPLITTING_ST_DOOR = 26,
3008 helixhorne 408
    ST_27_STRETCH_BRIDGE = 27,
2970 helixhorne 409
    ST_28_DROP_FLOOR = 28,
410
    ST_29_TEETH_DOOR = 29,
411
    ST_30_ROTATE_RISE_BRIDGE = 30,
412
    ST_31_TWO_WAY_TRAIN = 31,
3008 helixhorne 413
    // left: ST 32767, 65534, 65535
2970 helixhorne 414
};
415
 
3005 helixhorne 416
// Cheats
417
// KEEPINSYNC game.c: char CheatStrings[][]
418
enum cheatindex_t
419
{
420
    CHEAT_CORNHOLIO,  // 0
421
    CHEAT_STUFF,
422
    CHEAT_SCOTTY,
423
    CHEAT_COORDS,
424
    CHEAT_VIEW,
425
    CHEAT_TIME,  // 5
426
    CHEAT_UNLOCK,
427
    CHEAT_CASHMAN,
428
    CHEAT_ITEMS,
429
    CHEAT_RATE,
430
    CHEAT_SKILL,  // 10
431
    CHEAT_BETA,
432
    CHEAT_HYPER,
433
    CHEAT_MONSTERS,
434
    CHEAT_RESERVED,
435
    CHEAT_RESERVED2,  // 15
436
    CHEAT_TODD,
437
    CHEAT_SHOWMAP,
438
    CHEAT_KROZ,
439
    CHEAT_ALLEN,
440
    CHEAT_CLIP,  // 20
441
    CHEAT_WEAPONS,
442
    CHEAT_INVENTORY,
443
    CHEAT_KEYS,
444
    CHEAT_DEBUG,
445
    CHEAT_RESERVED3,  // 25
446
    CHEAT_COMEGETSOME,
447
};
448
 
449
 
2997 helixhorne 450
# define G_ModDirSnprintf(buf, size, basename, ...) \
451
( \
452
    ( \
453
        (g_modDir[0] != '/') ? \
454
            Bsnprintf(buf, size, "%s/" basename, g_modDir, ## __VA_ARGS__) : \
455
            Bsnprintf(buf, size, basename, ## __VA_ARGS__) \
456
    ) >= ((int32_t)size)-1 \
457
)
458
 
1693 helixhorne 459
#endif