|
@@ -7,1613 +7,1596 @@
|
|
// Inhalt der InformationServer Klasse aus InformationServer.h
|
|
// Inhalt der InformationServer Klasse aus InformationServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
InformationServer::InformationServer( InitDatei *zIni )
|
|
InformationServer::InformationServer( InitDatei *zIni )
|
|
- : Thread()
|
|
|
|
|
|
+ : Thread()
|
|
{
|
|
{
|
|
- Network::Start( 100 );
|
|
|
|
- std::cout << "IS: Verbindung mit Datenbank wird hergestellt...\n";
|
|
|
|
- db = new ISDatenbank( zIni );
|
|
|
|
- klientAnzahl = 0;
|
|
|
|
- klients = new RCArray< ISKlient >();
|
|
|
|
- empfangen = 0;
|
|
|
|
- gesendet = 0;
|
|
|
|
- fehler = new Text();
|
|
|
|
- ini = zIni->getThis();
|
|
|
|
- id = *zIni->zWert( "ServerId" );
|
|
|
|
- server = new Server();
|
|
|
|
- aServer = new SSLServer();
|
|
|
|
|
|
+ Network::Start( 100 );
|
|
|
|
+ std::cout << "IS: Verbindung mit Datenbank wird hergestellt...\n";
|
|
|
|
+ db = new ISDatenbank( zIni );
|
|
|
|
+ klientAnzahl = 0;
|
|
|
|
+ klients = new RCArray< ISKlient >();
|
|
|
|
+ empfangen = 0;
|
|
|
|
+ gesendet = 0;
|
|
|
|
+ fehler = new Text();
|
|
|
|
+ ini = zIni->getThis();
|
|
|
|
+ id = *zIni->zWert( "ServerId" );
|
|
|
|
+ server = new Server();
|
|
|
|
+ aServer = new SSLServer();
|
|
aServer->setPrivateKeyPassword( zIni->zWert( "SSLPasswort" )->getText() );
|
|
aServer->setPrivateKeyPassword( zIni->zWert( "SSLPasswort" )->getText() );
|
|
aServer->setCertificateFile( zIni->zWert( "SSLCert" )->getText() );
|
|
aServer->setCertificateFile( zIni->zWert( "SSLCert" )->getText() );
|
|
aServer->setPrivateKeyFile( zIni->zWert( "SSLKey" )->getText() );
|
|
aServer->setPrivateKeyFile( zIni->zWert( "SSLKey" )->getText() );
|
|
- std::cout << "IS: Starten des Admin Servers...\n";
|
|
|
|
- if( !aServer->verbinde( (unsigned short)TextZuInt( ini->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
|
|
|
|
- {
|
|
|
|
- std::cout << "IS: Der Admin Server konnte nicht gestartet werden. Das Programm wird beendet.\n";
|
|
|
|
- exit( 1 );
|
|
|
|
- }
|
|
|
|
- db->setServerStatus( id, 2 );
|
|
|
|
- end = 0;
|
|
|
|
- nichtPausiert = 0;
|
|
|
|
- InitializeCriticalSection( &cs );
|
|
|
|
- ref = 1;
|
|
|
|
- if( zIni->zWert( "Aktiv" )->istGleich( "TRUE" ) )
|
|
|
|
- {
|
|
|
|
- serverStarten();
|
|
|
|
- serverFortsetzen();
|
|
|
|
- }
|
|
|
|
|
|
+ std::cout << "IS: Starten des Admin Servers...\n";
|
|
|
|
+ if( !aServer->verbinde( (unsigned short)TextZuInt( ini->zWert( "AdminServerPort" )->getText(), 10 ), 10 ) )
|
|
|
|
+ {
|
|
|
|
+ std::cout << "IS: Der Admin Server konnte nicht gestartet werden. Das Programm wird beendet.\n";
|
|
|
|
+ exit( 1 );
|
|
|
|
+ }
|
|
|
|
+ db->setServerStatus( id, 2 );
|
|
|
|
+ end = 0;
|
|
|
|
+ nichtPausiert = 0;
|
|
|
|
+ InitializeCriticalSection( &cs );
|
|
|
|
+ if( zIni->zWert( "Aktiv" )->istGleich( "TRUE" ) )
|
|
|
|
+ {
|
|
|
|
+ serverStarten();
|
|
|
|
+ serverFortsetzen();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
// Destruktor
|
|
InformationServer::~InformationServer()
|
|
InformationServer::~InformationServer()
|
|
{
|
|
{
|
|
- fehler->release();
|
|
|
|
- server->trenne();
|
|
|
|
- server->release();
|
|
|
|
- aServer->trenne();
|
|
|
|
- aServer->release();
|
|
|
|
- if( klients )
|
|
|
|
- klients->release();
|
|
|
|
- ini->release();
|
|
|
|
- db->release();
|
|
|
|
- DeleteCriticalSection( &cs );
|
|
|
|
|
|
+ fehler->release();
|
|
|
|
+ server->trenne();
|
|
|
|
+ server->release();
|
|
|
|
+ aServer->trenne();
|
|
|
|
+ aServer->release();
|
|
|
|
+ if( klients )
|
|
|
|
+ klients->release();
|
|
|
|
+ ini->release();
|
|
|
|
+ db->release();
|
|
|
|
+ DeleteCriticalSection( &cs );
|
|
}
|
|
}
|
|
|
|
|
|
// nicht constant
|
|
// nicht constant
|
|
void InformationServer::runn()
|
|
void InformationServer::runn()
|
|
{
|
|
{
|
|
- while( !end && aServer->isConnected() )
|
|
|
|
- {
|
|
|
|
- SSLSKlient *klient;
|
|
|
|
- klient = aServer->getKlient();
|
|
|
|
- if( end && klient )
|
|
|
|
- {
|
|
|
|
- klient->trenne();
|
|
|
|
- klient = klient->release();
|
|
|
|
- Sleep( 1000 );
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if( !klient )
|
|
|
|
- continue;
|
|
|
|
- ISAKlient *clHandle = new ISAKlient( klient, getThis() );
|
|
|
|
- clHandle->start();
|
|
|
|
- }
|
|
|
|
|
|
+ while( !end && aServer->isConnected() )
|
|
|
|
+ {
|
|
|
|
+ SSLSKlient *klient;
|
|
|
|
+ klient = aServer->getKlient();
|
|
|
|
+ if( end && klient )
|
|
|
|
+ {
|
|
|
|
+ klient->trenne();
|
|
|
|
+ klient = klient->release();
|
|
|
|
+ Sleep( 1000 );
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if( !klient )
|
|
|
|
+ continue;
|
|
|
|
+ ISAKlient * clHandle = new ISAKlient( klient, (InformationServer *)getThis() );
|
|
|
|
+ clHandle->start();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void InformationServer::thread()
|
|
void InformationServer::thread()
|
|
{
|
|
{
|
|
- while( server->isConnected() )
|
|
|
|
- {
|
|
|
|
- SKlient *klient;
|
|
|
|
- klient = server->getKlient();
|
|
|
|
- if( !klient )
|
|
|
|
- continue;
|
|
|
|
- Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
|
|
- ISKlient *clHandle = new ISKlient( klient, getThis() );
|
|
|
|
- EnterCriticalSection( &cs );
|
|
|
|
- klients->set( clHandle, klientAnzahl );
|
|
|
|
- klientAnzahl++;
|
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
|
- clHandle->start();
|
|
|
|
- }
|
|
|
|
|
|
+ while( server->isConnected() )
|
|
|
|
+ {
|
|
|
|
+ SKlient *klient;
|
|
|
|
+ klient = server->getKlient();
|
|
|
|
+ if( !klient )
|
|
|
|
+ continue;
|
|
|
|
+ Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
|
|
+ ISKlient * clHandle = new ISKlient( klient, (InformationServer *)getThis() );
|
|
|
|
+ EnterCriticalSection( &cs );
|
|
|
|
+ klients->set( clHandle, klientAnzahl );
|
|
|
|
+ klientAnzahl++;
|
|
|
|
+ LeaveCriticalSection( &cs );
|
|
|
|
+ clHandle->start();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void InformationServer::close()
|
|
void InformationServer::close()
|
|
{
|
|
{
|
|
- db->setServerStatus( id, 1 );
|
|
|
|
- server->trenne();
|
|
|
|
|
|
+ db->setServerStatus( id, 1 );
|
|
|
|
+ server->trenne();
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
- warteAufThread( 1000 );
|
|
|
|
|
|
+ warteAufThread( 1000 );
|
|
#endif
|
|
#endif
|
|
- EnterCriticalSection( &cs );
|
|
|
|
- for( int i = 0; i < klientAnzahl; i++ )
|
|
|
|
- klients->z( i )->absturz();
|
|
|
|
- klients = klients->release();
|
|
|
|
- klientAnzahl = 0;
|
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
|
- ende();
|
|
|
|
- run = 0;
|
|
|
|
- end = 1;
|
|
|
|
- Klient *klient = new Klient();
|
|
|
|
- klient->verbinde( aServer->getPort(), "127.0.0.1" );
|
|
|
|
- Sleep( 500 );
|
|
|
|
- aServer->trenne();
|
|
|
|
- klient->release();
|
|
|
|
|
|
+ EnterCriticalSection( &cs );
|
|
|
|
+ for( int i = 0; i < klientAnzahl; i++ )
|
|
|
|
+ klients->z( i )->absturz();
|
|
|
|
+ klients = klients->release();
|
|
|
|
+ klientAnzahl = 0;
|
|
|
|
+ LeaveCriticalSection( &cs );
|
|
|
|
+ ende();
|
|
|
|
+ run = 0;
|
|
|
|
+ end = 1;
|
|
|
|
+ Klient * klient = new Klient();
|
|
|
|
+ klient->verbinde( aServer->getPort(), "127.0.0.1" );
|
|
|
|
+ Sleep( 500 );
|
|
|
|
+ aServer->trenne();
|
|
|
|
+ klient->release();
|
|
}
|
|
}
|
|
|
|
|
|
bool InformationServer::serverStarten()
|
|
bool InformationServer::serverStarten()
|
|
{
|
|
{
|
|
- if( nichtPausiert )
|
|
|
|
- {
|
|
|
|
- fehler->setText( "Der Server konnte nicht gestartet werden: Der Server läuft bereits." );
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- if( server )
|
|
|
|
- server->release();
|
|
|
|
- server = new Server();
|
|
|
|
- if( server->verbinde( (unsigned short)TextZuInt( ini->zWert( "ServerPort" )->getText(), 10 ), 10 ) )
|
|
|
|
- {
|
|
|
|
- nichtPausiert = 1;
|
|
|
|
- start();
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- serverBeenden();
|
|
|
|
- fehler->setText( "Der Server konnte nicht gestartet werden: Eventuell ist der Port in benutzung." );
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
|
|
+ if( nichtPausiert )
|
|
|
|
+ {
|
|
|
|
+ fehler->setText( "Der Server konnte nicht gestartet werden: Der Server läuft bereits." );
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ if( server )
|
|
|
|
+ server->release();
|
|
|
|
+ server = new Server();
|
|
|
|
+ if( server->verbinde( (unsigned short)TextZuInt( ini->zWert( "ServerPort" )->getText(), 10 ), 10 ) )
|
|
|
|
+ {
|
|
|
|
+ nichtPausiert = 1;
|
|
|
|
+ start();
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ serverBeenden();
|
|
|
|
+ fehler->setText( "Der Server konnte nicht gestartet werden: Eventuell ist der Port in benutzung." );
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
bool InformationServer::serverPause()
|
|
bool InformationServer::serverPause()
|
|
{
|
|
{
|
|
- if( !nichtPausiert )
|
|
|
|
- {
|
|
|
|
- fehler->setText( "Der Server konnte nicht pausiert werden: Der Server läuft nicht." );
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- if( !db->setServerStatus( id, 2 ) )
|
|
|
|
- {
|
|
|
|
- fehler->setText( "Der Server konnte nicht pausiert werden: " );
|
|
|
|
- fehler->append( db->getLetzterFehler() );
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- return 1;
|
|
|
|
|
|
+ if( !nichtPausiert )
|
|
|
|
+ {
|
|
|
|
+ fehler->setText( "Der Server konnte nicht pausiert werden: Der Server läuft nicht." );
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ if( !db->setServerStatus( id, 2 ) )
|
|
|
|
+ {
|
|
|
|
+ fehler->setText( "Der Server konnte nicht pausiert werden: " );
|
|
|
|
+ fehler->append( db->getLetzterFehler() );
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
}
|
|
}
|
|
|
|
|
|
bool InformationServer::serverFortsetzen()
|
|
bool InformationServer::serverFortsetzen()
|
|
{
|
|
{
|
|
- if( !nichtPausiert )
|
|
|
|
- {
|
|
|
|
- fehler->setText( "Der Server konnte nicht fortgesetzt werden: Der Server läuft nicht." );
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- if( !db->setServerStatus( id, 3 ) )
|
|
|
|
- {
|
|
|
|
- fehler->setText( "Der Server konnte nicht fortgesetzt werden: " );
|
|
|
|
- fehler->append( db->getLetzterFehler() );
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- return 1;
|
|
|
|
|
|
+ if( !nichtPausiert )
|
|
|
|
+ {
|
|
|
|
+ fehler->setText( "Der Server konnte nicht fortgesetzt werden: Der Server läuft nicht." );
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ if( !db->setServerStatus( id, 3 ) )
|
|
|
|
+ {
|
|
|
|
+ fehler->setText( "Der Server konnte nicht fortgesetzt werden: " );
|
|
|
|
+ fehler->append( db->getLetzterFehler() );
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
}
|
|
}
|
|
|
|
|
|
bool InformationServer::serverBeenden()
|
|
bool InformationServer::serverBeenden()
|
|
{
|
|
{
|
|
- if( !nichtPausiert )
|
|
|
|
- {
|
|
|
|
- fehler->setText( "Der Server konnte nicht beendet werden: Der Server läuft nicht." );
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- if( db->serverIstNichtPausiert( id ) )
|
|
|
|
- {
|
|
|
|
- fehler->setText( "Der Server konnte nicht beendet werden: Der Server muss erst pausiert werden." );
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- nichtPausiert = 0;
|
|
|
|
- ende();
|
|
|
|
- if( server )
|
|
|
|
- server->trenne();
|
|
|
|
- return 1;
|
|
|
|
|
|
+ if( !nichtPausiert )
|
|
|
|
+ {
|
|
|
|
+ fehler->setText( "Der Server konnte nicht beendet werden: Der Server läuft nicht." );
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ if( db->serverIstNichtPausiert( id ) )
|
|
|
|
+ {
|
|
|
|
+ fehler->setText( "Der Server konnte nicht beendet werden: Der Server muss erst pausiert werden." );
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ nichtPausiert = 0;
|
|
|
|
+ ende();
|
|
|
|
+ if( server )
|
|
|
|
+ server->trenne();
|
|
|
|
+ return 1;
|
|
}
|
|
}
|
|
|
|
|
|
bool InformationServer::setMaxKlients( int mc )
|
|
bool InformationServer::setMaxKlients( int mc )
|
|
{
|
|
{
|
|
- if( !db->setMaxClients( id, mc ) )
|
|
|
|
- {
|
|
|
|
- fehler->setText( "Die maximale Anzahl der Clients konnte nicht gesetzt werden:\n" );
|
|
|
|
- fehler->append( db->getLetzterFehler() );
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- ini->setWert( "MaxClients", Text() += mc );
|
|
|
|
- return 1;
|
|
|
|
|
|
+ if( !db->setMaxClients( id, mc ) )
|
|
|
|
+ {
|
|
|
|
+ fehler->setText( "Die maximale Anzahl der Clients konnte nicht gesetzt werden:\n" );
|
|
|
|
+ fehler->append( db->getLetzterFehler() );
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ ini->setWert( "MaxClients", Text() += mc );
|
|
|
|
+ return 1;
|
|
}
|
|
}
|
|
|
|
|
|
bool InformationServer::absturzKlient( int klientId )
|
|
bool InformationServer::absturzKlient( int klientId )
|
|
{
|
|
{
|
|
- bool gefunden = 0;
|
|
|
|
- EnterCriticalSection( &cs );
|
|
|
|
- for( int i = 0; i < klientAnzahl; i++ )
|
|
|
|
- {
|
|
|
|
- if( klients->z( i )->getKlientNummer() == klientId )
|
|
|
|
- {
|
|
|
|
- klients->z( i )->absturz();
|
|
|
|
- klients->remove( i );
|
|
|
|
- klientAnzahl--;
|
|
|
|
- gefunden = 1;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
|
- return gefunden;
|
|
|
|
|
|
+ bool gefunden = 0;
|
|
|
|
+ EnterCriticalSection( &cs );
|
|
|
|
+ for( int i = 0; i < klientAnzahl; i++ )
|
|
|
|
+ {
|
|
|
|
+ if( klients->z( i )->getKlientNummer() == klientId )
|
|
|
|
+ {
|
|
|
|
+ klients->z( i )->absturz();
|
|
|
|
+ klients->remove( i );
|
|
|
|
+ klientAnzahl--;
|
|
|
|
+ gefunden = 1;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ LeaveCriticalSection( &cs );
|
|
|
|
+ return gefunden;
|
|
}
|
|
}
|
|
|
|
|
|
-bool InformationServer::removeKlient( ISKlient *zKlient )
|
|
|
|
|
|
+bool InformationServer::removeKlient( ISKlient * zKlient )
|
|
{
|
|
{
|
|
- bool gefunden = 0;
|
|
|
|
- EnterCriticalSection( &cs );
|
|
|
|
- for( int i = 0; i < klientAnzahl; i++ )
|
|
|
|
- {
|
|
|
|
- if( klients->z( i ) == zKlient )
|
|
|
|
- {
|
|
|
|
- klients->remove( i );
|
|
|
|
- klientAnzahl--;
|
|
|
|
- gefunden = 1;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
|
- return gefunden;
|
|
|
|
|
|
+ bool gefunden = 0;
|
|
|
|
+ EnterCriticalSection( &cs );
|
|
|
|
+ for( int i = 0; i < klientAnzahl; i++ )
|
|
|
|
+ {
|
|
|
|
+ if( klients->z( i ) == zKlient )
|
|
|
|
+ {
|
|
|
|
+ klients->remove( i );
|
|
|
|
+ klientAnzahl--;
|
|
|
|
+ gefunden = 1;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ LeaveCriticalSection( &cs );
|
|
|
|
+ return gefunden;
|
|
}
|
|
}
|
|
|
|
|
|
void InformationServer::addGesendet( int bytes )
|
|
void InformationServer::addGesendet( int bytes )
|
|
{
|
|
{
|
|
- gesendet += bytes;
|
|
|
|
|
|
+ gesendet += bytes;
|
|
}
|
|
}
|
|
|
|
|
|
void InformationServer::addEmpfangen( int bytes )
|
|
void InformationServer::addEmpfangen( int bytes )
|
|
{
|
|
{
|
|
- empfangen += bytes;
|
|
|
|
|
|
+ empfangen += bytes;
|
|
}
|
|
}
|
|
|
|
|
|
// constant
|
|
// constant
|
|
bool InformationServer::istAn() const
|
|
bool InformationServer::istAn() const
|
|
{
|
|
{
|
|
- return db->serverIstNichtPausiert( id );
|
|
|
|
|
|
+ return db->serverIstNichtPausiert( id );
|
|
}
|
|
}
|
|
|
|
|
|
Server *InformationServer::zServer() const
|
|
Server *InformationServer::zServer() const
|
|
{
|
|
{
|
|
- return server;
|
|
|
|
|
|
+ return server;
|
|
}
|
|
}
|
|
|
|
|
|
ISDatenbank *InformationServer::zDB() const
|
|
ISDatenbank *InformationServer::zDB() const
|
|
{
|
|
{
|
|
- return db;
|
|
|
|
|
|
+ return db;
|
|
}
|
|
}
|
|
|
|
|
|
bool InformationServer::hatClients() const
|
|
bool InformationServer::hatClients() const
|
|
{
|
|
{
|
|
- return klientAnzahl > 0;
|
|
|
|
|
|
+ return klientAnzahl > 0;
|
|
}
|
|
}
|
|
|
|
|
|
int InformationServer::getId() const
|
|
int InformationServer::getId() const
|
|
{
|
|
{
|
|
- return id;
|
|
|
|
|
|
+ return id;
|
|
}
|
|
}
|
|
|
|
|
|
char *InformationServer::getLetzterFehler() const
|
|
char *InformationServer::getLetzterFehler() const
|
|
{
|
|
{
|
|
- return fehler->getText();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Reference Counting
|
|
|
|
-InformationServer *InformationServer::getThis()
|
|
|
|
-{
|
|
|
|
- ref++;
|
|
|
|
- return this;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-InformationServer *InformationServer::release()
|
|
|
|
-{
|
|
|
|
- ref--;
|
|
|
|
- if( !ref )
|
|
|
|
- delete this;
|
|
|
|
- return 0;
|
|
|
|
|
|
+ return fehler->getText();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
// Inhalt der ISAKlient Klasse aus InformationServer.h
|
|
// Inhalt der ISAKlient Klasse aus InformationServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-ISAKlient::ISAKlient( SSLSKlient *klient, InformationServer *is )
|
|
|
|
- : Thread()
|
|
|
|
|
|
+ISAKlient::ISAKlient( SSLSKlient * klient, InformationServer * is )
|
|
|
|
+ : Thread()
|
|
{
|
|
{
|
|
- this->klient = klient;
|
|
|
|
- name = new Text( "" );
|
|
|
|
- passwort = new Text( "" );
|
|
|
|
- adminId = 0;
|
|
|
|
- this->is = is;
|
|
|
|
|
|
+ this->klient = klient;
|
|
|
|
+ name = new Text( "" );
|
|
|
|
+ passwort = new Text( "" );
|
|
|
|
+ adminId = 0;
|
|
|
|
+ this->is = is;
|
|
}
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
// Destruktor
|
|
ISAKlient::~ISAKlient()
|
|
ISAKlient::~ISAKlient()
|
|
{
|
|
{
|
|
- klient->trenne();
|
|
|
|
- klient->release();
|
|
|
|
- is->release();
|
|
|
|
- name->release();
|
|
|
|
- passwort->release();
|
|
|
|
|
|
+ klient->trenne();
|
|
|
|
+ klient->release();
|
|
|
|
+ is->release();
|
|
|
|
+ name->release();
|
|
|
|
+ passwort->release();
|
|
}
|
|
}
|
|
|
|
|
|
// nicht constant
|
|
// nicht constant
|
|
void ISAKlient::thread()
|
|
void ISAKlient::thread()
|
|
{
|
|
{
|
|
- while( 1 )
|
|
|
|
- {
|
|
|
|
- char c = 0;
|
|
|
|
- if( !klient->getNachricht( &c, 1 ) )
|
|
|
|
- break;
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- bool br = 0;
|
|
|
|
- switch( c )
|
|
|
|
- {
|
|
|
|
- case 1: // Login
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- unsigned char nLen = 0;
|
|
|
|
- klient->getNachricht( (char*)&nLen, 1 );
|
|
|
|
- char *n = new char[ nLen + 1 ];
|
|
|
|
- n[ (int)nLen ] = 0;
|
|
|
|
- if( nLen )
|
|
|
|
- klient->getNachricht( n, nLen );
|
|
|
|
- unsigned char pLen = 0;
|
|
|
|
- klient->getNachricht( (char*)&pLen, 1 );
|
|
|
|
- char *p = new char[ pLen + 1 ];
|
|
|
|
- p[ (int)pLen ] = 0;
|
|
|
|
- if( pLen )
|
|
|
|
- klient->getNachricht( p, pLen );
|
|
|
|
- int adminId = is->zDB()->istAdministrator( n, p );
|
|
|
|
- if( adminId )
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- name->setText( n );
|
|
|
|
- passwort->setText( p );
|
|
|
|
- this->adminId = adminId;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Falsche Kombination aus Name und Passwort." );
|
|
|
|
- delete[] n;
|
|
|
|
- delete[] p;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 2: // Logout
|
|
|
|
- adminId = 0;
|
|
|
|
- name->setText( "" );
|
|
|
|
- passwort->setText( "" );
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- break;
|
|
|
|
- case 3: // Trennen
|
|
|
|
- br = 1;
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- break;
|
|
|
|
- case 4: // Server starten
|
|
|
|
- if( !adminId )
|
|
|
|
- errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISStarten ) )
|
|
|
|
- {
|
|
|
|
- if( !is->serverStarten() )
|
|
|
|
- {
|
|
|
|
- Text *err = new Text();
|
|
|
|
- err->append( is->getLetzterFehler() );
|
|
|
|
- errorZuKlient( err->getText() );
|
|
|
|
- err->release();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht berechtigt den Server zu starten." );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 5: // Server beenden
|
|
|
|
- if( !adminId )
|
|
|
|
- errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISBeenden ) )
|
|
|
|
- {
|
|
|
|
- if( is->serverBeenden() )
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- Text *err = new Text();
|
|
|
|
- err->append( is->getLetzterFehler() );
|
|
|
|
- errorZuKlient( err->getText() );
|
|
|
|
- err->release();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 6: // Programm Schließen
|
|
|
|
- if( !adminId )
|
|
|
|
- errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- bool ok = 0;
|
|
|
|
- if( is->isRunning() )
|
|
|
|
- {
|
|
|
|
- if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISBeenden ) )
|
|
|
|
- {
|
|
|
|
- if( is->serverBeenden() )
|
|
|
|
- ok = 1;
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- Text *err = new Text();
|
|
|
|
- err->append( is->getLetzterFehler() );
|
|
|
|
- errorZuKlient( err->getText() );
|
|
|
|
- err->release();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- ok = 1;
|
|
|
|
- if( ok && is->hatClients() )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if( ok )
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- std::cout << "IS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
|
|
- is->close();
|
|
|
|
- br = 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 7: // Progtamm abstürzen
|
|
|
|
- if( !adminId )
|
|
|
|
- errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- bool ok = 0;
|
|
|
|
- if( is->isRunning() )
|
|
|
|
- {
|
|
|
|
- if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISBeenden ) )
|
|
|
|
- {
|
|
|
|
- is->serverBeenden();
|
|
|
|
- ok = 1;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- ok = 1;
|
|
|
|
- if( ok )
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- std::cout << "IS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
|
|
- is->close();
|
|
|
|
- br = 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 8: // Status Frage
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- char status = 0;
|
|
|
|
- if( is->isRunning() )
|
|
|
|
- {
|
|
|
|
- status = 1;
|
|
|
|
- if( is->istAn() )
|
|
|
|
- status = 2;
|
|
|
|
- }
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- klient->sende( &status, 1 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 9: // Server pausieren
|
|
|
|
- if( !adminId )
|
|
|
|
- errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- char pause = 0;
|
|
|
|
- klient->getNachricht( &pause, 1 );
|
|
|
|
- if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISPausieren ) )
|
|
|
|
- {
|
|
|
|
- bool ok = 0;
|
|
|
|
- if( pause )
|
|
|
|
- ok = is->serverPause();
|
|
|
|
- else
|
|
|
|
- ok = is->serverFortsetzen();
|
|
|
|
- if( ok )
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- Text *err = new Text();
|
|
|
|
- err->append( is->getLetzterFehler() );
|
|
|
|
- errorZuKlient( err->getText() );
|
|
|
|
- err->release();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if( pause )
|
|
|
|
- errorZuKlient( "Du bist nicht berechtigt den Server zu pausieren." );
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht berechtigt den Server fortzusetzen." );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0xA: // maximale Anzahl der Clients setzen
|
|
|
|
- if( !adminId )
|
|
|
|
- errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- int maxC = 0;
|
|
|
|
- klient->getNachricht( (char*)&maxC, 4 );
|
|
|
|
- if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISMCChange ) )
|
|
|
|
- {
|
|
|
|
- if( is->setMaxKlients( maxC ) )
|
|
|
|
- klient->sende( "\1", 1 );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- Text *err = new Text();
|
|
|
|
- err->append( is->getLetzterFehler() );
|
|
|
|
- errorZuKlient( err->getText() );
|
|
|
|
- err->release();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht berechtigt die maximale Anzahl der Clients zu verändern." );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ while( 1 )
|
|
|
|
+ {
|
|
|
|
+ char c = 0;
|
|
|
|
+ if( !klient->getNachricht( &c, 1 ) )
|
|
|
|
+ break;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ bool br = 0;
|
|
|
|
+ switch( c )
|
|
|
|
+ {
|
|
|
|
+ case 1: // Login
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ unsigned char nLen = 0;
|
|
|
|
+ klient->getNachricht( (char *)& nLen, 1 );
|
|
|
|
+ char *n = new char[ nLen + 1 ];
|
|
|
|
+ n[ (int)nLen ] = 0;
|
|
|
|
+ if( nLen )
|
|
|
|
+ klient->getNachricht( n, nLen );
|
|
|
|
+ unsigned char pLen = 0;
|
|
|
|
+ klient->getNachricht( (char *)& pLen, 1 );
|
|
|
|
+ char *p = new char[ pLen + 1 ];
|
|
|
|
+ p[ (int)pLen ] = 0;
|
|
|
|
+ if( pLen )
|
|
|
|
+ klient->getNachricht( p, pLen );
|
|
|
|
+ int adminId = is->zDB()->istAdministrator( n, p );
|
|
|
|
+ if( adminId )
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ name->setText( n );
|
|
|
|
+ passwort->setText( p );
|
|
|
|
+ this->adminId = adminId;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Falsche Kombination aus Name und Passwort." );
|
|
|
|
+ delete[] n;
|
|
|
|
+ delete[] p;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 2: // Logout
|
|
|
|
+ adminId = 0;
|
|
|
|
+ name->setText( "" );
|
|
|
|
+ passwort->setText( "" );
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ break;
|
|
|
|
+ case 3: // Trennen
|
|
|
|
+ br = 1;
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ break;
|
|
|
|
+ case 4: // Server starten
|
|
|
|
+ if( !adminId )
|
|
|
|
+ errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISStarten ) )
|
|
|
|
+ {
|
|
|
|
+ if( !is->serverStarten() )
|
|
|
|
+ {
|
|
|
|
+ Text *err = new Text();
|
|
|
|
+ err->append( is->getLetzterFehler() );
|
|
|
|
+ errorZuKlient( err->getText() );
|
|
|
|
+ err->release();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht berechtigt den Server zu starten." );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 5: // Server beenden
|
|
|
|
+ if( !adminId )
|
|
|
|
+ errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISBeenden ) )
|
|
|
|
+ {
|
|
|
|
+ if( is->serverBeenden() )
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Text *err = new Text();
|
|
|
|
+ err->append( is->getLetzterFehler() );
|
|
|
|
+ errorZuKlient( err->getText() );
|
|
|
|
+ err->release();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 6: // Programm Schließen
|
|
|
|
+ if( !adminId )
|
|
|
|
+ errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ bool ok = 0;
|
|
|
|
+ if( is->isRunning() )
|
|
|
|
+ {
|
|
|
|
+ if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISBeenden ) )
|
|
|
|
+ {
|
|
|
|
+ if( is->serverBeenden() )
|
|
|
|
+ ok = 1;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Text *err = new Text();
|
|
|
|
+ err->append( is->getLetzterFehler() );
|
|
|
|
+ errorZuKlient( err->getText() );
|
|
|
|
+ err->release();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ ok = 1;
|
|
|
|
+ if( ok &&is->hatClients() )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if( ok )
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ std::cout << "IS: Der Server wird von Benutzer " << adminId << " heruntergefahren.\n";
|
|
|
|
+ is->close();
|
|
|
|
+ br = 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 7: // Progtamm abstürzen
|
|
|
|
+ if( !adminId )
|
|
|
|
+ errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ bool ok = 0;
|
|
|
|
+ if( is->isRunning() )
|
|
|
|
+ {
|
|
|
|
+ if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISBeenden ) )
|
|
|
|
+ {
|
|
|
|
+ is->serverBeenden();
|
|
|
|
+ ok = 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht berechtigt den Server zu beenden." );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ ok = 1;
|
|
|
|
+ if( ok )
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ std::cout << "IS: Der Server wurde von Benutzer " << adminId << " terminiert.\n";
|
|
|
|
+ is->close();
|
|
|
|
+ br = 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 8: // Status Frage
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ char status = 0;
|
|
|
|
+ if( is->isRunning() )
|
|
|
|
+ {
|
|
|
|
+ status = 1;
|
|
|
|
+ if( is->istAn() )
|
|
|
|
+ status = 2;
|
|
|
|
+ }
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ klient->sende( &status, 1 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 9: // Server pausieren
|
|
|
|
+ if( !adminId )
|
|
|
|
+ errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ char pause = 0;
|
|
|
|
+ klient->getNachricht( &pause, 1 );
|
|
|
|
+ if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISPausieren ) )
|
|
|
|
+ {
|
|
|
|
+ bool ok = 0;
|
|
|
|
+ if( pause )
|
|
|
|
+ ok = is->serverPause();
|
|
|
|
+ else
|
|
|
|
+ ok = is->serverFortsetzen();
|
|
|
|
+ if( ok )
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Text *err = new Text();
|
|
|
|
+ err->append( is->getLetzterFehler() );
|
|
|
|
+ errorZuKlient( err->getText() );
|
|
|
|
+ err->release();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if( pause )
|
|
|
|
+ errorZuKlient( "Du bist nicht berechtigt den Server zu pausieren." );
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht berechtigt den Server fortzusetzen." );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0xA: // maximale Anzahl der Clients setzen
|
|
|
|
+ if( !adminId )
|
|
|
|
+ errorZuKlient( "Du musst dich einloggen." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ int maxC = 0;
|
|
|
|
+ klient->getNachricht( (char *)& maxC, 4 );
|
|
|
|
+ if( is->zDB()->adminHatRecht( adminId, Admin_Recht::ISMCChange ) )
|
|
|
|
+ {
|
|
|
|
+ if( is->setMaxKlients( maxC ) )
|
|
|
|
+ klient->sende( "\1", 1 );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Text *err = new Text();
|
|
|
|
+ err->append( is->getLetzterFehler() );
|
|
|
|
+ errorZuKlient( err->getText() );
|
|
|
|
+ err->release();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht berechtigt die maximale Anzahl der Clients zu verändern." );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
case 0xC: // klient absturtz
|
|
case 0xC: // klient absturtz
|
|
if( 1 )
|
|
if( 1 )
|
|
{
|
|
{
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
int klientId = 0;
|
|
int klientId = 0;
|
|
- klient->getNachricht( (char*)&klientId, 4 );
|
|
|
|
- if( klientId && is->absturzKlient( klientId ) )
|
|
|
|
|
|
+ klient->getNachricht( (char *)& klientId, 4 );
|
|
|
|
+ if( klientId &&is->absturzKlient( klientId ) )
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
klient->sende( "\0", 1 );
|
|
klient->sende( "\0", 1 );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
- default:
|
|
|
|
- errorZuKlient( "Unbekannte Nachricht!" );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if( br )
|
|
|
|
- break;
|
|
|
|
- is->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- is->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- is->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- is->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- delete this;
|
|
|
|
|
|
+ default:
|
|
|
|
+ errorZuKlient( "Unbekannte Nachricht!" );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if( br )
|
|
|
|
+ break;
|
|
|
|
+ is->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ is->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ is->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ is->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ delete this;
|
|
}
|
|
}
|
|
|
|
|
|
void ISAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
void ISAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
{
|
|
{
|
|
- klient->sende( "\3", 1 );
|
|
|
|
- char len = (char)textLength( nachricht );
|
|
|
|
- klient->sende( &len, 1 );
|
|
|
|
- klient->sende( nachricht, len );
|
|
|
|
|
|
+ klient->sende( "\3", 1 );
|
|
|
|
+ char len = (char)textLength( nachricht );
|
|
|
|
+ klient->sende( &len, 1 );
|
|
|
|
+ klient->sende( nachricht, len );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
// Inhalt der ISKlient aus InformationServer.h
|
|
// Inhalt der ISKlient aus InformationServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-ISKlient::ISKlient( SKlient *klient, InformationServer *is )
|
|
|
|
- : Thread()
|
|
|
|
|
|
+ISKlient::ISKlient( SKlient * klient, InformationServer * is )
|
|
|
|
+ : Thread()
|
|
{
|
|
{
|
|
- this->klient = klient;
|
|
|
|
- unsigned char key[ 20 ] = { 231, 246, 125, 32, 88, 172, 229, 223, 246, 138, 74, 64, 142, 245, 217, 218, 162, 62, 103, 50 };
|
|
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
|
- klientNummer = 0;
|
|
|
|
- this->is = is;
|
|
|
|
- ref = 1;
|
|
|
|
|
|
+ this->klient = klient;
|
|
|
|
+ unsigned char key[ 20 ] = { 231, 246, 125, 32, 88, 172, 229, 223, 246, 138, 74, 64, 142, 245, 217, 218, 162, 62, 103, 50 };
|
|
|
|
+ klient->setSendeKey( (char *)key, 20 );
|
|
|
|
+ klient->setEmpfangKey( (char *)key, 20 );
|
|
|
|
+ klientNummer = 0;
|
|
|
|
+ this->is = is;
|
|
}
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
// Destruktor
|
|
ISKlient::~ISKlient()
|
|
ISKlient::~ISKlient()
|
|
{
|
|
{
|
|
- klient->release();
|
|
|
|
- is->release();
|
|
|
|
|
|
+ klient->release();
|
|
|
|
+ is->release();
|
|
}
|
|
}
|
|
|
|
|
|
// nicht constant
|
|
// nicht constant
|
|
void ISKlient::absturz()
|
|
void ISKlient::absturz()
|
|
{
|
|
{
|
|
- ende();
|
|
|
|
- klient->trenne();
|
|
|
|
- is->zDB()->unregisterKlient( klientNummer, is->getId() );
|
|
|
|
|
|
+ ende();
|
|
|
|
+ klient->trenne();
|
|
|
|
+ is->zDB()->unregisterKlient( klientNummer, is->getId() );
|
|
}
|
|
}
|
|
|
|
|
|
void ISKlient::thread()
|
|
void ISKlient::thread()
|
|
{
|
|
{
|
|
- while( 1 )
|
|
|
|
- {
|
|
|
|
- char c = 0;
|
|
|
|
- if( !klient->getNachrichtEncrypted( &c, 1 ) )
|
|
|
|
- break;
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- bool br = 0;
|
|
|
|
- switch( c )
|
|
|
|
- {
|
|
|
|
- case 1: // Klient identifikation
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&klientNummer, 4 );
|
|
|
|
- if( !is->zDB()->proveKlient( klientNummer, is->getId() ) )
|
|
|
|
- {
|
|
|
|
- klientNummer = 0;
|
|
|
|
- errorZuKlient( "Du bist nicht für diesen Server eingetragen" );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- Text *key = is->zDB()->getKlientKey( klientNummer );
|
|
|
|
- if( !key )
|
|
|
|
- errorZuKlient( "Es konnte kein Schlüssel ermittelt werden." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- klient->setEmpfangKey( *key, key->getLength() );
|
|
|
|
- klient->setSendeKey( *key, key->getLength() );
|
|
|
|
- key->release();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 2: // Main / Erhaltung Server message
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- char befehl = 0;
|
|
|
|
- klient->getNachrichtEncrypted( &befehl, 1 );
|
|
|
|
- switch( befehl )
|
|
|
|
- {
|
|
|
|
- case 2: // klient absturtz
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- int klientId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&klientId, 4 );
|
|
|
|
- if( klientId && is->absturzKlient( klientId ) )
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- else
|
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- errorZuKlient( "Befehl nicht bekannt!" );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 3: // Verbindungsende
|
|
|
|
- br = 1;
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- break;
|
|
|
|
- case 4: // unregister Klient
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- is->zDB()->unregisterKlient( klientNummer, is->getId() );
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- break;
|
|
|
|
- case 5: // frage nach Informations Text
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- char typ = 0;
|
|
|
|
- Text *info = is->zDB()->getInformationsText( &typ );
|
|
|
|
- unsigned short len = info ? (unsigned short)info->getLength() : (unsigned short)0;
|
|
|
|
- klient->sendeEncrypted( (char*)&len, 2 );
|
|
|
|
- if( len > 0 )
|
|
|
|
- klient->sendeEncrypted( info->getText(), len );
|
|
|
|
- klient->sendeEncrypted( &typ, 1 );
|
|
|
|
- if( info )
|
|
|
|
- info->release();
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 6: // frage, ob Spiel erlaubt ist
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int spielId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&spielId, 4 );
|
|
|
|
- if( is->zDB()->istSpielErlaubt( spielId ) )
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- else
|
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 7: // frage, ob Karte erlaubt ist
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int karteId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&karteId, 4 );
|
|
|
|
- if( is->zDB()->istKarteErlaubt( karteId ) )
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- else
|
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 8: // Frage nach Spiel Id
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- unsigned char len = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&len, 1 );
|
|
|
|
- char *name = new char[ len + 1 ];
|
|
|
|
- name[ (int)len ] = 0;
|
|
|
|
- klient->getNachrichtEncrypted( name, len );
|
|
|
|
- int id = is->zDB()->getSpielId( name );
|
|
|
|
- klient->sendeEncrypted( (char*)&id, 4 );
|
|
|
|
- delete[] name;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 9: // Frage nach Karte Id
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- unsigned char len = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&len, 1 );
|
|
|
|
- char *name = new char[ len + 1 ];
|
|
|
|
- name[ (int)len ] = 0;
|
|
|
|
- klient->getNachrichtEncrypted( name, len );
|
|
|
|
- int id = is->zDB()->getKarteId( name );
|
|
|
|
- klient->sendeEncrypted( (char*)&id, 4 );
|
|
|
|
- delete[] name;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0xA: // Frage nach Account rufName
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int accountId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&accountId, 4 );
|
|
|
|
- Text *rName = is->zDB()->getAccountRufName( accountId );
|
|
|
|
- if( rName )
|
|
|
|
- {
|
|
|
|
- char len = (char)rName->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- klient->sendeEncrypted( rName->getText(), len );
|
|
|
|
- rName->release();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0xB: // Frage nach Spiel Statistik
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int accountId = 0;
|
|
|
|
- int spielId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&accountId, 4 );
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&spielId, 4 );
|
|
|
|
- Array< int > *values = is->zDB()->getAccountSpielStatistik( accountId, spielId );
|
|
|
|
- for( int i = 0; i < 10; i++ )
|
|
|
|
- {
|
|
|
|
- int tmp = values ? values->get( i ) : 0;
|
|
|
|
- klient->sendeEncrypted( (char*)&tmp, 4 );
|
|
|
|
- }
|
|
|
|
- if( values )
|
|
|
|
- values->release();
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0xC: // Frage nach Spieler Liste
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- unsigned char len = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&len, 1 );
|
|
|
|
- char *suche = new char[ len + 1 ];
|
|
|
|
- suche[ (int)len ] = 0;
|
|
|
|
- klient->getNachrichtEncrypted( suche, len );
|
|
|
|
- int seite = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&seite, 4 );
|
|
|
|
- char sortSpalte = 0;
|
|
|
|
- char backwords = 0;
|
|
|
|
- klient->getNachrichtEncrypted( &sortSpalte, 1 );
|
|
|
|
- klient->getNachrichtEncrypted( &backwords, 1 );
|
|
|
|
- int maxSeite = 0;
|
|
|
|
- Result list = is->zDB()->getSpielerListe( suche, &seite, &maxSeite, sortSpalte, backwords != 0 );
|
|
|
|
- delete[] suche;
|
|
|
|
- klient->sendeEncrypted( (char*)&seite, 4 );
|
|
|
|
- klient->sendeEncrypted( (char*)&maxSeite, 4 );
|
|
|
|
- klient->sendeEncrypted( (char*)&list.zeilenAnzahl, 4 );
|
|
|
|
- for( int i = 0; i < list.zeilenAnzahl; i++ )
|
|
|
|
- {
|
|
|
|
- int accId = list.values[ i * 6 ];
|
|
|
|
- klient->sendeEncrypted( (char*)&accId, 4 );
|
|
|
|
- len = (char)list.values[ i * 6 + 1 ].getLength();
|
|
|
|
- klient->sendeEncrypted( (char*)&len, 1 );
|
|
|
|
- klient->sendeEncrypted( list.values[ i * 6 + 1 ], len );
|
|
|
|
- len = (char)list.values[ i * 6 + 2 ].getLength();
|
|
|
|
- klient->sendeEncrypted( (char*)&len, 1 );
|
|
|
|
- klient->sendeEncrypted( list.values[ i * 6 + 2 ], len );
|
|
|
|
- len = (char)list.values[ i * 6 + 3 ].getLength();
|
|
|
|
- klient->sendeEncrypted( (char*)&len, 1 );
|
|
|
|
- klient->sendeEncrypted( list.values[ i * 6 + 3 ], len );
|
|
|
|
- len = (char)list.values[ i * 6 + 4 ].getLength();
|
|
|
|
- klient->sendeEncrypted( (char*)&len, 1 );
|
|
|
|
- klient->sendeEncrypted( list.values[ i * 6 + 4 ], len );
|
|
|
|
- len = (char)list.values[ i * 6 + 5 ].getLength();
|
|
|
|
- klient->sendeEncrypted( (char*)&len, 1 );
|
|
|
|
- klient->sendeEncrypted( list.values[ i * 6 + 5 ], len );
|
|
|
|
- }
|
|
|
|
- list.destroy();
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0xD: // Frage nach Gruppe Karte Id
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int gruppeId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&gruppeId, 4 );
|
|
|
|
- int karteId = is->zDB()->getGruppenKarteId( gruppeId );
|
|
|
|
- klient->sendeEncrypted( (char*)&karteId, 4 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0xE: // Frage nach Karten Name
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int karteId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&karteId, 4 );
|
|
|
|
- Text *name = is->zDB()->getKarteName( karteId );
|
|
|
|
- if( !name )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- char len = (char)name->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- klient->sendeEncrypted( name->getText(), len );
|
|
|
|
- name->release();
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0xF: // Frage nach Spiel Name
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int spielId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&spielId, 4 );
|
|
|
|
- Text *name = is->zDB()->getSpielName( spielId );
|
|
|
|
- if( !name )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- char len = (char)name->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- klient->sendeEncrypted( name->getText(), len );
|
|
|
|
- name->release();
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0x10: // Frage nach Chatroom Name
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int chatroomId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&chatroomId, 4 );
|
|
|
|
- Text *name = is->zDB()->getChatroomName( chatroomId );
|
|
|
|
- if( !name )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- char len = (char)name->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- klient->sendeEncrypted( name->getText(), len );
|
|
|
|
- name->release();
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0x11: // Frage nach Spiel Id
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int karteId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&karteId, 4 );
|
|
|
|
- int spielId = is->zDB()->getSpielId( karteId );
|
|
|
|
- klient->sendeEncrypted( (char*)&spielId, 4 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0x12: // Frage nach Spieler Id
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- unsigned char len = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- {
|
|
|
|
- char *name = new char[ len + 1 ];
|
|
|
|
- name[ (int)len ] = 0;
|
|
|
|
- klient->getNachrichtEncrypted( name, len );
|
|
|
|
- int id = is->zDB()->getAccountId( name );
|
|
|
|
- klient->sendeEncrypted( (char*)&id, 4 );
|
|
|
|
- delete[]name;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0x13: // Frage nach Chatroom Id
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- unsigned char len = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- {
|
|
|
|
- char *name = new char[ len + 1 ];
|
|
|
|
- name[ (int)len ] = 0;
|
|
|
|
- klient->getNachrichtEncrypted( name, len );
|
|
|
|
- int id = is->zDB()->getChatroomId( name );
|
|
|
|
- klient->sendeEncrypted( (char*)&id, 4 );
|
|
|
|
- delete[]name;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0x14: // Frage nach Spiel Punkten
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int spielId = 0;
|
|
|
|
- int accountId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&spielId, 4 );
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&accountId, 4 );
|
|
|
|
- int ret = is->zDB()->getSpielerPunkte( spielId, accountId );
|
|
|
|
- klient->sendeEncrypted( (char*)&ret, 4 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0x15: // Frage nach Gruppe Administrator
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int gruppeId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&gruppeId, 4 );
|
|
|
|
- int ret = is->zDB()->getGruppeAdminId( gruppeId );
|
|
|
|
- klient->sendeEncrypted( (char*)&ret, 4 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0x16: // Frage nach Spiel Liste
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- Array< int > *list = is->zDB()->getAccountSpielArtListe( klientNummer );
|
|
|
|
- if( !list )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\0\0\0\0", 4 );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- int anz = list->getEintragAnzahl();
|
|
|
|
- klient->sendeEncrypted( (char*)&anz, 4 );
|
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
|
- {
|
|
|
|
- int id = list->get( i );
|
|
|
|
- klient->sendeEncrypted( (char*)&id, 4 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x17: // Frage nach neuster Spiel Version
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int id = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&id, 4 );
|
|
|
|
- int v = is->zDB()->getNeusteSpielVersion( id );
|
|
|
|
- klient->sendeEncrypted( (char*)&v, 4 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x18: // Frage nach Kupfer
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int k = is->zDB()->getKupfer( klientNummer );
|
|
|
|
- klient->sendeEncrypted( (char*)&k, 4 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x19: // Frage nach Dateigruppen Id von Spiel
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int spielId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&spielId, 4 );
|
|
|
|
- int dgId = is->zDB()->getDateiGruppeVonSpiel( spielId );
|
|
|
|
- klient->sendeEncrypted( (char*)&dgId, 4 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x1A: // Frage nach Dateigruppen Pfad
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int dgId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&dgId, 4 );
|
|
|
|
- Text *pf = is->zDB()->getDateiGruppePfad( dgId );
|
|
|
|
- if( !pf )
|
|
|
|
- errorZuKlient( "Die Dateigruppe wurde nicht gefunden." );
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- char len = (char)pf->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( pf->getText(), len );
|
|
|
|
- pf->release();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x1B: // Frage nach karte Liste
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int spielId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&spielId, 4 );
|
|
|
|
- Array< int > *list = is->zDB()->getAccountKarteListe( klientNummer, spielId );
|
|
|
|
- if( !list )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\0\0\0\0", 4 );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- int anz = list->getEintragAnzahl();
|
|
|
|
- klient->sendeEncrypted( (char*)&anz, 4 );
|
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
|
- {
|
|
|
|
- int id = list->get( i );
|
|
|
|
- klient->sendeEncrypted( (char*)&id, 4 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x1E: // Frage nach Gruppe Spieler Hinzufügen
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int gruppeId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&gruppeId, 4 );
|
|
|
|
- char gSH = (char)is->zDB()->getGruppeSpielerAdd( gruppeId );
|
|
|
|
- klient->sendeEncrypted( &gSH, 1 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x1F: // Frage nach Spieler Aktivität
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int acc = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&acc, 4 );
|
|
|
|
- RCArray< Text > *datum = new RCArray< Text >();
|
|
|
|
- Array< double > *stOnline = new Array< double >();
|
|
|
|
- Array< double > *stSpiel = new Array< double >();
|
|
|
|
- Array< int > *anzSpiele = new Array< int >();
|
|
|
|
- Array< int > *anzGewonnen = new Array< int >();
|
|
|
|
- if( is->zDB()->getSpielerAktivity( acc, datum, stOnline, stSpiel, anzSpiele, anzGewonnen ) )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int anz = datum->getEintragAnzahl();
|
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
|
- {
|
|
|
|
- if( datum->z( i ) )
|
|
|
|
- {
|
|
|
|
- char len = (char)datum->get( i )->getLength();
|
|
|
|
- if( len )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- klient->sendeEncrypted( datum->z( i )->getText(), len );
|
|
|
|
- double sto = stOnline->hat( i ) ? stOnline->get( i ) : 0;
|
|
|
|
- klient->sendeEncrypted( (char*)&sto, 8 );
|
|
|
|
- double sts = stSpiel->hat( i ) ? stSpiel->get( i ) : 0;
|
|
|
|
- klient->sendeEncrypted( (char*)&sts, 8 );
|
|
|
|
- int anzs = anzSpiele->hat( i ) ? anzSpiele->get( i ) : 0;
|
|
|
|
- klient->sendeEncrypted( (char*)&anzs, 4 );
|
|
|
|
- int anzg = anzGewonnen->hat( i ) ? anzGewonnen->get( i ) : 0;
|
|
|
|
- klient->sendeEncrypted( (char*)&anzg, 4 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Keine Daten gefunden." );
|
|
|
|
- datum->release();
|
|
|
|
- stOnline->release();
|
|
|
|
- stSpiel->release();
|
|
|
|
- anzSpiele->release();
|
|
|
|
- anzGewonnen->release();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x20: // Frage nach Anzahl der gespielten Spiele von Karte
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int acc = 0;
|
|
|
|
- int karte = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&acc, 4 );
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&karte, 4 );
|
|
|
|
- int anz = is->zDB()->getAccountKarteSpiele( acc, karte );
|
|
|
|
- klient->sendeEncrypted( (char*)&anz, 4 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x21: // Frage nach Anzahl gewonnener Spiele von Karte
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int acc = 0;
|
|
|
|
- int karte = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&acc, 4 );
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&karte, 4 );
|
|
|
|
- int anz = is->zDB()->getAccountKarteSpieleGewonnen( acc, karte );
|
|
|
|
- klient->sendeEncrypted( (char*)&anz, 4 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x22: // Frage nach Besitz Status von Karte
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int acc = 0;
|
|
|
|
- int karte = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&acc, 4 );
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&karte, 4 );
|
|
|
|
- char status = (char)is->zDB()->hatAccountKarte( acc, karte );
|
|
|
|
- klient->sendeEncrypted( &status, 1 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x23: // Frage nach Besitz Status von Spiel
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int acc = 0;
|
|
|
|
- int spiel = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&acc, 4 );
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&spiel, 4 );
|
|
|
|
- char status = (char)is->zDB()->hatAccountSpiel( acc, spiel );
|
|
|
|
- klient->sendeEncrypted( &status, 1 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x24: // Frage nach Liste mit gespielten Karten
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int acc = 0;
|
|
|
|
- int spiel = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&acc, 4 );
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&spiel, 4 );
|
|
|
|
- Array< int > *res = is->zDB()->getAccountKarteGespieltListe( acc, spiel );
|
|
|
|
- if( res )
|
|
|
|
- {
|
|
|
|
- int anz = res->getEintragAnzahl();
|
|
|
|
- klient->sendeEncrypted( (char*)&anz, 4 );
|
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
|
- {
|
|
|
|
- int val = res->get( i );
|
|
|
|
- klient->sendeEncrypted( (char*)&val, 4 );
|
|
|
|
- }
|
|
|
|
- res->release();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- klient->sendeEncrypted( "\0\0\0\0", 4 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x25: // Frage nach Liste mit gespielten Spielen
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int acc = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&acc, 4 );
|
|
|
|
- Array< int > *res = is->zDB()->getAccountSpielGespieltListe( acc );
|
|
|
|
- if( res )
|
|
|
|
- {
|
|
|
|
- int anz = res->getEintragAnzahl();
|
|
|
|
- klient->sendeEncrypted( (char*)&anz, 4 );
|
|
|
|
- for( int i = 0; i < anz; i++ )
|
|
|
|
- {
|
|
|
|
- int val = res->get( i );
|
|
|
|
- klient->sendeEncrypted( (char*)&val, 4 );
|
|
|
|
- }
|
|
|
|
- res->release();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- klient->sendeEncrypted( "\0\0\0\0", 4 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x26: // Frage nach Liste mit spiel Partnern
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int acc = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&acc, 4 );
|
|
|
|
- Result res = is->zDB()->getSpielPartnerListe( acc );
|
|
|
|
- klient->sendeEncrypted( (char*)&res.zeilenAnzahl, 4 );
|
|
|
|
- for( int i = 0; i < res.zeilenAnzahl; i++ )
|
|
|
|
- {
|
|
|
|
- int spieler = res.values[ i * 3 ];
|
|
|
|
- int anzahl = res.values[ i * 3 + 1 ];
|
|
|
|
- int karte = res.values[ i * 3 + 2 ];
|
|
|
|
- klient->sendeEncrypted( (char*)&spieler, 4 );
|
|
|
|
- klient->sendeEncrypted( (char*)&karte, 4 );
|
|
|
|
- klient->sendeEncrypted( (char*)&anzahl, 4 );
|
|
|
|
- }
|
|
|
|
- res.destroy();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x27: // Frage nach Liste mit spiel Statistiken
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int acc = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&acc, 4 );
|
|
|
|
- int seite = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&seite, 4 );
|
|
|
|
- char sortSpalte = 0;
|
|
|
|
- char backwords = 0;
|
|
|
|
- klient->getNachrichtEncrypted( &sortSpalte, 1 );
|
|
|
|
- klient->getNachrichtEncrypted( &backwords, 1 );
|
|
|
|
- int maxSeite = 0;
|
|
|
|
- Result list = is->zDB()->getSpielStatistikListe( acc, &seite, &maxSeite, sortSpalte, backwords != 0 );
|
|
|
|
- klient->sendeEncrypted( (char*)&seite, 4 );
|
|
|
|
- klient->sendeEncrypted( (char*)&maxSeite, 4 );
|
|
|
|
- klient->sendeEncrypted( (char*)&list.zeilenAnzahl, 4 );
|
|
|
|
- klient->sendeEncrypted( (char*)&list.feldAnzahl, 4 );
|
|
|
|
- for( int i = 0; i < list.zeilenAnzahl; i++ )
|
|
|
|
- {
|
|
|
|
- for( int j = 0; j < list.feldAnzahl; j++ )
|
|
|
|
- {
|
|
|
|
- if( j != 1 )
|
|
|
|
- {
|
|
|
|
- int val = list.values[ j + i * list.feldAnzahl ];
|
|
|
|
- klient->sendeEncrypted( (char*)&val, 4 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- char len = (char)( list.values[ j + i * list.feldAnzahl ].getLength() );
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( list.values[ j + i * list.feldAnzahl ], len );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- list.destroy();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x28: // Spiel Historie Liste
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int acc = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&acc, 4 );
|
|
|
|
- AHDaten *daten = is->zDB()->getSpielHistorie( acc, is );
|
|
|
|
- if( daten )
|
|
|
|
- {
|
|
|
|
- char anz = (char)daten->spiele->getEintragAnzahl();
|
|
|
|
- klient->sendeEncrypted( &anz, 1 );
|
|
|
|
- for( char i = 0; i < anz; i++ )
|
|
|
|
- {
|
|
|
|
- AHSpielDaten *spiel = daten->spiele->z( i );
|
|
|
|
- klient->sendeEncrypted( (char*)&spiel->id, 4 );
|
|
|
|
- klient->sendeEncrypted( (char*)&spiel->karteId, 4 );
|
|
|
|
- char len = (char)spiel->spiel->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( *spiel->spiel, len );
|
|
|
|
- len = (char)spiel->karte->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( *spiel->karte, len );
|
|
|
|
- len = (char)spiel->datum->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( *spiel->datum, len );
|
|
|
|
- len = (char)spiel->status->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( *spiel->status, len );
|
|
|
|
- len = (char)spiel->dauer->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( *spiel->dauer, len );
|
|
|
|
- len = (char)spiel->spielStatus->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( *spiel->spielStatus, len );
|
|
|
|
- len = (char)spiel->gewinner->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( *spiel->gewinner, len );
|
|
|
|
- klient->sendeEncrypted( (char*)&spiel->sAnzahl, 4 );
|
|
|
|
- char tAnz = (char)spiel->teams->getEintragAnzahl();
|
|
|
|
- klient->sendeEncrypted( &tAnz, 1 );
|
|
|
|
- for( char j = 0; j < tAnz; j++ )
|
|
|
|
- {
|
|
|
|
- AHSpielTeamDaten *team = spiel->teams->z( j );
|
|
|
|
- char len = (char)team->name->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( *team->name, len );
|
|
|
|
- klient->sendeEncrypted( (char*)&team->sAnzahl, 4 );
|
|
|
|
- len = (char)team->status->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( *team->status, len );
|
|
|
|
- klient->sendeEncrypted( (char*)&team->farbe, 4 );
|
|
|
|
- char sAnz = (char)team->spieler->getEintragAnzahl();
|
|
|
|
- klient->sendeEncrypted( &sAnz, 1 );
|
|
|
|
- for( char k = 0; k < sAnz; k++ )
|
|
|
|
- {
|
|
|
|
- AHSpielSpielerDaten *spieler = team->spieler->z( k );
|
|
|
|
- char len = (char)spieler->name->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( *spieler->name, len );
|
|
|
|
- klient->sendeEncrypted( (char*)&spieler->punkte, 4 );
|
|
|
|
- len = (char)spieler->status->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( *spieler->status, len );
|
|
|
|
- klient->sendeEncrypted( (char*)&spieler->farbe, 4 );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- daten->release();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x29: // Frage nach Historie Server
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int spielId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&spielId, 4 );
|
|
|
|
- int port = 0;
|
|
|
|
- Text *ip = new Text();
|
|
|
|
- if( is->zDB()->getHistorieServerPortIp( klientNummer, spielId, &port, ip ) )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)&port, 4 );
|
|
|
|
- char len = (char)ip->getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- klient->sendeEncrypted( *ip, len );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Die Daten für dieses Spiel sind vorrübergehend nicht verfügbar." );
|
|
|
|
- ip->release();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x2A: // Frage nach Dateigruppen Id von Pfad
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- unsigned char len = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&len, 1 );
|
|
|
|
- char *pf = new char[ len + 1 ];
|
|
|
|
- pf[ (int)len ] = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)pf, len );
|
|
|
|
- int dgId = is->zDB()->getDateiGruppeVonPfad( pf );
|
|
|
|
- delete[] pf;
|
|
|
|
- klient->sendeEncrypted( (char*)&dgId, 4 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x2B: // Frage nach neuster Version einer Dateigruppe
|
|
|
|
- if( klientNummer )
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int dg = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&dg, 4 );
|
|
|
|
- int v = is->zDB()->getNeusteDateiGruppe( dg );
|
|
|
|
- klient->sendeEncrypted( (char*)&v, 4 );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- case 0x2C: // ping
|
|
|
|
- if( 1 )
|
|
|
|
- {
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0x2D: // Hat Account Recht
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int recht = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&recht, 4 );
|
|
|
|
- if( is->zDB()->hatKlientRecht( klientNummer, recht ) )
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- else
|
|
|
|
- klient->sendeEncrypted( "\0", 1 );
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0x2E: // Karten Liste
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- unsigned char filterLen = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&filterLen, 1 );
|
|
|
|
- char *filter = new char[ filterLen + 1 ];
|
|
|
|
- filter[ (int)filterLen ] = 0;
|
|
|
|
- if( filterLen )
|
|
|
|
- klient->getNachrichtEncrypted( filter, filterLen );
|
|
|
|
- char sortSpalte = 0;
|
|
|
|
- klient->getNachrichtEncrypted( &sortSpalte, 1 );
|
|
|
|
- char sortRichtung = 0;
|
|
|
|
- klient->getNachrichtEncrypted( &sortRichtung, 1 );
|
|
|
|
- Result res = is->zDB()->getKartenListe( klientNummer, filter, sortSpalte, sortRichtung );
|
|
|
|
- delete[] filter;
|
|
|
|
- klient->sendeEncrypted( (char*)&res.zeilenAnzahl, 4 );
|
|
|
|
- for( int i = 0; i < res.zeilenAnzahl; i++ )
|
|
|
|
- {
|
|
|
|
- int val = res.values[ i * 6 ];
|
|
|
|
- klient->sendeEncrypted( (char*)&val, 4 );
|
|
|
|
- char len = (char)res.values[ i * 6 + 1 ].getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( res.values[ i * 6 + 1 ], len );
|
|
|
|
- len = (char)res.values[ i * 6 + 2 ].getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- if( len )
|
|
|
|
- klient->sendeEncrypted( res.values[ i * 6 + 2 ], len );
|
|
|
|
- val = res.values[ i * 6 + 3 ];
|
|
|
|
- klient->sendeEncrypted( (char*)&val, 4 );
|
|
|
|
- val = res.values[ i * 6 + 4 ];
|
|
|
|
- klient->sendeEncrypted( (char*)&val, 4 );
|
|
|
|
- val = res.values[ i * 6 + 5 ];
|
|
|
|
- klient->sendeEncrypted( (char*)&val, 4 );
|
|
|
|
- }
|
|
|
|
- res.destroy();
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0x2F: // Editor Server Anfrage
|
|
|
|
- if( !klientNummer )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- int karteId = 0;
|
|
|
|
- klient->getNachrichtEncrypted( (char*)&karteId, 4 );
|
|
|
|
- int port = 0;
|
|
|
|
- Text ip;
|
|
|
|
- if( !is->zDB()->getEditorServerPortIp( klientNummer, karteId, &port, &ip ) )
|
|
|
|
- {
|
|
|
|
- errorZuKlient( "Du kannst diese Karte momentan nicht abrufen." );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- klient->sendeEncrypted( "\1", 1 );
|
|
|
|
- klient->sendeEncrypted( (char*)&port, 4 );
|
|
|
|
- char len = (char)ip.getLength();
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- klient->sendeEncrypted( ip, len );
|
|
|
|
- }
|
|
|
|
|
|
+ while( 1 )
|
|
|
|
+ {
|
|
|
|
+ char c = 0;
|
|
|
|
+ if( !klient->getNachrichtEncrypted( &c, 1 ) )
|
|
|
|
+ break;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ bool br = 0;
|
|
|
|
+ switch( c )
|
|
|
|
+ {
|
|
|
|
+ case 1: // Klient identifikation
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& klientNummer, 4 );
|
|
|
|
+ if( !is->zDB()->proveKlient( klientNummer, is->getId() ) )
|
|
|
|
+ {
|
|
|
|
+ klientNummer = 0;
|
|
|
|
+ errorZuKlient( "Du bist nicht für diesen Server eingetragen" );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Text *key = is->zDB()->getKlientKey( klientNummer );
|
|
|
|
+ if( !key )
|
|
|
|
+ errorZuKlient( "Es konnte kein Schlüssel ermittelt werden." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ klient->setEmpfangKey( *key, key->getLength() );
|
|
|
|
+ klient->setSendeKey( *key, key->getLength() );
|
|
|
|
+ key->release();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 2: // Main / Erhaltung Server message
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ char befehl = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( &befehl, 1 );
|
|
|
|
+ switch( befehl )
|
|
|
|
+ {
|
|
|
|
+ case 2: // klient absturtz
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ int klientId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ if( klientId &&is->absturzKlient( klientId ) )
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ else
|
|
|
|
+ klient->sendeEncrypted( "\0", 1 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ errorZuKlient( "Befehl nicht bekannt!" );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 3: // Verbindungsende
|
|
|
|
+ br = 1;
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ break;
|
|
|
|
+ case 4: // unregister Klient
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ is->zDB()->unregisterKlient( klientNummer, is->getId() );
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ break;
|
|
|
|
+ case 5: // frage nach Informations Text
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ char typ = 0;
|
|
|
|
+ Text *info = is->zDB()->getInformationsText( &typ );
|
|
|
|
+ unsigned short len = info ? (unsigned short)info->getLength() : (unsigned short)0;
|
|
|
|
+ klient->sendeEncrypted( (char *)& len, 2 );
|
|
|
|
+ if( len > 0 )
|
|
|
|
+ klient->sendeEncrypted( info->getText(), len );
|
|
|
|
+ klient->sendeEncrypted( &typ, 1 );
|
|
|
|
+ if( info )
|
|
|
|
+ info->release();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 6: // frage, ob Spiel erlaubt ist
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int spielId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& spielId, 4 );
|
|
|
|
+ if( is->zDB()->istSpielErlaubt( spielId ) )
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ else
|
|
|
|
+ klient->sendeEncrypted( "\0", 1 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 7: // frage, ob Karte erlaubt ist
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int karteId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& karteId, 4 );
|
|
|
|
+ if( is->zDB()->istKarteErlaubt( karteId ) )
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ else
|
|
|
|
+ klient->sendeEncrypted( "\0", 1 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 8: // Frage nach Spiel Id
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ unsigned char len = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& len, 1 );
|
|
|
|
+ char *name = new char[ len + 1 ];
|
|
|
|
+ name[ (int)len ] = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( name, len );
|
|
|
|
+ int id = is->zDB()->getSpielId( name );
|
|
|
|
+ klient->sendeEncrypted( (char *)& id, 4 );
|
|
|
|
+ delete[] name;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 9: // Frage nach Karte Id
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ unsigned char len = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& len, 1 );
|
|
|
|
+ char *name = new char[ len + 1 ];
|
|
|
|
+ name[ (int)len ] = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( name, len );
|
|
|
|
+ int id = is->zDB()->getKarteId( name );
|
|
|
|
+ klient->sendeEncrypted( (char *)& id, 4 );
|
|
|
|
+ delete[] name;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0xA: // Frage nach Account rufName
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int accountId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& accountId, 4 );
|
|
|
|
+ Text *rName = is->zDB()->getAccountRufName( accountId );
|
|
|
|
+ if( rName )
|
|
|
|
+ {
|
|
|
|
+ char len = (char)rName->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ klient->sendeEncrypted( rName->getText(), len );
|
|
|
|
+ rName->release();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ klient->sendeEncrypted( "\0", 1 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0xB: // Frage nach Spiel Statistik
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int accountId = 0;
|
|
|
|
+ int spielId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& accountId, 4 );
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& spielId, 4 );
|
|
|
|
+ Array< int > *values = is->zDB()->getAccountSpielStatistik( accountId, spielId );
|
|
|
|
+ for( int i = 0; i < 10; i++ )
|
|
|
|
+ {
|
|
|
|
+ int tmp = values ? values->get( i ) : 0;
|
|
|
|
+ klient->sendeEncrypted( (char *)& tmp, 4 );
|
|
|
|
+ }
|
|
|
|
+ if( values )
|
|
|
|
+ values->release();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0xC: // Frage nach Spieler Liste
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ unsigned char len = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& len, 1 );
|
|
|
|
+ char *suche = new char[ len + 1 ];
|
|
|
|
+ suche[ (int)len ] = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( suche, len );
|
|
|
|
+ int seite = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& seite, 4 );
|
|
|
|
+ char sortSpalte = 0;
|
|
|
|
+ char backwords = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( &sortSpalte, 1 );
|
|
|
|
+ klient->getNachrichtEncrypted( &backwords, 1 );
|
|
|
|
+ int maxSeite = 0;
|
|
|
|
+ Result list = is->zDB()->getSpielerListe( suche, &seite, &maxSeite, sortSpalte, backwords != 0 );
|
|
|
|
+ delete[] suche;
|
|
|
|
+ klient->sendeEncrypted( (char *)& seite, 4 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& maxSeite, 4 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& list.zeilenAnzahl, 4 );
|
|
|
|
+ for( int i = 0; i < list.zeilenAnzahl; i++ )
|
|
|
|
+ {
|
|
|
|
+ int accId = list.values[ i * 6 ];
|
|
|
|
+ klient->sendeEncrypted( (char *)& accId, 4 );
|
|
|
|
+ len = (char)list.values[ i * 6 + 1 ].getLength();
|
|
|
|
+ klient->sendeEncrypted( (char *)& len, 1 );
|
|
|
|
+ klient->sendeEncrypted( list.values[ i * 6 + 1 ], len );
|
|
|
|
+ len = (char)list.values[ i * 6 + 2 ].getLength();
|
|
|
|
+ klient->sendeEncrypted( (char *)& len, 1 );
|
|
|
|
+ klient->sendeEncrypted( list.values[ i * 6 + 2 ], len );
|
|
|
|
+ len = (char)list.values[ i * 6 + 3 ].getLength();
|
|
|
|
+ klient->sendeEncrypted( (char *)& len, 1 );
|
|
|
|
+ klient->sendeEncrypted( list.values[ i * 6 + 3 ], len );
|
|
|
|
+ len = (char)list.values[ i * 6 + 4 ].getLength();
|
|
|
|
+ klient->sendeEncrypted( (char *)& len, 1 );
|
|
|
|
+ klient->sendeEncrypted( list.values[ i * 6 + 4 ], len );
|
|
|
|
+ len = (char)list.values[ i * 6 + 5 ].getLength();
|
|
|
|
+ klient->sendeEncrypted( (char *)& len, 1 );
|
|
|
|
+ klient->sendeEncrypted( list.values[ i * 6 + 5 ], len );
|
|
|
|
+ }
|
|
|
|
+ list.destroy();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0xD: // Frage nach Gruppe Karte Id
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int gruppeId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& gruppeId, 4 );
|
|
|
|
+ int karteId = is->zDB()->getGruppenKarteId( gruppeId );
|
|
|
|
+ klient->sendeEncrypted( (char *)& karteId, 4 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0xE: // Frage nach Karten Name
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int karteId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& karteId, 4 );
|
|
|
|
+ Text *name = is->zDB()->getKarteName( karteId );
|
|
|
|
+ if( !name )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\0", 1 );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ char len = (char)name->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ klient->sendeEncrypted( name->getText(), len );
|
|
|
|
+ name->release();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0xF: // Frage nach Spiel Name
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int spielId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& spielId, 4 );
|
|
|
|
+ Text *name = is->zDB()->getSpielName( spielId );
|
|
|
|
+ if( !name )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\0", 1 );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ char len = (char)name->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ klient->sendeEncrypted( name->getText(), len );
|
|
|
|
+ name->release();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0x10: // Frage nach Chatroom Name
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int chatroomId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& chatroomId, 4 );
|
|
|
|
+ Text *name = is->zDB()->getChatroomName( chatroomId );
|
|
|
|
+ if( !name )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\0", 1 );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ char len = (char)name->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ klient->sendeEncrypted( name->getText(), len );
|
|
|
|
+ name->release();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0x11: // Frage nach Spiel Id
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int karteId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& karteId, 4 );
|
|
|
|
+ int spielId = is->zDB()->getSpielId( karteId );
|
|
|
|
+ klient->sendeEncrypted( (char *)& spielId, 4 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0x12: // Frage nach Spieler Id
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ unsigned char len = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ {
|
|
|
|
+ char *name = new char[ len + 1 ];
|
|
|
|
+ name[ (int)len ] = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( name, len );
|
|
|
|
+ int id = is->zDB()->getAccountId( name );
|
|
|
|
+ klient->sendeEncrypted( (char *)& id, 4 );
|
|
|
|
+ delete[]name;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0x13: // Frage nach Chatroom Id
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ unsigned char len = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ {
|
|
|
|
+ char *name = new char[ len + 1 ];
|
|
|
|
+ name[ (int)len ] = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( name, len );
|
|
|
|
+ int id = is->zDB()->getChatroomId( name );
|
|
|
|
+ klient->sendeEncrypted( (char *)& id, 4 );
|
|
|
|
+ delete[]name;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0x14: // Frage nach Spiel Punkten
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int spielId = 0;
|
|
|
|
+ int accountId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& spielId, 4 );
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& accountId, 4 );
|
|
|
|
+ int ret = is->zDB()->getSpielerPunkte( spielId, accountId );
|
|
|
|
+ klient->sendeEncrypted( (char *)& ret, 4 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0x15: // Frage nach Gruppe Administrator
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int gruppeId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& gruppeId, 4 );
|
|
|
|
+ int ret = is->zDB()->getGruppeAdminId( gruppeId );
|
|
|
|
+ klient->sendeEncrypted( (char *)& ret, 4 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0x16: // Frage nach Spiel Liste
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ Array< int > *list = is->zDB()->getAccountSpielArtListe( klientNummer );
|
|
|
|
+ if( !list )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\0\0\0\0", 4 );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ int anz = list->getEintragAnzahl();
|
|
|
|
+ klient->sendeEncrypted( (char *)& anz, 4 );
|
|
|
|
+ for( int i = 0; i < anz; i++ )
|
|
|
|
+ {
|
|
|
|
+ int id = list->get( i );
|
|
|
|
+ klient->sendeEncrypted( (char *)& id, 4 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x17: // Frage nach neuster Spiel Version
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int id = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
|
|
+ int v = is->zDB()->getNeusteSpielVersion( id );
|
|
|
|
+ klient->sendeEncrypted( (char *)& v, 4 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x18: // Frage nach Kupfer
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int k = is->zDB()->getKupfer( klientNummer );
|
|
|
|
+ klient->sendeEncrypted( (char *)& k, 4 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x19: // Frage nach Dateigruppen Id von Spiel
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int spielId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& spielId, 4 );
|
|
|
|
+ int dgId = is->zDB()->getDateiGruppeVonSpiel( spielId );
|
|
|
|
+ klient->sendeEncrypted( (char *)& dgId, 4 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x1A: // Frage nach Dateigruppen Pfad
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int dgId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& dgId, 4 );
|
|
|
|
+ Text *pf = is->zDB()->getDateiGruppePfad( dgId );
|
|
|
|
+ if( !pf )
|
|
|
|
+ errorZuKlient( "Die Dateigruppe wurde nicht gefunden." );
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ char len = (char)pf->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( pf->getText(), len );
|
|
|
|
+ pf->release();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x1B: // Frage nach karte Liste
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int spielId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& spielId, 4 );
|
|
|
|
+ Array< int > *list = is->zDB()->getAccountKarteListe( klientNummer, spielId );
|
|
|
|
+ if( !list )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\0\0\0\0", 4 );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ int anz = list->getEintragAnzahl();
|
|
|
|
+ klient->sendeEncrypted( (char *)& anz, 4 );
|
|
|
|
+ for( int i = 0; i < anz; i++ )
|
|
|
|
+ {
|
|
|
|
+ int id = list->get( i );
|
|
|
|
+ klient->sendeEncrypted( (char *)& id, 4 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x1E: // Frage nach Gruppe Spieler Hinzufügen
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int gruppeId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& gruppeId, 4 );
|
|
|
|
+ char gSH = (char)is->zDB()->getGruppeSpielerAdd( gruppeId );
|
|
|
|
+ klient->sendeEncrypted( &gSH, 1 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x1F: // Frage nach Spieler Aktivität
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int acc = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& acc, 4 );
|
|
|
|
+ RCArray< Text > *datum = new RCArray< Text >();
|
|
|
|
+ Array< double > *stOnline = new Array< double >();
|
|
|
|
+ Array< double > *stSpiel = new Array< double >();
|
|
|
|
+ Array< int > *anzSpiele = new Array< int >();
|
|
|
|
+ Array< int > *anzGewonnen = new Array< int >();
|
|
|
|
+ if( is->zDB()->getSpielerAktivity( acc, datum, stOnline, stSpiel, anzSpiele, anzGewonnen ) )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int anz = datum->getEintragAnzahl();
|
|
|
|
+ for( int i = 0; i < anz; i++ )
|
|
|
|
+ {
|
|
|
|
+ if( datum->z( i ) )
|
|
|
|
+ {
|
|
|
|
+ char len = (char)datum->get( i )->getLength();
|
|
|
|
+ if( len )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ klient->sendeEncrypted( datum->z( i )->getText(), len );
|
|
|
|
+ double sto = stOnline->hat( i ) ? stOnline->get( i ) : 0;
|
|
|
|
+ klient->sendeEncrypted( (char *)& sto, 8 );
|
|
|
|
+ double sts = stSpiel->hat( i ) ? stSpiel->get( i ) : 0;
|
|
|
|
+ klient->sendeEncrypted( (char *)& sts, 8 );
|
|
|
|
+ int anzs = anzSpiele->hat( i ) ? anzSpiele->get( i ) : 0;
|
|
|
|
+ klient->sendeEncrypted( (char *)& anzs, 4 );
|
|
|
|
+ int anzg = anzGewonnen->hat( i ) ? anzGewonnen->get( i ) : 0;
|
|
|
|
+ klient->sendeEncrypted( (char *)& anzg, 4 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\0", 1 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Keine Daten gefunden." );
|
|
|
|
+ datum->release();
|
|
|
|
+ stOnline->release();
|
|
|
|
+ stSpiel->release();
|
|
|
|
+ anzSpiele->release();
|
|
|
|
+ anzGewonnen->release();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x20: // Frage nach Anzahl der gespielten Spiele von Karte
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int acc = 0;
|
|
|
|
+ int karte = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& acc, 4 );
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& karte, 4 );
|
|
|
|
+ int anz = is->zDB()->getAccountKarteSpiele( acc, karte );
|
|
|
|
+ klient->sendeEncrypted( (char *)& anz, 4 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x21: // Frage nach Anzahl gewonnener Spiele von Karte
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int acc = 0;
|
|
|
|
+ int karte = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& acc, 4 );
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& karte, 4 );
|
|
|
|
+ int anz = is->zDB()->getAccountKarteSpieleGewonnen( acc, karte );
|
|
|
|
+ klient->sendeEncrypted( (char *)& anz, 4 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x22: // Frage nach Besitz Status von Karte
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int acc = 0;
|
|
|
|
+ int karte = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& acc, 4 );
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& karte, 4 );
|
|
|
|
+ char status = (char)is->zDB()->hatAccountKarte( acc, karte );
|
|
|
|
+ klient->sendeEncrypted( &status, 1 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x23: // Frage nach Besitz Status von Spiel
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int acc = 0;
|
|
|
|
+ int spiel = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& acc, 4 );
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& spiel, 4 );
|
|
|
|
+ char status = (char)is->zDB()->hatAccountSpiel( acc, spiel );
|
|
|
|
+ klient->sendeEncrypted( &status, 1 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x24: // Frage nach Liste mit gespielten Karten
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int acc = 0;
|
|
|
|
+ int spiel = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& acc, 4 );
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& spiel, 4 );
|
|
|
|
+ Array< int > *res = is->zDB()->getAccountKarteGespieltListe( acc, spiel );
|
|
|
|
+ if( res )
|
|
|
|
+ {
|
|
|
|
+ int anz = res->getEintragAnzahl();
|
|
|
|
+ klient->sendeEncrypted( (char *)& anz, 4 );
|
|
|
|
+ for( int i = 0; i < anz; i++ )
|
|
|
|
+ {
|
|
|
|
+ int val = res->get( i );
|
|
|
|
+ klient->sendeEncrypted( (char *)& val, 4 );
|
|
|
|
+ }
|
|
|
|
+ res->release();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ klient->sendeEncrypted( "\0\0\0\0", 4 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x25: // Frage nach Liste mit gespielten Spielen
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int acc = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& acc, 4 );
|
|
|
|
+ Array< int > *res = is->zDB()->getAccountSpielGespieltListe( acc );
|
|
|
|
+ if( res )
|
|
|
|
+ {
|
|
|
|
+ int anz = res->getEintragAnzahl();
|
|
|
|
+ klient->sendeEncrypted( (char *)& anz, 4 );
|
|
|
|
+ for( int i = 0; i < anz; i++ )
|
|
|
|
+ {
|
|
|
|
+ int val = res->get( i );
|
|
|
|
+ klient->sendeEncrypted( (char *)& val, 4 );
|
|
|
|
+ }
|
|
|
|
+ res->release();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ klient->sendeEncrypted( "\0\0\0\0", 4 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x26: // Frage nach Liste mit spiel Partnern
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int acc = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& acc, 4 );
|
|
|
|
+ Result res = is->zDB()->getSpielPartnerListe( acc );
|
|
|
|
+ klient->sendeEncrypted( (char *)& res.zeilenAnzahl, 4 );
|
|
|
|
+ for( int i = 0; i < res.zeilenAnzahl; i++ )
|
|
|
|
+ {
|
|
|
|
+ int spieler = res.values[ i * 3 ];
|
|
|
|
+ int anzahl = res.values[ i * 3 + 1 ];
|
|
|
|
+ int karte = res.values[ i * 3 + 2 ];
|
|
|
|
+ klient->sendeEncrypted( (char *)& spieler, 4 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& karte, 4 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& anzahl, 4 );
|
|
|
|
+ }
|
|
|
|
+ res.destroy();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x27: // Frage nach Liste mit spiel Statistiken
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int acc = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& acc, 4 );
|
|
|
|
+ int seite = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& seite, 4 );
|
|
|
|
+ char sortSpalte = 0;
|
|
|
|
+ char backwords = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( &sortSpalte, 1 );
|
|
|
|
+ klient->getNachrichtEncrypted( &backwords, 1 );
|
|
|
|
+ int maxSeite = 0;
|
|
|
|
+ Result list = is->zDB()->getSpielStatistikListe( acc, &seite, &maxSeite, sortSpalte, backwords != 0 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& seite, 4 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& maxSeite, 4 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& list.zeilenAnzahl, 4 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& list.feldAnzahl, 4 );
|
|
|
|
+ for( int i = 0; i < list.zeilenAnzahl; i++ )
|
|
|
|
+ {
|
|
|
|
+ for( int j = 0; j < list.feldAnzahl; j++ )
|
|
|
|
+ {
|
|
|
|
+ if( j != 1 )
|
|
|
|
+ {
|
|
|
|
+ int val = list.values[ j + i * list.feldAnzahl ];
|
|
|
|
+ klient->sendeEncrypted( (char *)& val, 4 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ char len = (char)( list.values[ j + i * list.feldAnzahl ].getLength() );
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( list.values[ j + i * list.feldAnzahl ], len );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ list.destroy();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x28: // Spiel Historie Liste
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int acc = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& acc, 4 );
|
|
|
|
+ AHDaten *daten = is->zDB()->getSpielHistorie( acc, is );
|
|
|
|
+ if( daten )
|
|
|
|
+ {
|
|
|
|
+ char anz = (char)daten->spiele->getEintragAnzahl();
|
|
|
|
+ klient->sendeEncrypted( &anz, 1 );
|
|
|
|
+ for( char i = 0; i < anz; i++ )
|
|
|
|
+ {
|
|
|
|
+ AHSpielDaten *spiel = daten->spiele->z( i );
|
|
|
|
+ klient->sendeEncrypted( (char *)& spiel->id, 4 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& spiel->karteId, 4 );
|
|
|
|
+ char len = (char)spiel->spiel->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( *spiel->spiel, len );
|
|
|
|
+ len = (char)spiel->karte->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( *spiel->karte, len );
|
|
|
|
+ len = (char)spiel->datum->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( *spiel->datum, len );
|
|
|
|
+ len = (char)spiel->status->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( *spiel->status, len );
|
|
|
|
+ len = (char)spiel->dauer->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( *spiel->dauer, len );
|
|
|
|
+ len = (char)spiel->spielStatus->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( *spiel->spielStatus, len );
|
|
|
|
+ len = (char)spiel->gewinner->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( *spiel->gewinner, len );
|
|
|
|
+ klient->sendeEncrypted( (char *)& spiel->sAnzahl, 4 );
|
|
|
|
+ char tAnz = (char)spiel->teams->getEintragAnzahl();
|
|
|
|
+ klient->sendeEncrypted( &tAnz, 1 );
|
|
|
|
+ for( char j = 0; j < tAnz; j++ )
|
|
|
|
+ {
|
|
|
|
+ AHSpielTeamDaten *team = spiel->teams->z( j );
|
|
|
|
+ char len = (char)team->name->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( *team->name, len );
|
|
|
|
+ klient->sendeEncrypted( (char *)& team->sAnzahl, 4 );
|
|
|
|
+ len = (char)team->status->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( *team->status, len );
|
|
|
|
+ klient->sendeEncrypted( (char *)& team->farbe, 4 );
|
|
|
|
+ char sAnz = (char)team->spieler->getEintragAnzahl();
|
|
|
|
+ klient->sendeEncrypted( &sAnz, 1 );
|
|
|
|
+ for( char k = 0; k < sAnz; k++ )
|
|
|
|
+ {
|
|
|
|
+ AHSpielSpielerDaten *spieler = team->spieler->z( k );
|
|
|
|
+ char len = (char)spieler->name->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( *spieler->name, len );
|
|
|
|
+ klient->sendeEncrypted( (char *)& spieler->punkte, 4 );
|
|
|
|
+ len = (char)spieler->status->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( *spieler->status, len );
|
|
|
|
+ klient->sendeEncrypted( (char *)& spieler->farbe, 4 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ daten->release();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ klient->sendeEncrypted( "\0", 1 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x29: // Frage nach Historie Server
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int spielId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& spielId, 4 );
|
|
|
|
+ int port = 0;
|
|
|
|
+ Text *ip = new Text();
|
|
|
|
+ if( is->zDB()->getHistorieServerPortIp( klientNummer, spielId, &port, ip ) )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& port, 4 );
|
|
|
|
+ char len = (char)ip->getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ klient->sendeEncrypted( *ip, len );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Die Daten für dieses Spiel sind vorrübergehend nicht verfügbar." );
|
|
|
|
+ ip->release();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x2A: // Frage nach Dateigruppen Id von Pfad
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ unsigned char len = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& len, 1 );
|
|
|
|
+ char *pf = new char[ len + 1 ];
|
|
|
|
+ pf[ (int)len ] = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)pf, len );
|
|
|
|
+ int dgId = is->zDB()->getDateiGruppeVonPfad( pf );
|
|
|
|
+ delete[] pf;
|
|
|
|
+ klient->sendeEncrypted( (char *)& dgId, 4 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x2B: // Frage nach neuster Version einer Dateigruppe
|
|
|
|
+ if( klientNummer )
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int dg = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& dg, 4 );
|
|
|
|
+ int v = is->zDB()->getNeusteDateiGruppe( dg );
|
|
|
|
+ klient->sendeEncrypted( (char *)& v, 4 );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ case 0x2C: // ping
|
|
|
|
+ if( 1 )
|
|
|
|
+ {
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0x2D: // Hat Account Recht
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int recht = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& recht, 4 );
|
|
|
|
+ if( is->zDB()->hatKlientRecht( klientNummer, recht ) )
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ else
|
|
|
|
+ klient->sendeEncrypted( "\0", 1 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0x2E: // Karten Liste
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ unsigned char filterLen = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& filterLen, 1 );
|
|
|
|
+ char *filter = new char[ filterLen + 1 ];
|
|
|
|
+ filter[ (int)filterLen ] = 0;
|
|
|
|
+ if( filterLen )
|
|
|
|
+ klient->getNachrichtEncrypted( filter, filterLen );
|
|
|
|
+ char sortSpalte = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( &sortSpalte, 1 );
|
|
|
|
+ char sortRichtung = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( &sortRichtung, 1 );
|
|
|
|
+ Result res = is->zDB()->getKartenListe( klientNummer, filter, sortSpalte, sortRichtung );
|
|
|
|
+ delete[] filter;
|
|
|
|
+ klient->sendeEncrypted( (char *)& res.zeilenAnzahl, 4 );
|
|
|
|
+ for( int i = 0; i < res.zeilenAnzahl; i++ )
|
|
|
|
+ {
|
|
|
|
+ int val = res.values[ i * 6 ];
|
|
|
|
+ klient->sendeEncrypted( (char *)& val, 4 );
|
|
|
|
+ char len = (char)res.values[ i * 6 + 1 ].getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( res.values[ i * 6 + 1 ], len );
|
|
|
|
+ len = (char)res.values[ i * 6 + 2 ].getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ if( len )
|
|
|
|
+ klient->sendeEncrypted( res.values[ i * 6 + 2 ], len );
|
|
|
|
+ val = res.values[ i * 6 + 3 ];
|
|
|
|
+ klient->sendeEncrypted( (char *)& val, 4 );
|
|
|
|
+ val = res.values[ i * 6 + 4 ];
|
|
|
|
+ klient->sendeEncrypted( (char *)& val, 4 );
|
|
|
|
+ val = res.values[ i * 6 + 5 ];
|
|
|
|
+ klient->sendeEncrypted( (char *)& val, 4 );
|
|
|
|
+ }
|
|
|
|
+ res.destroy();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 0x2F: // Editor Server Anfrage
|
|
|
|
+ if( !klientNummer )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du bist nicht Identifiziert." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ int karteId = 0;
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& karteId, 4 );
|
|
|
|
+ int port = 0;
|
|
|
|
+ Text ip;
|
|
|
|
+ if( !is->zDB()->getEditorServerPortIp( klientNummer, karteId, &port, &ip ) )
|
|
|
|
+ {
|
|
|
|
+ errorZuKlient( "Du kannst diese Karte momentan nicht abrufen." );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ klient->sendeEncrypted( "\1", 1 );
|
|
|
|
+ klient->sendeEncrypted( (char *)& port, 4 );
|
|
|
|
+ char len = (char)ip.getLength();
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ klient->sendeEncrypted( ip, len );
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
case 0x30: // Karten Server Anfrage
|
|
case 0x30: // Karten Server Anfrage
|
|
if( !klientNummer )
|
|
if( !klientNummer )
|
|
@@ -1625,7 +1608,7 @@ void ISKlient::thread()
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
int karteId = 0;
|
|
int karteId = 0;
|
|
- klient->getNachrichtEncrypted( (char*)&karteId, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& karteId, 4 );
|
|
int port = 0;
|
|
int port = 0;
|
|
Text ip;
|
|
Text ip;
|
|
if( !is->zDB()->getKartenServerPortIp( klientNummer, karteId, &port, &ip ) )
|
|
if( !is->zDB()->getKartenServerPortIp( klientNummer, karteId, &port, &ip ) )
|
|
@@ -1634,52 +1617,37 @@ void ISKlient::thread()
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
- klient->sendeEncrypted( (char*)&port, 4 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)& port, 4 );
|
|
char len = (char)ip.getLength();
|
|
char len = (char)ip.getLength();
|
|
klient->sendeEncrypted( &len, 1 );
|
|
klient->sendeEncrypted( &len, 1 );
|
|
klient->sendeEncrypted( ip, len );
|
|
klient->sendeEncrypted( ip, len );
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
- default:
|
|
|
|
- errorZuKlient( "Unbekannte Nachricht!" );
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if( br )
|
|
|
|
- break;
|
|
|
|
- is->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- is->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- is->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
- is->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
- is->removeKlient( this ); // delete this
|
|
|
|
|
|
+ default:
|
|
|
|
+ errorZuKlient( "Unbekannte Nachricht!" );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if( br )
|
|
|
|
+ break;
|
|
|
|
+ is->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ is->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ is->addEmpfangen( klient->getDownloadBytes( 1 ) );
|
|
|
|
+ is->addGesendet( klient->getUploadBytes( 1 ) );
|
|
|
|
+ is->removeKlient( this ); // delete this
|
|
}
|
|
}
|
|
|
|
|
|
// constant
|
|
// constant
|
|
void ISKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
void ISKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehlernachricht zum Klient
|
|
{
|
|
{
|
|
- klient->sendeEncrypted( "\3", 1 );
|
|
|
|
- char len = (char)textLength( nachricht );
|
|
|
|
- klient->sendeEncrypted( &len, 1 );
|
|
|
|
- klient->sendeEncrypted( nachricht, len );
|
|
|
|
|
|
+ klient->sendeEncrypted( "\3", 1 );
|
|
|
|
+ char len = (char)textLength( nachricht );
|
|
|
|
+ klient->sendeEncrypted( &len, 1 );
|
|
|
|
+ klient->sendeEncrypted( nachricht, len );
|
|
}
|
|
}
|
|
|
|
|
|
int ISKlient::getKlientNummer() const // gibt die KlientId zurück
|
|
int ISKlient::getKlientNummer() const // gibt die KlientId zurück
|
|
{
|
|
{
|
|
- return klientNummer;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Reference Counting
|
|
|
|
-ISKlient *ISKlient::getThis()
|
|
|
|
-{
|
|
|
|
- ref++;
|
|
|
|
- return this;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-ISKlient *ISKlient::release()
|
|
|
|
-{
|
|
|
|
- ref--;
|
|
|
|
- if( !ref )
|
|
|
|
- delete this;
|
|
|
|
- return 0;
|
|
|
|
|
|
+ return klientNummer;
|
|
}
|
|
}
|