From 3404f759968c46bedcc2a8dac4ff4488a177e3b2 Mon Sep 17 00:00:00 2001 From: Martin Schaffner Date: Sat, 15 May 2004 16:25:35 +0000 Subject: [PATCH] fix joystick_read_raw_axis(), define and use gr_remap_mono_font(), limit homing missile turn rate --- 2d/font.c | 14 +++++++++++++- ChangeLog | 12 ++++++++++++ arch/sdl/joy.c | 10 ++++++---- include/gr.h | 3 ++- main/gameseq.c | 5 +++-- main/laser.c | 40 ++++++++++++++++++++++++++++++++++++---- 6 files changed, 72 insertions(+), 12 deletions(-) diff --git a/2d/font.c b/2d/font.c index bfc0f6c3..fec3763f 100644 --- a/2d/font.c +++ b/2d/font.c @@ -1,4 +1,4 @@ -/* $Id: font.c,v 1.26 2003-11-26 12:26:23 btb Exp $ */ +/* $Id: font.c,v 1.27 2004-05-15 16:25:35 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -1576,6 +1576,18 @@ void gr_remap_color_fonts() } } +void gr_remap_mono_fonts() +{ + int fontnum; + con_printf (CON_DEBUG, "gr_remap_mono_fonts ()\n"); + for (fontnum=0;fontnumft_flags & FT_COLOR)) + gr_remap_font(font, open_font[fontnum].filename, open_font[fontnum].dataptr); + } +} + #ifdef FAST_FILE_IO #define grs_font_read(gf, fp) cfread(gf, GRS_FONT_SIZE, 1, fp) #else diff --git a/ChangeLog b/ChangeLog index e9c30522..e72478b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-05-15 Dietfrid Mali + + * arch/sdl/joy.c: joystick_read_raw_axis() will return a proper + bitmask for each joystick axis that has sent input data, + and will not crash Windows anymore during joystick setup because + of for() loop over axis being executed once too often. + + * main/gameseq.c, include/gr.h, 2d/font.c: define new function + gr_remap_mono_font() and call it after loading saved level. + + * main/laser.c: limit homing missile turn rate + 2004-05-13 Bradley Bell * VisualC/d2/d2x/d2x.dsp, VisualC/d2xgl/d2xgl.dsp, diff --git a/arch/sdl/joy.c b/arch/sdl/joy.c index a327cc6a..e06f82ec 100644 --- a/arch/sdl/joy.c +++ b/arch/sdl/joy.c @@ -1,4 +1,4 @@ -/* $Id: joy.c,v 1.12 2003-04-12 00:11:46 btb Exp $ */ +/* $Id: joy.c,v 1.13 2004-05-15 16:25:35 schaffner Exp $ */ /* * * SDL joystick support @@ -285,17 +285,19 @@ fix joy_get_button_down_time(int btn) ubyte joystick_read_raw_axis( ubyte mask, int * axis ) { int i; + ubyte channel_masks = 0; if (!num_joysticks) return 0; event_poll(); - for (i = 0; i <= JOY_NUM_AXES; i++) { - axis[i] = Joystick.axes[i].value; + for (i = 0; i < JOY_NUM_AXES; i++) { + if ((axis[i] = Joystick.axes[i].value)) + channel_masks |= 1 << i; } - return 0; + return channel_masks; } void joy_flush() diff --git a/include/gr.h b/include/gr.h index 5fd24828..8aa3c806 100644 --- a/include/gr.h +++ b/include/gr.h @@ -1,4 +1,4 @@ -/* $Id: gr.h,v 1.23 2004-01-08 20:31:35 schaffner Exp $ */ +/* $Id: gr.h,v 1.24 2004-05-15 16:25:35 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -523,6 +523,7 @@ void gr_remap_font( grs_font *font, char * fontname, char *font_data ); //remap (by re-reading) all the color fonts void gr_remap_color_fonts(); +void gr_remap_mono_fonts(); // Writes a string using current font. Returns the next column after last char. void gr_set_fontcolor( int fg, int bg ); diff --git a/main/gameseq.c b/main/gameseq.c index 41bf1073..2a6b4bd4 100644 --- a/main/gameseq.c +++ b/main/gameseq.c @@ -1,4 +1,4 @@ -/* $Id: gameseq.c,v 1.33 2003-11-26 12:26:30 btb Exp $ */ +/* $Id: gameseq.c,v 1.34 2004-05-15 16:25:35 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -292,7 +292,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -char gameseq_rcsid[] = "$Id: gameseq.c,v 1.33 2003-11-26 12:26:30 btb Exp $"; +char gameseq_rcsid[] = "$Id: gameseq.c,v 1.34 2004-05-15 16:25:35 schaffner Exp $"; #endif #ifdef WINDOWS @@ -2234,6 +2234,7 @@ void StartNewLevelSub(int level_num, int page_in_textures, int secret_flag) reset_special_effects(); #ifdef OGL + gr_remap_mono_fonts(); ogl_cache_level_textures(); #endif diff --git a/main/laser.c b/main/laser.c index 1013f406..91adc1b1 100644 --- a/main/laser.c +++ b/main/laser.c @@ -1,4 +1,4 @@ -/* $Id: laser.c,v 1.10 2003-10-10 09:36:35 btb Exp $ */ +/* $Id: laser.c,v 1.11 2004-05-15 16:25:35 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -28,11 +28,12 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -char laser_rcsid[] = "$Id: laser.c,v 1.10 2003-10-10 09:36:35 btb Exp $"; +char laser_rcsid[] = "$Id: laser.c,v 1.11 2004-05-15 16:25:35 schaffner Exp $"; #endif #include #include +#include #include "inferno.h" #include "game.h" @@ -1423,15 +1424,46 @@ void Flare_create(object *obj) #define HOMING_MISSILE_SCALE 16 -//------------------------------------------------------------------------------------------- +#define LIMIT_HOMERS 1 +#define HOMER_MAX_FPS 30 +#define HOMER_MIN_DELAY (1000 / HOMER_MAX_FPS) + +//-------------------------------------------------------------------- // Set object *objp's orientation to (or towards if I'm ambitious) its velocity. void homing_missile_turn_towards_velocity(object *objp, vms_vector *norm_vel) { vms_vector new_fvec; +#ifdef LIMIT_HOMERS + static time_t last_time = -1; + static int nFrames = 1; + time_t this_time, delta_time; + fix frame_time; + int fps; + if (last_time == -1) { + last_time = clock (); + frame_time = FrameTime; + } else { + nFrames++; + this_time = clock (); + delta_time = this_time - last_time; + if (delta_time < HOMER_MIN_DELAY) { + return; + } else { + fps = (1000 + delta_time / 2) / delta_time; + frame_time = fps ? (f1_0 + fps / 2) / fps : f1_0; + // frame_time /= nFrames; + nFrames = 0; + last_time = this_time; + } + } +#else + fix frame_time = FrameTime; +#endif + new_fvec = *norm_vel; - vm_vec_scale(&new_fvec, FrameTime*HOMING_MISSILE_SCALE); + vm_vec_scale(&new_fvec, frame_time * HOMING_MISSILE_SCALE); vm_vec_add2(&new_fvec, &objp->orient.fvec); vm_vec_normalize_quick(&new_fvec); -- 2.39.2