Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 26, 2010, 2:27:14 AM (14 years ago)
Author:
landauf
Message:

added access level checking

Location:
code/branches/consolecommands3/src/libraries/core/command
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc

    r7221 r7222  
    3131#include "util/Convert.h"
    3232#include "core/Language.h"
    33 #include "core/BaseObject.h" // remove this
     33#include "core/GameMode.h"
    3434
    3535namespace orxonox
    3636{
    37     _SetConsoleCommand("BaseObject", "setName", &BaseObject::setName, (BaseObject*)0);
    38     _ConsoleCommand::_ConsoleCommandManipulator test(_ModifyConsoleCommand("BaseObject", "setName").setFunction(&BaseObject::setActive));
    39 
    4037    _ConsoleCommand::_ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized)
    4138    {
     
    9491    {
    9592        return (this->bActive_ && this->executor_ && this->executor_->getFunctor() && (this->executor_->getFunctor()->getType() == Functor::Type::Static || this->executor_->getFunctor()->getRawObjectPointer()));
     93    }
     94
     95    bool _ConsoleCommand::hasAccess() const
     96    {
     97        switch (this->accessLevel_)
     98        {
     99            case AccessLevel::All:        return true;
     100            case AccessLevel::Standalone: return GameMode::isStandalone();
     101            case AccessLevel::Master:     return GameMode::isMaster();
     102            case AccessLevel::Server:     return GameMode::hasServer();
     103            case AccessLevel::Client:     return GameMode::isClient();
     104            case AccessLevel::Online:     return (GameMode::hasServer() || GameMode::isClient());
     105            case AccessLevel::Offline:    return GameMode::isStandalone();
     106            case AccessLevel::None:       return false;
     107            default:                      return false;
     108        }
    96109    }
    97110
  • code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h

    r7221 r7222  
    242242            bool isActive() const;
    243243            bool hasAccess() const;
    244             bool isHidden() const;
     244            inline bool isHidden() const
     245                { return this->bHidden_; }
    245246
    246247            _ConsoleCommand& description(const std::string& description);
Note: See TracChangeset for help on using the changeset viewer.