XNA Creators Club Online
Page 1 of 1 (10 items)
Sort Posts: Previous Next

xml files in release build.

Last post 11/10/2007 15:42 by dteviot. 9 replies.
  • 10/10/2007 21:37

    xml files in release build.

    Hi, Im making a 2-D rpg that is currently using an .xml file to load up all the ingame dialog. The problem is that anyone can open up a text editor and change the dialog.

    Is there a way to compile the .xml file into a .dll or something so that it can't be accessed in the release build?

    I need to know this because I want to make a commercial game for pc and i don't want the player to be able to hack the xml file. thanks.
  • 10/10/2007 21:50 In reply to

    Re: xml files in release build.

    You can make the xml file compiled resource content: http://blogs.msdn.com/shawnhar/archive/2007/06/12/embedding-content-as-resources.aspx.

    It's still pretty easy to get at, but no longer as trivial as opening up a datafile in your installation directory.

  • 10/10/2007 22:51 In reply to

    Re: xml files in release build.

    so this compiles the .xml to a .xnb file, and loads
    it up as a resource, but lets say in my code I load the xml file by name,

    ie:
    loadDialog("../../level01.xml");

    will this automatically point to the .xnb file?
  • 10/10/2007 23:22 In reply to

    Re: xml files in release build.

    actually that method wouldn't work at all since xna does not recognize .xml files as a content file and as such wouldn't build it as one. There's gotta be another way...anyone??
  • 10/10/2007 23:43 In reply to

    Re: xml files in release build.

    You can make a silly string importer :-) :

    [ContentImporter(".*", CacheImportedData=true, DisplayName="String - Stanlo")]

    class StringImporter : ContentImporter<string>

    {

    public override string Import(string filename, ContentImporterContext context)

    {

    return File.ReadAllText(filename);

    }

    }
  • 10/10/2007 23:44 In reply to

    Re: xml files in release build.

    Then you could do this:

    string s = content.Load<string>("XMLFile1");
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(s);
    Although what you should be doing is loading up your string tables inside the importer for use in your game (i.e. doing content.Load<MyDataStructureWithStrings>("helloworld") or something).
  • 11/10/2007 0:31 In reply to

    Re: xml files in release build.

    Sorry, im a bit of a newb...I dont really know much about importers, but what you're saying is to create a importer that takes everything in as a string and then create a new xmldocument with
    the string data?

    Right now im using XmlTextReader to read in the entire xml file, how would I access the xmldocument in the same manner?
  • 11/10/2007 0:55 In reply to

    Re: xml files in release build.

    This tutorial walks you through how to import arbitrary XML data into a custom binary XNB format:

    http://creators.xna.com/Headlines/tutorialscol1/archive/2007/06/28/Authoring-Particle-Systems-Using-XML-and-the-Content-Pipeline.aspx

    XNA Framework Developer - blog - homepage
  • 11/10/2007 1:08 In reply to

    Re: xml files in release build.

    nice, this is exactly what I need, thank you!
  • 11/10/2007 15:42 In reply to

    Re: xml files in release build.

    I'll just add the point, if you don't want people changing your files, the "classic" solution is digital signatures.  http://en.wikipedia.org/wiki/Digital_signature
    And .Net supports code signing.
Page 1 of 1 (10 items) Previous Next