Attribute is returning to its previous value

2010-05-27
2013-05-20
  • Andre Santee
    Andre Santee
    2010-05-27

    Why are my local variables going back to their previous values right after the querying?
    Here is the code:

    TiXmlElement *pElement = hRoot.FirstChildElement().Element();
    pElement->QueryIntAttribute("Type", (int*)&type);
    pElement->QueryIntAttribute("Static", (int*)&staticEntity);
    pElement->QueryIntAttribute("Collidable", (int*)&collidable);
    pElement->QueryIntAttribute("StartFrame", &startFrame);
    pElement->QueryIntAttribute("ApplyLight", (int*)&applyLight);
    pElement->QueryIntAttribute("CastShadow", (int*)&castShadow);
    pElement->QueryFloatAttribute("LayerDepth", &fLayerDepth);
    pElement->QueryFloatAttribute("SoundVolume", &soundVolume);
    pElement->QueryFloatAttribute("ShadowScale", &shadowScale);
    pElement->QueryFloatAttribute("ShadowOpacity", &shadowOpacity);

    I ran it in the debug mode and I saw that it reads each attribute correctly, but after the second or the third querying, all my variables (like type and staticEntity) were mysteriously having their previous value from before the query.
    What’s that supposed to be?

     
  • Andre Santee
    Andre Santee
    2010-05-27

    Correction: actually it doesn't go back to the previous value, it always goes back to 0. It seems to happen only to the int atributtes. Very weird uh?

     
  • Andre Santee
    Andre Santee
    2010-05-27

    Problem solved!