Selaa lähdekoodia

Random seed wird empfangen und verwendet

Kolja Strohm 4 vuotta sitten
vanhempi
commit
e1b13eec20
2 muutettua tiedostoa jossa 20 lisäystä ja 0 poistoa
  1. 2 0
      StickmanWorldOnline/Spiel.cpp
  2. 18 0
      StickmanWorldOnline/Spieler.cpp

+ 2 - 0
StickmanWorldOnline/Spiel.cpp

@@ -644,6 +644,8 @@ void Spiel::stknVerarbeitung()
                     }
                 }
             }
+            __int64 seed = *(__int64 *)( msg + 2 + spielerAnzahl * 8 );
+            randG.setSeed( seed );
             n->setVerarbeitet();
             break;
         case 2: // spielernummer

+ 18 - 0
StickmanWorldOnline/Spieler.cpp

@@ -224,6 +224,8 @@ Spieler::Spieler( ResourceRegistry *zResources, int id, Team *team, int spawnX,
     texturScale = 1;
     resources = zResources->getThis();
     current = zResources->getResource( R_SPIELER, farbe );
+    if( !current )
+        throw "error";
     textur = current->getImages()->getThis();
     heilungR = zResources->getResource( R_HEILUNG, 0 );
     schadenR = zResources->getResource( R_SCHADEN, 0 );
@@ -251,6 +253,8 @@ bool Spieler::setTastenStand( unsigned char taste, bool pressed )
             {
                 current->release();
                 current = resources->getResource( R_SPIELER_RECHTS, color );
+                if( !current )
+                    throw "error";
             }
             ausrichtung = OBEN;
         }
@@ -258,6 +262,8 @@ bool Spieler::setTastenStand( unsigned char taste, bool pressed )
         {
             current->release();
             current = resources->getResource( R_SPIELER_LINKS, color );
+            if( !current )
+                throw "error";
             ausrichtung = LINKS;
         }
         if( taste == 's' )
@@ -266,6 +272,8 @@ bool Spieler::setTastenStand( unsigned char taste, bool pressed )
             {
                 current->release();
                 current = resources->getResource( R_SPIELER_LINKS, color );
+                if( !current )
+                    throw "error";
             }
             ausrichtung = UNTEN;
         }
@@ -273,6 +281,8 @@ bool Spieler::setTastenStand( unsigned char taste, bool pressed )
         {
             current->release();
             current = resources->getResource( R_SPIELER_RECHTS, color );
+            if( !current )
+                throw "error";
             ausrichtung = RECHTS;
         }
         if( taste >= '1' && taste <= '8' )
@@ -284,6 +294,8 @@ bool Spieler::setTastenStand( unsigned char taste, bool pressed )
         {
             current->release();
             current = resources->getResource( R_SPIELER, color );
+            if( !current )
+                throw "error";
             ausrichtung = MITTE;
         }
         else
@@ -299,6 +311,8 @@ bool Spieler::setTastenStand( unsigned char taste, bool pressed )
                 {
                     current->release();
                     current = resources->getResource( R_SPIELER_LINKS, color );
+                    if( !current )
+                        throw "error";
                     ausrichtung = LINKS;
                 }
                 if( tastenStand[ 's' ] )
@@ -307,6 +321,8 @@ bool Spieler::setTastenStand( unsigned char taste, bool pressed )
                 {
                     current->release();
                     current = resources->getResource( R_SPIELER_RECHTS, color );
+                    if( !current )
+                        throw "error";
                     ausrichtung = RECHTS;
                 }
             }
@@ -728,6 +744,8 @@ void Spieler::nimmSchaden( float schaden, Spieler *zVerursacher, Richtung r, Spi
     {
         current->release();
         current = resources->getResource( R_SPIELER, color );
+        if( !current )
+            throw "error";
         heilungImage = 0;
         schadenImage = 0;
         showSchaden = 0;