2006-03-20 16:43:15 +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-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
2006-03-27 17:38:11 +00:00
|
|
|
|
2006-09-08 23:31:06 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Game loop for Inferno
|
|
|
|
*
|
|
|
|
*/
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
2006-09-08 23:31:06 +00:00
|
|
|
#include <SDL/SDL.h>
|
2010-02-02 07:52:03 +00:00
|
|
|
#include <setjmp.h>
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
#ifdef OGL
|
|
|
|
#include "ogl_init.h"
|
|
|
|
#endif
|
2009-07-01 11:35:33 +00:00
|
|
|
|
|
|
|
#include "pstypes.h"
|
|
|
|
#include "console.h"
|
|
|
|
#include "gr.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "inferno.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "object.h"
|
|
|
|
#include "physics.h"
|
|
|
|
#include "error.h"
|
|
|
|
#include "joy.h"
|
|
|
|
#include "iff.h"
|
|
|
|
#include "pcx.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "render.h"
|
|
|
|
#include "laser.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "textures.h"
|
|
|
|
#include "slew.h"
|
|
|
|
#include "gauges.h"
|
|
|
|
#include "texmap.h"
|
|
|
|
#include "3d.h"
|
|
|
|
#include "effects.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "gameseg.h"
|
|
|
|
#include "wall.h"
|
|
|
|
#include "ai.h"
|
|
|
|
#include "hostage.h"
|
|
|
|
#include "fuelcen.h"
|
|
|
|
#include "digi.h"
|
|
|
|
#include "u_mem.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "morph.h"
|
|
|
|
#include "lighting.h"
|
|
|
|
#include "newdemo.h"
|
|
|
|
#include "collide.h"
|
|
|
|
#include "weapon.h"
|
|
|
|
#include "sounds.h"
|
|
|
|
#include "args.h"
|
|
|
|
#include "gameseq.h"
|
|
|
|
#include "automap.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "powerup.h"
|
|
|
|
#include "fireball.h"
|
|
|
|
#include "newmenu.h"
|
|
|
|
#include "gamefont.h"
|
|
|
|
#include "endlevel.h"
|
|
|
|
#include "kconfig.h"
|
2009-07-01 11:35:33 +00:00
|
|
|
#include "config.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "mouse.h"
|
2009-07-01 11:35:33 +00:00
|
|
|
#include "switch.h"
|
|
|
|
#include "controls.h"
|
|
|
|
#include "songs.h"
|
|
|
|
#include "rbaudio.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "multi.h"
|
|
|
|
#include "desc_id.h"
|
|
|
|
#include "cntrlcen.h"
|
|
|
|
#include "pcx.h"
|
|
|
|
#include "state.h"
|
|
|
|
#include "piggy.h"
|
|
|
|
#include "multibot.h"
|
2006-09-08 23:31:06 +00:00
|
|
|
#include "fvi.h"
|
2008-04-13 00:28:36 +00:00
|
|
|
#include "playsave.h"
|
2009-07-01 11:35:33 +00:00
|
|
|
#include "hudmsg.h"
|
|
|
|
#include "vers_id.h"
|
2009-08-10 10:47:17 +00:00
|
|
|
#include "event.h"
|
|
|
|
#include "window.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
#ifdef EDITOR
|
|
|
|
#include "editor/editor.h"
|
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
int Mark_count = 0; // number of debugging marks set
|
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
static fix last_timer_value=0;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-12-02 13:49:54 +00:00
|
|
|
fix VR_eye_width = F1_0;
|
2006-03-27 17:38:11 +00:00
|
|
|
int VR_render_mode = VR_NONE;
|
|
|
|
int VR_low_res = 3; // Default to low res
|
2006-03-20 16:43:15 +00:00
|
|
|
int VR_show_hud = 1;
|
2006-03-27 17:38:11 +00:00
|
|
|
int VR_sensitivity = 1; // 0 - 2
|
2009-12-02 13:49:54 +00:00
|
|
|
|
|
|
|
//NEWVR
|
|
|
|
int VR_eye_offset = 0;
|
|
|
|
int VR_eye_switch = 0;
|
|
|
|
int VR_eye_offset_changed = 0;
|
|
|
|
int VR_use_reg_code = 0;
|
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
grs_canvas Screen_3d_window; // The rectangle for rendering the mine to
|
|
|
|
grs_canvas *VR_offscreen_buffer = NULL; // The offscreen data buffer
|
|
|
|
grs_canvas VR_render_buffer[2]; // Two offscreen buffers for left/right eyes.
|
|
|
|
grs_canvas VR_render_sub_buffer[2]; // Two sub buffers for left/right eyes.
|
|
|
|
grs_canvas VR_editor_canvas; // The canvas that the editor writes to.
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2006-03-27 17:38:11 +00:00
|
|
|
int force_cockpit_redraw=0;
|
|
|
|
int PaletteRedAdd, PaletteGreenAdd, PaletteBlueAdd;
|
2009-07-01 11:35:33 +00:00
|
|
|
|
|
|
|
// Toggle_var points at a variable which gets !ed on del-T press.
|
2006-03-20 16:43:15 +00:00
|
|
|
int Dummy_var;
|
|
|
|
int *Toggle_var = &Dummy_var;
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
#ifdef EDITOR
|
2009-07-01 11:35:33 +00:00
|
|
|
//flag for whether initial fade-in has been done
|
2006-03-27 17:38:11 +00:00
|
|
|
char faded_in;
|
2006-03-20 16:43:15 +00:00
|
|
|
#endif
|
|
|
|
|
2006-03-27 17:38:11 +00:00
|
|
|
int Game_suspended=0; //if non-zero, nothing moves but player
|
2006-03-20 16:43:15 +00:00
|
|
|
fix Auto_fire_fusion_cannon_time = 0;
|
|
|
|
fix Fusion_charge = 0;
|
2006-03-27 17:38:11 +00:00
|
|
|
int Game_turbo_mode = 0;
|
|
|
|
int Game_mode = GM_GAME_OVER;
|
2006-03-20 16:43:15 +00:00
|
|
|
int Global_laser_firing_count = 0;
|
|
|
|
int Global_missile_firing_count = 0;
|
2010-06-14 21:59:41 +00:00
|
|
|
fix Next_flare_fire_time = 0;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
// Function prototypes for GAME.C exclusively.
|
|
|
|
|
2009-08-10 10:47:17 +00:00
|
|
|
void GameProcessFrame(void);
|
2009-07-01 11:35:33 +00:00
|
|
|
void FireLaser(void);
|
|
|
|
void powerup_grab_cheat_all(void);
|
|
|
|
void game_init_render_sub_buffers(int x, int y, int w, int h);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2010-03-31 09:18:28 +00:00
|
|
|
extern int ReadControls(d_event *event); // located in gamecntl.c
|
2006-03-20 16:43:15 +00:00
|
|
|
// ==============================================================================================
|
|
|
|
|
|
|
|
//this is called once per game
|
|
|
|
void init_game()
|
|
|
|
{
|
|
|
|
init_objects();
|
|
|
|
|
|
|
|
hostage_init();
|
|
|
|
|
|
|
|
init_special_effects();
|
|
|
|
|
|
|
|
init_exploding_walls();
|
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
Clear_window = 2; // do portal only window clear.
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void reset_palette_add()
|
|
|
|
{
|
|
|
|
PaletteRedAdd = 0;
|
|
|
|
PaletteGreenAdd = 0;
|
|
|
|
PaletteBlueAdd = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void game_show_warning(char *s)
|
|
|
|
{
|
|
|
|
nm_messagebox( TXT_WARNING, 1, TXT_OK, s );
|
|
|
|
}
|
|
|
|
|
2007-08-08 12:38:13 +00:00
|
|
|
u_int32_t Game_screen_mode = SM(640,480);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//initialize the various canvases on the game screen
|
|
|
|
//called every time the screen mode or cockpit changes
|
|
|
|
void init_cockpit()
|
|
|
|
{
|
|
|
|
//Initialize the on-screen canvases
|
|
|
|
|
|
|
|
if (Screen_mode != SCREEN_GAME)
|
|
|
|
return;
|
|
|
|
|
2006-09-29 00:49:28 +00:00
|
|
|
if (( Screen_mode == SCREEN_EDITOR ) || ( VR_render_mode != VR_NONE ))
|
2010-01-28 00:04:29 +00:00
|
|
|
PlayerCfg.CockpitMode[1] = CM_FULL_SCREEN;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
#ifndef OGL
|
2010-01-28 00:04:29 +00:00
|
|
|
if ( Game_screen_mode != (HiresGFXAvailable? SM(640,480) : SM(320,200)) && PlayerCfg.CockpitMode[1] != CM_LETTERBOX) {
|
|
|
|
PlayerCfg.CockpitMode[1] = CM_FULL_SCREEN;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-09-08 23:31:06 +00:00
|
|
|
gr_set_current_canvas(NULL);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2010-01-28 00:04:29 +00:00
|
|
|
switch( PlayerCfg.CockpitMode[1] ) {
|
2009-07-01 11:35:33 +00:00
|
|
|
case CM_FULL_COCKPIT:
|
|
|
|
game_init_render_sub_buffers(0, 0, SWIDTH, (SHEIGHT*2)/3);
|
|
|
|
break;
|
2006-09-29 00:49:28 +00:00
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
case CM_REAR_VIEW:
|
2010-06-18 07:31:06 +00:00
|
|
|
{ int x = 0, y = 0, w = SWIDTH, h = (SHEIGHT*2)/3;
|
|
|
|
grs_bitmap *bm;
|
|
|
|
|
|
|
|
PIGGY_PAGE_IN(cockpit_bitmap[PlayerCfg.CockpitMode[1]]);
|
|
|
|
bm = &GameBitmaps[cockpit_bitmap[PlayerCfg.CockpitMode[1]].index];
|
|
|
|
gr_bitblt_find_transparent_area(bm, &x, &y, &w, &h);
|
|
|
|
game_init_render_sub_buffers(x*((float)SWIDTH/bm->bm_w), y*((float)SHEIGHT/bm->bm_h), w*((float)SWIDTH/bm->bm_w), h*((float)SHEIGHT/bm->bm_h));
|
|
|
|
break;
|
|
|
|
}
|
2009-07-01 11:35:33 +00:00
|
|
|
case CM_FULL_SCREEN:
|
|
|
|
game_init_render_sub_buffers(0, 0, SWIDTH, SHEIGHT);
|
|
|
|
break;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
case CM_STATUS_BAR:
|
|
|
|
game_init_render_sub_buffers( 0, 0, SWIDTH, (HIRESMODE?(SHEIGHT*2)/2.6:(SHEIGHT*2)/2.72) );
|
|
|
|
break;
|
2006-09-29 00:49:28 +00:00
|
|
|
|
2010-06-18 07:31:06 +00:00
|
|
|
case CM_LETTERBOX:
|
|
|
|
{
|
2009-07-01 11:35:33 +00:00
|
|
|
int x,y,w,h;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
x = 0; w = SM_W(Game_screen_mode);
|
|
|
|
h = (SM_H(Game_screen_mode) * 3) / 4; // true letterbox size (16:9)
|
|
|
|
y = (SM_H(Game_screen_mode)-h)/2;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
gr_rect(x,0,w,SM_H(Game_screen_mode)-h);
|
|
|
|
gr_rect(x,SM_H(Game_screen_mode)-h,w,SM_H(Game_screen_mode));
|
2006-09-29 00:49:28 +00:00
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
game_init_render_sub_buffers( x, y, w, h );
|
|
|
|
break;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
gr_set_current_canvas(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//selects a given cockpit (or lack of one). See types in game.h
|
|
|
|
void select_cockpit(int mode)
|
|
|
|
{
|
2010-01-28 00:04:29 +00:00
|
|
|
if (mode != PlayerCfg.CockpitMode[1]) { //new mode
|
|
|
|
PlayerCfg.CockpitMode[1]=mode;
|
2006-03-20 16:43:15 +00:00
|
|
|
init_cockpit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//force cockpit redraw next time. call this if you've trashed the screen
|
|
|
|
void reset_cockpit()
|
|
|
|
{
|
|
|
|
force_cockpit_redraw=1;
|
2007-03-22 14:15:46 +00:00
|
|
|
last_drawn_cockpit = -1;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void game_init_render_sub_buffers( int x, int y, int w, int h )
|
|
|
|
{
|
2007-06-10 16:21:53 +00:00
|
|
|
gr_clear_canvas(0);
|
2007-03-26 10:47:34 +00:00
|
|
|
gr_init_sub_canvas( &Screen_3d_window, &grd_curscreen->sc_canvas, x, y, w, h );
|
2006-03-20 16:43:15 +00:00
|
|
|
gr_init_sub_canvas( &VR_render_sub_buffer[0], &VR_render_buffer[0], x, y, w, h );
|
|
|
|
gr_init_sub_canvas( &VR_render_sub_buffer[1], &VR_render_buffer[1], x, y, w, h );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Sets up the canvases we will be rendering to
|
2007-04-05 13:23:44 +00:00
|
|
|
void game_init_render_buffers(int render_w, int render_h, int render_method )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2009-07-01 11:35:33 +00:00
|
|
|
VR_render_mode = render_method;
|
2006-09-29 00:49:28 +00:00
|
|
|
|
2006-10-06 00:39:15 +00:00
|
|
|
if (VR_offscreen_buffer) {
|
|
|
|
gr_free_canvas(VR_offscreen_buffer);
|
|
|
|
}
|
|
|
|
|
2006-09-29 00:49:28 +00:00
|
|
|
if ( (VR_render_mode==VR_AREA_DET) || (VR_render_mode==VR_INTERLACED ) ) {
|
|
|
|
if ( render_h*2 < 200 )
|
|
|
|
VR_offscreen_buffer = gr_create_canvas( render_w, 200 );
|
|
|
|
else
|
|
|
|
VR_offscreen_buffer = gr_create_canvas( render_w, render_h*2 );
|
2006-03-20 16:43:15 +00:00
|
|
|
gr_init_sub_canvas( &VR_render_buffer[0], VR_offscreen_buffer, 0, 0, render_w, render_h );
|
2006-09-29 00:49:28 +00:00
|
|
|
gr_init_sub_canvas( &VR_render_buffer[1], VR_offscreen_buffer, 0, render_h, render_w, render_h );
|
|
|
|
} else {
|
|
|
|
if ( render_h < 200 )
|
|
|
|
VR_offscreen_buffer = gr_create_canvas( render_w, 200 );
|
|
|
|
else
|
|
|
|
VR_offscreen_buffer = gr_create_canvas( render_w, render_h );
|
2006-03-20 16:43:15 +00:00
|
|
|
#ifdef OGL
|
2009-07-01 11:35:33 +00:00
|
|
|
VR_offscreen_buffer->cv_bitmap.bm_type = BM_OGL;
|
2006-03-20 16:43:15 +00:00
|
|
|
#endif
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2006-09-29 00:49:28 +00:00
|
|
|
gr_init_sub_canvas( &VR_render_buffer[0], VR_offscreen_buffer, 0, 0, render_w, render_h );
|
|
|
|
gr_init_sub_canvas( &VR_render_buffer[1], VR_offscreen_buffer, 0, 0, render_w, render_h );
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2006-09-29 00:49:28 +00:00
|
|
|
|
|
|
|
game_init_render_sub_buffers( 0, 0, render_w, render_h );
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//called to change the screen mode. Parameter sm is the new mode, one of
|
|
|
|
//SMODE_GAME or SMODE_EDITOR. returns mode acutally set (could be other
|
|
|
|
//mode if cannot init requested mode)
|
|
|
|
int set_screen_mode(int sm)
|
|
|
|
{
|
2007-08-08 18:06:33 +00:00
|
|
|
if ( (Screen_mode == sm) && !((sm==SCREEN_GAME) && (grd_curscreen->sc_mode != Game_screen_mode)) && !(sm==SCREEN_MENU) )
|
|
|
|
{
|
|
|
|
gr_set_current_canvas(NULL);
|
|
|
|
return 1;
|
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
#ifdef EDITOR
|
|
|
|
Canv_editor = NULL;
|
|
|
|
#endif
|
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
Screen_mode = sm;
|
|
|
|
|
|
|
|
switch( Screen_mode )
|
|
|
|
{
|
2007-06-14 20:51:52 +00:00
|
|
|
case SCREEN_MENU:
|
2007-07-26 23:56:00 +00:00
|
|
|
if (grd_curscreen->sc_mode != Game_screen_mode)
|
|
|
|
if (gr_set_mode(Game_screen_mode))
|
|
|
|
Error("Cannot set screen mode.");
|
2007-06-14 20:51:52 +00:00
|
|
|
break;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2007-06-14 20:51:52 +00:00
|
|
|
case SCREEN_GAME:
|
|
|
|
if (grd_curscreen->sc_mode != Game_screen_mode)
|
|
|
|
if (gr_set_mode(Game_screen_mode))
|
|
|
|
Error("Cannot set screen mode.");
|
|
|
|
break;
|
2006-09-08 23:31:06 +00:00
|
|
|
#ifdef EDITOR
|
2007-06-14 20:51:52 +00:00
|
|
|
case SCREEN_EDITOR:
|
|
|
|
if (grd_curscreen->sc_mode != SM(800,600)) {
|
|
|
|
int gr_error;
|
|
|
|
if ((gr_error=gr_set_mode(SM(800,600)))!=0) { //force into game scrren
|
|
|
|
Warning("Cannot init editor screen (error=%d)",gr_error);
|
|
|
|
return 0;
|
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2007-06-14 20:51:52 +00:00
|
|
|
gr_palette_load( gr_palette );
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2008-02-24 14:41:27 +00:00
|
|
|
gr_init_sub_canvas( &VR_editor_canvas, &grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT );
|
2007-06-14 20:51:52 +00:00
|
|
|
Canv_editor = &VR_editor_canvas;
|
|
|
|
gr_set_current_canvas( Canv_editor );
|
|
|
|
init_editor_screen(); //setup other editor stuff
|
|
|
|
break;
|
2006-09-08 23:31:06 +00:00
|
|
|
#endif
|
2007-06-14 20:51:52 +00:00
|
|
|
default:
|
|
|
|
Error("Invalid screen mode %d",sm);
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 14:15:46 +00:00
|
|
|
gr_set_current_canvas(NULL);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-01-29 03:36:44 +00:00
|
|
|
static int time_paused=0;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
void stop_time()
|
|
|
|
{
|
2010-01-29 03:36:44 +00:00
|
|
|
if (time_paused==0) {
|
2010-07-04 13:57:21 +00:00
|
|
|
fix time;
|
2006-03-20 16:43:15 +00:00
|
|
|
time = timer_get_fixed_seconds();
|
|
|
|
last_timer_value = time - last_timer_value;
|
|
|
|
if (last_timer_value < 0) {
|
|
|
|
last_timer_value = 0;
|
|
|
|
}
|
|
|
|
}
|
2010-01-29 03:36:44 +00:00
|
|
|
time_paused++;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void start_time()
|
|
|
|
{
|
2010-01-29 03:36:44 +00:00
|
|
|
time_paused--;
|
|
|
|
Assert(time_paused >= 0);
|
|
|
|
if (time_paused==0) {
|
2010-07-04 13:57:21 +00:00
|
|
|
fix time;
|
2006-03-20 16:43:15 +00:00
|
|
|
time = timer_get_fixed_seconds();
|
|
|
|
last_timer_value = time - last_timer_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void game_flush_inputs()
|
|
|
|
{
|
2007-05-14 13:38:44 +00:00
|
|
|
int dx,dy,dz;
|
2010-07-30 17:59:21 +00:00
|
|
|
event_flush();
|
2006-03-20 16:43:15 +00:00
|
|
|
key_flush();
|
|
|
|
joy_flush();
|
|
|
|
mouse_flush();
|
2007-05-14 13:38:44 +00:00
|
|
|
mouse_get_delta( &dx, &dy, &dz ); // Read mouse
|
2006-03-20 16:43:15 +00:00
|
|
|
memset(&Controls,0,sizeof(control_info));
|
|
|
|
}
|
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
/*
|
|
|
|
Calculates several - common used - timesteps and stores into FixedStep
|
|
|
|
*/
|
|
|
|
void FixedStepCalc()
|
|
|
|
{
|
|
|
|
int StepRes = 0;
|
|
|
|
static fix Timer4 = 0, Timer20 = 0, Timer30 = 0;
|
|
|
|
|
|
|
|
Timer4 += FrameTime;
|
|
|
|
if (Timer4 >= F1_0/4)
|
|
|
|
{
|
|
|
|
StepRes |= EPS4;
|
|
|
|
Timer4 = 0 - (Timer4-F1_0/4);
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer20 += FrameTime;
|
|
|
|
if (Timer20 >= F1_0/20)
|
|
|
|
{
|
|
|
|
StepRes |= EPS20;
|
|
|
|
Timer20 = 0 - (Timer20-F1_0/20);
|
|
|
|
}
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
Timer30 += FrameTime;
|
|
|
|
if (Timer30 >= F1_0/30)
|
|
|
|
{
|
|
|
|
StepRes |= EPS30;
|
|
|
|
Timer30 = 0 - (Timer30-F1_0/30);
|
|
|
|
}
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
FixedStep = StepRes;
|
|
|
|
}
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
void reset_time()
|
2010-07-04 13:57:21 +00:00
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
last_timer_value = timer_get_fixed_seconds();
|
|
|
|
}
|
|
|
|
|
|
|
|
void calc_frame_time()
|
|
|
|
{
|
|
|
|
fix timer_value,last_frametime = FrameTime;
|
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
timer_value = timer_get_fixed_seconds();
|
|
|
|
FrameTime = timer_value - last_timer_value;
|
|
|
|
|
2008-09-30 00:18:39 +00:00
|
|
|
while (FrameTime < f1_0 / (GameCfg.VSync?MAXIMUM_FPS:GameArg.SysMaxFPS))
|
2007-03-25 21:00:14 +00:00
|
|
|
{
|
2008-09-30 00:18:39 +00:00
|
|
|
if (GameArg.SysUseNiceFPS && !GameCfg.VSync)
|
|
|
|
timer_delay(f1_0 / GameArg.SysMaxFPS - FrameTime);
|
|
|
|
timer_value = timer_get_fixed_seconds();
|
|
|
|
FrameTime = timer_value - last_timer_value;
|
2007-03-25 21:00:14 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
if ( Game_turbo_mode )
|
|
|
|
FrameTime *= 2;
|
|
|
|
|
|
|
|
last_timer_value = timer_value;
|
|
|
|
|
2006-03-27 17:38:11 +00:00
|
|
|
if (FrameTime < 0) //if bogus frametime...
|
2008-09-30 00:07:07 +00:00
|
|
|
FrameTime = (last_frametime==0?1:last_frametime); //...then use time from last frame
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
GameTime += FrameTime;
|
|
|
|
|
|
|
|
if (GameTime < 0 || GameTime > i2f(0x7fff - 600))
|
|
|
|
GameTime = FrameTime; //wrap when goes negative, or ~9hrs
|
|
|
|
|
|
|
|
FixedStepCalc();
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void move_player_2_segment(segment *seg,int side)
|
|
|
|
{
|
|
|
|
vms_vector vp;
|
|
|
|
|
|
|
|
compute_segment_center(&ConsoleObject->pos,seg);
|
|
|
|
compute_center_point_on_side(&vp,seg,side);
|
|
|
|
vm_vec_sub2(&vp,&ConsoleObject->pos);
|
|
|
|
vm_vector_2_matrix(&ConsoleObject->orient,&vp,NULL,NULL);
|
|
|
|
|
|
|
|
obj_relink( ConsoleObject-Objects, SEG_PTR_2_NUM(seg) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void do_photos();
|
|
|
|
void level_with_floor();
|
|
|
|
|
|
|
|
#ifndef OGL
|
|
|
|
void save_screen_shot(int automap_flag)
|
|
|
|
{
|
|
|
|
char message[100];
|
|
|
|
grs_canvas *screen_canv=&grd_curscreen->sc_canvas;
|
2008-01-23 17:25:09 +00:00
|
|
|
static int savenum=0;
|
2008-10-28 17:04:35 +00:00
|
|
|
grs_canvas *temp_canv,*save_canv;
|
|
|
|
char savename[FILENAME_LEN+sizeof(SCRNS_DIR)];
|
2006-03-20 16:43:15 +00:00
|
|
|
ubyte pal[768];
|
|
|
|
|
|
|
|
stop_time();
|
|
|
|
|
2007-01-25 09:56:05 +00:00
|
|
|
if (!cfexist(SCRNS_DIR))
|
2008-01-23 17:25:09 +00:00
|
|
|
PHYSFS_mkdir(SCRNS_DIR); //try making directory
|
2007-01-25 09:56:05 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
save_canv = grd_curcanv;
|
2008-10-28 17:04:35 +00:00
|
|
|
temp_canv = gr_create_canvas(screen_canv->cv_bitmap.bm_w,screen_canv->cv_bitmap.bm_h);
|
|
|
|
gr_set_current_canvas(temp_canv);
|
|
|
|
gr_ubitmap(0,0,&screen_canv->cv_bitmap);
|
2008-01-23 17:25:09 +00:00
|
|
|
|
|
|
|
gr_set_current_canvas(save_canv);
|
|
|
|
|
2008-10-28 17:04:35 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
sprintf(savename, "%sscrn%04d.pcx",SCRNS_DIR, savenum++);
|
|
|
|
} while (PHYSFS_exists(savename));
|
|
|
|
sprintf( message, "%s 'scrn%04d.pcx'", TXT_DUMPING_SCREEN, savenum-1 );
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2007-03-22 14:15:46 +00:00
|
|
|
gr_set_current_canvas(NULL);
|
2008-01-23 17:25:09 +00:00
|
|
|
|
2008-10-28 17:04:35 +00:00
|
|
|
if (!automap_flag)
|
2010-07-13 06:35:25 +00:00
|
|
|
HUD_init_message(HM_DEFAULT, message);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-01-23 17:25:09 +00:00
|
|
|
gr_palette_read(pal); //get actual palette from the hardware
|
2006-03-20 16:43:15 +00:00
|
|
|
pcx_write_bitmap(savename,&temp_canv->cv_bitmap,pal);
|
|
|
|
gr_set_current_canvas(screen_canv);
|
2008-10-28 17:04:35 +00:00
|
|
|
gr_ubitmap(0,0,&temp_canv->cv_bitmap);
|
2006-03-20 16:43:15 +00:00
|
|
|
gr_free_canvas(temp_canv);
|
|
|
|
gr_set_current_canvas(save_canv);
|
2008-10-28 17:04:35 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
key_flush();
|
|
|
|
start_time();
|
|
|
|
}
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2008-01-23 17:25:09 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//initialize flying
|
|
|
|
void fly_init(object *obj)
|
|
|
|
{
|
|
|
|
obj->control_type = CT_FLYING;
|
|
|
|
obj->movement_type = MT_PHYSICS;
|
|
|
|
|
|
|
|
vm_vec_zero(&obj->mtype.phys_info.velocity);
|
|
|
|
vm_vec_zero(&obj->mtype.phys_info.thrust);
|
|
|
|
vm_vec_zero(&obj->mtype.phys_info.rotvel);
|
|
|
|
vm_vec_zero(&obj->mtype.phys_info.rotthrust);
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_anim_states();
|
|
|
|
|
|
|
|
extern int been_in_editor;
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------
|
|
|
|
void do_cloak_stuff(void)
|
|
|
|
{
|
|
|
|
int i;
|
2007-10-28 20:14:25 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
for (i = 0; i < N_players; i++)
|
|
|
|
if (Players[i].flags & PLAYER_FLAGS_CLOAKED) {
|
2007-10-28 20:14:25 +00:00
|
|
|
if (Players[Player_num].cloak_time+CLOAK_TIME_MAX-GameTime < 0 &&
|
|
|
|
Players[Player_num].cloak_time+CLOAK_TIME_MAX-GameTime > -F1_0*2)
|
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
Players[i].flags &= ~PLAYER_FLAGS_CLOAKED;
|
|
|
|
if (i == Player_num) {
|
|
|
|
digi_play_sample( SOUND_CLOAK_OFF, F1_0);
|
2006-09-08 23:31:06 +00:00
|
|
|
#ifdef NETWORK
|
2006-03-20 16:43:15 +00:00
|
|
|
if (Game_mode & GM_MULTI)
|
|
|
|
multi_send_play_sound(SOUND_CLOAK_OFF, F1_0);
|
|
|
|
maybe_drop_net_powerup(POW_CLOAK);
|
2007-05-02 18:42:46 +00:00
|
|
|
if ( Newdemo_state != ND_STATE_PLAYBACK )
|
2007-02-28 20:43:10 +00:00
|
|
|
multi_send_decloak(); // For demo recording
|
2006-09-08 23:31:06 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------
|
|
|
|
void do_invulnerable_stuff(void)
|
|
|
|
{
|
|
|
|
if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) {
|
2007-10-28 20:14:25 +00:00
|
|
|
if (Players[Player_num].invulnerable_time+INVULNERABLE_TIME_MAX-GameTime < 0 &&
|
|
|
|
Players[Player_num].invulnerable_time+INVULNERABLE_TIME_MAX-GameTime > -F1_0*2)
|
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
Players[Player_num].flags ^= PLAYER_FLAGS_INVULNERABLE;
|
2006-09-08 23:31:06 +00:00
|
|
|
#ifdef NETWORK
|
2006-03-20 16:43:15 +00:00
|
|
|
maybe_drop_net_powerup(POW_INVULNERABILITY);
|
2006-09-08 23:31:06 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
digi_play_sample( SOUND_INVULNERABILITY_OFF, F1_0);
|
2006-09-08 23:31:06 +00:00
|
|
|
#ifdef NETWORK
|
2006-03-20 16:43:15 +00:00
|
|
|
if (Game_mode & GM_MULTI)
|
|
|
|
multi_send_play_sound(SOUND_INVULNERABILITY_OFF, F1_0);
|
2006-09-08 23:31:06 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Amount to diminish guns towards normal, per second.
|
2006-09-08 23:31:06 +00:00
|
|
|
#define DIMINISH_RATE 16 // gots to be a power of 2, else change the code in diminish_palette_towards_normal
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-12-02 13:49:54 +00:00
|
|
|
//adds to rgb values for palette flash
|
|
|
|
void PALETTE_FLASH_ADD(int _dr, int _dg, int _db)
|
|
|
|
{
|
|
|
|
int maxval;
|
|
|
|
|
|
|
|
PaletteRedAdd += _dr;
|
|
|
|
PaletteGreenAdd += _dg;
|
|
|
|
PaletteBlueAdd += _db;
|
|
|
|
|
|
|
|
maxval = MAX_PALETTE_ADD;
|
|
|
|
|
|
|
|
if (PaletteRedAdd > maxval)
|
|
|
|
PaletteRedAdd = maxval;
|
|
|
|
|
|
|
|
if (PaletteGreenAdd > maxval)
|
|
|
|
PaletteGreenAdd = maxval;
|
|
|
|
|
|
|
|
if (PaletteBlueAdd > maxval)
|
|
|
|
PaletteBlueAdd = maxval;
|
|
|
|
|
|
|
|
if (PaletteRedAdd < -maxval)
|
|
|
|
PaletteRedAdd = -maxval;
|
|
|
|
|
|
|
|
if (PaletteGreenAdd < -maxval)
|
|
|
|
PaletteGreenAdd = -maxval;
|
|
|
|
|
|
|
|
if (PaletteBlueAdd < -maxval)
|
|
|
|
PaletteBlueAdd = -maxval;
|
|
|
|
}
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
|
|
|
// Diminish palette effects towards normal.
|
|
|
|
void diminish_palette_towards_normal(void)
|
|
|
|
{
|
|
|
|
int dec_amount = 0;
|
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
// Diminish at DIMINISH_RATE units/second.
|
|
|
|
// For frame rates > DIMINISH_RATE Hz, use randomness to achieve this.
|
2006-03-20 16:43:15 +00:00
|
|
|
if (FrameTime < F1_0/DIMINISH_RATE) {
|
2009-07-01 11:35:33 +00:00
|
|
|
if (d_rand() < FrameTime*DIMINISH_RATE/2) // Note: d_rand() is in 0..32767, and 8 Hz means decrement every frame
|
2006-03-20 16:43:15 +00:00
|
|
|
dec_amount = 1;
|
|
|
|
} else {
|
2006-09-08 23:31:06 +00:00
|
|
|
dec_amount = f2i(FrameTime*DIMINISH_RATE); // one second = DIMINISH_RATE counts
|
2006-03-20 16:43:15 +00:00
|
|
|
if (dec_amount == 0)
|
2006-09-08 23:31:06 +00:00
|
|
|
dec_amount++; // make sure we decrement by something
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (PaletteRedAdd > 0 ) { PaletteRedAdd -= dec_amount; if (PaletteRedAdd < 0 ) PaletteRedAdd = 0; }
|
|
|
|
if (PaletteRedAdd < 0 ) { PaletteRedAdd += dec_amount; if (PaletteRedAdd > 0 ) PaletteRedAdd = 0; }
|
|
|
|
|
|
|
|
if (PaletteGreenAdd > 0 ) { PaletteGreenAdd -= dec_amount; if (PaletteGreenAdd < 0 ) PaletteGreenAdd = 0; }
|
|
|
|
if (PaletteGreenAdd < 0 ) { PaletteGreenAdd += dec_amount; if (PaletteGreenAdd > 0 ) PaletteGreenAdd = 0; }
|
|
|
|
|
|
|
|
if (PaletteBlueAdd > 0 ) { PaletteBlueAdd -= dec_amount; if (PaletteBlueAdd < 0 ) PaletteBlueAdd = 0; }
|
|
|
|
if (PaletteBlueAdd < 0 ) { PaletteBlueAdd += dec_amount; if (PaletteBlueAdd > 0 ) PaletteBlueAdd = 0; }
|
|
|
|
|
|
|
|
if ( (Newdemo_state==ND_STATE_RECORDING) && (PaletteRedAdd || PaletteGreenAdd || PaletteBlueAdd) )
|
|
|
|
newdemo_record_palette_effect(PaletteRedAdd, PaletteGreenAdd, PaletteBlueAdd);
|
|
|
|
|
|
|
|
gr_palette_step_up( PaletteRedAdd, PaletteGreenAdd, PaletteBlueAdd );
|
|
|
|
}
|
|
|
|
|
|
|
|
int Redsave, Bluesave, Greensave;
|
|
|
|
|
|
|
|
void palette_save(void)
|
|
|
|
{
|
|
|
|
Redsave = PaletteRedAdd; Bluesave = PaletteBlueAdd; Greensave = PaletteGreenAdd;
|
|
|
|
}
|
|
|
|
|
|
|
|
void palette_restore(void)
|
|
|
|
{
|
|
|
|
PaletteRedAdd = Redsave; PaletteBlueAdd = Bluesave; PaletteGreenAdd = Greensave;
|
|
|
|
gr_palette_step_up( PaletteRedAdd, PaletteGreenAdd, PaletteBlueAdd );
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void dead_player_frame(void);
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------------
|
|
|
|
int allowed_to_fire_laser(void)
|
|
|
|
{
|
|
|
|
if (Player_is_dead) {
|
|
|
|
Global_missile_firing_count = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure enough time has elapsed to fire laser, but if it looks like it will
|
|
|
|
// be a long while before laser can be fired, then there must be some mistake!
|
|
|
|
if (Next_laser_fire_time > GameTime)
|
|
|
|
if (Next_laser_fire_time < GameTime + 2*F1_0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int allowed_to_fire_flare(void)
|
|
|
|
{
|
|
|
|
if (Next_flare_fire_time > GameTime)
|
|
|
|
if (Next_flare_fire_time < GameTime + F1_0) // In case time is bogus, never wait > 1 second.
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
Next_flare_fire_time = GameTime + F1_0/4;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int allowed_to_fire_missile(void)
|
|
|
|
{
|
|
|
|
// Make sure enough time has elapsed to fire missile, but if it looks like it will
|
|
|
|
// be a long while before missile can be fired, then there must be some mistake!
|
|
|
|
if (Next_missile_fire_time > GameTime)
|
|
|
|
if (Next_missile_fire_time < GameTime + 5*F1_0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int Death_sequence_aborted;
|
|
|
|
|
2008-06-15 08:50:05 +00:00
|
|
|
#ifdef USE_SDLMIXER
|
|
|
|
#define EXT_MUSIC_TEXT "Jukebox/Audio CD"
|
|
|
|
#else
|
|
|
|
#define EXT_MUSIC_TEXT "Audio CD"
|
|
|
|
#endif
|
|
|
|
|
2010-04-03 07:24:50 +00:00
|
|
|
static int free_help(newmenu *menu, d_event *event, void *userdata)
|
|
|
|
{
|
|
|
|
userdata = userdata;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-04-03 07:24:50 +00:00
|
|
|
if (event->type == EVENT_WINDOW_CLOSE)
|
|
|
|
{
|
|
|
|
newmenu_item *items = newmenu_get_items(menu);
|
|
|
|
d_free(items);
|
|
|
|
}
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-04-03 07:24:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
void show_help()
|
|
|
|
{
|
2008-04-06 20:23:28 +00:00
|
|
|
int nitems = 0;
|
2010-04-03 07:24:50 +00:00
|
|
|
newmenu_item *m;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-04-03 07:24:50 +00:00
|
|
|
MALLOC(m, newmenu_item, 26);
|
|
|
|
if (!m)
|
|
|
|
return;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2008-04-06 20:23:28 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = TXT_HELP_ESC;
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "SHIFT-ESC\t SHOW GAME LOG";
|
2008-12-13 12:58:57 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "F1\t THIS SCREEN";
|
2008-04-06 20:23:28 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = TXT_HELP_F2;
|
2008-12-07 12:26:43 +00:00
|
|
|
#if !(defined(__APPLE__) || defined(macintosh))
|
2008-04-06 20:23:28 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Alt-F2/F3\t SAVE/LOAD GAME";
|
2010-02-25 03:08:10 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Alt-F1\t Fast Save";
|
2008-12-07 12:26:43 +00:00
|
|
|
#else
|
2010-02-25 03:08:10 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Alt-F2/F3 (\x85-SHIFT-s/\x85-o)\t SAVE/LOAD GAME";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Alt-F1 (\x85-s)\t Fast Save";
|
2008-12-07 12:26:43 +00:00
|
|
|
#endif
|
2008-04-06 20:23:28 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "F3\t SWITCH COCKPIT MODES";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = TXT_HELP_F5;
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "ALT-F7\t SWITCH HUD MODES";
|
2008-12-07 12:26:43 +00:00
|
|
|
#if !(defined(__APPLE__) || defined(macintosh))
|
2008-04-06 20:23:28 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = TXT_HELP_PAUSE;
|
2008-12-07 12:26:43 +00:00
|
|
|
#else
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Pause (\x85-P)\t Pause";
|
|
|
|
#endif
|
2008-04-06 20:23:28 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = TXT_HELP_PRTSCN;
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = TXT_HELP_1TO5;
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = TXT_HELP_6TO10;
|
2008-12-07 12:26:43 +00:00
|
|
|
#if !(defined(__APPLE__) || defined(macintosh))
|
2008-06-15 08:50:05 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Alt-Shift-F9\t Eject Audio CD";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Alt-Shift-F10\t Play/Pause " EXT_MUSIC_TEXT;
|
2008-06-01 12:53:03 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "Alt-Shift-F11/F12\t Previous/Next Song";
|
2008-12-07 12:26:43 +00:00
|
|
|
#else
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "\x85-E\t Eject Audio CD";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "\x85-Up/Down\t Play/Pause " EXT_MUSIC_TEXT;
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "\x85-Left/Right\t Previous/Next Song";
|
|
|
|
#endif
|
2008-12-13 12:58:57 +00:00
|
|
|
#if (defined(__APPLE__) || defined(macintosh))
|
2008-04-06 20:23:28 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "";
|
2008-12-13 12:58:57 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "(Use \x85-# for F#. e.g. \x85-1 for F1)";
|
|
|
|
#endif
|
2010-04-03 07:24:50 +00:00
|
|
|
|
2010-06-30 15:26:27 +00:00
|
|
|
newmenu_dotiny( NULL, TXT_KEYS, nitems, m, 0, free_help, NULL );
|
2008-12-13 12:58:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void show_netgame_help()
|
|
|
|
{
|
|
|
|
int nitems = 0;
|
2010-04-03 07:24:50 +00:00
|
|
|
newmenu_item *m;
|
2008-12-13 12:58:57 +00:00
|
|
|
|
2010-04-03 07:24:50 +00:00
|
|
|
MALLOC(m, newmenu_item, 13);
|
|
|
|
if (!m)
|
|
|
|
return;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2008-12-13 12:58:57 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "F1\t THIS SCREEN";
|
2008-04-06 20:23:28 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "ALT-F4\t SHOW RETICLE NAMES";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "F7\t TOGGLE KILL LIST";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "F8\t SEND MESSAGE";
|
2010-06-15 17:20:37 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "(SHIFT-)F9 to F12\t (DEFINE)SEND MACRO";
|
2008-04-06 20:23:28 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "PAUSE\t SHOW NETGAME INFORMATION";
|
2008-12-13 12:58:57 +00:00
|
|
|
|
2008-12-07 12:26:43 +00:00
|
|
|
#if (defined(__APPLE__) || defined(macintosh))
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "(Use \x85-# for F#. e.g. \x85-1 for F1)";
|
|
|
|
#endif
|
2008-12-13 12:58:57 +00:00
|
|
|
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "MULTIPLAYER MESSAGE COMMANDS:";
|
2010-02-23 15:22:28 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "(*): TEXT\t SEND TEXT TO PLAYER (*)";
|
2008-12-13 12:58:57 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "kick: (*)\t KICK PLAYER (*) FROM GAME (Host-only)";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "KillReactor\t BLOW UP THE MINE (Host-only)";
|
|
|
|
|
2010-06-30 15:26:27 +00:00
|
|
|
newmenu_dotiny( NULL, TXT_KEYS, nitems, m, 0, free_help, NULL );
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2007-11-06 20:33:22 +00:00
|
|
|
void show_newdemo_help()
|
|
|
|
{
|
2010-04-03 07:24:50 +00:00
|
|
|
newmenu_item *m;
|
2008-12-13 12:58:57 +00:00
|
|
|
int nitems = 0;
|
|
|
|
|
2010-04-03 07:24:50 +00:00
|
|
|
MALLOC(m, newmenu_item, 15);
|
|
|
|
if (!m)
|
|
|
|
return;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2008-12-13 12:58:57 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "ESC\t QUIT DEMO PLAYBACK";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "F1\t THIS SCREEN";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = TXT_HELP_F2;
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "F3\t SWITCH COCKPIT MODES";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "F4\t TOGGLE PERCENTAGE DISPLAY";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "UP\t PLAY";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "DOWN\t PAUSE";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "RIGHT\t ONE FRAME FORWARD";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "LEFT\t ONE FRAME BACKWARD";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "SHIFT-RIGHT\t FAST FORWARD";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "SHIFT-LEFT\t FAST BACKWARD";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "CTRL-RIGHT\t JUMP TO END";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "CTRL-LEFT\t JUMP TO START";
|
2008-12-07 12:26:43 +00:00
|
|
|
#if (defined(__APPLE__) || defined(macintosh))
|
2008-12-13 12:58:57 +00:00
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "";
|
|
|
|
m[nitems].type = NM_TYPE_TEXT; m[nitems++].text = "(Use \x85-# for F#. e.g. \x85-1 for F1)";
|
2008-12-07 12:26:43 +00:00
|
|
|
#endif
|
2010-04-03 07:24:50 +00:00
|
|
|
|
2010-06-30 15:26:27 +00:00
|
|
|
newmenu_dotiny( NULL, "DEMO PLAYBACK CONTROLS", nitems, m, 0, free_help, NULL );
|
2007-11-06 20:33:22 +00:00
|
|
|
}
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//temp function until Matt cleans up game sequencing
|
|
|
|
extern void temp_reset_stuff_on_level();
|
|
|
|
|
2008-10-16 17:27:02 +00:00
|
|
|
#define LEAVE_TIME 0x4000 //how long until we decide key is down (Used to be 0x4000)
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//deal with rear view - switch it on, or off, or whatever
|
|
|
|
void check_rear_view()
|
|
|
|
{
|
|
|
|
static int leave_mode;
|
|
|
|
static fix entry_time;
|
|
|
|
|
2009-11-30 14:59:37 +00:00
|
|
|
if (Newdemo_state == ND_STATE_PLAYBACK)
|
|
|
|
return;
|
|
|
|
|
2006-09-08 23:31:06 +00:00
|
|
|
if ( Controls.rear_view_down_count ) { //key/button has gone down
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
if (Rear_view) {
|
|
|
|
Rear_view = 0;
|
2010-01-28 00:04:29 +00:00
|
|
|
if (PlayerCfg.CockpitMode[1]==CM_REAR_VIEW) {
|
|
|
|
select_cockpit(PlayerCfg.CockpitMode[0]);
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
if (Newdemo_state == ND_STATE_RECORDING)
|
|
|
|
newdemo_record_restore_rearview();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Rear_view = 1;
|
|
|
|
leave_mode = 0; //means wait for another key
|
|
|
|
entry_time = timer_get_fixed_seconds();
|
2010-01-28 00:04:29 +00:00
|
|
|
if (PlayerCfg.CockpitMode[1] == CM_FULL_COCKPIT) {
|
2006-03-20 16:43:15 +00:00
|
|
|
select_cockpit(CM_REAR_VIEW);
|
|
|
|
}
|
|
|
|
if (Newdemo_state == ND_STATE_RECORDING)
|
|
|
|
newdemo_record_rearview();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (Controls.rear_view_down_state) {
|
2009-07-01 11:35:33 +00:00
|
|
|
|
|
|
|
if (leave_mode == 0 && (timer_get_fixed_seconds() - entry_time) > LEAVE_TIME)
|
2006-03-20 16:43:15 +00:00
|
|
|
leave_mode = 1;
|
|
|
|
}
|
2006-09-08 23:31:06 +00:00
|
|
|
else
|
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
if (leave_mode==1 && Rear_view) {
|
|
|
|
Rear_view = 0;
|
2010-01-28 00:04:29 +00:00
|
|
|
if (PlayerCfg.CockpitMode[1]==CM_REAR_VIEW) {
|
|
|
|
select_cockpit(PlayerCfg.CockpitMode[0]);
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
if (Newdemo_state == ND_STATE_RECORDING)
|
|
|
|
newdemo_record_restore_rearview();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset_rear_view(void)
|
|
|
|
{
|
|
|
|
if (Rear_view) {
|
|
|
|
if (Newdemo_state == ND_STATE_RECORDING)
|
|
|
|
newdemo_record_restore_rearview();
|
|
|
|
}
|
|
|
|
|
|
|
|
Rear_view = 0;
|
2010-01-28 00:04:29 +00:00
|
|
|
select_cockpit(PlayerCfg.CockpitMode[0]);
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Config_menu_flag;
|
|
|
|
|
2009-06-07 11:28:12 +00:00
|
|
|
extern int Laser_rapid_fire, Ugly_robot_cheat;
|
|
|
|
extern void do_lunacy_on(), do_lunacy_off();
|
2006-09-08 23:31:06 +00:00
|
|
|
extern int Physics_cheat_flag;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-06-07 11:28:12 +00:00
|
|
|
extern int cheat_enable_index;
|
|
|
|
extern int cheat_wowie_index;
|
|
|
|
extern int cheat_allkeys_index;
|
|
|
|
extern int cheat_invuln_index;
|
|
|
|
extern int cheat_cloak_index;
|
|
|
|
extern int cheat_shield_index;
|
|
|
|
extern int cheat_warp_index;
|
|
|
|
extern int cheat_astral_index;
|
2010-07-17 12:08:45 +00:00
|
|
|
extern int cheat_poboys_index;
|
2009-06-07 11:28:12 +00:00
|
|
|
extern int cheat_turbomode_index;
|
|
|
|
extern int cheat_wowie2_index;
|
|
|
|
extern int cheat_newlife_index;
|
|
|
|
extern int cheat_exitpath_index;
|
|
|
|
extern int cheat_robotpause_index;
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
void game_disable_cheats()
|
|
|
|
{
|
|
|
|
Game_turbo_mode = 0;
|
|
|
|
Cheats_enabled=0;
|
|
|
|
do_lunacy_off();
|
|
|
|
Laser_rapid_fire = 0;
|
|
|
|
Ugly_robot_cheat = 0;
|
|
|
|
Physics_cheat_flag = 0;
|
|
|
|
}
|
|
|
|
|
2009-01-15 20:55:35 +00:00
|
|
|
// game_setup()
|
|
|
|
// ----------------------------------------------------------------------------
|
2007-08-25 23:35:19 +00:00
|
|
|
|
2009-08-10 10:47:17 +00:00
|
|
|
int game_handler(window *wind, d_event *event, void *data);
|
|
|
|
|
|
|
|
window *game_setup(void)
|
2009-01-15 20:55:35 +00:00
|
|
|
{
|
2009-08-10 10:47:17 +00:00
|
|
|
window *game_wind;
|
|
|
|
|
2010-02-07 04:34:21 +00:00
|
|
|
#ifdef EDITOR
|
|
|
|
keyd_editor_mode = 0;
|
|
|
|
#endif
|
2006-09-08 23:31:06 +00:00
|
|
|
do_lunacy_on(); // Copy values for insane into copy buffer in ai.c
|
|
|
|
do_lunacy_off(); // Restore true insane mode.
|
2010-01-28 00:04:29 +00:00
|
|
|
PlayerCfg.CockpitMode[1] = PlayerCfg.CockpitMode[0];
|
2007-03-22 14:15:46 +00:00
|
|
|
last_drawn_cockpit = -1; // Force cockpit to redraw next time a frame renders.
|
2006-03-20 16:43:15 +00:00
|
|
|
Endlevel_sequence = 0;
|
|
|
|
cheat_enable_index = 0;
|
|
|
|
|
2010-07-17 12:08:45 +00:00
|
|
|
cheat_wowie_index = cheat_allkeys_index = cheat_invuln_index = cheat_cloak_index = cheat_shield_index = cheat_warp_index = cheat_astral_index = cheat_poboys_index = cheat_turbomode_index = cheat_wowie2_index = 0;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-08-10 10:47:17 +00:00
|
|
|
game_wind = window_create(&grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, game_handler, NULL);
|
|
|
|
if (!game_wind)
|
|
|
|
return NULL;
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
reset_palette_add();
|
|
|
|
set_warn_func(game_show_warning);
|
|
|
|
init_cockpit();
|
|
|
|
init_gauges();
|
|
|
|
|
2006-09-08 23:31:06 +00:00
|
|
|
#ifdef EDITOR
|
|
|
|
if (Segments[ConsoleObject->segnum].segnum == -1) //segment no longer exists
|
|
|
|
obj_relink( ConsoleObject-Objects, SEG_PTR_2_NUM(Cursegp) );
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2006-09-08 23:31:06 +00:00
|
|
|
if (!check_obj_seg(ConsoleObject))
|
|
|
|
move_player_2_segment(Cursegp,Curside);
|
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
Viewer = ConsoleObject;
|
|
|
|
fly_init(ConsoleObject);
|
|
|
|
Game_suspended = 0;
|
|
|
|
reset_time();
|
|
|
|
FrameTime = 0; //make first frame zero
|
|
|
|
|
2006-09-08 23:31:06 +00:00
|
|
|
#ifdef EDITOR
|
|
|
|
if (Current_level_num == 0) { //not a real level
|
2006-03-20 16:43:15 +00:00
|
|
|
init_player_stats_game();
|
|
|
|
init_ai_objects();
|
|
|
|
}
|
2006-09-08 23:31:06 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
fix_object_segs();
|
2009-08-10 10:47:17 +00:00
|
|
|
|
|
|
|
return game_wind;
|
2009-01-15 20:55:35 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 10:47:17 +00:00
|
|
|
void game_render_frame();
|
|
|
|
|
2010-01-20 11:04:09 +00:00
|
|
|
window *Game_wind = NULL;
|
|
|
|
|
2009-08-10 10:47:17 +00:00
|
|
|
// Event handler for the game
|
|
|
|
int game_handler(window *wind, d_event *event, void *data)
|
2009-01-15 20:55:35 +00:00
|
|
|
{
|
2009-08-10 10:47:17 +00:00
|
|
|
data = data;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2010-01-20 11:04:09 +00:00
|
|
|
switch (event->type)
|
2009-08-10 10:47:17 +00:00
|
|
|
{
|
2010-02-02 03:38:29 +00:00
|
|
|
case EVENT_WINDOW_ACTIVATED:
|
2010-07-29 08:30:46 +00:00
|
|
|
set_screen_mode(SCREEN_GAME);
|
|
|
|
|
2010-07-28 17:27:35 +00:00
|
|
|
mouse_toggle_cursor(0);
|
2010-07-30 17:59:21 +00:00
|
|
|
game_flush_inputs();
|
2010-07-16 11:07:42 +00:00
|
|
|
|
2010-03-27 04:30:59 +00:00
|
|
|
if (time_paused)
|
2010-02-02 03:38:29 +00:00
|
|
|
start_time();
|
|
|
|
|
2010-03-20 13:53:08 +00:00
|
|
|
if (!((Game_mode & GM_MULTI) && (Newdemo_state != ND_STATE_PLAYBACK)))
|
2010-02-02 03:38:29 +00:00
|
|
|
digi_resume_digi_sounds();
|
2010-02-05 02:31:36 +00:00
|
|
|
|
|
|
|
if (!((Game_mode & GM_MULTI) && (Newdemo_state != ND_STATE_PLAYBACK)))
|
|
|
|
palette_restore();
|
2010-07-29 08:30:46 +00:00
|
|
|
|
|
|
|
reset_cockpit();
|
2010-02-02 03:38:29 +00:00
|
|
|
break;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-02-02 03:38:29 +00:00
|
|
|
case EVENT_WINDOW_DEACTIVATED:
|
2010-03-20 13:53:08 +00:00
|
|
|
if (!(((Game_mode & GM_MULTI) && (Newdemo_state != ND_STATE_PLAYBACK)) && (!Endlevel_sequence)) )
|
2010-02-02 03:38:29 +00:00
|
|
|
stop_time();
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-03-20 13:53:08 +00:00
|
|
|
if (!((Game_mode & GM_MULTI) && (Newdemo_state != ND_STATE_PLAYBACK)))
|
2010-02-02 03:38:29 +00:00
|
|
|
digi_pause_digi_sounds();
|
2010-02-05 02:31:36 +00:00
|
|
|
|
|
|
|
if (!((Game_mode & GM_MULTI) && (Newdemo_state != ND_STATE_PLAYBACK)))
|
|
|
|
palette_save();
|
2010-07-16 11:07:42 +00:00
|
|
|
|
2010-07-28 17:27:35 +00:00
|
|
|
mouse_toggle_cursor(1);
|
2010-02-02 03:38:29 +00:00
|
|
|
break;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-03-31 09:18:28 +00:00
|
|
|
case EVENT_MOUSE_BUTTON_UP:
|
|
|
|
case EVENT_MOUSE_BUTTON_DOWN:
|
|
|
|
case EVENT_KEY_COMMAND:
|
2010-08-14 02:26:18 +00:00
|
|
|
case EVENT_IDLE: // EVENT_IDLE will be removed once all input events are in place
|
2010-03-31 09:18:28 +00:00
|
|
|
return ReadControls(event);
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-01-20 11:04:09 +00:00
|
|
|
case EVENT_WINDOW_DRAW:
|
2010-01-29 03:36:44 +00:00
|
|
|
if (!time_paused)
|
|
|
|
{
|
|
|
|
calc_frame_time();
|
|
|
|
GameProcessFrame();
|
|
|
|
}
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-01-29 03:36:44 +00:00
|
|
|
if (!Automap_active) // efficiency hack
|
|
|
|
{
|
|
|
|
if (force_cockpit_redraw) { //screen need redrawing?
|
|
|
|
init_cockpit();
|
|
|
|
force_cockpit_redraw=0;
|
|
|
|
}
|
|
|
|
game_render_frame();
|
2010-01-20 11:04:09 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-01-20 11:04:09 +00:00
|
|
|
case EVENT_WINDOW_CLOSE:
|
2010-06-14 08:13:16 +00:00
|
|
|
digi_stop_digi_sounds();
|
|
|
|
|
2010-01-20 11:04:09 +00:00
|
|
|
if ( (Newdemo_state == ND_STATE_RECORDING) || (Newdemo_state == ND_STATE_PAUSED) )
|
|
|
|
newdemo_stop_recording();
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-01-20 11:04:09 +00:00
|
|
|
#ifdef NETWORK
|
|
|
|
multi_leave_game();
|
|
|
|
#endif
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-01-20 11:04:09 +00:00
|
|
|
if ( Newdemo_state == ND_STATE_PLAYBACK )
|
|
|
|
newdemo_stop_playback();
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-04-04 01:31:48 +00:00
|
|
|
songs_play_song( SONG_TITLE, 1 );
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-01-20 11:04:09 +00:00
|
|
|
clear_warn_func(game_show_warning); //don't use this func anymore
|
|
|
|
game_disable_cheats();
|
2010-07-08 09:35:59 +00:00
|
|
|
Game_mode = GM_GAME_OVER;
|
2010-03-18 07:02:38 +00:00
|
|
|
show_menus();
|
2010-01-20 11:04:09 +00:00
|
|
|
Game_wind = NULL;
|
2010-07-28 17:27:35 +00:00
|
|
|
mouse_toggle_cursor(1);
|
2010-01-20 11:04:09 +00:00
|
|
|
break;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-02-02 07:52:03 +00:00
|
|
|
case EVENT_WINDOW_CLOSED:
|
2010-02-07 04:34:21 +00:00
|
|
|
longjmp(LeaveEvents, 0);
|
2010-02-02 07:52:03 +00:00
|
|
|
break;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-01-20 11:04:09 +00:00
|
|
|
default:
|
|
|
|
break;
|
2009-08-10 10:47:17 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2010-08-14 02:26:18 +00:00
|
|
|
return 0;
|
2009-08-10 10:47:17 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2010-02-07 04:34:21 +00:00
|
|
|
// Initialise game, actually runs in main event loop
|
2009-08-10 10:47:17 +00:00
|
|
|
void game()
|
|
|
|
{
|
2010-03-18 07:02:38 +00:00
|
|
|
hide_menus();
|
2009-12-02 13:49:54 +00:00
|
|
|
Game_wind = game_setup();
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//called at the end of the program
|
|
|
|
void close_game()
|
|
|
|
{
|
|
|
|
if (VR_offscreen_buffer) {
|
|
|
|
gr_free_canvas(VR_offscreen_buffer);
|
|
|
|
VR_offscreen_buffer = NULL;
|
|
|
|
}
|
|
|
|
|
2008-10-28 13:28:10 +00:00
|
|
|
close_gauges();
|
2006-03-20 16:43:15 +00:00
|
|
|
restore_effect_bitmap_icons();
|
|
|
|
clear_warn_func(game_show_warning); //don't use this func anymore
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef EDITOR
|
2009-07-01 11:35:33 +00:00
|
|
|
extern void player_follow_path(object *objp);
|
|
|
|
extern void check_create_player_path(void);
|
2006-03-20 16:43:15 +00:00
|
|
|
#endif
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2006-09-08 23:31:06 +00:00
|
|
|
extern int Do_appearance_effect;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2010-01-31 07:45:26 +00:00
|
|
|
void game_leave_menus(void)
|
|
|
|
{
|
|
|
|
window *wind;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-01-31 07:45:26 +00:00
|
|
|
if (!Game_wind)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (wind = window_get_next(Game_wind); wind != NULL; wind = window_get_next(wind))
|
|
|
|
window_close(wind);
|
|
|
|
}
|
|
|
|
|
2009-08-10 10:47:17 +00:00
|
|
|
void GameProcessFrame(void)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2010-01-31 07:45:26 +00:00
|
|
|
fix player_shields = Players[Player_num].shields;
|
|
|
|
int was_fuelcen_destroyed = Control_center_destroyed;
|
|
|
|
int player_was_dead = Player_is_dead;
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
update_player_stats();
|
|
|
|
diminish_palette_towards_normal(); // Should leave palette effect up for as long as possible by putting right before render.
|
|
|
|
do_cloak_stuff();
|
|
|
|
do_invulnerable_stuff();
|
|
|
|
remove_obsolete_stuck_objects();
|
2006-03-20 16:43:15 +00:00
|
|
|
#ifdef EDITOR
|
2008-09-30 00:07:07 +00:00
|
|
|
check_create_player_path();
|
|
|
|
player_follow_path(ConsoleObject);
|
2006-03-20 16:43:15 +00:00
|
|
|
#endif
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2006-09-08 23:31:06 +00:00
|
|
|
#ifdef NETWORK
|
2008-09-30 00:07:07 +00:00
|
|
|
if (Game_mode & GM_MULTI)
|
|
|
|
multi_do_frame();
|
2006-09-08 23:31:06 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
dead_player_frame();
|
|
|
|
if (Newdemo_state != ND_STATE_PLAYBACK)
|
|
|
|
do_controlcen_dead_frame();
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
digi_sync_sounds();
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
if (Endlevel_sequence) {
|
|
|
|
do_endlevel_frame();
|
|
|
|
powerup_grab_cheat_all();
|
|
|
|
do_special_effects();
|
2009-07-01 11:35:33 +00:00
|
|
|
return; //skip everything else
|
2008-09-30 00:07:07 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
if (Newdemo_state != ND_STATE_PLAYBACK)
|
|
|
|
do_exploding_wall_frame();
|
|
|
|
if ((Newdemo_state != ND_STATE_PLAYBACK) || (Newdemo_vcr_state != ND_STATE_PAUSED)) {
|
|
|
|
do_special_effects();
|
|
|
|
wall_frame_process();
|
|
|
|
triggers_frame_process();
|
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
if (Control_center_destroyed) {
|
2008-09-30 00:07:07 +00:00
|
|
|
if (Newdemo_state==ND_STATE_RECORDING )
|
|
|
|
newdemo_record_control_center_destroyed();
|
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
flash_frame();
|
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
if ( Newdemo_state == ND_STATE_PLAYBACK ) {
|
|
|
|
newdemo_playback_one_frame();
|
2009-07-01 11:35:33 +00:00
|
|
|
if ( Newdemo_state != ND_STATE_PLAYBACK ) {
|
2010-01-27 04:30:31 +00:00
|
|
|
if (Game_wind)
|
|
|
|
window_close(Game_wind); // Go back to menu
|
|
|
|
return;
|
2007-02-26 13:50:59 +00:00
|
|
|
}
|
2008-09-30 00:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Note the link to above!
|
2007-02-26 13:50:59 +00:00
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
Players[Player_num].homing_object_dist = -1; // Assume not being tracked. Laser_do_weapon_sequence modifies this.
|
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
object_move_all();
|
|
|
|
powerup_grab_cheat_all();
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
if (Endlevel_sequence) //might have been started during move
|
|
|
|
return;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
fuelcen_update_all();
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
do_ai_frame_all();
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
if (allowed_to_fire_laser())
|
2009-07-01 11:35:33 +00:00
|
|
|
FireLaser(); // Fire Laser!
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
if (Auto_fire_fusion_cannon_time) {
|
|
|
|
if (Primary_weapon != FUSION_INDEX)
|
|
|
|
Auto_fire_fusion_cannon_time = 0;
|
|
|
|
else if (GameTime + FrameTime/2 >= Auto_fire_fusion_cannon_time) {
|
|
|
|
Auto_fire_fusion_cannon_time = 0;
|
|
|
|
Global_laser_firing_count = 1;
|
|
|
|
} else if (FixedStep & EPS20) {
|
|
|
|
vms_vector rand_vec;
|
|
|
|
fix bump_amount;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
Global_laser_firing_count = 0;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
ConsoleObject->mtype.phys_info.rotvel.x += (d_rand() - 16384)/8;
|
|
|
|
ConsoleObject->mtype.phys_info.rotvel.z += (d_rand() - 16384)/8;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
make_random_vector(&rand_vec);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
bump_amount = F1_0*4;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
if (Fusion_charge > F1_0*2)
|
|
|
|
bump_amount = Fusion_charge*4;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
bump_one_object(ConsoleObject, &rand_vec, bump_amount);
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2008-09-30 00:07:07 +00:00
|
|
|
else
|
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
Global_laser_firing_count = 0;
|
2008-09-30 00:07:07 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
if (Global_laser_firing_count)
|
2009-07-01 11:35:33 +00:00
|
|
|
Global_laser_firing_count -= do_laser_firing_player();
|
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
if (Global_laser_firing_count < 0)
|
|
|
|
Global_laser_firing_count = 0;
|
|
|
|
}
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
if (Do_appearance_effect) {
|
|
|
|
create_player_appearance_effect(ConsoleObject);
|
|
|
|
Do_appearance_effect = 0;
|
|
|
|
}
|
2010-01-31 07:45:26 +00:00
|
|
|
|
|
|
|
// Check if we have to close in-game menus for multiplayer
|
|
|
|
if (Endlevel_sequence || (Player_is_dead != player_was_dead) || (Players[Player_num].shields < player_shields))
|
|
|
|
game_leave_menus();
|
2010-06-14 08:13:16 +00:00
|
|
|
|
2010-03-20 13:21:53 +00:00
|
|
|
if ((Control_center_destroyed && !was_fuelcen_destroyed) || ((Control_center_destroyed) && (Countdown_seconds_left < 10)))
|
2010-01-31 07:45:26 +00:00
|
|
|
game_leave_menus();
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Fire Laser: Registers a laser fire, and performs special stuff for the fusion
|
|
|
|
// cannon.
|
|
|
|
void FireLaser()
|
|
|
|
{
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
Global_laser_firing_count = Weapon_info[Primary_weapon_to_weapon_info[Primary_weapon]].fire_count * (Controls.fire_primary_state || Controls.fire_primary_down_count);
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
if ((Primary_weapon == FUSION_INDEX) && (Global_laser_firing_count)) {
|
|
|
|
if ((Players[Player_num].energy < F1_0*2) && (Auto_fire_fusion_cannon_time == 0)) {
|
|
|
|
Global_laser_firing_count = 0;
|
|
|
|
} else {
|
2010-09-04 09:22:07 +00:00
|
|
|
static int Fusion_next_sound_time = 0;
|
|
|
|
|
2008-09-30 00:07:07 +00:00
|
|
|
if (Fusion_charge == 0)
|
|
|
|
Players[Player_num].energy -= F1_0*2;
|
|
|
|
|
|
|
|
Fusion_charge += FrameTime;
|
|
|
|
Players[Player_num].energy -= FrameTime;
|
|
|
|
|
|
|
|
if (Players[Player_num].energy <= 0) {
|
|
|
|
Players[Player_num].energy = 0;
|
2009-07-01 11:35:33 +00:00
|
|
|
Auto_fire_fusion_cannon_time = GameTime -1; // Fire now!
|
2008-09-30 00:07:07 +00:00
|
|
|
} else
|
|
|
|
Auto_fire_fusion_cannon_time = GameTime + FrameTime/2 + 1; // Fire the fusion cannon at this time in the future.
|
|
|
|
|
|
|
|
if (Fusion_charge < F1_0*2)
|
|
|
|
PALETTE_FLASH_ADD(Fusion_charge >> 11, 0, Fusion_charge >> 11);
|
|
|
|
else
|
|
|
|
PALETTE_FLASH_ADD(Fusion_charge >> 11, Fusion_charge >> 11, 0);
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2010-09-04 09:22:07 +00:00
|
|
|
if (Fusion_next_sound_time > GameTime + F1_0/8 + D_RAND_MAX/4) //gametime has wrapped or something is screwed
|
|
|
|
Fusion_next_sound_time = GameTime - 1;
|
2008-09-30 00:07:07 +00:00
|
|
|
|
|
|
|
if (Fusion_next_sound_time < GameTime) {
|
|
|
|
if (Fusion_charge > F1_0*2) {
|
|
|
|
digi_play_sample( 11, F1_0 );
|
|
|
|
#ifdef NETWORK
|
|
|
|
if(Game_mode & GM_MULTI)
|
|
|
|
multi_send_play_sound(11, F1_0);
|
|
|
|
#endif
|
|
|
|
apply_damage_to_player(ConsoleObject, ConsoleObject, d_rand() * 4);
|
|
|
|
} else {
|
|
|
|
create_awareness_event(ConsoleObject, PA_WEAPON_ROBOT_COLLISION);
|
|
|
|
digi_play_sample( SOUND_FUSION_WARMUP, F1_0 );
|
|
|
|
#ifdef NETWORK
|
|
|
|
if (Game_mode & GM_MULTI)
|
|
|
|
multi_send_play_sound(SOUND_FUSION_WARMUP, F1_0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
Fusion_next_sound_time = GameTime + F1_0/8 + d_rand()/4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
|
|
// If player is close enough to objnum, which ought to be a powerup, pick it up!
|
|
|
|
// This could easily be made difficulty level dependent.
|
|
|
|
void powerup_grab_cheat(object *player, int objnum)
|
|
|
|
{
|
|
|
|
fix powerup_size;
|
|
|
|
fix player_size;
|
|
|
|
fix dist;
|
|
|
|
|
|
|
|
Assert(Objects[objnum].type == OBJ_POWERUP);
|
|
|
|
|
|
|
|
powerup_size = Objects[objnum].size;
|
|
|
|
player_size = player->size;
|
|
|
|
|
|
|
|
dist = vm_vec_dist_quick(&Objects[objnum].pos, &player->pos);
|
|
|
|
|
|
|
|
if ((dist < 2*(powerup_size + player_size)) && !(Objects[objnum].flags & OF_SHOULD_BE_DEAD)) {
|
|
|
|
vms_vector collision_point;
|
|
|
|
|
|
|
|
vm_vec_avg(&collision_point, &Objects[objnum].pos, &player->pos);
|
|
|
|
collide_player_and_powerup(player, &Objects[objnum], &collision_point);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
|
|
// Make it easier to pick up powerups.
|
|
|
|
// For all powerups in this segment, pick them up at up to twice pickuppable distance based on dot product
|
|
|
|
// from player to powerup and player's forward vector.
|
|
|
|
// This has the effect of picking them up more easily left/right and up/down, but not making them disappear
|
|
|
|
// way before the player gets there.
|
|
|
|
void powerup_grab_cheat_all(void)
|
|
|
|
{
|
|
|
|
segment *segp;
|
2009-07-01 11:35:33 +00:00
|
|
|
int objnum;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
segp = &Segments[ConsoleObject->segnum];
|
|
|
|
objnum = segp->objects;
|
|
|
|
|
|
|
|
while (objnum != -1) {
|
|
|
|
if (Objects[objnum].type == OBJ_POWERUP)
|
|
|
|
powerup_grab_cheat(ConsoleObject, objnum);
|
|
|
|
objnum = Objects[objnum].next;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int Last_level_path_created = -1;
|
|
|
|
|
|
|
|
#ifdef SHOW_EXIT_PATH
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------------------------
|
|
|
|
// Create path for player from current segment to goal segment.
|
|
|
|
// Return true if path created, else return false.
|
|
|
|
int mark_player_path_to_segment(int segnum)
|
|
|
|
{
|
|
|
|
int i;
|
2009-07-01 11:35:33 +00:00
|
|
|
object *objp = ConsoleObject;
|
2006-03-20 16:43:15 +00:00
|
|
|
short player_path_length=0;
|
|
|
|
int player_hide_index=-1;
|
|
|
|
|
|
|
|
if (Last_level_path_created == Current_level_num) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Last_level_path_created = Current_level_num;
|
|
|
|
|
|
|
|
if (create_path_points(objp, objp->segnum, segnum, Point_segs_free_ptr, &player_path_length, 100, 0, 0, -1) == -1) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
player_hide_index = Point_segs_free_ptr - Point_segs;
|
|
|
|
Point_segs_free_ptr += player_path_length;
|
|
|
|
|
|
|
|
if (Point_segs_free_ptr - Point_segs + MAX_PATH_LENGTH*2 > MAX_POINT_SEGS) {
|
|
|
|
ai_reset_all_paths();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=1; i<player_path_length; i++) {
|
|
|
|
int segnum, objnum;
|
|
|
|
vms_vector seg_center;
|
|
|
|
object *obj;
|
|
|
|
|
|
|
|
segnum = Point_segs[player_hide_index+i].segnum;
|
|
|
|
seg_center = Point_segs[player_hide_index+i].point;
|
|
|
|
|
|
|
|
objnum = obj_create( OBJ_POWERUP, POW_ENERGY, segnum, &seg_center, &vmd_identity_matrix, Powerup_info[POW_ENERGY].size, CT_POWERUP, MT_NONE, RT_POWERUP);
|
|
|
|
if (objnum == -1) {
|
2009-07-01 11:35:33 +00:00
|
|
|
Int3(); // Unable to drop energy powerup for path
|
2006-03-20 16:43:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj = &Objects[objnum];
|
|
|
|
obj->rtype.vclip_info.vclip_num = Powerup_info[obj->id].vclip_num;
|
|
|
|
obj->rtype.vclip_info.frametime = Vclip[obj->rtype.vclip_info.vclip_num].frame_time;
|
|
|
|
obj->rtype.vclip_info.framenum = 0;
|
|
|
|
obj->lifeleft = F1_0*100 + d_rand() * 4;
|
|
|
|
}
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return true if it happened, else return false.
|
|
|
|
int create_special_path(void)
|
|
|
|
{
|
|
|
|
int i,j;
|
|
|
|
|
|
|
|
// ---------- Find exit doors ----------
|
|
|
|
for (i=0; i<=Highest_segment_index; i++)
|
|
|
|
for (j=0; j<MAX_SIDES_PER_SEGMENT; j++)
|
|
|
|
if (Segments[i].children[j] == -2) {
|
|
|
|
return mark_player_path_to_segment(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-01 11:35:33 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef RELEASE
|
|
|
|
int Max_obj_count_mike = 0;
|
|
|
|
|
|
|
|
// Shows current number of used objects.
|
|
|
|
void show_free_objects(void)
|
|
|
|
{
|
|
|
|
if (!(FrameCount & 8)) {
|
|
|
|
int i;
|
|
|
|
int count=0;
|
|
|
|
|
|
|
|
for (i=0; i<=Highest_object_index; i++)
|
|
|
|
if (Objects[i].type != OBJ_NONE)
|
|
|
|
count++;
|
|
|
|
|
|
|
|
if (count > Max_obj_count_mike) {
|
|
|
|
Max_obj_count_mike = count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|