forked from fte/fteqw
1
0
Fork 0

fix possible infinite loop.

fix viewmodel animations not adhering to sv_gamespeed.
actually fix -watchdog, at least for msvc.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4972 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2015-08-24 15:47:40 +00:00
parent ca09c08072
commit 3d4e7f87b8
5 changed files with 46 additions and 27 deletions

View File

@ -4859,7 +4859,10 @@ void CL_LinkViewModel(void)
ent.model = cl.model_precache[pv->stats[STAT_WEAPONMODELI]]; ent.model = cl.model_precache[pv->stats[STAT_WEAPONMODELI]];
if (!ent.model) if (!ent.model)
{
pv->vm.oldmodel = NULL;
return; return;
}
#ifdef HLCLIENT #ifdef HLCLIENT
if (!CLHL_AnimateViewEntity(&ent)) if (!CLHL_AnimateViewEntity(&ent))
@ -4870,7 +4873,7 @@ void CL_LinkViewModel(void)
{ {
pv->vm.oldmodel = ent.model; pv->vm.oldmodel = ent.model;
pv->vm.oldframe = pv->vm.prevframe = pv->stats[STAT_WEAPONFRAME]; pv->vm.oldframe = pv->vm.prevframe = pv->stats[STAT_WEAPONFRAME];
pv->vm.oldlerptime = pv->vm.lerptime = realtime; pv->vm.oldlerptime = pv->vm.lerptime = cl.time;
pv->vm.frameduration = 0.1; pv->vm.frameduration = 0.1;
} }
//if the frame changed, update the oldframe to lerp into the new frame //if the frame changed, update the oldframe to lerp into the new frame
@ -4880,19 +4883,19 @@ void CL_LinkViewModel(void)
pv->vm.prevframe = pv->stats[STAT_WEAPONFRAME]; pv->vm.prevframe = pv->stats[STAT_WEAPONFRAME];
pv->vm.oldlerptime = pv->vm.lerptime; pv->vm.oldlerptime = pv->vm.lerptime;
pv->vm.frameduration = (realtime - pv->vm.lerptime); pv->vm.frameduration = (cl.time - pv->vm.lerptime);
if (pv->vm.frameduration < 0.01)//no faster than 100 times a second... to avoid divide by zero if (pv->vm.frameduration < 0.01)//no faster than 100 times a second... to avoid divide by zero
pv->vm.frameduration = 0.01; pv->vm.frameduration = 0.01;
if (pv->vm.frameduration > 0.2) //no slower than 5 times a second if (pv->vm.frameduration > 0.2) //no slower than 5 times a second
pv->vm.frameduration = 0.2; pv->vm.frameduration = 0.2;
pv->vm.lerptime = realtime; pv->vm.lerptime = cl.time;
} }
//work out the blend fraction //work out the blend fraction
ent.framestate.g[FS_REG].frame[0] = pv->vm.prevframe; ent.framestate.g[FS_REG].frame[0] = pv->vm.prevframe;
ent.framestate.g[FS_REG].frame[1] = pv->vm.oldframe; ent.framestate.g[FS_REG].frame[1] = pv->vm.oldframe;
ent.framestate.g[FS_REG].frametime[0] = realtime - pv->vm.lerptime; ent.framestate.g[FS_REG].frametime[0] = cl.time - pv->vm.lerptime;
ent.framestate.g[FS_REG].frametime[1] = realtime - pv->vm.oldlerptime; ent.framestate.g[FS_REG].frametime[1] = cl.time - pv->vm.oldlerptime;
ent.framestate.g[FS_REG].lerpweight[0] = (realtime-pv->vm.lerptime)/pv->vm.frameduration; ent.framestate.g[FS_REG].lerpweight[0] = (cl.time-pv->vm.lerptime)/pv->vm.frameduration;
ent.framestate.g[FS_REG].lerpweight[0] = bound(0, ent.framestate.g[FS_REG].lerpweight[0], 1); ent.framestate.g[FS_REG].lerpweight[0] = bound(0, ent.framestate.g[FS_REG].lerpweight[0], 1);
ent.framestate.g[FS_REG].lerpweight[1] = 1-ent.framestate.g[FS_REG].lerpweight[0]; ent.framestate.g[FS_REG].lerpweight[1] = 1-ent.framestate.g[FS_REG].lerpweight[0];
} }

View File

@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "fs.h" #include "fs.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#define _MSC_SEH #define MSVC_SEH
#endif #endif
//#define RESTARTTEST //#define RESTARTTEST
@ -3903,7 +3903,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
#ifdef CATCHCRASH #ifdef CATCHCRASH
LoadLibraryU ("DBGHELP"); //heap corruption can prevent loadlibrary from working properly, so do this in advance. LoadLibraryU ("DBGHELP"); //heap corruption can prevent loadlibrary from working properly, so do this in advance.
#ifdef _MSC_SEH #ifdef MSVC_SEH
__try __try
#else #else
{ {
@ -4231,7 +4231,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
} }
} }
#ifdef CATCHCRASH #ifdef CATCHCRASH
#ifdef _MSC_SEH #ifdef MSVC_SEH
__except (CrashExceptionHandler(false, GetExceptionCode(), GetExceptionInformation())) __except (CrashExceptionHandler(false, GetExceptionCode(), GetExceptionInformation()))
{ {
return 1; return 1;

View File

@ -26,10 +26,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#if (defined(_DEBUG) || defined(DEBUG)) && !defined(NPFTE) #if (defined(_DEBUG) || defined(DEBUG)) && !defined(NPFTE)
#define CATCHCRASH #define CATCHCRASH
#ifdef _MSC_VER
#define MSVC_SEH
DWORD CrashExceptionHandler (qboolean iswatchdog, DWORD exceptionCode, LPEXCEPTION_POINTERS exceptionInfo);
#else
LONG CALLBACK nonmsvc_CrashExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo); LONG CALLBACK nonmsvc_CrashExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo);
#ifdef _MSC_VER //nt5
PVOID WINAPI AddVectoredExceptionHandler(ULONG FirstHandler, PVECTORED_EXCEPTION_HANDLER VectoredHandler);
#endif #endif
#endif #endif
@ -93,15 +94,28 @@ unsigned int WINAPI threadwrapper(void *args)
#ifdef CATCHCRASH #ifdef CATCHCRASH
if (strcmp(((threadwrap_t *)args)->name, "watchdog")) //don't do this for the watchdog timer, as it just breaks the 'no' option. if (strcmp(((threadwrap_t *)args)->name, "watchdog")) //don't do this for the watchdog timer, as it just breaks the 'no' option.
{ {
PVOID (WINAPI *pAddVectoredExceptionHandler)(ULONG FirstHandler, PVECTORED_EXCEPTION_HANDLER VectoredHandler); #ifdef MSVC_SEH
dllfunction_t dbgfuncs[] = {{(void*)&pAddVectoredExceptionHandler, "AddVectoredExceptionHandler"}, {NULL,NULL}}; __try
{
free(args);
tw.func(tw.args);
}
__except (CrashExceptionHandler(false, GetExceptionCode(), GetExceptionInformation()))
{
}
#else
PVOID (WINAPI *[SetUnhandledExceptionFilter)(ULONG FirstHandler, PVECTORED_EXCEPTION_HANDLER VectoredHandler);
dllfunction_t dbgfuncs[] = {{(void*)&pAddVectoredExceptionHandler, "SetUnhandledExceptionFilter"}, {NULL,NULL}};
if (Sys_LoadLibrary("kernel32.dll", dbgfuncs) && pAddVectoredExceptionHandler) if (Sys_LoadLibrary("kernel32.dll", dbgfuncs) && pAddVectoredExceptionHandler)
pAddVectoredExceptionHandler(0, nonmsvc_CrashExceptionHandler); pAddVectoredExceptionHandler(0, nonmsvc_CrashExceptionHandler);
}
#endif #endif
}
free(args); else
tw.func(tw.args); #endif
{
free(args);
tw.func(tw.args);
}
#ifndef WIN32CRTDLL #ifndef WIN32CRTDLL
_endthreadex(0); _endthreadex(0);

View File

@ -2684,27 +2684,29 @@ void SV_SendClientMessages (void)
c->msecs = 1200; c->msecs = 1200;
if (c->isindependant && !sv.paused) if (c->isindependant && !sv.paused)
{ {
unsigned int stepmsec;
usercmd_t cmd; usercmd_t cmd;
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
host_client = c; host_client = c;
sv_player = c->edict; sv_player = c->edict;
SV_PreRunCmd(); SV_PreRunCmd();
cmd.msec = msecs;//25; stepmsec = 12;
if (msecs > 1000) cmd.msec = stepmsec;
msecs = 1000; //really? I blame the debugger.
VectorCopy(c->lastcmd.angles, cmd.angles); VectorCopy(c->lastcmd.angles, cmd.angles);
cmd.buttons = c->lastcmd.buttons; cmd.buttons = c->lastcmd.buttons;
SV_RunCmd (&cmd, true); SV_RunCmd (&cmd, true);
SV_PostRunCmd(); SV_PostRunCmd();
if (msecs > c->msecs) if (stepmsec > c->msecs)
c->msecs = 0; c->msecs = 0;
else else
c->msecs -= msecs;//25; c->msecs -= stepmsec;
if (c->msecs > 2000)
c->msecs = 2000; //assume debugger or system suspend/hibernate
host_client = NULL; host_client = NULL;
sv_player = NULL; sv_player = NULL;
} }
else else
c->msecs = 500; c->msecs = 500; //for switching between.
} }
#endif #endif

View File

@ -58,7 +58,7 @@ typedef BOOL (WINAPI *MINIDUMPWRITEDUMP) (
PMINIDUMP_CALLBACK_INFORMATION CallbackParam PMINIDUMP_CALLBACK_INFORMATION CallbackParam
); );
DWORD CrashExceptionHandler (DWORD exceptionCode, LPEXCEPTION_POINTERS exceptionInfo) DWORD CrashExceptionHandler (qboolean iswatchdog, DWORD exceptionCode, LPEXCEPTION_POINTERS exceptionInfo)
{ {
char dumpPath[1024]; char dumpPath[1024];
HANDLE hProc = GetCurrentProcess(); HANDLE hProc = GetCurrentProcess();
@ -305,7 +305,7 @@ DWORD CrashExceptionHandler (DWORD exceptionCode, LPEXCEPTION_POINTERS exception
LONG CALLBACK nonmsvc_CrashExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo) LONG CALLBACK nonmsvc_CrashExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo)
{ {
DWORD foo = EXCEPTION_CONTINUE_SEARCH; DWORD foo = EXCEPTION_CONTINUE_SEARCH;
foo = CrashExceptionHandler(/*false, */ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo); foo = CrashExceptionHandler(false, ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo);
//we have no handler. thus we handle it by exiting. //we have no handler. thus we handle it by exiting.
if (foo == EXCEPTION_EXECUTE_HANDLER) if (foo == EXCEPTION_EXECUTE_HANDLER)
exit(1); exit(1);
@ -1602,7 +1602,7 @@ int main (int argc, char **argv)
} }
#ifdef CATCHCRASH #ifdef CATCHCRASH
#ifdef _MSC_VER #ifdef _MSC_VER
__except (CrashExceptionHandler(GetExceptionCode(), GetExceptionInformation())) __except (CrashExceptionHandler(false, GetExceptionCode(), GetExceptionInformation()))
{ {
return 1; return 1;
} }