fix last commit introducing possible crash if no data is received from server for over 30 seconds

This commit is contained in:
UnknownShadow200 2019-07-18 21:46:51 +10:00
parent ff7bbdb1ad
commit 14c9da9e27
3 changed files with 6 additions and 8 deletions

View file

@ -414,8 +414,8 @@ static void Gfx_FreeState(void) {
}
static void Gfx_RestoreState(void) {
Gfx_InitDefaultResources();
Gfx_SetFaceCulling(false);
Gfx_InitDefaultResources();
gfx_batchFormat = -1;
D3D9_SetRenderState(D3DRS_COLORVERTEX, false, "D3D9_ColorVertex");
@ -974,7 +974,7 @@ void Gfx_UpdateApiInfo(void) {
void Gfx_OnWindowResize(void) {
if (Gfx.LostContext) return;
Gfx_LoseContext(" (resizing window)");
/* NOTE: Windows enters a size/move modal loop. (WM_ENTERSIZELOOP) */
/* NOTE: Windows enters a size/move modal loop. (WM_ENTERSIZEMOVE) */
/* This blocks the normal game loop from running, which means */
/* Gfx_OnWindowResize can end up getting called multiple times. */
}

View file

@ -172,7 +172,7 @@ void Gfx_UpdateApiInfo(void);
/* Raises ContextLost event and updates state for lost contexts. */
void Gfx_LoseContext(const char* reason);
/* Attempts to restore a lost context. Raises ContextRecreated event is successful. */
/* Attempts to restore a lost context. Raises ContextRecreated event on success. */
bool Gfx_TryRestoreContext(void);
/* Binds and draws the specified subset of the vertices in the current dynamic vertex buffer. */

View file

@ -348,7 +348,7 @@ static void MPConnection_SendPosition(Vec3 pos, float rotY, float headX) {
Net_SendPacket();
}
static void MPConnection_CheckDisconnection(double delta) {
static void MPConnection_CheckDisconnection(void) {
static const String title = String_FromConst("Disconnected!");
static const String reason = String_FromConst("You've lost connection to the server");
ReturnCode availRes, selectRes;
@ -382,11 +382,9 @@ static void MPConnection_Tick(struct ScheduledTask* task) {
if (Server.Disconnected) return;
if (net_connecting) { MPConnection_TickConnect(); return; }
/* over 30 seconds since last packet */
/* Over 30 seconds since last packet, connection likely dropped */
now = DateTime_CurrentUTC_MS();
if (net_lastPacket + (30 * 1000) < now) {
MPConnection_CheckDisconnection(task->Interval);
}
if (net_lastPacket + (30 * 1000) < now) MPConnection_CheckDisconnection();
if (Server.Disconnected) return;
pending = 0;