Forráskód Böngészése

Fehlende funktionen implementiert

Kolja Strohm 4 éve
szülő
commit
38485df45f

+ 5 - 0
StickmanWorldOnline/Bariere.cpp

@@ -130,6 +130,11 @@ int Bariere::getSchaltungAnzahl() const
     return schaltungAnzahl;
 }
 
+int Bariere::getId() const
+{
+    return id;
+}
+
 Team *Bariere::getTeam() const
 {
     if( !team )

+ 1 - 0
StickmanWorldOnline/Bariere.h

@@ -44,6 +44,7 @@ public:
     bool hatStyle( int style ) const;
     int getVerschiebungAnzahl() const;
     int getSchaltungAnzahl() const;
+    int getId() const;
     Team *getTeam() const;
     Team *zTeam() const;
 };

+ 5 - 0
StickmanWorldOnline/Base.cpp

@@ -76,6 +76,11 @@ void Base::tick( double time, Spiel *zSpiel )
     }
 }
 
+int Base::getId() const
+{
+    return id;
+}
+
 Team *Base::getTeam() const
 {
     return team ? (Team*)team->getThis() : 0;

+ 1 - 0
StickmanWorldOnline/Base.h

@@ -21,6 +21,7 @@ public:
     void setTeam( Team *team );
     void startChange( Team *team );
     void tick( double time, Spiel *zSpiel );
+    int getId() const;
     Team *getTeam() const;
     Team *zTeam() const;
 };

+ 7 - 1
StickmanWorldOnline/Drop.cpp

@@ -5,6 +5,7 @@
 Drop::Drop( int id, int minX, int maxX, int minY, int maxY, int maxTime, int numDrops, const char *name, float wkeit[ ITEMANZAHL ] )
     : Variable( DROP )
 {
+    this->id = id;
     this->name = name;
     this->minX = minX;
     this->maxX = maxX;
@@ -102,4 +103,9 @@ int Drop::getMaxY() const
 int Drop::getMaxTime() const
 {
     return maxTime;
-}
+}
+
+int Drop::getId() const
+{
+    return id;
+}

+ 2 - 0
StickmanWorldOnline/Drop.h

@@ -17,6 +17,7 @@ private:
     float nextDrop;
     int numDrops;
     float wahrscheinlichkeit[ ITEMANZAHL ];
+    int id;
 
 public:
     Drop( int id, int minX, int maxX, int minY, int maxY, int maxTime, int numDrops, const char *name, float wkeit[ ITEMANZAHL ] );
@@ -34,4 +35,5 @@ public:
     int getMinY() const;
     int getMaxY() const;
     int getMaxTime() const;
+    int getId() const;
 };

+ 1 - 1
StickmanWorldOnline/Reader.cpp

@@ -792,7 +792,7 @@ void MapReader::ladeKarte( Spiel *zSpiel )
         RCArray< Aktion > * aktionen = new RCArray< Aktion >();
         for( int j = 0; j < aktionAnzahl; j++ )
             aktionen->add( readAktion( mapFile ) );
-        zSpiel->addTrigger( new Trigger( name, ereignisAnzahl, ereignisse, bedingungen, aktionen ) );
+        zSpiel->addTrigger( new Trigger( zSpiel->getNextId(), name, ereignisAnzahl, ereignisse, bedingungen, aktionen ) );
         delete[] name;
     }
     // Variablen

+ 5 - 0
StickmanWorldOnline/Schiene.cpp

@@ -4,4 +4,9 @@ Schiene::Schiene( int id, int x, int y, int width, int height )
     : GameObject( SCHIENE, x, y, width, height )
 {
     this->id = id;
+}
+
+int Schiene::getId() const
+{
+    return id;
 }

+ 1 - 0
StickmanWorldOnline/Schiene.h

@@ -8,4 +8,5 @@ private:
     int id;
 public:
     Schiene( int id, int x, int y, int width, int height );
+    int getId() const;
 };

+ 120 - 0
StickmanWorldOnline/Spiel.cpp

@@ -341,6 +341,11 @@ void Spiel::nachricht( int accountId, int len, char *bytes )
     c.unlock();
 }
 
+void Spiel::setMapSize( int width, int height )
+{
+    mapSize = Punkt( width, height );
+}
+
 void Spiel::setPausiert( bool pausiert )
 {
     this->pause = pausiert;
@@ -708,6 +713,116 @@ Team *Spiel::getTeam( int id ) const
     return 0;
 }
 
+Spieler *Spiel::getSpieler( int id ) const
+{
+    for( auto s = spieler.getIterator(); s; s++ )
+    {
+        if( s->getId() == id )
+            return (Spieler*)s->getThis();
+    }
+    return 0;
+}
+
+Iterator<Spieler *> Spiel::getSpieler() const
+{
+    return spieler.getIterator();
+}
+
+Iterator<Bariere *> Spiel::getBarieren() const
+{
+    return barieren.getIterator();
+}
+
+Bariere *Spiel::getBariere( int id ) const
+{
+    for( auto b = barieren.getIterator(); b; b++ )
+    {
+        if( b->getId() == id )
+            return (Bariere *)b->getThis();
+    }
+    return 0;
+}
+
+Base *Spiel::getBase( int id ) const
+{
+    for( auto b = basen.getIterator(); b; b++ )
+    {
+        if( b->getId() == id )
+            return (Base *)b->getThis();
+    }
+    return 0;
+}
+
+Drop *Spiel::getDrop( int id ) const
+{
+    for( auto d = drops.getIterator(); d; d++ )
+    {
+        if( d->getId() == id )
+            return (Drop *)d->getThis();
+    }
+    return 0;
+}
+
+Schalter *Spiel::getSchalter( int id ) const
+{
+    for( auto s = schalter.getIterator(); s; s++ )
+    {
+        if( s->getId() == id )
+            return (Schalter *)s->getThis();
+    }
+    return 0;
+}
+
+Schiene *Spiel::getSchiene( int id ) const
+{
+    for( auto s = schienen.getIterator(); s; s++ )
+    {
+        if( s->getId() == id )
+            return (Schiene *)s->getThis();
+    }
+    return 0;
+}
+
+Timer *Spiel::getTimer( int id ) const
+{
+    for( auto t = timer.getIterator(); t; t++ )
+    {
+        if( t->getId() == id )
+            return (Timer *)t->getThis();
+    }
+    return 0;
+}
+
+Tunnel *Spiel::getTunnel( int id ) const
+{
+    for( auto t = tunnel.getIterator(); t; t++ )
+    {
+        if( t->getId() == id )
+            return (Tunnel *)t->getThis();
+    }
+    return 0;
+}
+
+Umlenkung *Spiel::getUmlenkung( int id ) const
+{
+    for( auto u = umlenkungen.getIterator(); u; u++ )
+    {
+        if( u->getId() == id )
+            return (Umlenkung *)u->getThis();
+    }
+    return 0;
+}
+
+Trigger *Spiel::getTrigger( int id ) const
+{
+    for( auto t = trigger.getIterator(); t; t++ )
+    {
+        if( t->getId() == id )
+            return (Trigger *)t->getThis();
+    }
+    return 0;
+}
+
 Variable *Spiel::getVariable( const char *name ) const
 {
     for( auto v = variablen.getIterator(); v; v++ )
@@ -772,6 +887,11 @@ int Spiel::getNextId()
     return ++nextId;
 }
 
+double Spiel::getRand()
+{
+    return randG.rand();
+}
+
 StatistikV *Spiel::getStatistik() const
 {
     return stat->getThis();

+ 0 - 1
StickmanWorldOnline/Spiel.h

@@ -76,7 +76,6 @@ public:
     void klientOffline( int accountId ) override;
     void klientOnline( int accountId, SSKlientV *zKlient ) override;
     void nachricht( int accountId, int len, char *bytes ) override;
-
     void setMapSize( int width, int height );
     void setPausiert( bool pausiert );
     void tick( double zeit );

+ 6 - 1
StickmanWorldOnline/Spieler.cpp

@@ -659,4 +659,9 @@ Richtung Spieler::getAusrichtung() const
 float Spieler::getAbklingZeitVerringerung() const
 {
     return abklingZeitVerringerung;
-}
+}
+
+int Spieler::getId() const
+{
+    return spielerNummer;
+}

+ 1 - 0
StickmanWorldOnline/Spieler.h

@@ -120,4 +120,5 @@ public:
     bool istGegenstandErlaubt( GegenstandTyp typ ) const;
     Richtung getAusrichtung() const;
     float getAbklingZeitVerringerung() const;
+    int getId() const;
 };

+ 6 - 1
StickmanWorldOnline/Timer.cpp

@@ -102,4 +102,9 @@ int Timer::getMaxTime() const
 bool Timer::istAutoWiederhohlung() const
 {
     return autoWiederhohlung;
-}
+}
+
+int Timer::getId() const
+{
+    return id;
+}

+ 1 - 0
StickmanWorldOnline/Timer.h

@@ -33,4 +33,5 @@ public:
     bool istPausiert() const;
     int getMaxTime() const;
     bool istAutoWiederhohlung() const;
+    int getId() const;
 };

+ 2 - 2
StickmanWorldOnline/Trigger.h

@@ -46,7 +46,6 @@ public:
 class Trigger : public Variable
 {
 private:
-    static int nextId;
     int id;
     Text name;
     int ereignisAnzahl;
@@ -55,7 +54,7 @@ private:
     RCArray< Aktion > *aktionen;
 
 public:
-    Trigger( const char *name, int ereignisAnzahl, EreignisTyp *ereignisse, RCArray< Bedingung > *bedingungen, RCArray< Aktion > *aktionen );
+    Trigger( int id, const char *name, int ereignisAnzahl, EreignisTyp *ereignisse, RCArray< Bedingung > *bedingungen, RCArray< Aktion > *aktionen );
     ~Trigger();
     bool hatEreignis( EreignisTyp typ ) const;
     int getAktionAnzahl() const;
@@ -65,6 +64,7 @@ public:
     bool wirdGetriggertVon( EreignisTyp typ ) const;
     // return: 0, falls die bedingungen nicht erfüllt sind
     TriggerRun *runTrigger( Ereignis *e, Spiel *zSpiel );
+    int getId() const;
 };
 
 class TriggerRun

+ 6 - 1
StickmanWorldOnline/Tunnel.cpp

@@ -49,4 +49,9 @@ bool Tunnel::istAktiv() const
 int Tunnel::getBenutzungen() const
 {
     return benutzt;
-}
+}
+
+int Tunnel::getId() const
+{
+    return id;
+}

+ 1 - 0
StickmanWorldOnline/Tunnel.h

@@ -21,4 +21,5 @@ public:
     int getZielY() const;
     bool istAktiv() const;
     int getBenutzungen() const;
+    int getId() const;
 };

+ 6 - 1
StickmanWorldOnline/Umlenkung.cpp

@@ -92,4 +92,9 @@ int Umlenkung::getMaxAbklingzeit() const
 Richtung Umlenkung::getRichtung() const
 {
     return richtung;
-}
+}
+
+int Umlenkung::getId() const
+{
+    return id;
+}

+ 1 - 0
StickmanWorldOnline/Umlenkung.h

@@ -26,4 +26,5 @@ public:
     bool istDrehend() const;
     int getMaxAbklingzeit() const;
     Richtung getRichtung() const;
+    int getId() const;
 };