|
@@ -2,6 +2,7 @@
|
|
|
#include <iostream>
|
|
|
#include <Klient.h>
|
|
|
#include <Globals.h>
|
|
|
+#include <Thread.h>
|
|
|
|
|
|
// Inhalt der LoginServer Klasse aus LoginServer.h
|
|
|
// Konstruktor
|
|
@@ -11,7 +12,6 @@ MinigameServer::MinigameServer( InitDatei* zIni )
|
|
|
Network::Start( 100 );
|
|
|
std::cout << "MS: Verbindung mit Datenbank wird hergestellt...\n";
|
|
|
db = new MSDatenbank( zIni );
|
|
|
- klientAnzahl = 0;
|
|
|
klients = new RCArray< MSKlient >();
|
|
|
empfangen = 0;
|
|
|
gesendet = 0;
|
|
@@ -87,8 +87,7 @@ void MinigameServer::thread()
|
|
|
Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
|
MSKlient* clHandle = new MSKlient( klient, dynamic_cast<MinigameServer*>(getThis()) );
|
|
|
EnterCriticalSection( &cs );
|
|
|
- klients->set( clHandle, klientAnzahl );
|
|
|
- klientAnzahl++;
|
|
|
+ klients->add( clHandle );
|
|
|
LeaveCriticalSection( &cs );
|
|
|
clHandle->start();
|
|
|
}
|
|
@@ -102,10 +101,9 @@ void MinigameServer::close()
|
|
|
warteAufThread( 1000 );
|
|
|
#endif
|
|
|
EnterCriticalSection( &cs );
|
|
|
- for( int i = 0; i < klientAnzahl; i++ )
|
|
|
+ for( int i = 0; i < klients->getEintragAnzahl(); i++ )
|
|
|
klients->z( i )->absturz();
|
|
|
klients = (RCArray<MSKlient>*)klients->release();
|
|
|
- klientAnzahl = 0;
|
|
|
LeaveCriticalSection( &cs );
|
|
|
ende();
|
|
|
run = 0;
|
|
@@ -208,13 +206,12 @@ bool MinigameServer::absturzKlient( int klientId )
|
|
|
{
|
|
|
bool gefunden = 0;
|
|
|
EnterCriticalSection( &cs );
|
|
|
- for( int i = 0; i < klientAnzahl; i++ )
|
|
|
+ for( int i = 0; i < klients->getEintragAnzahl(); i++ )
|
|
|
{
|
|
|
if( klients->z( i ) && klients->z( i )->getKlientNummer() == klientId )
|
|
|
{
|
|
|
klients->z( i )->absturz();
|
|
|
klients->remove( i );
|
|
|
- klientAnzahl--;
|
|
|
gefunden = 1;
|
|
|
break;
|
|
|
}
|
|
@@ -227,12 +224,11 @@ bool MinigameServer::removeKlient( MSKlient* zKlient )
|
|
|
{
|
|
|
bool gefunden = 0;
|
|
|
EnterCriticalSection( &cs );
|
|
|
- for( int i = 0; i < klientAnzahl; i++ )
|
|
|
+ for( int i = 0; i < klients->getEintragAnzahl(); i++ )
|
|
|
{
|
|
|
if( klients->z( i ) == zKlient )
|
|
|
{
|
|
|
klients->remove( i );
|
|
|
- klientAnzahl--;
|
|
|
gefunden = 1;
|
|
|
break;
|
|
|
}
|
|
@@ -269,7 +265,7 @@ MSDatenbank* MinigameServer::zDB() const
|
|
|
|
|
|
bool MinigameServer::hatClients() const
|
|
|
{
|
|
|
- return klientAnzahl > 0;
|
|
|
+ return klients->hat( 0 );
|
|
|
}
|
|
|
|
|
|
int MinigameServer::getId() const
|