Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2173


Ignore:
Timestamp:
Nov 10, 2008, 2:06:09 AM (11 years ago)
Author:
landauf
Message:
  • Added new XMLPort mode, ExpandObject, which works like LoadObject but doesn't use default values if there are missing parameters. This is used if an object is expanded by templates (like adding CameraPositions).
  • Changed default level to sample3.oxw in objecthierarchy2 branch
  • Small fix with doubly added clients in Level- and PlayerManager
Location:
code/branches/objecthierarchy2/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy2/src/core/BaseObject.cc

    r2171 r2173  
    109109            std::list<std::string> eventnames;
    110110
    111             if (mode == XMLPort::LoadObject)
     111            if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject)
    112112            {
    113113                for (ticpp::Iterator<ticpp::Element> child = events->FirstChildElement(false); child != child.end(); child++)
  • code/branches/objecthierarchy2/src/core/CorePrereqs.h

    r2087 r2173  
    6969    {
    7070      LoadObject,
    71       SaveObject
     71      SaveObject,
     72      ExpandObject
    7273    };
    7374  }
  • code/branches/objecthierarchy2/src/core/Template.cc

    r2171 r2173  
    4343
    4444        this->bIsLink_ = false;
     45        this->bLoadDefaults_ = true;
    4546        this->bIsReturningXMLElement_ = false;
    4647        this->baseclassIdentifier_ = 0;
     
    5657        SUPER(Template, XMLPort, xmlelement, mode);
    5758
    58         XMLPortParam(Template, "link", setLink, getLink, xmlelement, mode);
    59         XMLPortParam(Template, "baseclass", setBaseclass, getBaseclass, xmlelement, mode);
     59        XMLPortParam(Template, "link",      setLink,         getLink,         xmlelement, mode);
     60        XMLPortParam(Template, "baseclass", setBaseclass,    getBaseclass,    xmlelement, mode);
     61        XMLPortParam(Template, "defaults",  setLoadDefaults, getLoadDefaults, xmlelement, mode).defaultValues(true);
    6062
    6163        Element* element = xmlelement.FirstChildElement(false);
     
    134136
    135137        Element temp = ((TiXmlElement*)&this->getXMLElement());
    136         object->XMLPort(temp, XMLPort::LoadObject);
     138
     139        if (this->bLoadDefaults_)
     140            object->XMLPort(temp, XMLPort::LoadObject);
     141        else
     142            object->XMLPort(temp, XMLPort::ExpandObject);
    137143    }
    138144
  • code/branches/objecthierarchy2/src/core/Template.h

    r2171 r2173  
    5353                { return this->link_; }
    5454
     55            inline void setLoadDefaults(bool bLoadDefaults)
     56                { this->bLoadDefaults_ = bLoadDefaults; }
     57            inline bool getLoadDefaults() const
     58                { return this->bLoadDefaults_; }
     59
    5560            inline void setXMLElement(const TiXmlElement& xmlelement)
    5661                { this->xmlelement_ = xmlelement; }
     
    7580            Identifier* baseclassIdentifier_;
    7681            bool bIsLink_;
     82            bool bLoadDefaults_;
    7783            mutable bool bIsReturningXMLElement_;
    7884    };
  • code/branches/objecthierarchy2/src/core/XMLPort.h

    r2171 r2173  
    336336                this->parseParams_.mode = mode;
    337337
    338                 if (mode == XMLPort::LoadObject)
     338                if ((mode == XMLPort::LoadObject) || (mode == XMLPort::ExpandObject))
    339339                {
    340340                    try
    341341                    {
    342342                        std::string attribute = xmlelement.GetAttribute(this->paramname_);
    343                         if ((attribute.size() > 0) || (this->loadexecutor_->allDefaultValuesSet()))
     343                        if ((attribute.size() > 0) || ((mode != XMLPort::ExpandObject) && this->loadexecutor_->allDefaultValuesSet()))
    344344                        {
    345345                            COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();
    346                             if (this->loadexecutor_->parse(object, attribute, ","))
     346                            if (this->loadexecutor_->parse(object, attribute, ",") || (mode  == XMLPort::ExpandObject))
    347347                                this->parseResult_ = PR_finished;
    348348                            else
    349349                                this->parseResult_ = PR_waiting_for_default_values;
    350350                        }
     351                        else if (mode == XMLPort::ExpandObject)
     352                            this->parseResult_ = PR_finished;
    351353                        else
    352354                            this->parseResult_ = PR_waiting_for_default_values;
     
    473475            XMLPortObjectContainer& port(T* object, Element& xmlelement, XMLPort::Mode mode)
    474476            {
    475                 if (mode == XMLPort::LoadObject)
     477                if ((mode == XMLPort::LoadObject) || (mode == XMLPort::ExpandObject))
    476478                {
    477479                    try
  • code/branches/objecthierarchy2/src/orxonox/LevelManager.cc

    r2171 r2173  
    4242        assert(singletonRef_s == 0);
    4343        singletonRef_s = this;
     44
     45        PlayerManager::getInstance(); // ensure existence of PlayerManager
    4446    }
    4547
  • code/branches/objecthierarchy2/src/orxonox/gamestates/GSLevel.cc

    r2103 r2173  
    5151namespace orxonox
    5252{
    53     SetCommandLineArgument(level, "sample2.oxw").shortcut("l");
     53    SetCommandLineArgument(level, "sample3.oxw").shortcut("l");
    5454
    5555    GSLevel::GSLevel()
  • code/branches/objecthierarchy2/src/orxonox/objects/Level.cc

    r2171 r2173  
    141141    void Level::playerEntered(PlayerInfo* player)
    142142    {
    143         COUT(3) << "player entered level" << std::endl;
     143        COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
    144144        player->setGametype(this->getGametype());
    145145    }
     
    147147    void Level::playerLeft(PlayerInfo* player)
    148148    {
    149         COUT(3) << "player left level" << std::endl;
     149        COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
    150150        player->setGametype(0);
    151151    }
Note: See TracChangeset for help on using the changeset viewer.