FS2_Open
Open source remastering of the Freespace 2 engine
freespace.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifndef _FREESPACE_H
13 #define _FREESPACE_H
14 #ifndef STAMPER_PROGRAM // because of all the dependancies, I have to do this...yuck!!! MWA 7/21/97
15 
16 #include "camera/camera.h"
17 #include "globalincs/pstypes.h"
18 #include "globalincs/systemvars.h"
19 #include "graphics/2d.h"
20 
21 // --------------------------------------------------------------------------------------------------------
22 // FREESPACE DEFINES/VARS
23 //
24 
25 // filename extensions
26 #define FS_CAMPAIGN_FILE_EXT NOX(".fc2")
27 
28 // CDROM volume names
29 #define FS_CDROM_VOLUME_1 NOX("FREESPACE2_1")
30 #define FS_CDROM_VOLUME_2 NOX("FREESPACE2_2")
31 #define FS_CDROM_VOLUME_3 NOX("FREESPACE2_3")
32 
33 
34 // frametime/missiontime variables
35 extern fix Frametime;
36 extern float flRealframetime;
37 extern float flFrametime;
38 extern fix Missiontime;
39 extern int Last_frame_timestamp; // A timestamp for when the previous frame ended
40 extern fix Skybox_timestamp; // A timestamp for animated skyboxes -MageKing17
41 
42 // 0 - 4
43 extern int Game_skill_level;
44 
45 // see GM_* defines in systemvars.h
46 extern int Game_mode;
47 
48 // if this value is set anywhere within the game_do_state_common() function, the normal do_state() will not be called
49 // for this frame. Useful for getting out of sticky sequencing situations.
50 extern int Game_do_state_should_skip;
51 
52 // time compression
53 extern bool Time_compression_locked;
55 
56 // Set if subspace is active this level
57 extern int Game_subspace_effect;
58 
59 // The current mission being played.
61 
62 // game's CDROM directory
63 extern char Game_CDROM_dir[MAX_PATH_LEN];
64 
65 // if the ships.tbl the player has is valid
66 extern int Game_ships_tbl_valid;
67 
68 // if the weapons.tbl the player has is valid
69 extern int Game_weapons_tbl_valid;
70 
71 // to disable networking at runtime
72 extern int Networking_disabled;
73 
74 // this is a mission actually designed at Volition
75 #define MAX_BUILTIN_MISSIONS 100
76 #define FSB_FROM_VOLITION (1<<0) // we made it in-house
77 #define FSB_MULTI (1<<1) // is a multiplayer mission
78 #define FSB_TRAINING (1<<2) // is a training mission
79 #define FSB_CAMPAIGN (1<<3) // is a campaign mission
80 #define FSB_CAMPAIGN_FILE (1<<4) // is actually a campaign file
81 
82 typedef struct fs_builtin_mission {
84  int flags; // see FSB_* defines above
85  char cd_volume[MAX_FILENAME_LEN]; // cd volume which this needs
87 
88 
89 // --------------------------------------------------------------------------------------------------------
90 // FREESPACE FUNCTIONS
91 //
92 
93 // mission management -------------------------------------------------
94 
95 // loads in the currently selected mission
96 int game_start_mission();
97 
98 // shutdown a mission
99 void game_level_close();
100 
101 
102 // gameplay stuff -----------------------------------------------------
103 
104 // stop the game (mission) timer
105 void game_stop_time();
106 
107 // start the game (mission) timer
108 void game_start_time();
109 
110 // call whenever in a loop or if you need to get a keypress
111 int game_check_key();
112 
113 // poll for keypresses
114 int game_poll();
115 
116 // function to read keyboard stuff
117 void game_process_keys();
118 
119 // call this when you don't want the user changing time compression
120 void lock_time_compression(bool is_locked);
121 
122 // call this to set time compression properly
123 void set_time_compression(float multiplier, float change_time = 0);
124 
125 //call this to change the relative time compression (ie double it)
126 void change_time_compression(float multiplier);
127 
128 // call this to set frametime properly (once per frame)
129 void game_set_frametime(int state);
130 
131 // overall frametime of game, indepedent of mission timer
133 
134 // Used to halt all looping game sounds
136 
137 // do stuff that may need to be done regardless of state
138 void game_do_state_common(int state,int no_networking = 0);
139 
140 
141 // skill level --------------------------------------------------------
142 
143 // increase the skill level (will wrap around to min skill level)
145 
146 // get the default game skill level
148 
149 // a keypress. See CPP file for more info.
150 void game_flush();
151 
152 // running with low-memory (less than 48MB)
153 bool game_using_low_mem();
154 
155 // misc ---------------------------------------------------------------
156 
157 // lookup the specified filename. return an fs_builtin_mission* if found, NULL otherwise
159 
160 
161 
162 //================================================================
163 // GAME FLASH STUFF - code in FreeSpace.cpp
164 
165 // Resets the flash
166 void game_flash_reset();
167 
168 // Adds a flash effect. These can be positive or negative.
169 // The range will get capped at around -1 to 1, so stick
170 // with a range like that.
171 void game_flash( float r, float g, float b );
172 
173 // Adds a flash for Big Ship explosions
174 // cap range from 0 to 1
175 void big_explosion_flash(float flash);
176 
177 // Call once a frame to diminish the
178 // flash effect to 0.
179 void game_flash_diminish();
180 
181 //================================================================
182 
183 // Call at the beginning of each frame
184 void game_whack_reset();
185 
186 // Call to apply a whack to a the ship. Used for force feedback
187 void game_whack_apply( float x, float y );
188 
189 // call to apply a "shudder"
190 void game_shudder_apply(int time, float intensity);
191 
192 //===================================================================
193 
194 // make sure a CD is in the drive before continuing (returns 1 to continue, otherwise 0).
195 int game_do_cd_check(char *volume_name=NULL);
196 int game_do_cd_check_specific(char *volume_name, int cdnum);
197 int find_freespace_cd(char *volume_name=NULL);
198 int set_cdrom_path(int drive_num);
199 
200 // Used to tell the player that a feature is disabled by build settings
202 
203 // Return version string for build.
204 void get_version_string(char *str, int max_size);
205 
206 // format the specified time (fixed point) into a nice string
207 void game_format_time(fix m_time,char *time_str);
208 
209 // if the game is running using hacked data
210 int game_hacked_data();
211 
212 // show the oem upsell screens (end of campaign, or close of game
214 
215 // calls to be executed when the game is put in or restored from minimized or inactive state
216 void game_pause();
217 void game_unpause();
218 
219 //WMC - Stuff for scripting, these make the game go
220 extern camid Main_camera;
221 
222 extern void game_level_init();
223 extern void game_post_level_init();
225 extern void game_render_frame(camid cid);
226 extern void game_simulation_frame();
227 extern void game_update_missiontime();
228 extern void game_render_post_frame();
229 
230 #endif // endif of #ifndef STAMPER_PROGRAM
231 #endif
void game_simulation_frame()
Definition: fredstubs.cpp:237
void game_feature_disabled_popup()
Definition: fredstubs.cpp:219
#define MAX_FILENAME_LEN
Definition: pstypes.h:324
int game_check_key()
Definition: fredstubs.cpp:65
void change_time_compression(float multiplier)
Definition: fredstubs.cpp:228
fix Frametime
Definition: systemvars.cpp:21
fix Missiontime
Definition: systemvars.cpp:19
struct fs_builtin_mission fs_builtin_mission
int find_freespace_cd(char *volume_name=NULL)
Definition: fredstubs.cpp:193
void game_do_state_common(int state, int no_networking=0)
Definition: fredstubs.cpp:195
bool game_using_low_mem()
Definition: freespace.cpp:8754
bool Time_compression_locked
Definition: fredstubs.cpp:225
void game_render_frame(camid cid)
Definition: fredstubs.cpp:236
float flRealframetime
Definition: fredstubs.cpp:226
void game_update_missiontime()
Definition: fredstubs.cpp:238
void game_level_init()
Definition: fredstubs.cpp:233
int Last_frame_timestamp
int Game_do_state_should_skip
Definition: fredstubs.cpp:201
void game_whack_apply(float x, float y)
Definition: fredstubs.cpp:138
void game_post_level_init()
Definition: fredstubs.cpp:234
char cd_volume[MAX_FILENAME_LEN]
Definition: freespace.h:85
char Game_current_mission_filename[MAX_FILENAME_LEN]
Definition: fredstubs.cpp:26
int game_do_cd_check_specific(char *volume_name, int cdnum)
Definition: freespace.cpp:8377
fix game_get_overall_frametime()
Definition: fredstubs.cpp:230
camid game_render_frame_setup()
Definition: fredstubs.cpp:235
int Game_subspace_effect
Definition: fredstubs.cpp:163
void game_set_frametime(int state)
Definition: fredstubs.cpp:196
void game_stop_looped_sounds()
Definition: fredstubs.cpp:168
void set_time_compression(float multiplier, float change_time=0)
Definition: fredstubs.cpp:229
void game_flash(float r, float g, float b)
Definition: fredstubs.cpp:40
void game_flush()
Definition: fredstubs.cpp:83
void oem_upsell_show_screens()
int game_poll()
Definition: fredstubs.cpp:70
GLdouble GLdouble GLdouble r
Definition: Glext.h:5337
int game_start_mission()
Definition: fredstubs.cpp:179
GLboolean GLboolean g
Definition: Glext.h:5781
int game_get_default_skill_level()
Definition: fredstubs.cpp:190
char * filename
float flFrametime
Definition: fredstubs.cpp:22
int Game_weapons_tbl_valid
Definition: fredstubs.cpp:180
int Game_ships_tbl_valid
Definition: fredstubs.cpp:181
int set_cdrom_path(int drive_num)
Definition: fredstubs.cpp:192
fix Skybox_timestamp
Definition: systemvars.cpp:20
void game_increase_skill_level()
Definition: fredstubs.cpp:197
void game_process_keys()
void game_flash_reset()
Definition: freespace.cpp:549
int game_hacked_data()
Definition: fredstubs.cpp:208
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
long fix
Definition: pstypes.h:54
void game_format_time(fix m_time, char *time_str)
Definition: fredstubs.cpp:204
void get_version_string(char *str, int max_size)
Definition: fredstubs.cpp:198
void game_shudder_apply(int time, float intensity)
Definition: fredstubs.cpp:207
void lock_time_compression(bool is_locked)
Definition: fredstubs.cpp:227
#define MAX_PATH_LEN
Definition: pstypes.h:325
GLboolean GLboolean GLboolean b
Definition: Glext.h:5781
void game_whack_reset()
Definition: freespace.cpp:3058
void game_stop_time()
Definition: fredstubs.cpp:189
char Game_CDROM_dir[MAX_PATH_LEN]
Definition: fredstubs.cpp:38
void big_explosion_flash(float flash)
Definition: fredstubs.cpp:164
Definition: pstypes.h:606
char filename[MAX_FILENAME_LEN]
Definition: freespace.h:83
fs_builtin_mission * game_find_builtin_mission(char *filename)
Definition: fredstubs.cpp:203
void game_level_close()
Definition: fredstubs.cpp:182
int Game_mode
Definition: systemvars.cpp:24
int game_do_cd_check(char *volume_name=NULL)
Definition: fredstubs.cpp:166
camid Main_camera
Definition: camera.cpp:25
fix Game_time_compression
Definition: fredstubs.cpp:202
void game_flash_diminish()
int Networking_disabled
Definition: fredstubs.cpp:32
void game_render_post_frame()
Definition: fredstubs.cpp:239
void game_start_time()
Definition: fredstubs.cpp:188
void game_pause()
Definition: fredstubs.cpp:221
int Game_skill_level
Definition: fredstubs.cpp:170
void game_unpause()
Definition: fredstubs.cpp:222
GLint y
Definition: Gl.h:1505