|
@@ -33,7 +33,6 @@ EditorServer::EditorServer( InitDatei *zIni )
|
|
end = 0;
|
|
end = 0;
|
|
nichtPausiert = 0;
|
|
nichtPausiert = 0;
|
|
InitializeCriticalSection( &cs );
|
|
InitializeCriticalSection( &cs );
|
|
- ref = 1;
|
|
|
|
if( zIni->zWert( "Aktiv" )->istGleich( "TRUE" ) )
|
|
if( zIni->zWert( "Aktiv" )->istGleich( "TRUE" ) )
|
|
{
|
|
{
|
|
serverStarten();
|
|
serverStarten();
|
|
@@ -72,7 +71,7 @@ void EditorServer::runn()
|
|
}
|
|
}
|
|
if( !klient )
|
|
if( !klient )
|
|
continue;
|
|
continue;
|
|
- EdSAKlient *clHandle = new EdSAKlient( klient, getThis() );
|
|
|
|
|
|
+ EdSAKlient * clHandle = new EdSAKlient( klient, (EditorServer *)getThis() );
|
|
clHandle->start();
|
|
clHandle->start();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -85,8 +84,8 @@ void EditorServer::thread()
|
|
klient = server->getKlient();
|
|
klient = server->getKlient();
|
|
if( !klient )
|
|
if( !klient )
|
|
continue;
|
|
continue;
|
|
- Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
|
|
- EdSKlient *clHandle = new EdSKlient( klient, getThis() );
|
|
|
|
|
|
+ Framework::getThreadRegister()->cleanUpClosedThreads();
|
|
|
|
+ EdSKlient * clHandle = new EdSKlient( klient, (EditorServer *)getThis() );
|
|
EnterCriticalSection( &cs );
|
|
EnterCriticalSection( &cs );
|
|
klients->set( clHandle, klientAnzahl );
|
|
klients->set( clHandle, klientAnzahl );
|
|
klientAnzahl++;
|
|
klientAnzahl++;
|
|
@@ -111,7 +110,7 @@ void EditorServer::close()
|
|
ende();
|
|
ende();
|
|
run = 0;
|
|
run = 0;
|
|
end = 1;
|
|
end = 1;
|
|
- Klient *klient = new Klient();
|
|
|
|
|
|
+ Klient * klient = new Klient();
|
|
klient->verbinde( aServer->getPort(), "127.0.0.1" );
|
|
klient->verbinde( aServer->getPort(), "127.0.0.1" );
|
|
Sleep( 500 );
|
|
Sleep( 500 );
|
|
aServer->trenne();
|
|
aServer->trenne();
|
|
@@ -224,7 +223,7 @@ bool EditorServer::absturzKlient( int klientId )
|
|
return gefunden;
|
|
return gefunden;
|
|
}
|
|
}
|
|
|
|
|
|
-bool EditorServer::removeKlient( EdSKlient *zKlient )
|
|
|
|
|
|
+bool EditorServer::removeKlient( EdSKlient * zKlient )
|
|
{
|
|
{
|
|
bool gefunden = 0;
|
|
bool gefunden = 0;
|
|
EnterCriticalSection( &cs );
|
|
EnterCriticalSection( &cs );
|
|
@@ -288,25 +287,10 @@ char *EditorServer::getLetzterFehler() const
|
|
return fehler->getText();
|
|
return fehler->getText();
|
|
}
|
|
}
|
|
|
|
|
|
-// Reference Counting
|
|
|
|
-EditorServer *EditorServer::getThis()
|
|
|
|
-{
|
|
|
|
- ref++;
|
|
|
|
- return this;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-EditorServer *EditorServer::release()
|
|
|
|
-{
|
|
|
|
- ref--;
|
|
|
|
- if( !ref )
|
|
|
|
- delete this;
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
|
|
|
|
// Inhalt der EdSAKlient Klasse aus EditorServer.h
|
|
// Inhalt der EdSAKlient Klasse aus EditorServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-EdSAKlient::EdSAKlient( SSLSKlient *klient, EditorServer *eds )
|
|
|
|
|
|
+EdSAKlient::EdSAKlient( SSLSKlient * klient, EditorServer * eds )
|
|
: Thread()
|
|
: Thread()
|
|
{
|
|
{
|
|
this->klient = klient;
|
|
this->klient = klient;
|
|
@@ -344,13 +328,13 @@ void EdSAKlient::thread()
|
|
{
|
|
{
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
unsigned char nLen = 0;
|
|
unsigned char nLen = 0;
|
|
- klient->getNachricht( (char*)&nLen, 1 );
|
|
|
|
|
|
+ klient->getNachricht( (char *)& nLen, 1 );
|
|
char *n = new char[ nLen + 1 ];
|
|
char *n = new char[ nLen + 1 ];
|
|
n[ (int)nLen ] = 0;
|
|
n[ (int)nLen ] = 0;
|
|
if( nLen )
|
|
if( nLen )
|
|
klient->getNachricht( n, nLen );
|
|
klient->getNachricht( n, nLen );
|
|
unsigned char pLen = 0;
|
|
unsigned char pLen = 0;
|
|
- klient->getNachricht((char*)&pLen, 1 );
|
|
|
|
|
|
+ klient->getNachricht( (char *)& pLen, 1 );
|
|
char *p = new char[ pLen + 1 ];
|
|
char *p = new char[ pLen + 1 ];
|
|
p[ (int)pLen ] = 0;
|
|
p[ (int)pLen ] = 0;
|
|
if( pLen )
|
|
if( pLen )
|
|
@@ -446,7 +430,7 @@ void EdSAKlient::thread()
|
|
}
|
|
}
|
|
else
|
|
else
|
|
ok = 1;
|
|
ok = 1;
|
|
- if( ok && eds->hatClients() )
|
|
|
|
|
|
+ if( ok &&eds->hatClients() )
|
|
{
|
|
{
|
|
errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
|
|
errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
|
|
break;
|
|
break;
|
|
@@ -542,7 +526,7 @@ void EdSAKlient::thread()
|
|
{
|
|
{
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
int maxK = 0;
|
|
int maxK = 0;
|
|
- klient->getNachricht( (char*)&maxK, 4 );
|
|
|
|
|
|
+ klient->getNachricht( (char *)& maxK, 4 );
|
|
if( eds->zDB()->adminHatRecht( adminId, Admin_Recht::EdSMKChange ) )
|
|
if( eds->zDB()->adminHatRecht( adminId, Admin_Recht::EdSMKChange ) )
|
|
{
|
|
{
|
|
if( eds->setMaxKarten( maxK ) )
|
|
if( eds->setMaxKarten( maxK ) )
|
|
@@ -564,8 +548,8 @@ void EdSAKlient::thread()
|
|
{
|
|
{
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
int klientId = 0;
|
|
int klientId = 0;
|
|
- klient->getNachricht( (char*)&klientId, 4 );
|
|
|
|
- if( klientId && eds->absturzKlient( klientId ) )
|
|
|
|
|
|
+ klient->getNachricht( (char *)& klientId, 4 );
|
|
|
|
+ if( klientId &&eds->absturzKlient( klientId ) )
|
|
klient->sende( "\1", 1 );
|
|
klient->sende( "\1", 1 );
|
|
else
|
|
else
|
|
klient->sende( "\0", 1 );
|
|
klient->sende( "\0", 1 );
|
|
@@ -597,13 +581,13 @@ void EdSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Feh
|
|
|
|
|
|
// Inhalt der EdSKlient aus EditorServer.h
|
|
// Inhalt der EdSKlient aus EditorServer.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-EdSKlient::EdSKlient( SKlient *klient, EditorServer *eds )
|
|
|
|
|
|
+EdSKlient::EdSKlient( SKlient * klient, EditorServer * eds )
|
|
: Thread()
|
|
: Thread()
|
|
{
|
|
{
|
|
this->klient = klient;
|
|
this->klient = klient;
|
|
unsigned char key[ 20 ] = { 55, 124, 19, 204, 23, 5, 59, 75, 247, 138, 119, 111, 57, 250, 206, 187, 165, 6, 247, 151 };
|
|
unsigned char key[ 20 ] = { 55, 124, 19, 204, 23, 5, 59, 75, 247, 138, 119, 111, 57, 250, 206, 187, 165, 6, 247, 151 };
|
|
- klient->setSendeKey( (char*)key, 20 );
|
|
|
|
- klient->setEmpfangKey( (char*)key, 20 );
|
|
|
|
|
|
+ klient->setSendeKey( (char *)key, 20 );
|
|
|
|
+ klient->setEmpfangKey( (char *)key, 20 );
|
|
klientNummer = 0;
|
|
klientNummer = 0;
|
|
this->eds = eds;
|
|
this->eds = eds;
|
|
ked = 0;
|
|
ked = 0;
|
|
@@ -640,7 +624,7 @@ void EdSKlient::thread()
|
|
switch( c )
|
|
switch( c )
|
|
{
|
|
{
|
|
case 1: // Klient identifikation
|
|
case 1: // Klient identifikation
|
|
- klient->getNachrichtEncrypted( (char*)&klientNummer, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& klientNummer, 4 );
|
|
if( !eds->zDB()->proveKlient( klientNummer, eds->getId() ) )
|
|
if( !eds->zDB()->proveKlient( klientNummer, eds->getId() ) )
|
|
{
|
|
{
|
|
klientNummer = 0;
|
|
klientNummer = 0;
|
|
@@ -671,8 +655,8 @@ void EdSKlient::thread()
|
|
if( 1 )
|
|
if( 1 )
|
|
{
|
|
{
|
|
int klientId = 0;
|
|
int klientId = 0;
|
|
- klient->getNachrichtEncrypted( (char*)&klientId, 4 );
|
|
|
|
- if( klientId && eds->absturzKlient( klientId ) )
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& klientId, 4 );
|
|
|
|
+ if( klientId &&eds->absturzKlient( klientId ) )
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
else
|
|
else
|
|
klient->sendeEncrypted( "\0", 1 );
|
|
klient->sendeEncrypted( "\0", 1 );
|
|
@@ -715,7 +699,7 @@ void EdSKlient::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 );
|
|
if( eds->zDB()->proveKarte( karteId, klientNummer, eds->getId() ) )
|
|
if( eds->zDB()->proveKarte( karteId, klientNummer, eds->getId() ) )
|
|
{
|
|
{
|
|
if( ked )
|
|
if( ked )
|
|
@@ -762,7 +746,7 @@ void EdSKlient::thread()
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
int id = 0;
|
|
int id = 0;
|
|
- klient->getNachrichtEncrypted( (char*)&id, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
if( ked )
|
|
if( ked )
|
|
ked->release();
|
|
ked->release();
|
|
ked = new KarteEditor( id, eds->zDB()->getThis(), eds->zIni()->zWert( "KartenPfad" )->getText(), eds->zIni() );
|
|
ked = new KarteEditor( id, eds->zDB()->getThis(), eds->zIni()->zWert( "KartenPfad" )->getText(), eds->zIni() );
|
|
@@ -774,8 +758,8 @@ void EdSKlient::thread()
|
|
}
|
|
}
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
RCArray< Text > *list = new RCArray< Text >();
|
|
RCArray< Text > *list = new RCArray< Text >();
|
|
- int anz = ked->getDateiUpdateListe( ( char* )"shop", list );
|
|
|
|
- klient->sendeEncrypted( (char*)&anz, 4 );
|
|
|
|
|
|
+ int anz = ked->getDateiUpdateListe( ( char * )"shop", list );
|
|
|
|
+ klient->sendeEncrypted( (char *)& anz, 4 );
|
|
for( int i = 0; i < anz; i++ )
|
|
for( int i = 0; i < anz; i++ )
|
|
{
|
|
{
|
|
Text p = list->z( i )->getText();
|
|
Text p = list->z( i )->getText();
|
|
@@ -784,11 +768,11 @@ void EdSKlient::thread()
|
|
klient->sendeEncrypted( p, l );
|
|
klient->sendeEncrypted( p, l );
|
|
Text tmp = ked->getPfad();
|
|
Text tmp = ked->getPfad();
|
|
tmp += "/live/shop";
|
|
tmp += "/live/shop";
|
|
- p.insert( 0, (char*)tmp );
|
|
|
|
|
|
+ p.insert( 0, (char *)tmp );
|
|
Datei d;
|
|
Datei d;
|
|
d.setDatei( p );
|
|
d.setDatei( p );
|
|
__int64 size = d.getSize();
|
|
__int64 size = d.getSize();
|
|
- klient->sendeEncrypted( (char*)&size, 8 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)& size, 8 );
|
|
d.open( Datei::Style::lesen );
|
|
d.open( Datei::Style::lesen );
|
|
char *buffer = new char[ 2048 ];
|
|
char *buffer = new char[ 2048 ];
|
|
while( size )
|
|
while( size )
|
|
@@ -816,7 +800,7 @@ void EdSKlient::thread()
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
int id = 0;
|
|
int id = 0;
|
|
- klient->getNachrichtEncrypted( (char*)&id, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& id, 4 );
|
|
if( ked )
|
|
if( ked )
|
|
ked->release();
|
|
ked->release();
|
|
ked = new KarteEditor( id, eds->zDB()->getThis(), eds->zIni()->zWert( "KartenPfad" )->getText(), eds->zIni() );
|
|
ked = new KarteEditor( id, eds->zDB()->getThis(), eds->zIni()->zWert( "KartenPfad" )->getText(), eds->zIni() );
|
|
@@ -828,8 +812,8 @@ void EdSKlient::thread()
|
|
}
|
|
}
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
RCArray< Text > *list = new RCArray< Text >();
|
|
RCArray< Text > *list = new RCArray< Text >();
|
|
- int anz = ked->getDateiUpdateListe( ( char* )"map", list );
|
|
|
|
- klient->sendeEncrypted( (char*)&anz, 4 );
|
|
|
|
|
|
+ int anz = ked->getDateiUpdateListe( ( char * )"map", list );
|
|
|
|
+ klient->sendeEncrypted( (char *)& anz, 4 );
|
|
for( int i = 0; i < anz; i++ )
|
|
for( int i = 0; i < anz; i++ )
|
|
{
|
|
{
|
|
Text p = list->z( i )->getText();
|
|
Text p = list->z( i )->getText();
|
|
@@ -838,11 +822,11 @@ void EdSKlient::thread()
|
|
klient->sendeEncrypted( p, l );
|
|
klient->sendeEncrypted( p, l );
|
|
Text tmp = ked->getPfad();
|
|
Text tmp = ked->getPfad();
|
|
tmp += "/live/map";
|
|
tmp += "/live/map";
|
|
- p.insert( 0, (char*)tmp );
|
|
|
|
|
|
+ p.insert( 0, (char *)tmp );
|
|
Datei d;
|
|
Datei d;
|
|
d.setDatei( p );
|
|
d.setDatei( p );
|
|
__int64 size = d.getSize();
|
|
__int64 size = d.getSize();
|
|
- klient->sendeEncrypted( (char*)&size, 8 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)& size, 8 );
|
|
d.open( Datei::Style::lesen );
|
|
d.open( Datei::Style::lesen );
|
|
char *buffer = new char[ 2048 ];
|
|
char *buffer = new char[ 2048 ];
|
|
while( size )
|
|
while( size )
|
|
@@ -871,12 +855,12 @@ void EdSKlient::thread()
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
unsigned char l = 0;
|
|
unsigned char l = 0;
|
|
- klient->getNachrichtEncrypted((char*)&l, 1 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& l, 1 );
|
|
char *n = new char[ l + 1 ];
|
|
char *n = new char[ l + 1 ];
|
|
n[ (int)l ] = 0;
|
|
n[ (int)l ] = 0;
|
|
klient->getNachrichtEncrypted( n, l );
|
|
klient->getNachrichtEncrypted( n, l );
|
|
int spielArt = 0;
|
|
int spielArt = 0;
|
|
- klient->getNachrichtEncrypted( (char*)&spielArt, 4 );
|
|
|
|
|
|
+ klient->getNachrichtEncrypted( (char *)& spielArt, 4 );
|
|
if( eds->zDB()->karteErstellen( n, spielArt, klientNummer ) )
|
|
if( eds->zDB()->karteErstellen( n, spielArt, klientNummer ) )
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
klient->sendeEncrypted( "\1", 1 );
|
|
else
|
|
else
|
|
@@ -905,26 +889,11 @@ void EdSKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehl
|
|
{
|
|
{
|
|
klient->sendeEncrypted( "\3", 1 );
|
|
klient->sendeEncrypted( "\3", 1 );
|
|
unsigned char len = (unsigned char)textLength( nachricht );
|
|
unsigned char len = (unsigned char)textLength( nachricht );
|
|
- klient->sendeEncrypted( (char*)&len, 1 );
|
|
|
|
|
|
+ klient->sendeEncrypted( (char *)& len, 1 );
|
|
klient->sendeEncrypted( nachricht, len );
|
|
klient->sendeEncrypted( nachricht, len );
|
|
}
|
|
}
|
|
|
|
|
|
int EdSKlient::getKlientNummer() const // gibt die KlientId zurück
|
|
int EdSKlient::getKlientNummer() const // gibt die KlientId zurück
|
|
{
|
|
{
|
|
return klientNummer;
|
|
return klientNummer;
|
|
-}
|
|
|
|
-
|
|
|
|
-// Reference Counting
|
|
|
|
-EdSKlient *EdSKlient::getThis()
|
|
|
|
-{
|
|
|
|
- ref++;
|
|
|
|
- return this;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-EdSKlient *EdSKlient::release()
|
|
|
|
-{
|
|
|
|
- ref--;
|
|
|
|
- if( !ref )
|
|
|
|
- delete this;
|
|
|
|
- return 0;
|
|
|
|
}
|
|
}
|