Changeset 1834
- Timestamp:
- Sep 26, 2008, 12:59:48 AM (16 years ago)
- Location:
- code/branches/network
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/TODO
r1793 r1834 5 5 check that we dont have to much registervar because of virtual function calls 6 6 7 setvariable mode 8 objectmode 9 friend classes 10 priorities 11 static (sync once) 12 triggerSync -
code/branches/network/src/network/ConnectionManager.cc
r1755 r1834 372 372 orxonox::ObjectList<orxonox::SpaceShip>::iterator it; 373 373 for(it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); it; ++it){ 374 if(it-> objectID!=id)374 if(it->getObjectID()!=id) 375 375 continue; 376 376 delete *it; -
code/branches/network/src/network/Server.cc
r1793 r1834 326 326 orxonox::SpaceShip *no = dynamic_cast<orxonox::SpaceShip *>(id->fabricate()); 327 327 no->classID = id->getNetworkID(); 328 client->setShipID(no-> objectID);328 client->setShipID(no->getObjectID()); 329 329 no->setPosition(orxonox::Vector3(0,0,80)); 330 330 no->setScale(10); … … 355 355 gamestates_->removeClient(client); 356 356 while(it){ 357 if(it-> objectID!=client->getShipID()){357 if(it->getObjectID()!=client->getShipID()){ 358 358 ++it; 359 359 continue; -
code/branches/network/src/network/Synchronisable.cc
r1827 r1834 65 65 RegisterRootObject(Synchronisable); 66 66 static unsigned int idCounter=0; 67 datasize=0;68 67 objectFrequency_=1; 69 objectMode_=0x1; // by default do not send data to server e68 objectMode_=0x1; // by default do not send data to server 70 69 objectID=idCounter++; 70 // COUT(3) << " bump +++" << objectID << " | " << &objectMap_ << std::endl; 71 71 syncList = new std::list<synchronisableVariable *>; 72 72 } … … 81 81 for(std::list<synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++) 82 82 delete (*it)->callback; 83 assert(objectMap_[objectID]->objectID==objectID); 84 objectMap_.erase(objectID); 83 // COUT(3) << " bump ---" << objectID << " | " << &objectMap_ << std::endl; 84 // assert(objectMap_[objectID]->objectID==objectID); 85 // objectMap_.erase(objectID); 85 86 } 86 87 } … … 92 93 */ 93 94 bool Synchronisable::create(){ 94 objectMap_[objectID]=this;95 assert(objectMap_[objectID]==this);96 95 this->classID = this->getIdentifier()->getNetworkID(); 97 96 COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl; 97 98 // objectMap_[objectID]=this; 99 // assert(objectMap_[objectID]==this); 100 // assert(objectMap_[objectID]->objectID==objectID); 98 101 return true; 99 102 } … … 145 148 assert(getSynchronisable(objectID)); 146 149 assert(getSynchronisable(objectID)->objectID==objectID); 147 delete objectMap_[objectID]; 150 // delete objectMap_[objectID]; 151 Synchronisable *s = getSynchronisable(objectID); 152 if(s) 153 delete s; 154 else 155 return false; 148 156 return true; 149 157 } … … 155 163 */ 156 164 Synchronisable* Synchronisable::getSynchronisable(unsigned int objectID){ 157 std::map<unsigned int, Synchronisable *>::iterator i = objectMap_.find(objectID); 158 if(i==objectMap_.end()) 159 return NULL; 160 assert(i->second->objectID==objectID); 161 return (*i).second; 165 orxonox::ObjectList<Synchronisable>::iterator it; 166 for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){ 167 if( it->getObjectID()==objectID ) 168 return *it; 169 } 170 return NULL; 171 172 // std::map<unsigned int, Synchronisable *>::iterator i = objectMap_.find(objectID); 173 // if(i==objectMap_.end()) 174 // return NULL; 175 // assert(i->second->objectID==objectID); 176 // return (*i).second; 162 177 } 163 178 … … 181 196 temp->callback = cb; 182 197 COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl; 183 // increase datasize184 datasize+=sizeof(int)+size;185 198 //std::cout << "push temp to syncList (at the bottom) " << datasize << std::endl; 186 199 COUT(5) << "Syncronisable::objectID: " << objectID << " this: " << this << " name: " << this->getIdentifier()->getName() << " networkID: " << this->getIdentifier()->getNetworkID() << std::endl; -
code/branches/network/src/network/Synchronisable.h
r1827 r1834 44 44 #define REGISTERSTRING_WITHDIR(stringname, mode) registerVar(&stringname, stringname.length()+1, network::STRING, mode) 45 45 46 //TODO: this is only a very ugly hack ... 47 namespace orxonox{ 48 class SpaceShip; 49 } 50 46 51 namespace network 47 52 { … … 75 80 }SYNCVAR; 76 81 77 78 82 /** 79 83 * This class is the base class of all the Objects in the universe that need to be synchronised over the network … … 83 87 class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{ 84 88 public: 89 friend class packet::Gamestate; 90 friend class GamestateClient; 91 friend class Server; 92 friend class orxonox::SpaceShip; 93 virtual ~Synchronisable(); 94 85 95 86 virtual ~Synchronisable();87 unsigned int objectID;88 unsigned int classID;89 90 bool getData(unsigned char*& men, unsigned int id, int mode=0x0);91 int getSize(unsigned int id, int mode=0x0);92 bool updateData(unsigned char*& mem, int mode=0x0);93 bool isMyData(unsigned char* mem);94 bool doSelection(unsigned int id);95 void setObjectMode(int mode);96 void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }97 98 virtual void registerAllVariables()=0;99 96 virtual bool create(); 100 97 static void setClient(bool b); … … 106 103 static unsigned int popDeletedObject(){ unsigned int i = deletedObjects_.front(); deletedObjects_.pop(); return i; } 107 104 108 105 inline unsigned int getObjectID(){return objectID;} 106 inline unsigned int getClassID(){return classID;} 109 107 protected: 110 108 Synchronisable(); 111 109 void registerVar(void *var, int size, variableType t, int mode=1, NetworkCallbackBase *cb=0); 110 void setObjectMode(int mode); 111 void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; } 112 virtual void registerAllVariables()=0; 113 114 112 115 private: 116 bool getData(unsigned char*& men, unsigned int id, int mode=0x0); 117 int getSize(unsigned int id, int mode=0x0); 118 bool updateData(unsigned char*& mem, int mode=0x0); 119 bool isMyData(unsigned char* mem); 120 bool doSelection(unsigned int id); 113 121 bool isMyTick(unsigned int id); 122 123 unsigned int objectID; 124 unsigned int classID; 125 114 126 std::list<synchronisableVariable *> *syncList; 115 int datasize;116 127 static int state_; // detemines wheter we are server (default) or client 117 128 bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server) -
code/branches/network/src/network/packet/Gamestate.cc
r1827 r1834 80 80 return false; 81 81 } 82 82 83 #ifndef NDEBUG 84 std::list<Synchronisable*> slist; 85 std::list<Synchronisable*>::iterator iit; 86 #endif 83 87 //start collect data synchronisable by synchronisable 84 88 unsigned char *mem=data_; … … 101 105 }// stop allocate additional memory 102 106 107 #ifndef NDEBUG 108 for(iit=slist.begin(); iit!=slist.end(); iit++) 109 assert((*iit)!=*it); 110 slist.push_back(*it); 111 #endif 112 103 113 //if(it->doSelection(id)) 104 114 dataMap_[mem-data_]=(*it); // save the mem location of the synchronisable data … … 143 153 { 144 154 s = Synchronisable::fabricate(mem, mode); 145 if(!s) 146 return false; 155 assert(s); 156 // if(!s) 157 // return false; 147 158 } 148 159 else 149 160 { 150 if(!s->updateData(mem, mode)) 151 return false; 161 assert(s->updateData(mem, mode)); 162 //if(!s->updateData(mem, mode)) 163 //return false; 152 164 } 153 165 } -
code/branches/network/src/orxonox/objects/BillboardProjectile.cc
r1747 r1834 42 42 RegisterObject(BillboardProjectile); 43 43 44 if (this->owner_) 45 { 46 this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1); 47 this->attachObject(this->billboard_.getBillboardSet()); 48 this->scale(0.5); 49 } 44 this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1); 45 this->attachObject(this->billboard_.getBillboardSet()); 46 this->scale(0.5); 50 47 } 51 48 -
code/branches/network/src/orxonox/objects/ParticleProjectile.cc
r1747 r1834 42 42 RegisterObject(ParticleProjectile); 43 43 44 this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal); 45 this->particles_->addToSceneNode(this->getNode()); 46 this->particles_->setKeepParticlesInLocalSpace(true); 44 47 if (this->owner_) 45 48 { 46 this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal);47 this->particles_->addToSceneNode(this->getNode());48 this->particles_->getAllEmitters()->setDirection(-this->owner_->getInitialDir());49 this->particles_->setKeepParticlesInLocalSpace(true);50 49 } 51 else52 {53 this->particles_ = 0;54 }50 // else 51 // { 52 // this->particles_ = 0; 53 // } 55 54 56 55 this->setConfigValues(); … … 73 72 this->particles_->setEnabled(this->isVisible()); 74 73 } 74 75 bool ParticleProjectile::create(){ 76 if(!Projectile::create()) 77 return false; 78 this->particles_->getAllEmitters()->setDirection(-this->getOrientation()*Vector3(1,0,0)); 79 return true; 80 } 75 81 } -
code/branches/network/src/orxonox/objects/ParticleProjectile.h
r1747 r1834 45 45 virtual void changedVisibility(); 46 46 void setConfigValues(); 47 48 virtual bool create(); 47 49 48 50 private: -
code/branches/network/src/orxonox/objects/Projectile.cc
r1747 r1834 54 54 this->smokeTemplateName_ = "Orxonox/smoke4"; 55 55 56 this->setStatic(false); 57 this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL); 58 56 59 if (this->owner_) 57 60 { 58 this->setStatic(false);59 61 this->setOrientation(this->owner_->getOrientation()); 60 62 this->setPosition(this->owner_->getPosition()); 61 this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);62 63 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 63 64 } … … 121 122 delete this; 122 123 } 124 125 bool Projectile::create(){ 126 return WorldEntity::create(); 127 } 123 128 } -
code/branches/network/src/orxonox/objects/Projectile.h
r1747 r1834 45 45 void destroyObject(); 46 46 virtual void tick(float dt); 47 48 virtual bool create(); 47 49 48 50 static float getSpeed() -
code/branches/network/src/orxonox/objects/SpaceShip.cc
r1772 r1834 78 78 for(it = ObjectList<SpaceShip>::begin(); it; ++it){ 79 79 assert(it->isA(Class(SpaceShip))); 80 if( (it)->myShip_ || (network::Host::running() && network::Host::getShipID()==(it)-> objectID) ){80 if( (it)->myShip_ || (network::Host::running() && network::Host::getShipID()==(it)->getObjectID()) ){ 81 81 // COUT(1) << "^^^^^^^^^^ myShip_:" << *it << " classname: " << (*it)->getIdentifier()->getName() << " objectid: " << (*it)->objectID << std::endl; 82 82 return *it; … … 173 173 if(network::Host::running()) 174 174 // COUT(3) << "this id: " << this->objectID << " myShipID: " << network::Host::getShipID() << std::endl; 175 if(network::Host::running() && objectID== network::Host::getShipID()){175 if(network::Host::running() && getObjectID() == network::Host::getShipID()){ 176 176 if(!network::Host::isServer()) 177 177 setObjectMode(0x3); … … 375 375 if(this->isExactlyA(Class(SpaceShip))){ 376 376 getFocus(); 377 COUT(3) << "getting focus for obj id: " << objectID<< std::endl;377 COUT(3) << "getting focus for obj id: " << getObjectID() << std::endl; 378 378 }else 379 COUT(3) << "not getting focus (not exactly spaceship) for obj id: " << objectID<< std::endl;379 COUT(3) << "not getting focus (not exactly spaceship) for obj id: " << getObjectID() << std::endl; 380 380 }else 381 COUT(3) << "not getting focus (not my ship) for obj id: " << objectID<< std::endl;381 COUT(3) << "not getting focus (not my ship) for obj id: " << getObjectID() << std::endl; 382 382 } 383 383 … … 475 475 projectile->setColour(this->getProjectileColour()); 476 476 projectile->create(); 477 if (projectile-> classID== 0)477 if (projectile->getClassID() == 0) 478 478 { 479 479 COUT(3) << "generated projectile with classid 0" << std::endl; // TODO: remove this output … … 570 570 } 571 571 572 COUT(5) << "steering our ship: " << objectID<< std::endl;572 COUT(5) << "steering our ship: " << getObjectID() << std::endl; 573 573 this->acceleration_.x = 0; 574 574 this->acceleration_.y = 0;
Note: See TracChangeset
for help on using the changeset viewer.