Browse Source

Fehler beim ändern des Teams von Basen behoben

Kolja Strohm 4 years ago
parent
commit
0a92e13613
1 changed files with 7 additions and 8 deletions
  1. 7 8
      StickmanWorldOnline/Base.cpp

+ 7 - 8
StickmanWorldOnline/Base.cpp

@@ -28,6 +28,10 @@ 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;
@@ -35,6 +39,7 @@ void Base::setTeam( Team *team, Spiel *zSpiel )
         textur->release();
     textur = resources->zResource( R_BASE, team ? team->getFarbe() : 0 )->getImages()->getThis();
     zSpiel->setLastTeamChangedBase( (Base *)getThis() );
+    zSpiel->throwEvent( e );
 }
 
 void Base::startChange( Team *team )
@@ -72,14 +77,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;
         }
     }