|
@@ -4,20 +4,20 @@
|
|
|
// Inhalt der MSDatenbank Klasse aus Datenbank.h
|
|
|
// Konstruktor
|
|
|
MSDatenbank::MSDatenbank( InitDatei *zDat )
|
|
|
+ : ReferenceCounter()
|
|
|
{
|
|
|
- datenbank = new Datenbank( zDat->zWert( "DBBenutzer" )->getText(), zDat->zWert( "DBPasswort" )->getText(),
|
|
|
- zDat->zWert( "DBName" )->getText(), zDat->zWert( "DBIP" )->getText(),
|
|
|
- (unsigned short)TextZuInt( zDat->zWert( "DBPort" )->getText(), 10 ) );
|
|
|
- if( !datenbank->istOk() )
|
|
|
- {
|
|
|
- std::cout << "MS: Es konnte keine Verbindung zur Datenbank hergestellt werden:\n";
|
|
|
- Text *txt = datenbank->getLetzterFehler();
|
|
|
- std::cout << txt->getText() << "\nDas Programm wird beendet.";
|
|
|
- txt->release();
|
|
|
- exit( 1 );
|
|
|
- }
|
|
|
- InitializeCriticalSection( &ths );
|
|
|
- ref = 1;
|
|
|
+ datenbank = new Datenbank( zDat->zWert( "DBBenutzer" )->getText(), zDat->zWert( "DBPasswort" )->getText(),
|
|
|
+ zDat->zWert( "DBName" )->getText(), zDat->zWert( "DBIP" )->getText(),
|
|
|
+ (unsigned short)TextZuInt( zDat->zWert( "DBPort" )->getText(), 10 ) );
|
|
|
+ if( !datenbank->istOk() )
|
|
|
+ {
|
|
|
+ std::cout << "MS: Es konnte keine Verbindung zur Datenbank hergestellt werden:\n";
|
|
|
+ Text *txt = datenbank->getLetzterFehler();
|
|
|
+ std::cout << txt->getText() << "\nDas Programm wird beendet.";
|
|
|
+ txt->release();
|
|
|
+ exit( 1 );
|
|
|
+ }
|
|
|
+ InitializeCriticalSection( &ths );
|
|
|
Text befehl = "SELECT port, admin_port FROM server WHERE id = ";
|
|
|
befehl += zDat->zWert( "ServerId" )->getText();
|
|
|
lock();
|
|
@@ -35,279 +35,279 @@ MSDatenbank::MSDatenbank( InitDatei *zDat )
|
|
|
// Detruktor
|
|
|
MSDatenbank::~MSDatenbank()
|
|
|
{
|
|
|
- datenbank->release();
|
|
|
- DeleteCriticalSection( &ths );
|
|
|
+ datenbank->release();
|
|
|
+ DeleteCriticalSection( &ths );
|
|
|
}
|
|
|
|
|
|
// nicht constant
|
|
|
void MSDatenbank::lock()
|
|
|
{
|
|
|
- EnterCriticalSection( &ths );
|
|
|
+ EnterCriticalSection( &ths );
|
|
|
}
|
|
|
|
|
|
void MSDatenbank::unlock()
|
|
|
{
|
|
|
- LeaveCriticalSection( &ths );
|
|
|
+ LeaveCriticalSection( &ths );
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::istAdministrator( const char *name, const char *passwort )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT id FROM benutzer WHERE name = '" );
|
|
|
- Text n( name );
|
|
|
- n.ersetzen( "'", "''" );
|
|
|
- befehl->append( (char*)n );
|
|
|
- befehl->append( "' AND passwort = md5( '" );
|
|
|
- Text p( passwort );
|
|
|
- p.ersetzen( "'", "''" );
|
|
|
- befehl->append( (char*)p );
|
|
|
- befehl->append( "' )" );
|
|
|
- lock();
|
|
|
- datenbank->befehl( befehl->getText() );
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- int ret = 0;
|
|
|
- if( res.zeilenAnzahl > 0 )
|
|
|
- ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT id FROM benutzer WHERE name = '" );
|
|
|
+ Text n( name );
|
|
|
+ n.ersetzen( "'", "''" );
|
|
|
+ befehl->append( (char *)n );
|
|
|
+ befehl->append( "' AND passwort = md5( '" );
|
|
|
+ Text p( passwort );
|
|
|
+ p.ersetzen( "'", "''" );
|
|
|
+ befehl->append( (char *)p );
|
|
|
+ befehl->append( "' )" );
|
|
|
+ lock();
|
|
|
+ datenbank->befehl( befehl->getText() );
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ int ret = 0;
|
|
|
+ if( res.zeilenAnzahl > 0 )
|
|
|
+ ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::adminHatRecht( int id, int recht )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT * FROM benutzer_rechte WHERE benutzer_id = " );
|
|
|
- befehl->append( id );
|
|
|
- befehl->append( " AND rechte_id = " );
|
|
|
- befehl->append( recht );
|
|
|
- lock();
|
|
|
- datenbank->befehl( befehl->getText() );
|
|
|
- int ret = datenbank->getZeilenAnzahl();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return ret != 0;
|
|
|
+ Text *befehl = new Text( "SELECT * FROM benutzer_rechte WHERE benutzer_id = " );
|
|
|
+ befehl->append( id );
|
|
|
+ befehl->append( " AND rechte_id = " );
|
|
|
+ befehl->append( recht );
|
|
|
+ lock();
|
|
|
+ datenbank->befehl( befehl->getText() );
|
|
|
+ int ret = datenbank->getZeilenAnzahl();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return ret != 0;
|
|
|
}
|
|
|
|
|
|
unsigned int MSDatenbank::getNextClientId()
|
|
|
{
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( "SELECT get_next_client_id()" ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- unsigned int ret = (unsigned int)TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( "SELECT get_next_client_id()" ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ unsigned int ret = (unsigned int)TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
Text *MSDatenbank::getKlientKey( int cId )
|
|
|
{
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( Text( "SELECT schluessel FROM client WHERE id = " ) += cId ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Text *ret = new Text( res.values[ 0 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( Text( "SELECT schluessel FROM client WHERE id = " ) += cId ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Text *ret = new Text( res.values[ 0 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::proveRegisteredClient( unsigned int num )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT * FROM client WHERE id = " );
|
|
|
- befehl->append( num );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- befehl->release();
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- bool ret = res.zeilenAnzahl == 1;
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT * FROM client WHERE id = " );
|
|
|
+ befehl->append( num );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ befehl->release();
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ bool ret = res.zeilenAnzahl == 1;
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int *MSDatenbank::unregisterClient( unsigned int num, int *len )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT unregister_client( " );
|
|
|
- befehl->append( num );
|
|
|
- befehl->append( " )" );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( len )
|
|
|
- *len = res.zeilenAnzahl;
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- int *ret = new int[ res.zeilenAnzahl ];
|
|
|
- for( int i = 0; i < res.zeilenAnzahl; i++ )
|
|
|
- ret[ i ] = TextZuInt( res.values[ i ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT unregister_client( " );
|
|
|
+ befehl->append( num );
|
|
|
+ befehl->append( " )" );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( len )
|
|
|
+ *len = res.zeilenAnzahl;
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ int *ret = new int[ res.zeilenAnzahl ];
|
|
|
+ for( int i = 0; i < res.zeilenAnzahl; i++ )
|
|
|
+ ret[ i ] = TextZuInt( res.values[ i ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::suchPatchServer( unsigned int client )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT such_server( " );
|
|
|
- befehl->append( client );
|
|
|
- befehl->append( ", 'patch' )" );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- befehl->release();
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT such_server( " );
|
|
|
+ befehl->append( client );
|
|
|
+ befehl->append( ", 'patch' )" );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ befehl->release();
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::suchRegisterServer( unsigned int client )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT such_server( " );
|
|
|
- befehl->append( client );
|
|
|
- befehl->append( ", 'register' )" );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- befehl->release();
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT such_server( " );
|
|
|
+ befehl->append( client );
|
|
|
+ befehl->append( ", 'register' )" );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ befehl->release();
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::suchLoginServer( unsigned int client )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT such_server( " );
|
|
|
- befehl->append( client );
|
|
|
- befehl->append( ", 'login' )" );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- befehl->release();
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT such_server( " );
|
|
|
+ befehl->append( client );
|
|
|
+ befehl->append( ", 'login' )" );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ befehl->release();
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::suchInformationServer( unsigned int client )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT such_server( " );
|
|
|
- befehl->append( client );
|
|
|
- befehl->append( ", 'information' )" );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- befehl->release();
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT such_server( " );
|
|
|
+ befehl->append( client );
|
|
|
+ befehl->append( ", 'information' )" );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ befehl->release();
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::suchChatServer( unsigned int client )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT such_server( " );
|
|
|
- befehl->append( client );
|
|
|
- befehl->append( ", 'chat' )" );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- befehl->release();
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT such_server( " );
|
|
|
+ befehl->append( client );
|
|
|
+ befehl->append( ", 'chat' )" );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ befehl->release();
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::suchAnmeldungServer( unsigned int client )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT such_server( " );
|
|
|
- befehl->append( client );
|
|
|
- befehl->append( ", 'anmeldung' )" );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- befehl->release();
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT such_server( " );
|
|
|
+ befehl->append( client );
|
|
|
+ befehl->append( ", 'anmeldung' )" );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ befehl->release();
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::suchErhaltungServer( unsigned int client )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT such_server( " );
|
|
|
- befehl->append( client );
|
|
|
- befehl->append( ", 'erhaltung' )" );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- befehl->release();
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT such_server( " );
|
|
|
+ befehl->append( client );
|
|
|
+ befehl->append( ", 'erhaltung' )" );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ befehl->release();
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::suchShopServer( unsigned int client )
|
|
@@ -315,7 +315,7 @@ int MSDatenbank::suchShopServer( unsigned int client )
|
|
|
Text befehl = "SELECT server_id FROM server_client a, server b WHERE a.server_id = b.id AND b.server_typ_name = 'shop' AND a.client_id = ";
|
|
|
befehl += (int)client;
|
|
|
lock();
|
|
|
- if( !datenbank->befehl( (char*)befehl ) )
|
|
|
+ if( !datenbank->befehl( (char *)befehl ) )
|
|
|
{
|
|
|
unlock();
|
|
|
return 0;
|
|
@@ -330,7 +330,7 @@ int MSDatenbank::suchShopServer( unsigned int client )
|
|
|
}
|
|
|
res.destroy();
|
|
|
lock();
|
|
|
- if( !datenbank->befehl( "SELECT a.id, count( b.client_id ) AS anz FROM server a LEFT JOIN server_client b ON a.id = b.server_id WHERE a.server_typ_name = 'shop' AND a.server_status_id = 3 GROUP BY a.id ORDER BY anz LIMIT 1" ) )
|
|
|
+ if( !datenbank->befehl( "SELECT a.id, count( b.client_id ) AS anz FROM server a LEFT JOIN server_client b ON a.id = b.server_id WHERE a.server_typ_name = 'shop' AND a.server_status_id = 3 GROUP BY a.id ORDER BY anz LIMIT 1" ) )
|
|
|
{
|
|
|
unlock();
|
|
|
return 0;
|
|
@@ -345,39 +345,39 @@ int MSDatenbank::suchShopServer( unsigned int client )
|
|
|
}
|
|
|
int id = res.values[ 0 ];
|
|
|
res.destroy();
|
|
|
- befehl = "INSERT INTO server_client( client_id, server_id ) VALUES ( ";
|
|
|
+ befehl = "INSERT INTO server_client( client_id, server_id ) VALUES ( ";
|
|
|
befehl += (int)client;
|
|
|
befehl += ", ";
|
|
|
befehl += id;
|
|
|
befehl += " )";
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( (char*)befehl ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- unlock();
|
|
|
- return id;
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( (char *)befehl ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ unlock();
|
|
|
+ return id;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::suchNewsServer( unsigned int client )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT such_server( " );
|
|
|
- befehl->append( client );
|
|
|
- befehl->append( ", 'news' )" );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- befehl->release();
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT such_server( " );
|
|
|
+ befehl->append( client );
|
|
|
+ befehl->append( ", 'news' )" );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ befehl->release();
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::suchMinigameServer( unsigned int client )
|
|
@@ -436,564 +436,564 @@ unsigned char *MSDatenbank::getServerPortIp( int sId )
|
|
|
|
|
|
int MSDatenbank::logoutKlient( int klientId, Array< int > *ret )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT logout_client( " );
|
|
|
- befehl->append( klientId );
|
|
|
- befehl->append( " )" );
|
|
|
- lock();
|
|
|
- datenbank->befehl( befehl->getText() );
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- for( int i = 0; i < res.zeilenAnzahl; i++ )
|
|
|
- ret->set( TextZuInt( res.values[ i ].getText(), 10 ), i );
|
|
|
- int retVal = res.zeilenAnzahl;
|
|
|
- res.destroy();
|
|
|
- return retVal;
|
|
|
+ Text *befehl = new Text( "SELECT logout_client( " );
|
|
|
+ befehl->append( klientId );
|
|
|
+ befehl->append( " )" );
|
|
|
+ lock();
|
|
|
+ datenbank->befehl( befehl->getText() );
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ for( int i = 0; i < res.zeilenAnzahl; i++ )
|
|
|
+ ret->set( TextZuInt( res.values[ i ].getText(), 10 ), i );
|
|
|
+ int retVal = res.zeilenAnzahl;
|
|
|
+ res.destroy();
|
|
|
+ return retVal;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getSpielServerPortIp( int spielErstelltId, unsigned short *port, Text *ip )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, spiel_erstellt b "
|
|
|
- "WHERE a.id = b.server_spiel_id AND b.id = " );
|
|
|
- befehl->append( spielErstelltId );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- *port = (unsigned short)TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, spiel_erstellt b "
|
|
|
+ "WHERE a.id = b.server_spiel_id AND b.id = " );
|
|
|
+ befehl->append( spielErstelltId );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ *port = (unsigned short)TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::getSpielerAusGruppe( int gruppeId, Array< int > *accountId )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT account_id FROM gruppe_spieler WHERE gruppe_id = " );
|
|
|
- befehl->append( gruppeId );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- int ret = res.zeilenAnzahl;
|
|
|
- for( int i = 0; i < ret; i++ )
|
|
|
- accountId->add( TextZuInt( res.values[ i ].getText(), 10 ), i );
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT account_id FROM gruppe_spieler WHERE gruppe_id = " );
|
|
|
+ befehl->append( gruppeId );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ int ret = res.zeilenAnzahl;
|
|
|
+ for( int i = 0; i < ret; i++ )
|
|
|
+ accountId->add( TextZuInt( res.values[ i ].getText(), 10 ), i );
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::kickSpielerAusGruppe( int gruppeId, int accountId )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT spieler_verlaesst_gruppe( " );
|
|
|
- befehl->append( accountId );
|
|
|
- befehl->append( ", " );
|
|
|
- befehl->append( gruppeId );
|
|
|
- befehl->append( " )" );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT spieler_verlaesst_gruppe( " );
|
|
|
+ befehl->append( accountId );
|
|
|
+ befehl->append( ", " );
|
|
|
+ befehl->append( gruppeId );
|
|
|
+ befehl->append( " )" );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getChatServerPortIp( int accountId, unsigned short *port, Text *ip )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b, account_client c "
|
|
|
- "WHERE a.server_typ_name = 'char' AND c.client_id = b.client_id AND a.id = b.server_id AND c.account_id = " );
|
|
|
- befehl->append( accountId );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- *port = (unsigned short)TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b, account_client c "
|
|
|
+ "WHERE a.server_typ_name = 'char' AND c.client_id = b.client_id AND a.id = b.server_id AND c.account_id = " );
|
|
|
+ befehl->append( accountId );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ *port = (unsigned short)TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
int MSDatenbank::getGruppeAdmin( int gruppeId )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT admin_account_id FROM gruppe WHERE id = " );
|
|
|
- befehl->append( gruppeId );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-int MSDatenbank::getSpielerAusChatroom( int chatroomId, Array< int > *accountId )
|
|
|
-{
|
|
|
- Text *befehl = new Text( "SELECT account_id FROM chatroom_spieler WHERE chatroom_id = " );
|
|
|
- befehl->append( chatroomId );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- int ret = res.zeilenAnzahl;
|
|
|
- for( int i = 0; i < ret; i++ )
|
|
|
- accountId->add( TextZuInt( res.values[ i ].getText(), 10 ), i );
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-int MSDatenbank::getChatroomAdmin( int chatroomId )
|
|
|
-{
|
|
|
- Text *befehl = new Text( "SELECT admin_account_id FROM chatroom WHERE id = " );
|
|
|
- befehl->append( chatroomId );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
+ Text *befehl = new Text( "SELECT admin_account_id FROM gruppe WHERE id = " );
|
|
|
+ befehl->append( gruppeId );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+int MSDatenbank::getSpielerAusChatroom( int chatroomId, Array< int > *accountId )
|
|
|
+{
|
|
|
+ Text *befehl = new Text( "SELECT account_id FROM chatroom_spieler WHERE chatroom_id = " );
|
|
|
+ befehl->append( chatroomId );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ int ret = res.zeilenAnzahl;
|
|
|
+ for( int i = 0; i < ret; i++ )
|
|
|
+ accountId->add( TextZuInt( res.values[ i ].getText(), 10 ), i );
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+int MSDatenbank::getChatroomAdmin( int chatroomId )
|
|
|
+{
|
|
|
+ Text *befehl = new Text( "SELECT admin_account_id FROM chatroom WHERE id = " );
|
|
|
+ befehl->append( chatroomId );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
int MSDatenbank::clientistEingeloggt( int clientId )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT account_id FROM account_client WHERE client_id = " );
|
|
|
- befehl->append( clientId );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT account_id FROM account_client WHERE client_id = " );
|
|
|
+ befehl->append( clientId );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getPatchServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
- "WHERE a.server_typ_name = 'patch' AND a.id = b.server_id AND b.client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
+ "WHERE a.server_typ_name = 'patch' AND a.id = b.server_id AND b.client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getRegisterServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
- "WHERE a.server_typ_name = 'register' AND a.id = b.server_id AND b.client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
+ "WHERE a.server_typ_name = 'register' AND a.id = b.server_id AND b.client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getLoginServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
- "WHERE a.server_typ_name = 'login' AND a.id = b.server_id AND b.client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
+ "WHERE a.server_typ_name = 'login' AND a.id = b.server_id AND b.client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getInformationServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
- "WHERE a.server_typ_name = 'information' AND a.id = b.server_id AND b.client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
+ "WHERE a.server_typ_name = 'information' AND a.id = b.server_id AND b.client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getChatServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
- "WHERE a.server_typ_name = 'chat' AND a.id = b.server_id AND b.client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
+ "WHERE a.server_typ_name = 'chat' AND a.id = b.server_id AND b.client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getAnmeldungServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
- "WHERE a.server_typ_name = 'anmeldung' AND a.id = b.server_id AND b.client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
+ "WHERE a.server_typ_name = 'anmeldung' AND a.id = b.server_id AND b.client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getSpielServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT account_id FROM account_client WHERE client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- int accountId = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- befehl->setText( "SELECT a.id FROM spiel a, spiel_spieler b WHERE b.spiel_id = a.id "
|
|
|
- "AND a.spiel_status_id < 3 AND b.spiel_spieler_status_id = 5 AND b.account_id = " );
|
|
|
- befehl->append( accountId );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- int spielId = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- befehl->setText( "SELECT spiel_server_id FROM spiel WHERE id = " );
|
|
|
- befehl->append( spielId );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- int serverId = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- res.destroy();
|
|
|
- befehl->setText( "SELECT port, ip FROM server WHERE id = " );
|
|
|
- befehl->append( serverId );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT account_id FROM account_client WHERE client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ int accountId = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ befehl->setText( "SELECT a.id FROM spiel a, spiel_spieler b WHERE b.spiel_id = a.id "
|
|
|
+ "AND a.spiel_status_id < 3 AND b.spiel_spieler_status_id = 5 AND b.account_id = " );
|
|
|
+ befehl->append( accountId );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ int spielId = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ befehl->setText( "SELECT spiel_server_id FROM spiel WHERE id = " );
|
|
|
+ befehl->append( spielId );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ int serverId = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ res.destroy();
|
|
|
+ befehl->setText( "SELECT port, ip FROM server WHERE id = " );
|
|
|
+ befehl->append( serverId );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getShopServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
- "WHERE a.server_typ_name = 'shop' AND a.id = b.server_id AND b.client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
+ "WHERE a.server_typ_name = 'shop' AND a.id = b.server_id AND b.client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getNewsServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
- "WHERE a.server_typ_name = 'news' AND a.id = b.server_id AND b.client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
+ "WHERE a.server_typ_name = 'news' AND a.id = b.server_id AND b.client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getHistorieServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
- "WHERE a.server_typ_name = 'historie' AND a.id = b.server_id AND b.client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
+ "WHERE a.server_typ_name = 'historie' AND a.id = b.server_id AND b.client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getKartenServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
- "WHERE a.server_typ_name = 'karten' AND a.id = b.server_id AND b.client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server a, server_client b "
|
|
|
+ "WHERE a.server_typ_name = 'karten' AND a.id = b.server_id AND b.client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getEditorServer( int client, Text *ip, int *port )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT a.port, a.ip FROM server AS a, server_client AS b "
|
|
|
- "WHERE a.server_typ_name = 'editor' AND a.id = b.server_id AND b.client_id = " );
|
|
|
- befehl->append( client );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
- {
|
|
|
- res.destroy();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
- ip->setText( res.values[ 1 ].getText() );
|
|
|
- res.destroy();
|
|
|
- return 1;
|
|
|
+ Text *befehl = new Text( "SELECT a.port, a.ip FROM server AS a, server_client AS b "
|
|
|
+ "WHERE a.server_typ_name = 'editor' AND a.id = b.server_id AND b.client_id = " );
|
|
|
+ befehl->append( client );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ if( !res.zeilenAnzahl )
|
|
|
+ {
|
|
|
+ res.destroy();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ *port = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
+ ip->setText( res.values[ 1 ].getText() );
|
|
|
+ res.destroy();
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
bool MSDatenbank::getMinigameServer( int client, Text *ip, int *port )
|
|
@@ -1022,7 +1022,7 @@ bool MSDatenbank::getMinigameServer( int client, Text *ip, int *port )
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-bool MSDatenbank::getPatchServerList( Array< ServerData* > *list )
|
|
|
+bool MSDatenbank::getPatchServerList( Array< ServerData * > *list )
|
|
|
{
|
|
|
lock();
|
|
|
if( !datenbank->befehl( "SELECT a.id, a.name, a.ip, a.port, a.admin_port, b.bezeichnung FROM server a, server_status b WHERE a.server_status_id = b.id AND a.server_typ_name = 'patch'" ) )
|
|
@@ -1061,27 +1061,12 @@ bool MSDatenbank::getPatchServerDetails( int id, ServerDetails *details )
|
|
|
unlock();
|
|
|
if( !res.zeilenAnzahl )
|
|
|
return 0;
|
|
|
- details->name = (char*)res.values[ 0 ];
|
|
|
- details->ip = (char*)res.values[ 1 ];
|
|
|
+ details->name = (char *)res.values[ 0 ];
|
|
|
+ details->ip = (char *)res.values[ 1 ];
|
|
|
details->port = (unsigned short)(int)res.values[ 2 ];
|
|
|
details->adminPort = (unsigned short)(int)res.values[ 3 ];
|
|
|
details->tasks = res.values[ 4 ];
|
|
|
details->maxTasks = res.values[ 5 ];
|
|
|
res.destroy();
|
|
|
return 1;
|
|
|
-}
|
|
|
-
|
|
|
-// Reference Counting
|
|
|
-MSDatenbank *MSDatenbank::getThis()
|
|
|
-{
|
|
|
- ref++;
|
|
|
- return this;
|
|
|
-}
|
|
|
-
|
|
|
-MSDatenbank *MSDatenbank::release()
|
|
|
-{
|
|
|
- ref--;
|
|
|
- if( !ref )
|
|
|
- delete this;
|
|
|
- return 0;
|
|
|
}
|