![Cool 8)](http://game-editor.com/forum/images/smilies/icon_cool.gif)
Lately I've been promising through my signature, and maybe in a post or few (or was that just chat with some of you?) that I was coming up with a networked game created with the current stable version of GE (to be exact, I use 1.3.9).
I realized lately that the method I was going to use to achieve this would actually create a security breach to the server you use. So I decided not to do the networking, since I didn't want to take the risk for security problems.
BUT
I decided also to share the idea, because I think it might be something to provoke thinking, and maybe somebody comes up with an idea to make the method safe...
So here's the way it works in theory:
You get a website, and you create a PHP registration, and login. Now the page that leads to tells you simply to also open the game program on your local computer. So here's the trick: the PHP page, has itself auto-refreshed every 3 seconds or so (faster or slower could be chosen depending on the system resources). The GE created game could also have a timer which is set to so many seconds. It is at the page reload and the ontimer events that synchronization happens, in the following way:
Let's suppose that the game directory was given to the online user database. When the page loads, it checks for a txt file in the game directory. First of all, it checks the date the txt file was last modified (which would be marked in the first line).
Based on that, it opens a database of actions, in which each action has the issue date, as well as all the information to fully describe its meaning. All actions since the time of the txt file modification are copied from the database, in text form, to another txt file in the same directory, as well as the current time (and the number of actions it copied).
The GE game then on the ontimer event opens this file PHP wrote to, reads the timestamp, and copies it to the file it writes to, which is the same file PHP read from! It then executes the actions which it received, and it copies all actions the user did in the meantime, into that file PHP read from. It then deletes the contents of the file it read from.
In the PHP code's turn it reads those actions, and copies it into its action's database. With the appropriate timestamp it read. It also deletes all information it read.
The reason they delete what they read is so that they do not read the same thing twice, therefore no single action may be actually done twice, causing different game statuses by the different users.
Timestamps are all written by PHP code, since it can get it, while GE can't (FEATURE REQUEST!!!).
Disadvantage of the method: to have a networked non-turn-based game, you'd need to figure such upgrades every split second, which demands many resources both from your computer, plus at least twice that amount from the server...
Action databases need to have frequent deletions with many active users, since if nothing is deleted, the database may grow too big, too fast...
And the greatest disadvantage... On your computer the game uses 2 text files, I call communication files. Now PHP always needs to download and upload the current communication file to view, otherwise it cannot read its contents, since it's a server side interface. Javascript may possibly used, but it may have similar consequences, but most importantly, it basically restricts users to Win IE, which means most people wont play, since most people nowadays use Mozilla, Chrome, Safari, Opera...
Though you could say, you're controlling what PHP uploads for itself, it's actually not true. Have a hacker rename their codes' file to the appropriate name in disguise, start the game, and PHP downloads a dangerous file... Even if you have your own game start up before the online PHP codes, so it may write into the file first, even then, with the right timing, the user can put in a virus code, instead of the info...
I thought I'd share the ideas, even if they can't be used seriously... You may have an idea... You may not even understand
![Laughing :lol:](http://game-editor.com/forum/images/smilies/icon_lol.gif)
![Very Happy :D](http://game-editor.com/forum/images/smilies/icon_biggrin.gif)