Warscale 94 - Expanding TGE capabilities with TCP+Java
by Guimo · 06/08/2011 (7:36 pm) · 4 comments
Hi everybody!
There are so many things to tell you and so little time as I'm extremely busy on the development of the store systems in Warscale.
But first things first!
New associate!!!!
A lot of you may know Quinton Delpeche, his projects and his website on http://www.gobbogames.co.za/
What I would like to announce is that he has decided to join me on the development of Warscale! I'm quite excited with that news! He is an extremely experienced developer and he is now redesigning and remodeling the website and I have so many things in queue for him (evil laugh).
And as an added bonus, I have just learned he has license for all the MMOWorkshop packs... so expect new creatures in Warscale... sweeeet...
We are now looking for an 2d/3d artist (or artists, or company with artists) which may be interested in joining us. As usual send me a mail to guimo at spritekin dot com
Back to the main feature
So, I have been working on the payment system. I really take this thing seriously as this is the point where you can get into real troubles.
Cleaner database connection
The first thing I did this week was to expose some API to Torquescript in order to directly execute or extract data from my database. Previously I had one function for each DB instruction I wanted to execute but this was cumbersome as I had to add more and more functions and it was getting out of control. So now I have things like:
%result = DBConn.query("select * from users");
And the result will have a table with Torque separators like EOL for rows and TABs for columns and I can access the result with getRow and getField.
Add to that some executeCommand for inserts, updates and deletes and some commits and rollbacks and I got a fairly decent database access class. I access my database using the SQLAPI library (www.sqlapi.com) which allows me to switch to any database system if I need to.
Solved a big huge bug
I always had this erratic bug. When the client attempted a login, sometimes the client crashed. It usually worked and sometimes it didn't and I never was sure when it happened. I tracked the problem to invalid data being received in the client, but the server said the data was correctly being sent. To makes things worse, when I added debug messages in the server it always worked, flawlessly. When I removed the messages it failed.
So, after days with this problem I identified it as a network buffer being too small. Basically after writing too many messages in the network buffer without flushing it (which is accomplished any time you echo somethig to the console) then the data was truncated and corrupted. I managed a workaround solutio but I need to keep an eye on this in case of sudden disconnections.
Increased packet security
Being the buying and selling things such a delicate issue, I decided to increase the security. Before this only the login packet was encrypted, but now it is possible to encrypt all the packets sent from client to server. As usual encryption/decryption has a toll on resources and packet size so I still can keep it to the minimum necessary.
And the the bestest amazingest trickest trick of all time
Honestly I don't know why I never thought about this one before. I have always complained that Torque needed some access to HTTPs connections. Or just to anything SSH or SSL. The problem is that I was thinking inside the box so integrating an SSL library in Torque was, to say the least, painful and overkill. Too much time to invest.
So in order to solve this problem I coded some cumbersome solutions. Like a parallel server in java which connected to the website and synchronized any information on the forums and account registration with the information on the game database. Not really the best solution as I had to maintain yet another code path. Torque server, torque shards, torque game, php website and this cumbersome java synchronizer. Too much.
The solution hit me in the head while looking for something else at my real work. Idiot, just connect Torque to a Java service via TCP!!! So simple and obvious... double shameful as Warscale is TCP based...
So, let me introduce my personal assistant, the TorqueButtler. As any well behaved buttler, I request some task to be executed and it will in time give me the result, then have my shirts ironed and still make some Grey Earl tea with ginger cookies at 5:00pm.
What is exactly TorqueButtler? Technically its a middleware server written in Java, also known as a bridge, able to execute commands Torque is unable, like HTTPS access. TorqueButtler starts an TCP server and listens on a specified port (i.e. 9999) and waits for connections and commands to arrive.
When the Warscale server starts, it will connect to the TorqueButtler using a simple TCPObject like;
new TCPObject(ButtlerClient);
ButtlerClient.connect("localhost:9999");
The Buttler will respond with a "YESMASTER?" to signal the completed connection. then I just have to send the commands. Of course I still have to code the commands in order to expand its vocabulary. Right now the Buttler can handle a simple single command which is 'https' or 'http'. You call the command from TorqueScript like:
ButtlerClient.sendCommand("https https://www.mywebsite.com/pendingorders.php?param=value", "testComplete");
Which means, connect to the specified https page, then return the results and when finished run the function testComplete. This 'when finished' condition is quite important as the process is asynchronous so a return entry point is required to process the results.
All in all, this Buttler works as a charm and I pay him peanuts. It has the intelligence of a monkey so he won't complain. I see so many possibilities in this buttler... email... ftp... format my hard drive :)
So, with the buttler in place and ready I moved some functions I had in the old java synchronizer into the main Torque Server, one less lose knot in all Warscale.
And of course, if one day you find my dead body in a pool of blood, you know who the culprit is...
More weapons
I added some more weapons to the game. Nothing really special, just retexture a sword which already existed, and take it to impressive levels via the Warscale element table, like this:






This helped me a lot into defining my material system and weapon categories. I plan to do the same with some axes as well. That way when you increase a level you will find more things to buy.
Improved invitation rewards
When the game is relaunched, any player who invites another player into the game will receive 1000gp and 10XP!!!! That way you can level up and buy more things by inviting friends... not bad right?
Nothing else.
Luck with your projects!
Guimo
#2
06/08/2011 (10:58 pm)
Impressive work! But you do realize that butler has only one "t" in it, right? :-)
#3
06/09/2011 (4:33 am)
I will excuse myself and say english is not my native language. But I can still do some refactoring and change buttler to butler. Thanks!
#4
Otherwise very fun work =)
06/14/2011 (9:14 pm)
You may also want to replace all instances of SSH with SSL, which I think is what you meant.Otherwise very fun work =)

Torque Owner Edward Smith
Silencersoft