fix input when using vsync

git-svn-id: https://svn.eduke32.com/eduke32@1634 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2010-05-09 08:51:25 +00:00
parent a6b614f6bf
commit 3514722a74
8 changed files with 49 additions and 59 deletions

View file

@ -81,7 +81,7 @@ ifeq (4,$(GCC_MAJOR))
endif endif
endif endif
ifeq (5,$(GCC_MINOR)) ifeq (5,$(GCC_MINOR))
debug += -flto # debug += -flto
endif endif
endif endif
endif endif

View file

@ -103,7 +103,7 @@ ifeq (4,$(GCC_MAJOR))
endif endif
endif endif
ifeq (5,$(GCC_MINOR)) ifeq (5,$(GCC_MINOR))
debug += -flto # debug += -flto
endif endif
endif endif
endif endif

View file

@ -1469,9 +1469,7 @@ void OSD_DispatchQueued(void)
osdexeccount=0; osdexeccount=0;
for (; cmd>=0; cmd--) for (; cmd>=0; cmd--)
{
OSD_Dispatch((const char *)osdhistorybuf[cmd]); OSD_Dispatch((const char *)osdhistorybuf[cmd]);
}
} }
@ -1576,36 +1574,30 @@ static char *strtoken(char *s, char **ptrptr, int32_t *restart)
int32_t OSD_Dispatch(const char *cmd) int32_t OSD_Dispatch(const char *cmd)
{ {
char *workbuf, *wp, *wtp, *state; char *workbuf, *wp, *wtp, *state;
char *parms[MAXPARMS]; int32_t restart = 0;
int32_t numparms, restart = 0;
osdfuncparm_t ofp;
symbol_t *symb;
//int32_t i;
workbuf = state = Bstrdup(cmd); workbuf = state = Bstrdup(cmd);
if (!workbuf) return -1; if (!workbuf) return -1;
do do
{ {
numparms = 0; int32_t numparms = 0;
symbol_t *symb;
osdfuncparm_t ofp;
char *parms[MAXPARMS];
Bmemset(parms, 0, sizeof(parms)); Bmemset(parms, 0, sizeof(parms));
wp = strtoken(state, &wtp, &restart);
if (!wp) if ((wp = strtoken(state, &wtp, &restart)) == NULL)
{ {
state = wtp; state = wtp;
continue; continue;
} }
if (wp[0] == '/' && wp[1] == '/') // cheap hack if ((symb = findexactsymbol(wp)) == NULL)
{ {
Bfree(workbuf); if (wp[0] != '/' || wp[1] != '/') // cheap hack for comments in cfgs
return -1; OSD_Printf(OSDTEXT_RED "\"%s\" is not a valid command or cvar\n", wp);
}
symb = findexactsymbol(wp);
if (!symb)
{
OSD_Printf(OSDTEXT_RED "Error: \"%s\" is not a valid command or cvar\n", wp);
Bfree(workbuf); Bfree(workbuf);
return -1; return -1;
} }
@ -1619,10 +1611,14 @@ int32_t OSD_Dispatch(const char *cmd)
ofp.numparms = numparms; ofp.numparms = numparms;
ofp.parms = (const char **)parms; ofp.parms = (const char **)parms;
ofp.raw = cmd; ofp.raw = cmd;
if (symb->func == OSD_ALIAS)
OSD_Dispatch(symb->help); switch((intptr_t)symb->func)
else if (symb->func != OSD_UNALIASED)
{ {
case (intptr_t)OSD_ALIAS:
OSD_Dispatch(symb->help);
case (intptr_t)OSD_UNALIASED:
break;
default:
switch (symb->func(&ofp)) switch (symb->func(&ofp))
{ {
case OSDCMD_OK: case OSDCMD_OK:
@ -1631,6 +1627,7 @@ int32_t OSD_Dispatch(const char *cmd)
OSD_Printf("%s\n", symb->help); OSD_Printf("%s\n", symb->help);
break; break;
} }
break;
} }
state = wtp; state = wtp;

View file

@ -183,7 +183,7 @@ int32_t r_fullbrights = 1;
// texture downsizing // texture downsizing
// is medium quality a good default? // is medium quality a good default?
int32_t r_downsize = 1; int32_t r_downsize = 1;
int32_t r_downsizevar = 1; int32_t r_downsizevar = -1;
// used for fogcalc // used for fogcalc
float fogresult, fogcol[4], fogtable[4*MAXPALOOKUPS]; float fogresult, fogcol[4], fogtable[4*MAXPALOOKUPS];
@ -5916,14 +5916,15 @@ static int32_t osdcmd_cvar_set_polymost(const osdfuncparm_t *parm)
} }
else if (!Bstrcasecmp(parm->name, "r_downsize")) else if (!Bstrcasecmp(parm->name, "r_downsize"))
{ {
if (r_downsize != r_downsizevar) if (r_downsize != r_downsizevar && r_downsizevar != -1)
{ {
invalidatecache(); invalidatecache();
resetvideomode(); resetvideomode();
if (setgamemode(fullscreen,xdim,ydim,bpp)) if (setgamemode(fullscreen,xdim,ydim,bpp))
OSD_Printf("restartvid: Reset failed...\n"); OSD_Printf("restartvid: Reset failed...\n");
} }
r_downsize = r_downsizevar; else r_downsizevar = r_downsize;
return r; return r;
} }
else if (!Bstrcasecmp(parm->name, "r_textureanisotropy")) else if (!Bstrcasecmp(parm->name, "r_textureanisotropy"))
@ -5962,7 +5963,7 @@ void polymost_initosdfuncs(void)
{ "r_animsmoothing","r_animsmoothing: enable/disable model animation smoothing",(void *)&r_animsmoothing, CVAR_BOOL, 0, 1 }, { "r_animsmoothing","r_animsmoothing: enable/disable model animation smoothing",(void *)&r_animsmoothing, CVAR_BOOL, 0, 1 },
{ "r_modelocclusionchecking","r_modelocclusionchecking: enable/disable hack to cull \"obstructed\" models",(void *)&r_modelocclusionchecking, CVAR_INT, 0, 2 }, { "r_modelocclusionchecking","r_modelocclusionchecking: enable/disable hack to cull \"obstructed\" models",(void *)&r_modelocclusionchecking, CVAR_INT, 0, 2 },
{ "r_detailmapping","r_detailmapping: enable/disable detail mapping",(void *)&r_detailmapping, CVAR_BOOL, 0, 1 }, { "r_detailmapping","r_detailmapping: enable/disable detail mapping",(void *)&r_detailmapping, CVAR_BOOL, 0, 1 },
{ "r_downsize","r_downsize: controls downsizing factor for hires textures",(void *)&r_downsizevar, CVAR_INT|CVAR_FUNCPTR, 0, 5 }, { "r_downsize","r_downsize: controls downsizing factor for hires textures",(void *)&r_downsize, CVAR_INT|CVAR_FUNCPTR, 0, 5 },
{ "r_fullbrights","r_fullbrights: enable/disable fullbright textures",(void *)&r_fullbrights, CVAR_BOOL, 0, 1 }, { "r_fullbrights","r_fullbrights: enable/disable fullbright textures",(void *)&r_fullbrights, CVAR_BOOL, 0, 1 },
{ "r_glowmapping","r_glowmapping: enable/disable glow mapping",(void *)&r_glowmapping, CVAR_BOOL, 0, 1 }, { "r_glowmapping","r_glowmapping: enable/disable glow mapping",(void *)&r_glowmapping, CVAR_BOOL, 0, 1 },
/* /*

View file

@ -80,7 +80,7 @@ static inline void RI_ProcessMouse(const RAWMOUSE* rmouse)
static inline void RI_ProcessKeyboard(const RAWKEYBOARD* rkbd) static inline void RI_ProcessKeyboard(const RAWKEYBOARD* rkbd)
{ {
uint8_t key = rkbd->MakeCode, VKey = rkbd->VKey; uint8_t key = rkbd->MakeCode, VKey = rkbd->VKey;
uint8_t buf[2], i; uint8_t buf[2];
// for some reason rkbd->MakeCode is wrong for these // for some reason rkbd->MakeCode is wrong for these
// even though rkbd->VKey is right... // even though rkbd->VKey is right...

View file

@ -1606,12 +1606,12 @@ inline void sampletimer(void)
if (!timerfreq) return; if (!timerfreq) return;
QueryPerformanceCounter((LARGE_INTEGER*)&i); QueryPerformanceCounter((LARGE_INTEGER*)&i);
n = (int32_t)(i*timerticspersec / timerfreq) - timerlastsample; n = (int32_t)((i*timerticspersec / timerfreq) - timerlastsample);
if (n>0)
{ if (n <= 0) return;
totalclock += n;
timerlastsample += n; totalclock += n;
} timerlastsample += n;
if (usertimercallback) for (; n>0; n--) usertimercallback(); if (usertimercallback) for (; n>0; n--) usertimercallback();
} }

View file

@ -2241,23 +2241,6 @@ void Net_UpdateClients(void)
void faketimerhandler(void) void faketimerhandler(void)
{ {
int32_t i;
if (g_quickExit == 0 && KB_KeyPressed(sc_LeftControl) && KB_KeyPressed(sc_LeftAlt) && KB_KeyPressed(sc_Delete))
{
g_quickExit = 1;
G_GameExit("Quick Exit.");
}
sampletimer();
MUSIC_Update();
if ((totalclock < ototalclock+TICSPERFRAME) || (ready2send == 0)) return;
ototalclock += TICSPERFRAME;
Net_GetPackets();
g_player[myconnectindex].movefifoend++;
} }
extern int32_t cacnum; extern int32_t cacnum;
@ -11808,7 +11791,7 @@ MAIN_LOOP_RESTART:
do //main loop do //main loop
{ {
static uint32_t nextrender = 0, next = 0; static uint32_t nextrender = 0, framewaiting = 0;
uint32_t j; uint32_t j;
if (handleevents() && quitevent) if (handleevents() && quitevent)
@ -11818,6 +11801,8 @@ MAIN_LOOP_RESTART:
} }
sampletimer(); sampletimer();
MUSIC_Update();
Net_GetPackets();
// only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo // only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo
bindsenabled = g_player[myconnectindex].ps->gm & (MODE_GAME|MODE_DEMO); bindsenabled = g_player[myconnectindex].ps->gm & (MODE_GAME|MODE_DEMO);
@ -11852,7 +11837,14 @@ MAIN_LOOP_RESTART:
} }
*/ */
do faketimerhandler(); do
{
sampletimer();
if ((totalclock < ototalclock+TICSPERFRAME) || (ready2send == 0)) return;
ototalclock += TICSPERFRAME;
g_player[myconnectindex].movefifoend++;
}
while (!(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO)) && totalclock >= ototalclock+TICSPERFRAME); while (!(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO)) && totalclock >= ototalclock+TICSPERFRAME);
} }
@ -11883,9 +11875,9 @@ MAIN_LOOP_RESTART:
g_multiMapState = NULL; g_multiMapState = NULL;
} }
if (next) if (framewaiting)
{ {
next--; framewaiting--;
if (ud.statusbarmode == 1 && (ud.statusbarscale == 100 || !getrendermode())) if (ud.statusbarmode == 1 && (ud.statusbarscale == 100 || !getrendermode()))
{ {
ud.statusbarmode = 0; ud.statusbarmode = 0;
@ -11915,7 +11907,7 @@ MAIN_LOOP_RESTART:
G_DrawBackground(); G_DrawBackground();
S_Update(); S_Update();
next++; framewaiting++;
} }
if (g_player[myconnectindex].ps->gm&MODE_DEMO) if (g_player[myconnectindex].ps->gm&MODE_DEMO)

View file

@ -1453,7 +1453,7 @@ static void __fastcall VM_GetPlayer(register int32_t lVar1, register int32_t lLa
case PLAYER_FALLING_COUNTER: case PLAYER_FALLING_COUNTER:
Gv_SetVar(lVar2, g_player[iPlayer].ps->falling_counter, vm.g_i, vm.g_p); return; Gv_SetVar(lVar2, g_player[iPlayer].ps->falling_counter, vm.g_i, vm.g_p); return;
case PLAYER_GOTWEAPON: case PLAYER_GOTWEAPON:
Gv_SetVar(lVar2, g_player[iPlayer].ps->gotweapon & (1<<lParm2), vm.g_i, vm.g_p); return; Gv_SetVar(lVar2, (g_player[iPlayer].ps->gotweapon & (1<<lParm2)) != 0, vm.g_i, vm.g_p); return;
case PLAYER_REFRESH_INVENTORY: case PLAYER_REFRESH_INVENTORY:
Gv_SetVar(lVar2, g_player[iPlayer].ps->refresh_inventory, vm.g_i, vm.g_p); return; Gv_SetVar(lVar2, g_player[iPlayer].ps->refresh_inventory, vm.g_i, vm.g_p); return;
case PLAYER_TOGGLE_KEY_FLAG: case PLAYER_TOGGLE_KEY_FLAG:
@ -3710,7 +3710,7 @@ static int32_t __fastcall VM_AccessPlayerX(int32_t iPlayer, int32_t lLabelID, in
case PLAYER_FALLING_COUNTER: case PLAYER_FALLING_COUNTER:
return g_player[iPlayer].ps->falling_counter; return g_player[iPlayer].ps->falling_counter;
case PLAYER_GOTWEAPON: case PLAYER_GOTWEAPON:
return g_player[iPlayer].ps->gotweapon & (1<<lParm2); return (g_player[iPlayer].ps->gotweapon & (1<<lParm2)) != 0;
case PLAYER_REFRESH_INVENTORY: case PLAYER_REFRESH_INVENTORY:
return g_player[iPlayer].ps->refresh_inventory; return g_player[iPlayer].ps->refresh_inventory;
case PLAYER_TOGGLE_KEY_FLAG: case PLAYER_TOGGLE_KEY_FLAG: