[Orxonox-commit 5689] r10349 - in code/branches/core7/src/orxonox: controllers gametypes

landauf at orxonox.net landauf at orxonox.net
Mon Apr 6 22:18:25 CEST 2015


Author: landauf
Date: 2015-04-06 22:18:25 +0200 (Mon, 06 Apr 2015)
New Revision: 10349

Modified:
   code/branches/core7/src/orxonox/controllers/HumanController.cc
   code/branches/core7/src/orxonox/controllers/HumanController.h
   code/branches/core7/src/orxonox/gametypes/Gametype.cc
   code/branches/core7/src/orxonox/gametypes/Gametype.h
Log:
removed hack. addBots/killBots is now part of Gametype

Modified: code/branches/core7/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/core7/src/orxonox/controllers/HumanController.cc	2015-04-06 20:00:37 UTC (rev 10348)
+++ code/branches/core7/src/orxonox/controllers/HumanController.cc	2015-04-06 20:18:25 UTC (rev 10349)
@@ -58,8 +58,6 @@
     SetConsoleCommand("HumanController", "mouseLook",              &HumanController::mouseLook     ).addShortcut();
     SetConsoleCommand("HumanController", __CC_suicide_name,        &HumanController::suicide       ).addShortcut();
     SetConsoleCommand("HumanController", "toggleGodMode",          &HumanController::toggleGodMode ).addShortcut();
-    SetConsoleCommand("HumanController", "addBots",                &HumanController::addBots       ).addShortcut().defaultValues(1);
-    SetConsoleCommand("HumanController", "killBots",               &HumanController::killBots      ).addShortcut().defaultValues(0);
     SetConsoleCommand("HumanController", "cycleNavigationFocus",   &HumanController::cycleNavigationFocus).addShortcut();
     SetConsoleCommand("HumanController", "releaseNavigationFocus", &HumanController::releaseNavigationFocus).addShortcut();
     SetConsoleCommand("HumanController", "myposition",             &HumanController::myposition    ).addShortcut();
@@ -317,18 +315,6 @@
         }
     }
 
-    void HumanController::addBots(unsigned int amount)
-    {
-        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
-            HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount);
-    }
-
-    void HumanController::killBots(unsigned int amount)
-    {
-        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
-            HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount);
-    }
-
     Pawn* HumanController::getLocalControllerEntityAsPawn()
     {
         if (HumanController::localController_s)

Modified: code/branches/core7/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/core7/src/orxonox/controllers/HumanController.h	2015-04-06 20:00:37 UTC (rev 10348)
+++ code/branches/core7/src/orxonox/controllers/HumanController.h	2015-04-06 20:18:25 UTC (rev 10349)
@@ -82,9 +82,6 @@
             static void toggleFormationFlight();
             static void FFChangeMode();
 
-            static void addBots(unsigned int amount);
-            static void killBots(unsigned int amount = 0);
-
             static void pauseControl(); // tolua_export
             static void resumeControl(); // tolua_export
             virtual void doPauseControl() {};

Modified: code/branches/core7/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/branches/core7/src/orxonox/gametypes/Gametype.cc	2015-04-06 20:00:37 UTC (rev 10348)
+++ code/branches/core7/src/orxonox/gametypes/Gametype.cc	2015-04-06 20:18:25 UTC (rev 10349)
@@ -48,6 +48,12 @@
 
 namespace orxonox
 {
+    static const std::string __CC_addBots_name  = "addBots";
+    static const std::string __CC_killBots_name = "killBots";
+
+    SetConsoleCommand("Gametype", __CC_addBots_name,  &Gametype::addBots ).addShortcut().defaultValues(1);
+    SetConsoleCommand("Gametype", __CC_killBots_name, &Gametype::killBots).addShortcut().defaultValues(0);
+
     RegisterUnloadableClass(Gametype);
 
     Gametype::Gametype(Context* context) : BaseObject(context)
@@ -83,10 +89,8 @@
         else
             this->scoreboard_ = 0;
 
-        /* HACK HACK HACK */
-        this->dedicatedAddBots_ = new ConsoleCommand( "dedicatedAddBots", createExecutor( createFunctor(&Gametype::addBots, this) ) );
-        this->dedicatedKillBots_ = new ConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) );
-        /* HACK HACK HACK */
+        ModifyConsoleCommand(__CC_addBots_name).setObject(this);
+        ModifyConsoleCommand(__CC_killBots_name).setObject(this);
     }
 
     Gametype::~Gametype()
@@ -94,10 +98,9 @@
         if (this->isInitialized())
         {
             this->gtinfo_->destroy();
-            if( this->dedicatedAddBots_ )
-                delete this->dedicatedAddBots_;
-            if( this->dedicatedKillBots_ )
-                delete this->dedicatedKillBots_;
+
+            ModifyConsoleCommand(__CC_addBots_name).setObject(NULL);
+            ModifyConsoleCommand(__CC_killBots_name).setObject(NULL);
         }
     }
 

Modified: code/branches/core7/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/branches/core7/src/orxonox/gametypes/Gametype.h	2015-04-06 20:00:37 UTC (rev 10348)
+++ code/branches/core7/src/orxonox/gametypes/Gametype.h	2015-04-06 20:18:25 UTC (rev 10349)
@@ -198,10 +198,6 @@
             // Config Values
             std::string scoreboardTemplate_;
 
-            /* HACK HACK HACK */
-            ConsoleCommand* dedicatedAddBots_;
-            ConsoleCommand* dedicatedKillBots_;
-            /* HACK HACK HACK */
             Timer showMenuTimer_;
     };
 




More information about the Orxonox-commit mailing list