ソースを参照

Fehler mit Adminrechten behoben,
Rekordaufsteller bekommen jetzt Kupfer als belonung

Kolja Strohm 6 年 前
コミット
63b03947da

+ 21 - 2
Minigame Server/Datenbank.cpp

@@ -296,7 +296,17 @@ bool MSDatenbank::updateMinigameScore( int score, char *option, int cId, char *m
     o.ersetzen( "'", "''" );
     Text m( minigame );
     m.ersetzen( "'", "''" );
-    Text befehl = "SELECT a.id FROM minigame_option a, minigame b WHERE a.minigame_id = b.id AND b.name = '";
+    Text befehl = "UPDATE minigame SET games_played = games_played + 1 WHERE name = '";
+    befehl += m;
+    befehl += "'";
+    lock();
+    if( !datenbank->befehl( befehl ) )
+    {
+        unlock();
+        return 0;
+    }
+    unlock();
+    befehl = "SELECT a.id FROM minigame_option a, minigame b WHERE a.minigame_id = b.id AND b.name = '";
     befehl += m;
     befehl += "' AND a.options = '";
     befehl += o;
@@ -337,7 +347,7 @@ bool MSDatenbank::updateMinigameScore( int score, char *option, int cId, char *m
         {
             befehl = "UPDATE minigame_bestscore b SET score = ";
             befehl += score;
-            befehl += ", account_id = a.account_id, minigame_server_id = ";
+            befehl += ", account_id = a.account_id, counter = counter + 1, minigame_server_id = ";
             befehl += sId;
             befehl += " FROM account_client a WHERE a.client_id = ";
             befehl += cId;
@@ -362,6 +372,15 @@ bool MSDatenbank::updateMinigameScore( int score, char *option, int cId, char *m
             return 0;
         }
         unlock();
+        befehl = "UPDATE account b SET kupfer = b.kupfer + a.counter FROM minigame_bestscore a WHERE a.account_id = b.id AND a.minigame_options_id = ";
+        befehl += optionId;
+        lock();
+        if( !datenbank->befehl( befehl ) )
+        {
+            unlock();
+            return 0;
+        }
+        unlock();
     }
     return ret;
 }

+ 4 - 4
Minigame Server/Datenbank.h

@@ -10,10 +10,10 @@ using namespace sql;
 
 namespace Admin_Recht
 {
-    const int LSStarten = 12;
-    const int LSBeenden = 13;
-    const int LSPausieren = 14;
-    const int LSMCChange = 15;
+    const int MSStarten = 66;
+    const int MSBeenden = 67;
+    const int MSPausieren = 68;
+    const int MSMCChange = 69;
 }
 
 class MSDatenbank

+ 2 - 0
Minigame Server/Minigame Server.vcxproj

@@ -90,12 +90,14 @@
     <Link>
       <AdditionalLibraryDirectories>$(RemoteRootDir)/sql/debug/bin/x64/debug;$(RemoteRootDir)/Network/debug/bin/x64/debug;$(RemoteRootDir)/Framework/debug/bin/x64/debug;/usr/lib/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <LibraryDependencies>dbgFramework;dbgNetwork;dbgSQL;pq;pthread</LibraryDependencies>
+      <AdditionalOptions>-Wl,-rpath,../lib %(AdditionalOptions)</AdditionalOptions>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <Link>
       <AdditionalLibraryDirectories>$(RemoteRootDir)/sql/release/bin/x64/release;$(RemoteRootDir)/Network/release/bin/x64/release;$(RemoteRootDir)/Framework/release/bin/x64/release;/usr/lib/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <LibraryDependencies>Framework;Network;SQL;pq;pthread</LibraryDependencies>
+      <AdditionalOptions>-Wl,-rpath,../lib %(AdditionalOptions)</AdditionalOptions>
     </Link>
   </ItemDefinitionGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

+ 6 - 6
Minigame Server/MinigameServer.cpp

@@ -385,7 +385,7 @@ void MSAKlient::thread()
                     errorZuKlient( "Du musst dich einloggen." );
                 else
                 {
-                    if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::LSStarten ) )
+                    if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSStarten ) )
                     {
                         if( !ms->serverStarten() )
                         {
@@ -406,7 +406,7 @@ void MSAKlient::thread()
                     errorZuKlient( "Du musst dich einloggen." );
                 else
                 {
-                    if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::LSBeenden ) )
+                    if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSBeenden ) )
                     {
                         if( ms->serverBeenden() )
                             klient->sendeEncrypted( "\1", 1 );
@@ -430,7 +430,7 @@ void MSAKlient::thread()
                     bool ok = 0;
                     if( ms->isRunning() )
                     {
-                        if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::LSBeenden ) )
+                        if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSBeenden ) )
                         {
                             if( ms->serverBeenden() )
                                 ok = 1;
@@ -469,7 +469,7 @@ void MSAKlient::thread()
                     bool ok = 0;
                     if( ms->isRunning() )
                     {
-                        if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::LSBeenden ) )
+                        if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSBeenden ) )
                         {
                             ms->serverBeenden();
                             ok = 1;
@@ -510,7 +510,7 @@ void MSAKlient::thread()
                     klient->sendeEncrypted( "\1", 1 );
                     char pause = 0;
                     klient->getNachrichtEncrypted( &pause, 1 );
-                    if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::LSPausieren ) )
+                    if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSPausieren ) )
                     {
                         bool ok = 0;
                         if( pause )
@@ -544,7 +544,7 @@ void MSAKlient::thread()
                     klient->sendeEncrypted( "\1", 1 );
                     int maxC = 0;
                     klient->getNachrichtEncrypted( (char*)&maxC, 4 );
-                    if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::LSMCChange ) )
+                    if( ms->zDB()->adminHatRecht( adminId, Admin_Recht::MSMCChange ) )
                     {
                         if( ms->setMaxKlients( maxC ) )
                             klient->sendeEncrypted( "\1", 1 );