Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 31, 2010, 3:37:40 AM (14 years ago)
Author:
landauf
Message:

merged consolecommands3 branch back to trunk.

note: the console command interface has changed completely, but the documentation is not yet up to date. just copy an existing command and change it to your needs, it's pretty self-explanatory. also the include files related to console commands are now located in core/command/. in the game it should work exactly like before, except for some changes in the auto-completion.

Location:
code/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/Client.cc

    r7163 r7284  
    4545#include "util/Clock.h"
    4646#include "util/Debug.h"
     47#include "util/ScopedSingletonManager.h"
    4748#include "synchronisable/Synchronisable.h"
    4849#include "packet/Chat.h"
     
    5253#include "core/CommandLineParser.h"
    5354#include "core/Game.h"
    54 #include "core/ScopedSingletonManager.h"
    5555
    5656namespace orxonox
     
    107107    return ClientConnection::closeConnection();
    108108  }
    109  
     109
    110110  void Client::setDestination(const std::string& serverAddress, unsigned int port)
    111111  {
  • code/trunk/src/libraries/network/ClientConnection.cc

    r6417 r7284  
    149149  uint32_t ClientConnection::getRTT()
    150150  {
    151     assert(server_);
    152     return server_->roundTripTime;
     151    if (server_)
     152        return server_->roundTripTime;
     153    else
     154        return 0;
    153155  }
    154156
  • code/trunk/src/libraries/network/GamestateManager.cc

    r7163 r7284  
    4747
    4848#include "util/Debug.h"
    49 #include "core/Executor.h"
    5049#include "core/ThreadPool.h"
     50#include "core/command/Executor.h"
    5151#include "ClientInformation.h"
    5252#include "packet/Acknowledgement.h"
  • code/trunk/src/libraries/network/Host.cc

    r7163 r7284  
    3232#include <string>
    3333
    34 #include "core/ConsoleCommand.h"
    3534#include "core/ObjectList.h"
     35#include "core/command/ConsoleCommand.h"
    3636#include "ChatListener.h"
    3737
    3838namespace orxonox {
    3939
    40   SetConsoleCommandShortcut(Host, Chat);
     40  static const std::string __CC_printRTT_name = "printRTT";
     41
     42  SetConsoleCommand("chat", &Host::Chat);
     43  SetConsoleCommand(__CC_printRTT_name, &Host::printRTT);
    4144
    4245  // Host*               Host::instance_=0;
     
    5255  //   assert(instance_==0);
    5356    instances_s.push_back(this);
    54     this->printRTTCC_ = createConsoleCommand( createFunctor(&Host::printRTT, this), "printRTT" );
    55     CommandExecutor::addConsoleCommandShortcut( this->printRTTCC_ );
     57    ModifyConsoleCommand(__CC_printRTT_name).setObject(this);
    5658    this->bIsActive_ = false;
    5759  }
     
    6567    assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() );
    6668    instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this ));
    67     if( this->printRTTCC_ )
    68       delete this->printRTTCC_;
     69    ModifyConsoleCommand(__CC_printRTT_name).setObject(0);
    6970  }
    7071
     
    8990  }
    9091
    91   bool Host::Chat(const std::string& message)
     92  void Host::Chat(const std::string& message)
    9293  {
    9394    if(instances_s.size()==0)
     
    9596      for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
    9697        it->incomingChat(message, 0);
    97       return true;
     98//      return true;
    9899    }
    99100    else
     
    108109        }
    109110      }
    110       return result;
     111//      return result;
    111112    }
    112113  }
     
    139140    for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
    140141      it->incomingChat(message, playerID);
    141    
     142
    142143    bool result = true;
    143144    for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
  • code/trunk/src/libraries/network/Host.h

    r7163 r7284  
    7979    static void setShipID(unsigned int id){ shipID_s = id; }
    8080    static bool isServer();
    81     static bool Chat(const std::string& message);
     81    static void Chat(const std::string& message);
    8282    static bool Broadcast(const std::string& message);
    8383    static bool incomingChat(const std::string& message, unsigned int playerID);
     
    8585    bool isActive(){ return bIsActive_; }
    8686  private:
    87     ConsoleCommand* printRTTCC_;
    8887    static uint32_t clientID_s;
    8988    static uint32_t shipID_s;
  • code/trunk/src/libraries/network/LANDiscovery.cc

    r7163 r7284  
    3232#include <cstring>
    3333
     34#include "util/ScopedSingletonManager.h"
    3435#include "core/CoreIncludes.h"
    35 #include "core/ScopedSingletonManager.h"
    3636
    3737
    3838namespace orxonox
    39 { 
     39{
    4040  ManageScopedSingleton(LANDiscovery, ScopeID::Root, true);
    41  
     41
    4242  LANDiscovery::LANDiscovery()
    4343  {
     
    4949    enet_host_destroy(this->host_);
    5050  }
    51  
     51
    5252  void LANDiscovery::discover()
    5353  {
     
    5656    enet_address_set_host(&address, "255.255.255.255");
    5757    address.port = LAN_DISCOVERY_PORT;
    58    
     58
    5959    ENetPeer* peer;
    6060    peer = enet_host_connect(this->host_, &address, 0);
    61    
     61
    6262    ENetEvent event;
    6363    while( enet_host_service(this->host_, &event, 1000 ) )
     
    9393    }
    9494  }
    95  
     95
    9696  std::string LANDiscovery::getServerListItemName(unsigned int index)
    9797  {
     
    101101      return this->servers_[index].getServerName();
    102102  }
    103  
     103
    104104  std::string LANDiscovery::getServerListItemIP(unsigned int index)
    105105  {
     
    109109      return this->servers_[index].getServerIP();
    110110  }
    111  
    112  
     111
     112
    113113} // namespace orxonox
  • code/trunk/src/libraries/network/NetworkFunction.cc

    r6417 r7284  
    6868
    6969
    70   NetworkFunctionStatic::NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p):
     70  NetworkFunctionStatic::NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p):
    7171    NetworkFunctionBase(name)
    7272  {
     
    7676    NetworkFunctionStatic::getFunctorMap()[p] = this;
    7777    NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this;
    78   }
    79 
    80   NetworkFunctionStatic::~NetworkFunctionStatic()
    81   {
    82     delete this->functor_;
    8378  }
    8479
  • code/trunk/src/libraries/network/NetworkFunction.h

    r6417 r7284  
    3939#include <boost/static_assert.hpp>
    4040
    41 #include "core/Functor.h"
    4241#include "core/Identifier.h"
     42#include "core/command/Functor.h"
    4343#include "FunctionCallManager.h"
    4444#include "synchronisable/Synchronisable.h"
     
    102102class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
    103103  public:
    104     NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p);
    105     ~NetworkFunctionStatic();
     104    NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p);
    106105
    107106    inline void call(){ (*this->functor_)(); }
     
    124123    static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap();
    125124    static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap();
    126     FunctorStatic* functor_;
     125    FunctorStaticPtr functor_;
    127126
    128127};
     
    155154template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase {
    156155  public:
    157     NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p);
    158     ~NetworkMemberFunction();
     156    NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p);
    159157
    160158    inline void call(uint32_t objectID)
     
    190188
    191189  private:
    192     FunctorMember<T>* functor_;
    193 };
    194 
    195 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p):
     190    FunctorMemberPtr<T> functor_;
     191};
     192
     193template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p):
    196194    NetworkMemberFunctionBase(name, p), functor_(functor)
    197195{
    198 }
    199 template <class T> NetworkMemberFunction<T>::~NetworkMemberFunction()
    200 {
    201   delete this->functor_;
    202196}
    203197
  • code/trunk/src/libraries/network/Server.cc

    r7163 r7284  
    4949#include "util/Debug.h"
    5050#include "core/ObjectList.h"
    51 #include "core/Executor.h"
     51#include "core/command/Executor.h"
    5252#include "packet/Chat.h"
    5353#include "packet/ClassID.h"
  • code/trunk/src/libraries/network/synchronisable/Serialise.h

    r7266 r7284  
    4242#include "core/CorePrereqs.h"
    4343#include "core/CoreIncludes.h"
    44 #include "core/SmartPtr.h"
     44#include "core/BaseObject.h" // remove this if circular dependencies in BaseObject/SmartPtr are fixed
     45//#include "core/SmartPtr.h"
    4546
    4647namespace orxonox{
    47    
     48
    4849    // These functions implement loading / saving / etc. for pointer types
    49    
     50
    5051    /** @brief returns the size of the objectID needed to synchronise the pointer */
    5152    template <class T> inline uint32_t returnSize( T*& variable )
     
    5354      return sizeof(uint32_t);
    5455    }
    55    
     56
    5657    /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
    5758    template <class T> inline void loadAndIncrease( T*& variable, uint8_t*& mem )
     
    6061        mem += returnSize( variable );
    6162    }
    62    
     63
    6364    /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
    6465    template <class T> inline void saveAndIncrease( T*& variable, uint8_t*& mem )
     
    7071        mem += returnSize( variable );
    7172    }
    72    
     73
    7374    /** @brief checks whether the objectID of the variable is the same as in the bytestream */
    7475    template <class T> inline  bool checkEquality( T*& variable, uint8_t* mem )
     
    7980            return variable == variable->getSynchronisable(*(uint32_t*)(mem));
    8081    }
    81    
     82
    8283    // These functions implement loading / saving / etc. for SmartPtr<T>
    83    
     84
    8485    /** @brief returns the size of the objectID needed to synchronise the pointer */
    8586    template <class T> inline uint32_t returnSize( const SmartPtr<T>& variable )
     
    8788        return sizeof(uint32_t);
    8889    }
    89    
     90
    9091    /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
    9192    template <class T> inline void loadAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
     
    9596        mem += returnSize( variable );
    9697    }
    97    
     98
    9899    /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
    99100    template <class T> inline void saveAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
     
    105106        mem += returnSize( variable );
    106107    }
    107    
     108
    108109    /** @brief checks whether the objectID of the variable is the same as in the bytestream */
    109110    template <class T> inline  bool checkEquality( const SmartPtr<T>& variable, uint8_t* mem )
     
    114115            return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
    115116    }
    116    
     117
    117118    // These functions implement loading / saving / etc. for WeakPtr<T>
    118    
     119
    119120    /** @brief returns the size of the objectID needed to synchronise the pointer */
    120121    template <class T> inline uint32_t returnSize( const WeakPtr<T>& variable )
     
    122123        return sizeof(uint32_t);
    123124    }
    124    
     125
    125126    /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
    126127    template <class T> inline void loadAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem )
     
    130131        mem += returnSize( variable );
    131132    }
    132    
     133
    133134    /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
    134135    template <class T> inline void saveAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem )
     
    140141        mem += returnSize( variable );
    141142    }
    142    
     143
    143144    /** @brief checks whether the objectID of the variable is the same as in the bytestream */
    144145    template <class T> inline  bool checkEquality( const WeakPtr<T>& variable, uint8_t* mem )
Note: See TracChangeset for help on using the changeset viewer.