Plan for Tom Bampton
by Tom Bampton · 05/30/2005 (4:45 am) · 4 comments
I've been musing over putting TinyIRC into Torque for a good year or two now. Work started on TinyIRC 3 in semi-secretness a few months back, and when the new core got to a usable stage, I finally got around to putting my money where my mouth is.

Admittedly, that screenshot doesnt show very much. However, the road to the screenshot is a an interesting one.
The original plan was to do the Torque interface along the lines of the Lua plugin in TinyIRC 2. That is, TinyIRC is a seperate entity and Torque provides some script interfaces. That would let me do the UI completely in Torque script whilst keeping the core virtually unchanged from the core used in TinyIRC itself. The general idea behind that being that it would be easier to keep both versions upto date with bug fixes etc, as well as open doors for other uses of the code.
The big stumbling block for that plan was Torque is not threadsafe, but TinyIRC is multithreaded. For the plan to work, I had to be able to call script code from any thread. At first glance, that seemed like a daunting task. After a quick chat with Ben, a general plan was formed and this morning I got it working nicely.
I threadsafed the Sim::postEvent() function (and related functions) and wrote a Con::threadSafeExecute() function that uses the same idea behind schedule() to call the script code. The only caveat is since the script function doesnt execute til the next tick, they can't return values to the C++ code. That is a bit of a pain but it's a lot better then spending days or weeks threadsafing the whole console. I'll be sending patches for that to Ben later.
The general plan for TinyIRC 3 + Torque is to create an IRC pack. Primarily it will be a modern IRC client in Torque tailored towards games. I'm planning on providing a choice of at least 2 UIs: the first a very simple chat lobby; the second a more complex game chat system akin to a desktop IRC client.
Aside from the obvious, TinyIRC 3 brings some other useful things to the Torque table. The multithreaded TCP/IP networking code allows incredibly easy and efficient implementation of most Internet protocols without affecting the game. The event dispatcher is flexible enough to be put to good use for other protocols besides IRC, or even in game code. By the time the IRC pack is finished, enough of Torque will have been threadsafed to allow for some interesting uses of threading. For example, you could do all your AI calculations in a seperate thread and use TI3 events to tell the game logic what's going on.
As a proof of concept, I've been pondering writing a threaded replacement for HTTPObject using TI3 and hooking it up to a GuiMLTextCtrl to create a mini web browser in TGE. There is also a possibility of an HTTP server as well as other nifty things.
This .plan barely scratches the surface, but I'd rather be writing the code then writing about it, so that's your lot for now. Some things may not be that clear from the above, so feel free to ask any questions. That said, don't bother asking for an ETA, I'm doing this in my spare time at the moment, and spare time isnt exactly in abundance right now.

Admittedly, that screenshot doesnt show very much. However, the road to the screenshot is a an interesting one.
The original plan was to do the Torque interface along the lines of the Lua plugin in TinyIRC 2. That is, TinyIRC is a seperate entity and Torque provides some script interfaces. That would let me do the UI completely in Torque script whilst keeping the core virtually unchanged from the core used in TinyIRC itself. The general idea behind that being that it would be easier to keep both versions upto date with bug fixes etc, as well as open doors for other uses of the code.
The big stumbling block for that plan was Torque is not threadsafe, but TinyIRC is multithreaded. For the plan to work, I had to be able to call script code from any thread. At first glance, that seemed like a daunting task. After a quick chat with Ben, a general plan was formed and this morning I got it working nicely.
I threadsafed the Sim::postEvent() function (and related functions) and wrote a Con::threadSafeExecute() function that uses the same idea behind schedule() to call the script code. The only caveat is since the script function doesnt execute til the next tick, they can't return values to the C++ code. That is a bit of a pain but it's a lot better then spending days or weeks threadsafing the whole console. I'll be sending patches for that to Ben later.
The general plan for TinyIRC 3 + Torque is to create an IRC pack. Primarily it will be a modern IRC client in Torque tailored towards games. I'm planning on providing a choice of at least 2 UIs: the first a very simple chat lobby; the second a more complex game chat system akin to a desktop IRC client.
Aside from the obvious, TinyIRC 3 brings some other useful things to the Torque table. The multithreaded TCP/IP networking code allows incredibly easy and efficient implementation of most Internet protocols without affecting the game. The event dispatcher is flexible enough to be put to good use for other protocols besides IRC, or even in game code. By the time the IRC pack is finished, enough of Torque will have been threadsafed to allow for some interesting uses of threading. For example, you could do all your AI calculations in a seperate thread and use TI3 events to tell the game logic what's going on.
As a proof of concept, I've been pondering writing a threaded replacement for HTTPObject using TI3 and hooking it up to a GuiMLTextCtrl to create a mini web browser in TGE. There is also a possibility of an HTTP server as well as other nifty things.
This .plan barely scratches the surface, but I'd rather be writing the code then writing about it, so that's your lot for now. Some things may not be that clear from the above, so feel free to ask any questions. That said, don't bother asking for an ETA, I'm doing this in my spare time at the moment, and spare time isnt exactly in abundance right now.
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
Torque Owner N R Bharathae