Crystal Space
Welcome, Guest. Please login or register.
April 20, 2014, 10:28:09 am

Login with username, password and session length
Search:     Advanced search
8990 Posts in 2037 Topics by 7598 Members
Latest Member: Tarafigueroa
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Problem with integrating "Torque Network Library"
« previous next »
Pages: [1] Print
Author Topic: Problem with integrating "Torque Network Library"  (Read 4515 times)
rvhaasen
Jr. Member
**
Posts: 62


View Profile
« on: October 03, 2007, 03:49:54 pm »

Both the CS libraries as well as the tnl library use static class-members, which are initialised before main()  is called.
So far no problem. However, at program termination (after the main(){..} scope has finished) there is a problem while destructing
the static components. The program crashes, giving a "corrupt" heap error. I narrowed down the problem by making a testprogram
that actually does nothing (just an empty main(){}), resulting in the same behaviour.

To be more specific: the destructor of one of the tnl classes crashes while calling free() on a pointer that has been used for malloc() in the
constructor. The crash only occurs when both the tnl and cs libraries are used in 1 application.

Also the TNLTest program (part of the tnl package) crashes in this way when i just add CS_IMPLEMENT_APPLICATION to the source, and link
it to libcrystalspace.lib

What i further see is that it has to do something with the method
Code:
csStaticVarCleanup_csutil
what could be the problem?
Logged
genjix
Jr. Member
**
Posts: 53


View Profile
« Reply #1 on: October 07, 2007, 04:49:04 pm »

Hi!

Maybe this is bad practice... but if you're making a game, why do you care about a crash on exit? Cheesy
Logged
rvhaasen
Jr. Member
**
Posts: 62


View Profile
« Reply #2 on: October 10, 2007, 09:31:01 am »

i hate any crash...
Instead of trying to solve the specific problem, i threw TNL aboard and continued with RakNet, which is one of the other network libraries...
Boht TNL and RakNet are commercial products, which are free to use for non-commercial purposes.
It's a pity that Sun has not released the C++ api of SGS http://www.projectdarkstar.com/index.php?option=com_smf&Itemid=44&topic=4.0 yet.
I think it would be a good thing to have a SGS-plugin (or another OpenSource networking library, but there are not that many) for CS.
Logged
maharaja
Jr. Member
**
Posts: 52

t.javed@hotmail.com
View Profile Email
« Reply #3 on: November 09, 2007, 02:53:20 am »

Instead of trying to solve the specific problem, i threw TNL aboard and continued with RakNet, which is one of the other network libraries...
.....
I think it would be a good thing to have a SGS-plugin (or another OpenSource networking library, but there are not that many) for CS.

Hi rvhaasen,

Are you working or intend to start working on a raknet plugin for CS?
I am personally very interested to develop a raknet plugin for CS and have been looking into it for some time.
I have not started any coding yet but have been familiarizing myself with multithreading in CS.

If you are interested we could perhaps collaborate on this?

/regards

Logged
rvhaasen
Jr. Member
**
Posts: 62


View Profile
« Reply #4 on: November 09, 2007, 01:33:33 pm »

Hi maharaja,

At the moment I implemented a class structure using CS and RakNet components. As part of the learing curve, this will most likely  change a few times. The experience gained in this way could serve as a good base for defining a CS plugin. One issue is ofcourse that RakNet is not OpenSource...
SGS would probably fit better in that respect. The emphasis of these 2 project is however a bit different. Darkstar is more focussed on massive-multiplayer involving heterogenous participants (like pc's, cell-phones etc), where RakNet is more focussed on fast and efficient communication between homogenous partners, so probably more suited for applications like fast pace shooters, not involving a "massive" amount of players.
Anyway, i am interested in multiplayer solutions for CS, lets keep in touch...


Logged
maharaja
Jr. Member
**
Posts: 52

t.javed@hotmail.com
View Profile Email
« Reply #5 on: November 09, 2007, 06:29:09 pm »

Well, that sounds like a good start Smiley

If the nature of your work is not confidential or copyrighted, I'd be very interested to look at your class structure, so perhaps we could use it as a starting point.

I do think though that either of these libraries are by themselves neither optimised for MMORPGs nor for FPS, these are just plain network libraries. The ability to support large number of players in MMORPG is usually implemented through various algorithms and techniques such as server-side extrapolation and so on. Since raknet handles UDP well it seems quite an appropriate base on which one could develop either an FPS or an MMORPG. Supporting mobile devices is certainly another issue.

I need to implement a very efficient client-server solution myself and as I understand that is what you are doing as well, so perhaps lets just build a decent client-server solution with CS and raknet first and later we can see how to create communication plugins for CS.

Let me know what you think?

/regards
Logged
rvhaasen
Jr. Member
**
Posts: 62


View Profile
« Reply #6 on: November 12, 2007, 11:56:42 am »

I do think though that either of these libraries are by themselves neither optimised for MMORPGs nor for FPS, these are just plain network libraries. The ability to support large number of players in MMORPG is usually implemented through various algorithms and techniques such as server-side extrapolation and so on. Since raknet handles UDP well it seems quite an appropriate base on which one could develop either an FPS or an MMORPG. Supporting mobile devices is certainly another issue.
i don't agree on that, RakNet is by itself not scalable such that is can be used for MMORGs, SGS on the other hand is designed with this in mind. In terms of "efficiency and speed", RakNet looks stronger. Ofcourse this is another kind of discussion, you should check the design documents (and experiment with the SDK's) if you are interested.
Anyway, to be more constructive, i can tell that i'm very pleased with the RakNet solution. I started studying the ReplicaManagerCS example of the SDK, which is a good example to get an overview. Basicaly, you derive your "synchronised class" from RakNet::Replica. After establishing a connection with your server application (in case of an client-server approach), the server can (as an example) instantiate the "synhcronised object", all connected clients will receive this "event" such that the "ghost" objects can be created. When one of the clients upates its "local gost", all other gost will be synchronised. The "syncronised class" contains just the state that needs to be synchronised, for example, a CS actor object will be connected to a "synchronised class" such that only the relevant state will be syncronised, you do not want complete object synchronisation, because this is redundant and thus inefficient. Ofcourse there are all kinds of details, but basically this is how it can be used.
The syncrhonisation part of the project is not confidential, so i can share the corresponding class structure soon (i quite busy getting my application ready..)

Logged
maharaja
Jr. Member
**
Posts: 52

t.javed@hotmail.com
View Profile Email
« Reply #7 on: November 12, 2007, 12:39:54 pm »

i don't agree on that, RakNet is by itself not scalable such that is can be used for MMORGs, SGS on the other hand is designed with this in mind. In terms of "efficiency and speed", RakNet looks stronger.

Humn.. thats interesting. I must admit I practically know nothing about SGS so not in a good position to compare, but I'd be nice if you could perhaps point out some concrete reasosn why SGS should be more suitable for MMORPG. Also, is "speed and efficiency" not one of the key requirements for an MMORPG┬┤?

Anyway, to be more constructive, i can tell that i'm very pleased with the RakNet solution. I started studying the ReplicaManagerCS example of the SDK, which is a good example to get an overview. Basicaly, you derive your "synchronised class" from RakNet::Replica. After establishing a connection with your server application (in case of an client-server approach), the server can (as an example) instantiate the "synhcronised object", all connected clients will receive this "event" such that the "ghost" objects can be created. When one of the clients upates its "local gost", all other gost will be synchronised. The "syncronised class" contains just the state that needs to be synchronised, for example, a CS actor object will be connected to a "synchronised class" such that only the relevant state will be syncronised, you do not want complete object synchronisation, because this is redundant and thus inefficient. Ofcourse there are all kinds of details, but basically this is how it can be used.

Incidently, I also just now finished reading the RakNet manual. If I'd had my own messageloop it seems simple how to integrate with RakNet. But how exactly to pass the events to CS Run() loop or actually vice-versa.. for instance at this stage I'm not clear at all on how would I catch an onKeyboard event and send it to server (for instance to replicate player movement).
Simply means I need to look more into CS event handling Smiley

The syncrhonisation part of the project is not confidential, so i can share the corresponding class structure soon (i quite busy getting my application ready..)

This would be great and probably help me much to start off with using RakNet in my CS solution.

/regards


Logged
rvhaasen
Jr. Member
**
Posts: 62


View Profile
« Reply #8 on: November 12, 2007, 04:57:16 pm »

Speed and efficiency are ofcourse alsways important issues, it is that there are more issues for a typical MMORG than for a FPS. Suppose that you were making a server for a MMORGS using a "network library" like Raknet. 10 people connect, no problem. 100 connect, no problem. 10000 connect, crash because of memory depletion, after restarting the server, all data is gone. With other words, its not enough to have your data only in memory.
More in general, how do you insure that players can continue playing without starting from 0 when a server quits for whatever reason (too many connections, no more memory etc).
More than that, you would like another server to automaticaly takeover if the main server would crash. Dealing with all these issues is not easy, SGS claims to have an opensource solution for this.
Check the faq of SGS for other issues

http://www.projectdarkstar.com/index.php?option=com_content&task=view&id=19&Itemid=37

If these issues are not important for you, a "network library" (although  RakNet is more than just that)  is sufficient.

Incidently, I also just now finished reading the RakNet manual. If I'd had my own messageloop it seems simple how to integrate with RakNet. But how exactly to pass the events to CS Run() loop or actually vice-versa.. for instance at this stage I'm not clear at all on how would I catch an onKeyboard event and send it to server (for instance to replicate player movement).
Simply means I need to look more into CS event handling Smiley

Conceptually, if you want to syncronize the position of a player, the position is the relevant state, and it is irrelevant to the synchronisation part how this state is updated. In case of a keypress, it is the new position of the object that is send to the server, and not the keypress.

you could define a function tick() that is called in the CS ProcessFrame() method of the csApplicationFramework based application.
Code:
tick()
{
  p = rakPeer->Receive();
  if (p)
  {
   ...
    rakPeer->DeallocatePacket(p);
  }
}
In this way RakNet execution occurs once per frame. The Raknet::ReplicaConstructor based class is responsible for ghost object creation.
When the position of a player has changed as result of a keypress, this has to be told to the RakNet::ReplicaManager:
Code:
replicaManager.SignalSerializeNeeded(player, UNASSIGNED_SYSTEM_ADDRESS, true); // UNASSIGNED_SYSTEM_ADDRESS, true means everybody
For a plugin module, this tick() function would actually be the ProcessFrame method of the plugin. The update of the player position from the main application class should then trigger an event that will be handled by the network plugin.

If CEL would be used as a "starting point" (instead of core CS), the PropertyClass mechanism could be used to send events to the network plugin, this could be an elegant solution....
Logged
maharaja
Jr. Member
**
Posts: 52

t.javed@hotmail.com
View Profile Email
« Reply #9 on: November 19, 2007, 11:54:53 pm »

Hi,

As this discussion has changed to RakNet, so I continue it in the new thread "CS and RakNet" here:

http://www.crystalspace3d.org/forum/index.php/topic,1511.0.html

Hope you'd find it Smiley

/regards
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 9.563 seconds with 16 queries.