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

Abfrage eines Secrets hinzugefügt

Kolja Strohm 5 éve
szülő
commit
1a178dedfd

+ 19 - 0
Minigame Server/Datenbank.cpp

@@ -243,6 +243,25 @@ Text *MSDatenbank::getAccountName( int accountId )
     return ret;
 }
 
+Text *MSDatenbank::getSecret( int client )
+{
+    Text befehl = "SELECT secret FROM client WHERE id = ";
+    befehl += client;
+    lock();
+    if( !datenbank->befehl( befehl ) )
+    {
+        unlock();
+        return 0;
+    }
+    Result res = datenbank->getResult();
+    unlock();
+    if( !res.zeilenAnzahl )
+        return 0;
+    Text *ret = new Text( res.values[ 0 ].getText() );
+    res.destroy();
+    return ret;
+}
+
 int MSDatenbank::getMinigameOptionList( char *minigame, RCArray< Text > *zOptionList )
 {
     Text befehl = "SELECT a.options FROM minigame_option a, minigame b WHERE a.minigame_id = b.id AND b.name = '";

+ 1 - 0
Minigame Server/Datenbank.h

@@ -41,6 +41,7 @@ public:
     bool serverIstNichtPausiert( int id );
     int getAccountId( int clientNumber );
     Text *getAccountName( int accountId );
+    Text *getSecret( int client );
     int getMinigameOptionList( char *minigame, RCArray< Text > *zOptionList );
     int getMinigameBestscore( char *options, char *minigame, Text *zPlayer );
     int getMinigameBestscore( char *minigame, Array< int > *zScoreList, RCArray< Text > *zPlayerList, RCArray< Text > *zOptionList );

+ 19 - 0
Minigame Server/MinigameServer.cpp

@@ -976,6 +976,25 @@ void MSKlient::thread()
                     name->release();
                 }
             }
+            case 0xD:
+            {
+                if( !klientNummer )
+                {
+                    errorZuKlient( "Du bist nicht Identifiziert." );
+                    break;
+                }
+                Text *name = ms->zDB()->getSecret( klientNummer );
+                if( !name )
+                    errorZuKlient( "Kein secret gefunden." );
+                else
+                {
+                    klient->sendeEncrypted( "\1", 1 );
+                    char len = (char)name->getLength();
+                    klient->sendeEncrypted( &len, 1 );
+                    klient->sendeEncrypted( name->getText(), len );
+                    name->release();
+                }
+            }
             default:
                 errorZuKlient( "Unbekannte Nachricht!" );
                 break;