Game Development Community

Hosting xml files on Webserver

by Joseph Jonathan · in Torque Game Engine · 05/01/2008 (8:02 pm) · 6 replies

I have a website and I have a game with the loading and saving system in xml.

Since my game is a fully online game with stats and other things that could maybe be tampered with I want to have all the players data stored in the xml files to be on my website.

How would I go about this so that the game would still be able to find the files even if they are not on the clients machine?


~Joseph-Jonathan

#1
05/02/2008 (5:49 am)
It's hard to suggest the best approach for you to be doing this without knowing more about your game, you mention that it is fully online game with stats, does that mean you have your own game servers running seperately to the client?

If that's the case the best bet would be to have the server save the xml files to local storage for itself, the client couldn't access those files and you can use Torques inbuilt communication between client and server to pass the data backwards and forwards as required.

If that's not the case then to get files onto your webserver you need to have a look at how you will allow the XML file to updated & maintained on the webserver - this isn't a torque question but one for a web developer, typically you can ftp files onto there or perhaps pass the data via a HTTP request to say a PHP or ASP script that could process the data and store an XML file.

Again there are plenty of methods and ways of doing it but they all rather depend on what you can do on your webserver and your game architecture
#2
05/02/2008 (6:52 am)
No I will have my game set up so that players create their own room so the server is on there machine.


Ill ask my web coding friend what he knows about it.

Wouldn't I need to know what I should call instead of file.openforread?
#3
05/02/2008 (7:23 am)
There are a few approaches, but as Andy said they hinge upon what your game topology looks like. Some possible solutions:

Use the tcpObject or httpObject from the client to post information from the game to a web page, which in turn saves that information out into XML or a database or whatever. This gives you a centralized repository of data on the web server. This really only makes sense if you are running a bunch of single player games.

If the clients connect to a centralized server, as is hinted at in your description, then it's best to use the built-in client/server functionality of torque to report to the game server stats, and let the server act as the maintainer of that information via saving/loading/and telling the clients what those stats are. In this way the game server is the single authoritative point, and it can make the saved data available to the web server via an xml file.

Then there's a hybrid of methods. If you need the game clients to save the stats locally, use what you have already but either post to the website or send to the game server the stat information as it is updated. Then you have both local stats and online stats, the online ones would be very difficult to fake.
#4
05/02/2008 (8:05 am)
I used the User Account System as a starting point for all my xml saving stuff.

I use v3.1.

would HTMLObject work with it?
#5
05/02/2008 (3:07 pm)
I'm not familiar with User Account System but from looking at the resource it appears that the later version (3.3) that hasn't been fully finished is basically what you are after doing, and matches with what Dave and myself have mentioned in that it would use the HTTPobject to pass data into a webpage which then stores it backend.

The Httpobject lets you query a webpage and pass it parameters, for example if you look at the top of this page you can see the address:
http://www.garagegames.com/mg/forums/result.thread.php?qt=74783

The end part of that URL ("qt=74783") is a parameter to the php script, where it can then use the variable "qt" to read a database of all the forum threads and this thread you created is number 74783. The is the most common way of passing values to a web server, another example would be doing a search on google:
http://www.google.com/search?q=this_was_my_search
where you can see a variable called "q" is passed with the value of "this_was_my_search".

Now for your game server passing information to the database it is more likely to be things like:

http://your_web_site.com/update_stats.php?user=fred&no_wins=25&no_deaths=5
so you can see we pass the user, number of wins and number of deaths. Obviously you need a way of protecting those pages so that it stops anyone from just updating stats for every other user, but that's something you'll have to have a look at.

You might want to take a look at the Persistant Character Server resource which sends information and gets data back from a website, it also includes a small change to the engine to put in some basic encryption to prevent people hacking it. Personally if you have a database available on your website I'd use that to store your information, if not then you can write to flat-file or xml files.
#6
05/02/2008 (4:45 pm)
Ok thanks. This helps a whole bunch.