Forráskód Böngészése

fix compiler errors

Kolja Strohm 3 éve
szülő
commit
47a3675f6f

+ 6 - 21
Minigame Server/Datenbank.cpp

@@ -4,6 +4,7 @@
 // Inhalt der LSDatenbank Klasse aus Datenbank.h
 // Konstruktor
 MSDatenbank::MSDatenbank( InitDatei *zIni )
+    : ReferenceCounter()
 {
     datenbank = new Datenbank( zIni->zWert( "DBBenutzer" )->getText(), zIni->zWert( "DBPasswort" )->getText(),
                                zIni->zWert( "DBName" )->getText(), zIni->zWert( "DBIP" )->getText(),
@@ -14,7 +15,6 @@ MSDatenbank::MSDatenbank( InitDatei *zIni )
         exit( 1 );
     }
     InitializeCriticalSection( &cs );
-    ref = 1;
     Text befehl = "SELECT port, admin_port  FROM server WHERE id = ";
     befehl += zIni->zWert( "ServerId" )->getText();
     lock();
@@ -52,11 +52,11 @@ int MSDatenbank::istAdministrator( const char *name, const char *passwort )
     Text *befehl = new Text( "SELECT id FROM benutzer WHERE name = '" );
     Text n( name );
     n.ersetzen( "'", "''" );
-    befehl->append( (char*)n );
+    befehl->append( (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() );
@@ -279,7 +279,7 @@ int MSDatenbank::getMinigameOptionList( char *minigame, RCArray< Text > *zOption
     unlock();
     int anz = res.zeilenAnzahl;
     for( int i = 0; i < anz; i++ )
-        zOptionList->add( new Text( (char*)res.values[ i ] ) );
+        zOptionList->add( new Text( (char *)res.values[ i ] ) );
     res.destroy();
     return anz;
 }
@@ -521,8 +521,8 @@ bool MSDatenbank::getMinigameServer( char *minigame, char *option, Text *zIp, Te
     unlock();
     if( res.zeilenAnzahl )
     {
-        zIp->setText( (char*)res.values[ 0 ] );
-        zPort->setText( (char*)res.values[ 1 ] );
+        zIp->setText( (char *)res.values[ 0 ] );
+        zPort->setText( (char *)res.values[ 1 ] );
         res.destroy();
         return 1;
     }
@@ -534,19 +534,4 @@ bool MSDatenbank::getMinigameServer( char *minigame, char *option, Text *zIp, Te
 Text *MSDatenbank::getLetzterFehler() const
 {
     return datenbank->getLetzterFehler();
-}
-
-// Reference Counting
-MSDatenbank *MSDatenbank::getThis()
-{
-    ref++;
-    return this;
-}
-
-MSDatenbank *MSDatenbank::release()
-{
-    ref--;
-    if( !ref )
-        delete this;
-    return 0;
 }

+ 1 - 5
Minigame Server/Datenbank.h

@@ -16,12 +16,11 @@ namespace Admin_Recht
     const int MSMCChange = 69;
 }
 
-class MSDatenbank
+class MSDatenbank : public virtual ReferenceCounter
 {
 private:
     Datenbank *datenbank;
     CRITICAL_SECTION cs;
-    int ref;
 
 public:
     // Konstruktor
@@ -51,7 +50,4 @@ public:
     bool getMinigameServer( char *minigame, char *option, Text *zIp, Text *zPort );
     // constant
     Text *getLetzterFehler() const;
-    // Reference Counting
-    MSDatenbank *getThis();
-    MSDatenbank *release();
 };

+ 6 - 4
Minigame Server/Minigame Server.vcxproj

@@ -67,7 +67,7 @@
     <OutDir>$(RemoteRootDir)/Server/$(ProjectName)/debug/</OutDir>
     <IntDir>$(RemoteRootDir)/Server/$(ProjectName)/debug/</IntDir>
     <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>
     <TargetExt />
     <RemoteTargetPath>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</RemoteTargetPath>
   </PropertyGroup>
@@ -75,7 +75,7 @@
     <OutDir>$(RemoteRootDir)/Server/$(ProjectName)/release/</OutDir>
     <IntDir>$(RemoteRootDir)/Server/$(ProjectName)/release/</IntDir>
     <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>
     <TargetExt />
     <RemoteTargetPath>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</RemoteTargetPath>
   </PropertyGroup>
@@ -91,15 +91,17 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <Link>
       <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>
       <AdditionalOptions>-Wl,-rpath,../lib %(AdditionalOptions)</AdditionalOptions>
+      <OutputFile>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</OutputFile>
     </Link>
   </ItemDefinitionGroup>
   <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>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

BIN
Minigame Server/MinigameServer


+ 44 - 44
Minigame Server/MinigameServer.cpp

@@ -16,7 +16,7 @@ MinigameServer::MinigameServer( 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();
@@ -65,13 +65,13 @@ void MinigameServer::runn()
         if( end && klient )
         {
             klient->trenne();
-            klient = klient->release();
+            klient = (SSLSKlient *)klient->release();
             Sleep( 1000 );
             return;
         }
         if( !klient )
             continue;
-        MSAKlient * clHandle = new MSAKlient( klient, (MinigameServer *)getThis() );
+        MSAKlient *clHandle = new MSAKlient( klient, dynamic_cast<MinigameServer *>( getThis() ) );
         clHandle->start();
     }
 }
@@ -85,7 +85,7 @@ void MinigameServer::thread()
         if( !klient )
             continue;
         Framework::getThreadRegister()->cleanUpClosedThreads();
-        MSKlient * clHandle = new MSKlient( klient, (MinigameServer *)getThis() );
+        MSKlient *clHandle = new MSKlient( klient, dynamic_cast<MinigameServer *>( getThis() ) );
         EnterCriticalSection( &cs );
         klients->set( clHandle, klientAnzahl );
         klientAnzahl++;
@@ -104,13 +104,13 @@ void MinigameServer::close()
     EnterCriticalSection( &cs );
     for( int i = 0; i < klientAnzahl; i++ )
         klients->z( i )->absturz();
-    klients = klients->release();
+    klients = ( RCArray<MSKlient>* )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();
@@ -223,7 +223,7 @@ bool MinigameServer::absturzKlient( int klientId )
     return gefunden;
 }
 
-bool MinigameServer::removeKlient( MSKlient * zKlient )
+bool MinigameServer::removeKlient( MSKlient *zKlient )
 {
     bool gefunden = 0;
     EnterCriticalSection( &cs );
@@ -290,7 +290,7 @@ InitDatei *MinigameServer::zInit() const
 
 // Inhalt der LSAKlient Klasse aus LoginServer.h
 // Konstruktor 
-MSAKlient::MSAKlient( SSLSKlient * klient, MinigameServer * ls )
+MSAKlient::MSAKlient( SSLSKlient *klient, MinigameServer *ls )
     : Thread()
 {
     this->klient = klient;
@@ -329,13 +329,13 @@ void MSAKlient::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 )
@@ -431,7 +431,7 @@ void MSAKlient::thread()
                     }
                     else
                         ok = 1;
-                    if( ok &&ms->hatClients() )
+                    if( ok && ms->hatClients() )
                     {
                         errorZuKlient( "Es sind noch Klients Online. Bitte versuche es später erneut." );
                         break;
@@ -527,7 +527,7 @@ void MSAKlient::thread()
                 {
                     klient->sende( "\1", 1 );
                     int maxC = 0;
-                    klient->getNachricht( (char *)& maxC, 4 );
+                    klient->getNachricht( (char *)&maxC, 4 );
                     if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSMCChange ) )
                     {
                         if( ms->setMaxKlients( maxC ) )
@@ -549,8 +549,8 @@ void MSAKlient::thread()
                 {
                     klient->sende( "\1", 1 );
                     int klientId = 0;
-                    klient->getNachricht( (char *)& klientId, 4 );
-                    if( klientId &&ms->absturzKlient( klientId ) )
+                    klient->getNachricht( (char *)&klientId, 4 );
+                    if( klientId && ms->absturzKlient( klientId ) )
                         klient->sende( "\1", 1 );
                     else
                         klient->sende( "\0", 1 );
@@ -582,7 +582,7 @@ void MSAKlient::errorZuKlient( const char *nachricht ) const // sendet eine Fehl
 
 // Inhalt der LSKlient aus LoginServer.h
 // Konstruktor
-MSKlient::MSKlient( SKlient * klient, MinigameServer * ls )
+MSKlient::MSKlient( SKlient *klient, MinigameServer *ls )
     : Thread()
 {
     this->klient = klient;
@@ -621,7 +621,7 @@ void MSKlient::thread()
             switch( c )
             {
             case 1: // Klient identifikation
-                klient->getNachrichtEncrypted( (char *)& klientNummer, 4 );
+                klient->getNachrichtEncrypted( (char *)&klientNummer, 4 );
                 if( !ms->zDB()->proveKlient( klientNummer, ms->getId() ) )
                 {
                     klientNummer = 0;
@@ -652,8 +652,8 @@ void MSKlient::thread()
                         if( 1 )
                         {
                             int klientId = 0;
-                            klient->getNachrichtEncrypted( (char *)& klientId, 4 );
-                            if( klientId &&ms->absturzKlient( klientId ) )
+                            klient->getNachrichtEncrypted( (char *)&klientId, 4 );
+                            if( klientId && ms->absturzKlient( klientId ) )
                                 klient->sendeEncrypted( "\1", 1 );
                             else
                                 klient->sendeEncrypted( "\0", 1 );
@@ -690,18 +690,18 @@ void MSKlient::thread()
             {
                 klient->sendeEncrypted( "\1", 1 );
                 unsigned char l = 0;
-                klient->getNachrichtEncrypted( (char *)& l, 1 );
+                klient->getNachrichtEncrypted( (char *)&l, 1 );
                 char *mName = new char[ l ];
                 mName[ (int)l ] = 0;
                 klient->getNachrichtEncrypted( mName, l );
                 RCArray< Text > oList;
                 int anz = ms->zDB()->getMinigameOptionList( mName, &oList );
                 delete[] mName;
-                klient->sendeEncrypted( (char *)& anz, 4 );
+                klient->sendeEncrypted( (char *)&anz, 4 );
                 for( auto t = oList.getIterator(); t && t._; t++ )
                 {
                     l = (char)t->getLength();
-                    klient->sendeEncrypted( (char *)& l, 1 );
+                    klient->sendeEncrypted( (char *)&l, 1 );
                     klient->sendeEncrypted( t->getText(), l );
                 }
                 break;
@@ -710,7 +710,7 @@ void MSKlient::thread()
             {
                 klient->sendeEncrypted( "\1", 1 );
                 unsigned char l = 0;
-                klient->getNachrichtEncrypted( (char *)& l, 1 );
+                klient->getNachrichtEncrypted( (char *)&l, 1 );
                 char *mName = new char[ l ];
                 mName[ (int)l ] = 0;
                 klient->getNachrichtEncrypted( mName, l );
@@ -719,16 +719,16 @@ void MSKlient::thread()
                 RCArray< Text > oList;
                 int anz = ms->zDB()->getMinigameBestscore( mName, &sList, &pList, &oList );
                 delete[] mName;
-                klient->sendeEncrypted( (char *)& anz, 4 );
+                klient->sendeEncrypted( (char *)&anz, 4 );
                 for( int i = 0; i < anz; i++ )
                 {
                     int s = sList.get( i );
-                    klient->sendeEncrypted( (char *)& s, 4 );
+                    klient->sendeEncrypted( (char *)&s, 4 );
                     l = (char)pList.z( i )->getLength();
-                    klient->sendeEncrypted( (char *)& l, 1 );
+                    klient->sendeEncrypted( (char *)&l, 1 );
                     klient->sendeEncrypted( pList.z( i )->getText(), l );
                     l = (char)oList.z( i )->getLength();
-                    klient->sendeEncrypted( (char *)& l, 1 );
+                    klient->sendeEncrypted( (char *)&l, 1 );
                     klient->sendeEncrypted( oList.z( i )->getText(), l );
                 }
                 break;
@@ -737,11 +737,11 @@ void MSKlient::thread()
             {
                 klient->sendeEncrypted( "\1", 1 );
                 unsigned char l = 0;
-                klient->getNachrichtEncrypted( (char *)& l, 1 );
+                klient->getNachrichtEncrypted( (char *)&l, 1 );
                 char *mName = new char[ l ];
                 mName[ (int)l ] = 0;
                 klient->getNachrichtEncrypted( mName, l );
-                klient->getNachrichtEncrypted( (char *)& l, 1 );
+                klient->getNachrichtEncrypted( (char *)&l, 1 );
                 char *oName = new char[ l ];
                 oName[ (int)l ] = 0;
                 klient->getNachrichtEncrypted( oName, l );
@@ -749,11 +749,11 @@ void MSKlient::thread()
                 int score = ms->zDB()->getMinigameBestscore( oName, mName, &player );
                 delete[] mName;
                 delete[] oName;
-                klient->sendeEncrypted( (char *)& score, 4 );
+                klient->sendeEncrypted( (char *)&score, 4 );
                 if( score )
                 {
                     l = (char)player.getLength();
-                    klient->sendeEncrypted( (char *)& l, 1 );
+                    klient->sendeEncrypted( (char *)&l, 1 );
                     klient->sendeEncrypted( player.getText(), l );
                 }
                 break;
@@ -767,16 +767,16 @@ void MSKlient::thread()
                 }
                 klient->sendeEncrypted( "\1", 1 );
                 unsigned char l = 0;
-                klient->getNachrichtEncrypted( (char *)& l, 1 );
+                klient->getNachrichtEncrypted( (char *)&l, 1 );
                 char *mName = new char[ l ];
                 mName[ (int)l ] = 0;
                 klient->getNachrichtEncrypted( mName, l );
-                klient->getNachrichtEncrypted( (char *)& l, 1 );
+                klient->getNachrichtEncrypted( (char *)&l, 1 );
                 char *oName = new char[ l ];
                 oName[ (int)l ] = 0;
                 klient->getNachrichtEncrypted( oName, l );
                 int score;
-                klient->getNachrichtEncrypted( (char *)& score, 4 );
+                klient->getNachrichtEncrypted( (char *)&score, 4 );
                 Text fName;
                 if( ms->zDB()->updateMinigameScore( score, oName, klientNummer, mName, ms->getId(), &fName ) )
                 {
@@ -792,7 +792,7 @@ void MSKlient::thread()
                     {
                         klient->sendeEncrypted( "\1", 1 );
                         int size;
-                        klient->getNachrichtEncrypted( (char *)& size, 4 );
+                        klient->getNachrichtEncrypted( (char *)&size, 4 );
                         char *buffer = new char[ 2048 ];
                         while( size > 0 )
                         {
@@ -818,11 +818,11 @@ void MSKlient::thread()
             {
                 klient->sendeEncrypted( "\1", 1 );
                 unsigned char l = 0;
-                klient->getNachrichtEncrypted( (char *)& l, 1 );
+                klient->getNachrichtEncrypted( (char *)&l, 1 );
                 char *mName = new char[ l ];
                 mName[ (int)l ] = 0;
                 klient->getNachrichtEncrypted( mName, l );
-                klient->getNachrichtEncrypted( (char *)& l, 1 );
+                klient->getNachrichtEncrypted( (char *)&l, 1 );
                 char *oName = new char[ l ];
                 oName[ (int)l ] = 0;
                 klient->getNachrichtEncrypted( oName, l );
@@ -842,7 +842,7 @@ void MSKlient::thread()
                     {
                         klient->sendeEncrypted( "\1", 1 );
                         int size = (int)d.getSize();
-                        klient->sendeEncrypted( (char *)& size, 4 );
+                        klient->sendeEncrypted( (char *)&size, 4 );
                         char *buffer = new char[ 2048 ];
                         while( size > 0 )
                         {
@@ -875,18 +875,18 @@ void MSKlient::thread()
                             if( ret == 1 )
                             {
                                 l = (char)textLength( mName );
-                                k->sendeEncrypted( (char *)& l, 1 );
+                                k->sendeEncrypted( (char *)&l, 1 );
                                 k->sendeEncrypted( mName, l );
                                 l = (char)textLength( oName );
-                                k->sendeEncrypted( (char *)& l, 1 );
+                                k->sendeEncrypted( (char *)&l, 1 );
                                 k->sendeEncrypted( oName, l );
                                 k->getNachrichtEncrypted( &ret, 1 );
                                 if( ret == 1 )
                                 {
                                     klient->sendeEncrypted( "\1", 1 );
                                     int size;
-                                    k->getNachrichtEncrypted( (char *)& size, 4 );
-                                    klient->sendeEncrypted( (char *)& size, 4 );
+                                    k->getNachrichtEncrypted( (char *)&size, 4 );
+                                    klient->sendeEncrypted( (char *)&size, 4 );
                                     char *buffer = new char[ 2048 ];
                                     while( size > 0 )
                                     {
@@ -900,7 +900,7 @@ void MSKlient::thread()
                             }
                             if( ret == 3 )
                             {
-                                k->getNachrichtEncrypted( (char *)& l, 1 );
+                                k->getNachrichtEncrypted( (char *)&l, 1 );
                                 char *error = new char[ l + 1 ];
                                 error[ (int)l ] = 0;
                                 k->getNachrichtEncrypted( error, l );
@@ -935,7 +935,7 @@ void MSKlient::thread()
                 }
                 klient->sendeEncrypted( "\1", 1 );
                 int acc = ms->zDB()->getAccountId( klientNummer );
-                klient->sendeEncrypted( (char *)& acc, 4 );
+                klient->sendeEncrypted( (char *)&acc, 4 );
                 break;
             }
             case 0xC:
@@ -947,7 +947,7 @@ void MSKlient::thread()
                 }
                 klient->sendeEncrypted( "\1", 1 );
                 int acc;
-                klient->getNachrichtEncrypted( (char *)& acc, 4 );
+                klient->getNachrichtEncrypted( (char *)&acc, 4 );
                 Text *name = ms->zDB()->getAccountName( acc );
                 if( !name )
                     errorZuKlient( "Der Acount existiert nicht." );

+ 5 - 5
Minigame Server/main.cpp

@@ -7,19 +7,19 @@
 
 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/minigame/" );
     pfad->append( z->getZeit( "y-m-d h-i-s.log" ) );
     z->release();
-    DateiPfadErstellen( pfad->getThis() );
+    DateiPfadErstellen( pfad->getText() );
     std::ofstream file;
     file.open( pfad->getText() );
-    std::streambuf* sbuf = std::cout.rdbuf();
+    std::streambuf *sbuf = std::cout.rdbuf();
     std::cout.rdbuf( file.rdbuf() );
     pfad->release();