Ver Fonte

Fehler beim ändern des Teams von Basen behoben

Kolja Strohm há 4 anos atrás
pai
commit
8fba5f28f5
1 ficheiros alterados com 7 adições e 8 exclusões
  1. 7 8
      StickmanWorldOnline/Base.cpp

+ 7 - 8
StickmanWorldOnline/Base.cpp

@@ -24,10 +24,15 @@ Base::~Base()
 
 void Base::setTeam( Team *team, Spiel *zSpiel )
 {
+    Ereignis *e = new Ereignis( BASIS_BESITZERWECHSEL );
+    e->addParameter( "Betroffene Basis", getThis() );
+    e->addParameter( "Vorheriges Team", this->team ? this->team->getThis() : new Variable( NICHTS ) );
+    e->addParameter( "Nächstes Team", team ? team->getThis() : new Variable( NICHTS ) );
     if( this->team )
         this->team->release();
     this->team = team;
     zSpiel->setLastTeamChangedBase( (Base *)getThis() );
+    zSpiel->throwEvent( e );
 }
 
 void Base::startChange( Team *team )
@@ -65,14 +70,8 @@ void Base::tick( double time, Spiel *zSpiel )
         leftTime -= (float)time;
         if( leftTime <= 0 )
         {
-            Ereignis *e = new Ereignis( BASIS_BESITZERWECHSEL );
-            e->addParameter( "Betroffene Basis", getThis() );
-            e->addParameter( "Vorheriges Team", team ? team->getThis() : new Variable( NICHTS ) );
-            e->addParameter( "Nächstes Team", nextTeam ? nextTeam->getThis() : new Variable( NICHTS ) );
-            zSpiel->throwEvent( e );
-            if( team )
-                team->release();
-            team = nextTeam;
+            setTeam( nextTeam, zSpiel );
+            nextTeam = 0;
             inChange = 0;
         }
     }