about summary refs log tree commit diff
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2011-01-17 12:28:37 +0100
committeroy <Tom_Adams@web.de>2011-01-17 12:28:37 +0100
commit216967c3bf72ccff9d069327a5531e50f8f88b5a (patch)
treeedda4389c670ddbb9e37885a948f5231babbf496
parent5483eb66294aabea76624659886a7c39a0758e66 (diff)
downloadzcatch-216967c3bf72ccff9d069327a5531e50f8f88b5a.tar.gz
zcatch-216967c3bf72ccff9d069327a5531e50f8f88b5a.zip
release gameclient components when opening the editor. Closes #429
-rw-r--r--src/engine/client.h1
-rw-r--r--src/engine/client/client.cpp10
-rw-r--r--src/engine/client/client.h1
-rw-r--r--src/game/client/components/controls.cpp5
-rw-r--r--src/game/client/components/controls.h1
-rw-r--r--src/game/client/gameclient.cpp5
-rw-r--r--src/game/client/gameclient.h1
7 files changed, 24 insertions, 0 deletions
diff --git a/src/engine/client.h b/src/engine/client.h
index 80a0241d..a0ebb3e7 100644
--- a/src/engine/client.h
+++ b/src/engine/client.h
@@ -149,6 +149,7 @@ public:
 	virtual void OnConnected() = 0;
 	virtual void OnMessage(int MsgId, CUnpacker *pUnpacker) = 0;
 	virtual void OnPredict() = 0;
+	virtual void OnActivateEditor() = 0;
 	
 	virtual int OnSnapInput(int *pData) = 0;
 	
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp
index d67e3332..9b8c4151 100644
--- a/src/engine/client/client.cpp
+++ b/src/engine/client/client.cpp
@@ -414,6 +414,7 @@ CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta), m_DemoRecorder(&m_SnapshotD
 	m_WindowMustRefocus = 0;
 	m_SnapCrcErrors = 0;
 	m_AutoScreenshotRecycle = false;
+	m_EditorActive = false;
 
 	m_AckGameTick = -1;
 	m_CurrentRecvTick = 0;
@@ -1914,12 +1915,21 @@ void CClient::Run()
 		// render
 		if(g_Config.m_ClEditor)
 		{
+			if(!m_EditorActive)
+			{
+				GameClient()->OnActivateEditor();
+				m_EditorActive = true;
+			}
+
 			Update();
 			m_pEditor->UpdateAndRender();
 			m_pGraphics->Swap();
 		}
 		else
 		{
+			if(m_EditorActive)
+				m_EditorActive = false;
+
 			Update();
 
 			if(g_Config.m_DbgStress)
diff --git a/src/engine/client/client.h b/src/engine/client/client.h
index 406b0ac7..f25e7cf7 100644
--- a/src/engine/client/client.h
+++ b/src/engine/client/client.h
@@ -141,6 +141,7 @@ class CClient : public IClient, public CDemoPlayer::IListner
 	int m_WindowMustRefocus;
 	int m_SnapCrcErrors;
 	bool m_AutoScreenshotRecycle;
+	bool m_EditorActive;
 
 	int m_AckGameTick;
 	int m_CurrentRecvTick;
diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp
index 1dd74af2..f7da46b6 100644
--- a/src/game/client/components/controls.cpp
+++ b/src/game/client/components/controls.cpp
@@ -32,6 +32,11 @@ void CControls::OnReset()
 	m_InputDirectionRight = 0;
 }
 
+void CControls::OnRelease()
+{
+	OnReset();
+}
+
 void CControls::OnPlayerDeath()
 {
 	m_LastData.m_WantedWeapon = m_InputData.m_WantedWeapon = 0;
diff --git a/src/game/client/components/controls.h b/src/game/client/components/controls.h
index 38b3c8ba..a50318f5 100644
--- a/src/game/client/components/controls.h
+++ b/src/game/client/components/controls.h
@@ -19,6 +19,7 @@ public:
 	CControls();
 	
 	virtual void OnReset();
+	virtual void OnRelease();
 	virtual void OnRender();
 	virtual void OnMessage(int MsgType, void *pRawMsg);
 	virtual bool OnMouseMove(float x, float y);
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index 9a05cc88..e37eebea 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -971,6 +971,11 @@ void CGameClient::OnPredict()
 	m_PredictedTick = Client()->PredGameTick();
 }
 
+void CGameClient::OnActivateEditor()
+{
+	OnRelease();
+}
+
 void CGameClient::CClientData::UpdateRenderInfo()
 {
 	m_RenderInfo = m_SkinInfo;
diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h
index 99e64028..1e5c4856 100644
--- a/src/game/client/gameclient.h
+++ b/src/game/client/gameclient.h
@@ -176,6 +176,7 @@ public:
 	virtual void OnMessage(int MsgId, CUnpacker *pUnpacker);
 	virtual void OnNewSnapshot();
 	virtual void OnPredict();
+	virtual void OnActivateEditor();
 	virtual int OnSnapInput(int *pData);
 	virtual void OnShutdown();
 	virtual void OnEnterGame();