|
@@ -7,21 +7,28 @@
|
|
// Konstruktor
|
|
// Konstruktor
|
|
ISDatenbank::ISDatenbank( InitDatei *zIni )
|
|
ISDatenbank::ISDatenbank( InitDatei *zIni )
|
|
{
|
|
{
|
|
- if( !zIni->wertExistiert( "DBBenutzer" ) )
|
|
|
|
- zIni->addWert( "DBBenutzer", "informationserveru" );
|
|
|
|
- if( !zIni->wertExistiert( "DBPasswort" ) )
|
|
|
|
- zIni->addWert( "DBPasswort", "LTInformationServerPW" );
|
|
|
|
- if( !zIni->wertExistiert( "DBName" ) )
|
|
|
|
- zIni->addWert( "DBName", "lenck_tech_db" );
|
|
|
|
- if( !zIni->wertExistiert( "DBIP" ) )
|
|
|
|
- zIni->addWert( "DBIP", "127.0.0.1" );
|
|
|
|
- if( !zIni->wertExistiert( "DBPort" ) )
|
|
|
|
- zIni->addWert( "DBPort", "5432" );
|
|
|
|
datenbank = new Datenbank( zIni->zWert( "DBBenutzer" )->getText(), zIni->zWert( "DBPasswort" )->getText(),
|
|
datenbank = new Datenbank( zIni->zWert( "DBBenutzer" )->getText(), zIni->zWert( "DBPasswort" )->getText(),
|
|
zIni->zWert( "DBName" )->getText(), zIni->zWert( "DBIP" )->getText(),
|
|
zIni->zWert( "DBName" )->getText(), zIni->zWert( "DBIP" )->getText(),
|
|
(unsigned short)TextZuInt( zIni->zWert( "DBPort" )->getText(), 10 ) );
|
|
(unsigned short)TextZuInt( zIni->zWert( "DBPort" )->getText(), 10 ) );
|
|
|
|
+ if( !datenbank->istOk() )
|
|
|
|
+ {
|
|
|
|
+ std::cout << "IS: Die Verbindung zur Datenbank konnte nicht hergestellt werden.\nDas Programm wird beendet.";
|
|
|
|
+ exit( 1 );
|
|
|
|
+ }
|
|
InitializeCriticalSection( &cs );
|
|
InitializeCriticalSection( &cs );
|
|
ref = 1;
|
|
ref = 1;
|
|
|
|
+ Text befehl = "SELECT port, admin_port FROM server WHERE id = ";
|
|
|
|
+ befehl += zIni->zWert( "ServerId" )->getText();
|
|
|
|
+ lock();
|
|
|
|
+ datenbank->befehl( befehl );
|
|
|
|
+ Result res = datenbank->getResult();
|
|
|
|
+ unlock();
|
|
|
|
+ if( res.zeilenAnzahl == 1 )
|
|
|
|
+ {
|
|
|
|
+ zIni->addWert( "ServerPort", res.values[ 0 ] );
|
|
|
|
+ zIni->addWert( "AdminServerPort", res.values[ 1 ] );
|
|
|
|
+ }
|
|
|
|
+ res.destroy();
|
|
}
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
// Destruktor
|
|
@@ -46,9 +53,9 @@ int ISDatenbank::istAdministrator( const char *name, const char *passwort )
|
|
{
|
|
{
|
|
Text *befehl = new Text( "SELECT id FROM benutzer WHERE name = '" );
|
|
Text *befehl = new Text( "SELECT id FROM benutzer WHERE name = '" );
|
|
befehl->append( name );
|
|
befehl->append( name );
|
|
- befehl->append( "' AND passwort = '" );
|
|
|
|
|
|
+ befehl->append( "' AND passwort = md5('" );
|
|
befehl->append( passwort );
|
|
befehl->append( passwort );
|
|
- befehl->append( "'" );
|
|
|
|
|
|
+ befehl->append( "')" );
|
|
lock();
|
|
lock();
|
|
datenbank->befehl( befehl->getText() );
|
|
datenbank->befehl( befehl->getText() );
|
|
Result res = datenbank->getResult();
|
|
Result res = datenbank->getResult();
|
|
@@ -77,7 +84,7 @@ bool ISDatenbank::adminHatRecht( int id, int recht )
|
|
|
|
|
|
bool ISDatenbank::proveKlient( int num, int sNum )
|
|
bool ISDatenbank::proveKlient( int num, int sNum )
|
|
{
|
|
{
|
|
- Text *befehl = new Text( "SELECT * FROM server_information_clients WHERE server_information_id = " );
|
|
|
|
|
|
+ Text *befehl = new Text( "SELECT * FROM server_client WHERE server_id = " );
|
|
befehl->append( sNum );
|
|
befehl->append( sNum );
|
|
befehl->append( " AND client_id = " );
|
|
befehl->append( " AND client_id = " );
|
|
befehl->append( num );
|
|
befehl->append( num );
|
|
@@ -96,7 +103,7 @@ bool ISDatenbank::proveKlient( int num, int sNum )
|
|
Text *ISDatenbank::getKlientKey( int cId )
|
|
Text *ISDatenbank::getKlientKey( int cId )
|
|
{
|
|
{
|
|
lock();
|
|
lock();
|
|
- if( !datenbank->befehl( Text( "SELECT schluessel FROM clients WHERE id = " ) += cId ) )
|
|
|
|
|
|
+ if( !datenbank->befehl( Text( "SELECT schluessel FROM client WHERE id = " ) += cId ) )
|
|
{
|
|
{
|
|
unlock();
|
|
unlock();
|
|
return 0;
|
|
return 0;
|
|
@@ -115,9 +122,9 @@ Text *ISDatenbank::getKlientKey( int cId )
|
|
|
|
|
|
void ISDatenbank::unregisterKlient( int num, int sNum )
|
|
void ISDatenbank::unregisterKlient( int num, int sNum )
|
|
{
|
|
{
|
|
- Text *befehl = new Text( "DELETE FROM server_information_clients WHERE client_id = " );
|
|
|
|
|
|
+ Text *befehl = new Text( "DELETE FROM server_client WHERE client_id = " );
|
|
befehl->append( num );
|
|
befehl->append( num );
|
|
- befehl->append( " AND server_information_id = " );
|
|
|
|
|
|
+ befehl->append( " AND server_id = " );
|
|
befehl->append( sNum );
|
|
befehl->append( sNum );
|
|
lock();
|
|
lock();
|
|
datenbank->befehl( befehl->getText() );
|
|
datenbank->befehl( befehl->getText() );
|
|
@@ -125,7 +132,7 @@ void ISDatenbank::unregisterKlient( int num, int sNum )
|
|
unlock();
|
|
unlock();
|
|
if( za == 1 )
|
|
if( za == 1 )
|
|
{
|
|
{
|
|
- befehl->setText( "UPDATE server_information SET clients = clients - 1 WHERE id = " );
|
|
|
|
|
|
+ befehl->setText( "UPDATE server SET tasks = tasks - 1 WHERE id = " );
|
|
befehl->append( sNum );
|
|
befehl->append( sNum );
|
|
lock();
|
|
lock();
|
|
datenbank->befehl( befehl->getText() );
|
|
datenbank->befehl( befehl->getText() );
|
|
@@ -134,114 +141,9 @@ void ISDatenbank::unregisterKlient( int num, int sNum )
|
|
befehl->release();
|
|
befehl->release();
|
|
}
|
|
}
|
|
|
|
|
|
-bool ISDatenbank::serverAnmelden( InitDatei *zIni )
|
|
|
|
-{
|
|
|
|
- if( !zIni->wertExistiert( "ServerId" ) )
|
|
|
|
- zIni->addWert( "ServerId", "0" );
|
|
|
|
- if( !zIni->wertExistiert( "ServerName" ) )
|
|
|
|
- zIni->addWert( "ServerName", "Name" );
|
|
|
|
- if( !zIni->wertExistiert( "ServerPort" ) )
|
|
|
|
- zIni->addWert( "ServerPort", "49144" );
|
|
|
|
- if( !zIni->wertExistiert( "ServerIP" ) )
|
|
|
|
- zIni->addWert( "ServerIP", "127.0.0.1" );
|
|
|
|
- if( !zIni->wertExistiert( "AdminServerPort" ) )
|
|
|
|
- zIni->addWert( "AdminServerPort", "49143" );
|
|
|
|
- if( !zIni->wertExistiert( "Aktiv" ) )
|
|
|
|
- zIni->addWert( "Aktiv", "FALSE" );
|
|
|
|
- if( !zIni->wertExistiert( "MaxClients" ) )
|
|
|
|
- zIni->addWert( "MaxClients", "50" );
|
|
|
|
- bool insert = 0;
|
|
|
|
- int id = *zIni->zWert( "ServerId" );
|
|
|
|
- if( id )
|
|
|
|
- {
|
|
|
|
- lock();
|
|
|
|
- if( !datenbank->befehl( Text( "SELECT id FROM server_information WHERE id = " ) += id ) )
|
|
|
|
- {
|
|
|
|
- unlock();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- int anz = datenbank->getZeilenAnzahl();
|
|
|
|
- unlock();
|
|
|
|
- insert = anz == 0;
|
|
|
|
- if( !insert )
|
|
|
|
- {
|
|
|
|
- lock();
|
|
|
|
- if( !datenbank->befehl( Text( "SELECT id FROM server_information WHERE server_status_id = 1 AND id = " ) += id ) )
|
|
|
|
- {
|
|
|
|
- unlock();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- int anz = datenbank->getZeilenAnzahl();
|
|
|
|
- unlock();
|
|
|
|
- if( !anz ) // Server läuft bereits
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if( insert || !id )
|
|
|
|
- { // Neuer Eintrag in Tabelle server_information
|
|
|
|
- Text *befehl = new Text( "INSERT INTO server_information( " );
|
|
|
|
- if( id )
|
|
|
|
- *befehl += "id, ";
|
|
|
|
- *befehl += "name, ip, port, admin_port, server_status_id, max_clients ) VALUES( ";
|
|
|
|
- if( id )
|
|
|
|
- {
|
|
|
|
- *befehl += id;
|
|
|
|
- *befehl += ", ";
|
|
|
|
- }
|
|
|
|
- *befehl += "'";
|
|
|
|
- *befehl += zIni->zWert( "ServerName" )->getText();
|
|
|
|
- *befehl += "', '";
|
|
|
|
- *befehl += zIni->zWert( "ServerIP" )->getText();
|
|
|
|
- *befehl += "', ";
|
|
|
|
- *befehl += zIni->zWert( "ServerPort" )->getText();
|
|
|
|
- *befehl += ", ";
|
|
|
|
- *befehl += zIni->zWert( "AdminServerPort" )->getText();
|
|
|
|
- *befehl += ", 1, ";
|
|
|
|
- *befehl += zIni->zWert( "MaxClients" )->getText();
|
|
|
|
- *befehl += " ) RETURNING id";
|
|
|
|
- lock();
|
|
|
|
- if( !datenbank->befehl( *befehl ) )
|
|
|
|
- {
|
|
|
|
- unlock();
|
|
|
|
- befehl->release();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- Result res = datenbank->getResult();
|
|
|
|
- unlock();
|
|
|
|
- befehl->release();
|
|
|
|
- if( !res.zeilenAnzahl )
|
|
|
|
- {
|
|
|
|
- res.destroy();
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- zIni->setWert( "ServerId", res.values[ 0 ] );
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- { // Alten Eintrag aus Tabelle server_information ändern
|
|
|
|
- Text *befehl = new Text( "UPDATE server_information SET name = '" );
|
|
|
|
- *befehl += zIni->zWert( "ServerName" )->getText();
|
|
|
|
- *befehl += "', port = ";
|
|
|
|
- *befehl += zIni->zWert( "ServerPort" )->getText();
|
|
|
|
- *befehl += ", ip = '";
|
|
|
|
- *befehl += zIni->zWert( "ServerIP" )->getText();
|
|
|
|
- *befehl += "', max_clients = ";
|
|
|
|
- *befehl += zIni->zWert( "MaxClients" )->getText();
|
|
|
|
- *befehl += ", admin_port = ";
|
|
|
|
- *befehl += zIni->zWert( "AdminServerPort" )->getText();
|
|
|
|
- *befehl += " WHERE id = ";
|
|
|
|
- *befehl += id;
|
|
|
|
- lock();
|
|
|
|
- bool ret = datenbank->befehl( *befehl );
|
|
|
|
- unlock();
|
|
|
|
- befehl->release();
|
|
|
|
- return ret;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
bool ISDatenbank::setServerStatus( int id, int status )
|
|
bool ISDatenbank::setServerStatus( int id, int status )
|
|
{
|
|
{
|
|
- Text *befehl = new Text( "UPDATE server_information SET server_status_id = " );
|
|
|
|
|
|
+ Text *befehl = new Text( "UPDATE server SET server_status_id = " );
|
|
*befehl += status;
|
|
*befehl += status;
|
|
*befehl += "WHERE id = ";
|
|
*befehl += "WHERE id = ";
|
|
*befehl += id;
|
|
*befehl += id;
|
|
@@ -260,7 +162,7 @@ bool ISDatenbank::setServerStatus( int id, int status )
|
|
|
|
|
|
bool ISDatenbank::setMaxClients( int id, int maxC )
|
|
bool ISDatenbank::setMaxClients( int id, int maxC )
|
|
{
|
|
{
|
|
- Text *befehl = new Text( "UPDATE server_information SET max_clients = " );
|
|
|
|
|
|
+ Text *befehl = new Text( "UPDATE server SET max_tasks = " );
|
|
befehl->append( maxC );
|
|
befehl->append( maxC );
|
|
befehl->append( " WHERE id = " );
|
|
befehl->append( " WHERE id = " );
|
|
befehl->append( id );
|
|
befehl->append( id );
|
|
@@ -277,33 +179,9 @@ bool ISDatenbank::setMaxClients( int id, int maxC )
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
-int ISDatenbank::getAdminPort( int id )
|
|
|
|
-{
|
|
|
|
- Text *befehl = new Text( "SELECT admin_port FROM server_information 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;
|
|
|
|
- }
|
|
|
|
- int ret = TextZuInt( res.values[ 0 ].getText(), 10 );
|
|
|
|
- res.destroy();
|
|
|
|
- return ret;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
bool ISDatenbank::serverIstNichtPausiert( int id )
|
|
bool ISDatenbank::serverIstNichtPausiert( int id )
|
|
{
|
|
{
|
|
- Text *befehl = new Text( "SELECT server_status_id FROM server_information WHERE id = " );
|
|
|
|
|
|
+ Text *befehl = new Text( "SELECT server_status_id FROM server WHERE id = " );
|
|
befehl->append( id );
|
|
befehl->append( id );
|
|
lock();
|
|
lock();
|
|
if( !datenbank->befehl( befehl->getText() ) )
|
|
if( !datenbank->befehl( befehl->getText() ) )
|
|
@@ -769,7 +647,7 @@ int ISDatenbank::getSpielerPunkte( int spielId, int accountId )
|
|
|
|
|
|
Array< int > *ISDatenbank::getAccountSpielArtListe( int cId )
|
|
Array< int > *ISDatenbank::getAccountSpielArtListe( int cId )
|
|
{
|
|
{
|
|
- Text *befehl = new Text( "SELECT a.spiel_art_id FROM spiel_art_account a, account_clients b "
|
|
|
|
|
|
+ Text *befehl = new Text( "SELECT a.spiel_art_id FROM spiel_art_account a, account_client b "
|
|
"WHERE a.account_id = b.account_id AND a.end_dat IS NULL AND b.client_id = " );
|
|
"WHERE a.account_id = b.account_id AND a.end_dat IS NULL AND b.client_id = " );
|
|
befehl->append( cId );
|
|
befehl->append( cId );
|
|
lock();
|
|
lock();
|
|
@@ -815,7 +693,7 @@ int ISDatenbank::getNeusteSpielVersion( int sId )
|
|
|
|
|
|
int ISDatenbank::getKupfer( int cId )
|
|
int ISDatenbank::getKupfer( int cId )
|
|
{
|
|
{
|
|
- Text *befehl = new Text( "SELECT a.kupfer FROM account a, account_clients b WHERE a.id = b.account_id AND b.client_id = " );
|
|
|
|
|
|
+ Text *befehl = new Text( "SELECT a.kupfer FROM account a, account_client b WHERE a.id = b.account_id AND b.client_id = " );
|
|
befehl->append( cId );
|
|
befehl->append( cId );
|
|
lock();
|
|
lock();
|
|
if( !datenbank->befehl( befehl->getText() ) )
|
|
if( !datenbank->befehl( befehl->getText() ) )
|
|
@@ -887,7 +765,7 @@ Text *ISDatenbank::getDateiGruppePfad( int dgId )
|
|
|
|
|
|
Array< int > *ISDatenbank::getAccountKarteListe( int cId, int sId )
|
|
Array< int > *ISDatenbank::getAccountKarteListe( int cId, int sId )
|
|
{
|
|
{
|
|
- Text *befehl = new Text( "SELECT a.karte_id FROM karte_account a, account_clients b, karte c "
|
|
|
|
|
|
+ Text *befehl = new Text( "SELECT a.karte_id FROM karte_account a, account_client b, karte c "
|
|
"WHERE c.id = a.karte_id AND a.account_id = b.account_id AND a.end_dat IS NULL AND b.client_id = " );
|
|
"WHERE c.id = a.karte_id AND a.account_id = b.account_id AND a.end_dat IS NULL AND b.client_id = " );
|
|
befehl->append( cId );
|
|
befehl->append( cId );
|
|
befehl->append( " AND c.spiel_art_id = " );
|
|
befehl->append( " AND c.spiel_art_id = " );
|
|
@@ -1891,7 +1769,7 @@ AHDaten *ISDatenbank::getSpielHistorie( int accountId, InformationServer *is )
|
|
bool ISDatenbank::getHistorieServerPortIp( int clientId, int spielId, int *port, Text *ip )
|
|
bool ISDatenbank::getHistorieServerPortIp( int clientId, int spielId, int *port, Text *ip )
|
|
{
|
|
{
|
|
lock();
|
|
lock();
|
|
- if( !datenbank->befehl( Text( "SELECT a.id, a.port, a.ip FROM server_historie a, server_historie_spiel b "
|
|
|
|
|
|
+ if( !datenbank->befehl( Text( "SELECT a.id, a.port, a.ip FROM server a, server_historie_spiel b "
|
|
"WHERE a.id = b.server_historie_id AND a.clients < a.max_clients - 1 AND "
|
|
"WHERE a.id = b.server_historie_id AND a.clients < a.max_clients - 1 AND "
|
|
"a.server_status_id = 3 AND b.spiel_id = " ) += spielId ) )
|
|
"a.server_status_id = 3 AND b.spiel_id = " ) += spielId ) )
|
|
{
|
|
{
|
|
@@ -1909,21 +1787,15 @@ bool ISDatenbank::getHistorieServerPortIp( int clientId, int spielId, int *port,
|
|
*port = res.values[ 1 ];
|
|
*port = res.values[ 1 ];
|
|
*ip = res.values[ 2 ].getText();
|
|
*ip = res.values[ 2 ].getText();
|
|
res.destroy();
|
|
res.destroy();
|
|
- Text *befehl = new Text( "INSERT INTO server_historie_clients( client_id, server_historie_id ) VALUES ( " );
|
|
|
|
|
|
+ Text *befehl = new Text( "INSERT INTO server_client( client_id, server_id ) VALUES ( " );
|
|
befehl->append( clientId );
|
|
befehl->append( clientId );
|
|
befehl->append( ", " );
|
|
befehl->append( ", " );
|
|
befehl->append( id );
|
|
befehl->append( id );
|
|
befehl->append( " )" );
|
|
befehl->append( " )" );
|
|
bool ret = 1;
|
|
bool ret = 1;
|
|
lock();
|
|
lock();
|
|
- ret &= datenbank->befehl( Text( "SELECT server_historie_id FROM server_historie_clients WHERE client_id = " ) += clientId );
|
|
|
|
- res = datenbank->getResult();
|
|
|
|
- if( res.zeilenAnzahl )
|
|
|
|
- ret &= datenbank->befehl( Text( "UPDATE server_historie SET clients = clients - 1 WHERE id = " ) += res.values[ 0 ] );
|
|
|
|
- res.destroy();
|
|
|
|
- ret &= datenbank->befehl( Text( "DELETE FROM server_historie_clients WHERE client_id = " ) += clientId );
|
|
|
|
|
|
+ ret &= datenbank->befehl( Text( "DELETE FROM server_client a USING server b WHERE b.server_typ_name = 'historie' AND b.id = a.server_id AND a.client_id = " ) += clientId );
|
|
ret &= datenbank->befehl( *befehl );
|
|
ret &= datenbank->befehl( *befehl );
|
|
- ret &= datenbank->befehl( Text( "UPDATE server_historie SET clients = clients + 1 WHERE id = " ) += id );
|
|
|
|
unlock();
|
|
unlock();
|
|
befehl->release();
|
|
befehl->release();
|
|
return ret;
|
|
return ret;
|
|
@@ -1931,7 +1803,7 @@ bool ISDatenbank::getHistorieServerPortIp( int clientId, int spielId, int *port,
|
|
|
|
|
|
bool ISDatenbank::hatKlientRecht( int kId, int recht )
|
|
bool ISDatenbank::hatKlientRecht( int kId, int recht )
|
|
{
|
|
{
|
|
- Text befehl = "SELECT a.* FROM account_user_rechte a, account_clients b WHERE a.account_id = b.account_id AND b.client_id = ";
|
|
|
|
|
|
+ Text befehl = "SELECT a.* FROM account_user_rechte a, account_client b WHERE a.account_id = b.account_id AND b.client_id = ";
|
|
befehl += kId;
|
|
befehl += kId;
|
|
befehl += " AND a.user_rechte_id = ";
|
|
befehl += " AND a.user_rechte_id = ";
|
|
befehl += recht;
|
|
befehl += recht;
|
|
@@ -1947,7 +1819,7 @@ Result ISDatenbank::getKartenListe( int kId, char *suchFilter, char sortSpalte,
|
|
Text befehl = "SELECT a.id, a.name, b.name, c.kupfer, a.verkauft, a.max_spieler FROM karte a ";
|
|
Text befehl = "SELECT a.id, a.name, b.name, c.kupfer, a.verkauft, a.max_spieler FROM karte a ";
|
|
befehl += "INNER JOIN spiel_art b ON a.spiel_art_id = b.id ";
|
|
befehl += "INNER JOIN spiel_art b ON a.spiel_art_id = b.id ";
|
|
befehl += "LEFT JOIN karte_kauf_erlaubt c ON a.id = c.karte_id ";
|
|
befehl += "LEFT JOIN karte_kauf_erlaubt c ON a.id = c.karte_id ";
|
|
- befehl += "INNER JOIN account_clients d ON d.account_id = a.account_id ";
|
|
|
|
|
|
+ befehl += "INNER JOIN account_client d ON d.account_id = a.account_id ";
|
|
befehl += "WHERE d.client_id = ";
|
|
befehl += "WHERE d.client_id = ";
|
|
befehl += kId;
|
|
befehl += kId;
|
|
befehl += " AND a.name LIKE'%";
|
|
befehl += " AND a.name LIKE'%";
|
|
@@ -1970,7 +1842,7 @@ Result ISDatenbank::getKartenListe( int kId, char *suchFilter, char sortSpalte,
|
|
|
|
|
|
bool ISDatenbank::getEditorServerPortIp( int clientId, int karteId, int *port, Text *ip )
|
|
bool ISDatenbank::getEditorServerPortIp( int clientId, int karteId, int *port, Text *ip )
|
|
{
|
|
{
|
|
- Text befehl = "SELECT a.port, a.ip, a.id FROM server_editor a, karte b, account_clients c ";
|
|
|
|
|
|
+ Text befehl = "SELECT a.port, a.ip, a.id FROM server a, karte b, account_client c ";
|
|
befehl += "WHERE a.id = b.server_editor_id AND b.account_id = c.account_id AND a.server_status_id = 3 AND c.client_id = ";
|
|
befehl += "WHERE a.id = b.server_editor_id AND b.account_id = c.account_id AND a.server_status_id = 3 AND c.client_id = ";
|
|
befehl += clientId;
|
|
befehl += clientId;
|
|
befehl += " AND b.id = ";
|
|
befehl += " AND b.id = ";
|
|
@@ -1987,15 +1859,15 @@ bool ISDatenbank::getEditorServerPortIp( int clientId, int karteId, int *port, T
|
|
ip->setText( res.values[ 1 ] );
|
|
ip->setText( res.values[ 1 ] );
|
|
int id = res.values[ 2 ];
|
|
int id = res.values[ 2 ];
|
|
res.destroy();
|
|
res.destroy();
|
|
- befehl = "INSERT INTO server_editor_clients( client_id, server_editor_id ) VALUES ( ";
|
|
|
|
|
|
+ befehl = "INSERT INTO server_client( client_id, server_id ) VALUES ( ";
|
|
befehl += clientId;
|
|
befehl += clientId;
|
|
befehl += ", ";
|
|
befehl += ", ";
|
|
befehl += id;
|
|
befehl += id;
|
|
befehl += " )";
|
|
befehl += " )";
|
|
bool ret = 1;
|
|
bool ret = 1;
|
|
lock();
|
|
lock();
|
|
- ret &= datenbank->befehl( Text( "SELECT server_editor_id FROM server_editor_clients WHERE client_id = " ) += clientId );
|
|
|
|
- ret &= datenbank->befehl( Text( "DELETE FROM server_editor_clients WHERE client_id = " ) += clientId );
|
|
|
|
|
|
+ ret &= datenbank->befehl( Text( "SELECT a.server_id FROM server_client a, server b WHERE a.server_id = b.id AND b.server_typ_name = 'editor' AND a.client_id = " ) += clientId );
|
|
|
|
+ ret &= datenbank->befehl( Text( "DELETE FROM server_client a USING server b WHERE b.id = a.server_id AND b.server_typ_name = 'editor' AND a.client_id = " ) += clientId );
|
|
ret &= datenbank->befehl( befehl );
|
|
ret &= datenbank->befehl( befehl );
|
|
unlock();
|
|
unlock();
|
|
return 1;
|
|
return 1;
|
|
@@ -2003,11 +1875,11 @@ bool ISDatenbank::getEditorServerPortIp( int clientId, int karteId, int *port, T
|
|
|
|
|
|
bool ISDatenbank::getKartenServerPortIp( int clientId, int karteId, int *port, Text *ip )
|
|
bool ISDatenbank::getKartenServerPortIp( int clientId, int karteId, int *port, Text *ip )
|
|
{
|
|
{
|
|
- Text befehl = "SELECT a.port, a.ip, a.id FROM server_karten a, karte b ";
|
|
|
|
|
|
+ Text befehl = "SELECT a.port, a.ip, a.id FROM server a, karte b ";
|
|
befehl += "WHERE a.id = b.server_karten_id AND a.server_status_id = 3 AND b.id = ";
|
|
befehl += "WHERE a.id = b.server_karten_id AND a.server_status_id = 3 AND b.id = ";
|
|
befehl += karteId;
|
|
befehl += karteId;
|
|
if( !karteId )
|
|
if( !karteId )
|
|
- befehl = "SELECT port, ip, a.id FROM server_karten WHERE server_status_id = 3 LIMIT 1";
|
|
|
|
|
|
+ befehl = "SELECT port, ip, id FROM server WHERE server_typ_name = 'karten' AND server_status_id = 3 LIMIT 1";
|
|
lock();
|
|
lock();
|
|
if( !datenbank->befehl( befehl ) )
|
|
if( !datenbank->befehl( befehl ) )
|
|
{
|
|
{
|
|
@@ -2024,15 +1896,15 @@ bool ISDatenbank::getKartenServerPortIp( int clientId, int karteId, int *port, T
|
|
res.destroy();
|
|
res.destroy();
|
|
if( clientId )
|
|
if( clientId )
|
|
{
|
|
{
|
|
- befehl = "INSERT INTO server_karten_clients( client_id, server_karten_id ) VALUES ( ";
|
|
|
|
|
|
+ befehl = "INSERT INTO server_client( client_id, server_id ) VALUES ( ";
|
|
befehl += clientId;
|
|
befehl += clientId;
|
|
befehl += ", ";
|
|
befehl += ", ";
|
|
befehl += id;
|
|
befehl += id;
|
|
befehl += " )";
|
|
befehl += " )";
|
|
bool ret = 1;
|
|
bool ret = 1;
|
|
lock();
|
|
lock();
|
|
- ret &= datenbank->befehl( Text( "SELECT server_karten_id FROM server_karten_clients WHERE client_id = " ) += clientId );
|
|
|
|
- ret &= datenbank->befehl( Text( "DELETE FROM server_karten_clients WHERE client_id = " ) += clientId );
|
|
|
|
|
|
+ ret &= datenbank->befehl( Text( "SELECT a.server_id FROM server_client a, server b WHERE b.id = a.server_id AND b.server_typ_name = 'karten' AND a.client_id = " ) += clientId );
|
|
|
|
+ ret &= datenbank->befehl( Text( "DELETE FROM server_client a USING server b WHERE b.id = a.server_id AND b.server_typ_name = 'karten' AND a.client_id = " ) += clientId );
|
|
ret &= datenbank->befehl( befehl );
|
|
ret &= datenbank->befehl( befehl );
|
|
unlock();
|
|
unlock();
|
|
}
|
|
}
|