Renamed FixedStepCalc() to cald_d_tick() and FixedStep became d_tick_step; Also ther eonly is a 50ms-timer used to d_tick_step as it was the only one used so far; Replaced FrameCount with d_tick_count which only increments by 50ms-timer used in calc_d_tick() - that now scales timed actions for certain functions properly and makes AI work FPS-independent without any hacks in that regard

This commit is contained in:
zicodxx 2012-05-14 19:06:28 +02:00
parent dbb5eeef35
commit d3fb313fd9
22 changed files with 87 additions and 138 deletions

View file

@ -4,6 +4,7 @@ D2X-Rebirth Changelog
--------
2d/disc.c, SConstruct, editor/medmisc.c, include/gr.h, include/internal.h, main/gauges.c, main/menu.c, main/net_udp.c, main/playsave.c, main/state.c, misc/hmp.c, misc/physfsx.c: Fixed some non-critical compiler warnings; Now compiling with -std=c99 -pedantic and fixed warnings (except for editor build) caused by this
2d/bitblt.c, 2d/pixel.c, arch/sdl/digi_mixer.c, main/gauges.c, main/menu.c: Made inline functions static
include/gr.h, main/ai.c, main/ai2.c, main/aipath.c, main/automap.c, main/cntrlcen.c, main/escort.c, main/fuelcen.c, main/game.c, main/game.h, main/gamecntl.c, main/gamerend.c, main/gamesave.c, main/laser.c, main/mglobal.c, main/object.c, main/object.h, main/render.c, main/texmerge.c, main/wall.c, main/weapon.c: Renamed FixedStepCalc() to cald_d_tick() and FixedStep became d_tick_step; Also ther eonly is a 50ms-timer used to d_tick_step as it was the only one used so far; Replaced FrameCount with d_tick_count which only increments by 50ms-timer used in calc_d_tick() - that now scales timed actions for certain functions properly and makes AI work FPS-independent without any hacks in that regard
20120510
--------

View file

@ -225,7 +225,6 @@ void gr_init_bitmap_data (grs_bitmap *bm);
void gr_free_sub_bitmap(grs_bitmap *bm);
void gr_bm_pixel( grs_bitmap * bm, int x, int y, unsigned char color );
void gr_bm_upixel( grs_bitmap * bm, int x, int y, unsigned char color );
void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
void gr_bm_ubitblt( int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
void gr_bm_ubitbltm(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);

View file

@ -359,7 +359,7 @@ void do_ai_frame(object *obj)
Assert(obj->segnum != -1);
Assert(obj->id < N_robot_types);
obj_ref = objnum ^ FrameCount;
obj_ref = objnum ^ d_tick_count;
if (ailp->next_fire > -F1_0*8)
ailp->next_fire -= FrameTime;
@ -1027,7 +1027,7 @@ _exit_cheat:
}
}
vm_vec_scale(&goal_vector, 2*(ConsoleObject->size + obj->size + (((objnum*4 + FrameCount) & 63) << 12)));
vm_vec_scale(&goal_vector, 2*(ConsoleObject->size + obj->size + (((objnum*4 + d_tick_count) & 63) << 12)));
vm_vec_add(&goal_point, &ConsoleObject->pos, &goal_vector);
make_random_vector(&rand_vec);
vm_vec_scale_add2(&goal_point, &rand_vec, F1_0*8);
@ -1471,7 +1471,7 @@ void do_ai_frame_all(void)
if (Ai_last_missile_camera > -1) {
// Clear if supposed misisle camera is not a weapon, or just every so often, just in case.
if (((FrameCount & 0x0f) == 0) || (Objects[Ai_last_missile_camera].type != OBJ_WEAPON)) {
if (((d_tick_count & 0x0f) == 0) || (Objects[Ai_last_missile_camera].type != OBJ_WEAPON)) {
int i;
Ai_last_missile_camera = -1;

View file

@ -1083,30 +1083,13 @@ void move_around_player(object *objp, vms_vector *vec_to_player, int fast_flag)
physics_info *pptr = &objp->mtype.phys_info;
fix speed;
robot_info *robptr = &Robot_info[objp->id];
int objnum = objp-Objects;
int dir;
int dir_change;
fix ft;
vms_vector evade_vector;
int count=0;
if (fast_flag == 0)
return;
dir_change = 48;
ft = FrameTime;
if (ft < F1_0/32) {
dir_change *= 8;
count += 3;
} else
while (ft < F1_0/4) {
dir_change *= 2;
ft *= 2;
count++;
}
dir = (/*FrameCount*/(GameTime64/2000==0?1:GameTime64/2000) + (count+1) * (objnum*8 + objnum*4 + objnum)) & dir_change;
dir >>= (4+count);
dir = ((objp-Objects) ^ ((d_tick_count + 3*(objp-Objects)) >> 5)) & 3;
Assert((dir >= 0) && (dir <= 3));
@ -1185,7 +1168,7 @@ void move_away_from_player(object *objp, vms_vector *vec_to_player, int attack_t
if (attack_type) {
// Get value in 0..3 to choose evasion direction.
objref = ((objp-Objects) ^ ((FrameCount + 3*(objp-Objects)) >> 5)) & 3;
objref = ((objp-Objects) ^ ((d_tick_count + 3*(objp-Objects)) >> 5)) & 3;
switch (objref) {
case 0: vm_vec_scale_add2(&pptr->velocity, &objp->orient.uvec, FrameTime << 5); break;

View file

@ -487,7 +487,7 @@ cpp_done1: ;
return 0;
}
int Last_buddy_polish_path_frame;
int Last_buddy_polish_path_tick;
// -------------------------------------------------------------------------------------------------------
// polish_path
@ -506,13 +506,13 @@ int polish_path(object *objp, point_seg *psegs, int num_points)
if (num_points <= 4)
return num_points;
// Prevent the buddy from polishing his path twice in one frame, which can cause him to get hung up. Pretty ugly, huh?
// Prevent the buddy from polishing his path twice in one tick, which can cause him to get hung up. Pretty ugly, huh?
if (Robot_info[objp->id].companion)
{
if (FrameCount == Last_buddy_polish_path_frame)
if (d_tick_count == Last_buddy_polish_path_tick)
return num_points;
else
Last_buddy_polish_path_frame = FrameCount;
Last_buddy_polish_path_tick = d_tick_count;
}
// -- MK: 10/18/95: for (i=0; i<num_points-3; i++) {
@ -966,7 +966,7 @@ void ai_follow_path(object *objp, int player_visibility, int previous_visibility
vm_vec_scale(&objp->mtype.phys_info.velocity, vel_scale);
return;
} else if (!(FrameCount ^ ((objp-Objects) & 0x07))) { // Done 1/8 frames.
} else if (!(d_tick_count ^ ((objp-Objects) & 0x07))) { // Done 1/8 ticks.
// If player on path (beyond point robot is now at), then create a new path.
point_seg *curpsp = &Point_segs[aip->hide_index];
int player_segnum = ConsoleObject->segnum;
@ -1230,7 +1230,7 @@ void ai_path_set_orient_and_vel(object *objp, vms_vector *goal_point, int player
}
int Last_frame_garbage_collected = 0;
int Last_tick_garbage_collected = 0;
// ----------------------------------------------------------------------------------------------------------
// Garbage colledion -- Free all unused records in Point_segs and compress all paths.
@ -1246,7 +1246,7 @@ void ai_path_garbage_collect(void)
force_dump_ai_objects_all("***** Start ai_path_garbage_collect *****");
#endif
Last_frame_garbage_collected = FrameCount;
Last_tick_garbage_collected = d_tick_count;
#if PATH_VALIDATION
validate_all_paths();
@ -1311,7 +1311,7 @@ void ai_path_garbage_collect(void)
void maybe_ai_path_garbage_collect(void)
{
if (Point_segs_free_ptr - Point_segs > MAX_POINT_SEGS - MAX_PATH_LENGTH) {
if (Last_frame_garbage_collected+1 >= FrameCount) {
if (Last_tick_garbage_collected+1 >= d_tick_count) {
// This is kind of bad. Garbage collected last frame or this frame.
// Just destroy all paths. Too bad for the robots. They are memory wasteful.
ai_reset_all_paths();
@ -1320,11 +1320,11 @@ void maybe_ai_path_garbage_collect(void)
ai_path_garbage_collect();
}
} else if (Point_segs_free_ptr - Point_segs > 3*MAX_POINT_SEGS/4) {
if (Last_frame_garbage_collected + 16 < FrameCount) {
if (Last_tick_garbage_collected + 16 < d_tick_count) {
ai_path_garbage_collect();
}
} else if (Point_segs_free_ptr - Point_segs > MAX_POINT_SEGS/2) {
if (Last_frame_garbage_collected + 256 < FrameCount) {
if (Last_tick_garbage_collected + 256 < d_tick_count) {
ai_path_garbage_collect();
}
}

View file

@ -553,7 +553,7 @@ void draw_automap(automap *am)
if (am->pause_game)
{
FrameTime=am->t2-am->t1;
FixedStepCalc();
calc_d_tick();
}
am->t1 = am->t2;
}

View file

@ -174,7 +174,7 @@ void do_countdown_frame()
if (Difficulty_level == 0)
div_scale = 4;
if (FixedStep & EPS20)
if (d_tick_step)
{
ConsoleObject->mtype.phys_info.rotvel.x += (fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32))/div_scale;
ConsoleObject->mtype.phys_info.rotvel.z += (fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32))/div_scale;
@ -286,7 +286,7 @@ void do_controlcen_frame(object *obj)
#endif
if (!(Control_center_been_hit || Control_center_player_been_seen)) {
if (!(FrameCount % 8)) { // Do every so often...
if (!(d_tick_count % 8)) { // Do every so often...
vms_vector vec_to_player;
fix dist_to_player;
int i;

View file

@ -1344,7 +1344,7 @@ void do_thief_frame(object *objp, fix dist_to_player, int player_visibility, vms
} else {
ai_static *aip = &objp->ctype.ai_info;
// If path length == 0, then he will keep trying to create path, but he is probably stuck in his closet.
if ((aip->path_length > 1) || ((FrameCount & 0x0f) == 0)) {
if ((aip->path_length > 1) || ((d_tick_count & 0x0f) == 0)) {
ai_follow_path(objp, player_visibility, player_visibility, vec_to_player);
ailp->mode = AIM_THIEF_ATTACK;
}

View file

@ -363,10 +363,6 @@ object * create_morph_robot( segment *segp, vms_vector *object_pos, int object_i
int Num_extry_robots = 15;
#ifndef NDEBUG
int FrameCount_last_msg = 0;
#endif
// ----------------------------------------------------------------------------------------------------------
void robotmaker_proc( FuelCenter * robotcen )
{
@ -416,11 +412,6 @@ void robotmaker_proc( FuelCenter * robotcen )
// Wait until we have a free slot for this puppy...
// <<<<<<<<<<<<<<<< Num robots in mine >>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<< Max robots in mine >>>>>>>>>>>>>>>
if ( (Players[Player_num].num_robots_level - Players[Player_num].num_kills_level) >= (Gamesave_num_org_robots + Num_extry_robots ) ) {
#ifndef NDEBUG
if (FrameCount > FrameCount_last_msg + 20) {
FrameCount_last_msg = FrameCount;
}
#endif
return;
}

View file

@ -421,35 +421,23 @@ void game_flush_inputs()
}
/*
Calculates several - common used - timesteps and stores into FixedStep
*/
void FixedStepCalc()
* timer that every 50ms sets d_tick_step true and increments d_tick_count
*/
void calc_d_tick()
{
int StepRes = 0;
static fix Timer4 = 0, Timer20 = 0, Timer30 = 0;
static fix timer = 0;
Timer4 += FrameTime;
if (Timer4 >= F1_0/4)
d_tick_step = 0;
timer += FrameTime;
if (timer >= F1_0/20)
{
StepRes |= EPS4;
Timer4 = (Timer4-(F1_0/4));
d_tick_step = 1;
d_tick_count++;
if (d_tick_count > 1000000)
d_tick_count = 0;
timer = (timer-(F1_0/20));
}
Timer20 += FrameTime;
if (Timer20 >= F1_0/20)
{
StepRes |= EPS20;
Timer20 = (Timer20-(F1_0/20));
}
Timer30 += FrameTime;
if (Timer30 >= F1_0/30)
{
StepRes |= EPS30;
Timer30 = (Timer30-(F1_0/30));
}
FixedStep = StepRes;
}
void reset_time()
@ -486,7 +474,7 @@ void calc_frame_time()
GameTime64 += FrameTime;
FixedStepCalc();
calc_d_tick();
}
void move_player_2_segment(segment *seg,int side)
@ -1455,7 +1443,7 @@ void GameProcessFrame(void)
else if (GameTime64 + FrameTime/2 >= Auto_fire_fusion_cannon_time) {
Auto_fire_fusion_cannon_time = 0;
Global_laser_firing_count = 1;
} else if (FixedStep & EPS20) {
} else if (d_tick_step) {
vms_vector rand_vec;
fix bump_amount;
@ -1901,7 +1889,7 @@ int Max_obj_count_mike = 0;
// Shows current number of used objects.
void show_free_objects(void)
{
if (!(FrameCount & 8)) {
if (!(d_tick_count & 8)) {
int i;
int count=0;

View file

@ -38,19 +38,14 @@ extern struct window *Game_wind;
// from mglobal.c
extern fix FrameTime; // time in seconds since last frame
extern fix64 GameTime64; // time in game (sum of FrameTime)
extern int FrameCount; // how many frames rendered
extern int FixedStep; //fixed time bytes stored here
extern int d_tick_count; // increments every 50ms
extern int d_tick_step; // true once every 50ms
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;
extern fix Laser_delay_time; // Delay between laser fires.
// bits for FixedStep
#define EPS4 1
#define EPS20 2
#define EPS30 4
extern struct object *Missile_viewer;
extern int Missile_viewer_sig;
@ -125,7 +120,7 @@ void game(void);
void close_game(void);
void init_cockpit(void);
void calc_frame_time(void);
void FixedStepCalc();
void calc_d_tick();
int do_flythrough(struct object *obj,int first_time);
extern int Difficulty_level; // Difficulty level in 0..NDL-1, 0 = easiest, NDL-1 = hardest

View file

@ -203,13 +203,13 @@ fix64 newdemo_single_frame_time;
void update_vcr_state(void)
{
if ((keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) && keyd_pressed[KEY_RIGHT] && FixedStep & EPS20)
if ((keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) && keyd_pressed[KEY_RIGHT] && d_tick_step)
Newdemo_vcr_state = ND_STATE_FASTFORWARD;
else if ((keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) && keyd_pressed[KEY_LEFT] && FixedStep & EPS20)
else if ((keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) && keyd_pressed[KEY_LEFT] && d_tick_step)
Newdemo_vcr_state = ND_STATE_REWINDING;
else if (!(keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) && keyd_pressed[KEY_RIGHT] && ((GameTime64 - newdemo_single_frame_time) >= F1_0) && FixedStep & EPS20)
else if (!(keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) && keyd_pressed[KEY_RIGHT] && ((GameTime64 - newdemo_single_frame_time) >= F1_0) && d_tick_step)
Newdemo_vcr_state = ND_STATE_ONEFRAMEFORWARD;
else if (!(keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) && keyd_pressed[KEY_LEFT] && ((GameTime64 - newdemo_single_frame_time) >= F1_0) && FixedStep & EPS20)
else if (!(keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) && keyd_pressed[KEY_LEFT] && ((GameTime64 - newdemo_single_frame_time) >= F1_0) && d_tick_step)
Newdemo_vcr_state = ND_STATE_ONEFRAMEBACKWARD;
else if ((Newdemo_vcr_state == ND_STATE_FASTFORWARD) || (Newdemo_vcr_state == ND_STATE_REWINDING))
Newdemo_vcr_state = ND_STATE_PLAYBACK;

View file

@ -837,8 +837,6 @@ void game_render_frame()
if (VR_render_mode == VR_NONE )
game_render_frame_mono(GameArg.DbgUseDoubleBuffer);
FrameCount++;
}
//show a message in a nice little box

View file

@ -1737,7 +1737,7 @@ int save_level_sub(char * filename, int compiled_version)
{
//write the version 8 data (to make file unreadable by 1.0 & 1.1)
PHYSFS_writeSLE32(SaveFile, GameTime64);
PHYSFS_writeSLE16(SaveFile, FrameCount);
PHYSFS_writeSLE16(SaveFile, d_tick_count);
PHYSFSX_writeU8(SaveFile, FrameTime);
}

View file

@ -978,7 +978,7 @@ int find_homing_object(vms_vector *curpos, object *tracker)
// Find the window which has the forward view.
for (i=0; i<MAX_RENDERED_WINDOWS; i++)
if (Window_rendered_data[i].frame >= FrameCount-1)
if (Window_rendered_data[i].time >= timer_query()-1)
if (Window_rendered_data[i].viewer == ConsoleObject)
if (!Window_rendered_data[i].rear_view) {
window_num = i;
@ -1157,9 +1157,9 @@ int track_track_goal(int track_goal, object *tracker, fix *dot)
} else if (tracker-Objects)
#else
// Every 8 frames for each object, scan all objects.
if (object_is_trackable(track_goal, tracker, dot) && ((((tracker-Objects) ^ FrameCount) % 8) != 0)) {
if (object_is_trackable(track_goal, tracker, dot) && ((((tracker-Objects) ^ d_tick_count) % 8) != 0)) {
return track_goal;
} else if ((((tracker-Objects) ^ FrameCount) % 4) == 0)
} else if ((((tracker-Objects) ^ d_tick_count) % 4) == 0)
#endif
{
int rval = -2;
@ -1428,7 +1428,7 @@ void Laser_do_weapon_sequence(object *obj)
return;
//delete weapons that are not moving
if ( !((FrameCount ^ obj->signature) & 3) &&
if ( !((d_tick_count ^ obj->signature) & 3) &&
(obj->id != FLARE_ID) &&
(Weapon_info[obj->id].speed[Difficulty_level] > 0) &&
(vm_vec_mag_quick(&obj->mtype.phys_info.velocity) < F2_0)) {

View file

@ -34,9 +34,8 @@ g3s_point Segment_points[MAX_VERTICES];
fix FrameTime = 0x1000; // Time since last frame, in seconds
fix64 GameTime64 = 0; // Time in game, in seconds
//How many frames we've rendered
int FrameCount = 0;
int FixedStep; //fixed time bytes stored here
int d_tick_count = 0; // increments every 50ms
int d_tick_step = 0; // true once every 50ms
// This is the global mine which create_new_mine returns.
segment Segments[MAX_SEGMENTS];

View file

@ -66,6 +66,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "switch.h"
#include "gameseq.h"
#include "playsave.h"
#include "timer.h"
#ifdef EDITOR
#include "editor/editor.h"
#endif
@ -1661,8 +1662,6 @@ void dead_player_frame(void)
time_dead = 0;
}
int Killed_in_frame = -1;
short Killed_objnum = -1;
extern char Multi_killed_yourself;
// ------------------------------------------------------------------------------------------------------------------
@ -1682,8 +1681,6 @@ void start_player_death_sequence(object *player)
if (!(Game_mode & GM_MULTI))
HUD_clear_messages();
Killed_in_frame = FrameCount;
Killed_objnum = player-Objects;
Death_sequence_aborted = 0;
#ifdef NETWORK
@ -2364,7 +2361,7 @@ void wake_up_rendered_objects(object *viewer, int window_num)
int i;
// Make sure that we are processing current data.
if (FrameCount != Window_rendered_data[window_num].frame) {
if (timer_query() != Window_rendered_data[window_num].time) {
return;
}
@ -2373,7 +2370,7 @@ void wake_up_rendered_objects(object *viewer, int window_num)
for (i=0; i<Window_rendered_data[window_num].num_objects; i++) {
int objnum;
object *objp;
int fcval = FrameCount & 3;
int fcval = d_tick_count & 3;
objnum = Window_rendered_data[window_num].rendered_objects[i];
if ((objnum & 3) == fcval) {

View file

@ -343,7 +343,7 @@ typedef struct obj_position {
} obj_position;
typedef struct {
int frame;
fix64 time;
object *viewer;
int rear_view;
int user;

View file

@ -77,7 +77,7 @@ int Max_debris_objects = 15; // How many debris objects to create
int Clear_window_color=-1;
int Clear_window=2; // 1 = Clear whole background window, 2 = clear view portals into rest of world, 0 = no clear
int RL_framecount=-1;
int framecount=-1;
short Rotated_last[MAX_VERTICES];
// When any render function needs to know what's looking at it, it should
@ -719,12 +719,12 @@ int check_window_check=0;
//This must be called at the start of the frame if rotate_list() will be used
void render_start_frame()
{
RL_framecount++;
framecount++;
if (RL_framecount==0) { //wrap!
if (framecount==0) { //wrap!
memset(Rotated_last,0,sizeof(Rotated_last)); //clear all to zero
RL_framecount=1; //and set this frame to 1
framecount=1; //and set this frame to 1
}
}
@ -743,7 +743,7 @@ g3s_codes rotate_list(int nv,int *pointnumlist)
pnt = &Segment_points[pnum];
if (Rotated_last[pnum] != RL_framecount)
if (Rotated_last[pnum] != framecount)
{
if (cheats.acid)
{
@ -757,7 +757,7 @@ g3s_codes rotate_list(int nv,int *pointnumlist)
else
g3_rotate_point(pnt,&Vertices[pnum]);
Rotated_last[pnum] = RL_framecount;
Rotated_last[pnum] = framecount;
}
cc.and &= pnt->p3_codes;
@ -1617,7 +1617,6 @@ void render_frame(fix eye_offset, int window_num)
if (Endlevel_sequence) {
render_endlevel_frame(eye_offset);
FrameCount++;
return;
}
@ -1700,7 +1699,7 @@ int first_terminal_seg;
void update_rendered_data(int window_num, object *viewer, int rear_view_flag, int user)
{
Assert(window_num < MAX_RENDERED_WINDOWS);
Window_rendered_data[window_num].frame = FrameCount;
Window_rendered_data[window_num].time = timer_query();
Window_rendered_data[window_num].viewer = viewer;
Window_rendered_data[window_num].rear_view = rear_view_flag;
Window_rendered_data[window_num].user = user;

View file

@ -25,6 +25,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "textures.h"
#include "rle.h"
#include "piggy.h"
#include "timer.h"
#ifdef OGL
#include "ogl_init.h"
@ -40,7 +41,7 @@ typedef struct {
grs_bitmap * bottom_bmp;
grs_bitmap * top_bmp;
int orient;
int last_frame_used;
fix64 last_time_used;
} TEXTURE_CACHE;
static TEXTURE_CACHE Cache[MAX_NUM_CACHE_BITMAPS];
@ -69,7 +70,7 @@ int texmerge_init(int num_cached_textures)
for (i=0; i<num_cache_entries; i++ ) {
Cache[i].bitmap = NULL;
Cache[i].last_frame_used = -1;
Cache[i].last_time_used = -1;
Cache[i].top_bmp = NULL;
Cache[i].bottom_bmp = NULL;
Cache[i].orient = -1;
@ -83,7 +84,7 @@ void texmerge_flush()
int i;
for (i=0; i<num_cache_entries; i++ ) {
Cache[i].last_frame_used = -1;
Cache[i].last_time_used = -1;
Cache[i].top_bmp = NULL;
Cache[i].bottom_bmp = NULL;
Cache[i].orient = -1;
@ -109,7 +110,7 @@ grs_bitmap * texmerge_get_cached_bitmap( int tmap_bottom, int tmap_top )
{
grs_bitmap *bitmap_top, *bitmap_bottom;
int i, orient;
int lowest_frame_count;
int lowest_time_used;
int least_recently_used;
bitmap_top = &GameBitmaps[Textures[tmap_top&0x3FFF].index];
@ -118,16 +119,16 @@ grs_bitmap * texmerge_get_cached_bitmap( int tmap_bottom, int tmap_top )
orient = ((tmap_top&0xC000)>>14) & 3;
least_recently_used = 0;
lowest_frame_count = Cache[0].last_frame_used;
lowest_time_used = Cache[0].last_time_used;
for (i=0; i<num_cache_entries; i++ ) {
if ( (Cache[i].last_frame_used > -1) && (Cache[i].top_bmp==bitmap_top) && (Cache[i].bottom_bmp==bitmap_bottom) && (Cache[i].orient==orient )) {
if ( (Cache[i].last_time_used > -1) && (Cache[i].top_bmp==bitmap_top) && (Cache[i].bottom_bmp==bitmap_bottom) && (Cache[i].orient==orient )) {
cache_hits++;
Cache[i].last_frame_used = FrameCount;
Cache[i].last_time_used = timer_query();
return Cache[i].bitmap;
}
if ( Cache[i].last_frame_used < lowest_frame_count ) {
lowest_frame_count = Cache[i].last_frame_used;
if ( Cache[i].last_time_used < lowest_time_used ) {
lowest_time_used = Cache[i].last_time_used;
least_recently_used = i;
}
}
@ -171,7 +172,7 @@ grs_bitmap * texmerge_get_cached_bitmap( int tmap_bottom, int tmap_top )
Cache[least_recently_used].top_bmp = bitmap_top;
Cache[least_recently_used].bottom_bmp = bitmap_bottom;
Cache[least_recently_used].last_frame_used = FrameCount;
Cache[least_recently_used].last_time_used = timer_query();
Cache[least_recently_used].orient = orient;
return Cache[least_recently_used].bitmap;

View file

@ -1423,7 +1423,7 @@ void remove_obsolete_stuck_objects(void)
if (!Num_stuck_objects)
return;
objnum = FrameCount % MAX_STUCK_OBJECTS;
objnum = d_tick_count % MAX_STUCK_OBJECTS;
if (Stuck_objects[objnum].wallnum != -1)
if ((Walls[Stuck_objects[objnum].wallnum].state != WALL_DOOR_CLOSED) || (Objects[Stuck_objects[objnum].objnum].signature != Stuck_objects[objnum].signature)) {

View file

@ -788,11 +788,11 @@ void rock_the_mine_frame(void)
Seismic_tremor_volume += fc;
rx = fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32);
rz = fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32);
if (FixedStep & EPS20)
if (d_tick_step)
{
rx = fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32);
rz = fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32);
ConsoleObject->mtype.phys_info.rotvel.x += rx;
ConsoleObject->mtype.phys_info.rotvel.z += rz;
@ -801,11 +801,10 @@ void rock_the_mine_frame(void)
Objects[Buddy_objnum].mtype.phys_info.rotvel.x += rx*4;
Objects[Buddy_objnum].mtype.phys_info.rotvel.z += rz*4;
}
// Shake a guided missile!
Seismic_tremor_magnitude += rx;
}
// Shake a guided missile!
Seismic_tremor_magnitude += rx;
} else
Smega_detonate_times[i] = 0;
@ -883,11 +882,11 @@ void seismic_disturbance_frame(void)
Seismic_tremor_volume += fc;
rx = fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32);
rz = fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32);
if (FixedStep & EPS20)
if (d_tick_step)
{
rx = fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32);
rz = fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32);
ConsoleObject->mtype.phys_info.rotvel.x += rx;
ConsoleObject->mtype.phys_info.rotvel.z += rz;
@ -896,10 +895,9 @@ void seismic_disturbance_frame(void)
Objects[Buddy_objnum].mtype.phys_info.rotvel.x += rx*4;
Objects[Buddy_objnum].mtype.phys_info.rotvel.z += rz*4;
}
// Shake a guided missile!
Seismic_tremor_magnitude += rx;
}
// Shake a guided missile!
Seismic_tremor_magnitude += rx;
}
}
}
@ -934,7 +932,7 @@ void process_super_mines_frame(void)
// If we don't know of there being any super mines in the level, just
// check every 8th object each frame.
if (Super_mines_yes == 0) {
start = FrameCount & 7;
start = d_tick_count & 7;
add = 8;
} else {
start = 0;
@ -969,7 +967,7 @@ void process_super_mines_frame(void)
else {
// Object which is close enough to detonate smart mine is not in same segment as smart mine.
// Need to do a more expensive check to make sure there isn't an obstruction.
if (((FrameCount ^ (i+j)) % 4) == 0) {
if (((d_tick_count ^ (i+j)) % 4) == 0) {
fvi_query fq;
fvi_info hit_data;
int fate;