Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 20, 2005, 2:51:37 PM (18 years ago)
Author:
rennerc
Message:

synchronizeable: added sender parameter to writeBytes
network_stream: creates now a network_game_manager
network_game_manager: implemented some functions

File:
1 edited

Legend:

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

    r6139 r6190  
    2727#include "synchronizeable.h"
    2828#include "network_manager.h"
     29#include "network_game_manager.h"
    2930#include "list.h"
    3031#include "debug.h"
     
    7778  this->handshakes.push_back( NULL );
    7879  this->bActive = true;
     80  this->networkGameManager = new NetworkGameManager();
     81  // setUniqueID( maxCon+2 ) because we need one id for every handshake
     82  // and one for handshake to reject client maxCon+1
     83  this->networkGameManager->setUniqueID( this->maxConnections+2 );
     84  this->connectSynchronizeable( *(this->networkGameManager) );
    7985
    8086  this->setMaxConnections( 10 );
     
    8894  this->bActive = false;
    8995  this->serverSocket = NULL;
     96  this->networkGameManager = NULL;
    9097  myHostId = 0;
    9198}
     
    175182          }
    176183          PRINT(0)("handshake finished\n");
     184
     185          this->networkGameManager = new NetworkGameManager();
     186          this->networkGameManager->setUniqueID( handshakes[i]->getNetworkGameManagerId() );
     187          this->connectSynchronizeable( *(this->networkGameManager) );
     188
    177189          delete handshakes[i];
    178190          handshakes[i] = NULL;
    179           //TODO: replace handshake by entitymanager
    180191        }
    181192        else
     
    199210  for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++)
    200211  {
    201     //TODO: remove items from synchronizeables if they dont exist
    202212    if ( (*it)!=NULL && (*it)->getOwner() == myHostId )
    203213    {
     
    214224        dataLength = networkProtocol->createHeader((byte*)downBuffer, dataLength, DATA_STREAM_BUFFER_SIZE, static_cast<const Synchronizeable&>(*(*it)));
    215225
    216         //FIXME: this is a hack, find a better way
    217226        Header* header = (Header*)downBuffer;
    218         if ( header->synchronizeableID<100 )
     227        if ( header->synchronizeableID < this->maxConnections )
    219228          header->synchronizeableID = 0;
    220229
     
    284293        {
    285294          if ( *it && (*it)->getUniqueID()==header.synchronizeableID )
    286             (*it)->writeBytes(upBuffer+sizeof(header), dataLength);
     295            (*it)->writeBytes(upBuffer+sizeof(header), dataLength, i);
    287296        }
    288297
     
    306315      freeSocketSlots.pop_back();
    307316      networkSockets[clientId] = tempNetworkSocket;
    308       handshakes[clientId] = new Handshake(true, clientId);
     317      handshakes[clientId] = new Handshake(true, clientId, this->networkGameManager->getUniqueID());
    309318      handshakes[clientId]->setUniqueID(clientId);
    310319    } else
     
    312321      clientId = networkSockets.size();
    313322      networkSockets.push_back(tempNetworkSocket);
    314       Handshake* tHs = new Handshake(true, clientId);
     323      Handshake* tHs = new Handshake(true, clientId, this->networkGameManager->getUniqueID());
    315324      tHs->setUniqueID(clientId);
    316325      handshakes.push_back(tHs);
     
    374383  }
    375384  this->maxConnections = n;
    376 }
    377 
    378 
     385  this->networkGameManager->setUniqueID( n+2 );
     386}
     387
     388
Note: See TracChangeset for help on using the changeset viewer.