NetStringTable Changes
by Mark Frohnmayer · in Torque Game Engine · 04/21/2002 (1:44 pm) · 3 replies
Hey all,
I just checked in some fairly major changes to the way that the NetStringTable class works and manages strings across the network.
Original purpose: The idea behind the NetStringTable is to manage a list of strings that continually get sent across the net. This can be the name of remote console commands (commandToServer('doSomethingPlease')) or the names of players, or string messages that get sent often ('Your flag has been taken!').
How it worked before: Strings were added to the table using addString() which returned a U32 identifier. Strings were ref counted, so the same string added multiple times would work fine. Strings were removed with removeString(id). Also, the NetStringTable was a fixed size. Adding more tagged strings '' to the table than would fit would cause undefined behavior.
In this system (totally manually ref counted), we ended up with the potential for lots of unwanted ref counting bugs.
New system: Net strings are allocated using StringHandles, which manage the reference counting automatically. I also prepared the way for uncapping the limit on NetStringTable entries (right now the table size is still capped), by making the NetConnection manage a window of currently cached network strings.
Currently I've set the connection's 'string window' to have 32 elements. This is only for debugging... it is likely that any problems will show up much sooner with a window size of 32 than of 1024 (which is likely to be the final #).
I also bumped the net protocol #.
Anyway, the brave among you who wish to do a sync to the head revision and test out the new stuff are welcome to do so :)
I just checked in some fairly major changes to the way that the NetStringTable class works and manages strings across the network.
Original purpose: The idea behind the NetStringTable is to manage a list of strings that continually get sent across the net. This can be the name of remote console commands (commandToServer('doSomethingPlease')) or the names of players, or string messages that get sent often ('Your flag has been taken!').
How it worked before: Strings were added to the table using addString() which returned a U32 identifier. Strings were ref counted, so the same string added multiple times would work fine. Strings were removed with removeString(id). Also, the NetStringTable was a fixed size. Adding more tagged strings '' to the table than would fit would cause undefined behavior.
In this system (totally manually ref counted), we ended up with the potential for lots of unwanted ref counting bugs.
New system: Net strings are allocated using StringHandles, which manage the reference counting automatically. I also prepared the way for uncapping the limit on NetStringTable entries (right now the table size is still capped), by making the NetConnection manage a window of currently cached network strings.
Currently I've set the connection's 'string window' to have 32 elements. This is only for debugging... it is likely that any problems will show up much sooner with a window size of 32 than of 1024 (which is likely to be the final #).
I also bumped the net protocol #.
Anyway, the brave among you who wish to do a sync to the head revision and test out the new stuff are welcome to do so :)
About the author
Torque Owner Bryan "daerid" Ross