Game Development Community

Database Access (Asset Streaming)

by James Laker (BurNinG) · in Torque Game Engine · 01/21/2009 (4:26 am) · 6 replies

Hi there.

I'm currently working on a project where I would like to use website for administration purposes to reflect ingame. This means I need SQL access. My problem with the current implementations is that each Client needs to connect to the Database. This doesn't seem right to me. A better implementation would be to send the assets from the Server/Host. For now I just need text to get sent to client.

Eg.
DB <-- SQL --> host <--> Client
                     <--> Client
                     <--> Client
Do anyone know of any Asset Streaming tech I can use?

Any input would really be appreciated.

#1
01/21/2009 (4:55 am)
If you want to pull it from an HTTP server, you could probably have a server-side PHP system that converts the database information into XML, which is then parsed on the server. If you want to directly talk to the database, you could easily roll MySQL support into your application.
#2
01/21/2009 (5:43 am)
Is this the correct way of doing it? I would think that the server/host would handle all DB requests and the Clients connecting to the Host would also receive it from there.

Can't think that nobody has implemented something like this using Torque. What about custom maps. Quake/Doom all those games actually downloads maps from the server if it's missing.
#3
01/21/2009 (6:53 am)
James - Torque already does download map files, terrain, interior files and probably some others (it doesn't do textures though) and I'm not sure about DTS files if they are missing from the client... Be warned though Torque is optimised for sending lots of small packets which is ideal for a game but is very slow for streaming files.

Also you don't want your game host to be streaming the data either as it's a slow slow process especially for large files and that can cause a lot of lag for clients already connected and playing the game.

A much better and faster solution is to build a backend patch server either using HTTP or TCP protocols and have the client connect to it using TCPOBJECT or HTTPOBJECT.. this will work by default for text and is easy to implement but for binary files (images, dts, dif files,etc) you'll need to alter those objects to accept a binary mode transfer.

The good news is there's a resource already that shows you how to do it - www.garagegames.com/community/resources/view/10800

We've used a similar approach except I use twisted Python which is much faster than a PHP script and also you should not the TCPObject loads the entire file into memory before writing to a file, this can cause game crashes if you send files over a certain size - we've changed ours to stream to a file as things are downloading to avoid the issue!!
#4
01/21/2009 (2:21 pm)
Aaah... cool. Thanks for the input. That resource is exactly what I need. I'm not too bothered about it being too slow. I'm sure Company Logos and Text wont bring the system to a halt. I'll post some test results as I go along. :)
#5
01/21/2009 (2:32 pm)
I must have totally misread this, I thought you wanted to just get statistics and such from the database.
#6
01/21/2009 (3:49 pm)
That's good to hear James, hope you get on well with it