|
@@ -217,14 +217,29 @@ void FCKlient::setForegroundClient(SKlient* foreground)
|
|
|
zGameClient
|
|
|
= Game::INSTANCE->addPlayer(dynamic_cast<FCKlient*>(getThis()),
|
|
|
Framework::Text((int)accountId));
|
|
|
+ foregroundRunning = 1;
|
|
|
new AsynchronCall([this]() {
|
|
|
while (this->foreground->waitForNextMessage())
|
|
|
{
|
|
|
if (zGameClient) zGameClient->addMessage(foregroundReader);
|
|
|
if (!zGameClient) Sleep(100);
|
|
|
}
|
|
|
- zGameClient->logout();
|
|
|
- ls->removeKlient(this);
|
|
|
+ cs.lock();
|
|
|
+ foregroundRunning = 0;
|
|
|
+ if (!backgroundRunning)
|
|
|
+ {
|
|
|
+ cs.unlock();
|
|
|
+ if (zGameClient)
|
|
|
+ {
|
|
|
+ zGameClient->logout();
|
|
|
+ zGameClient = (GameClient*)zGameClient->release();
|
|
|
+ }
|
|
|
+ ls->removeKlient(this);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cs.unlock();
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -237,25 +252,44 @@ void FCKlient::setBackgroundClient(SKlient* background)
|
|
|
zGameClient
|
|
|
= Game::INSTANCE->addPlayer(dynamic_cast<FCKlient*>(getThis()),
|
|
|
Framework::Text((int)accountId));
|
|
|
+ backgroundRunning = 1;
|
|
|
new AsynchronCall([this]() {
|
|
|
while (this->background->waitForNextMessage())
|
|
|
{
|
|
|
if (zGameClient) zGameClient->addMessage(backgroundReader);
|
|
|
if (!zGameClient) Sleep(100);
|
|
|
}
|
|
|
- zGameClient->logout();
|
|
|
- ls->removeKlient(this);
|
|
|
+ cs.lock();
|
|
|
+ backgroundRunning = 0;
|
|
|
+ if (!foregroundRunning)
|
|
|
+ {
|
|
|
+ cs.unlock();
|
|
|
+ if (zGameClient)
|
|
|
+ {
|
|
|
+ zGameClient->logout();
|
|
|
+ zGameClient = (GameClient*)zGameClient->release();
|
|
|
+ }
|
|
|
+ ls->removeKlient(this);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cs.unlock();
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
void FCKlient::absturz()
|
|
|
{
|
|
|
- ende();
|
|
|
klient->trenne();
|
|
|
+ if (background) background->trenne();
|
|
|
+ if (foreground) foreground->trenne();
|
|
|
+ warteAufThread(10000);
|
|
|
+ ende();
|
|
|
}
|
|
|
|
|
|
void FCKlient::thread()
|
|
|
{
|
|
|
+ bool identified = 0;
|
|
|
while (1)
|
|
|
{
|
|
|
char c = 0;
|
|
@@ -296,6 +330,7 @@ void FCKlient::thread()
|
|
|
else
|
|
|
{
|
|
|
klient->sende("\1", 1);
|
|
|
+ identified = 1;
|
|
|
}
|
|
|
klient->sende((char*)&authKeyLen, 4);
|
|
|
klient->sende(authKey, authKeyLen);
|
|
@@ -342,6 +377,10 @@ void FCKlient::thread()
|
|
|
if (br) break;
|
|
|
}
|
|
|
}
|
|
|
+ if (!identified)
|
|
|
+ {
|
|
|
+ ls->removeKlient(this);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
int FCKlient::getAccountId() const // gibt die KlientId zurück
|