Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] - A save XML example without any plugins

Author
Message
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 24th Jun 2011 13:26 Edited at: 13th Sep 2011 13:00
This basic snippet demonstrates one way to save an XML file, without the use of any plugins. No media files required.

The purpose you use XML for is up to you; but the idea of this example is to transfer information to another system; such as a website; not really to load it back. If you do not wish to use an XML plugin, consider other data storage methods.

In this example we are saving a game state which could be uploaded to a database or loaded into another application created by another programming language. If it were to be stored on the users system, one could encrypt the output or pack it into a memblock file.



More DBPRO XML tutorials
Using XML to initiate GDK.NET classes (VB)
Converting XML to another file format
About INI configuration files
Saving data to disk

Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Jun 2011 00:31
Alright, but then how do you load it back into the game???

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Jun 2011 11:07 Edited at: 1st Sep 2011 14:36


There are many ways to read a document back into DBPRO. I assume you want to know how to read it back without an XML plugin?

I must go to work now, so, on my next day off, I will post code which will parse the document without an XML plugin. (Unless someone else posts a solution before me)


Go here in the meantime and see how to parse XML back into DBPRO using Styx in my XML tutorial


Later..

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Jun 2011 11:11


There are many ways to read a document back into DBPRO. I assume you want to know how to read it back without an XML plugin?

I must go to work now, so, on my next day off, I will post code which will parse the document without an XML plugin. (Unless someone else posts a solution before me)



[href=http://www.binarymodular.com/main/articles.php?article_id=61]Go here
in the meantime[/href] and see how to parse XML back into DBPRO using Styx in my XML tutorial
Please excuse the temporary HTML the formatting issues in the code.

Later..
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Jun 2011 11:12
Sorry. Please remove the last post, I had issues with my link and clicked the post button by accident.
Red Eye
15
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 25th Jun 2011 11:37
XML Plugin or not, plugin stays code, so does your code.

XML Writer is far from difficult, getting it to load might be a challenge to optimize it for speed.

Good work though,

Cheers,

Leo

Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Jun 2011 05:50
Quote: "Unless someone else posts a solution before me"


I did. I have a more mature version of my code in GLB also.

http://forum.thegamecreators.com/?m=forum_view&t=162669&b=6

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 1st Sep 2011 14:49 Edited at: 1st Sep 2011 14:50
On the subject of data file use; two functions for loading strings from a file have been added to the website:

Get the snippets

Mugen Wizardry
User Banned
Posted: 1st Sep 2011 15:24
Or you can just use Kaedroho's XML reader =D

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Mugen Wizardry
User Banned
Posted: 1st Sep 2011 15:32
This is a stupid way of doing it, because ANYONE can change the data. let me write a more sophisticated version that's encrypted!

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Mugen Wizardry
User Banned
Posted: 1st Sep 2011 15:42
You know what? Screw it. Just use Kaedroho's plugin -.-

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 2nd Sep 2011 16:52 Edited at: 2nd Sep 2011 17:00
Hello guys.

From the original topic of not requiring plugins to quickly saving a small amount of data for use online or with an XML driven database; Mugen is quite right about this not being a great way of storing sensitive information such as passwords or puzzle clues.

For such things, consider encrypting the XML string as a whole, or at least the values in each XML node. There is also one way encryption that could be used for passwords or similar data that you would not want someone to ever read.

If you feel it is not the end of the world if a DBPRO user hacks such a file, consider storing strings in an array, convert that into a memblock and use [Write Memblock] to add the memblock to an open file. The contents of this file could not be interpreted in a text editor by any being from planet earth.

Here is what was added to the array: "<Message>Hi, my name is sam and I like to eat fish and play with monkeys</Message>"

Here is what the text file looks like in a text editor:4 8&„

"What does this file do? What does that say?".




Well at least most of your players will not be able to interpret the secret information; but they could type in a few words and cause you program to crash when loading the file back; thus, we probably should not make such a file easy to find in the first place, although, anyone could open any file of anykind and screw it up if they wanted.

The key is to put what ever you do not want them to read, in a difficult to find place, in a difficult to read form. In other words, write it in backwards Chinese-Egyptian-Algebra-Fusion, put it underneath a pile of pooh in a treasure chest, and bury it under the ocean near the Bermuda Triangle, to the east, below the sharks (Make sure you have it memorized because you might find it difficult to get it back). Hyperbole aside, there are some serious hackers out there, some of them far, some maybe in your very room right now.

Commercial games such as Civilization 5 feature 100s of script files, text files, XML files and image files fully exposed for the players to change. So what! Let them modify the game if they want to. As for the save game files, they are sensitive and therefore encrypted.

---

Following on with the topic of loading XML data, without plugins. Yes, I tend to use a plugin, the XML features in the Styx Plugin; we can all use what ever reader we want, however, if you needed to create your own reader, to work the way you want it to work (with XML namespaces, multi root level nodes etc), feel free to use my LoadString() or LoadDoc() snippets. Expand them and modify them for the purpose you need. Copy, paste and just call them to load up any string you saved using my SaveString() command in the original post above.

Happy days!

Mugen Wizardry
User Banned
Posted: 2nd Sep 2011 19:57 Edited at: 2nd Sep 2011 19:57
Let them modify it? Are you CRAZY?! I would NOT want some ******* hacking into my hard-work game. That is why Encryption is not neccessary. It's REQUIRED.

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 3rd Sep 2011 03:36
^
Part of the fun of a lot of games is messing with what they do. You can bend-over backwards to prevent someone hacking your game, but in the end a determined bored coder will (1) hack it, and (2) think you're a jerk for making it so hard to change the dialog. I have no idea why you would be upset from someone modifying a game that they have. (And yes, when you sell/give it to them, and it's on their computer, it's their property, and so in a sense it's not your game, it's their game.)

of course, it's different for an online game.


Why does blue text appear every time you are near?
Mugen Wizardry
User Banned
Posted: 3rd Sep 2011 13:28
Again, I repeat my answer. I will be ****ed if I'm gonna let some jerk hack into my hard work! I will protect it with SHA-256 if I effing have to -.-

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !

Login to post a reply

Server time is: 2024-03-28 20:15:04
Your offset time is: 2024-03-28 20:15:04