Game Development Community

Duplicate Namespace Functions possible?

by Robert \"Roswell_r\" · in Torque Game Engine · 03/25/2008 (8:48 pm) · 3 replies

Greetings,

This is my first post. Ive familiarized myself somewhat with the engine already and have got a little project up and running. What this project is made up of is a client, menu server, game server. Now what I have already setup and got successfully working is a client which when first run connects to a (offline) menu server so I can display a camera view from the level stored locally on the machine.

This makes for a nice title/main menu page with sound and groovy clouds in the background. But ive encountered a problem and that is having duplicate server code. Now I can't merge the 2 together because I need to keep the server code clean and on its own because it will be used as a dedicated server in the end.

So what this means is I have duplicate namespace defined functions such as: GameConnection::onConnectRequest and onDataBlockObjectReceived etc... which stops the mission from loading. Now I could put a if statement in there to determine if its the menu server running or the local server running but that is a last resort, I was just wondering if there was a way to have both co-existing, or if there was a way to disable one of the functions/events?

I appreciate your help if given.

#1
03/25/2008 (9:10 pm)
You should take a look at the documentation for packages, and only activate the package appropriate for the state your client and server are in.
#2
03/25/2008 (9:10 pm)
Yes you can
Use packages. That allows you to enable / disable blocks of implementations.
#3
03/26/2008 (12:03 am)
So this will allow me to disable and enable packages which contain namespace functions aswell as event functions such as onDataBlockObjectReceived? because I have attempted this already and not had any luck. Though my code may be incorrect.

I have several exec statements in my package { branch which include scripts for the menu server. I also ensure I close the package with }; This works fine, I can activate the menu server package, run the menu server but when i destroy the menu server and deactivate the package using deactivatePackage("packagename"); and activate my new package the particular onDataBlockObjectRecieved event is invoked in the menu package even though the menu package has been deactivated plus my new server package has been activated.

Edit: is there a way to show which packages are activated?

Edit2: Seems i was able to sort my problems out. It seems the package statement does not associate functions in exec statements with the package. After putting the 'package menuPackage {' under each file associated for it it seem to have fixed the problem.

Thanks for your posts.