Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8120 in orxonox.OLD for branches/network


Ignore:
Timestamp:
Jun 2, 2006, 4:19:10 PM (18 years ago)
Author:
rennerc
Message:

spectator movement works now
old Playables will be deleted
teamchoice random works now

Location:
branches/network/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/network_game_manager.cc

    r8097 r8120  
    161161    {
    162162      if ( (*it)->isA(CL_PLAYABLE) )
     163      {
     164        getInstance()->playablesToDelete.push_back( dynamic_cast<Playable*>(*it) );
    163165        return true;
     166      }
    164167       
    165168      delete dynamic_cast<Synchronizeable*>(*it);
     
    238241}
    239242
    240 
    241 
    242 
     243/**
     244 * this function will be called periodically by networkManager
     245 * @param ds time elapsed since last call of tick
     246 */
     247void NetworkGameManager::tick( float ds )
     248{
     249  //delete playables if they are not assigned to local player anymore
     250  for ( std::list<Playable*>::iterator it = playablesToDelete.begin(); it != playablesToDelete.end();  )
     251  {
     252    if ( State::getPlayer()->getPlayable() != *it )
     253    {
     254      PRINTF(0)("Delete unused playable: %s owner: %d\n", (*it)->getClassName(), (*it)->getOwner() );
     255      std::list<Playable*>::iterator delit = it;
     256      it++;
     257      delete *delit;
     258      playablesToDelete.erase( delit );
     259      continue;
     260    }
     261    it++;
     262  }
     263}
     264
     265
     266
     267
  • branches/network/src/lib/network/network_game_manager.h

    r8096 r8120  
    1212/* include base_object.h since all classes are derived from this one */
    1313#include "synchronizeable.h"
     14#include "playable.h"
    1415#include "message_manager.h"
    1516
     
    6162    inline void setGameState( int gameState ){ this->gameState = gameState; }
    6263    inline int getGameState(){ return this->gameState; }
     64   
     65    void tick( float ds );
    6366
    6467  private:
     
    7376   
    7477    int                           gameState;
     78   
     79    std::list<Playable*>          playablesToDelete;
    7580};
    7681
  • branches/network/src/lib/network/network_manager.cc

    r7954 r8120  
    3030#include "preferences.h"
    3131#include "network_log.h"
     32#include "network_game_manager.h"
    3233
    3334
     
    149150        static_cast<NetworkStream*>(*stream)->processData();
    150151  }
     152 
     153  NetworkGameManager::getInstance()->tick( this->elapsedTime );
    151154}
    152155
  • branches/network/src/util/multiplayer_team_deathmatch.cc

    r8096 r8120  
    431431      if ( stats.getPreferedTeamId() == TEAM_RANDOM )
    432432      {
    433         stats.setPreferedTeamId( getTeamForNewUser() );
     433        stats.setPreferedTeamId( getRandomTeam() );
    434434        teamChange( stats.getUserId() );
    435435      }
  • branches/network/src/world_entities/playable.cc

    r8096 r8120  
    7979  // this->setPlayer(NULL);
    8080  // IN ITS DESTRUCTOR.
    81   detachCamera();
     81 
    8282  assert(this->currentPlayer == NULL);
    8383}
     
    283283void  Playable::detachCamera()
    284284{
    285   PRINTF(0)("detach camera\n");
    286   if ( (PNode*)(State::getCameraTarget()) == this )
    287   {
    288     PRINTF(0)("lookAt nullParent\n");
    289    
    290     State::getCameraNode()->setParentSoft(PNode::getNullParent());
    291     State::getCameraTargetNode()->setParentSoft(PNode::getNullParent());
    292    
    293     State::getCamera()->lookAt( PNode::getNullParent() );
    294   }
    295285}
    296286
  • branches/network/src/world_entities/spectator.cc

    r8068 r8120  
    7171{
    7272  this->mouseDir =  rot;
    73   this->rotY = Quaternion( rot.getHeading(), Vector( 0, 1, 0) );
    74   this->rotAxis = Quaternion( rot.getAttitude(), Vector( 0, 0, 1 ) );
     73  this->angleY = rot.getHeading();
     74  this->angleX = rot.getAttitude();
    7575}
    7676
     
    104104    yMouse *= time / 10;
    105105   
    106     this->rotY *= Quaternion(-M_PI/4.0*this->xMouse, Vector(0,1,0));
    107     this->rotAxis *= Quaternion(-M_PI/4.0*this->yMouse, Vector(0,0,1) );
    108 
    109     this->mouseDir = rotY * rotAxis;
    110     //this->mouseDir *= Quaternion(-M_PI/4.0*this->yMouse, Vector(0,0,1));
     106    angleX -= xMouse;
     107    angleY -= yMouse;
     108   
     109    if ( angleY > 2.05 )
     110      angleY = 2.05;
     111   
     112    if ( angleY < -1.15 )
     113      angleY = -1.15;
     114   
     115    this->mouseDir = Quaternion( angleX, Vector( 0, 1, 0 ) ) * Quaternion( angleY, Vector( 0, 0, 1 ) );
     116   
    111117    xMouse = yMouse = 0;
    112118  }
    113119 
    114120  this->setAbsDir( this->mouseDir );
     121 
     122  Vector velocity;
     123 
     124  if ( this->bForward )
     125  {
     126    velocity += this->getAbsDirX();
     127  }
     128 
     129  if ( this->bBackward )
     130  {
     131    velocity -= this->getAbsDirX();
     132  }
     133 
     134  if ( this->bRight )
     135  {
     136    velocity += this->getAbsDirZ();
     137  }
     138 
     139  if ( this->bLeft )
     140  {
     141    velocity -= this->getAbsDirZ();
     142  }
     143 
     144  velocity *= 100;
     145 
     146  this->shiftCoor( velocity*time );
    115147}
    116148
  • branches/network/src/world_entities/spectator.h

    r8068 r8120  
    3535    Quaternion            mouseDir;           //!< the direction where the player wants to fly
    3636
    37     Quaternion            rotY;
    38     Quaternion            rotAxis;
     37    //Quaternion            rotY;
     38    //Quaternion            rotAxis;
     39    float                 angleX;
     40    float                 angleY;
    3941};
    4042
Note: See TracChangeset for help on using the changeset viewer.