Changeset 1748
- Timestamp:
- Sep 9, 2008, 11:23:40 AM (16 years ago)
- Location:
- code/branches/network/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/Server.cc
r1742 r1748 326 326 w->setClientID(temp->getID()); 327 327 assert(w->send()); 328 packet::Gamestate *g = new packet::Gamestate(); 329 g->setClientID(temp->getID()); 330 assert(g->collectData(0)); 331 assert(g->compressData()); 332 assert(g->send()); 328 333 return true; 329 334 } … … 353 358 no->setCamera(std::string("cam_") + convertToString(client->getID())); 354 359 no->create(); 355 no->setBacksync(true);356 360 357 361 return true; -
code/branches/network/src/network/Synchronisable.cc
r1742 r1748 64 64 datasize=0; 65 65 objectFrequency_=1; 66 objectMode_=0x1; // by default do not send data to servere 66 67 objectID=idCounter++; 67 68 syncList = new std::list<synchronisableVariable *>; … … 82 83 } 83 84 85 84 86 void Synchronisable::setClient(bool b){ 85 87 if(b) // client … … 314 316 } 315 317 318 /** 319 * 320 * @param id 321 * @return 322 */ 316 323 bool Synchronisable::isMyTick(unsigned int id){ 317 324 // return true; 318 return id==0 || id%objectFrequency_==objectID%objectFrequency_;325 return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0); 319 326 } 320 327 … … 333 340 } 334 341 335 void Synchronisable::setBacksync(bool sync){ 336 backsync_=sync; 337 } 338 339 bool Synchronisable::getBacksync(){ 340 return backsync_; 341 } 342 void Synchronisable::setObjectMode(int mode){ 343 assert(mode==0x1 || mode==0x2 || mode==0x3); 344 objectMode_=mode; 345 } 346 342 347 343 348 } -
code/branches/network/src/network/Synchronisable.h
r1742 r1748 34 34 #include <list> 35 35 #include "core/OrxonoxClass.h" 36 #include "util/XMLIncludes.h" 36 37 #include "NetworkCallback.h" 37 38 … … 66 67 class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{ 67 68 public: 68 69 69 70 virtual ~Synchronisable(); 70 71 unsigned int objectID; … … 76 77 bool updateData(unsigned char*& mem, int mode=0x0); 77 78 bool isMyData(unsigned char* mem); 78 void setBacksync(bool sync); 79 bool getBacksync(); 79 void setObjectMode(int mode); 80 void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; } 81 80 82 virtual void registerAllVariables()=0; 81 83 virtual bool create(); … … 93 95 bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server) 94 96 unsigned int objectFrequency_; 97 int objectMode_; 95 98 }; 96 99 } -
code/branches/network/src/network/packet/Welcome.cc
r1735 r1748 32 32 #include "Welcome.h" 33 33 #include "network/Host.h" 34 #include "network/Synchronisable.h" 34 35 #include "core/CoreIncludes.h" 35 36 #include <assert.h> … … 79 80 Host::setShipID(shipID); 80 81 COUT(3) << "Welcome set clientId: " << clientID << " shipID: " << shipID << std::endl; 82 Synchronisable::setClient(true); 81 83 delete this; 82 84 return true; -
code/branches/network/src/orxonox/objects/Model.cc
r1627 r1748 45 45 CreateFactory(Model); 46 46 47 /** 48 * 49 */ 47 50 Model::Model() 48 51 { 49 52 RegisterObject(Model); 50 53 registerAllVariables(); 54 if(this->isExactlyA(Class(Model))) 55 setObjectFrequency(1); 51 56 } 52 57 -
code/branches/network/src/orxonox/objects/SpaceShip.cc
r1742 r1748 166 166 if(network::Host::running()) 167 167 COUT(3) << "this id: " << this->objectID << " myShipID: " << network::Host::getShipID() << std::endl; 168 if(network::Host::running() && objectID == network::Host::getShipID()) 168 if(network::Host::running() && objectID == network::Host::getShipID()){ 169 setObjectMode(0x3); 169 170 myShip_=true; 171 } 170 172 else 171 173 this->setRadarObjectColour(this->getProjectileColour()); … … 360 362 if(myShip_){ 361 363 COUT(3) << "requesting focus for camera" << std::endl; 362 this->setBacksync(true);363 364 //CameraHandler::getInstance()->requestFocus(cam_); 364 365 if(this->isExactlyA(Class(SpaceShip))){ … … 466 467 } 467 468 468 projectile->set Backsync(true);469 projectile->setObjectMode(0x3); 469 470 this->timeToReload_ = this->reloadTime_; 470 471 }
Note: See TracChangeset
for help on using the changeset viewer.