Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1834


Ignore:
Timestamp:
Sep 26, 2008, 12:59:48 AM (16 years ago)
Author:
scheusso
Message:

Fix in Projectiles (network fix)
different improvements in synchronisable and gamestates

Location:
code/branches/network
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/TODO

    r1793 r1834  
    55        check that we dont have to much registervar because of virtual function calls
    66
     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  
    372372    orxonox::ObjectList<orxonox::SpaceShip>::iterator it;
    373373    for(it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); it; ++it){
    374       if(it->objectID!=id)
     374      if(it->getObjectID()!=id)
    375375        continue;
    376376      delete *it;
  • code/branches/network/src/network/Server.cc

    r1793 r1834  
    326326    orxonox::SpaceShip *no = dynamic_cast<orxonox::SpaceShip *>(id->fabricate());
    327327    no->classID = id->getNetworkID();
    328     client->setShipID(no->objectID);
     328    client->setShipID(no->getObjectID());
    329329    no->setPosition(orxonox::Vector3(0,0,80));
    330330    no->setScale(10);
     
    355355    gamestates_->removeClient(client);
    356356    while(it){
    357       if(it->objectID!=client->getShipID()){
     357      if(it->getObjectID()!=client->getShipID()){
    358358        ++it;
    359359        continue;
  • code/branches/network/src/network/Synchronisable.cc

    r1827 r1834  
    6565    RegisterRootObject(Synchronisable);
    6666    static unsigned int idCounter=0;
    67     datasize=0;
    6867    objectFrequency_=1;
    69     objectMode_=0x1; // by default do not send data to servere
     68    objectMode_=0x1; // by default do not send data to server
    7069    objectID=idCounter++;
     70//     COUT(3) << " bump +++" << objectID << " | " << &objectMap_ << std::endl;
    7171    syncList = new std::list<synchronisableVariable *>;
    7272  }
     
    8181      for(std::list<synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++)
    8282        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);
    8586    }
    8687  }
     
    9293   */
    9394  bool Synchronisable::create(){
    94     objectMap_[objectID]=this;
    95     assert(objectMap_[objectID]==this);
    9695    this->classID = this->getIdentifier()->getNetworkID();
    9796    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);
    98101    return true;
    99102  }
     
    145148    assert(getSynchronisable(objectID));
    146149    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;
    148156    return true;
    149157  }
     
    155163   */
    156164  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;
    162177  }
    163178
     
    181196    temp->callback = cb;
    182197    COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl;
    183     // increase datasize
    184     datasize+=sizeof(int)+size;
    185198    //std::cout << "push temp to syncList (at the bottom) " << datasize << std::endl;
    186199    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  
    4444#define REGISTERSTRING_WITHDIR(stringname, mode) registerVar(&stringname, stringname.length()+1, network::STRING, mode)
    4545
     46//TODO: this is only a very ugly hack ...
     47namespace orxonox{
     48class SpaceShip;
     49}
     50
    4651namespace network
    4752{
     
    7580  }SYNCVAR;
    7681
    77 
    7882  /**
    7983  * This class is the base class of all the Objects in the universe that need to be synchronised over the network
     
    8387  class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{
    8488  public:
     89    friend class packet::Gamestate;
     90    friend class GamestateClient;
     91    friend class Server;
     92    friend class orxonox::SpaceShip;
     93    virtual ~Synchronisable();
     94
    8595   
    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;
    9996    virtual bool create();
    10097    static void setClient(bool b);
     
    106103    static unsigned int popDeletedObject(){ unsigned int i = deletedObjects_.front(); deletedObjects_.pop(); return i; }
    107104   
    108    
     105    inline unsigned int getObjectID(){return objectID;}
     106    inline unsigned int getClassID(){return classID;}
    109107  protected:
    110108    Synchronisable();
    111109    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   
    112115  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);
    113121    bool isMyTick(unsigned int id);
     122   
     123    unsigned int objectID;
     124    unsigned int classID;
     125   
    114126    std::list<synchronisableVariable *> *syncList;
    115     int datasize;
    116127    static int state_; // detemines wheter we are server (default) or client
    117128    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  
    8080    return false;
    8181  }
    82 
     82 
     83#ifndef NDEBUG
     84  std::list<Synchronisable*> slist;
     85  std::list<Synchronisable*>::iterator iit;
     86#endif
    8387  //start collect data synchronisable by synchronisable
    8488  unsigned char *mem=data_;
     
    101105    }// stop allocate additional memory
    102106
     107#ifndef NDEBUG
     108    for(iit=slist.begin(); iit!=slist.end(); iit++)
     109      assert((*iit)!=*it);
     110    slist.push_back(*it);
     111#endif
     112   
    103113    //if(it->doSelection(id))
    104114    dataMap_[mem-data_]=(*it);  // save the mem location of the synchronisable data
     
    143153    {
    144154      s = Synchronisable::fabricate(mem, mode);
    145       if(!s)
    146         return false;
     155      assert(s);
     156//       if(!s)
     157//         return false;
    147158    }
    148159    else
    149160    {
    150       if(!s->updateData(mem, mode))
    151         return false;
     161      assert(s->updateData(mem, mode));
     162      //if(!s->updateData(mem, mode))
     163        //return false;
    152164    }
    153165  }
  • code/branches/network/src/orxonox/objects/BillboardProjectile.cc

    r1747 r1834  
    4242        RegisterObject(BillboardProjectile);
    4343
    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);
    5047    }
    5148
  • code/branches/network/src/orxonox/objects/ParticleProjectile.cc

    r1747 r1834  
    4242        RegisterObject(ParticleProjectile);
    4343
     44        this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal);
     45        this->particles_->addToSceneNode(this->getNode());
     46        this->particles_->setKeepParticlesInLocalSpace(true);
    4447        if (this->owner_)
    4548        {
    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);
    5049        }
    51         else
    52         {
    53             this->particles_ = 0;
    54         }
     50//        else
     51//        {
     52//            this->particles_ = 0;
     53//        }
    5554
    5655        this->setConfigValues();
     
    7372        this->particles_->setEnabled(this->isVisible());
    7473    }
     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    }
    7581}
  • code/branches/network/src/orxonox/objects/ParticleProjectile.h

    r1747 r1834  
    4545            virtual void changedVisibility();
    4646            void setConfigValues();
     47           
     48            virtual bool create();
    4749
    4850        private:
  • code/branches/network/src/orxonox/objects/Projectile.cc

    r1747 r1834  
    5454        this->smokeTemplateName_ = "Orxonox/smoke4";
    5555
     56        this->setStatic(false);
     57        this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);
     58       
    5659        if (this->owner_)
    5760        {
    58             this->setStatic(false);
    5961            this->setOrientation(this->owner_->getOrientation());
    6062            this->setPosition(this->owner_->getPosition());
    61             this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);
    6263            this->setVelocity(this->owner_->getInitialDir() * this->speed_);
    6364        }
     
    121122        delete this;
    122123    }
     124   
     125    bool Projectile::create(){
     126      return WorldEntity::create();
     127    }
    123128}
  • code/branches/network/src/orxonox/objects/Projectile.h

    r1747 r1834  
    4545            void destroyObject();
    4646            virtual void tick(float dt);
     47           
     48            virtual bool create();
    4749
    4850            static float getSpeed()
  • code/branches/network/src/orxonox/objects/SpaceShip.cc

    r1772 r1834  
    7878      for(it = ObjectList<SpaceShip>::begin(); it; ++it){
    7979        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()) ){
    8181//        COUT(1) << "^^^^^^^^^^ myShip_:" << *it << " classname: " << (*it)->getIdentifier()->getName() << " objectid: " << (*it)->objectID << std::endl;
    8282          return *it;
     
    173173        if(network::Host::running())
    174174//          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()){
    176176          if(!network::Host::isServer())
    177177            setObjectMode(0x3);
     
    375375        if(this->isExactlyA(Class(SpaceShip))){
    376376          getFocus();
    377           COUT(3) << "getting focus for obj id: " << objectID << std::endl;
     377          COUT(3) << "getting focus for obj id: " << getObjectID() << std::endl;
    378378        }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;
    380380      }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;
    382382    }
    383383
     
    475475            projectile->setColour(this->getProjectileColour());
    476476            projectile->create();
    477             if (projectile->classID == 0)
     477            if (projectile->getClassID() == 0)
    478478            {
    479479              COUT(3) << "generated projectile with classid 0" <<  std::endl; // TODO: remove this output
     
    570570        }
    571571
    572         COUT(5) << "steering our ship: " << objectID << std::endl;
     572        COUT(5) << "steering our ship: " << getObjectID() << std::endl;
    573573        this->acceleration_.x = 0;
    574574        this->acceleration_.y = 0;
Note: See TracChangeset for help on using the changeset viewer.