Преглед изворни кода

Option zum Abfragen von Account Ids und Account Namen hinzugefügt

Kolja Strohm пре 5 година
родитељ
комит
7341dae0d2
4 измењених фајлова са 88 додато и 1 уклоњено
  1. 38 0
      Minigame Server/Datenbank.cpp
  2. 2 0
      Minigame Server/Datenbank.h
  3. 33 0
      Minigame Server/MinigameServer.cpp
  4. 15 1
      build.bat

+ 38 - 0
Minigame Server/Datenbank.cpp

@@ -205,6 +205,44 @@ bool MSDatenbank::serverIstNichtPausiert( int id )
     return ret;
 }
 
+int MSDatenbank::getAccountId( int clientNumber )
+{
+    Text befehl = "SELECT account_id FROM account_client WHERE client_id = ";
+    befehl += clientNumber;
+    lock();
+    if( !datenbank->befehl( befehl ) )
+    {
+        unlock();
+        return 0;
+    }
+    Result res = datenbank->getResult();
+    unlock();
+    if( !res.zeilenAnzahl )
+        return 0;
+    int ret = res.values[ 0 ];
+    res.destroy();
+    return ret;
+}
+
+Text *MSDatenbank::getAccountName( int accountId )
+{
+    Text befehl = "SELECT ruf_name FROM account WHERE id = ";
+    befehl += accountId;
+    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 = '";

+ 2 - 0
Minigame Server/Datenbank.h

@@ -39,6 +39,8 @@ public:
     bool setServerStatus( int id, int status );
     bool setMaxClients( int id, int maxC );
     bool serverIstNichtPausiert( int id );
+    int getAccountId( int clientNumber );
+    Text *getAccountName( int accountId );
     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 );

+ 33 - 0
Minigame Server/MinigameServer.cpp

@@ -943,6 +943,39 @@ void MSKlient::thread()
                 delete[] oName;
                 break;
             }
+            case 0xB:
+            {
+                if( !klientNummer )
+                {
+                    errorZuKlient( "Du bist nicht Identifiziert." );
+                    break;
+                }
+                klient->sendeEncrypted( "\1", 1 );
+                int acc = ms->zDB()->getAccountId( klientNummer );
+                klient->sendeEncrypted( (char*)&acc, 4 );
+            }
+            case 0xC:
+            {
+                if( !klientNummer )
+                {
+                    errorZuKlient( "Du bist nicht Identifiziert." );
+                    break;
+                }
+                klient->sendeEncrypted( "\1", 1 );
+                int acc;
+                klient->getNachrichtEncrypted( (char*)&acc, 4 );
+                Text *name = ms->zDB()->getAccountName( acc );
+                if( !name )
+                    errorZuKlient( "Der Acount existiert nicht." );
+                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;

+ 15 - 1
build.bat

@@ -1,2 +1,16 @@
+:DebugLinux64
+SET RETURN=DebugLinux64
+SET NEXT=ReleaseLinux64
 "D:\Visual Studio 2017\MSBuild\15.0\Bin\MSBuild.exe" "Minigame Server.sln" /t:rebuild /p:configuration=debug /p:platform=x64
-"D:\Visual Studio 2017\MSBuild\15.0\Bin\MSBuild.exe" "Minigame Server.sln" /t:rebuild /p:configuration=release /p:platform=x64
+if errorlevel 1 GOTO Error
+:ReleaseLinux64
+SET RETURN=ReleaseLinux64
+SET NEXT=End
+"D:\Visual Studio 2017\MSBuild\15.0\Bin\MSBuild.exe" "Minigame Server.sln" /t:rebuild /p:configuration=release /p:platform=x64
+if errorlevel 1 GOTO Error
+GOTO End
+:Error
+SET /p redo=Nochmal versuchen?(j/n):
+IF /I '%redo%' equ 'j' GOTO %RETURN%
+GOTO %NEXT%
+:End