|
@@ -5,6 +5,7 @@
|
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
#include <Logging.h>
|
|
#include <Logging.h>
|
|
|
|
|
|
|
|
|
|
+#include "Game.h"
|
|
|
#include "PlayerRegister.h"
|
|
#include "PlayerRegister.h"
|
|
|
|
|
|
|
|
// Inhalt der LoginServer Klasse aus LoginServer.h
|
|
// Inhalt der LoginServer Klasse aus LoginServer.h
|
|
@@ -63,7 +64,7 @@ FactoryCraftServer::FactoryCraftServer(InitDatei* zIni)
|
|
|
klient->getNachricht((char*)&bg, 1);
|
|
klient->getNachricht((char*)&bg, 1);
|
|
|
klient->setEmpfangTimeout(0);
|
|
klient->setEmpfangTimeout(0);
|
|
|
bool found = 0;
|
|
bool found = 0;
|
|
|
- EnterCriticalSection(&cs);
|
|
|
|
|
|
|
+ cs.lock();
|
|
|
for (FCKlient* client : *klients)
|
|
for (FCKlient* client : *klients)
|
|
|
{
|
|
{
|
|
|
if (client->matchAuthKey(key, len))
|
|
if (client->matchAuthKey(key, len))
|
|
@@ -82,7 +83,7 @@ FactoryCraftServer::FactoryCraftServer(InitDatei* zIni)
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- LeaveCriticalSection(&cs);
|
|
|
|
|
|
|
+ cs.unlock();
|
|
|
if (!found)
|
|
if (!found)
|
|
|
{
|
|
{
|
|
|
klient->sende("\0", 1);
|
|
klient->sende("\0", 1);
|
|
@@ -93,7 +94,6 @@ FactoryCraftServer::FactoryCraftServer(InitDatei* zIni)
|
|
|
}
|
|
}
|
|
|
runningThreads--;
|
|
runningThreads--;
|
|
|
});
|
|
});
|
|
|
- InitializeCriticalSection(&cs);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Destruktor
|
|
// Destruktor
|
|
@@ -107,7 +107,6 @@ FactoryCraftServer::~FactoryCraftServer()
|
|
|
server->release();
|
|
server->release();
|
|
|
if (klients) klients->release();
|
|
if (klients) klients->release();
|
|
|
ini->release();
|
|
ini->release();
|
|
|
- DeleteCriticalSection(&cs);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// nicht constant
|
|
// nicht constant
|
|
@@ -121,9 +120,9 @@ void FactoryCraftServer::run()
|
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
|
FCKlient* clHandle = new FCKlient(
|
|
FCKlient* clHandle = new FCKlient(
|
|
|
klient, dynamic_cast<FactoryCraftServer*>(getThis()));
|
|
klient, dynamic_cast<FactoryCraftServer*>(getThis()));
|
|
|
- EnterCriticalSection(&cs);
|
|
|
|
|
|
|
+ cs.lock();
|
|
|
klients->add(clHandle);
|
|
klients->add(clHandle);
|
|
|
- LeaveCriticalSection(&cs);
|
|
|
|
|
|
|
+ cs.unlock();
|
|
|
clHandle->start();
|
|
clHandle->start();
|
|
|
}
|
|
}
|
|
|
runningThreads--;
|
|
runningThreads--;
|
|
@@ -134,17 +133,17 @@ void FactoryCraftServer::close()
|
|
|
Game::INSTANCE->save();
|
|
Game::INSTANCE->save();
|
|
|
sslServer->trenne();
|
|
sslServer->trenne();
|
|
|
server->trenne();
|
|
server->trenne();
|
|
|
- EnterCriticalSection(&cs);
|
|
|
|
|
|
|
+ cs.lock();
|
|
|
for (int i = 0; i < klients->getEintragAnzahl(); i++)
|
|
for (int i = 0; i < klients->getEintragAnzahl(); i++)
|
|
|
klients->z(i)->absturz();
|
|
klients->z(i)->absturz();
|
|
|
- LeaveCriticalSection(&cs);
|
|
|
|
|
|
|
+ cs.unlock();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool FactoryCraftServer::removeKlient(FCKlient* zKlient)
|
|
bool FactoryCraftServer::removeKlient(FCKlient* zKlient)
|
|
|
{
|
|
{
|
|
|
bool gefunden = 0;
|
|
bool gefunden = 0;
|
|
|
getThis();
|
|
getThis();
|
|
|
- EnterCriticalSection(&cs);
|
|
|
|
|
|
|
+ cs.lock();
|
|
|
for (int i = 0; i < klients->getEintragAnzahl(); i++)
|
|
for (int i = 0; i < klients->getEintragAnzahl(); i++)
|
|
|
{
|
|
{
|
|
|
if (klients->z(i) == zKlient)
|
|
if (klients->z(i) == zKlient)
|
|
@@ -154,7 +153,7 @@ bool FactoryCraftServer::removeKlient(FCKlient* zKlient)
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- LeaveCriticalSection(&cs);
|
|
|
|
|
|
|
+ cs.unlock();
|
|
|
release();
|
|
release();
|
|
|
return gefunden;
|
|
return gefunden;
|
|
|
}
|
|
}
|