About Store Forum Documentation Contact



Post Reply 
[Solved]EE 2.0 Xmlparam.findparam bugs out with @ / , space etc..
Author Message
Fex Offline
Gold Supporter

Post: #1
[Solved]EE 2.0 Xmlparam.findparam bugs out with @ / , space etc..
Xmlparam.findparam fails if the param Str name contains:

spaces
/
comma (,)
@

Haven't tested the full range, other things probably break it as well.

In 1.0 you could have all characters except spaces, now in 2.0 more things seem to bug out Xmlparam.findparam. My param names are the names of my Input.name so things like "Move Left" "Crouch,Fly Down", "Lightening Storm" etc..

The names of my params contain spaces / , etc so I need to use the following when I save or load from the XML file.

Seems like a bug because @ / , space etc are allowed to be Xml param names per the xml spec,only < > & require escape sequences.

Here is the workaround I use for my input bind loading:

Code:
Str xml_string_space_remove(Str string)
{
   return Replace(Replace(Replace(string, ',', ""), ' ', ""), '/', "");
}
/******************************************************************************/
void load_binds(Str name)
{
    defaultkeybinds(); // reset them so when we switch chars unbound things don't carry over
    Str filename = S+ name + "_bindings.txt";
    XmlData   data; data .load    (filename);
    //inputbinds.clear();
    REPA(inputbinds)
      {
        if(XmlNode  *node=data .findNode ("inputbinds"))
         if(XmlParam *param=node.findParam(xml_string_space_remove(inputbinds[i].input.name)))
         //if(XmlParam *param=node.findParam(inputbinds[i].input.name))
         {
            if(param.value.is())
               {
                  CM.New(S+"Loaded: "+xml_string_space_remove(inputbinds[i].input.name));
                   Byte btnbyte  =  TextInt(param.value); //CM.New(S+ "byte "+ btnbyte+ " value "+ email.value );
                   if(btnbyte != 199)inputbinds[i].input.b[0].type = INPUT_KEYBOARD; // 199 is what all the INPUT_NONE things seem to save as
                   inputbinds[i].input.b[0].button = btnbyte;
               }
         } else{CM.New(S+"Xmlparam not found: "+xml_string_space_remove(inputbinds[i].input.name)); }
      }
      bindswindow.build(); // rebuild the binds window to account for the updated 'inputbinds' container
}
/******************************************************************************/
void save_binds(Str name)
{
    Str filename = S+ name + "_bindings.txt";
    FDel(filename);
    XmlData   data; data .load(filename);
    REPA(inputbinds)
      {
         XmlNode  &node=data .getNode ("inputbinds");
         XmlParam &param=node.getParam(xml_string_space_remove(inputbinds[i].input.name)); // the storage parameter is the name of the bind like "Move Forward" or "Lightening Storm"
         // XmlParam &param=node.getParam(inputbinds[i].input.name);
         param.value=inputbinds[i].input.b[0].button;
      }
      data.save(filename);
}
(This post was last modified: 12-23-2013 07:02 AM by Fex.)
12-23-2013 04:49 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
RE: EE 2.0 Xmlparam.findparam bugs out with @ / , space etc..
Quote: Seems like a bug because @ / , space etc are allowed to be Xml param names per the xml spec,only < > & require escape sequences.
that's incorrect, you're talking about a different part of xml spec.

valid chars for param(attribute) names are those listed here:
http://razzed.com/2009/01/30/valid-chara...n-htmlxml/

You can use every char in param value, because EE handles encoding/decoding of it.
However you can't store invalid chars in param names.

I recommend that you use TextData instead of XmlData where you can use everything without limitations (like spaces in param names), and you will generate smaller file sizes.
12-23-2013 05:32 AM
Find all posts by this user Quote this message in a reply
Fex Offline
Gold Supporter

Post: #3
RE: EE 2.0 Xmlparam.findparam bugs out with @ / , space etc..
(12-23-2013 05:32 AM)Esenthel Wrote:  I recommend that you use TextData instead of XmlData where you can use everything without limitations (like spaces in param names), and you will generate smaller file sizes.

Thanks for the prompt reply, I will use TextData instead.
12-23-2013 07:01 AM
Find all posts by this user Quote this message in a reply
Post Reply