From aa0450df9e05dcdbeacf67f270976984ec83f914 Mon Sep 17 00:00:00 2001 From: false_genesis Date: Sat, 30 Aug 2008 12:18:49 +0000 Subject: [PATCH] * fixed some threading problems (1 possible crash: SceneCharSelection window resized or reloaded while WorldSession is destroyed) --- src/Client/GUI/Scene.h | 2 +- src/Client/GUI/SceneCharselection.cpp | 2 ++ src/Client/World/WorldSession.cpp | 2 +- src/Client/World/WorldSocket.cpp | 3 ++- src/shared/Auth/AuthCrypt.h | 2 ++ 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Client/GUI/Scene.h b/src/Client/GUI/Scene.h index d8fabee..db343e2 100644 --- a/src/Client/GUI/Scene.h +++ b/src/Client/GUI/Scene.h @@ -64,6 +64,7 @@ protected: SceneState _scenestate; uint32 scenedata[SCENEDATA_SIZE]; // generic storage for anything the PseuInstance thread wants to tell us SCPDatabase *textdb; + ZThread::FastMutex mutex; }; class SceneGuiStart : public Scene @@ -148,7 +149,6 @@ private: ShTlTerrainSceneNode *terrain; MCameraFPS *camera; MyEventReceiver *eventrecv; - ZThread::FastMutex mutex; uint32 map_gridX, map_gridY; WorldSession *wsession; World *world; diff --git a/src/Client/GUI/SceneCharselection.cpp b/src/Client/GUI/SceneCharselection.cpp index 12975c8..4a2cf2d 100644 --- a/src/Client/GUI/SceneCharselection.cpp +++ b/src/Client/GUI/SceneCharselection.cpp @@ -162,6 +162,7 @@ void SceneCharSelection::OnResize(void) GetStringFromDB(ISCENE_CHARSEL_BUTTONS, DSCENE_CHARSEL_BUTTON_DELCHAR).c_str()); realmwin = NULL; + mutex.acquire(); if(scenedata[ISCENE_CHARSEL_REALMFIRST]) { dimension2d dim; @@ -260,6 +261,7 @@ void SceneCharSelection::OnResize(void) } } + mutex.release(); } diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index 47e5fc6..c155f3e 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -701,7 +701,7 @@ void WorldSession::EnterWorldWithCharacter(std::string name) WorldPacket pkt(CMSG_PLAYER_LOGIN,8); pkt << _myGUID; - SendWorldPacket(pkt); + AddSendWorldPacket(pkt); // it can be called from gui thread also, use threadsafe version // close realm session when logging into world if(!MustDie() && _socket->IsOk() && GetInstance()->GetRSession()) diff --git a/src/Client/World/WorldSocket.cpp b/src/Client/World/WorldSocket.cpp index fee9d61..fd594a9 100644 --- a/src/Client/World/WorldSocket.cpp +++ b/src/Client/World/WorldSocket.cpp @@ -127,5 +127,6 @@ void WorldSocket::InitCrypt(BigNumber *k) { _crypt.SetKey(k); _crypt.Init(); - logdebug("WorldSocket: Crypt initialized"); + std::string tmp = toHexDump(_crypt.GetKey(),_crypt.GetKeySize(), false); + logdebug("WorldSocket: Crypt initialized [%s]",tmp.c_str()); } diff --git a/src/shared/Auth/AuthCrypt.h b/src/shared/Auth/AuthCrypt.h index d56cfec..0d84311 100644 --- a/src/shared/Auth/AuthCrypt.h +++ b/src/shared/Auth/AuthCrypt.h @@ -36,6 +36,8 @@ class AuthCrypt void Init(); void SetKey(BigNumber *); + inline uint8 *GetKey(void) { return &_key[0]; } + inline uint32 GetKeySize(void) { return _key.size(); } void DecryptRecv(uint8 *, size_t); void EncryptSend(uint8 *, size_t);