Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 888 for code/branches/network


Ignore:
Timestamp:
Mar 13, 2008, 3:25:10 PM (17 years ago)
Author:
scheusso
Message:

sdfsdf

Location:
code/branches/network
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/bin/levels/sample.oxw

    r887 r888  
    11<!--
    2  <audio>sdfasdfasd
     2 <audio>
    33                <ambient>
    44                        <ogg src="allgorythm-lift_up" />
     
    1515
    1616<!--Fighter camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assf3.mesh"  forward="500" rotateupdown="200" rotaterightleft="200" looprightleft="200" /-->
    17 <SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assf5.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />
     17<SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assf3.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />
    1818
    1919<NPC position="0,100,400" scale="1" mesh="razor.mesh"/>
     
    2323<NPC position="100,0,400" scale="1" mesh="razor.mesh"/>
    2424
    25 <Model name="starship" position="200,0,500" scale="10" mesh="starship.mesh" yawpitchroll="-90,-90,0" />
    26 <Model name="drone" position="-200,0,500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0">
     25<!--Model name="starship" position="200,0,500" scale="10" mesh="starship.mesh" yawpitchroll="-90,-90,0" /-->
     26<!--Model name="drone" position="-200,0,500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0">
    2727  <attached>
    2828    <Model name="drone2" position="200,-100,-500" scale="10" mesh="drone.mesh" yawpitchroll="-90,-90,0">
     
    3232    </Model>
    3333  </attached>
    34 </Model>
     34</Model -->
    3535
    3636<Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yawpitchroll="-90,-90,0" />
  • code/branches/network/src/network/Client.h

    r790 r888  
    1616#include <string>
    1717
     18#include "orxonox/objects/Tickable.h"
     19
    1820#include "NetworkPrereqs.h"
    1921#include "ClientConnection.h"
     
    2123#include "GameStateClient.h"
    2224//#include "NetworkFrameListener.h"
     25
    2326
    2427
     
    3235  *
    3336  */
    34   class _NetworkExport Client : PacketDecoder{
     37  class _NetworkExport Client : PacketDecoder, public orxonox::Tickable{
    3538  public:
    3639    Client();
  • code/branches/network/src/network/ConnectionManager.cc

    r790 r888  
    281281  }
    282282
     283 
     284 
     285  void ConnectionManager::addClientsObjectID( int clientID, int objectID ) {
     286    COUT(4) << "ship of client: " << clientID << ": " << objectID << " mapped" << std::endl;
     287    clientsShip.insert( std::make_pair( clientID, objectID ) );
     288  }
     289
     290  int ConnectionManager::getClientsShipID( int clientID ) {
     291    return clientsShip[clientID];
     292  }
     293
     294  int ConnectionManager::getObjectsClientID( int objectID ) {
     295    std::map<int, int>::iterator iter = clientsShip.begin();
     296    while( iter != clientsShip.end() ) {
     297      if( iter->second == objectID ) return iter->first;
     298    }
     299    return -99;
     300  }
     301
     302  void ConnectionManager::deleteClientIDReg( int clientID ) {
     303    clientsShip.erase( clientID );
     304  }
     305
     306  void ConnectionManager::deleteObjectIDReg( int objectID ) {
     307    std::map<int, int>::iterator iter = clientsShip.begin();
     308    while( iter != clientsShip.end() ) {
     309      if( iter->second == objectID ) break;
     310    }
     311    clientsShip.erase( iter->first );
     312  }
     313 
    283314}
  • code/branches/network/src/network/ConnectionManager.h

    r790 r888  
    1414
    1515#include <string>
     16#include <map>
    1617// enet library for networking support
    1718#include <enet/enet.h>
     
    7374    bool quit; // quit-variable (communication with threads)
    7475    ClientInformation *head_;
     76   
     77    //functions to map what object every clients uses
     78    std::map<int, int> clientsShip;
     79    void addClientsObjectID( int clientID, int objectID );
     80    int getClientsShipID( int clientID );
     81    int getObjectsClientID( int objectID );
     82    void deleteClientIDReg( int clientID );
     83    void deleteObjectIDReg( int objectID );
    7584  };
    7685
  • code/branches/network/src/network/Server.h

    r790 r888  
    1616#include <string>
    1717
     18#include "orxonox/objects/Tickable.h"
     19
    1820#include "PacketManager.h"
    1921#include "NetworkPrereqs.h"
     22
     23
    2024
    2125namespace network
     
    2529  * It implements all functions necessary for a Server
    2630  */
    27   class _NetworkExport Server : public PacketDecoder{
     31  class _NetworkExport Server : public PacketDecoder, public orxonox::Tickable{
    2832  public:
    2933    Server();
  • code/branches/network/src/orxonox/Orxonox.cc

    r871 r888  
    6363#include "network/Server.h"
    6464#include "network/Client.h"
    65 #include "network/NetworkFrameListener.h"
     65#include "network/NetworkPrereqs.h"
     66network::Client *client_g;
     67network::Server *server_g;
     68
    6669
    6770// objects
     
    97100        updateAI();
    98101
    99         if(mode_ == PRESENTATION)
    100           server_g->tick(evt.timeSinceLastFrame);
    101         else if(mode_ == CLIENT)
    102           client_g->tick(evt.timeSinceLastFrame);
     102//         if(mode_ == SERVER)
     103//           server_g->tick(evt.timeSinceLastFrame);
     104//         else if(mode_ == CLIENT)
     105//           client_g->tick(evt.timeSinceLastFrame);
    103106
    104107        usleep(10);
     
    162165    //TODO: give config file to Ogre
    163166    std::string mode;
    164 //     if(argc>=2)
    165 //       mode = std::string(argv[1]);
    166 //     else
    167 //       mode = "";
     167   
     168   
    168169    ArgReader ar = ArgReader(argc, argv);
    169170    ar.checkArgument("mode", mode, false);
    170171    ar.checkArgument("data", this->dataPath_, false);
    171172    ar.checkArgument("ip", serverIp_, false);
    172     //mode = "presentation";
    173173    if(ar.errorHandling()) die();
    174     if(mode == std::string("server"))
     174    if(mode == std::string("client"))
    175175    {
     176      mode_ = CLIENT;
     177      clientInit(path);
     178    }
     179    else if(mode== std::string("server")){
     180      mode_ = SERVER;
    176181      serverInit(path);
    177       mode_ = SERVER;
    178     }
    179     else if(mode == std::string("client"))
    180     {
    181       clientInit(path);
    182       mode_ = CLIENT;
    183     }
    184     else if(mode == std::string("presentation"))
    185     {
    186       serverInit(path);
    187       mode_ = PRESENTATION;
    188182    }
    189183    else{
     184      mode_ = STANDALONE;
    190185      standaloneInit(path);
    191       mode_ = STANDALONE;
    192     }
    193   }
    194 
     186    }
     187  }
     188
     189 
    195190  /**
    196191   * start modules
     
    198193  void Orxonox::start()
    199194  {
     195    switch(mode_){
     196    case CLIENT:
     197      clientStart();
     198      break;
     199    case SERVER:
     200      serverStart();
     201      break;
     202    default:
     203      standaloneStart();
     204    }
     205  }
     206 
     207  void Orxonox::clientStart(){
     208   
     209   
     210  }
     211 
     212  void Orxonox::serverStart(){
    200213    //TODO: start modules
    201214    ogre_->startRender();
     
    205218    setupScene();
    206219    setupInputSystem();
    207     if(mode_!=CLIENT){ // remove this in future ---- presentation hack
    208     }
    209     else
    210       std::cout << "client here" << std::endl;
     220   
    211221    createFrameListener();
    212     switch(mode_){
    213     case PRESENTATION:
    214       //ogre_->getRoot()->addFrameListener(new network::ServerFrameListener());
    215       //std::cout << "could not add framelistener" << std::endl;
    216       server_g->open();
    217       break;
    218     case CLIENT:
    219       client_g->establishConnection();
    220       break;
    221     case SERVER:
    222     case STANDALONE:
    223     default:
    224       break;
    225     }
     222    server_g->open();
     223   
     224    startRenderLoop();
     225  }
     226 
     227  void Orxonox::standaloneStart(){
     228    //TODO: start modules
     229    ogre_->startRender();
     230    //TODO: run engine
     231    Factory::createClassHierarchy();
     232    createScene();
     233    setupScene();
     234    setupInputSystem();
     235   
     236    createFrameListener();
     237   
    226238    startRenderLoop();
    227239  }
     
    246258  }
    247259
    248   void Orxonox::standaloneInit(std::string path)
    249   {
     260
     261  void Orxonox::serverInit(std::string path)
     262  {
     263    COUT(2) << "initialising server" << std::endl;
     264   
    250265    ogre_->setConfigPath(path);
    251266    ogre_->setup();
    252267    root_ = ogre_->getRoot();
    253268    if(!ogre_->load()) die(/* unable to load */);
    254 
    255     //defineResources();
    256     //setupRenderSystem();
    257     //createRenderWindow();
    258     //initializeResourceGroups();
    259     /*createScene();
    260     setupScene();
    261     setupInputSystem();
    262     createFrameListener();
    263     Factory::createClassHierarchy();
    264     startRenderLoop();*/
    265   }
    266 
    267   void Orxonox::playableServer(std::string path)
    268   {
    269     ogre_->setConfigPath(path);
    270     ogre_->setup();
    271     root_ = ogre_->getRoot();
    272     defineResources();
    273     setupRenderSystem();
    274     createRenderWindow();
    275     initializeResourceGroups();
    276     setupInputSystem();
    277     Factory::createClassHierarchy();
    278     createScene();
    279     setupScene();
    280     createFrameListener();
    281     try{
    282       server_g = new network::Server(); //!< add port and bindadress
    283       server_g->open(); //!< open server and create listener thread
    284       if(ogre_ && ogre_->getRoot())
    285         ogre_->getRoot()->addFrameListener(new network::ServerFrameListener()); // adds a framelistener for the server
    286       COUT(3) << "Info: network framelistener added" << std::endl;
    287     }
    288     catch(...)
    289     {
    290       COUT(1) << "Error: There was a problem initialising the server :(" << std::endl;
    291     }
    292     startRenderLoop();
    293   }
    294 
    295   void Orxonox::standalone(){
    296 
    297 
    298 
    299   }
    300 
    301   void Orxonox::serverInit(std::string path)
    302   {
    303     COUT(2) << "initialising server" << std::endl;
    304     ogre_->setConfigPath(path);
    305     ogre_->setup();
    306     server_g = new network::Server(); // FIXME add some settings if wanted
    307     if(!ogre_->load()) die(/* unable to load */);
    308     // FIXME add network framelistener
     269   
     270    server_g = new network::Server();
    309271  }
    310272
    311273  void Orxonox::clientInit(std::string path)
    312274  {
    313     COUT(2) << "initialising client" << std::endl;
     275    COUT(2) << "initialising client" << std::endl;\
     276   
    314277    ogre_->setConfigPath(path);
    315278    ogre_->setup();
     
    317280      client_g = new network::Client();
    318281    else
    319       client_g = new network::Client(serverIp_, 55556);
     282      client_g = new network::Client(serverIp_, NETWORK_PORT);
    320283    if(!ogre_->load()) die(/* unable to load */);
    321     ogre_->getRoot()->addFrameListener(new network::ClientFrameListener());
     284  }
     285 
     286  void Orxonox::standaloneInit(std::string path)
     287  {
     288    COUT(2) << "initialising standalone mode" << std::endl;
     289   
     290    ogre_->setConfigPath(path);
     291    ogre_->setup();
     292    root_ = ogre_->getRoot();
     293    if(!ogre_->load()) die(/* unable to load */);
    322294  }
    323295
  • code/branches/network/src/orxonox/Orxonox.h

    r871 r888  
    2525
    2626  enum gameMode{
    27     STANDALONE,
    2827    SERVER,
    2928    CLIENT,
    30     PRESENTATION
     29    STANDALONE
    3130  };
    3231
     
    5453      void standaloneInit(std::string path);
    5554      // run functions
    56       void playableServer(std::string path);
    57       void standalone();
     55      void serverStart();
     56      void clientStart();
     57      void standaloneStart();
    5858      void defineResources();
    5959      void setupRenderSystem();
  • code/branches/network/src/orxonox/objects/SpaceShip.cc

    r871 r888  
    196196        SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down).");
    197197        SetConfigValue(reloadTime_, 0.125).description("The reload time of the weapon in seconds");
    198         SetConfigValue(testvector_, Vector3()).description("asdfblah");
     198        //SetConfigValue(testvector_, Vector3()).description("asdfblah");
    199199    }
    200200
Note: See TracChangeset for help on using the changeset viewer.