Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 22, 2008, 4:25:54 PM (17 years ago)
Author:
scheusso
Message:

and here come the other files

Location:
code/branches/network2
Files:
4 deleted
15 edited
16 copied

Legend:

Unmodified
Added
Removed
  • code/branches/network2/CMakeLists.txt

    r1103 r1132  
    3232
    3333#set binary output directories
    34 SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
    35 SET(LIBRARY_OUTPUT_PATH    ${PROJECT_BINARY_DIR}/bin/lib)
     34SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
     35SET(LIBRARY_OUTPUT_PATH    ${PROJECT_SOURCE_DIR}/bin/lib)
    3636
    3737# global compiler/linker flags. force -O2!
     
    4343SET(CMAKE_MODULE_LINKER_FLAGS " --no-undefined")
    4444
    45 #Create verbose makefile output when compiling
    46 SET(CMAKE_VERBOSE_MAKEFILE TRUE)
     45#use 'cmake -D make_verb:1 path' to get verbose make output when compiling
     46IF (MAKE_VERB)
     47 SET(CMAKE_VERBOSE_MAKEFILE TRUE)
     48ENDIF (MAKE_VERB)
    4749
    4850
     
    7981  ${ENet_INCLUDE_DIR}
    8082  ${Boost_INCLUDE_DIRS}
    81   ${OPENAL_INCLUDE_DIR} ${ALUT_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR} ${OGG_INCLUDE_DIR}
     83  ${OPENAL_INCLUDE_DIR}
     84  ${ALUT_INCLUDE_DIR}
     85  ${VORBIS_INCLUDE_DIR}
     86  ${OGG_INCLUDE_DIR}
    8287  ${Lua_INCLUDE_DIR}
    8388)
    84 
    85 
    86 ################ Source files ###################
    87 
    88 #At first, build lua
    89 MESSAGE(STATUS "\n******************* Building tolua... ******************\n\n")
    90 EXECUTE_PROCESS(COMMAND ./tolua-build)
    91 MESSAGE(STATUS "\n\n******************* Building tolua done ****************\n")
    92 
    93 #generate lua bind source files
    94 EXECUTE_PROCESS(COMMAND bin/./tolua-exec-script)
    9589
    9690#add main source dir
  • code/branches/network2/cmake/FindLua.cmake

    r1076 r1132  
    1 # Find Lua includes and library
     1#  Find Lua header and library files
    22#
    3 # This module defines
    4 #  Lua_INCLUDE_DIR
    5 #  Lua_LIBRARIES, the libraries to link against to use Lua.
    6 #  Lua_LIB_DIR, the location of the libraries
    7 #  Lua_FOUND, If false, do not try to use Lua
     3#  When called, this script tries to define:
     4#  Lua_INCLUDE_DIR    Header files directory
     5#  Lua_LIBRARIES      library files (or file when using lua 5.1)
     6#  Lua_FOUND          defined (true) if lua was found
     7#  Lua_VERSION        either 5.1 or 5.0 or undefined
    88#
    9 # Copyright © 2007, Matt Williams
    10 #
    11 # Redistribution and use is allowed according to the terms of the BSD license.
     9#  authors: Benjamin Knecht, Reto Grieder
    1210
    13 MESSAGE(STATUS "lua libs in cache: ${Lua_LIBRARIES}")
    1411IF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
    15     SET(Lua_FIND_QUIETLY TRUE) # Already in cache, be silent
     12
     13  # Already in cache, be silent
     14  SET(Lua_FOUND TRUE)
     15  SET(Lua_FIND_QUIETLY TRUE)
     16  MESSAGE(STATUS "Lua was found.")
     17
     18ELSE (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
     19
     20  FIND_PATH(Lua_INCLUDE_DIR_51 lua.h
     21    /usr/include/lua5.1
     22    /usr/local/include/lua5.1
     23    ../libs/lua-5.1.3/src)
     24
     25  FIND_PATH(Lua_INCLUDE_DIR_50 lua.h
     26    /usr/include/lua50
     27    /usr/local/include/lua50
     28    /usr/pack/lua-5.0.3-sd/include)
     29
     30  FIND_LIBRARY(Lua_LIBRARY_51 NAMES lua5.1 lua PATHS
     31    /usr/lib
     32    /usr/local/lib
     33    ../libs/lua-5.1.3/lib)
     34
     35  FIND_LIBRARY(Lua_LIBRARY_1_50 NAMES lua50 lua PATHS
     36        /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
     37    /usr/lib
     38    /usr/local/lib)
     39
     40  FIND_LIBRARY(Lua_LIBRARY_2_50 NAMES lualib50 lualib PATHS
     41        /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
     42    /usr/lib
     43    /usr/local/lib)
     44
     45
     46  IF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
     47
     48    # Found newer lua 5.1 libs
     49    SET(Lua_FOUND TRUE)
     50    SET(Lua_VERSION 5.1 CACHE STRING "")
     51    SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_51} CACHE PATH "")
     52    SET(Lua_LIBRARIES ${Lua_LIBRARY_51} CACHE FILEPATH "")
     53
     54  ELSEIF(Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
     55
     56    # Found older lua 5.0 libs
     57    SET(Lua_FOUND TRUE)
     58    SET(Lua_VERSION 5.0 CACHE STRING "")
     59    SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_50} CACHE PATH "")
     60    SET(Lua_LIBRARIES ${Lua_LIBRARY_1_50} ${Lua_LIBRARY_2_50} CACHE FILEPATH "")
     61
     62  ENDIF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
     63       
     64
     65  IF (Lua_FOUND)
     66    MESSAGE(STATUS "Found Lua: ${Lua_LIBRARIES}")
     67  ELSE (Lua_FOUND)
     68    IF (Lua_FIND_REQUIRED)
     69      MESSAGE(FATAL_ERROR "Could not find Lua")
     70    ENDIF (Lua_FIND_REQUIRED)
     71  ENDIF (Lua_FOUND)
     72
    1673ENDIF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
    1774
    18 FIND_PATH(Lua_INCLUDE_DIR lua.h
    19         /usr/include/lua5.1
    20         /usr/local/include/lua5.1
    21         ../libs/lua-5.1.3/src)
    22 
    23 FIND_LIBRARY(Lua_LIBRARIES lua5.1
    24         /usr/lib
    25         /usr/local/lib
    26         ../libs/lua-5.1.3/lib)
    27 
    28 IF (NOT Lua_INCLUDE_DIR)
    29  FIND_PATH(Lua_INCLUDE_DIR lua.h
    30         /usr/include/lua50
    31         /usr/local/include/lua50
    32         /usr/pack/lua-5.0.3-sd/include)
    33 ENDIF (NOT Lua_INCLUDE_DIR)
    34 
    35 IF (NOT Lua_LIBRARIES)
    36  FIND_LIBRARY(Lua_LIBRARIES lua50
    37         /usr/lib
    38         /usr/local/lib)
    39 
    40  FIND_LIBRARY(Lua_LIBRARY lualib50
    41         /usr/lib
    42         /usr/local/lib)
    43 
    44 #SET(Lua_LIBRARIES ${Lua_LIBRARIES} ${Lua_LIBRARY})
    45 ENDIF (NOT Lua_LIBRARIES)
    46 
    47 #especially for tardis
    48 IF (NOT Lua_LIBRARIES)
    49  FIND_LIBRARY(Lua_LIBRARIES lua
    50         /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib)
    51 
    52  FIND_LIBRARY(Lua_LIBRARY lualib
    53         /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib)
    54 
    55 #SET(Lua_LIBRARIES ${Lua_LIBRARIES} ${Lua_LIBRARY})
    56 ENDIF (NOT Lua_LIBRARIES)
    57 
    58 IF (Lua_INCLUDE_DIR AND Lua_LIBRARIES)
    59     SET(Lua_FOUND TRUE)
    60 ENDIF (Lua_INCLUDE_DIR AND Lua_LIBRARIES)
    61 
    62 IF (Lua_FOUND)
    63     MESSAGE(STATUS "Found Lua: ${Lua_LIBRARIES}")
    64     MESSAGE(STATUS "Found Lua: ${Lua_LIBRARY}")
    65 ELSE (Lua_FOUND)
    66     IF (Lua_FIND_REQUIRED)
    67         MESSAGE(FATAL_ERROR "Could not find Lua")
    68     ENDIF (Lua_FIND_REQUIRED)
    69 ENDIF (Lua_FOUND)
  • code/branches/network2/src/CMakeLists.txt

    r1076 r1132  
    11INCLUDE_DIRECTORIES(.)
    22INCLUDE_DIRECTORIES(orxonox)
    3 INCLUDE_DIRECTORIES(util/tolua)
     3INCLUDE_DIRECTORIES(tolua)
    44
     5ADD_SUBDIRECTORY(tolua)
    56ADD_SUBDIRECTORY(util)
    67ADD_SUBDIRECTORY(core)
  • code/branches/network2/src/core/CMakeLists.txt

    r1084 r1132  
    1 #get the created files
    2 AUX_SOURCE_DIRECTORY(tolua TOLUA_BIND_FILES)
    3 
    4 SET( CORE_SRC_FILES
     1SET(CORE_SRC_FILES
    52  OrxonoxClass.cc
    63  BaseObject.cc
     
    2926  Tickable.cc
    3027  Script.cc
    31   ${TOLUA_BIND_FILES}
    3228)
    3329
    34 ADD_LIBRARY( core SHARED ${CORE_SRC_FILES})
     30ADD_LIBRARY(core SHARED ${CORE_SRC_FILES})
    3531
    36 TARGET_LINK_LIBRARIES( core
     32TARGET_LINK_LIBRARIES(core
    3733  util
     34  tolualib
    3835  ${Lua_LIBRARIES}
    39   ${Lua_LIBRARY}
    4036  ${OIS_LIBRARIES}
    4137)
  • code/branches/network2/src/core/ConfigFileManager.h

    r1064 r1132  
    6363    {
    6464        public:
     65            virtual ~ConfigFileEntry() {};
    6566            virtual void setValue(const std::string& value) = 0;
    6667            virtual std::string getValue() const = 0;
  • code/branches/network2/src/core/Loader.cc

    r1085 r1132  
    115115        Script::init(Script::getLuaState());
    116116        Script::run();*/
    117         //Script* lua = Script::getInstance();
    118         //lua->loadFile(level->getFile(), true);
    119         //lua->run();
     117        Script* lua = Script::getInstance();
     118        lua->loadFile(level->getFile(), true);
     119        lua->run();
    120120
    121121        try
     
    124124            COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
    125125
    126             ticpp::Document xmlfile(level->getFile());
    127             xmlfile.LoadFile();
     126            //ticpp::Document xmlfile(level->getFile());
     127            //xmlfile.LoadFile();
    128128            //ticpp::Element myelement(*Script::getFileString());
    129             //ticpp::Document xmlfile;
    130             xmlfile.ToDocument();
    131             //xmlfile.Parse(lua->getLuaOutput(), true);
     129            ticpp::Document xmlfile;
     130            //xmlfile.ToDocument();
     131            xmlfile.Parse(lua->getLuaOutput(), true);
    132132
    133133            ticpp::Element rootElement;
  • code/branches/network2/src/core/Script.cc

    r1076 r1132  
    3939}
    4040
    41 #include "tolua++.h"
     41#include "tolua/tolua++.h"
    4242#include "tolua/tolua_bind.h"
    4343
     
    102102  }
    103103
     104#if LUA_VERSION_NUM != 501
     105  const char * Script::lua_Chunkreader(lua_State *L, void *data, size_t *size)
     106  {
     107    LoadS* ls = ((LoadS*)data);
     108    if (ls->size == 0) return NULL;
     109    *size = ls->size;
     110    ls->size = 0;
     111    return ls->s;
     112  }
     113#endif
    104114  void Script::run()
    105115  {
     
    110120    error = luaL_loadstring(luaState_, init.c_str());
    111121#else
    112     error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, (void*)init.c_str(), "init");
     122    LoadS ls;
     123    ls.s = init.c_str();
     124    ls.size = init.size();
     125    error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, &ls, init.c_str());
    113126#endif
    114127    if (error == 0)
  • code/branches/network2/src/core/Script.h

    r1056 r1132  
    5050  class _CoreExport Script // tolua_export
    5151  { // tolua_export
     52    struct LoadS {
     53      const char *s;
     54      size_t size;
     55    };
     56
    5257    public:
    5358      inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } // tolua_export
     
    6166
    6267#if LUA_VERSION_NUM != 501
    63     inline static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size) { return NULL;};
     68    static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size);
    6469#endif
    6570
  • code/branches/network2/src/orxonox/GraphicsEngine.cc

    r1090 r1132  
    100100      Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this);
    101101      Ogre::LogManager::getSingleton().destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
    102       delete Ogre::LogManager::getSingletonPtr();
     102      Ogre::LogManager::getSingletonPtr()->~LogManager();
    103103    }
    104104    COUT(4) << "*** GraphicsEngine: Destroying objects done" << std::endl;
  • code/branches/network2/src/orxonox/Orxonox.cc

    r1105 r1132  
    11/*
    22 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
    34 *
    45 *
     
    2728
    2829/**
    29  @file  Orxonox.cc
     30 @file
    3031 @brief Orxonox Main Class
    3132 */
     
    3334// Precompiled Headers
    3435#include "OrxonoxStableHeaders.h"
     36#include "Orxonox.h"
     37
     38//****** STD *******
     39//#include <iostream>
     40//#include <exception>
     41#include <deque>
    3542
    3643//****** OGRE ******
     
    3946#include <OgreOverlay.h>
    4047#include <OgreOverlayManager.h>
     48#include <OgreRoot.h>
    4149#include <OgreTimer.h>
    4250#include <OgreWindowEventUtilities.h>
    4351
    44 //****** STD *******
    45 //#include <iostream>
    46 //#include <exception>
    47 #include <deque>
    48 
    4952//***** ORXONOX ****
    50 //misc
     53// util
    5154//#include "util/Sleep.h"
    52 
    53 // audio
    54 #include "audio/AudioManager.h"
    55 
    56 // network
    57 #include "network/Server.h"
    58 #include "network/Client.h"
    59 network::Client *client_g;
    60 network::Server *server_g;
    61 
    62 // objects
    63 #include "core/ArgReader.h"
     55#include "util/ArgReader.h"
     56#include "util/ExprParser.h"
     57
     58// core
     59#include "core/ConfigFileManager.h"
     60#include "core/ConsoleCommand.h"
    6461#include "core/Debug.h"
    6562#include "core/Factory.h"
    6663#include "core/Loader.h"
    6764#include "core/Tickable.h"
     65#include "core/InputBuffer.h"
     66#include "core/InputManager.h"
     67
     68// audio
     69#include "audio/AudioManager.h"
     70
     71// network
     72#include "network/Server.h"
     73#include "network/Client.h"
     74
     75// objects and tools
     76#include "tools/Timer.h"
    6877#include "hud/HUD.h"
    69 #include "tools/Timer.h"
    70 #include "objects/weapon/BulletManager.h"
    71 
    72 #include "InputHandler.h"
    73 
    74 #include "Orxonox.h"
     78
     79// FIXME: is this really file scope?
     80// globals for the server or client
     81network::Client *client_g;
     82network::Server *server_g;
    7583
    7684namespace orxonox
    7785{
     86  ConsoleCommand(Orxonox, exit, AccessLevel::None, true);
     87  ConsoleCommand(Orxonox, slomo, AccessLevel::Offline, true).setDefaultValue(0, 1.0);
     88  ConsoleCommand(Orxonox, setTimeFactor, AccessLevel::Offline, false).setDefaultValue(0, 1.0);
     89
     90  class Testconsole : public InputBufferListener
     91  {
     92    public:
     93      Testconsole(InputBuffer* ib) : ib_(ib) {}
     94      void listen() const
     95      {
     96        std::cout << "> " << this->ib_->get() << std::endl;
     97      }
     98      void execute() const
     99      {
     100        std::cout << ">> " << this->ib_->get() << std::endl;
     101        if (!CommandExecutor::execute(this->ib_->get()))
     102          std::cout << "Error" << std::endl;
     103        this->ib_->clear();
     104      }
     105      void hintandcomplete() const
     106      {
     107        std::cout << CommandExecutor::hint(this->ib_->get()) << std::endl;
     108        this->ib_->set(CommandExecutor::complete(this->ib_->get()));
     109      }
     110      void clear() const
     111      {
     112        this->ib_->clear();
     113      }
     114      void removeLast() const
     115      {
     116        this->ib_->removeLast();
     117      }
     118      void exit() const
     119      {
     120        CommandExecutor::execute("setInputMode 2");
     121      }
     122
     123    private:
     124      InputBuffer* ib_;
     125  };
     126
     127  class Calculator
     128  {
     129  public:
     130    static void calculate(const std::string& calculation)
     131    {
     132      ExprParser expr(calculation);
     133      if (expr.getSuccess())
     134      {
     135        if (expr.getResult() == 42.0)
     136          std::cout << "Greetings from the restaurant at the end of the universe." << std::endl;
     137        // FIXME: insert modifier to display in full precision
     138        std::cout << "Result is: " << expr.getResult() << std::endl;
     139        if (expr.getRemains() != "")
     140          std::cout << "Warning: Expression could not be parsed to the end! Remains: '"
     141              << expr.getRemains() << "'" << std::endl;
     142      }
     143      else
     144        std::cout << "Cannot calculate expression: Parse error" << std::endl;
     145    }
     146  };
     147  ConsoleCommandShortcut(Calculator, calculate, AccessLevel::None);
     148
    78149  /**
    79150    @brief Reference to the only instance of the class.
     
    86157  Orxonox::Orxonox()
    87158  {
    88     this->ogre_ = new GraphicsEngine();
     159    this->ogre_ = &GraphicsEngine::getSingleton();
    89160    this->timer_ = 0;
    90161    this->dataPath_ = "";
    91162    this->auMan_ = 0;
    92163    this->inputHandler_ = 0;
    93     //this->root_ = 0;
    94164    // turn on frame smoothing by setting a value different from 0
    95165    this->frameSmoothingTime_ = 0.0f;
    96166    this->bAbort_ = false;
     167    this->timefactor_ = 1.0f;
    97168  }
    98169
     
    103174  {
    104175    // keep in mind: the order of deletion is very important!
    105     if (this->bulletMgr_)
    106       delete this->bulletMgr_;
    107176    if (this->orxonoxHUD_)
    108177      delete this->orxonoxHUD_;
    109178    Loader::close();
    110     InputHandler::destroy();
     179    InputManager::getSingleton().destroy();
    111180    if (this->auMan_)
    112181      delete this->auMan_;
    113182    if (this->timer_)
    114183      delete this->timer_;
    115     if (this->ogre_)
    116       delete this->ogre_;
     184    GraphicsEngine::getSingleton().destroy();
    117185
    118186    if (client_g)
     
    123191
    124192  /**
    125    * error kills orxonox
    126    */
    127   void Orxonox::abortImmediate(/* some error code */)
    128   {
    129     //TODO: destroy and destruct everything and print nice error msg
     193    @brief Immediately deletes the orxonox object.
     194    Never use if you can help it while rendering!
     195  */
     196  void Orxonox::abortImmediateForce()
     197  {
     198    COUT(1) << "*** Orxonox Error: Orxonox object was unexpectedly destroyed." << std::endl;
    130199    delete this;
    131200  }
     
    136205  void Orxonox::abortRequest()
    137206  {
     207    COUT(3) << "*** Orxonox: Abort requested." << std::endl;
    138208    bAbort_ = true;
    139209  }
     
    147217      singletonRef_s = new Orxonox();
    148218    return singletonRef_s;
    149     //static Orxonox theOnlyInstance;
    150     //return &theOnlyInstance;
    151219  }
    152220
     
    154222    @brief Destroys the Orxonox singleton.
    155223  */
    156   void Orxonox::destroy()
     224  void Orxonox::destroySingleton()
    157225  {
    158226    if (singletonRef_s)
     
    174242    std::string mode;
    175243
    176     ArgReader ar = ArgReader(argc, argv);
     244    ArgReader ar(argc, argv);
    177245    ar.checkArgument("mode", mode, false);
    178246    ar.checkArgument("data", this->dataPath_, false);
    179247    ar.checkArgument("ip", serverIp_, false);
    180     if(ar.errorHandling()) abortImmediate();
     248    if(ar.errorHandling()) abortImmediateForce();
    181249    if(mode == std::string("client"))
    182250    {
     
    197265  {
    198266    COUT(2) << "initialising server" << std::endl;
    199    
     267
    200268    ogre_->setConfigPath(path);
    201269    ogre_->setup();
    202270    //root_ = ogre_->getRoot();
    203     if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
    204    
     271    if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
     272
    205273    server_g = new network::Server();
    206274  }
     
    209277  {
    210278    COUT(2) << "initialising client" << std::endl;\
    211    
     279
    212280    ogre_->setConfigPath(path);
    213281    ogre_->setup();
     
    216284    else
    217285      client_g = new network::Client(serverIp_, NETWORK_PORT);
    218     if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
    219   }
    220  
     286    if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
     287  }
     288
    221289  void Orxonox::standaloneInit(std::string path)
    222290  {
    223291    COUT(2) << "initialising standalone mode" << std::endl;
    224    
     292
    225293    ogre_->setConfigPath(path);
    226294    ogre_->setup();
    227     //root_ = ogre_->getRoot();
    228     if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
    229   }
    230  
     295    if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
     296  }
     297
    231298  /**
    232299   * start modules
     
    245312    }
    246313  }
    247  
     314
    248315  void Orxonox::clientStart(){
    249316    ogre_->initialise();
     317    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
    250318    Factory::createClassHierarchy();
    251    
    252    
     319
     320
    253321    auMan_ = new audio::AudioManager();
    254322
    255     bulletMgr_ = new BulletManager();
    256    
    257323    Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
    258     orxonoxHUD_ = new HUD();
    259     orxonoxHUD_->setEnergyValue(20);
    260     orxonoxHUD_->setEnergyDistr(20,20,60);
     324    HUD* orxonoxHud;
     325    orxonoxHud = new HUD();
     326    orxonoxHud->setEnergyValue(20);
     327    orxonoxHud->setEnergyDistr(20,20,60);
    261328    hudOverlay->show();
    262    
    263     if( !client_g->establishConnection() )
    264       COUT(1) <<"CLIENT COULD NOT ESTABLISH CONNECTION" << std::endl;
     329
     330    client_g->establishConnection();
    265331    client_g->tick(0);
    266    
    267    
     332
     333
    268334    //setupInputSystem();
    269    
     335
    270336    startRenderLoop();
    271337  }
    272  
     338
    273339  void Orxonox::serverStart(){
    274340    //TODO: start modules
    275341    ogre_->initialise();
    276342    //TODO: run engine
     343    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
    277344    Factory::createClassHierarchy();
    278345    createScene();
    279346    setupInputSystem();
    280    
     347
    281348    server_g->open();
    282349
    283350    startRenderLoop();
    284351  }
    285  
     352
    286353  void Orxonox::standaloneStart(){
    287354    //TODO: start modules
    288355    ogre_->initialise();
    289356    //TODO: run engine
     357    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
    290358    Factory::createClassHierarchy();
    291359    createScene();
    292360    setupInputSystem();
    293    
     361
    294362    startRenderLoop();
    295363  }
     
    299367          // Init audio
    300368    auMan_ = new audio::AudioManager();
    301 
    302     bulletMgr_ = new BulletManager();
    303369
    304370    // load this file from config
     
    327393  void Orxonox::setupInputSystem()
    328394  {
    329     inputHandler_ = InputHandler::getSingleton();
     395    inputHandler_ = &InputManager::getSingleton();
    330396    if (!inputHandler_->initialise(ogre_->getWindowHandle(),
    331397          ogre_->getWindowWidth(), ogre_->getWindowHeight()))
    332       abortImmediate();
     398      abortImmediateForce();
     399    inputHandler_->setInputMode(IM_INGAME);
    333400  }
    334401
     
    343410    About the loop: The design is almost exactly like the one in ogre, so that
    344411    if any part of ogre registers a framelisteners, it will still behave
    345     correctly. Furthermore I have taken over the time smoothing feature from
    346     ogre. If turned on (see orxonox constructor), it will calculate the dt_n by
    347     means of the recent most dt_n-1, dt_n-2, etc.
     412    correctly. Furthermore the time smoothing feature from ogre has been
     413    implemented too. If turned on (see orxonox constructor), it will calculate
     414    the dt_n by means of the recent most dt_n-1, dt_n-2, etc.
    348415  */
    349416  void Orxonox::startRenderLoop()
    350417  {
     418    InputBuffer* ib = new InputBuffer();
     419    InputManager::getSingleton().feedInputBuffer(ib);
     420    Testconsole* console = new Testconsole(ib);
     421    ib->registerListener(console, &Testconsole::listen, true);
     422    ib->registerListener(console, &Testconsole::execute, '\r', false);
     423    ib->registerListener(console, &Testconsole::execute, '\n', false);
     424    ib->registerListener(console, &Testconsole::hintandcomplete, '\t', true);
     425    ib->registerListener(console, &Testconsole::clear, '§', true);
     426    ib->registerListener(console, &Testconsole::removeLast, '\b', true);
     427    ib->registerListener(console, &Testconsole::exit, (char)0x1B, true);
     428
     429    // first check whether ogre root object has been created
     430    if (Ogre::Root::getSingletonPtr() == 0)
     431    {
     432      COUT(2) << "*** Orxonox Error: Could not start rendering. No Ogre root object found" << std::endl;
     433      return;
     434    }
     435    Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
     436
     437
     438    // Contains the times of recently fired events
     439    // eventTimes[4] is the list for the times required for the fps counter
     440    std::deque<unsigned long> eventTimes[4];
     441    // Clear event times
     442    for (int i = 0; i < 4; ++i)
     443      eventTimes[i].clear();
     444    // fill the fps time list with zeros
     445    for (int i = 0; i < 20; i++)
     446      eventTimes[3].push_back(0);
     447
    351448    // use the ogre timer class to measure time.
    352449    if (!timer_)
     
    354451    timer_->reset();
    355452
    356     // Contains the times of recently fired events
    357     std::deque<unsigned long> eventTimes[3];
    358     // Clear event times
    359     for (int i = 0; i < 3; ++i)
    360       eventTimes[i].clear();
    361 
    362453          while (!bAbort_)
    363454          {
    364455                  // Pump messages in all registered RenderWindows
     456      // This calls the WindowEventListener objects.
    365457      Ogre::WindowEventUtilities::messagePump();
    366458
    367459      // get current time
    368460      unsigned long now = timer_->getMilliseconds();
     461      eventTimes[3].push_back(now);
     462      eventTimes[3].erase(eventTimes[3].begin());
    369463
    370464      // create an event to pass to the frameStarted method in ogre
     
    374468
    375469      // show the current time in the HUD
    376       //orxonoxHUD_->setTime((int)now, 0);
     470      orxonoxHUD_->setTime((int)now, 0);
     471      if (eventTimes[3].back() - eventTimes[3].front() != 0)
     472        orxonoxHUD_->setRocket1((int)(20000.0f/(eventTimes[3].back() - eventTimes[3].front())));
    377473
    378474      // Iterate through all Tickables and call their tick(dt) function
    379       for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; )
    380         (it++)->tick((float)evt.timeSinceLastFrame);
     475      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
     476        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    381477
    382478      // don't forget to call _fireFrameStarted in ogre to make sure
    383479      // everything goes smoothly
    384       ogre_->frameStarted(evt);
    385 
     480      ogreRoot._fireFrameStarted(evt);
     481
     482      // server still renders at the moment
    386483      //if (mode_ != SERVER)
    387         ogre_->renderOneFrame(); // only render in non-server mode
     484      ogreRoot._updateAllRenderTargets(); // only render in non-server mode
    388485
    389486      // get current time
     
    395492
    396493      // again, just to be sure ogre works fine
    397       ogre_->frameEnded(evt);
     494      ogreRoot._fireFrameEnded(evt);
    398495          }
    399496  }
     
    408505  {
    409506    // Calculate the average time passed between events of the given type
    410     // during the last mFrameSmoothingTime seconds.
     507    // during the last frameSmoothingTime_ seconds.
    411508
    412509    times.push_back(now);
     
    415512      return 0;
    416513
    417     // Times up to mFrameSmoothingTime seconds old should be kept
    418     unsigned long discardThreshold =
    419       static_cast<unsigned long>(frameSmoothingTime_ * 1000.0f);
     514    // Times up to frameSmoothingTime_ seconds old should be kept
     515    unsigned long discardThreshold = (unsigned long)(frameSmoothingTime_ * 1000.0f);
    420516
    421517    // Find the oldest time to keep
    422     std::deque<unsigned long>::iterator it = times.begin(),
    423       end = times.end()-2; // We need at least two times
     518    std::deque<unsigned long>::iterator it  = times.begin();
     519    // We need at least two times
     520    std::deque<unsigned long>::iterator end = times.end() - 2;
     521
    424522    while(it != end)
    425523    {
     
    433531    times.erase(times.begin(), it);
    434532
    435     return (float)(times.back() - times.front()) / ((times.size()-1) * 1000);
     533    return (float)(times.back() - times.front()) / ((times.size() - 1) * 1000);
    436534  }
    437535
  • code/branches/network2/src/util/CMakeLists.txt

    r1085 r1132  
    11AUX_SOURCE_DIRECTORY(tinyxml TINYXML_SRC_FILES)
    22
    3 SET (UTIL_SRC_FILES
     3SET(UTIL_SRC_FILES
    44  ArgReader.cc
    55  Math.cc
     
    77  Clipboard.cc
    88  SubString.cc
     9  ExprParser.cc
    910  MultiTypePrimitive.cc
    1011  MultiTypeString.cc
    1112  MultiTypeMath.cc
    12   tolua/tolua_event.c
    13   tolua/tolua_is.c
    14   tolua/tolua_map.c
    15   tolua/tolua_push.c
    16   tolua/tolua_to.c
    1713  ${TINYXML_SRC_FILES}
    1814)
    1915
    20 ADD_LIBRARY( util SHARED ${UTIL_SRC_FILES} )
     16ADD_LIBRARY(util SHARED ${UTIL_SRC_FILES})
    2117
    2218IF(TESTING_ENABLED)
     
    2420ENDIF(TESTING_ENABLED)
    2521
    26 TARGET_LINK_LIBRARIES( util
     22TARGET_LINK_LIBRARIES(util
    2723  ${OGRE_LIBRARIES}
    28   ${Lua_LIBRARIES}
    29   ${Lua_LIBRARY}
    3024)
    3125
  • code/branches/network2/src/util/String.cc

    r1064 r1132  
    274274    if (str.size() == 0)
    275275        return str;
     276    else if (str.size() == 1)
     277    {
     278      //TODO: decide whether we need the commented code
     279      /*if (str[0] != '\\')
     280        return "";
     281      else*/
     282      return str;
     283    }
    276284
    277285    std::string output = "";
  • code/branches/network2/visual_studio/vc8/core.vcproj

    r1084 r1132  
    252252                                >
    253253                        </File>
    254                         <Filter
    255                                 Name="tolua"
    256                                 >
    257                                 <File
    258                                         RelativePath="..\..\src\core\tolua\tolua_bind.cc"
    259                                         >
    260                                         <FileConfiguration
    261                                                 Name="Debug|Win32"
    262                                                 >
    263                                                 <Tool
    264                                                         Name="VCCLCompilerTool"
    265                                                 />
    266                                         </FileConfiguration>
    267                                 </File>
    268                         </Filter>
    269254                </Filter>
    270255                <Filter
     
    425410                                >
    426411                        </File>
    427                         <Filter
    428                                 Name="tolua"
    429                                 >
    430                                 <File
    431                                         RelativePath="..\..\src\core\tolua\tolua_bind.h"
    432                                         >
    433                                 </File>
    434                         </Filter>
    435412                </Filter>
    436413        </Files>
  • code/branches/network2/visual_studio/vc8/tolua++.vcproj

    r1089 r1132  
    131131                        >
    132132                        <File
    133                                 RelativePath="..\..\src\util\tolua\tolua_event.c"
     133                                RelativePath="..\..\src\tolua\tolua_bind.cc"
    134134                                >
    135135                        </File>
    136136                        <File
    137                                 RelativePath="..\..\src\util\tolua\tolua_is.c"
     137                                RelativePath="..\..\src\tolua\tolua_event.c"
    138138                                >
    139139                        </File>
    140140                        <File
    141                                 RelativePath="..\..\src\util\tolua\tolua_map.c"
     141                                RelativePath="..\..\src\tolua\tolua_is.c"
    142142                                >
    143143                        </File>
    144144                        <File
    145                                 RelativePath="..\..\src\util\tolua\tolua_push.c"
     145                                RelativePath="..\..\src\tolua\tolua_map.c"
    146146                                >
    147147                        </File>
    148148                        <File
    149                                 RelativePath="..\..\src\util\tolua\tolua_to.c"
     149                                RelativePath="..\..\src\tolua\tolua_push.c"
     150                                >
     151                        </File>
     152                        <File
     153                                RelativePath="..\..\src\tolua\tolua_to.c"
    150154                                >
    151155                        </File>
     
    157161                        >
    158162                        <File
    159                                 RelativePath="..\..\src\util\tolua\tolua++.h"
     163                                RelativePath="..\..\src\tolua\tolua++.h"
    160164                                >
    161165                        </File>
    162166                        <File
    163                                 RelativePath="..\..\src\util\tolua\tolua_event.h"
     167                                RelativePath="..\..\src\tolua\tolua_bind.h"
     168                                >
     169                        </File>
     170                        <File
     171                                RelativePath="..\..\src\tolua\tolua_event.h"
    164172                                >
    165173                        </File>
  • code/branches/network2/visual_studio/vc8/util.vcproj

    r1064 r1132  
    157157                        </File>
    158158                        <File
     159                                RelativePath="..\..\src\util\ExprParser.cc"
     160                                >
     161                        </File>
     162                        <File
    159163                                RelativePath="..\..\src\util\Math.cc"
    160164                                >
     
    199203                        </File>
    200204                        <File
     205                                RelativePath="..\..\src\util\ExprParser.h"
     206                                >
     207                        </File>
     208                        <File
    201209                                RelativePath="..\..\src\util\Math.h"
    202210                                >
Note: See TracChangeset for help on using the changeset viewer.