I would like to make a post about a few little things I observed with Thing creation/removal and multiplayer unsynced cogs. When testing CW mod in multiplayer, I noticed a little thing that should not have been. There is a scope section in a cog that runs using a very fast pulse, the cog is flagged to be totally unsynced. The problem was that whenver I toggled a scope, lag would errupt. I typed in the ping command many times and, ping skyrocketed up to about 2000msec and more for extended periods of time. Something I should point out is that the scope uses Things for a crosshair image, a scope "camera", and a "look vector" template. In the first version of this code, each of these was rapidly created, camera would be set, then destroyed in the next pulse where the camera would be created and set again. This was somehow causing lag in multiplayer, yet the cog was totally local.
So I came up with a theory of why there seemed to be lag produced by the scope code. You know, JK never seems to mess up the Thing count and ID system in multiplayer, not even with locally created and destroyed Things. It must be because the every Thing created, local or not, must be logged somehow to prevent confusion with other Things on other sides of the game.
Take this scenario for example. I have a locally created thing on my side of the game and it is ID'ed as Thing # 1337. That will make the next thing created in the game be Thing # 1338, but what about the other players game? On his side of the game, Thing # 1337 does not exist. The next thing created in his side will be # 1337. So lets say a new thing is created now globally. When a verb or whatever code is executed on that thing, how does it manage to execute on the correct Thing on all sides of the game when the Thing count is not synchronized? That's the thing, the count must be synchronized. Anything in a local cog is not sent across the network, but if a thing is created locally, it is forced to keep the count and ID's up to date.
Also something that adds to this theory is that I simplified my scope code to have less thing creations. Instead of creating a scope image Thing, scope "camera" Thing, and a "look vector" Thing rapidly, I created the image and scope "camera" Things only once, only to be reoriented every pulse. I did this instead of having Things created and destroyed in a new position every pulse, so I would no longer be messing with the Thing count at an extreme rate. The "look vector" remained rapidly created and destroyed though because it was my only way to retrieve the player's "true" look vector. I had this tested immediatelly in multiplayer and the lag was significantly reduced to something waaay more acceptable for my 56k. The ping commands I ran rocketed up to about 700msec instead of something close to 2000msec when I toggled the scope.
I posted this for all too see because I know it is usefull when dealing with local cogs. It is especially usesfull for a camera or scope I have just described, and is most essential for a Thing-based first-person weapon.
I am not entirely sure how the JK engine works with these sorts of things and I might not be entirely correct, but it seems to have worked for my own modding purposes.
[edit] I mispelled Theory in the thread title.
So I came up with a theory of why there seemed to be lag produced by the scope code. You know, JK never seems to mess up the Thing count and ID system in multiplayer, not even with locally created and destroyed Things. It must be because the every Thing created, local or not, must be logged somehow to prevent confusion with other Things on other sides of the game.
Take this scenario for example. I have a locally created thing on my side of the game and it is ID'ed as Thing # 1337. That will make the next thing created in the game be Thing # 1338, but what about the other players game? On his side of the game, Thing # 1337 does not exist. The next thing created in his side will be # 1337. So lets say a new thing is created now globally. When a verb or whatever code is executed on that thing, how does it manage to execute on the correct Thing on all sides of the game when the Thing count is not synchronized? That's the thing, the count must be synchronized. Anything in a local cog is not sent across the network, but if a thing is created locally, it is forced to keep the count and ID's up to date.
Also something that adds to this theory is that I simplified my scope code to have less thing creations. Instead of creating a scope image Thing, scope "camera" Thing, and a "look vector" Thing rapidly, I created the image and scope "camera" Things only once, only to be reoriented every pulse. I did this instead of having Things created and destroyed in a new position every pulse, so I would no longer be messing with the Thing count at an extreme rate. The "look vector" remained rapidly created and destroyed though because it was my only way to retrieve the player's "true" look vector. I had this tested immediatelly in multiplayer and the lag was significantly reduced to something waaay more acceptable for my 56k. The ping commands I ran rocketed up to about 700msec instead of something close to 2000msec when I toggled the scope.
I posted this for all too see because I know it is usefull when dealing with local cogs. It is especially usesfull for a camera or scope I have just described, and is most essential for a Thing-based first-person weapon.
I am not entirely sure how the JK engine works with these sorts of things and I might not be entirely correct, but it seems to have worked for my own modding purposes.
[edit] I mispelled Theory in the thread title.
visit my project
"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman