Skip to content

Instantly share code, notes, and snippets.

@sapier
Last active January 2, 2016 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sapier/8276589 to your computer and use it in GitHub Desktop.
Save sapier/8276589 to your computer and use it in GitHub Desktop.
diff --git a/src/client.cpp b/src/client.cpp
index 1d3c623..852b8e2 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -286,6 +286,20 @@ void * MeshUpdateThread::Thread()
}
}
+void Client::Stop()
+{
+ //request all client managed threads to stop
+ m_mesh_update_thread.Stop();
+}
+
+bool Client::isShutdown()
+{
+
+ if (!m_mesh_update_thread.IsRunning()) return true;
+
+ return false;
+}
+
Client::~Client()
{
{
diff --git a/src/client.h b/src/client.h
index a74668d..6e11d19 100644
--- a/src/client.h
+++ b/src/client.h
@@ -289,6 +289,14 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
);
~Client();
+
+ /*
+ request all threads managed by client to be stopped
+ */
+ void Stop();
+
+
+ bool isShutdown();
/*
The name of the local player should already be set when
calling this, as it is sent in the initialization.
diff --git a/src/game.cpp b/src/game.cpp
index 6f48870..ebaf711 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -3428,6 +3428,16 @@ void the_game(
chat_backend.addMessage(L"", L"# Disconnected.");
chat_backend.addMessage(L"", L"");
+ client.Stop();
+
+ //force answer all texture and shader jobs (TODO return empty values)
+
+ while(!client.isShutdown()) {
+ tsrc->processQueue();
+ shsrc->processQueue();
+ sleep_ms(100);
+ }
+
// Client scope (client is destructed before destructing *def and tsrc)
}while(0);
} // try-catch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment