2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Constants & prototypes which pertain to the game only
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GAME_H
|
|
|
|
#define _GAME_H
|
|
|
|
|
2013-12-26 04:18:28 +00:00
|
|
|
#include <physfs.h>
|
2009-12-02 13:49:54 +00:00
|
|
|
#include "pstypes.h"
|
2010-01-27 04:30:31 +00:00
|
|
|
#include "window.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#ifdef __cplusplus
|
2013-12-31 00:11:05 +00:00
|
|
|
#include <cstdint>
|
2014-06-26 02:24:32 +00:00
|
|
|
#include "pack.h"
|
2013-12-29 04:28:07 +00:00
|
|
|
#include "segnum.h"
|
2014-10-25 15:19:20 +00:00
|
|
|
#include "fwdvalptridx.h"
|
2012-11-11 22:12:51 +00:00
|
|
|
|
2013-08-08 20:07:29 +00:00
|
|
|
#define DESIGNATED_GAME_FPS 30 // assuming the original intended Framerate was 30
|
|
|
|
#define DESIGNATED_GAME_FRAMETIME (F1_0/DESIGNATED_GAME_FPS)
|
2012-11-11 22:12:51 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
#ifdef NDEBUG
|
2013-08-08 20:07:29 +00:00
|
|
|
#define MINIMUM_FPS DESIGNATED_GAME_FPS
|
2008-09-30 00:07:07 +00:00
|
|
|
#define MAXIMUM_FPS 200
|
|
|
|
#else
|
2013-08-08 20:07:29 +00:00
|
|
|
#define MINIMUM_FPS 1
|
2008-09-30 00:07:07 +00:00
|
|
|
#define MAXIMUM_FPS 1000
|
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2010-02-07 07:28:49 +00:00
|
|
|
struct object;
|
|
|
|
|
2009-12-02 13:49:54 +00:00
|
|
|
extern struct window *Game_wind;
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
// from mglobal.c
|
2008-09-30 00:07:07 +00:00
|
|
|
extern fix FrameTime; // time in seconds since last frame
|
2010-12-22 00:17:59 +00:00
|
|
|
extern fix64 GameTime64; // time in game (sum of FrameTime)
|
2013-08-08 20:07:29 +00:00
|
|
|
extern int d_tick_count; // increments according to DESIGNATED_GAME_FRAMETIME
|
|
|
|
extern int d_tick_step; // true once in interval of DESIGNATED_GAME_FRAMETIME
|
2010-12-22 00:17:59 +00:00
|
|
|
extern fix64 Next_laser_fire_time; // Time at which player can next fire his selected laser.
|
|
|
|
extern fix64 Last_laser_fired_time;
|
|
|
|
extern fix64 Next_missile_fire_time; // Time at which player can next fire his selected missile.
|
|
|
|
extern fix64 Next_flare_fire_time;
|
2006-03-20 17:12:09 +00:00
|
|
|
extern fix Laser_delay_time; // Delay between laser fires.
|
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2010-02-07 07:28:49 +00:00
|
|
|
extern struct object *Missile_viewer;
|
2009-02-02 08:49:58 +00:00
|
|
|
extern int Missile_viewer_sig;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
#define CV_NONE 0
|
|
|
|
#define CV_ESCORT 1
|
|
|
|
#define CV_REAR 2
|
|
|
|
#define CV_COOP 3
|
|
|
|
#define CV_MARKER 4
|
|
|
|
|
|
|
|
extern int Coop_view_player[2]; // left & right
|
|
|
|
extern int Marker_viewer_num[2]; // left & right
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// constants for ft_preference
|
|
|
|
#define FP_RIGHT 0
|
|
|
|
#define FP_UP 1
|
|
|
|
#define FP_FORWARD 2 // this is the default
|
|
|
|
#define FP_LEFT 3
|
|
|
|
#define FP_DOWN 4
|
|
|
|
#define FP_FIRST_TIME 5
|
|
|
|
|
|
|
|
extern int ft_preference;
|
|
|
|
|
|
|
|
// The following bits define the game modes.
|
|
|
|
#define GM_EDITOR 1 // You came into the game from the editor
|
2007-12-29 14:18:49 +00:00
|
|
|
// #define GM_SERIAL 2 // You are in serial mode // OBSOLETE
|
2006-03-20 17:12:09 +00:00
|
|
|
#define GM_NETWORK 4 // You are in network mode
|
|
|
|
#define GM_MULTI_ROBOTS 8 // You are in a multiplayer mode with robots.
|
|
|
|
#define GM_MULTI_COOP 16 // You are in a multiplayer mode and can't hurt other players.
|
2007-12-29 14:18:49 +00:00
|
|
|
// #define GM_MODEM 32 // You are in a modem (serial) game // OBSOLETE
|
2006-03-20 17:12:09 +00:00
|
|
|
#define GM_UNKNOWN 64 // You are not in any mode, kind of dangerous...
|
|
|
|
#define GM_GAME_OVER 128 // Game has been finished
|
|
|
|
#define GM_TEAM 256 // Team mode for network play
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
#define GM_BOUNTY 512 // New bounty mode by Matt1360
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
2006-03-20 17:12:09 +00:00
|
|
|
#define GM_CAPTURE 512 // Capture the flag mode for D2
|
|
|
|
#define GM_HOARD 1024 // New hoard mode for D2 Christmas
|
2011-01-19 01:19:17 +00:00
|
|
|
#define GM_BOUNTY 2048 /* New bounty mode by Matt1360 */
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
#define GM_NORMAL 0 // You are in normal play mode, no multiplayer stuff
|
|
|
|
#define GM_MULTI 38 // You are in some type of multiplayer game
|
|
|
|
|
|
|
|
|
|
|
|
#define NDL 5 // Number of difficulty levels.
|
|
|
|
|
|
|
|
extern int Game_mode;
|
|
|
|
extern u_int32_t Game_screen_mode;
|
|
|
|
|
|
|
|
extern int gauge_message_on;
|
|
|
|
|
|
|
|
#ifndef NDEBUG // if debugging, these are variables
|
|
|
|
|
|
|
|
extern int Slew_on; // in slew or sim mode?
|
|
|
|
|
|
|
|
#else // if not debugging, these are constants
|
|
|
|
|
|
|
|
#define Slew_on 0 // no slewing in real game
|
|
|
|
#define Game_double_buffer 1 // always double buffer in real game
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Suspend flags
|
|
|
|
|
|
|
|
#define SUSP_NONE 0 // Everything moving normally
|
|
|
|
#define SUSP_ROBOTS 1 // Robot AI doesn't move
|
|
|
|
#define SUSP_WEAPONS 2 // Lasers, etc. don't move
|
|
|
|
|
|
|
|
extern int Game_suspended; // if non-zero, nothing moves but player
|
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
#define SHOW_EXIT_PATH 1
|
|
|
|
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
// from game.c
|
|
|
|
void init_game(void);
|
|
|
|
void game(void);
|
|
|
|
void close_game(void);
|
|
|
|
void init_cockpit(void);
|
|
|
|
void calc_frame_time(void);
|
2012-05-14 17:06:28 +00:00
|
|
|
void calc_d_tick();
|
2010-02-07 07:28:49 +00:00
|
|
|
int do_flythrough(struct object *obj,int first_time);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
extern int Difficulty_level; // Difficulty level in 0..NDL-1, 0 = easiest, NDL-1 = hardest
|
|
|
|
extern int Global_laser_firing_count;
|
|
|
|
extern int Global_missile_firing_count;
|
2010-12-22 00:17:59 +00:00
|
|
|
extern fix64 Auto_fire_fusion_cannon_time;
|
|
|
|
extern fix Fusion_charge;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
extern int PaletteRedAdd, PaletteGreenAdd, PaletteBlueAdd;
|
|
|
|
|
|
|
|
#define MAX_PALETTE_ADD 30
|
|
|
|
|
|
|
|
extern void PALETTE_FLASH_ADD(int dr, int dg, int db);
|
|
|
|
|
|
|
|
//sets the rgb values for palette flash
|
|
|
|
#define PALETTE_FLASH_SET(_r,_g,_b) PaletteRedAdd=(_r), PaletteGreenAdd=(_g), PaletteBlueAdd=(_b)
|
|
|
|
|
|
|
|
extern int draw_gauges_on;
|
|
|
|
|
|
|
|
extern void init_game_screen(void);
|
|
|
|
|
|
|
|
extern void game_flush_inputs(); // clear all inputs
|
|
|
|
|
|
|
|
extern int Playing_game; // True if playing game
|
|
|
|
extern int Auto_flythrough; // if set, start flythough automatically
|
|
|
|
extern int Mark_count; // number of debugging marks set
|
|
|
|
extern char faded_in;
|
2007-04-01 02:14:38 +00:00
|
|
|
extern int last_drawn_cockpit;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
extern void stop_time(void);
|
|
|
|
extern void start_time(void);
|
|
|
|
extern void reset_time(void); // called when starting level
|
|
|
|
|
|
|
|
// If automap_flag == 1, then call automap routine to write message.
|
|
|
|
extern void save_screen_shot(int automap_flag);
|
|
|
|
|
2012-07-15 03:51:54 +00:00
|
|
|
enum cockpit_mode_t
|
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
//valid modes for cockpit
|
2012-07-15 03:51:54 +00:00
|
|
|
CM_FULL_COCKPIT, // normal screen with cockpit
|
|
|
|
CM_REAR_VIEW, // looking back with bitmap
|
|
|
|
CM_STATUS_BAR, // small status bar, w/ reticle
|
|
|
|
CM_FULL_SCREEN, // full screen, no cockpit (w/ reticle)
|
|
|
|
CM_LETTERBOX // half-height window (for cutscenes)
|
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
extern int Game_window_w, // width and height of player's game window
|
|
|
|
Game_window_h;
|
|
|
|
|
|
|
|
extern int Rear_view; // if true, looking back.
|
|
|
|
|
|
|
|
// initalize flying
|
2010-02-07 07:28:49 +00:00
|
|
|
void fly_init(struct object *obj);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// selects a given cockpit (or lack of one).
|
2012-07-15 03:51:54 +00:00
|
|
|
void select_cockpit(cockpit_mode_t mode);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// force cockpit redraw next time. call this if you've trashed the screen
|
|
|
|
void reset_cockpit(void); // called if you've trashed the screen
|
|
|
|
|
|
|
|
// functions to save, clear, and resture palette flash effects
|
|
|
|
void palette_save(void);
|
|
|
|
void reset_palette_add(void);
|
|
|
|
void palette_restore(void);
|
2013-10-28 03:41:44 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
static inline void full_palette_save(void)
|
|
|
|
{
|
|
|
|
palette_save();
|
|
|
|
}
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
2010-02-05 02:31:36 +00:00
|
|
|
void full_palette_save(void); // all of the above plus gr_palette_load(gr_palette)
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// put up the help message
|
2007-11-06 20:33:22 +00:00
|
|
|
void show_help();
|
2008-12-13 12:58:57 +00:00
|
|
|
void show_netgame_help();
|
2007-11-06 20:33:22 +00:00
|
|
|
void show_newdemo_help();
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// show a message in a nice little box
|
2013-06-08 22:24:17 +00:00
|
|
|
void show_boxed_message(const char *msg, int RenderFlag);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// turns off rear view & rear view cockpit
|
|
|
|
void reset_rear_view(void);
|
|
|
|
|
2013-09-24 01:46:10 +00:00
|
|
|
void game_init_render_sub_buffers(int x, int y, int w, int h);
|
|
|
|
// Sets up the canvases we will be rendering to
|
|
|
|
static inline void game_init_render_buffers (int render_max_w, int render_max_h)
|
|
|
|
{
|
|
|
|
game_init_render_sub_buffers( 0, 0, render_max_w, render_max_h );
|
|
|
|
}
|
2012-11-11 00:14:30 +00:00
|
|
|
|
|
|
|
extern int netplayerinfo_on;
|
|
|
|
extern int Slide_segs_computed;
|
|
|
|
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2013-08-11 16:03:47 +00:00
|
|
|
static inline int game_mode_capture_flag()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2013-08-11 16:03:47 +00:00
|
|
|
static inline int game_mode_hoard()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-03 01:03:33 +00:00
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
2013-08-11 16:03:47 +00:00
|
|
|
static inline int game_mode_capture_flag()
|
|
|
|
{
|
|
|
|
return (Game_mode & GM_CAPTURE);
|
|
|
|
}
|
2013-08-11 16:03:47 +00:00
|
|
|
static inline int game_mode_hoard()
|
|
|
|
{
|
|
|
|
return (Game_mode & GM_HOARD);
|
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
// returns ptr to escort robot, or NULL
|
2014-10-25 15:19:20 +00:00
|
|
|
objptridx_t find_escort();
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//Flickering light system
|
2013-12-22 22:03:07 +00:00
|
|
|
struct flickering_light {
|
2013-12-29 04:28:07 +00:00
|
|
|
segnum_t segnum;
|
|
|
|
short sidenum;
|
2013-12-31 00:11:05 +00:00
|
|
|
uint32_t mask; // determines flicker pattern
|
2006-03-20 17:12:09 +00:00
|
|
|
fix timer; // time until next change
|
|
|
|
fix delay; // time between changes
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
#define MAX_FLICKERING_LIGHTS 100
|
|
|
|
|
|
|
|
extern flickering_light Flickering_lights[MAX_FLICKERING_LIGHTS];
|
|
|
|
extern int Num_flickering_lights;
|
2012-11-11 00:14:30 +00:00
|
|
|
extern int BigWindowSwitch;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// turn flickering off (because light has been turned off)
|
2013-12-29 04:28:07 +00:00
|
|
|
void disable_flicker(segnum_t segnum, int sidenum);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// turn flickering off (because light has been turned on)
|
2013-12-29 04:28:07 +00:00
|
|
|
void enable_flicker(segnum_t segnum, int sidenum);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
/*
|
2011-06-01 07:59:55 +00:00
|
|
|
* reads a flickering_light structure from a PHYSFS_file
|
2006-03-20 17:12:09 +00:00
|
|
|
*/
|
2011-06-01 07:59:55 +00:00
|
|
|
void flickering_light_read(flickering_light *fl, PHYSFS_file *fp);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
void flickering_light_write(flickering_light *fl, PHYSFS_file *fp);
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2008-05-21 13:58:27 +00:00
|
|
|
|
2014-10-16 02:44:43 +00:00
|
|
|
void game_render_frame_mono();
|
|
|
|
static inline void game_render_frame_mono(int flip)
|
|
|
|
{
|
|
|
|
game_render_frame_mono();
|
|
|
|
if (flip)
|
|
|
|
gr_flip();
|
|
|
|
}
|
2010-01-31 07:45:26 +00:00
|
|
|
void game_leave_menus(void);
|
2011-02-14 21:27:07 +00:00
|
|
|
|
|
|
|
//Cheats
|
2014-06-26 02:24:32 +00:00
|
|
|
struct game_cheats : prohibit_void_ptr<game_cheats>
|
2011-02-14 21:27:07 +00:00
|
|
|
{
|
|
|
|
int enabled;
|
|
|
|
int wowie;
|
|
|
|
int allkeys;
|
|
|
|
int invul;
|
|
|
|
int shields;
|
|
|
|
int killreactor;
|
|
|
|
int exitpath;
|
|
|
|
int levelwarp;
|
|
|
|
int fullautomap;
|
|
|
|
int ghostphysics;
|
|
|
|
int rapidfire;
|
|
|
|
int turbo;
|
|
|
|
int robotfiringsuspended;
|
2013-03-03 01:03:33 +00:00
|
|
|
int acid;
|
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
int wowie2;
|
|
|
|
int cloak;
|
|
|
|
int extralife;
|
|
|
|
int baldguy;
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
|
|
|
int lamer;
|
|
|
|
int accessory;
|
|
|
|
int bouncyfire;
|
2011-02-14 21:27:07 +00:00
|
|
|
int killallrobots;
|
|
|
|
int robotskillrobots;
|
|
|
|
int monsterdamage;
|
|
|
|
int buddyclone;
|
|
|
|
int buddyangry;
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2014-06-26 02:24:32 +00:00
|
|
|
};
|
2011-02-14 21:27:07 +00:00
|
|
|
extern game_cheats cheats;
|
|
|
|
void game_disable_cheats();
|
2012-11-11 00:14:30 +00:00
|
|
|
struct segment;
|
|
|
|
void move_player_2_segment(struct segment *seg, int side);
|
|
|
|
int allowed_to_fire_laser(void);
|
|
|
|
int allowed_to_fire_flare(void);
|
|
|
|
int allowed_to_fire_missile(void);
|
|
|
|
void check_rear_view(void);
|
|
|
|
window *game_setup(void);
|
|
|
|
int create_special_path(void);
|
2014-10-04 21:47:13 +00:00
|
|
|
window_event_result ReadControls(const d_event &event);
|
2012-11-11 00:14:30 +00:00
|
|
|
void toggle_cockpit(void);
|
|
|
|
void game_render_frame();
|
|
|
|
extern fix Show_view_text_timer;
|
|
|
|
extern fix ThisLevelTime;
|
|
|
|
extern int Last_level_path_created;
|
|
|
|
extern int force_cockpit_redraw;
|
|
|
|
extern ubyte DemoDoingRight,DemoDoingLeft;
|
|
|
|
extern fix64 Time_flash_last_played;
|
2014-10-16 02:30:29 +00:00
|
|
|
window_event_result game_handler(window *wind,const d_event &event, const unused_window_userdata_t *);
|
2012-11-11 00:14:30 +00:00
|
|
|
|
|
|
|
#ifdef EDITOR
|
|
|
|
void dump_used_textures_all();
|
|
|
|
#endif
|
2011-02-14 21:27:07 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#endif
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
#endif /* _GAME_H */
|