[Orxonox-commit 2515] r7222 - code/branches/consolecommands3/src/libraries/core/command
landauf at orxonox.net
landauf at orxonox.net
Thu Aug 26 02:27:14 CEST 2010
Author: landauf
Date: 2010-08-26 02:27:14 +0200 (Thu, 26 Aug 2010)
New Revision: 7222
Modified:
code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc
code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h
Log:
added access level checking
Modified: code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc 2010-08-26 00:06:16 UTC (rev 7221)
+++ code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc 2010-08-26 00:27:14 UTC (rev 7222)
@@ -30,13 +30,10 @@
#include "util/Convert.h"
#include "core/Language.h"
-#include "core/BaseObject.h" // remove this
+#include "core/GameMode.h"
namespace orxonox
{
- _SetConsoleCommand("BaseObject", "setName", &BaseObject::setName, (BaseObject*)0);
- _ConsoleCommand::_ConsoleCommandManipulator test(_ModifyConsoleCommand("BaseObject", "setName").setFunction(&BaseObject::setActive));
-
_ConsoleCommand::_ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized)
{
this->bActive_ = true;
@@ -95,6 +92,22 @@
return (this->bActive_ && this->executor_ && this->executor_->getFunctor() && (this->executor_->getFunctor()->getType() == Functor::Type::Static || this->executor_->getFunctor()->getRawObjectPointer()));
}
+ bool _ConsoleCommand::hasAccess() const
+ {
+ switch (this->accessLevel_)
+ {
+ case AccessLevel::All: return true;
+ case AccessLevel::Standalone: return GameMode::isStandalone();
+ case AccessLevel::Master: return GameMode::isMaster();
+ case AccessLevel::Server: return GameMode::hasServer();
+ case AccessLevel::Client: return GameMode::isClient();
+ case AccessLevel::Online: return (GameMode::hasServer() || GameMode::isClient());
+ case AccessLevel::Offline: return GameMode::isStandalone();
+ case AccessLevel::None: return false;
+ default: return false;
+ }
+ }
+
bool _ConsoleCommand::headersMatch(const FunctorPtr& functor)
{
unsigned int minparams = std::min(this->baseExecutor_->getParamCount(), functor->getParamCount());
Modified: code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h 2010-08-26 00:06:16 UTC (rev 7221)
+++ code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h 2010-08-26 00:27:14 UTC (rev 7222)
@@ -241,7 +241,8 @@
bool isActive() const;
bool hasAccess() const;
- bool isHidden() const;
+ inline bool isHidden() const
+ { return this->bHidden_; }
_ConsoleCommand& description(const std::string& description);
const std::string& getDescription() const;
More information about the Orxonox-commit
mailing list