[Orxonox-commit 5688] r10348 - in code/branches/core7/src: libraries/core/command modules/towerdefense orxonox/gametypes
landauf at orxonox.net
landauf at orxonox.net
Mon Apr 6 22:00:38 CEST 2015
Author: landauf
Date: 2015-04-06 22:00:37 +0200 (Mon, 06 Apr 2015)
New Revision: 10348
Modified:
code/branches/core7/src/libraries/core/command/CommandExecutor.cc
code/branches/core7/src/libraries/core/command/ConsoleCommand.cc
code/branches/core7/src/libraries/core/command/ConsoleCommand.h
code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h
code/branches/core7/src/modules/towerdefense/TowerDefense.cc
code/branches/core7/src/orxonox/gametypes/Gametype.cc
Log:
removed unnecessary helper functions
Modified: code/branches/core7/src/libraries/core/command/CommandExecutor.cc
===================================================================
--- code/branches/core7/src/libraries/core/command/CommandExecutor.cc 2015-04-06 13:47:42 UTC (rev 10347)
+++ code/branches/core7/src/libraries/core/command/CommandExecutor.cc 2015-04-06 20:00:37 UTC (rev 10348)
@@ -295,9 +295,9 @@
// create a new console command with the given alias as its name
if (tokens.size() == 1)
- createConsoleCommand(tokens[0], executor);
+ new ConsoleCommand(tokens[0], executor);
else if (tokens.size() == 2)
- createConsoleCommand(tokens[0], tokens[1], executor);
+ new ConsoleCommand(tokens[0], tokens[1], executor);
else
orxout(user_error) << "\"" << alias << "\" is not a valid alias name (must have one or two words)." << endl;
}
Modified: code/branches/core7/src/libraries/core/command/ConsoleCommand.cc
===================================================================
--- code/branches/core7/src/libraries/core/command/ConsoleCommand.cc 2015-04-06 13:47:42 UTC (rev 10347)
+++ code/branches/core7/src/libraries/core/command/ConsoleCommand.cc 2015-04-06 20:00:37 UTC (rev 10348)
@@ -43,7 +43,18 @@
namespace orxonox
{
/**
- @brief Constructor: Initializes all values and registers the command.
+ @brief Constructor: Initializes all values and registers the command (without a group).
+ @param name The name of the command
+ @param executor The executor of the command
+ @param bInitialized If true, the executor is used for both, the definition of the function-header AND to executute the command. If false, the command is inactive and needs to be assigned a function before it can be used.
+ */
+ ConsoleCommand::ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized)
+ {
+ this->init("", name, executor, bInitialized);
+ }
+
+ /**
+ @brief Constructor: Initializes all values and registers the command (with a group).
@param group The group of the command
@param name The name of the command
@param executor The executor of the command
@@ -51,6 +62,11 @@
*/
ConsoleCommand::ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized)
{
+ this->init(group, name, executor, bInitialized);
+ }
+
+ void ConsoleCommand::init(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized)
+ {
this->bActive_ = true;
this->bHidden_ = false;
this->accessLevel_ = AccessLevel::All;
Modified: code/branches/core7/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/branches/core7/src/libraries/core/command/ConsoleCommand.h 2015-04-06 13:47:42 UTC (rev 10347)
+++ code/branches/core7/src/libraries/core/command/ConsoleCommand.h 2015-04-06 20:00:37 UTC (rev 10348)
@@ -260,6 +260,7 @@
};
public:
+ ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true);
ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true);
~ConsoleCommand();
@@ -359,6 +360,8 @@
{ return this; }
private:
+ void init(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized);
+
bool headersMatch(const FunctorPtr& functor);
bool headersMatch(const ExecutorPtr& executor);
Modified: code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h
===================================================================
--- code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h 2015-04-06 13:47:42 UTC (rev 10347)
+++ code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h 2015-04-06 20:00:37 UTC (rev 10348)
@@ -263,7 +263,7 @@
/// Internal macro
#define SetConsoleCommandGeneric(group, name, functor) \
- static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor)))
+ static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor)))
/**
@@ -298,31 +298,12 @@
/// Internal macro
#define DeclareConsoleCommandGeneric(group, name, functor) \
- static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false))
+ static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor), false))
namespace orxonox
{
/**
- @brief Creates a new ConsoleCommand.
- @param name The name of the command
- @param executor The executor of the command
- @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first.
- */
- inline ConsoleCommand* createConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
- { return new ConsoleCommand("", name, executor, bInitialized); }
- /**
- @brief Creates a new ConsoleCommand.
- @param group The group of the command
- @param name The name of the command
- @param executor The executor of the command
- @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first.
- */
- inline ConsoleCommand* createConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
- { return new ConsoleCommand(group, name, executor, bInitialized); }
-
-
- /**
@brief Returns a manipulator for a command with the given name.
@note If the command doesn't exist, the manipulator contains a NULL pointer to the command,
Modified: code/branches/core7/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/core7/src/modules/towerdefense/TowerDefense.cc 2015-04-06 13:47:42 UTC (rev 10347)
+++ code/branches/core7/src/modules/towerdefense/TowerDefense.cc 2015-04-06 20:00:37 UTC (rev 10348)
@@ -107,8 +107,8 @@
//this->stats_ = new TowerDefensePlayerStats();
/* Temporary hack to allow the player to add towers and upgrade them */
- this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
- this->dedicatedUpgradeTower_ = createConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) );
+ this->dedicatedAddTower_ = new ConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
+ this->dedicatedUpgradeTower_ = new ConsoleCommand( "upgradeTower", createExecutor( createFunctor(&TowerDefense::upgradeTower, this) ) );
}
TowerDefense::~TowerDefense()
Modified: code/branches/core7/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/branches/core7/src/orxonox/gametypes/Gametype.cc 2015-04-06 13:47:42 UTC (rev 10347)
+++ code/branches/core7/src/orxonox/gametypes/Gametype.cc 2015-04-06 20:00:37 UTC (rev 10348)
@@ -84,8 +84,8 @@
this->scoreboard_ = 0;
/* HACK HACK HACK */
- this->dedicatedAddBots_ = createConsoleCommand( "dedicatedAddBots", createExecutor( createFunctor(&Gametype::addBots, this) ) );
- this->dedicatedKillBots_ = createConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) );
+ this->dedicatedAddBots_ = new ConsoleCommand( "dedicatedAddBots", createExecutor( createFunctor(&Gametype::addBots, this) ) );
+ this->dedicatedKillBots_ = new ConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) );
/* HACK HACK HACK */
}
More information about the Orxonox-commit
mailing list