Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1945 for code/branches


Ignore:
Timestamp:
Oct 19, 2008, 1:36:13 AM (16 years ago)
Author:
landauf
Message:

added option "forceCallback" to updateData(…) in Synchronisable to get a callback when synchronizing a variable for the first time (even if it didn't changed)

Location:
code/branches/objecthierarchy/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/network/Synchronisable.cc

    r1940 r1945  
    139139    COUT(3) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
    140140          // update data and create object/entity...
    141     bool b = no->updateData(mem, mode);
     141    bool b = no->updateData(mem, mode, true);
    142142    assert(b);
    143143    b = no->create();
     
    297297   * @return true/false
    298298   */
    299   bool Synchronisable::updateData(uint8_t*& mem, int mode){
     299  bool Synchronisable::updateData(uint8_t*& mem, int mode, bool forceCallback){
    300300    if(mode==0x0)
    301301      mode=state_;
     
    349349      }
    350350      // call the callback function, if defined
    351       if(callback && (*i)->callback)
     351      if((callback || forceCallback) && (*i)->callback)
    352352        (*i)->callback->call();
    353353    }
  • code/branches/objecthierarchy/src/network/Synchronisable.h

    r1940 r1945  
    117117    bool getData(uint8_t*& men, unsigned int id, int mode=0x0);
    118118    uint32_t getSize(unsigned int id, int mode=0x0);
    119     bool updateData(uint8_t*& mem, int mode=0x0);
     119    bool updateData(uint8_t*& mem, int mode=0x0, bool forceCallback=false);
    120120    bool isMyData(uint8_t* mem);
    121121    bool doSelection(unsigned int id);
  • code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.cc

    r1943 r1945  
    7373    }
    7474
     75    void PlayerInfo::checkName()
     76    {
     77std::cout << "# PlayerInfo: checkName: " << this->bLocalPlayer_ << std::endl;
     78        if (this->bLocalPlayer_)
     79            this->setName(this->playerName_);
     80    }
     81
    7582    void PlayerInfo::registerVariables()
    7683    {
     
    8491    }
    8592
    86     void PlayerInfo::checkName()
    87     {
    88         if (this->bLocalPlayer_)
    89             this->setName(this->playerName_);
    90     }
    91 
    9293    void PlayerInfo::checkClientID()
    9394    {
     95std::cout << "# PlayerInfo: checkClientID" << std::endl;
    9496        this->bHumanPlayer_ = true;
    9597
    9698        if (this->clientID_ == network::Host::getPlayerID())
    9799        {
     100std::cout << "#             it's the client's ID" << std::endl;
    98101            this->bLocalPlayer_ = true;
    99102            this->setName(this->playerName_);
     103std::cout << "#             " << this->getName() << std::endl;
    100104
    101105            if (!Settings::isClient())
    102106            {
     107std::cout << "#             not client: finish setup" << std::endl;
    103108                this->bFinishedSetup_ = true;
    104109                this->finishedSetup();
     
    109114    void PlayerInfo::finishedSetup()
    110115    {
     116std::cout << "# PlayerInfo: finishedSetup: " << this->bFinishedSetup_ << std::endl;
    111117        if (Settings::isClient())
     118        {
     119std::cout << "#             client: set to true" << std::endl;
    112120            this->bFinishedSetup_ = true;
     121        }
    113122        else if (this->bFinishedSetup_)
    114123        {
     124std::cout << "#             not client but finished: add player" << std::endl;
    115125            Gametype* gametype = Gametype::getCurrentGametype();
    116126            if (gametype)
    117127                gametype->addPlayer(this);
    118128        }
     129        else
     130        {
     131std::cout << "#             not client and not finished" << std::endl;
     132        }
    119133    }
    120134}
Note: See TracChangeset for help on using the changeset viewer.