Fun with networking and T2D
by Tom Bampton · 02/08/2006 (7:51 am) · 8 comments
I've been wanting to post this for a few days now. First, a picture ...
The Lobby

No, I'm not yakkig on about TinyIRC again. That's just in there because I'm going to need it eventually. The interesting part is below. On the surface, it's fairly uninteresting. There's a drop down that changes between a bunch of predefined nations and fills in the relevant fields. It also changes the flag. Boring ? Yes, I guess it is when you look at it like that ...
However, if you look behind the scenes:
The flag comes from a t2dImageMapDatablock. There's actually no t2dSceneGraph at that point, that's actually a GuiControl. Why? Well, I have a number of imagemaps that need to be rendered both by the TGE GUI in some circumstances and T2D in others. It was the easiest solution.
Oh, and the t2dImageMapDatablock came across the network.
Now it gets interesting ...

Ignore for a moment the rather obvious bug and I'll explain what's going on ...
The map is the same map I mentioned in previous .plans. A quick recap for those that havnt seen it: Its generated at game start using a multithreaded version of the TGE terrain generator. It takes the output of that and creates a t2dTileMap.
What the hell is going on ?
The first set of datablocks define the nations. These are sent to the clients when they join the lobby in order to populate the nation selection GUI. This includes the t2dImageMapDatablocks for the flags.
When all the clients have clicked ready the game loads. It does this in a 3 stage process similar to TGE's mission load.
The first stage loads the rest of the game data and sends those datablocks. These datablocks include all the unit definitions and the datablocks used by the map generator (they contain data needed by the client, such as more image maps).
The second stage creates the map, which is a NetObject, and starts ghosting to cause the map to be downloaded.
The third stage just takes the downloaded map data and builds the tile map.
Well, actually, thats about it at the moment. If you're wondering about the strange but slightly funny bug, its a side effect of the way I quick hacked sbMap::packUpdate() to transfer the map. There was a hell of a lot of code needed to get T2D back to the stage where this was possible and i needed a way to test NetObjects.
But what does it all *mean* ?
Real time networking. In T2D.
The Lobby

No, I'm not yakkig on about TinyIRC again. That's just in there because I'm going to need it eventually. The interesting part is below. On the surface, it's fairly uninteresting. There's a drop down that changes between a bunch of predefined nations and fills in the relevant fields. It also changes the flag. Boring ? Yes, I guess it is when you look at it like that ...
However, if you look behind the scenes:
The flag comes from a t2dImageMapDatablock. There's actually no t2dSceneGraph at that point, that's actually a GuiControl. Why? Well, I have a number of imagemaps that need to be rendered both by the TGE GUI in some circumstances and T2D in others. It was the easiest solution.
Oh, and the t2dImageMapDatablock came across the network.
Now it gets interesting ...

Ignore for a moment the rather obvious bug and I'll explain what's going on ...
The map is the same map I mentioned in previous .plans. A quick recap for those that havnt seen it: Its generated at game start using a multithreaded version of the TGE terrain generator. It takes the output of that and creates a t2dTileMap.
What the hell is going on ?
The first set of datablocks define the nations. These are sent to the clients when they join the lobby in order to populate the nation selection GUI. This includes the t2dImageMapDatablocks for the flags.
When all the clients have clicked ready the game loads. It does this in a 3 stage process similar to TGE's mission load.
The first stage loads the rest of the game data and sends those datablocks. These datablocks include all the unit definitions and the datablocks used by the map generator (they contain data needed by the client, such as more image maps).
The second stage creates the map, which is a NetObject, and starts ghosting to cause the map to be downloaded.
The third stage just takes the downloaded map data and builds the tile map.
Well, actually, thats about it at the moment. If you're wondering about the strange but slightly funny bug, its a side effect of the way I quick hacked sbMap::packUpdate() to transfer the map. There was a hell of a lot of code needed to get T2D back to the stage where this was possible and i needed a way to test NetObjects.
But what does it all *mean* ?
Real time networking. In T2D.
About the author
Recent Blogs
• A Game in 2750 Days• GID23 and NPC Editor
• Fun with Lua
• How NOT to make a game
• Thinking Outside the Box
#2
02/08/2006 (8:11 am)
fresh picked juicey
#3
This is a fairly long way off being generally usable in a manner that the average T2D user would be able to actually use since this is all fairly low level C++ and requires an understanding of how TGE networking works to be able to use it. Integrating the code with the official T2D hasnt really been discussed at this point, and any integration with T2D would have to be fairly different to what exists now. I dont want to get anyone's hopes up :)
T.
02/08/2006 (8:28 am)
Anders,This is a fairly long way off being generally usable in a manner that the average T2D user would be able to actually use since this is all fairly low level C++ and requires an understanding of how TGE networking works to be able to use it. Integrating the code with the official T2D hasnt really been discussed at this point, and any integration with T2D would have to be fairly different to what exists now. I dont want to get anyone's hopes up :)
T.
#4
Great work Tom as usual. You always seem to find something interesting to work on; how do you do that? ;)
- Melv.
02/08/2006 (10:52 am)
Nevertheless, this is still juicy and ripe. :)Great work Tom as usual. You always seem to find something interesting to work on; how do you do that? ;)
- Melv.
#5
I'm dissapointed that you didn't have 5 clients connected in that photo to truly show off the multi monitor setup though ;)
02/08/2006 (11:05 am)
Nice, just goes to show where theres a will theres a way. Why wait for official support when you can do it yourself, even if its limited to only what you need :)I'm dissapointed that you didn't have 5 clients connected in that photo to truly show off the multi monitor setup though ;)
#6
02/08/2006 (12:01 pm)
Still, seems like you have gotten a long way with it ;) And i don't plan a purchase until late summer anyway, so maybe it have advanced more by then :)
#7
02/08/2006 (9:37 pm)
awesome stuff Tom!
#8
I think it helps to be a bit mental :)
Gary,
5 clients would make the map "bug" a lot worse ;-) Besides, I don't think I have enough computers:

T.
02/08/2006 (11:05 pm)
Melv,I think it helps to be a bit mental :)
Gary,
5 clients would make the map "bug" a lot worse ;-) Besides, I don't think I have enough computers:

T.

Torque Owner Anders Norén
This means a definite purchase for my sake. I can't believe how fast T2D is advancing.