Game Development Community

Getting started with Torque's networking

by Ade · in Technical Issues · 06/26/2006 (4:23 am) · 6 replies

I know a lot about networking, but the thought of having to write my own networking code for a game from scratch fills me with a mild feeling of fear.
So how easy is it to get going and write an online game, not massively multiplayer - for
1) played on the lan at work
2) hosted over the internet

Is all the message sending handled by Torque or do we have to define the messages/structures/players joining and leaving the game/ etc

cheers

#1
07/11/2006 (8:10 am)
Torque out of the Box does support LAN and Internet multiplayer capabilities. Not many changes if any are needed for a FPS clone.
#2
07/11/2006 (11:26 am)
In fact, Torque is so multiplayer-centric that a single player game still has a server, just run on the same local machine as the client. I think it would be harder to write a game that didn't use a client-server architecture at all with Torque than to create a game that had a natural tendency toward being multiplayer.
#3
10/01/2006 (9:43 am)
That's very encouraging to hear, but I haven't found any good (or even poor) examples of how to take a game that works on my standalone system and configure it to run on my LAN. Can you point me to even the most basic examples of real scripts?
#4
10/01/2006 (10:40 am)
The stock TGE demo FPS game runs either standalone or LAN or internet.
when you launch it on one computer just click "start server" or "host multiplayer" or whatever it is,
then on the other computer on the lan click "query lan" to find it.
#5
11/10/2006 (1:31 pm)
I'm glad I found this thread! Could someone shed some light on how to make the TGE demo FPS run across the internet. Do I need a master and dedicated server to do this? Thank you for the help.
#6
01/24/2007 (11:24 pm)
This can help:

Article Author: http://www.garagegames.com/my/home/view.profile.php?qid=40475

If you're developing a multiplayer game,
it can sometimes (often) get confusing what's on the server and what's on the client,
especially if you're running a single instance of torque as both server and client, which is the default mode.

for example, maybe you define function MyFoo() in client/init.cs.
in actual deployment, a dedicated server won't know about MyFoo() because only the clients have it defined.
but when running client and server as a single instance, the server *will* see MyFoo(),
and this can lead to unclear thinking and designing on your part,
and a game which works great when the server is also a client will totally fall apart with a dedicated server.

even if you're not planning on running a dedicated server for your multiplayer game,
it's still a good idea to run the server & client as seperate instances, because if you run them as a single instance the client will see all the server-only functions, and you're in the same situation as above.

so on to the tip:

make it your SOP to run w/ a dedicated server.

since this can be a little bit of a hassle,
here's what i do in windows to make launching the server quick and painless, so that i actually do it.
linux folks probably already do this sort of thing anyhow.

1. make a folder somewhere called 'mybin' and add it to your PATH.
1a. eg, i have c:\orionbin.
1b. PATH is accessible via control panel | system | advanced | envionment variables.
eg, i have ";c:\orionbin" appended to the end.

2. make a shortcut to your TorqueExecutable.exe, and copy that shortcut into 'mybin'.

3. rename the shortcut 'runserver'.

4. edit the shortcut's properties, and append the -dedicated and -mission flags to the "target" field.
eg, i have ".....\TorqueExecutable.exe -dedicated -mission mygame/data/missions/mymission.mis"

5. to launch a dedicated server, all you need to do is hit the windows key, select run, and enter 'runserver'.


more tip:

6. connecting a client to the server is easy, just use this console command:

new GameConnection().connect("localhost:28000");



6a. being a very lazy sort, i shortened this command to a function in client\scripts\client.cs:

function connectLocal()
{
new GameConnection().connect("localhost:28000");
}




yet more tip:

7. having a little folder for shortcuts in your PATH is really handy.
i put shortcuts to my regularly used folders in there,
for example instead of browsing all the way to "c:\people\orion\work\subversion\trunk\torque\myGame",
i just create a shortcut to myGame, put it in my orionBin folder, rename it 'gogame', and voila! - just a few keystrokes gets me where i want.


http://www.garagegames.com/mg/forums/result.thread.php?qt=56605

http://www.garagegames.com/docs/tge/general/apbs05.php

Basically all you need is to run demoFPS in dedicated server mode (by suppying proper arguments), then run clients with arguments to where they should connect (to your server's IP).