Kolja Strohm 3 жил өмнө
parent
commit
ac4921140b

+ 14 - 29
ShopServer/Datenbank.cpp

@@ -4,17 +4,17 @@
 // Inhalt der LSDatenbank Klasse aus Datenbank.h
 // Konstruktor
 ShSDatenbank::ShSDatenbank( 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 ) );
+                               zIni->zWert( "DBName" )->getText(), zIni->zWert( "DBIP" )->getText(),
+                               (unsigned short)TextZuInt( zIni->zWert( "DBPort" )->getText(), 10 ) );
     if( !datenbank->istOk() )
     {
         std::cout << "ShS: Die Verbindung zur Datenbank konnte nicht hergestellt werden.\nDas Programm wird beendet.";
         exit( 1 );
     }
     InitializeCriticalSection( &cs );
-    ref = 1;
     Text befehl = "SELECT port, admin_port  FROM server WHERE id = ";
     befehl += zIni->zWert( "ServerId" )->getText();
     sid = (int)*zIni->zWert( "ServerId" );
@@ -53,11 +53,11 @@ int ShSDatenbank::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( (char *)n );
     befehl->append( "' AND passwort = md5( '" );
     Text p( passwort );
     p.ersetzen( "'", "''" );
-    befehl->append( (char*)p );
+    befehl->append( (char *)p );
     befehl->append( "' )" );
     lock();
     datenbank->befehl( befehl->getText() );
@@ -202,7 +202,7 @@ bool ShSDatenbank::getSpielArtListe( int cId, char *suche, Array< int > *ret )
     Text *befehl = new Text( "SELECT distinct( a.id ) FROM spiel_art a LEFT JOIN account_client b ON b.client_id = " );
     befehl->append( cId );
     befehl->append( " LEFT JOIN spiel_art_account c ON a.id = c.spiel_art_id AND b.account_id = c.account_id AND "
-        "c.status_id = 2 AND c.end_dat IS NULL INNER JOIN spiel_art_kauf_erlaubt d ON d.spiel_art_id = a.id WHERE a.name LIKE '%" );
+                    "c.status_id = 2 AND c.end_dat IS NULL INNER JOIN spiel_art_kauf_erlaubt d ON d.spiel_art_id = a.id WHERE a.name LIKE '%" );
     befehl->append( suche );
     befehl->append( "%' AND c.spiel_art_id IS NULL" );
     lock();
@@ -225,7 +225,7 @@ bool ShSDatenbank::getSpielArtListe( int cId, char *suche, Array< int > *ret )
 int ShSDatenbank::getSpielBesitzStatus( int cId, int sId )
 {
     Text *befehl = new Text( "SELECT b.status_id FROM account_client a, spiel_art_account b "
-        "WHERE a.account_id = b.account_id AND b.end_dat IS NULL AND a.client_id = " );
+                             "WHERE a.account_id = b.account_id AND b.end_dat IS NULL AND a.client_id = " );
     befehl->append( cId );
     befehl->append( " AND b.spiel_art_id = " );
     befehl->append( sId );
@@ -252,7 +252,7 @@ int ShSDatenbank::getSpielBesitzStatus( int cId, int sId )
 int ShSDatenbank::getSpielTestversionStatus( int cId, int sId )
 {
     Text *befehl = new Text( "SELECT b.verbleibend FROM account_client a, spiel_art_account b "
-        "WHERE a.account_id = b.account_id AND b.end_dat IS NULL AND b.status_id = 1 AND a.client_id = " );
+                             "WHERE a.account_id = b.account_id AND b.end_dat IS NULL AND b.status_id = 1 AND a.client_id = " );
     befehl->append( cId );
     befehl->append( " AND b.spiel_art_id = " );
     befehl->append( sId );
@@ -281,7 +281,7 @@ int ShSDatenbank::getSpielErwerbbarStatus( int cId, int sId )
     Text *befehl = new Text( "SELECT a.spiel_art_account_status_id FROM spiel_art_kauf_erlaubt a LEFT JOIN account_client b ON b.client_id = " );
     befehl->append( cId );
     befehl->append( " LEFT JOIN spiel_art_account c ON a.spiel_art_id = c.spiel_art_id AND b.account_id = c.account_id AND c.end_dat IS NULL "
-        "AND a.spiel_art_account_status_id = c.status_id WHERE c.spiel_art_id IS NULL AND a.spiel_art_id = " );
+                    "AND a.spiel_art_account_status_id = c.status_id WHERE c.spiel_art_id IS NULL AND a.spiel_art_id = " );
     befehl->append( sId );
     lock();
     if( !datenbank->befehl( befehl->getText() ) )
@@ -367,10 +367,10 @@ bool ShSDatenbank::getKarteListe( int cId, int sId, char *suche, Array< int > *r
     Text *befehl = new Text( "SELECT distinct( a.id ) FROM karte a LEFT JOIN account_client b ON b.client_id = " );
     befehl->append( cId );
     befehl->append( " LEFT JOIN karte_account c ON a.id = c.karte_id AND b.account_id = c.account_id AND "
-        "c.status_id = 2 AND c.end_dat IS NULL INNER JOIN karte_kauf_erlaubt d ON d.karte_id = a.id WHERE a.name LIKE '%" );
+                    "c.status_id = 2 AND c.end_dat IS NULL INNER JOIN karte_kauf_erlaubt d ON d.karte_id = a.id WHERE a.name LIKE '%" );
     Text s( suche );
     s.ersetzen( "'", "''" );
-    befehl->append( (char*)s );
+    befehl->append( (char *)s );
     befehl->append( "%' AND c.karte_id IS NULL" );
     if( sId )
     {
@@ -397,7 +397,7 @@ bool ShSDatenbank::getKarteListe( int cId, int sId, char *suche, Array< int > *r
 int ShSDatenbank::getKarteBesitzStatus( int cId, int kId )
 {
     Text *befehl = new Text( "SELECT b.status_id FROM account_client a, karte_account b "
-        "WHERE a.account_id = b.account_id AND b.end_dat IS NULL AND a.client_id = " );
+                             "WHERE a.account_id = b.account_id AND b.end_dat IS NULL AND a.client_id = " );
     befehl->append( cId );
     befehl->append( " AND b.karte_id = " );
     befehl->append( kId );
@@ -424,7 +424,7 @@ int ShSDatenbank::getKarteBesitzStatus( int cId, int kId )
 int ShSDatenbank::getKarteTestversionStatus( int cId, int kId )
 {
     Text *befehl = new Text( "SELECT b.verbleibend FROM account_client a, karte_account b "
-        "WHERE a.account_id = b.account_id AND b.end_dat IS NULL AND b.status_id = 1 AND a.client_id = " );
+                             "WHERE a.account_id = b.account_id AND b.end_dat IS NULL AND b.status_id = 1 AND a.client_id = " );
     befehl->append( cId );
     befehl->append( " AND b.karte_id = " );
     befehl->append( kId );
@@ -453,7 +453,7 @@ int ShSDatenbank::getKarteErwerbbarStatus( int cId, int kId )
     Text *befehl = new Text( "SELECT a.karte_account_status_id FROM karte_kauf_erlaubt a LEFT JOIN account_client b ON b.client_id = " );
     befehl->append( cId );
     befehl->append( " LEFT JOIN karte_account c ON a.karte_id = c.karte_id AND b.account_id = c.account_id AND c.end_dat IS NULL "
-        "AND a.karte_account_status_id = c.status_id WHERE c.karte_id IS NULL AND a.karte_id = " );
+                    "AND a.karte_account_status_id = c.status_id WHERE c.karte_id IS NULL AND a.karte_id = " );
     befehl->append( kId );
     lock();
     if( !datenbank->befehl( befehl->getText() ) )
@@ -712,19 +712,4 @@ bool ShSDatenbank::getSpielShopServerPortIp( int spielId, int clientId, int *por
 Text *ShSDatenbank::getLetzterFehler() const
 {
     return datenbank->getLetzterFehler();
-}
-
-// Reference Counting
-ShSDatenbank *ShSDatenbank::getThis()
-{
-    ref++;
-    return this;
-}
-
-ShSDatenbank *ShSDatenbank::release()
-{
-    ref--;
-    if( !ref )
-        delete this;
-    return 0;
 }

+ 1 - 5
ShopServer/Datenbank.h

@@ -17,13 +17,12 @@ namespace Admin_Recht
     const int ShSMKChange = 40;
 }
 
-class ShSDatenbank
+class ShSDatenbank : public virtual ReferenceCounter
 {
 private:
 	Datenbank *datenbank;
 	CRITICAL_SECTION cs;
     int sid;
-	int ref;
 
 public:
 	// Konstruktor
@@ -62,9 +61,6 @@ public:
     bool getSpielShopServerPortIp( int spielId, int clientId, int *port, Text *ip );
 	// constant
 	Text *getLetzterFehler() const;
-	// Reference Counting
-	ShSDatenbank *getThis();
-	ShSDatenbank *release();
 };
 
 #endif

BIN
ShopServer/ShopServer


+ 60 - 61
ShopServer/ShopServer.cpp

@@ -16,7 +16,7 @@ ShopServer::ShopServer( InitDatei *zIni )
     empfangen = 0;
     gesendet = 0;
     fehler = new Text();
-    ini = zIni->getThis();
+    ini = dynamic_cast<InitDatei *>( zIni->getThis() );
     id = *zIni->zWert( "ServerId" );
     server = new Server();
     aServer = new SSLServer();
@@ -33,13 +33,12 @@ ShopServer::ShopServer( InitDatei *zIni )
     end = 0;
     nichtPausiert = 0;
     InitializeCriticalSection( &cs );
-    ref = 1;
     if( zIni->zWert( "Aktiv" )->istGleich( "TRUE" ) )
     {
         serverStarten();
         serverFortsetzen();
     }
-    updater = new Updater( (ShopServer *)getThis() );
+    updater = new Updater( dynamic_cast<ShopServer *>( getThis() ) );
 }
 
 // Destruktor 
@@ -68,13 +67,13 @@ void ShopServer::runn()
         if( end && klient )
         {
             klient->trenne();
-            klient = klient->release();
+            klient = (SSLSKlient *)klient->release();
             Sleep( 1000 );
             return;
         }
         if( !klient )
             continue;
-        ShSAKlient * clHandle = new ShSAKlient( klient, (ShopServer *)getThis() );
+        ShSAKlient *clHandle = new ShSAKlient( klient, dynamic_cast<ShopServer *>( getThis() ) );
         clHandle->start();
     }
 }
@@ -88,7 +87,7 @@ void ShopServer::thread()
         if( !klient )
             continue;
         Framework::getThreadRegister()->cleanUpClosedThreads();
-        ShSKlient * clHandle = new ShSKlient( klient, (ShopServer *)getThis() );
+        ShSKlient *clHandle = new ShSKlient( klient, dynamic_cast<ShopServer *>( getThis() ) );
         EnterCriticalSection( &cs );
         klients->set( clHandle, klientAnzahl );
         klientAnzahl++;
@@ -107,13 +106,13 @@ void ShopServer::close()
     EnterCriticalSection( &cs );
     for( int i = 0; i < klientAnzahl; i++ )
         klients->z( i )->absturz();
-    klients = klients->release();
+    klients = ( RCArray<ShSKlient>* ) klients->release();
     klientAnzahl = 0;
     LeaveCriticalSection( &cs );
     ende();
     run = 0;
     end = 1;
-    Klient * klient = new Klient();
+    Klient *klient = new Klient();
     klient->verbinde( aServer->getPort(), "127.0.0.1" );
     Sleep( 500 );
     aServer->trenne();
@@ -226,7 +225,7 @@ bool ShopServer::absturzKlient( int klientId )
     return gefunden;
 }
 
-bool ShopServer::removeKlient( ShSKlient * zKlient )
+bool ShopServer::removeKlient( ShSKlient *zKlient )
 {
     bool gefunden = 0;
     EnterCriticalSection( &cs );
@@ -293,7 +292,7 @@ char *ShopServer::getLetzterFehler() const
 
 // Inhalt der ShSAKlient Klasse aus ShopServer.h
 // Konstruktor 
-ShSAKlient::ShSAKlient( SSLSKlient * klient, ShopServer * shs )
+ShSAKlient::ShSAKlient( SSLSKlient *klient, ShopServer *shs )
     : Thread()
 {
     this->klient = klient;
@@ -331,13 +330,13 @@ void ShSAKlient::thread()
                 {
                     klient->sende( "\1", 1 );
                     unsigned char nLen = 0;
-                    klient->getNachricht( (char *)& nLen, 1 );
+                    klient->getNachricht( (char *)&nLen, 1 );
                     char *n = new char[ nLen + 1 ];
                     n[ (int)nLen ] = 0;
                     if( nLen )
                         klient->getNachricht( n, nLen );
                     unsigned char pLen = 0;
-                    klient->getNachricht( (char *)& pLen, 1 );
+                    klient->getNachricht( (char *)&pLen, 1 );
                     char *p = new char[ pLen + 1 ];
                     p[ (int)pLen ] = 0;
                     if( pLen )
@@ -433,7 +432,7 @@ void ShSAKlient::thread()
                     }
                     else
                         ok = 1;
-                    if( ok &&shs->hatClients() )
+                    if( ok && shs->hatClients() )
                     {
                         errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
                         break;
@@ -529,7 +528,7 @@ void ShSAKlient::thread()
                 {
                     klient->sende( "\1", 1 );
                     int maxK = 0;
-                    klient->getNachricht( (char *)& maxK, 4 );
+                    klient->getNachricht( (char *)&maxK, 4 );
                     if( shs->zDB()->adminHatRecht( adminId, Admin_Recht::ShSMKChange ) )
                     {
                         if( shs->setMaxKarten( maxK ) )
@@ -551,8 +550,8 @@ void ShSAKlient::thread()
                 {
                     klient->sende( "\1", 1 );
                     int klientId = 0;
-                    klient->getNachricht( (char *)& klientId, 4 );
-                    if( klientId &&shs->absturzKlient( klientId ) )
+                    klient->getNachricht( (char *)&klientId, 4 );
+                    if( klientId && shs->absturzKlient( klientId ) )
                         klient->sende( "\1", 1 );
                     else
                         klient->sende( "\0", 1 );
@@ -584,7 +583,7 @@ void ShSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Feh
 
 // Inhalt der ShSKlient aus ShopServer.h
 // Konstruktor 
-ShSKlient::ShSKlient( SKlient * klient, ShopServer * shs )
+ShSKlient::ShSKlient( SKlient *klient, ShopServer *shs )
     : Thread()
 {
     this->klient = klient;
@@ -623,7 +622,7 @@ void ShSKlient::thread()
             switch( c )
             {
             case 1: // Klient identifikation
-                klient->getNachrichtEncrypted( (char *)& klientNummer, 4 );
+                klient->getNachrichtEncrypted( (char *)&klientNummer, 4 );
                 if( !shs->zDB()->proveKlient( klientNummer, shs->getId() ) )
                 {
                     klientNummer = 0;
@@ -654,8 +653,8 @@ void ShSKlient::thread()
                         if( 1 )
                         {
                             int klientId = 0;
-                            klient->getNachrichtEncrypted( (char *)& klientId, 4 );
-                            if( klientId &&shs->absturzKlient( klientId ) )
+                            klient->getNachrichtEncrypted( (char *)&klientId, 4 );
+                            if( klientId && shs->absturzKlient( klientId ) )
                                 klient->sendeEncrypted( "\1", 1 );
                             else
                                 klient->sendeEncrypted( "\0", 1 );
@@ -685,23 +684,23 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     unsigned char len = 0;
-                    klient->getNachrichtEncrypted( (char *)& len, 1 );
+                    klient->getNachrichtEncrypted( (char *)&len, 1 );
                     char *suche = new char[ len + 1 ];
                     suche[ (int)len ] = 0;
                     if( len )
                         klient->getNachrichtEncrypted( suche, len );
-                    Array< int > * list = new Array< int >();
+                    Array< int > *list = new Array< int >();
                     if( shs->zDB()->getSpielArtListe( klientNummer, suche, list ) )
                     {
                         klient->sendeEncrypted( "\1", 1 );
                         int anz = list->getEintragAnzahl();
-                        klient->sendeEncrypted( (char *)& anz, 4 );
+                        klient->sendeEncrypted( (char *)&anz, 4 );
                         if( anz )
                         {
                             for( int i = 0; i < anz; i++ )
                             {
                                 int w = list->get( i );
-                                klient->sendeEncrypted( (char *)& w, 4 );
+                                klient->sendeEncrypted( (char *)&w, 4 );
                             }
                         }
                     }
@@ -718,7 +717,7 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int spielId = 0;
-                    klient->getNachrichtEncrypted( (char *)& spielId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&spielId, 4 );
                     if( !shs->zDB()->proveSpiel( shs->getId(), spielId ) )
                     {
                         Text ip = "";
@@ -728,7 +727,7 @@ void ShSKlient::thread()
                         else
                         {
                             klient->sendeEncrypted( "\2", 1 );
-                            klient->sendeEncrypted( (char *)& port, 4 );
+                            klient->sendeEncrypted( (char *)&port, 4 );
                             char len = (char)ip.getLength();
                             klient->sendeEncrypted( &len, 1 );
                             klient->sendeEncrypted( ip.getText(), len );
@@ -751,7 +750,7 @@ void ShSKlient::thread()
                     dat->setDatei( pfad );
                     dat->open( Datei::Style::lesen );
                     __int64 gr = dat->getSize();
-                    klient->sendeEncrypted( (char *)& gr, 8 );
+                    klient->sendeEncrypted( (char *)&gr, 8 );
                     char *bytes = new char[ 2048 ];
                     while( gr > 0 )
                     {
@@ -772,7 +771,7 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int spielId = 0;
-                    klient->getNachrichtEncrypted( (char *)& spielId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&spielId, 4 );
                     if( !shs->zDB()->proveSpiel( shs->getId(), spielId ) )
                     {
                         Text ip = "";
@@ -782,7 +781,7 @@ void ShSKlient::thread()
                         else
                         {
                             klient->sendeEncrypted( "\2", 1 );
-                            klient->sendeEncrypted( (char *)& port, 4 );
+                            klient->sendeEncrypted( (char *)&port, 4 );
                             char len = (char)ip.getLength();
                             klient->sendeEncrypted( &len, 1 );
                             klient->sendeEncrypted( ip.getText(), len );
@@ -814,7 +813,7 @@ void ShSKlient::thread()
                             i--;
                         }
                     }
-                    klient->sendeEncrypted( (char *)& dAnz, 4 );
+                    klient->sendeEncrypted( (char *)&dAnz, 4 );
                     for( int i = 0; i < dAnz; i++ )
                     {
                         Text *pf = new Text( dat->zPfad()->getText() );
@@ -827,7 +826,7 @@ void ShSKlient::thread()
                         klient->sendeEncrypted( &nl, 1 );
                         klient->sendeEncrypted( list->z( i )->getText(), nl );
                         __int64 gr = d->getSize();
-                        klient->sendeEncrypted( (char *)& gr, 8 );
+                        klient->sendeEncrypted( (char *)&gr, 8 );
                         char *bytes = new char[ 2048 ];
                         while( gr > 0 )
                         {
@@ -851,9 +850,9 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int spielId = 0;
-                    klient->getNachrichtEncrypted( (char *)& spielId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&spielId, 4 );
                     int status = shs->zDB()->getSpielBesitzStatus( klientNummer, spielId );
-                    klient->sendeEncrypted( (char *)& status, 4 );
+                    klient->sendeEncrypted( (char *)&status, 4 );
                 }
                 else
                     errorZuKlient( "Du bist nicht Identifiziert." );
@@ -863,9 +862,9 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int spielId = 0;
-                    klient->getNachrichtEncrypted( (char *)& spielId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&spielId, 4 );
                     int status = shs->zDB()->getSpielTestversionStatus( klientNummer, spielId );
-                    klient->sendeEncrypted( (char *)& status, 4 );
+                    klient->sendeEncrypted( (char *)&status, 4 );
                 }
                 else
                     errorZuKlient( "Du bist nicht Identifiziert." );
@@ -875,9 +874,9 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int spielId = 0;
-                    klient->getNachrichtEncrypted( (char *)& spielId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&spielId, 4 );
                     int status = shs->zDB()->getSpielErwerbbarStatus( klientNummer, spielId );
-                    klient->sendeEncrypted( (char *)& status, 4 );
+                    klient->sendeEncrypted( (char *)&status, 4 );
                 }
                 else
                     errorZuKlient( "Du bist nicht Identifiziert." );
@@ -887,11 +886,11 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int spielId = 0;
-                    klient->getNachrichtEncrypted( (char *)& spielId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&spielId, 4 );
                     char testVersion = 0;
                     klient->getNachrichtEncrypted( &testVersion, 1 );
                     int status = shs->zDB()->getSpielPreis( spielId, testVersion == 1 );
-                    klient->sendeEncrypted( (char *)& status, 4 );
+                    klient->sendeEncrypted( (char *)&status, 4 );
                 }
                 else
                     errorZuKlient( "Du bist nicht Identifiziert." );
@@ -901,7 +900,7 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int spielId = 0;
-                    klient->getNachrichtEncrypted( (char *)& spielId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&spielId, 4 );
                     char testVersion = 0;
                     klient->getNachrichtEncrypted( &testVersion, 1 );
                     bool ok = shs->zDB()->spielKaufen( klientNummer, spielId, testVersion == 1 );
@@ -918,25 +917,25 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int spielId = 0;
-                    klient->getNachrichtEncrypted( (char *)& spielId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&spielId, 4 );
                     unsigned char len = 0;
-                    klient->getNachrichtEncrypted( (char *)& len, 1 );
+                    klient->getNachrichtEncrypted( (char *)&len, 1 );
                     char *suche = new char[ len + 1 ];
                     suche[ (int)len ] = 0;
                     if( len )
                         klient->getNachrichtEncrypted( suche, len );
-                    Array< int > * list = new Array< int >();
+                    Array< int > *list = new Array< int >();
                     if( shs->zDB()->getKarteListe( klientNummer, spielId, suche, list ) )
                     {
                         klient->sendeEncrypted( "\1", 1 );
                         int anz = list->getEintragAnzahl();
-                        klient->sendeEncrypted( (char *)& anz, 4 );
+                        klient->sendeEncrypted( (char *)&anz, 4 );
                         if( anz )
                         {
                             for( int i = 0; i < anz; i++ )
                             {
                                 int w = list->get( i );
-                                klient->sendeEncrypted( (char *)& w, 4 );
+                                klient->sendeEncrypted( (char *)&w, 4 );
                             }
                         }
                     }
@@ -953,7 +952,7 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int karteId = 0;
-                    klient->getNachrichtEncrypted( (char *)& karteId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&karteId, 4 );
                     if( !shs->zDB()->proveKarte( shs->getId(), karteId ) )
                     {
                         Text ip = "";
@@ -963,7 +962,7 @@ void ShSKlient::thread()
                         else
                         {
                             klient->sendeEncrypted( "\2", 1 );
-                            klient->sendeEncrypted( (char *)& port, 4 );
+                            klient->sendeEncrypted( (char *)&port, 4 );
                             char len = (char)ip.getLength();
                             klient->sendeEncrypted( &len, 1 );
                             klient->sendeEncrypted( ip.getText(), len );
@@ -986,7 +985,7 @@ void ShSKlient::thread()
                     dat->setDatei( pfad );
                     dat->open( Datei::Style::lesen );
                     __int64 gr = dat->getSize();
-                    klient->sendeEncrypted( (char *)& gr, 8 );
+                    klient->sendeEncrypted( (char *)&gr, 8 );
                     char *bytes = new char[ 2048 ];
                     while( gr > 0 )
                     {
@@ -1007,7 +1006,7 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int karteId = 0;
-                    klient->getNachrichtEncrypted( (char *)& karteId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&karteId, 4 );
                     if( !shs->zDB()->proveKarte( shs->getId(), karteId ) )
                     {
                         Text ip = "";
@@ -1017,7 +1016,7 @@ void ShSKlient::thread()
                         else
                         {
                             klient->sendeEncrypted( "\2", 1 );
-                            klient->sendeEncrypted( (char *)& port, 4 );
+                            klient->sendeEncrypted( (char *)&port, 4 );
                             char len = (char)ip.getLength();
                             klient->sendeEncrypted( &len, 1 );
                             klient->sendeEncrypted( ip.getText(), len );
@@ -1049,7 +1048,7 @@ void ShSKlient::thread()
                             i--;
                         }
                     }
-                    klient->sendeEncrypted( (char *)& dAnz, 4 );
+                    klient->sendeEncrypted( (char *)&dAnz, 4 );
                     for( int i = 0; i < dAnz; i++ )
                     {
                         Text *pf = new Text( dat->zPfad()->getText() );
@@ -1062,7 +1061,7 @@ void ShSKlient::thread()
                         klient->sendeEncrypted( &nl, 1 );
                         klient->sendeEncrypted( list->z( i )->getText(), nl );
                         __int64 gr = d->getSize();
-                        klient->sendeEncrypted( (char *)& gr, 8 );
+                        klient->sendeEncrypted( (char *)&gr, 8 );
                         char *bytes = new char[ 2048 ];
                         while( gr > 0 )
                         {
@@ -1086,9 +1085,9 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int karteId = 0;
-                    klient->getNachrichtEncrypted( (char *)& karteId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&karteId, 4 );
                     int status = shs->zDB()->getKarteBesitzStatus( klientNummer, karteId );
-                    klient->sendeEncrypted( (char *)& status, 4 );
+                    klient->sendeEncrypted( (char *)&status, 4 );
                 }
                 else
                     errorZuKlient( "Du bist nicht Identifiziert." );
@@ -1098,9 +1097,9 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int karteId = 0;
-                    klient->getNachrichtEncrypted( (char *)& karteId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&karteId, 4 );
                     int status = shs->zDB()->getKarteTestversionStatus( klientNummer, karteId );
-                    klient->sendeEncrypted( (char *)& status, 4 );
+                    klient->sendeEncrypted( (char *)&status, 4 );
                 }
                 else
                     errorZuKlient( "Du bist nicht Identifiziert." );
@@ -1110,9 +1109,9 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int karteId = 0;
-                    klient->getNachrichtEncrypted( (char *)& karteId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&karteId, 4 );
                     int status = shs->zDB()->getKarteErwerbbarStatus( klientNummer, karteId );
-                    klient->sendeEncrypted( (char *)& status, 4 );
+                    klient->sendeEncrypted( (char *)&status, 4 );
                 }
                 else
                     errorZuKlient( "Du bist nicht Identifiziert." );
@@ -1122,11 +1121,11 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int karteId = 0;
-                    klient->getNachrichtEncrypted( (char *)& karteId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&karteId, 4 );
                     char testVersion = 0;
                     klient->getNachrichtEncrypted( &testVersion, 1 );
                     int status = shs->zDB()->getKartePreis( karteId, testVersion == 1 );
-                    klient->sendeEncrypted( (char *)& status, 4 );
+                    klient->sendeEncrypted( (char *)&status, 4 );
                 }
                 else
                     errorZuKlient( "Du bist nicht Identifiziert." );
@@ -1136,7 +1135,7 @@ void ShSKlient::thread()
                 {
                     klient->sendeEncrypted( "\1", 1 );
                     int karteId = 0;
-                    klient->getNachrichtEncrypted( (char *)& karteId, 4 );
+                    klient->getNachrichtEncrypted( (char *)&karteId, 4 );
                     char testVersion = 0;
                     klient->getNachrichtEncrypted( &testVersion, 1 );
                     bool ok = shs->zDB()->karteKaufen( klientNummer, karteId, testVersion == 1 );

+ 6 - 4
ShopServer/ShopServer.vcxproj

@@ -37,7 +37,7 @@
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <TargetExt />
     <RemoteProjectDir>$(RemoteRootDir)/Server/$(ProjectName)/release</RemoteProjectDir>
-    <IncludePath>..\..\..\..\Allgemein\Framework;../../../Framework/release;..\..\..\..\Allgemein\Network\Network;../../../Network/release;..\..\..\..\Allgemein\sql\sql;../../../sql/release;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\..\..\Allgemein\Framework;../../../Framework/release;..\..\..\..\Allgemein\Network\Network;../../../Network/release/Network;..\..\..\..\Allgemein\sql\sql;../../../sql/release/sql;$(IncludePath)</IncludePath>
     <OutDir>$(RemoteRootDir)/Server/$(ProjectName)/release/</OutDir>
     <IntDir>$(RemoteRootDir)/Server/$(ProjectName)/release/</IntDir>
     <RemoteTargetPath>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</RemoteTargetPath>
@@ -45,7 +45,7 @@
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <TargetExt />
     <RemoteProjectDir>$(RemoteRootDir)/Server/$(ProjectName)/debug</RemoteProjectDir>
-    <IncludePath>..\..\..\..\Allgemein\Framework;../../../Framework/debug;..\..\..\..\Allgemein\Network\Network;../../../Network/debug;..\..\..\..\Allgemein\sql\sql;../../../sql/debug;$(IncludePath)</IncludePath>
+    <IncludePath>..\..\..\..\Allgemein\Framework;../../../Framework/debug;..\..\..\..\Allgemein\Network\Network;../../../Network/debug/Network;..\..\..\..\Allgemein\sql\sql;../../../sql/debug/sql;$(IncludePath)</IncludePath>
     <OutDir>$(RemoteRootDir)/Server/$(ProjectName)/debug/</OutDir>
     <IntDir>$(RemoteRootDir)/Server/$(ProjectName)/debug/</IntDir>
     <RemoteTargetPath>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</RemoteTargetPath>
@@ -64,15 +64,17 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <Link>
       <AdditionalLibraryDirectories>$(RemoteRootDir)/sql/release;$(RemoteRootDir)/Network/release;$(RemoteRootDir)/Framework/release;/usr/lib/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
-      <LibraryDependencies>Framework;Network;SQL;pq;pthread</LibraryDependencies>
+      <LibraryDependencies>Framework;Network;SQL;pq;pthread;ssl</LibraryDependencies>
       <AdditionalOptions>-Wl,-rpath,../lib %(AdditionalOptions)</AdditionalOptions>
+      <OutputFile>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</OutputFile>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <Link>
       <AdditionalOptions>-Wl,-rpath,../lib %(AdditionalOptions)</AdditionalOptions>
       <AdditionalLibraryDirectories>$(RemoteRootDir)/sql/debug;$(RemoteRootDir)/Network/debug;$(RemoteRootDir)/Framework/debug;/usr/lib/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
-      <LibraryDependencies>dbgFramework;dbgNetwork;dbgSQL;pq;pthread</LibraryDependencies>
+      <LibraryDependencies>dbgFramework;dbgNetwork;dbgSQL;pq;pthread;ssl</LibraryDependencies>
+      <OutputFile>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</OutputFile>
     </Link>
   </ItemDefinitionGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

+ 8 - 8
ShopServer/Updater.cpp

@@ -47,12 +47,12 @@ void Updater::thread()
                 continue;
             Klient *k = new Klient();
             unsigned char key[ 20 ] = { 55, 124, 19, 204, 23, 5, 59, 75, 247, 138, 119, 111, 57, 250, 206, 187, 165, 6, 247, 151 };
-            k->setEmpfangKey( (char*)key, 20 );
-            k->setSendeKey( (char*)key, 20 );
+            k->setEmpfangKey( (char *)key, 20 );
+            k->setSendeKey( (char *)key, 20 );
             char ret = 0;
             if( !k->verbinde( (unsigned short)port, ip ) )
             {
-                k = k->release();
+                k = (Klient *)k->release();
                 std::cout << "ShS: Updater: Fehler beim Updaten von Karte " << kId << ".\n Verbindung zum Editorserver konnte nicht hergestellt werden.\n";
                 continue;
             }
@@ -60,23 +60,23 @@ void Updater::thread()
             k->getNachrichtEncrypted( &ret, 1 );
             if( ret == 1 )
             {
-                k->sendeEncrypted( (char*)&kId, 4 );
+                k->sendeEncrypted( (char *)&kId, 4 );
                 k->getNachrichtEncrypted( &ret, 1 );
                 if( ret == 1 )
                 {
                     int anz = 0;
-                    k->getNachrichtEncrypted( (char*)&anz, 4 );
+                    k->getNachrichtEncrypted( (char *)&anz, 4 );
                     for( int i = 0; i < anz && !beenden; i++ )
                     {
                         unsigned char len = 0;
-                        k->getNachrichtEncrypted( (char*)&len, 1 );
+                        k->getNachrichtEncrypted( (char *)&len, 1 );
                         if( !len )
                             continue;
                         char *pfa = new char[ len + 1 ];
                         pfa[ (int)len ] = 0;
                         k->getNachrichtEncrypted( pfa, len );
                         __int64 size = 0;
-                        k->getNachrichtEncrypted( (char*)&size, 8 );
+                        k->getNachrichtEncrypted( (char *)&size, 8 );
                         char *buffer = new char[ 2048 ];
                         Text pfad = updatePf;
                         pfad += pfa;
@@ -113,7 +113,7 @@ void Updater::thread()
             if( ret == 3 )
             {
                 unsigned char byte = 0;
-                k->getNachrichtEncrypted( (char*)&byte, 1 );
+                k->getNachrichtEncrypted( (char *)&byte, 1 );
                 char *f = new char[ byte + 1 ];
                 f[ (int)byte ] = 0;
                 k->getNachrichtEncrypted( f, byte );

+ 32 - 32
ShopServer/main.cpp

@@ -7,31 +7,31 @@
 
 int main()
 {
-	struct rlimit core_limits;
-	core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY;
-	setrlimit(RLIMIT_CORE, &core_limits);
+    struct rlimit core_limits;
+    core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY;
+    setrlimit( RLIMIT_CORE, &core_limits );
 
     Framework::initFramework();
-	Zeit *z = getZeit();
-	Text *pfad = new Text( "../log/shop/" );
-	pfad->append( z->getZeit( "y-m-d h-i-s.log" ) );
-	z->release();
-	DateiPfadErstellen( pfad->getThis() );
-	std::ofstream file;
-	file.open( pfad->getText() );
-	std::streambuf* sbuf = std::cout.rdbuf();
-	std::cout.rdbuf( file.rdbuf() );
-	pfad->release();
+    Zeit *z = getZeit();
+    Text *pfad = new Text( "../log/shop/" );
+    pfad->append( z->getZeit( "y-m-d h-i-s.log" ) );
+    z->release();
+    DateiPfadErstellen( pfad->getText() );
+    std::ofstream file;
+    file.open( pfad->getText() );
+    std::streambuf *sbuf = std::cout.rdbuf();
+    std::cout.rdbuf( file.rdbuf() );
+    pfad->release();
 
-	std::cout << "ShS: Startet...\n";
-	std::cout << "ShS: Lese init Datei ../data/shsInit.ini ...\n";
-	InitDatei *dat = new InitDatei( "../data/shsInit.ini" );
-	if( !dat->laden() )
-	{
-		std::cout << "ShS: error: Datei konnte nicht gelesen werden. Das Programm wird geschlossen.\n";
-		dat->release();
-		exit( 1 );
-	}
+    std::cout << "ShS: Startet...\n";
+    std::cout << "ShS: Lese init Datei ../data/shsInit.ini ...\n";
+    InitDatei *dat = new InitDatei( "../data/shsInit.ini" );
+    if( !dat->laden() )
+    {
+        std::cout << "ShS: error: Datei konnte nicht gelesen werden. Das Programm wird geschlossen.\n";
+        dat->release();
+        exit( 1 );
+    }
     const char *wichtig[] = { "ServerId", "DBBenutzer", "DBPasswort", "DBName", "DBIP", "DBPort", "Aktiv", "ShopSeitenPfad", "SSLCert", "SSLKey", "SSLPasswort" };
     for( const char *w : wichtig )
     {
@@ -43,17 +43,17 @@ int main()
         }
     }
 
-	ShopServer *shServer = new ShopServer( dat );
+    ShopServer *shServer = new ShopServer( dat );
 
-	std::cout << "ShS: Der Admin Server läuft. Startforgang beendet.\n";
-	shServer->runn();
+    std::cout << "ShS: Der Admin Server läuft. Startforgang beendet.\n";
+    shServer->runn();
 
-	shServer->ende();
-	shServer->release();
-	dat->release();
-	std::cout << "ShS: Der Server ist heruntergefahren.\n";
-	file.close();
-	std::cout.rdbuf( sbuf );
+    shServer->ende();
+    shServer->release();
+    dat->release();
+    std::cout << "ShS: Der Server ist heruntergefahren.\n";
+    file.close();
+    std::cout.rdbuf( sbuf );
     Framework::releaseFramework();
-	return 0;
+    return 0;
 }