mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
fix last commit introducing possible crash if no data is received from server for over 30 seconds
This commit is contained in:
parent
ff7bbdb1ad
commit
14c9da9e27
@ -414,8 +414,8 @@ static void Gfx_FreeState(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Gfx_RestoreState(void) {
|
static void Gfx_RestoreState(void) {
|
||||||
Gfx_InitDefaultResources();
|
|
||||||
Gfx_SetFaceCulling(false);
|
Gfx_SetFaceCulling(false);
|
||||||
|
Gfx_InitDefaultResources();
|
||||||
gfx_batchFormat = -1;
|
gfx_batchFormat = -1;
|
||||||
|
|
||||||
D3D9_SetRenderState(D3DRS_COLORVERTEX, false, "D3D9_ColorVertex");
|
D3D9_SetRenderState(D3DRS_COLORVERTEX, false, "D3D9_ColorVertex");
|
||||||
@ -974,7 +974,7 @@ void Gfx_UpdateApiInfo(void) {
|
|||||||
void Gfx_OnWindowResize(void) {
|
void Gfx_OnWindowResize(void) {
|
||||||
if (Gfx.LostContext) return;
|
if (Gfx.LostContext) return;
|
||||||
Gfx_LoseContext(" (resizing window)");
|
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 */
|
/* This blocks the normal game loop from running, which means */
|
||||||
/* Gfx_OnWindowResize can end up getting called multiple times. */
|
/* Gfx_OnWindowResize can end up getting called multiple times. */
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ void Gfx_UpdateApiInfo(void);
|
|||||||
|
|
||||||
/* Raises ContextLost event and updates state for lost contexts. */
|
/* Raises ContextLost event and updates state for lost contexts. */
|
||||||
void Gfx_LoseContext(const char* reason);
|
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);
|
bool Gfx_TryRestoreContext(void);
|
||||||
|
|
||||||
/* Binds and draws the specified subset of the vertices in the current dynamic vertex buffer. */
|
/* Binds and draws the specified subset of the vertices in the current dynamic vertex buffer. */
|
||||||
|
@ -348,7 +348,7 @@ static void MPConnection_SendPosition(Vec3 pos, float rotY, float headX) {
|
|||||||
Net_SendPacket();
|
Net_SendPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MPConnection_CheckDisconnection(double delta) {
|
static void MPConnection_CheckDisconnection(void) {
|
||||||
static const String title = String_FromConst("Disconnected!");
|
static const String title = String_FromConst("Disconnected!");
|
||||||
static const String reason = String_FromConst("You've lost connection to the server");
|
static const String reason = String_FromConst("You've lost connection to the server");
|
||||||
ReturnCode availRes, selectRes;
|
ReturnCode availRes, selectRes;
|
||||||
@ -382,11 +382,9 @@ static void MPConnection_Tick(struct ScheduledTask* task) {
|
|||||||
if (Server.Disconnected) return;
|
if (Server.Disconnected) return;
|
||||||
if (net_connecting) { MPConnection_TickConnect(); 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();
|
now = DateTime_CurrentUTC_MS();
|
||||||
if (net_lastPacket + (30 * 1000) < now) {
|
if (net_lastPacket + (30 * 1000) < now) MPConnection_CheckDisconnection();
|
||||||
MPConnection_CheckDisconnection(task->Interval);
|
|
||||||
}
|
|
||||||
if (Server.Disconnected) return;
|
if (Server.Disconnected) return;
|
||||||
|
|
||||||
pending = 0;
|
pending = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user