Introduced new data type fix64 to be used for new timers which can last 4462756 years instead of 9 hours; Introduced new timer functions to update and query program time; Used new timer all over the program except GameTime (which comes next)
This commit is contained in:
parent
84bf981a06
commit
ffc73ed4f2
|
@ -1,5 +1,9 @@
|
|||
D1X-Rebirth Changelog
|
||||
|
||||
20101211
|
||||
--------
|
||||
arch/include/key.h, arch/include/mouse.h, arch/sdl/event.c, arch/sdl/joy.c, arch/sdl/key.c, arch/sdl/mouse.c, arch/sdl/rbaudio.c, arch/sdl/timer.c, editor/ehostage.c, editor/medrobot.c, editor/medwall.c, include/maths.h, include/timer.h, include/ui.h, main/automap.c, main/console.c, main/digiobj.c, main/fireball.c, main/game.c, main/inferno.c, main/kmatrix.c, main/laser.c, main/laser.h, main/lighting.c, main/menu.c, main/multi.c, main/multi.h, main/multibot.c, main/net_ipx.c, main/net_ipx.h, main/net_udp.c, main/net_udp.h, main/newmenu.c, main/scores.c, main/titles.c, ui/listbox.c, ui/mouse.c, ui/scroll.c, ui/window.c: Introduced new data type fix64 to be used for new timers which can last 4462756 years instead of 9 hours; Introduced new timer functions to update and query program time; Used new timer all over the program except GameTime (which comes next)
|
||||
|
||||
20101205
|
||||
--------
|
||||
arch/carbon/messagebox.c, arch/include/window.h, arch/linux/messagebox.c, arch/sdl/key.c, arch/sdl/mouse.c, arch/sdl/window.c, arch/win32/messagebox.c: Add CON_DEBUG level con_printf's for basic events (not EVENT_IDLE or EVENT_DRAW though)
|
||||
|
|
|
@ -49,7 +49,7 @@ extern unsigned char keyd_buffer_type;
|
|||
extern unsigned char keyd_editor_mode;
|
||||
|
||||
// Time in seconds when last key was pressed...
|
||||
extern volatile int keyd_time_when_last_pressed;
|
||||
extern fix64 keyd_time_when_last_pressed;
|
||||
|
||||
// Stores Unicode values registered in one event_loop call
|
||||
unsigned char unicode_frame_buffer[KEY_BUFFER_SIZE];
|
||||
|
@ -63,7 +63,6 @@ extern void key_flush(); // Clears the 256 char buffer
|
|||
extern int key_checkch(); // Returns 1 if a char is waiting
|
||||
extern int key_getch(); // Gets key if one waiting other waits for one.
|
||||
extern int key_inkey(); // Gets key if one, other returns 0.
|
||||
extern int key_inkey_time(fix *time); // Same as inkey, but returns the time the key was pressed down.
|
||||
extern int key_peekkey(); // Same as inkey, but doesn't remove key from buffer.
|
||||
|
||||
extern unsigned char key_ascii();
|
||||
|
@ -79,7 +78,7 @@ extern volatile unsigned char keyd_last_pressed;
|
|||
extern volatile unsigned char keyd_last_released;
|
||||
|
||||
// Returns the seconds this key has been down since last call.
|
||||
extern fix key_down_time(int scancode);
|
||||
extern fix64 key_down_time(int scancode);
|
||||
|
||||
// Returns number of times key has went from up to down since last call.
|
||||
extern unsigned int key_down_count(int scancode);
|
||||
|
|
|
@ -43,7 +43,7 @@ extern void mouse_get_pos( int *x, int *y, int *z );
|
|||
extern void mouse_get_delta( int *dx, int *dy, int *dz );
|
||||
extern int mouse_get_btns();
|
||||
extern void mouse_set_pos( int x, int y);
|
||||
extern fix mouse_button_down_time(int button);
|
||||
extern fix64 mouse_button_down_time(int button);
|
||||
extern int mouse_button_down_count(int button);
|
||||
extern int mouse_button_state(int button);
|
||||
extern void mouse_toggle_cursor(int activate);
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
extern void key_handler(SDL_KeyboardEvent *event, fix time);
|
||||
extern void mouse_button_handler(SDL_MouseButtonEvent *mbe, fix time);
|
||||
extern void mouse_motion_handler(SDL_MouseMotionEvent *mme, fix time);
|
||||
extern void joy_button_handler(SDL_JoyButtonEvent *jbe, fix time);
|
||||
extern void joy_hat_handler(SDL_JoyHatEvent *jhe, fix time);
|
||||
extern void joy_axis_handler(SDL_JoyAxisEvent *jae, fix time);
|
||||
extern void mouse_update_cursor_and_grab(fix time);
|
||||
extern void key_handler(SDL_KeyboardEvent *event);
|
||||
extern void mouse_button_handler(SDL_MouseButtonEvent *mbe);
|
||||
extern void mouse_motion_handler(SDL_MouseMotionEvent *mme);
|
||||
extern void joy_button_handler(SDL_JoyButtonEvent *jbe);
|
||||
extern void joy_hat_handler(SDL_JoyHatEvent *jhe);
|
||||
extern void joy_axis_handler(SDL_JoyAxisEvent *jae);
|
||||
extern void mouse_update_cursor_and_grab();
|
||||
|
||||
static int initialised=0;
|
||||
|
||||
|
@ -29,7 +29,6 @@ void event_poll()
|
|||
{
|
||||
SDL_Event event;
|
||||
int clean_uniframe=1;
|
||||
fix time = timer_get_fixed_seconds();
|
||||
window *wind = window_get_front();
|
||||
|
||||
// If the front window changes, exit this loop, otherwise unintended behavior can occur
|
||||
|
@ -42,24 +41,24 @@ void event_poll()
|
|||
if (clean_uniframe)
|
||||
memset(unicode_frame_buffer,'\0',sizeof(unsigned char)*KEY_BUFFER_SIZE);
|
||||
clean_uniframe=0;
|
||||
key_handler((SDL_KeyboardEvent *)&event, time);
|
||||
key_handler((SDL_KeyboardEvent *)&event);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
mouse_button_handler((SDL_MouseButtonEvent *)&event, time);
|
||||
mouse_button_handler((SDL_MouseButtonEvent *)&event);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
mouse_motion_handler((SDL_MouseMotionEvent *)&event, time);
|
||||
mouse_motion_handler((SDL_MouseMotionEvent *)&event);
|
||||
break;
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
case SDL_JOYBUTTONUP:
|
||||
joy_button_handler((SDL_JoyButtonEvent *)&event, time);
|
||||
joy_button_handler((SDL_JoyButtonEvent *)&event);
|
||||
break;
|
||||
case SDL_JOYAXISMOTION:
|
||||
joy_axis_handler((SDL_JoyAxisEvent *)&event, time);
|
||||
joy_axis_handler((SDL_JoyAxisEvent *)&event);
|
||||
break;
|
||||
case SDL_JOYHATMOTION:
|
||||
joy_hat_handler((SDL_JoyHatEvent *)&event, time);
|
||||
joy_hat_handler((SDL_JoyHatEvent *)&event);
|
||||
break;
|
||||
case SDL_JOYBALLMOTION:
|
||||
break;
|
||||
|
@ -70,7 +69,7 @@ void event_poll()
|
|||
}
|
||||
}
|
||||
|
||||
mouse_update_cursor_and_grab(time);
|
||||
mouse_update_cursor_and_grab();
|
||||
}
|
||||
|
||||
void event_flush()
|
||||
|
|
|
@ -23,11 +23,11 @@ int num_joysticks = 0;
|
|||
int joy_num_axes = 0;
|
||||
|
||||
struct joybutton {
|
||||
int state;
|
||||
int last_state;
|
||||
fix time_went_down;
|
||||
int num_downs;
|
||||
int num_ups;
|
||||
int state;
|
||||
int last_state;
|
||||
fix64 time_went_down;
|
||||
int num_downs;
|
||||
int num_ups;
|
||||
};
|
||||
|
||||
struct joyaxis {
|
||||
|
@ -60,7 +60,7 @@ static struct {
|
|||
int button_map[MAX_BUTTONS_PER_JOYSTICK];
|
||||
} SDL_Joysticks[MAX_JOYSTICKS];
|
||||
|
||||
void joy_button_handler(SDL_JoyButtonEvent *jbe, fix time)
|
||||
void joy_button_handler(SDL_JoyButtonEvent *jbe)
|
||||
{
|
||||
int button;
|
||||
|
||||
|
@ -70,7 +70,7 @@ void joy_button_handler(SDL_JoyButtonEvent *jbe, fix time)
|
|||
|
||||
switch (jbe->type) {
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
Joystick.buttons[button].time_went_down = time;
|
||||
Joystick.buttons[button].time_went_down = timer_query();
|
||||
Joystick.buttons[button].num_downs++;
|
||||
break;
|
||||
case SDL_JOYBUTTONUP:
|
||||
|
@ -79,7 +79,7 @@ void joy_button_handler(SDL_JoyButtonEvent *jbe, fix time)
|
|||
}
|
||||
}
|
||||
|
||||
void joy_hat_handler(SDL_JoyHatEvent *jhe, fix time)
|
||||
void joy_hat_handler(SDL_JoyHatEvent *jhe)
|
||||
{
|
||||
int hat = SDL_Joysticks[jhe->which].hat_map[jhe->hat];
|
||||
int hbi;
|
||||
|
@ -102,7 +102,7 @@ void joy_hat_handler(SDL_JoyHatEvent *jhe, fix time)
|
|||
if( !Joystick.buttons[hat+hbi].last_state && Joystick.buttons[hat+hbi].state) //last_state up, current state down
|
||||
{
|
||||
Joystick.buttons[hat+hbi].time_went_down
|
||||
= time;
|
||||
= timer_query();
|
||||
Joystick.buttons[hat+hbi].num_downs++;
|
||||
}
|
||||
else if(Joystick.buttons[hat+hbi].last_state && !Joystick.buttons[hat+hbi].state) //last_state down, current state up
|
||||
|
@ -112,7 +112,7 @@ void joy_hat_handler(SDL_JoyHatEvent *jhe, fix time)
|
|||
}
|
||||
}
|
||||
|
||||
void joy_axis_handler(SDL_JoyAxisEvent *jae, fix time)
|
||||
void joy_axis_handler(SDL_JoyAxisEvent *jae)
|
||||
{
|
||||
int axis;
|
||||
|
||||
|
@ -249,8 +249,8 @@ fix joy_get_button_down_time(int btn)
|
|||
|
||||
switch (Joystick.buttons[btn].state) {
|
||||
case SDL_PRESSED:
|
||||
time = timer_get_fixed_seconds() - Joystick.buttons[btn].time_went_down;
|
||||
Joystick.buttons[btn].time_went_down = timer_get_fixed_seconds();
|
||||
time = timer_query() - Joystick.buttons[btn].time_went_down;
|
||||
Joystick.buttons[btn].time_went_down = timer_query();
|
||||
break;
|
||||
case SDL_RELEASED:
|
||||
time = 0;
|
||||
|
|
|
@ -26,15 +26,15 @@ unsigned char keyd_editor_mode;
|
|||
volatile unsigned char keyd_last_pressed;
|
||||
volatile unsigned char keyd_last_released;
|
||||
volatile unsigned char keyd_pressed[256];
|
||||
volatile int keyd_time_when_last_pressed;
|
||||
fix64 keyd_time_when_last_pressed;
|
||||
unsigned char unicode_frame_buffer[KEY_BUFFER_SIZE] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' };
|
||||
|
||||
typedef struct Key_info {
|
||||
ubyte state; // state of key 1 == down, 0 == up
|
||||
ubyte last_state; // previous state of key
|
||||
int counter; // incremented each time key is down in handler
|
||||
fix timewentdown; // simple counter incremented each time in interrupt and key is down
|
||||
fix timehelddown; // counter to tell how long key is down -- gets reset to 0 by key routines
|
||||
fix64 timewentdown; // simple counter incremented each time in interrupt and key is down
|
||||
fix64 timehelddown; // counter to tell how long key is down -- gets reset to 0 by key routines
|
||||
ubyte downcount; // number of key counts key was down
|
||||
ubyte upcount; // number of times key was released
|
||||
} Key_info;
|
||||
|
@ -42,7 +42,7 @@ typedef struct Key_info {
|
|||
typedef struct keyboard {
|
||||
unsigned short keybuffer[KEY_BUFFER_SIZE];
|
||||
Key_info keys[256];
|
||||
fix time_pressed[KEY_BUFFER_SIZE];
|
||||
fix64 time_pressed[KEY_BUFFER_SIZE];
|
||||
unsigned int keyhead, keytail;
|
||||
} keyboard;
|
||||
|
||||
|
@ -345,7 +345,7 @@ unsigned char key_ascii()
|
|||
return 255;
|
||||
}
|
||||
|
||||
void key_handler(SDL_KeyboardEvent *event, fix time)
|
||||
void key_handler(SDL_KeyboardEvent *event)
|
||||
{
|
||||
ubyte state;
|
||||
int i, keycode, event_keysym=-1, key_state;
|
||||
|
@ -381,7 +381,7 @@ void key_handler(SDL_KeyboardEvent *event, fix time)
|
|||
if (state) {
|
||||
key->counter++;
|
||||
keyd_last_pressed = keycode;
|
||||
keyd_time_when_last_pressed = time;
|
||||
keyd_time_when_last_pressed = timer_query();
|
||||
}
|
||||
} else {
|
||||
if (state) {
|
||||
|
@ -389,7 +389,7 @@ void key_handler(SDL_KeyboardEvent *event, fix time)
|
|||
keyd_pressed[keycode] = 1;
|
||||
key->downcount += state;
|
||||
key->state = 1;
|
||||
key->timewentdown = keyd_time_when_last_pressed = time;
|
||||
key->timewentdown = keyd_time_when_last_pressed = timer_query();
|
||||
key->counter++;
|
||||
} else {
|
||||
keyd_pressed[keycode] = 0;
|
||||
|
@ -397,7 +397,7 @@ void key_handler(SDL_KeyboardEvent *event, fix time)
|
|||
key->upcount += key->state;
|
||||
key->state = 0;
|
||||
key->counter = 0;
|
||||
key->timehelddown += time - key->timewentdown;
|
||||
key->timehelddown += timer_query() - key->timewentdown;
|
||||
}
|
||||
}
|
||||
if ( (state && !key->last_state) || (state && key->last_state && (key->counter > 30) && (key->counter & 0x01)) ) {
|
||||
|
@ -466,7 +466,7 @@ void key_init()
|
|||
Installed=1;
|
||||
SDL_EnableUNICODE(1);
|
||||
|
||||
keyd_time_when_last_pressed = timer_get_fixed_seconds();
|
||||
keyd_time_when_last_pressed = timer_query();
|
||||
keyd_buffer_type = 1;
|
||||
|
||||
for(i=0; i<256; i++)
|
||||
|
@ -479,7 +479,6 @@ void key_init()
|
|||
void key_flush()
|
||||
{
|
||||
int i;
|
||||
fix curtime;
|
||||
|
||||
if (!Installed)
|
||||
key_init();
|
||||
|
@ -493,14 +492,11 @@ void key_flush()
|
|||
unicode_frame_buffer[i] = '\0';
|
||||
}
|
||||
|
||||
//use gettimeofday here:
|
||||
curtime = timer_get_fixed_seconds();
|
||||
|
||||
for (i=0; i<256; i++ ) {
|
||||
keyd_pressed[i] = 0;
|
||||
key_data.keys[i].state = 1;
|
||||
key_data.keys[i].last_state = 0;
|
||||
key_data.keys[i].timewentdown = curtime;
|
||||
key_data.keys[i].timewentdown = timer_query();
|
||||
key_data.keys[i].downcount=0;
|
||||
key_data.keys[i].upcount=0;
|
||||
key_data.keys[i].timehelddown = 0;
|
||||
|
@ -539,21 +535,6 @@ int key_inkey()
|
|||
return key;
|
||||
}
|
||||
|
||||
int key_inkey_time(fix * time)
|
||||
{
|
||||
int key = 0;
|
||||
|
||||
if (!Installed)
|
||||
key_init();
|
||||
// event_poll();
|
||||
if (key_data.keytail!=key_data.keyhead) {
|
||||
key = key_data.keybuffer[key_data.keyhead];
|
||||
*time = key_data.time_pressed[key_data.keyhead];
|
||||
key_data.keyhead = add_one(key_data.keyhead);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
int key_peekkey()
|
||||
{
|
||||
int key = 0;
|
||||
|
@ -599,9 +580,9 @@ unsigned int key_get_shift_status()
|
|||
}
|
||||
|
||||
// Returns the number of seconds this key has been down since last call.
|
||||
fix key_down_time(int scancode)
|
||||
fix64 key_down_time(int scancode)
|
||||
{
|
||||
fix time_down, time;
|
||||
fix64 time_down, time;
|
||||
|
||||
// event_poll();
|
||||
if ((scancode<0)|| (scancode>255)) return 0;
|
||||
|
@ -610,7 +591,7 @@ fix key_down_time(int scancode)
|
|||
time_down = key_data.keys[scancode].timehelddown;
|
||||
key_data.keys[scancode].timehelddown = 0;
|
||||
} else {
|
||||
time = timer_get_fixed_seconds();
|
||||
time = timer_query();
|
||||
time_down = time - key_data.keys[scancode].timewentdown;
|
||||
key_data.keys[scancode].timewentdown = time;
|
||||
}
|
||||
|
|
|
@ -15,18 +15,18 @@
|
|||
|
||||
struct mousebutton {
|
||||
ubyte pressed;
|
||||
fix time_went_down;
|
||||
fix time_held_down;
|
||||
uint num_downs;
|
||||
uint num_ups;
|
||||
fix64 time_went_down;
|
||||
fix64 time_held_down;
|
||||
uint num_downs;
|
||||
uint num_ups;
|
||||
};
|
||||
|
||||
static struct mouseinfo {
|
||||
struct mousebutton buttons[MOUSE_MAX_BUTTONS];
|
||||
int delta_x, delta_y, delta_z, old_delta_x, old_delta_y;
|
||||
int x,y,z;
|
||||
int cursor_enabled;
|
||||
fix cursor_time;
|
||||
int delta_x, delta_y, delta_z, old_delta_x, old_delta_y;
|
||||
int x,y,z;
|
||||
int cursor_enabled;
|
||||
fix64 cursor_time;
|
||||
} Mouse;
|
||||
|
||||
typedef struct d_event_mousebutton
|
||||
|
@ -47,7 +47,7 @@ void mouse_close(void)
|
|||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
}
|
||||
|
||||
void mouse_button_handler(SDL_MouseButtonEvent *mbe, fix time)
|
||||
void mouse_button_handler(SDL_MouseButtonEvent *mbe)
|
||||
{
|
||||
// to bad, SDL buttons use a different mapping as descent expects,
|
||||
// this is at least true and tested for the first three buttons
|
||||
|
@ -78,11 +78,11 @@ void mouse_button_handler(SDL_MouseButtonEvent *mbe, fix time)
|
|||
if (GameArg.CtlNoMouse)
|
||||
return;
|
||||
|
||||
Mouse.cursor_time = time;
|
||||
Mouse.cursor_time = timer_query();
|
||||
|
||||
if (mbe->state == SDL_PRESSED) {
|
||||
Mouse.buttons[button].pressed = 1;
|
||||
Mouse.buttons[button].time_went_down = time;
|
||||
Mouse.buttons[button].time_went_down = timer_query();
|
||||
Mouse.buttons[button].num_downs++;
|
||||
|
||||
if (button == MBTN_Z_UP) {
|
||||
|
@ -94,7 +94,7 @@ void mouse_button_handler(SDL_MouseButtonEvent *mbe, fix time)
|
|||
}
|
||||
} else {
|
||||
Mouse.buttons[button].pressed = 0;
|
||||
Mouse.buttons[button].time_held_down += time - Mouse.buttons[button].time_went_down;
|
||||
Mouse.buttons[button].time_held_down += timer_query() - Mouse.buttons[button].time_went_down;
|
||||
Mouse.buttons[button].num_ups++;
|
||||
}
|
||||
|
||||
|
@ -112,12 +112,12 @@ void mouse_button_handler(SDL_MouseButtonEvent *mbe, fix time)
|
|||
call_default_handler((d_event *)&event);
|
||||
}
|
||||
|
||||
void mouse_motion_handler(SDL_MouseMotionEvent *mme, fix time)
|
||||
void mouse_motion_handler(SDL_MouseMotionEvent *mme)
|
||||
{
|
||||
if (GameArg.CtlNoMouse)
|
||||
return;
|
||||
|
||||
Mouse.cursor_time = time;
|
||||
Mouse.cursor_time = timer_query();
|
||||
Mouse.x += mme->xrel;
|
||||
Mouse.y += mme->yrel;
|
||||
}
|
||||
|
@ -125,14 +125,12 @@ void mouse_motion_handler(SDL_MouseMotionEvent *mme, fix time)
|
|||
void mouse_flush() // clears all mice events...
|
||||
{
|
||||
int i;
|
||||
fix current_time;
|
||||
|
||||
// event_poll();
|
||||
|
||||
current_time = timer_get_fixed_seconds();
|
||||
for (i=0; i<MOUSE_MAX_BUTTONS; i++) {
|
||||
Mouse.buttons[i].pressed=0;
|
||||
Mouse.buttons[i].time_went_down=current_time;
|
||||
Mouse.buttons[i].time_went_down=timer_query();
|
||||
Mouse.buttons[i].time_held_down=0;
|
||||
Mouse.buttons[i].num_ups=0;
|
||||
Mouse.buttons[i].num_downs=0;
|
||||
|
@ -203,9 +201,9 @@ int mouse_get_btns()
|
|||
}
|
||||
|
||||
// Returns how long this button has been down since last call.
|
||||
fix mouse_button_down_time(int button)
|
||||
fix64 mouse_button_down_time(int button)
|
||||
{
|
||||
fix time_down, time;
|
||||
fix64 time_down, time;
|
||||
|
||||
// event_poll();
|
||||
|
||||
|
@ -213,7 +211,7 @@ fix mouse_button_down_time(int button)
|
|||
time_down = Mouse.buttons[button].time_held_down;
|
||||
Mouse.buttons[button].time_held_down = 0;
|
||||
} else {
|
||||
time = timer_get_fixed_seconds();
|
||||
time = timer_query();
|
||||
time_down = time - Mouse.buttons[button].time_held_down;
|
||||
Mouse.buttons[button].time_held_down = time;
|
||||
}
|
||||
|
@ -261,15 +259,15 @@ void mouse_toggle_cursor(int activate)
|
|||
* If we want to display/hide cursor, do so if not already and also hide it automatically after some time.
|
||||
* If we want to grab/release cursor, do so if not already.
|
||||
*/
|
||||
void mouse_update_cursor_and_grab(fix time)
|
||||
void mouse_update_cursor_and_grab()
|
||||
{
|
||||
int show = SDL_ShowCursor(SDL_QUERY), grab = SDL_WM_GrabInput(SDL_QUERY);
|
||||
|
||||
if (Mouse.cursor_enabled)
|
||||
{
|
||||
if ( (Mouse.cursor_time + (F1_0*2)) >= time && !show)
|
||||
if ( (Mouse.cursor_time + (F1_0*2)) >= timer_query() && !show)
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
else if ( (Mouse.cursor_time + (F1_0*2)) < time && show)
|
||||
else if ( (Mouse.cursor_time + (F1_0*2)) < timer_query() && show)
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
||||
if (grab)
|
||||
|
|
|
@ -200,17 +200,15 @@ int RBAGetNumberOfTracks()
|
|||
// a real hook would be ideal, but is currently unsupported by SDL Audio CD
|
||||
void RBACheckFinishedHook()
|
||||
{
|
||||
static fix last_check_time;
|
||||
fix current_time;
|
||||
static fix64 last_check_time;
|
||||
|
||||
if (!s_cd) return;
|
||||
|
||||
current_time = timer_get_fixed_seconds();
|
||||
if (current_time < last_check_time || (current_time - last_check_time) >= F2_0)
|
||||
if ((timer_query() - last_check_time) >= F2_0)
|
||||
{
|
||||
if ((SDL_CDStatus(s_cd) == CD_STOPPED) && redbook_finished_hook)
|
||||
redbook_finished_hook();
|
||||
last_check_time = current_time;
|
||||
last_check_time = timer_query();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,28 @@
|
|||
#include "timer.h"
|
||||
#include "config.h"
|
||||
|
||||
fix timer_get_fixed_seconds(void)
|
||||
static fix64 F64_RunTime = 0;
|
||||
|
||||
void timer_update(void)
|
||||
{
|
||||
fix x;
|
||||
unsigned long tv_now = SDL_GetTicks();
|
||||
x=i2f(tv_now/1000) | fixdiv(i2f(tv_now % 1000),i2f(1000));
|
||||
return x;
|
||||
static ubyte init = 1;
|
||||
static u_int32_t last_tv = 0;
|
||||
u_int32_t cur_tv = SDL_GetTicks();
|
||||
|
||||
if (init)
|
||||
{
|
||||
last_tv = cur_tv;
|
||||
init = 0;
|
||||
}
|
||||
|
||||
if (last_tv < cur_tv) // in case SDL_GetTicks wraps, don't update and have a little hickup
|
||||
F64_RunTime += (cur_tv - last_tv)*F1_0/1000; // increment! this value will overflow long after we are all dead... so why bother checking?
|
||||
last_tv = cur_tv;
|
||||
}
|
||||
|
||||
fix64 timer_query(void)
|
||||
{
|
||||
return (F64_RunTime);
|
||||
}
|
||||
|
||||
void timer_delay(fix seconds)
|
||||
|
|
|
@ -106,7 +106,7 @@ void vclip_play( vclip * vc, fix frame_time )
|
|||
|
||||
static char HostageMessage[] = " ";
|
||||
|
||||
static fix Time;
|
||||
static fix64 Time;
|
||||
|
||||
int SelectPrevHostage() {
|
||||
int start=0;
|
||||
|
@ -374,7 +374,7 @@ int do_hostage_dialog()
|
|||
ui_add_gadget_button( MainWindow,155,i,140, 26, "Delete", ObjectDelete ); i += 29;
|
||||
ui_add_gadget_button( MainWindow,155,i,140, 26, "Create New", PlaceHostage ); i += 29;
|
||||
|
||||
Time = timer_get_fixed_seconds();
|
||||
Time = timer_query();
|
||||
|
||||
LastHostageIndex = -2; // Set to some dummy value so everything works ok on the first frame.
|
||||
|
||||
|
@ -395,7 +395,8 @@ void hostage_close_window()
|
|||
|
||||
void do_hostage_window()
|
||||
{
|
||||
fix DeltaTime, Temp;
|
||||
fix DeltaTime;
|
||||
fix64 Temp;
|
||||
|
||||
if ( MainWindow == NULL ) return;
|
||||
|
||||
|
@ -436,7 +437,7 @@ void do_hostage_window()
|
|||
//------------------------------------------------------------
|
||||
// A simple frame time counter for spinning the objects...
|
||||
//------------------------------------------------------------
|
||||
Temp = timer_get_fixed_seconds();
|
||||
Temp = timer_query();
|
||||
DeltaTime = Temp - Time;
|
||||
Time = Temp;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ static UI_GADGET_BUTTON *QuitButton;
|
|||
static UI_GADGET_RADIO *InitialMode[NUM_BOXES];
|
||||
|
||||
static int old_object;
|
||||
static fix Time;
|
||||
static fix64 Time;
|
||||
static vms_angvec angles={0,0,0}, goody_angles={0,0,0};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -536,7 +536,7 @@ int do_robot_dialog()
|
|||
ui_add_gadget_button( MainWindow,190,i,110, 26, "Create New", LocalObjectPlaceObject ); i += 29;
|
||||
ui_add_gadget_button( MainWindow,190,i,110, 26, "Set Path", med_set_ai_path );
|
||||
|
||||
Time = timer_get_fixed_seconds();
|
||||
Time = timer_query();
|
||||
|
||||
old_object = -2; // Set to some dummy value so everything works ok on the first frame.
|
||||
|
||||
|
@ -561,7 +561,8 @@ void robot_close_window()
|
|||
void do_robot_window()
|
||||
{
|
||||
int i;
|
||||
fix DeltaTime, Temp;
|
||||
fix DeltaTime;
|
||||
fix64 Temp;
|
||||
int first_object_index;
|
||||
|
||||
if ( MainWindow == NULL ) return;
|
||||
|
@ -615,7 +616,7 @@ void do_robot_window()
|
|||
//------------------------------------------------------------
|
||||
// A simple frame time counter for spinning the objects...
|
||||
//------------------------------------------------------------
|
||||
Temp = timer_get_fixed_seconds();
|
||||
Temp = timer_query();
|
||||
DeltaTime = Temp - Time;
|
||||
Time = Temp;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ static UI_GADGET_CHECKBOX *DoorFlag[4];
|
|||
static UI_GADGET_RADIO *KeyFlag[4];
|
||||
|
||||
static int old_wall_num;
|
||||
static fix Time;
|
||||
static fix64 Time;
|
||||
static int framenum=0;
|
||||
static int Current_door_type=1;
|
||||
|
||||
|
@ -400,7 +400,8 @@ void do_wall_window()
|
|||
{
|
||||
int i;
|
||||
sbyte type;
|
||||
fix DeltaTime, Temp;
|
||||
fix DeltaTime;
|
||||
fix64 Temp;
|
||||
|
||||
if ( MainWindow == NULL ) return;
|
||||
|
||||
|
@ -496,7 +497,7 @@ void do_wall_window()
|
|||
//------------------------------------------------------------
|
||||
// A simple frame time counter for animating the walls...
|
||||
//------------------------------------------------------------
|
||||
Temp = timer_get_fixed_seconds();
|
||||
Temp = timer_query();
|
||||
DeltaTime = Temp - Time;
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
|
|
@ -18,6 +18,7 @@ int d_rand (); // Random number function which returns in the range 0-0x7FFF
|
|||
|
||||
//=============================== FIXED POINT ===============================
|
||||
|
||||
typedef int64_t fix64; //64 bits int, for timers
|
||||
typedef int32_t fix; //16 bits int, 16 bits frac
|
||||
typedef int16_t fixang; //angles
|
||||
|
||||
|
@ -29,10 +30,8 @@ typedef struct quad
|
|||
quad;
|
||||
|
||||
|
||||
//Convert an int to a fix
|
||||
//Convert an int to a fix/fix64 and back
|
||||
#define i2f(i) ((i)<<16)
|
||||
|
||||
//Get the int part of a fix
|
||||
#define f2i(f) ((f)>>16)
|
||||
|
||||
//Get the int part of a fix, with rounding
|
||||
|
|
|
@ -24,7 +24,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#include "pstypes.h"
|
||||
#include "fix.h"
|
||||
|
||||
extern fix timer_get_fixed_seconds(); // Rolls about every 9 hours...
|
||||
void timer_update();
|
||||
fix64 timer_query();
|
||||
void timer_delay(fix seconds);
|
||||
void timer_delay2(int fps);
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ typedef struct {
|
|||
int fake_size;
|
||||
UI_GADGET_BUTTON * up_button;
|
||||
UI_GADGET_BUTTON * down_button;
|
||||
unsigned int last_scrolled;
|
||||
fix64 last_scrolled;
|
||||
short drag_x, drag_y;
|
||||
int drag_starting;
|
||||
int dragging;
|
||||
|
@ -176,7 +176,7 @@ typedef struct {
|
|||
int current_item;
|
||||
int selected_item;
|
||||
int old_current_item;
|
||||
unsigned int last_scrolled;
|
||||
fix64 last_scrolled;
|
||||
int dragging;
|
||||
int textheight;
|
||||
UI_GADGET_SCROLLBAR * scrollbar;
|
||||
|
@ -215,7 +215,7 @@ typedef struct {
|
|||
grs_bitmap * background;
|
||||
grs_bitmap * pointer;
|
||||
#endif
|
||||
unsigned int time_lastpressed;
|
||||
fix64 time_lastpressed;
|
||||
short moved;
|
||||
} UI_MOUSE;
|
||||
|
||||
|
|
|
@ -90,8 +90,8 @@ typedef struct Edge_info {
|
|||
|
||||
typedef struct automap
|
||||
{
|
||||
fix entry_time;
|
||||
fix t1, t2;
|
||||
fix64 entry_time;
|
||||
fix64 t1, t2;
|
||||
int leave_mode;
|
||||
int pause_game;
|
||||
vms_angvec tangles;
|
||||
|
@ -424,7 +424,7 @@ int automap_idle(window *wind, d_event *event, automap *am)
|
|||
Controls = am->saved_control_info; // Restore controls
|
||||
}
|
||||
|
||||
if ( am->leave_mode==0 && Controls.automap_state && (timer_get_fixed_seconds()-am->entry_time)>LEAVE_TIME)
|
||||
if ( am->leave_mode==0 && Controls.automap_state && (timer_query()-am->entry_time)>LEAVE_TIME)
|
||||
am->leave_mode = 1;
|
||||
|
||||
if ( !Controls.automap_state && (am->leave_mode==1) )
|
||||
|
@ -478,12 +478,13 @@ int automap_idle(window *wind, d_event *event, automap *am)
|
|||
if ( am->viewDist < ZOOM_MIN_VALUE ) am->viewDist = ZOOM_MIN_VALUE;
|
||||
if ( am->viewDist > ZOOM_MAX_VALUE ) am->viewDist = ZOOM_MAX_VALUE;
|
||||
|
||||
am->t2 = timer_get_fixed_seconds();
|
||||
am->t2 = timer_query();
|
||||
while (am->t2 - am->t1 < F1_0 / (GameCfg.VSync?MAXIMUM_FPS:GameArg.SysMaxFPS)) // ogl is fast enough that the automap can read the input too fast and you start to turn really slow. So delay a bit (and free up some cpu :)
|
||||
{
|
||||
if (GameArg.SysUseNiceFPS && !GameCfg.VSync)
|
||||
timer_delay(f1_0 / GameArg.SysMaxFPS - (am->t2 - am->t1));
|
||||
am->t2 = timer_get_fixed_seconds();
|
||||
timer_update();
|
||||
am->t2 = timer_query();
|
||||
}
|
||||
if (am->pause_game)
|
||||
{
|
||||
|
@ -619,7 +620,7 @@ void do_automap( int key_code )
|
|||
|
||||
am->view_target = Objects[Players[Player_num].objnum].pos;
|
||||
|
||||
am->t1 = am->entry_time = timer_get_fixed_seconds();
|
||||
am->t1 = am->entry_time = timer_query();
|
||||
am->t2 = am->t1;
|
||||
|
||||
//Fill in Automap_visited from Objects[Players[Player_num].objnum].segnum
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "gamefont.h"
|
||||
#include "key.h"
|
||||
#include "vers_id.h"
|
||||
#include "game.h"
|
||||
#include "timer.h"
|
||||
|
||||
PHYSFS_file *gamelog_fp=NULL;
|
||||
struct console_buffer con_buffer[CON_LINES_MAX];
|
||||
|
@ -107,20 +107,23 @@ void con_printf(int priority, char *fmt, ...)
|
|||
void con_show(void)
|
||||
{
|
||||
int i=0, y;
|
||||
static float con_size=0;
|
||||
static int con_size=0;
|
||||
static fix64 last_scroll_time = 0;
|
||||
int done=0;
|
||||
|
||||
if (con_render)
|
||||
{
|
||||
if (con_size < CON_LINES_ONSCREEN && FixedStep & EPS30)
|
||||
if (con_size < CON_LINES_ONSCREEN && timer_query() >= last_scroll_time+(F1_0/30))
|
||||
{
|
||||
last_scroll_time = timer_query();
|
||||
con_size++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (con_size > 0 && FixedStep & EPS30)
|
||||
if (con_size > 0 && timer_query() >= last_scroll_time+(F1_0/30))
|
||||
{
|
||||
last_scroll_time = timer_query();
|
||||
con_size--;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -770,7 +770,7 @@ void digi_sound_debug()
|
|||
#endif
|
||||
|
||||
typedef struct sound_q {
|
||||
fix time_added;
|
||||
fix64 time_added;
|
||||
int soundnum;
|
||||
} sound_q;
|
||||
|
||||
|
@ -803,8 +803,6 @@ void SoundQ_end()
|
|||
|
||||
void SoundQ_process()
|
||||
{
|
||||
fix curtime = timer_get_fixed_seconds();
|
||||
|
||||
if ( SoundQ_channel > -1 ) {
|
||||
if ( digi_is_channel_playing(SoundQ_channel) )
|
||||
return;
|
||||
|
@ -814,7 +812,7 @@ void SoundQ_process()
|
|||
while ( SoundQ_head != SoundQ_tail ) {
|
||||
sound_q * q = &SoundQ[SoundQ_head];
|
||||
|
||||
if ( q->time_added+MAX_LIFE > curtime ) {
|
||||
if ( q->time_added+MAX_LIFE > timer_query() ) {
|
||||
SoundQ_channel = digi_start_sound(q->soundnum, F1_0+1, 0xFFFF/2, 0, -1, -1, -1 );
|
||||
return;
|
||||
} else {
|
||||
|
@ -841,7 +839,7 @@ void digi_start_sound_queued( short soundnum, fix volume )
|
|||
volume = F1_0 + 1;
|
||||
|
||||
if ( i != SoundQ_head ) {
|
||||
SoundQ[SoundQ_tail].time_added = timer_get_fixed_seconds();
|
||||
SoundQ[SoundQ_tail].time_added = timer_query();
|
||||
SoundQ[SoundQ_tail].soundnum = soundnum;
|
||||
SoundQ_num++;
|
||||
SoundQ_tail = i;
|
||||
|
|
|
@ -406,7 +406,7 @@ int choose_drop_segment(void)
|
|||
int cur_drop_depth = initial_drop_depth;
|
||||
int count;
|
||||
|
||||
d_srand(timer_get_fixed_seconds());
|
||||
d_srand((fix)timer_query());
|
||||
|
||||
while ((segnum == -1) && (cur_drop_depth > BASE_NET_DROP_DEPTH/2)) {
|
||||
pnum = (d_rand() * N_players) >> 15;
|
||||
|
|
26
main/game.c
26
main/game.c
|
@ -104,7 +104,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
int Mark_count = 0; // number of debugging marks set
|
||||
#endif
|
||||
|
||||
static fix last_timer_value=0;
|
||||
static fix64 last_timer_value=0;
|
||||
|
||||
fix VR_eye_width = F1_0;
|
||||
int VR_render_mode = VR_NONE;
|
||||
|
@ -360,8 +360,8 @@ static int time_paused=0;
|
|||
void stop_time()
|
||||
{
|
||||
if (time_paused==0) {
|
||||
fix time;
|
||||
time = timer_get_fixed_seconds();
|
||||
fix64 time;
|
||||
time = timer_query();
|
||||
last_timer_value = time - last_timer_value;
|
||||
if (last_timer_value < 0) {
|
||||
last_timer_value = 0;
|
||||
|
@ -375,8 +375,8 @@ void start_time()
|
|||
time_paused--;
|
||||
Assert(time_paused >= 0);
|
||||
if (time_paused==0) {
|
||||
fix time;
|
||||
time = timer_get_fixed_seconds();
|
||||
fix64 time;
|
||||
time = timer_query();
|
||||
last_timer_value = time - last_timer_value;
|
||||
}
|
||||
}
|
||||
|
@ -426,21 +426,23 @@ void FixedStepCalc()
|
|||
|
||||
void reset_time()
|
||||
{
|
||||
last_timer_value = timer_get_fixed_seconds();
|
||||
last_timer_value = timer_query();
|
||||
}
|
||||
|
||||
void calc_frame_time()
|
||||
{
|
||||
fix timer_value,last_frametime = FrameTime;
|
||||
fix64 timer_value;
|
||||
fix last_frametime = FrameTime;
|
||||
|
||||
timer_value = timer_get_fixed_seconds();
|
||||
timer_value = timer_query();
|
||||
FrameTime = timer_value - last_timer_value;
|
||||
|
||||
while (FrameTime < f1_0 / (GameCfg.VSync?MAXIMUM_FPS:GameArg.SysMaxFPS))
|
||||
{
|
||||
if (GameArg.SysUseNiceFPS && !GameCfg.VSync)
|
||||
timer_delay(f1_0 / GameArg.SysMaxFPS - FrameTime);
|
||||
timer_value = timer_get_fixed_seconds();
|
||||
timer_update();
|
||||
timer_value = timer_query();
|
||||
FrameTime = timer_value - last_timer_value;
|
||||
}
|
||||
|
||||
|
@ -841,7 +843,7 @@ extern void temp_reset_stuff_on_level();
|
|||
void check_rear_view()
|
||||
{
|
||||
static int leave_mode;
|
||||
static fix entry_time;
|
||||
static fix64 entry_time;
|
||||
|
||||
if (Newdemo_state == ND_STATE_PLAYBACK)
|
||||
return;
|
||||
|
@ -859,7 +861,7 @@ void check_rear_view()
|
|||
else {
|
||||
Rear_view = 1;
|
||||
leave_mode = 0; //means wait for another key
|
||||
entry_time = timer_get_fixed_seconds();
|
||||
entry_time = timer_query();
|
||||
if (PlayerCfg.CockpitMode[1] == CM_FULL_COCKPIT) {
|
||||
select_cockpit(CM_REAR_VIEW);
|
||||
}
|
||||
|
@ -870,7 +872,7 @@ void check_rear_view()
|
|||
else
|
||||
if (Controls.rear_view_down_state) {
|
||||
|
||||
if (leave_mode == 0 && (timer_get_fixed_seconds() - entry_time) > LEAVE_TIME)
|
||||
if (leave_mode == 0 && (timer_query() - entry_time) > LEAVE_TIME)
|
||||
leave_mode = 1;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -188,6 +188,8 @@ int standard_handler(d_event *event)
|
|||
{
|
||||
int key;
|
||||
|
||||
timer_update();
|
||||
|
||||
if (Quitting)
|
||||
{
|
||||
window *wind = window_get_front();
|
||||
|
|
|
@ -59,7 +59,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
/* IPX CODE - START */
|
||||
|
||||
#define MAX_VIEW_TIME F1_0*60
|
||||
fix StartAbortMenuTime;
|
||||
fix64 StartAbortMenuTime;
|
||||
|
||||
void kmatrix_ipx_draw_item( int i, int *sorted )
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ void kmatrix_ipx_draw_deaths(int *sorted)
|
|||
typedef struct kmatrix_ipx_screen
|
||||
{
|
||||
grs_bitmap background;
|
||||
fix entry_time;
|
||||
fix64 entry_time;
|
||||
int network;
|
||||
} kmatrix_ipx_screen;
|
||||
|
||||
|
@ -211,7 +211,7 @@ int kmatrix_ipx_handler(window *wind, d_event *event, kmatrix_ipx_screen *km)
|
|||
case EVENT_IDLE:
|
||||
timer_delay2(50);
|
||||
|
||||
if (timer_get_fixed_seconds() >= (km->entry_time+MAX_VIEW_TIME))
|
||||
if (timer_query() >= (km->entry_time+MAX_VIEW_TIME))
|
||||
window_close(wind);
|
||||
|
||||
if (km->network && (Game_mode & GM_NETWORK))
|
||||
|
@ -252,7 +252,7 @@ void kmatrix_ipx_view(int network)
|
|||
}
|
||||
gr_palette_load(gr_palette);
|
||||
|
||||
km->entry_time = timer_get_fixed_seconds();
|
||||
km->entry_time = timer_query();
|
||||
km->network = network;
|
||||
|
||||
set_screen_mode( SCREEN_MENU );
|
||||
|
@ -392,7 +392,7 @@ typedef struct kmatrix_screen
|
|||
{
|
||||
grs_bitmap background;
|
||||
int network;
|
||||
fix end_time;
|
||||
fix64 end_time;
|
||||
int playing;
|
||||
} kmatrix_screen;
|
||||
|
||||
|
@ -468,7 +468,6 @@ void kmatrix_redraw_coop()
|
|||
int kmatrix_handler(window *wind, d_event *event, kmatrix_screen *km)
|
||||
{
|
||||
int i = 0, k = 0, choice = 0;
|
||||
fix time = timer_get_fixed_seconds();
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
|
@ -479,7 +478,7 @@ int kmatrix_handler(window *wind, d_event *event, kmatrix_screen *km)
|
|||
case KEY_ESC:
|
||||
if (km->network)
|
||||
{
|
||||
StartAbortMenuTime=timer_get_fixed_seconds();
|
||||
StartAbortMenuTime=timer_query();
|
||||
choice=nm_messagebox1( NULL,multi_endlevel_poll2, NULL, 2, TXT_YES, TXT_NO, TXT_ABORT_GAME );
|
||||
}
|
||||
else
|
||||
|
@ -525,10 +524,10 @@ int kmatrix_handler(window *wind, d_event *event, kmatrix_screen *km)
|
|||
|
||||
// If Reactor is finished and end_time not inited, set the time when we will exit this loop
|
||||
if (km->end_time == -1 && Countdown_seconds_left < 0 && !km->playing)
|
||||
km->end_time = time + (KMATRIX_VIEW_SEC * F1_0);
|
||||
km->end_time = timer_query() + (KMATRIX_VIEW_SEC * F1_0);
|
||||
|
||||
// Check if end_time has been reached and exit loop
|
||||
if (time >= km->end_time && km->end_time != -1)
|
||||
if (timer_query() >= km->end_time && km->end_time != -1)
|
||||
{
|
||||
if (km->network)
|
||||
multi_send_endlevel_packet(); // make sure
|
||||
|
@ -543,7 +542,7 @@ int kmatrix_handler(window *wind, d_event *event, kmatrix_screen *km)
|
|||
if (km->playing)
|
||||
kmatrix_status_msg(Countdown_seconds_left, 1);
|
||||
else
|
||||
kmatrix_status_msg(f2i(time-km->end_time), 0);
|
||||
kmatrix_status_msg(f2i(timer_query()-km->end_time), 0);
|
||||
break;
|
||||
|
||||
case EVENT_WINDOW_CLOSE:
|
||||
|
|
|
@ -174,7 +174,7 @@ int Laser_offset=0;
|
|||
|
||||
void do_muzzle_stuff(int segnum, vms_vector *pos)
|
||||
{
|
||||
Muzzle_data[Muzzle_queue_index].create_time = timer_get_fixed_seconds();
|
||||
Muzzle_data[Muzzle_queue_index].create_time = timer_query();
|
||||
Muzzle_data[Muzzle_queue_index].segnum = segnum;
|
||||
Muzzle_data[Muzzle_queue_index].pos = *pos;
|
||||
Muzzle_queue_index++;
|
||||
|
|
|
@ -93,8 +93,8 @@ extern int object_to_object_visibility(struct object *obj1, struct object *obj2,
|
|||
extern int Muzzle_queue_index;
|
||||
|
||||
typedef struct muzzle_info {
|
||||
fix create_time;
|
||||
short segnum;
|
||||
fix64 create_time;
|
||||
short segnum;
|
||||
vms_vector pos;
|
||||
} muzzle_info;
|
||||
|
||||
|
|
|
@ -213,11 +213,11 @@ void apply_light(fix obj_intensity, int obj_seg, vms_vector *obj_pos, int n_rend
|
|||
// ----------------------------------------------------------------------------------------------
|
||||
void cast_muzzle_flash_light(int n_render_vertices, short *render_vertices)
|
||||
{
|
||||
fix current_time;
|
||||
fix64 current_time;
|
||||
int i;
|
||||
short time_since_flash;
|
||||
|
||||
current_time = timer_get_fixed_seconds();
|
||||
current_time = timer_query();
|
||||
|
||||
for (i=0; i<MUZZLE_QUEUE_MAX; i++) {
|
||||
if (Muzzle_data[i].create_time) {
|
||||
|
|
|
@ -394,7 +394,6 @@ void draw_copyright()
|
|||
|
||||
int main_menu_handler(newmenu *menu, d_event *event, int *menu_choice )
|
||||
{
|
||||
int curtime;
|
||||
newmenu_item *items = newmenu_get_items(menu);
|
||||
|
||||
switch (event->type)
|
||||
|
@ -403,7 +402,7 @@ int main_menu_handler(newmenu *menu, d_event *event, int *menu_choice )
|
|||
if ( Players[Player_num].callsign[0]==0 )
|
||||
RegisterPlayer();
|
||||
else
|
||||
keyd_time_when_last_pressed = timer_get_fixed_seconds(); // .. 20 seconds from now!
|
||||
keyd_time_when_last_pressed = timer_query(); // .. 20 seconds from now!
|
||||
break;
|
||||
|
||||
case EVENT_KEY_COMMAND:
|
||||
|
@ -413,11 +412,9 @@ int main_menu_handler(newmenu *menu, d_event *event, int *menu_choice )
|
|||
break;
|
||||
|
||||
case EVENT_IDLE:
|
||||
curtime = timer_get_fixed_seconds();
|
||||
if ( keyd_time_when_last_pressed+i2f(45) < curtime || GameArg.SysAutoDemo )
|
||||
if ( keyd_time_when_last_pressed+i2f(45) < timer_query() || GameArg.SysAutoDemo )
|
||||
{
|
||||
if (curtime < 0) curtime = 0;
|
||||
keyd_time_when_last_pressed = curtime; // Reset timer so that disk won't thrash if no demos.
|
||||
keyd_time_when_last_pressed = timer_query(); // Reset timer so that disk won't thrash if no demos.
|
||||
newdemo_start_playback(NULL); // Randomly pick a file
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -144,7 +144,7 @@ bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEXTURES];
|
|||
|
||||
// Globals for protocol-bound Refuse-functions
|
||||
char RefuseThisPlayer=0,WaitForRefuseAnswer=0,RefuseTeam,RefusePlayerName[12];
|
||||
fix RefuseTimeLimit=0;
|
||||
fix64 RefuseTimeLimit=0;
|
||||
|
||||
typedef struct netplayer_stats {
|
||||
ubyte message_type;
|
||||
|
|
|
@ -318,7 +318,7 @@ void change_playernum_to(int new_pnum);
|
|||
|
||||
// Globals for protocol-bound Refuse-functions
|
||||
extern char RefuseThisPlayer,WaitForRefuseAnswer,RefuseTeam,RefusePlayerName[12];
|
||||
extern fix RefuseTimeLimit;
|
||||
extern fix64 RefuseTimeLimit;
|
||||
#define REFUSE_INTERVAL (F1_0*8)
|
||||
|
||||
extern uint multi_allow_powerup;
|
||||
|
@ -359,7 +359,7 @@ typedef struct netplayer_info
|
|||
sbyte connected;
|
||||
ubyte rank;
|
||||
fix ping;
|
||||
fix LastPacketTime;
|
||||
fix64 LastPacketTime;
|
||||
} __pack__ netplayer_info;
|
||||
|
||||
/*
|
||||
|
|
|
@ -1109,7 +1109,7 @@ multi_drop_robot_powerups(int objnum)
|
|||
return;
|
||||
|
||||
else if (robptr->contains_count) {
|
||||
d_srand(timer_get_fixed_seconds());
|
||||
d_srand((fix)timer_query());
|
||||
if (((d_rand() * 16) >> 15) < robptr->contains_prob) {
|
||||
del_obj->contains_count = ((d_rand() * robptr->contains_count) >> 15) + 1;
|
||||
del_obj->contains_type = robptr->contains_type;
|
||||
|
|
133
main/net_ipx.c
133
main/net_ipx.c
|
@ -71,9 +71,6 @@ void net_ipx_read_object_packet( ubyte *data );
|
|||
void net_ipx_read_sync_packet( ubyte * sp );
|
||||
void net_ipx_flush();
|
||||
void net_ipx_listen();
|
||||
void net_ipx_ping_all(fix time);
|
||||
void net_ipx_ping(ubyte flag, int pnum);
|
||||
void net_ipx_handle_ping_return(ubyte pnum);
|
||||
void net_ipx_process_pdata(char *data);
|
||||
void net_ipx_more_game_options();
|
||||
void net_ipx_read_pdata_packet(IPX_frame_info *pd);
|
||||
|
@ -612,7 +609,7 @@ int net_ipx_endlevel_poll( newmenu *menu, d_event *event, int *secret )
|
|||
{
|
||||
// Polling loop for End-of-level menu
|
||||
|
||||
static fix t1 = 0;
|
||||
static fix64 t1 = 0;
|
||||
int i = 0;
|
||||
int num_ready = 0;
|
||||
int num_escaped = 0;
|
||||
|
@ -650,10 +647,10 @@ int net_ipx_endlevel_poll( newmenu *menu, d_event *event, int *secret )
|
|||
case EVENT_IDLE:
|
||||
// Send our endlevel packet at regular intervals
|
||||
|
||||
if (timer_get_fixed_seconds() > t1+ENDLEVEL_SEND_INTERVAL)
|
||||
if (timer_query() > t1+ENDLEVEL_SEND_INTERVAL)
|
||||
{
|
||||
net_ipx_send_endlevel_packet();
|
||||
t1 = timer_get_fixed_seconds();
|
||||
t1 = timer_query();
|
||||
}
|
||||
|
||||
for (i = 0; i < N_players; i++)
|
||||
|
@ -672,7 +669,7 @@ int net_ipx_endlevel_poll( newmenu *menu, d_event *event, int *secret )
|
|||
if (Players[i].connected == CONNECT_PLAYING)
|
||||
{
|
||||
// Check timeout for idle players
|
||||
if (timer_get_fixed_seconds() > Netgame.players[i].LastPacketTime+ENDLEVEL_IDLE_TIME)
|
||||
if (timer_query() > Netgame.players[i].LastPacketTime+ENDLEVEL_IDLE_TIME)
|
||||
{
|
||||
Players[i].connected = CONNECT_DISCONNECTED;
|
||||
net_ipx_send_endlevel_sub(i);
|
||||
|
@ -735,7 +732,7 @@ int net_ipx_endlevel_poll2( newmenu *menu, d_event *event, int *secret )
|
|||
{
|
||||
// Polling loop for End-of-level menu
|
||||
|
||||
static fix t1 = 0;
|
||||
static fix64 t1 = 0;
|
||||
int i = 0;
|
||||
int num_ready = 0;
|
||||
int goto_secret = 0;
|
||||
|
@ -747,10 +744,10 @@ int net_ipx_endlevel_poll2( newmenu *menu, d_event *event, int *secret )
|
|||
|
||||
// Send our endlevel packet at regular intervals
|
||||
|
||||
if (timer_get_fixed_seconds() > t1+ENDLEVEL_SEND_INTERVAL)
|
||||
if (timer_query() > t1+ENDLEVEL_SEND_INTERVAL)
|
||||
{
|
||||
net_ipx_send_endlevel_packet();
|
||||
t1 = timer_get_fixed_seconds();
|
||||
t1 = timer_query();
|
||||
}
|
||||
|
||||
net_ipx_listen();
|
||||
|
@ -778,7 +775,7 @@ int net_ipx_kmatrix_poll1( newmenu *menu, d_event *event, void *userdata )
|
|||
{
|
||||
// Polling loop for End-of-level menu
|
||||
|
||||
static fix t1 = 0;
|
||||
static fix64 t1 = 0;
|
||||
int i = 0;
|
||||
int num_ready = 0;
|
||||
int goto_secret = 0;
|
||||
|
@ -791,10 +788,10 @@ int net_ipx_kmatrix_poll1( newmenu *menu, d_event *event, void *userdata )
|
|||
|
||||
// Send our endlevel packet at regular intervals
|
||||
|
||||
if (timer_get_fixed_seconds() > t1+ENDLEVEL_SEND_INTERVAL)
|
||||
if (timer_query() > t1+ENDLEVEL_SEND_INTERVAL)
|
||||
{
|
||||
net_ipx_send_endlevel_packet();
|
||||
t1 = timer_get_fixed_seconds();
|
||||
t1 = timer_query();
|
||||
}
|
||||
|
||||
net_ipx_listen();
|
||||
|
@ -853,7 +850,7 @@ int net_ipx_endlevel(int *secret)
|
|||
m[i].type = NM_TYPE_TEXT;
|
||||
m[i].text = menu_text + i*80;
|
||||
sprintf(m[i].text, "%s %s", Players[i].callsign, CONNECT_STATES(Players[i].connected));
|
||||
Netgame.players[i].LastPacketTime = timer_get_fixed_seconds();
|
||||
Netgame.players[i].LastPacketTime = timer_query();
|
||||
}
|
||||
m[N_players].type = NM_TYPE_TEXT;
|
||||
m[N_players].text = menu_text + N_players*80;
|
||||
|
@ -1081,7 +1078,7 @@ void net_ipx_welcome_player(IPX_sequence_packet *their)
|
|||
// disconnected and replace the oldest player with this new one
|
||||
|
||||
int oldest_player = -1;
|
||||
fix oldest_time = timer_get_fixed_seconds();
|
||||
fix64 oldest_time = timer_query();
|
||||
int activeplayers = 0;
|
||||
|
||||
Assert(N_players == MaxNumNetPlayers);
|
||||
|
@ -1563,7 +1560,7 @@ void net_ipx_send_rejoin_sync(int player_num)
|
|||
int i, j;
|
||||
|
||||
Players[player_num].connected = CONNECT_PLAYING; // connect the new guy
|
||||
Netgame.players[player_num].LastPacketTime = timer_get_fixed_seconds();
|
||||
Netgame.players[player_num].LastPacketTime = timer_query();
|
||||
|
||||
if (Endlevel_sequence || Control_center_destroyed)
|
||||
{
|
||||
|
@ -1645,7 +1642,7 @@ void net_ipx_add_player(IPX_sequence_packet *p)
|
|||
memcpy( Netgame.players[N_players].protocol.ipx.server, p->player.protocol.ipx.server, 4 );
|
||||
Netgame.players[N_players].connected = CONNECT_PLAYING;
|
||||
Players[N_players].connected = CONNECT_PLAYING;
|
||||
Netgame.players[N_players].LastPacketTime = timer_get_fixed_seconds();
|
||||
Netgame.players[N_players].LastPacketTime = timer_query();
|
||||
N_players++;
|
||||
Netgame.numplayers = N_players;
|
||||
|
||||
|
@ -2005,12 +2002,6 @@ void net_ipx_process_packet(ubyte *data, int length )
|
|||
if ((Network_status == NETSTAT_ENDLEVEL) || (Network_status == NETSTAT_PLAYING))
|
||||
net_ipx_read_endlevel_packet(data);
|
||||
break;
|
||||
case PID_PING_SEND:
|
||||
net_ipx_ping (PID_PING_RETURN,data[1]);
|
||||
break;
|
||||
case PID_PING_RETURN:
|
||||
net_ipx_handle_ping_return(data[1]); // data[1] is player who told us of their ping time
|
||||
break;
|
||||
default:
|
||||
Int3(); // Invalid network packet type, see ROB
|
||||
}
|
||||
|
@ -2060,7 +2051,7 @@ net_ipx_read_endlevel_packet( ubyte *data )
|
|||
if ((Players[playernum].connected == CONNECT_PLAYING) && (end->seconds_left < Countdown_seconds_left))
|
||||
Countdown_seconds_left = end->seconds_left;
|
||||
|
||||
Netgame.players[playernum].LastPacketTime = timer_get_fixed_seconds();
|
||||
Netgame.players[playernum].LastPacketTime = timer_query();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2203,7 +2194,7 @@ net_ipx_read_object_packet( ubyte *data )
|
|||
*/
|
||||
int net_ipx_sync_poll( newmenu *menu, d_event *event, void *userdata )
|
||||
{
|
||||
static fix t1 = 0;
|
||||
static fix64 t1 = 0;
|
||||
int rval = 0;
|
||||
|
||||
menu = menu;
|
||||
|
@ -2217,13 +2208,13 @@ int net_ipx_sync_poll( newmenu *menu, d_event *event, void *userdata )
|
|||
if (Network_status != NETSTAT_WAITING) // Status changed to playing, exit the menu
|
||||
rval = -2;
|
||||
|
||||
if (Network_status != NETSTAT_MENU && !Network_rejoined && (timer_get_fixed_seconds() > t1+F1_0*2))
|
||||
if (Network_status != NETSTAT_MENU && !Network_rejoined && (timer_query() > t1+F1_0*2))
|
||||
{
|
||||
int i;
|
||||
|
||||
// Poll time expired, re-send request
|
||||
|
||||
t1 = timer_get_fixed_seconds();
|
||||
t1 = timer_query();
|
||||
|
||||
i = net_ipx_send_request();
|
||||
if (i < 0)
|
||||
|
@ -2589,7 +2580,7 @@ net_ipx_find_game(void)
|
|||
{
|
||||
// Find out whether or not there is space left on this socket
|
||||
|
||||
fix t1;
|
||||
fix64 t1;
|
||||
|
||||
Network_status = NETSTAT_BROWSING;
|
||||
|
||||
|
@ -2598,10 +2589,13 @@ net_ipx_find_game(void)
|
|||
show_boxed_message(TXT_WAIT, 0);
|
||||
|
||||
net_ipx_send_game_list_request();
|
||||
t1 = timer_get_fixed_seconds() + F1_0*2;
|
||||
t1 = timer_query() + F1_0*2;
|
||||
|
||||
while (timer_get_fixed_seconds() < t1) // Wait 3 seconds for replies
|
||||
while (timer_query() < t1) // Wait 3 seconds for replies
|
||||
{
|
||||
timer_update();
|
||||
net_ipx_listen();
|
||||
}
|
||||
|
||||
if (num_active_ipx_games < IPX_MAX_NETGAMES)
|
||||
return 0;
|
||||
|
@ -2763,7 +2757,7 @@ net_ipx_send_sync(void)
|
|||
}
|
||||
|
||||
//added/changed on 9/13/98 by adb to remove TICKER
|
||||
d_srand( timer_get_fixed_seconds() );
|
||||
d_srand( (fix)timer_query() );
|
||||
//end change - adb
|
||||
|
||||
for (i=0; i<MaxNumNetPlayers; i++ )
|
||||
|
@ -3063,12 +3057,12 @@ void restart_net_searching(newmenu_item * m)
|
|||
void net_ipx_join_listen(newmenu *menu)
|
||||
{
|
||||
newmenu_item *menus = newmenu_get_items(menu);
|
||||
static fix t1 = 0;
|
||||
static fix64 t1 = 0;
|
||||
int i,join_status,temp;
|
||||
|
||||
// send a request for game info every 3 seconds
|
||||
if (timer_get_fixed_seconds() > t1+F1_0*3) {
|
||||
t1 = timer_get_fixed_seconds();
|
||||
if (timer_query() > t1+F1_0*3) {
|
||||
t1 = timer_query();
|
||||
net_ipx_send_game_list_request();
|
||||
}
|
||||
|
||||
|
@ -3320,14 +3314,6 @@ int net_ipx_request_poll( newmenu *menu, d_event *event, void *userdata )
|
|||
menu = menu;
|
||||
userdata = userdata;
|
||||
|
||||
// Send our endlevel packet at regular intervals
|
||||
|
||||
// if (timer_get_fixed_seconds() > t1+ENDLEVEL_SEND_INTERVAL)
|
||||
// {
|
||||
// net_ipx_send_endlevel_packet();
|
||||
// t1 = timer_get_fixed_seconds();
|
||||
// }
|
||||
|
||||
net_ipx_listen();
|
||||
|
||||
for (i = 0; i < N_players; i++)
|
||||
|
@ -3637,12 +3623,10 @@ void net_ipx_do_frame(int force, int listen)
|
|||
|
||||
if (!(Game_mode&GM_NETWORK)) return;
|
||||
|
||||
net_ipx_ping_all(timer_get_fixed_seconds());
|
||||
|
||||
if ((Network_status != NETSTAT_PLAYING) || (Endlevel_sequence)) // Don't send postion during escape sequence...
|
||||
goto listen;
|
||||
|
||||
if (WaitForRefuseAnswer && timer_get_fixed_seconds()>(RefuseTimeLimit+(F1_0*12)))
|
||||
if (WaitForRefuseAnswer && timer_query()>(RefuseTimeLimit+(F1_0*12)))
|
||||
WaitForRefuseAnswer=0;
|
||||
|
||||
last_send_time += FrameTime;
|
||||
|
@ -3700,18 +3684,17 @@ void net_ipx_do_frame(int force, int listen)
|
|||
|
||||
if ((last_timeout_check > F1_0) && !(Control_center_destroyed))
|
||||
{
|
||||
fix approx_time = timer_get_fixed_seconds();
|
||||
// Check for player timeouts
|
||||
for (i = 0; i < N_players; i++)
|
||||
{
|
||||
if ((i != Player_num) && (Players[i].connected == CONNECT_PLAYING))
|
||||
{
|
||||
if ((Netgame.players[i].LastPacketTime == 0) || (Netgame.players[i].LastPacketTime > approx_time))
|
||||
if ((Netgame.players[i].LastPacketTime == 0) || (Netgame.players[i].LastPacketTime > timer_query()))
|
||||
{
|
||||
Netgame.players[i].LastPacketTime = approx_time;
|
||||
Netgame.players[i].LastPacketTime = timer_query();
|
||||
continue;
|
||||
}
|
||||
if ((approx_time - Netgame.players[i].LastPacketTime) > IPX_TIMEOUT)
|
||||
if ((timer_query() - Netgame.players[i].LastPacketTime) > IPX_TIMEOUT)
|
||||
net_ipx_timeout_player(i);
|
||||
}
|
||||
|
||||
|
@ -3793,7 +3776,7 @@ void net_ipx_read_pdata_packet(IPX_frame_info *pd)
|
|||
|
||||
//------------- Keep track of missed packets -----------------
|
||||
Players[TheirPlayernum].n_packets_got++;
|
||||
Netgame.players[TheirPlayernum].LastPacketTime = timer_get_fixed_seconds();
|
||||
Netgame.players[TheirPlayernum].LastPacketTime = timer_query();
|
||||
if ( pd->numpackets != Players[TheirPlayernum].n_packets_got ) {
|
||||
Players[TheirPlayernum].n_packets_got = pd->numpackets;
|
||||
}
|
||||
|
@ -3900,52 +3883,6 @@ int net_ipx_more_options_handler( newmenu *menu, d_event *event, void *userdata
|
|||
return 0;
|
||||
}
|
||||
|
||||
void net_ipx_ping (ubyte flag,int pnum)
|
||||
{
|
||||
ubyte mybuf[2];
|
||||
|
||||
mybuf[0]=flag;
|
||||
mybuf[1]=Player_num;
|
||||
*(u_int32_t*)(multibuf+2)=INTEL_INT(GameTime);
|
||||
ipxdrv_send_packet_data( (ubyte *)mybuf, 7, Netgame.players[pnum].protocol.ipx.server, Netgame.players[pnum].protocol.ipx.node,Players[pnum].net_address );
|
||||
}
|
||||
|
||||
static fix PingLaunchTime[MAX_PLAYERS],PingReturnTime[MAX_PLAYERS];
|
||||
|
||||
void net_ipx_handle_ping_return (ubyte pnum)
|
||||
{
|
||||
if (PingLaunchTime[pnum]==0 || pnum>=N_players)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PingReturnTime[pnum]=GameTime;
|
||||
Netgame.players[pnum].ping=f2i(fixmul(PingReturnTime[pnum]-PingLaunchTime[pnum],i2f(1000)));
|
||||
PingLaunchTime[pnum]=0;
|
||||
}
|
||||
|
||||
// ping all connected players (except yourself) in 3sec interval and update ping_table
|
||||
void net_ipx_ping_all(fix time)
|
||||
{
|
||||
int i;
|
||||
static fix PingTime=0;
|
||||
|
||||
Netgame.players[Player_num].ping = -1; // Set mine to fancy -1 because I am super fast! Weeee
|
||||
|
||||
if (PingTime+(F1_0*3)<time || PingTime > time)
|
||||
{
|
||||
for (i=0; i<MAX_PLAYERS; i++)
|
||||
{
|
||||
if (Players[i].connected && i != Player_num)
|
||||
{
|
||||
PingLaunchTime[i]=time;
|
||||
net_ipx_ping (PID_PING_SEND,i);
|
||||
}
|
||||
}
|
||||
PingTime=time;
|
||||
}
|
||||
}
|
||||
|
||||
void net_ipx_do_refuse_stuff (IPX_sequence_packet *their)
|
||||
{
|
||||
int i;
|
||||
|
@ -3975,7 +3912,7 @@ void net_ipx_do_refuse_stuff (IPX_sequence_packet *their)
|
|||
HUD_init_message(HM_MULTI, "%s wants to join (accept: F6)",their->player.callsign);
|
||||
|
||||
strcpy (RefusePlayerName,their->player.callsign);
|
||||
RefuseTimeLimit=timer_get_fixed_seconds();
|
||||
RefuseTimeLimit=timer_query();
|
||||
RefuseThisPlayer=0;
|
||||
WaitForRefuseAnswer=1;
|
||||
}
|
||||
|
@ -4002,7 +3939,7 @@ void net_ipx_do_refuse_stuff (IPX_sequence_packet *their)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((timer_get_fixed_seconds()) > RefuseTimeLimit+REFUSE_INTERVAL)
|
||||
if ((timer_query()) > RefuseTimeLimit+REFUSE_INTERVAL)
|
||||
{
|
||||
RefuseTimeLimit=0;
|
||||
RefuseThisPlayer=0;
|
||||
|
|
|
@ -46,9 +46,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#define PID_GAME_LIST 36
|
||||
#define PID_GAME_INFO 37
|
||||
|
||||
#define PID_PING_SEND 73
|
||||
#define PID_PING_RETURN 74
|
||||
|
||||
typedef struct IPX_endlevel_info {
|
||||
ubyte type;
|
||||
ubyte player_num;
|
||||
|
|
144
main/net_udp.c
144
main/net_udp.c
|
@ -66,24 +66,24 @@ void net_udp_send_netgame_update();
|
|||
void net_udp_do_refuse_stuff (UDP_sequence_packet *their);
|
||||
void net_udp_read_sync_packet( ubyte * data, int data_len, struct _sockaddr sender_addr );
|
||||
void net_udp_read_object_packet( ubyte *data );
|
||||
void net_udp_ping_frame(fix time);
|
||||
void net_udp_ping_frame(fix64 time);
|
||||
void net_udp_process_ping(ubyte *data, int data_len, struct _sockaddr sender_addr);
|
||||
void net_udp_process_pong(ubyte *data, int data_len, struct _sockaddr sender_addr);
|
||||
void net_udp_read_endlevel_packet( ubyte *data, int data_len, struct _sockaddr sender_addr );
|
||||
void net_udp_send_mdata(int priority, fix time);
|
||||
void net_udp_send_mdata(int priority, fix64 time);
|
||||
void net_udp_process_mdata (ubyte *data, int data_len, struct _sockaddr sender_addr, int priority);
|
||||
void net_udp_send_pdata();
|
||||
void net_udp_process_pdata ( ubyte *data, int data_len, struct _sockaddr sender_addr );
|
||||
void net_udp_read_pdata_short_packet(UDP_frame_info *pd);
|
||||
void net_udp_timeout_check(fix time);
|
||||
void net_udp_timeout_check(fix64 time);
|
||||
void net_udp_timeout_player(int playernum);
|
||||
int net_udp_get_new_player_num (UDP_sequence_packet *their);
|
||||
void net_udp_noloss_add_queue_pkt(uint32_t pkt_num, fix time, ubyte *data, ushort data_size, ubyte pnum, ubyte player_ack[MAX_PLAYERS]);
|
||||
void net_udp_noloss_add_queue_pkt(uint32_t pkt_num, fix64 time, ubyte *data, ushort data_size, ubyte pnum, ubyte player_ack[MAX_PLAYERS]);
|
||||
int net_udp_noloss_validate_mdata(uint32_t pkt_num, ubyte sender_pnum, struct _sockaddr sender_addr);
|
||||
void net_udp_noloss_got_ack(ubyte *data, int data_len);
|
||||
void net_udp_noloss_init_mdata_queue(void);
|
||||
void net_udp_noloss_clear_mdata_got(ubyte player_num);
|
||||
void net_udp_noloss_process_queue(fix time);
|
||||
void net_udp_noloss_process_queue(fix64 time);
|
||||
extern void game_disable_cheats();
|
||||
|
||||
// Variables
|
||||
|
@ -314,7 +314,7 @@ typedef struct direct_join
|
|||
{
|
||||
struct _sockaddr host_addr;
|
||||
int connecting;
|
||||
fix start_time, last_time;
|
||||
fix64 start_time, last_time;
|
||||
char addrbuf[128];
|
||||
char portbuf[6];
|
||||
} direct_join;
|
||||
|
@ -322,14 +322,10 @@ typedef struct direct_join
|
|||
// Connect to a game host and get full info. Eventually we join!
|
||||
int net_udp_game_connect(direct_join *dj)
|
||||
{
|
||||
fix time = 0;
|
||||
|
||||
// Get full game info so we can show it.
|
||||
|
||||
time = timer_get_fixed_seconds();
|
||||
|
||||
// Timeout after 10 seconds
|
||||
if (timer_get_fixed_seconds() >= dj->start_time + (F1_0*10) || timer_get_fixed_seconds() < dj->start_time)
|
||||
if (timer_query() >= dj->start_time + (F1_0*10))
|
||||
{
|
||||
nm_messagebox(TXT_ERROR,1,TXT_OK,"No response by host.\n\nPossible reasons:\n* No game on this IP (anymore)\n* Port of Host not open\n or different\n* Host uses a game version\n I do not understand");
|
||||
dj->connecting = 0;
|
||||
|
@ -343,10 +339,10 @@ int net_udp_game_connect(direct_join *dj)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (time >= dj->last_time + F1_0)
|
||||
if (timer_query() >= dj->last_time + F1_0)
|
||||
{
|
||||
net_udp_request_game_info(dj->host_addr, 0);
|
||||
dj->last_time = time;
|
||||
dj->last_time = timer_query();
|
||||
}
|
||||
timer_delay2(5);
|
||||
net_udp_listen();
|
||||
|
@ -366,7 +362,7 @@ int net_udp_game_connect(direct_join *dj)
|
|||
// Get full game info again as it could have changed since we entered the info menu.
|
||||
dj->connecting = 2;
|
||||
Netgame.protocol.udp.valid = 0;
|
||||
dj->start_time = timer_get_fixed_seconds();
|
||||
dj->start_time = timer_query();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -432,7 +428,7 @@ static int manual_join_game_handler(newmenu *menu, d_event *event, direct_join *
|
|||
{
|
||||
N_players = 0;
|
||||
change_playernum_to(1);
|
||||
dj->start_time = timer_get_fixed_seconds();
|
||||
dj->start_time = timer_query();
|
||||
dj->last_time = 0;
|
||||
|
||||
memcpy((struct _sockaddr *)&Netgame.players[0].protocol.udp.addr, (struct _sockaddr *)&dj->host_addr, sizeof(struct _sockaddr));
|
||||
|
@ -570,7 +566,7 @@ int net_udp_list_join_poll( newmenu *menu, d_event *event, direct_join *dj )
|
|||
{
|
||||
N_players = 0;
|
||||
change_playernum_to(1);
|
||||
dj->start_time = timer_get_fixed_seconds();
|
||||
dj->start_time = timer_query();
|
||||
dj->last_time = 0;
|
||||
memcpy((struct _sockaddr *)&dj->host_addr, (struct _sockaddr *)&Active_udp_games[(citem+(NLPage*UDP_NETGAMES_PPAGE))-2].game_addr, sizeof(struct _sockaddr));
|
||||
memcpy((struct _sockaddr *)&Netgame.players[0].protocol.udp.addr, (struct _sockaddr *)&dj->host_addr, sizeof(struct _sockaddr));
|
||||
|
@ -854,7 +850,7 @@ int net_udp_kmatrix_poll1( newmenu *menu, d_event *event, void *userdata )
|
|||
}
|
||||
|
||||
// Same as above but used when player pressed ESC during kmatrix (host also does the packets for playing clients)
|
||||
extern fix StartAbortMenuTime;
|
||||
extern fix64 StartAbortMenuTime;
|
||||
int net_udp_kmatrix_poll2( newmenu *menu, d_event *event, void *userdata )
|
||||
{
|
||||
int rval = 0;
|
||||
|
@ -866,7 +862,7 @@ int net_udp_kmatrix_poll2( newmenu *menu, d_event *event, void *userdata )
|
|||
menu = menu;
|
||||
userdata = userdata;
|
||||
|
||||
if (timer_get_fixed_seconds() > (StartAbortMenuTime+(F1_0*3)))
|
||||
if (timer_query() > (StartAbortMenuTime+(F1_0*3)))
|
||||
rval = -2;
|
||||
|
||||
net_udp_do_frame(0, 1);
|
||||
|
@ -896,7 +892,7 @@ int net_udp_endlevel(int *secret)
|
|||
|
||||
for (i=0; i<N_players; i++)
|
||||
{
|
||||
Netgame.players[i].LastPacketTime = timer_get_fixed_seconds();
|
||||
Netgame.players[i].LastPacketTime = timer_query();
|
||||
}
|
||||
|
||||
net_udp_send_endlevel_packet();
|
||||
|
@ -1106,7 +1102,7 @@ void net_udp_welcome_player(UDP_sequence_packet *their)
|
|||
// disconnected and replace the oldest player with this new one
|
||||
|
||||
int oldest_player = -1;
|
||||
fix oldest_time = timer_get_fixed_seconds();
|
||||
fix64 oldest_time = timer_query();
|
||||
int activeplayers = 0;
|
||||
|
||||
Assert(N_players == MaxNumNetPlayers);
|
||||
|
@ -1172,7 +1168,7 @@ void net_udp_welcome_player(UDP_sequence_packet *their)
|
|||
UDP_sync_player.player.connected = player_num;
|
||||
Network_send_objects = 1;
|
||||
Network_send_objnum = -1;
|
||||
Netgame.players[player_num].LastPacketTime = timer_get_fixed_seconds();
|
||||
Netgame.players[player_num].LastPacketTime = timer_query();
|
||||
|
||||
net_udp_send_objects();
|
||||
}
|
||||
|
@ -1587,7 +1583,7 @@ void net_udp_send_rejoin_sync(int player_num)
|
|||
int i, j;
|
||||
|
||||
Players[player_num].connected = CONNECT_PLAYING; // connect the new guy
|
||||
Netgame.players[player_num].LastPacketTime = timer_get_fixed_seconds();
|
||||
Netgame.players[player_num].LastPacketTime = timer_query();
|
||||
|
||||
if (Endlevel_sequence || Control_center_destroyed)
|
||||
{
|
||||
|
@ -1649,13 +1645,12 @@ char * net_udp_get_player_name( int objnum )
|
|||
void net_udp_add_player(UDP_sequence_packet *p)
|
||||
{
|
||||
int i;
|
||||
fix time = timer_get_fixed_seconds();
|
||||
|
||||
for (i=0; i<N_players; i++ )
|
||||
{
|
||||
if ( !memcmp( (struct _sockaddr *)&Netgame.players[i].protocol.udp.addr, (struct _sockaddr *)&p->player.protocol.udp.addr, sizeof(struct _sockaddr)))
|
||||
{
|
||||
Netgame.players[i].LastPacketTime = time;
|
||||
Netgame.players[i].LastPacketTime = timer_query();
|
||||
return; // already got them
|
||||
}
|
||||
}
|
||||
|
@ -1672,7 +1667,7 @@ void net_udp_add_player(UDP_sequence_packet *p)
|
|||
Netgame.players[N_players].rank=p->player.rank;
|
||||
Netgame.players[N_players].connected = CONNECT_PLAYING;
|
||||
Players[N_players].connected = CONNECT_PLAYING;
|
||||
Netgame.players[N_players].LastPacketTime = time;
|
||||
Netgame.players[N_players].LastPacketTime = timer_query();
|
||||
N_players++;
|
||||
Netgame.numplayers = N_players;
|
||||
|
||||
|
@ -2221,7 +2216,7 @@ void net_udp_process_request(UDP_sequence_packet *their)
|
|||
if (!memcmp((struct _sockaddr *)&their->player.protocol.udp.addr, (struct _sockaddr *)&Netgame.players[i].protocol.udp.addr, sizeof(struct _sockaddr)) && (!strcasecmp(their->player.callsign, Netgame.players[i].callsign)))
|
||||
{
|
||||
Players[i].connected = CONNECT_PLAYING;
|
||||
Netgame.players[i].LastPacketTime = timer_get_fixed_seconds();
|
||||
Netgame.players[i].LastPacketTime = timer_query();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2346,7 +2341,6 @@ void net_udp_read_endlevel_packet( ubyte *data, int data_len, struct _sockaddr s
|
|||
{
|
||||
int len = 0, i = 0, j = 0;
|
||||
ubyte tmpvar = 0;
|
||||
fix time = timer_get_fixed_seconds();
|
||||
|
||||
if (multi_i_am_master())
|
||||
{
|
||||
|
@ -2369,7 +2363,7 @@ void net_udp_read_endlevel_packet( ubyte *data, int data_len, struct _sockaddr s
|
|||
kill_matrix[pnum][i] = GET_INTEL_SHORT(&(data[len])); len += 2;
|
||||
}
|
||||
|
||||
Netgame.players[pnum].LastPacketTime = time;
|
||||
Netgame.players[pnum].LastPacketTime = timer_query();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2395,7 +2389,7 @@ void net_udp_read_endlevel_packet( ubyte *data, int data_len, struct _sockaddr s
|
|||
Players[i].net_killed_total = GET_INTEL_SHORT(&(data[len])); len += 2;
|
||||
|
||||
if (Players[i].connected)
|
||||
Netgame.players[i].LastPacketTime = time;
|
||||
Netgame.players[i].LastPacketTime = timer_query();
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_PLAYERS; i++)
|
||||
|
@ -2552,7 +2546,7 @@ net_udp_read_object_packet( ubyte *data )
|
|||
*/
|
||||
int net_udp_sync_poll( newmenu *menu, d_event *event, void *userdata )
|
||||
{
|
||||
static fix t1 = 0;
|
||||
static fix64 t1 = 0;
|
||||
int rval = 0;
|
||||
|
||||
if (event->type != EVENT_IDLE)
|
||||
|
@ -2570,13 +2564,13 @@ int net_udp_sync_poll( newmenu *menu, d_event *event, void *userdata )
|
|||
if (Network_status != NETSTAT_WAITING) // Status changed to playing, exit the menu
|
||||
rval = -2;
|
||||
|
||||
if (Network_status != NETSTAT_MENU && !Network_rejoined && (timer_get_fixed_seconds() > t1+F1_0*2))
|
||||
if (Network_status != NETSTAT_MENU && !Network_rejoined && (timer_query() > t1+F1_0*2))
|
||||
{
|
||||
int i;
|
||||
|
||||
// Poll time expired, re-send request
|
||||
|
||||
t1 = timer_get_fixed_seconds();
|
||||
t1 = timer_query();
|
||||
|
||||
i = net_udp_send_request();
|
||||
if (i < 0)
|
||||
|
@ -3171,7 +3165,7 @@ int net_udp_send_sync(void)
|
|||
}
|
||||
|
||||
// Randomize their starting locations...
|
||||
d_srand( timer_get_fixed_seconds() );
|
||||
d_srand( (fix)timer_query() );
|
||||
for (i=0; i<NumNetPlayerPositions; i++ )
|
||||
{
|
||||
if (Players[i].connected)
|
||||
|
@ -3505,16 +3499,8 @@ int net_udp_request_poll( newmenu *menu, d_event *event, void *userdata )
|
|||
menu = menu;
|
||||
userdata = userdata;
|
||||
|
||||
// Send our endlevel packet at regular intervals
|
||||
|
||||
// if (timer_get_fixed_seconds() > t1+ENDLEVEL_SEND_INTERVAL)
|
||||
// {
|
||||
// net_udp_send_endlevel_packet();
|
||||
// t1 = timer_get_fixed_seconds();
|
||||
// }
|
||||
|
||||
net_udp_listen();
|
||||
net_udp_timeout_check(timer_get_fixed_seconds());
|
||||
net_udp_timeout_check(timer_query());
|
||||
|
||||
for (i = 0; i < N_players; i++)
|
||||
{
|
||||
|
@ -3733,12 +3719,12 @@ void net_udp_send_data( ubyte * ptr, int len, int priority )
|
|||
UDP_MData.mbuf_size += len;
|
||||
}
|
||||
|
||||
void net_udp_timeout_check(fix time)
|
||||
void net_udp_timeout_check(fix64 time)
|
||||
{
|
||||
int i = 0;
|
||||
static fix last_timeout_time = 0;
|
||||
static fix64 last_timeout_time = 0;
|
||||
|
||||
if ((time>=last_timeout_time+F1_0) || (time < last_timeout_time))
|
||||
if (time>=last_timeout_time+F1_0)
|
||||
{
|
||||
// Check for player timeouts
|
||||
for (i = 0; i < N_players; i++)
|
||||
|
@ -3795,13 +3781,13 @@ void net_udp_timeout_player(int playernum)
|
|||
void net_udp_do_frame(int force, int listen)
|
||||
{
|
||||
int send_mdata = (Network_laser_fired || force || PacketUrgent);
|
||||
fix time = 0;
|
||||
static fix last_send_time = 0, last_endlevel_time = 0, last_bcast_time = 0;
|
||||
fix64 time = 0;
|
||||
static fix64 last_send_time = 0, last_endlevel_time = 0, last_bcast_time = 0;
|
||||
|
||||
if (!(Game_mode&GM_NETWORK))
|
||||
return;
|
||||
|
||||
time = timer_get_fixed_seconds();
|
||||
time = timer_query();
|
||||
|
||||
net_udp_ping_frame(time);
|
||||
|
||||
|
@ -3809,7 +3795,7 @@ void net_udp_do_frame(int force, int listen)
|
|||
WaitForRefuseAnswer=0;
|
||||
|
||||
// Send player position packet (and endlevel if needed)
|
||||
if ((time >= (last_send_time+(F1_0/Netgame.PacketsPerSec))) || (time < last_send_time))
|
||||
if (time >= (last_send_time+(F1_0/Netgame.PacketsPerSec)))
|
||||
{
|
||||
multi_send_robot_frame(0);
|
||||
multi_send_fire(); // Do firing if needed..
|
||||
|
@ -3826,14 +3812,14 @@ void net_udp_do_frame(int force, int listen)
|
|||
|
||||
net_udp_noloss_process_queue(time);
|
||||
|
||||
if (((time>=last_endlevel_time+F1_0) || (time < last_endlevel_time)) && Control_center_destroyed)
|
||||
if ((time>=last_endlevel_time+F1_0) && Control_center_destroyed)
|
||||
{
|
||||
last_endlevel_time = time;
|
||||
net_udp_send_endlevel_packet();
|
||||
}
|
||||
|
||||
// broadcast lite_info every 10 seconds
|
||||
if (multi_i_am_master() && (time>=last_bcast_time+(F1_0*10) || (time < last_bcast_time)))
|
||||
if (multi_i_am_master() && time>=last_bcast_time+(F1_0*10))
|
||||
{
|
||||
last_bcast_time = time;
|
||||
net_udp_send_game_info(GBcast, UPID_GAME_INFO_LITE);
|
||||
|
@ -3855,7 +3841,7 @@ void net_udp_do_frame(int force, int listen)
|
|||
* Adds a packet to our queue. Should be called when an IMPORTANT mdata packet is created.
|
||||
* player_ack is an array which should contain 0 for each player that needs to send an ACK signal.
|
||||
*/
|
||||
void net_udp_noloss_add_queue_pkt(uint32_t pkt_num, fix time, ubyte *data, ushort data_size, ubyte pnum, ubyte player_ack[MAX_PLAYERS])
|
||||
void net_udp_noloss_add_queue_pkt(uint32_t pkt_num, fix64 time, ubyte *data, ushort data_size, ubyte pnum, ubyte player_ack[MAX_PLAYERS])
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -3973,7 +3959,7 @@ void net_udp_noloss_clear_mdata_got(ubyte player_num)
|
|||
* The main queue-process function.
|
||||
* Check if we can remove a packet from queue, and check if there are packets in queue which we need to re-send
|
||||
*/
|
||||
void net_udp_noloss_process_queue(fix time)
|
||||
void net_udp_noloss_process_queue(fix64 time)
|
||||
{
|
||||
int queuec = 0, plc = 0, count = 0;
|
||||
|
||||
|
@ -4004,7 +3990,7 @@ void net_udp_noloss_process_queue(fix time)
|
|||
resend_delay = (F1_0/2);
|
||||
|
||||
// Resend if enough time has passed.
|
||||
if ((UDP_mdata_queue[queuec].pkt_timestamp[plc] + resend_delay <= time) || (time < UDP_mdata_queue[queuec].pkt_timestamp[plc]))
|
||||
if (UDP_mdata_queue[queuec].pkt_timestamp[plc] + resend_delay <= time)
|
||||
{
|
||||
ubyte buf[sizeof(UDP_mdata_info)];
|
||||
int len = 0;
|
||||
|
@ -4027,7 +4013,7 @@ void net_udp_noloss_process_queue(fix time)
|
|||
}
|
||||
|
||||
// Check if we can remove that packet due to to it had no resend's or Timeout
|
||||
if (!resend || ((UDP_mdata_queue[queuec].pkt_initial_timestamp + UDP_TIMEOUT <= time) || (time < UDP_mdata_queue[queuec].pkt_initial_timestamp)))
|
||||
if (!resend || UDP_mdata_queue[queuec].pkt_initial_timestamp + UDP_TIMEOUT <= time)
|
||||
{
|
||||
con_printf(CON_VERBOSE, "P#%i: Removing stored pkt_num %i - All ACK: %i\n",Player_num, UDP_mdata_queue[queuec].pkt_num, !resend);
|
||||
memset(&UDP_mdata_queue[queuec],0,sizeof(UDP_mdata_store));
|
||||
|
@ -4043,7 +4029,7 @@ void net_udp_noloss_process_queue(fix time)
|
|||
}
|
||||
/* CODE FOR PACKET LOSS PREVENTION - END */
|
||||
|
||||
void net_udp_send_mdata(int priority, fix time)
|
||||
void net_udp_send_mdata(int priority, fix64 time)
|
||||
{
|
||||
ubyte buf[sizeof(UDP_mdata_info)];
|
||||
ubyte pack[MAX_PLAYERS];
|
||||
|
@ -4151,7 +4137,7 @@ void net_udp_process_mdata (ubyte *data, int data_len, struct _sockaddr sender_a
|
|||
|
||||
if (priority && N_players > 2)
|
||||
{
|
||||
net_udp_noloss_add_queue_pkt(GET_INTEL_SHORT(&data[2]), timer_get_fixed_seconds(), data+dataoffset, data_len-dataoffset, pnum, pack);
|
||||
net_udp_noloss_add_queue_pkt(GET_INTEL_SHORT(&data[2]), timer_query(), data+dataoffset, data_len-dataoffset, pnum, pack);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4287,8 +4273,6 @@ void net_udp_process_pdata ( ubyte *data, int data_len, struct _sockaddr sender_
|
|||
}
|
||||
else
|
||||
{
|
||||
fix time = timer_get_fixed_seconds();
|
||||
|
||||
if (data_len > (sizeof(UDP_frame_info)*(MAX_PLAYERS-1)))
|
||||
return;
|
||||
|
||||
|
@ -4308,8 +4292,8 @@ void net_udp_process_pdata ( ubyte *data, int data_len, struct _sockaddr sender_
|
|||
{
|
||||
if (pd.connected == CONNECT_DISCONNECTED)
|
||||
{
|
||||
Netgame.players[i].LastPacketTime = time - UDP_TIMEOUT;
|
||||
net_udp_timeout_check(time);
|
||||
Netgame.players[i].LastPacketTime = timer_query() - UDP_TIMEOUT;
|
||||
net_udp_timeout_check(timer_query());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -4352,7 +4336,7 @@ void net_udp_read_pdata_short_packet(UDP_frame_info *pd)
|
|||
}
|
||||
|
||||
TheirObj = &Objects[TheirObjnum];
|
||||
Netgame.players[TheirPlayernum].LastPacketTime = timer_get_fixed_seconds();
|
||||
Netgame.players[TheirPlayernum].LastPacketTime = timer_query();
|
||||
|
||||
//------------ Read the player's ship's object info ----------------------
|
||||
|
||||
|
@ -4379,21 +4363,21 @@ void net_udp_read_pdata_short_packet(UDP_frame_info *pd)
|
|||
}
|
||||
|
||||
// Send the ping list in regular intervals
|
||||
void net_udp_ping_frame(fix time)
|
||||
void net_udp_ping_frame(fix64 time)
|
||||
{
|
||||
static fix PingTime = 0;
|
||||
static fix64 PingTime = 0;
|
||||
|
||||
if (!multi_i_am_master())
|
||||
return;
|
||||
|
||||
if (((PingTime + F1_0) < time) || (PingTime > time))
|
||||
if ((PingTime + F1_0) < time)
|
||||
{
|
||||
ubyte buf[UPKT_PING_SIZE];
|
||||
int len = 0, i = 0;
|
||||
|
||||
memset(&buf, 0, sizeof(ubyte)*UPKT_PING_SIZE);
|
||||
buf[len] = UPID_PING; len++;
|
||||
PUT_INTEL_INT(buf + len, time); len += 4;
|
||||
buf[len] = UPID_PING; len++;
|
||||
memcpy(&buf[len], &time, 8); len += 8;
|
||||
for (i = 1; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
PUT_INTEL_INT(buf + len, Netgame.players[i].ping); len += 4;
|
||||
|
@ -4412,7 +4396,7 @@ void net_udp_ping_frame(fix time)
|
|||
// Got a PING from host. Apply the pings to our players and respond to host.
|
||||
void net_udp_process_ping(ubyte *data, int data_len, struct _sockaddr sender_addr)
|
||||
{
|
||||
fix host_ping_time = 0;
|
||||
fix64 host_ping_time = 0;
|
||||
ubyte buf[UPKT_PONG_SIZE];
|
||||
int i, len = 0;
|
||||
|
||||
|
@ -4422,8 +4406,8 @@ void net_udp_process_ping(ubyte *data, int data_len, struct _sockaddr sender_add
|
|||
if (memcmp((struct _sockaddr *)&sender_addr, (struct _sockaddr *)&Netgame.players[0].protocol.udp.addr, sizeof(struct _sockaddr)))
|
||||
return;
|
||||
|
||||
len++; // Skip UPID byte;
|
||||
host_ping_time = GET_INTEL_INT(&(data[len])); len += 4;
|
||||
len++; // Skip UPID byte;
|
||||
memcpy(&host_ping_time, &data[len], 8); len += 8;
|
||||
for (i = 1; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
Netgame.players[i].ping = GET_INTEL_INT(&(data[len])); len += 4;
|
||||
|
@ -4431,15 +4415,15 @@ void net_udp_process_ping(ubyte *data, int data_len, struct _sockaddr sender_add
|
|||
|
||||
buf[0] = UPID_PONG;
|
||||
buf[1] = Player_num;
|
||||
PUT_INTEL_INT(buf + 2, host_ping_time);
|
||||
|
||||
memcpy(&buf[2], &host_ping_time, 8);
|
||||
|
||||
sendto (UDP_Socket[0], buf, sizeof(buf), 0, (struct sockaddr *)&sender_addr, sizeof(struct _sockaddr));
|
||||
}
|
||||
|
||||
// Got a PONG from a client. Check the time and add it to our players.
|
||||
void net_udp_process_pong(ubyte *data, int data_len, struct _sockaddr sender_addr)
|
||||
{
|
||||
fix client_pong_time = 0;
|
||||
fix64 client_pong_time = 0;
|
||||
int i = 0;
|
||||
|
||||
if (data_len != UPKT_PONG_SIZE)
|
||||
|
@ -4453,10 +4437,10 @@ void net_udp_process_pong(ubyte *data, int data_len, struct _sockaddr sender_add
|
|||
|
||||
if (i == MAX_PLAYERS)
|
||||
return;
|
||||
|
||||
memcpy(&client_pong_time, &(data[2]), 4);
|
||||
Netgame.players[data[1]].ping = f2i(fixmul(timer_get_fixed_seconds() - INTEL_INT(client_pong_time),i2f(1000)));
|
||||
|
||||
|
||||
memcpy(&client_pong_time, &data[2], 8);
|
||||
Netgame.players[data[1]].ping = f2i(fixmul(timer_query() - client_pong_time,i2f(1000)));
|
||||
|
||||
if (Netgame.players[data[1]].ping < 0)
|
||||
Netgame.players[data[1]].ping = 0;
|
||||
|
||||
|
@ -4501,7 +4485,7 @@ void net_udp_do_refuse_stuff (UDP_sequence_packet *their)
|
|||
}
|
||||
|
||||
strcpy (RefusePlayerName,their->player.callsign);
|
||||
RefuseTimeLimit=timer_get_fixed_seconds();
|
||||
RefuseTimeLimit=timer_query();
|
||||
RefuseThisPlayer=0;
|
||||
WaitForRefuseAnswer=1;
|
||||
}
|
||||
|
@ -4544,7 +4528,7 @@ void net_udp_do_refuse_stuff (UDP_sequence_packet *their)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((timer_get_fixed_seconds()) > RefuseTimeLimit+REFUSE_INTERVAL)
|
||||
if ((timer_query()) > RefuseTimeLimit+REFUSE_INTERVAL)
|
||||
{
|
||||
RefuseTimeLimit=0;
|
||||
RefuseThisPlayer=0;
|
||||
|
@ -4573,7 +4557,7 @@ int net_udp_get_new_player_num (UDP_sequence_packet *their)
|
|||
// disconnected and replace the oldest player with this new one
|
||||
|
||||
int oldest_player = -1;
|
||||
fix oldest_time = timer_get_fixed_seconds();
|
||||
fix64 oldest_time = timer_query();
|
||||
|
||||
Assert(N_players == MaxNumNetPlayers);
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ int net_udp_level_sync();
|
|||
#define UPKT_MAX_SIZE 576 // Max size for a packet - just for the buffers
|
||||
#define UPKT_GAME_INFO_REQ_SIZE 11
|
||||
#define UPKT_SEQUENCE_SIZE 14
|
||||
#define UPKT_PING_SIZE 33
|
||||
#define UPKT_PONG_SIZE 6
|
||||
#define UPKT_PING_SIZE 37
|
||||
#define UPKT_PONG_SIZE 10
|
||||
#define UPKT_MBUF_SIZE 454
|
||||
|
||||
// UDP-Packet identificators (ubyte)
|
||||
|
@ -116,8 +116,8 @@ typedef struct UDP_mdata_info
|
|||
typedef struct UDP_mdata_store
|
||||
{
|
||||
int used;
|
||||
fix pkt_initial_timestamp; // initial timestamp to see if packet is outdated
|
||||
fix pkt_timestamp[MAX_PLAYERS]; // Packet timestamp
|
||||
fix64 pkt_initial_timestamp; // initial timestamp to see if packet is outdated
|
||||
fix64 pkt_timestamp[MAX_PLAYERS]; // Packet timestamp
|
||||
int pkt_num; // Packet number
|
||||
ubyte Player_num; // sender of this packet
|
||||
ubyte player_ack[MAX_PLAYERS]; // 0 if player has not ACK'd this packet, 1 if ACK'd or not connected
|
||||
|
|
|
@ -306,7 +306,6 @@ void nm_rstring( int w1,int x, int y, char * s )
|
|||
void nm_string_inputbox( int w, int x, int y, char * text, int current )
|
||||
{
|
||||
int w1,h1,aw;
|
||||
fix time = timer_get_fixed_seconds();
|
||||
|
||||
// even with variable char widths and a box that goes over the whole screen, we maybe never get more than 75 chars on the line
|
||||
if (strlen(text)>75)
|
||||
|
@ -323,7 +322,7 @@ void nm_string_inputbox( int w, int x, int y, char * text, int current )
|
|||
|
||||
nm_string_black( w, x, y, text );
|
||||
|
||||
if ( current && time & 0x8000 )
|
||||
if ( current && timer_query() & 0x8000 )
|
||||
gr_string( x+w1, y, CURSOR_STRING );
|
||||
}
|
||||
|
||||
|
@ -603,11 +602,11 @@ int newmenu_mouse(window *wind, d_event *event, newmenu *menu)
|
|||
|
||||
// check possible scrollbar stuff first
|
||||
if (menu->is_scroll_box) {
|
||||
int arrow_width, arrow_height, aw, ScrollAllow=0, time=timer_get_fixed_seconds();
|
||||
static fix ScrollTime=0;
|
||||
if (ScrollTime + F1_0/5 < time || time < ScrollTime)
|
||||
int arrow_width, arrow_height, aw, ScrollAllow=0;
|
||||
static fix64 ScrollTime=0;
|
||||
if (ScrollTime + F1_0/5 < timer_query())
|
||||
{
|
||||
ScrollTime = time;
|
||||
ScrollTime = timer_query();
|
||||
ScrollAllow = 1;
|
||||
}
|
||||
|
||||
|
@ -1650,7 +1649,8 @@ struct listbox
|
|||
int allow_abort_flag;
|
||||
int (*listbox_callback)(listbox *lb, d_event *event, void *userdata);
|
||||
int citem, first_item;
|
||||
int marquee_maxchars, marquee_charpos, marquee_scrollback, marquee_lasttime; // to scroll text if string does not fit in box
|
||||
int marquee_maxchars, marquee_charpos, marquee_scrollback;
|
||||
fix64 marquee_lasttime; // to scroll text if string does not fit in box
|
||||
int box_w, height, box_x, box_y, title_height;
|
||||
short swidth, sheight; float fntscalex, fntscaley; // with these we check if resolution or fonts have changed so listbox structure can be recreated
|
||||
int mouse_state;
|
||||
|
@ -1880,7 +1880,7 @@ void listbox_create_structure( listbox *lb)
|
|||
lb->box_w = SWIDTH - (BORDERX*2);
|
||||
gr_get_string_size("O", &w, &h, &aw);
|
||||
lb->marquee_maxchars = lb->box_w/w;
|
||||
lb->marquee_lasttime = timer_get_fixed_seconds();
|
||||
lb->marquee_lasttime = timer_query();
|
||||
}
|
||||
|
||||
lb->box_x = (grd_curcanv->cv_bitmap.bm_w-lb->box_w)/2;
|
||||
|
@ -1943,7 +1943,7 @@ int listbox_draw(window *wind, listbox *lb)
|
|||
if (prev_citem != lb->citem)
|
||||
{
|
||||
lb->marquee_charpos = lb->marquee_scrollback = 0;
|
||||
lb->marquee_lasttime = timer_get_fixed_seconds();
|
||||
lb->marquee_lasttime = timer_query();
|
||||
prev_citem = lb->citem;
|
||||
}
|
||||
|
||||
|
@ -1951,12 +1951,10 @@ int listbox_draw(window *wind, listbox *lb)
|
|||
|
||||
if (i == lb->citem)
|
||||
{
|
||||
fix time = timer_get_fixed_seconds();
|
||||
|
||||
if (lb->marquee_lasttime + (F1_0/3) < time)
|
||||
if (lb->marquee_lasttime + (F1_0/3) < timer_query())
|
||||
{
|
||||
lb->marquee_charpos = lb->marquee_charpos+(lb->marquee_scrollback?-1:+1);
|
||||
lb->marquee_lasttime = time;
|
||||
lb->marquee_lasttime = timer_query();
|
||||
}
|
||||
if (lb->marquee_charpos < 0) // reached beginning of string -> scroll forward
|
||||
{
|
||||
|
|
|
@ -310,7 +310,7 @@ void scores_draw_item( int i, stats_info * stats )
|
|||
typedef struct scores_menu
|
||||
{
|
||||
int citem;
|
||||
fix t1;
|
||||
fix64 t1;
|
||||
int looper;
|
||||
all_scores scores;
|
||||
stats_info last_game;
|
||||
|
@ -390,9 +390,9 @@ int scores_handler(window *wind, d_event *event, scores_menu *menu)
|
|||
if ( menu->citem > -1 ) {
|
||||
|
||||
gr_set_fontcolor( BM_XRGB(7+fades[menu->looper],7+fades[menu->looper],7+fades[menu->looper]), -1 );
|
||||
if (timer_get_fixed_seconds() >= menu->t1+F1_0/128)
|
||||
if (timer_query() >= menu->t1+F1_0/128)
|
||||
{
|
||||
menu->t1 = timer_get_fixed_seconds();
|
||||
menu->t1 = timer_query();
|
||||
menu->looper++;
|
||||
if (menu->looper>63) menu->looper=0;
|
||||
}
|
||||
|
@ -425,7 +425,7 @@ void scores_view(stats_info *last_game, int citem)
|
|||
return;
|
||||
|
||||
menu->citem = citem;
|
||||
menu->t1 = timer_get_fixed_seconds();
|
||||
menu->t1 = timer_query();
|
||||
menu->looper = 0;
|
||||
if (last_game)
|
||||
menu->last_game = *last_game;
|
||||
|
|
|
@ -81,7 +81,7 @@ static int rescale_y(int y)
|
|||
typedef struct title_screen
|
||||
{
|
||||
grs_bitmap title_bm;
|
||||
fix timer;
|
||||
fix64 timer;
|
||||
int allow_keys;
|
||||
} title_screen;
|
||||
|
||||
|
@ -108,7 +108,7 @@ int title_handler(window *wind, d_event *event, title_screen *ts)
|
|||
case EVENT_IDLE:
|
||||
timer_delay2(50);
|
||||
|
||||
if (timer_get_fixed_seconds() > ts->timer)
|
||||
if (timer_query() > ts->timer)
|
||||
{
|
||||
window_close(wind);
|
||||
return 1;
|
||||
|
@ -159,7 +159,7 @@ int show_title_screen( char * filename, int allow_keys, int from_hog_only )
|
|||
Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
|
||||
}
|
||||
|
||||
ts->timer = timer_get_fixed_seconds() + i2f(3);
|
||||
ts->timer = timer_query() + i2f(3);
|
||||
|
||||
gr_palette_load( gr_palette );
|
||||
|
||||
|
@ -310,8 +310,8 @@ typedef struct briefing
|
|||
ubyte flashing_cursor;
|
||||
ubyte new_page;
|
||||
int new_screen;
|
||||
fix start_time;
|
||||
fix delay_count;
|
||||
fix64 start_time;
|
||||
fix64 delay_count;
|
||||
int robot_num;
|
||||
grs_canvas *robot_canv;
|
||||
vms_angvec robot_angles;
|
||||
|
@ -460,7 +460,7 @@ void put_char_delay(briefing *br, int ch)
|
|||
int w, h, aw;
|
||||
|
||||
str[0] = ch; str[1] = '\0';
|
||||
if (br->delay_count && (timer_get_fixed_seconds() < br->start_time + br->delay_count))
|
||||
if (br->delay_count && (timer_query() < br->start_time + br->delay_count))
|
||||
{
|
||||
br->message--; // Go back to same character
|
||||
return;
|
||||
|
@ -476,7 +476,7 @@ void put_char_delay(briefing *br, int ch)
|
|||
gr_get_string_size(str, &w, &h, &aw );
|
||||
br->text_x += w;
|
||||
|
||||
br->start_time = timer_get_fixed_seconds();
|
||||
br->start_time = timer_query();
|
||||
}
|
||||
|
||||
void init_spinning_robot(briefing *br);
|
||||
|
@ -655,7 +655,7 @@ void flash_cursor(briefing *br, int cursor_flag)
|
|||
if (cursor_flag == 0)
|
||||
return;
|
||||
|
||||
if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
|
||||
if ((timer_query() % (F1_0/2) ) > (F1_0/4))
|
||||
gr_set_fontcolor(Briefing_text_colors[Current_color], -1);
|
||||
else
|
||||
gr_set_fontcolor(Erase_color, -1);
|
||||
|
|
10
ui/listbox.c
10
ui/listbox.c
|
@ -316,18 +316,18 @@ void ui_listbox_do( UI_GADGET_LISTBOX * listbox, int keypress )
|
|||
else
|
||||
mitem = (Mouse.y - listbox->y1)/listbox->textheight;
|
||||
|
||||
if ( (mitem < 0 ) && ( timer_get_fixed_seconds() > listbox->last_scrolled+1) )
|
||||
if ( (mitem < 0 ) && ( timer_query() > listbox->last_scrolled+1) )
|
||||
{
|
||||
listbox->current_item--;
|
||||
listbox->last_scrolled = timer_get_fixed_seconds();
|
||||
listbox->last_scrolled = timer_query();
|
||||
listbox->moved = 1;
|
||||
}
|
||||
|
||||
if ( ( mitem >= listbox->num_items_displayed ) &&
|
||||
( timer_get_fixed_seconds() > listbox->last_scrolled+1) )
|
||||
( timer_query() > listbox->last_scrolled+1) )
|
||||
{
|
||||
listbox->current_item++;
|
||||
listbox->last_scrolled = timer_get_fixed_seconds();
|
||||
listbox->last_scrolled = timer_query();
|
||||
listbox->moved = 1;
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ void ui_listbox_change( UI_WINDOW * wnd, UI_GADGET_LISTBOX * listbox, short numi
|
|||
listbox->num_items = numitems;
|
||||
listbox->first_item = 0;
|
||||
listbox->current_item = -1;
|
||||
listbox->last_scrolled = timer_get_fixed_seconds();
|
||||
listbox->last_scrolled = timer_query();
|
||||
listbox->dragging = 0;
|
||||
listbox->selected_item = -1;
|
||||
listbox->status = 1;
|
||||
|
|
|
@ -205,11 +205,11 @@ void ui_mouse_process()
|
|||
|
||||
if ((Mouse.b1_status & BUTTON_PRESSED) && (Mouse.b1_last_status & BUTTON_RELEASED) )
|
||||
{
|
||||
if ( (timer_get_fixed_seconds() <= Mouse.time_lastpressed+5) ) //&& (Mouse.moved==0)
|
||||
if ( (timer_query() <= Mouse.time_lastpressed+5) ) //&& (Mouse.moved==0)
|
||||
Mouse.b1_status |= BUTTON_DOUBLE_CLICKED;
|
||||
|
||||
Mouse.moved = 0;
|
||||
Mouse.time_lastpressed = timer_get_fixed_seconds();
|
||||
Mouse.time_lastpressed = timer_query();
|
||||
Mouse.b1_status |= BUTTON_JUST_PRESSED;
|
||||
|
||||
}
|
||||
|
|
12
ui/scroll.c
12
ui/scroll.c
|
@ -157,9 +157,9 @@ void ui_scrollbar_do( UI_GADGET_SCROLLBAR * scrollbar, int keypress )
|
|||
|
||||
if ( (scrollbar->up_button->position!=0) || (keyfocus && keyd_pressed[KEY_UP]) )
|
||||
{
|
||||
if (timer_get_fixed_seconds() > scrollbar->last_scrolled+1)
|
||||
if (timer_query() > scrollbar->last_scrolled+1)
|
||||
{
|
||||
scrollbar->last_scrolled = timer_get_fixed_seconds();
|
||||
scrollbar->last_scrolled = timer_query();
|
||||
scrollbar->position--;
|
||||
if (scrollbar->position < scrollbar->start )
|
||||
scrollbar->position = scrollbar->start;
|
||||
|
@ -171,9 +171,9 @@ void ui_scrollbar_do( UI_GADGET_SCROLLBAR * scrollbar, int keypress )
|
|||
|
||||
if ( (scrollbar->down_button->position!=0) || (keyfocus && keyd_pressed[KEY_DOWN]) )
|
||||
{
|
||||
if (timer_get_fixed_seconds() > scrollbar->last_scrolled+1)
|
||||
if (timer_query() > scrollbar->last_scrolled+1)
|
||||
{
|
||||
scrollbar->last_scrolled = timer_get_fixed_seconds();
|
||||
scrollbar->last_scrolled = timer_query();
|
||||
scrollbar->position++;
|
||||
if (scrollbar->position > scrollbar->stop )
|
||||
scrollbar->position = scrollbar->stop;
|
||||
|
@ -207,9 +207,9 @@ void ui_scrollbar_do( UI_GADGET_SCROLLBAR * scrollbar, int keypress )
|
|||
scrollbar->drag_starting = scrollbar->fake_position;
|
||||
}
|
||||
|
||||
if ( B1_PRESSED && OnMe && !OnSlider && (timer_get_fixed_seconds() > scrollbar->last_scrolled+4) )
|
||||
if ( B1_PRESSED && OnMe && !OnSlider && (timer_query() > scrollbar->last_scrolled+4) )
|
||||
{
|
||||
scrollbar->last_scrolled = timer_get_fixed_seconds();
|
||||
scrollbar->last_scrolled = timer_query();
|
||||
|
||||
if ( Mouse.y < scrollbar->fake_position+scrollbar->y1 )
|
||||
{
|
||||
|
|
|
@ -322,16 +322,16 @@ void restore_state()
|
|||
}
|
||||
|
||||
|
||||
int last_event = 0;
|
||||
fix64 last_event = 0;
|
||||
|
||||
void ui_reset_idle_seconds()
|
||||
{
|
||||
last_event = timer_get_fixed_seconds();
|
||||
last_event = timer_query();
|
||||
}
|
||||
|
||||
int ui_get_idle_seconds()
|
||||
{
|
||||
return (((timer_get_fixed_seconds() - last_event)*10)/182);
|
||||
return (((timer_query() - last_event)*10)/182);
|
||||
}
|
||||
|
||||
void ui_mega_process()
|
||||
|
@ -349,7 +349,7 @@ void ui_mega_process()
|
|||
last_keypress = key_inkey();
|
||||
|
||||
if ( Mouse.new_buttons || last_keypress || Mouse.new_dx || Mouse.new_dy ) {
|
||||
last_event = timer_get_fixed_seconds();
|
||||
last_event = timer_query();
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue