|
@@ -5,17 +5,17 @@
|
|
|
// Inhalt der ESDatenbank Klasse aus Datenbank.h
|
|
|
// Konstruktor
|
|
|
ESDatenbank::ESDatenbank( InitDatei *zIni )
|
|
|
+ : ReferenceCounter()
|
|
|
{
|
|
|
- datenbank = new Datenbank( zIni->zWert( "DBBenutzer" )->getText(), zIni->zWert( "DBPasswort" )->getText(),
|
|
|
- zIni->zWert( "DBName" )->getText(), zIni->zWert( "DBIP" )->getText(),
|
|
|
- (unsigned short)TextZuInt( zIni->zWert( "DBPort" )->getText(), 10 ) );
|
|
|
+ datenbank = new Datenbank( zIni->zWert( "DBBenutzer" )->getText(), zIni->zWert( "DBPasswort" )->getText(),
|
|
|
+ zIni->zWert( "DBName" )->getText(), zIni->zWert( "DBIP" )->getText(),
|
|
|
+ (unsigned short)TextZuInt( zIni->zWert( "DBPort" )->getText(), 10 ) );
|
|
|
if( !datenbank->istOk() )
|
|
|
{
|
|
|
std::cout << "ES: Die Verbindung zur Datenbank konnte nicht hergestellt werden.\nDas Programm wird beendet.";
|
|
|
exit( 1 );
|
|
|
}
|
|
|
- InitializeCriticalSection( &cs );
|
|
|
- ref = 1;
|
|
|
+ InitializeCriticalSection( &cs );
|
|
|
Text befehl = "SELECT port, admin_port FROM server WHERE id = ";
|
|
|
befehl += zIni->zWert( "ServerId" )->getText();
|
|
|
lock();
|
|
@@ -33,475 +33,475 @@ ESDatenbank::ESDatenbank( InitDatei *zIni )
|
|
|
// Destruktor
|
|
|
ESDatenbank::~ESDatenbank()
|
|
|
{
|
|
|
- datenbank->release();
|
|
|
- DeleteCriticalSection( &cs );
|
|
|
+ datenbank->release();
|
|
|
+ DeleteCriticalSection( &cs );
|
|
|
}
|
|
|
|
|
|
// nicht constant
|
|
|
void ESDatenbank::lock()
|
|
|
{
|
|
|
- EnterCriticalSection( &cs );
|
|
|
+ EnterCriticalSection( &cs );
|
|
|
}
|
|
|
|
|
|
void ESDatenbank::unlock()
|
|
|
{
|
|
|
- LeaveCriticalSection( &cs );
|
|
|
+ LeaveCriticalSection( &cs );
|
|
|
}
|
|
|
|
|
|
int ESDatenbank::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 ESDatenbank::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;
|
|
|
}
|
|
|
|
|
|
bool ESDatenbank::proveKlient( int num, int sNum )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT * FROM server_client WHERE server_id = " );
|
|
|
- befehl->append( sNum );
|
|
|
- befehl->append( " AND client_id = " );
|
|
|
- befehl->append( num );
|
|
|
- lock();
|
|
|
- datenbank->befehl( befehl->getText() );
|
|
|
- Result res = datenbank->getResult();
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- bool ret = 0;
|
|
|
- if( res.zeilenAnzahl == 1 )
|
|
|
- ret = 1;
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT * FROM server_client WHERE server_id = " );
|
|
|
+ befehl->append( sNum );
|
|
|
+ befehl->append( " AND client_id = " );
|
|
|
+ befehl->append( num );
|
|
|
+ lock();
|
|
|
+ datenbank->befehl( befehl->getText() );
|
|
|
+ Result res = datenbank->getResult();
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ bool ret = 0;
|
|
|
+ if( res.zeilenAnzahl == 1 )
|
|
|
+ ret = 1;
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
Text *ESDatenbank::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;
|
|
|
}
|
|
|
|
|
|
void ESDatenbank::unregisterKlient( int num, int sNum )
|
|
|
{
|
|
|
- Text *befehl = new Text( "DELETE FROM server_client WHERE client_id = " );
|
|
|
- befehl->append( num );
|
|
|
- befehl->append( " AND server_id = " );
|
|
|
- befehl->append( sNum );
|
|
|
- lock();
|
|
|
- datenbank->befehl( befehl->getText() );
|
|
|
- int za = datenbank->getZeilenAnzahl();
|
|
|
- unlock();
|
|
|
- if( za == 1 )
|
|
|
- {
|
|
|
- befehl->setText( "UPDATE server SET tasks = tasks - 1 WHERE id = " );
|
|
|
- befehl->append( sNum );
|
|
|
- lock();
|
|
|
- datenbank->befehl( befehl->getText() );
|
|
|
- unlock();
|
|
|
- }
|
|
|
- befehl->release();
|
|
|
+ Text *befehl = new Text( "DELETE FROM server_client WHERE client_id = " );
|
|
|
+ befehl->append( num );
|
|
|
+ befehl->append( " AND server_id = " );
|
|
|
+ befehl->append( sNum );
|
|
|
+ lock();
|
|
|
+ datenbank->befehl( befehl->getText() );
|
|
|
+ int za = datenbank->getZeilenAnzahl();
|
|
|
+ unlock();
|
|
|
+ if( za == 1 )
|
|
|
+ {
|
|
|
+ befehl->setText( "UPDATE server SET tasks = tasks - 1 WHERE id = " );
|
|
|
+ befehl->append( sNum );
|
|
|
+ lock();
|
|
|
+ datenbank->befehl( befehl->getText() );
|
|
|
+ unlock();
|
|
|
+ }
|
|
|
+ befehl->release();
|
|
|
}
|
|
|
|
|
|
bool ESDatenbank::setServerStatus( int id, int status )
|
|
|
{
|
|
|
- Text *befehl = new Text( "UPDATE server SET server_status_id = " );
|
|
|
- *befehl += status;
|
|
|
- *befehl += "WHERE id = ";
|
|
|
- *befehl += id;
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- bool ret = datenbank->getZeilenAnzahl() != 0;
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "UPDATE server SET server_status_id = " );
|
|
|
+ *befehl += status;
|
|
|
+ *befehl += "WHERE id = ";
|
|
|
+ *befehl += id;
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ bool ret = datenbank->getZeilenAnzahl() != 0;
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
bool ESDatenbank::setMaxClients( int id, int maxC )
|
|
|
{
|
|
|
- Text *befehl = new Text( "UPDATE server SET max_tasks = " );
|
|
|
- befehl->append( maxC );
|
|
|
- befehl->append( " WHERE id = " );
|
|
|
- befehl->append( id );
|
|
|
- lock();
|
|
|
- if( !datenbank->befehl( befehl->getText() ) )
|
|
|
- {
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return 0;
|
|
|
- }
|
|
|
- bool ret = datenbank->getZeilenAnzahl() > 0;
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "UPDATE server SET max_tasks = " );
|
|
|
+ befehl->append( maxC );
|
|
|
+ befehl->append( " WHERE id = " );
|
|
|
+ befehl->append( id );
|
|
|
+ lock();
|
|
|
+ if( !datenbank->befehl( befehl->getText() ) )
|
|
|
+ {
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ bool ret = datenbank->getZeilenAnzahl() > 0;
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
bool ESDatenbank::serverIstNichtPausiert( int id )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT server_status_id FROM server WHERE id = " );
|
|
|
- befehl->append( id );
|
|
|
- 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;
|
|
|
- }
|
|
|
- bool ret = (int)res.values[ 0 ] == 3;
|
|
|
- res.destroy();
|
|
|
- return ret;
|
|
|
+ Text *befehl = new Text( "SELECT server_status_id FROM server WHERE id = " );
|
|
|
+ befehl->append( id );
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ bool ret = (int)res.values[ 0 ] == 3;
|
|
|
+ res.destroy();
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
bool ESDatenbank::getPatchServer( 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.id = b.server_id AND a.server_typ_name = 'patch' 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.id = b.server_id AND a.server_typ_name = 'patch' 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 ESDatenbank::getRegisterServer( 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.id = b.server_id AND a.server_typ_name = 'register' 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.id = b.server_id AND a.server_typ_name = 'register' 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 ESDatenbank::getLoginServer( 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.id = b.server_id AND a.server_typ_name = 'login' 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.id = b.server_id AND a.server_typ_name = 'login' 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 ESDatenbank::getInformationServer( 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.id = b.server_id AND a.server_typ_name = 'information' 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.id = b.server_id AND a.server_typ_name = 'information' 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 ESDatenbank::getChatServer( 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.id = b.server_id AND a.server_typ_name = 'chat' 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.id = b.server_id AND a.server_typ_name = 'chat' 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 ESDatenbank::getAnmeldungServer( 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.id = b.server_id AND a.server_typ_name = 'anmeldung' 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.id = b.server_id AND a.server_typ_name = 'anmeldung' 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 ESDatenbank::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.spiel_server_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 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.spiel_server_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 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 ESDatenbank::getShopServer( 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.id = b.server_id AND a.server_typ_name = 'shop' 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.id = b.server_id AND a.server_typ_name = 'shop' 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 ESDatenbank::getNewsServer( 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.id = b.server_id AND a.server_typ_name = 'news' 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.id = b.server_id AND a.server_typ_name = 'news' 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 ESDatenbank::getHistorieServer( 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.id = b.server_id AND a.server_typ_name = 'historie' 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.id = b.server_id AND a.server_typ_name = 'historie' 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 ESDatenbank::getKartenServer( int client, Text *ip, int *port )
|
|
@@ -584,183 +584,168 @@ bool ESDatenbank::getMinigameServer( int client, Text *ip, int *port )
|
|
|
|
|
|
void ESDatenbank::removeKlient( int klientId )
|
|
|
{
|
|
|
- Text *befehl = new Text( "SELECT unregister_client( " );
|
|
|
- befehl->append( klientId );
|
|
|
- befehl->append( " )" );
|
|
|
- lock();
|
|
|
- datenbank->befehl( befehl->getText() );
|
|
|
- unlock();
|
|
|
- befehl->release();
|
|
|
+ Text *befehl = new Text( "SELECT unregister_client( " );
|
|
|
+ befehl->append( klientId );
|
|
|
+ befehl->append( " )" );
|
|
|
+ lock();
|
|
|
+ datenbank->befehl( befehl->getText() );
|
|
|
+ unlock();
|
|
|
+ befehl->release();
|
|
|
}
|
|
|
|
|
|
int ESDatenbank::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;
|
|
|
}
|
|
|
|
|
|
int ESDatenbank::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;
|
|
|
}
|
|
|
|
|
|
int ESDatenbank::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 ESDatenbank::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;
|
|
|
}
|
|
|
|
|
|
int ESDatenbank::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;
|
|
|
+ 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 ESDatenbank::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;
|
|
|
+ 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 ESDatenbank::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 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;
|
|
|
}
|
|
|
|
|
|
// constant
|
|
|
Text *ESDatenbank::getLetzterFehler() const
|
|
|
{
|
|
|
- return datenbank->getLetzterFehler();
|
|
|
-}
|
|
|
-
|
|
|
-// Reference Counting
|
|
|
-ESDatenbank *ESDatenbank::getThis()
|
|
|
-{
|
|
|
- ref++;
|
|
|
- return this;
|
|
|
-}
|
|
|
-
|
|
|
-ESDatenbank *ESDatenbank::release()
|
|
|
-{
|
|
|
- ref--;
|
|
|
- if( !ref )
|
|
|
- delete this;
|
|
|
- return 0;
|
|
|
+ return datenbank->getLetzterFehler();
|
|
|
}
|