Game Development Community

TGEA 1.8 Beta 1 - RemoveCommandEvent::getDebugName() fixed

by Fyodor -bank- Osokin · in Torque Game Engine Advanced · 12/01/2008 (12:24 pm) · 4 replies

Intro: I started experiencing some weird behaviour in my project so tried enabling TORQUE_DEBUG_NET so I can track down whats wrong...
So far no luck as I met another weird thing:
in netEvent.cpp
NetConnection::eventWritePacket()
there is a line:
DEBUG_LOG(("PKLOG %d EVENT %d: %s", getId(), bstream->getBitPosition() - start, ev->mEvent->getDebugName()) );
(in two places).
Actually it works for everything except for "RemoteCommandEvent" class, as it put on log strange stuff, here is an example from console.log (i've modified sources only to dump info about events, as GHOST and other are gives too much spam into console.log):
PKLOG 2443 EVENT 100: NetStringEvent - "MsgLoadInfoDone"
PKLOG 2443 EVENT 23: RemoteCommandEvent [(null)]
PKLOG 2443 EVENT 82: NetStringEvent - "MsgClientJoin"
PKLOG 2443 EVENT 197: NetStringEvent - "Welcome to a Torque application %1."
PKLOG 2443 EVENT 99: NetStringEvent - "Visitor"
PKLOG 2443 EVENT 112: RemoteCommandEvent [(null)]
PKLOG 2443 EVENT 108: NetStringEvent - "MissionStartPhase1"
PKLOG 2443 EVENT 279: RemoteCommandEvent [MsgClientScoreChanged]
PKLOG 2443 EVENT 36: SetMissionCRCEvent
PKLOG 2443 EVENT 52: ConnectionMessageEvent
PKLOG 2443 EVENT 110: NetStringEvent - "MissionStartPhase2"
PKLOG 2443 EVENT 279: RemoteCommandEvent [Kork]
PKLOG 2443 EVENT 1541: PathManagerEvent
PKLOG 2443 EVENT 52: ConnectionMessageEvent
PKLOG 2443 EVENT 52: ConnectionMessageEvent
PKLOG 2443 EVENT 110: NetStringEvent - "MissionStartPhase3"
PKLOG 2443 EVENT 279: RemoteCommandEvent [ServerMessage]
PKLOG 2443 EVENT 75: NetStringEvent - "MissionStart"
PKLOG 2443 EVENT 27: RemoteCommandEvent [base]
PKLOG 2443 EVENT 73: NetStringEvent - "SyncClock"
PKLOG 2443 EVENT 68: RemoteCommandEvent [Visitor]
Can it be (null) ? And the others like "Kork" and "Visitor" also seems bad to me.
Looks like the RemoveCommandEvent::getDebugName() is broken, as it reports wrong string value.

For my project it reports random tagged string contents, even if none of those objects are being ghosted (but tagged string exists on server).

Haven't found solution yet.

P.S. Same for TGE 1.5.2 and it seems to me for every other Torque product, as all shares the same "sim" logic.

#1
12/01/2008 (1:08 pm)
Okay. After testing it more I have more details on this:
Marking server with ">" and client with "<".
// On server:
function testNet(%client)
{
   commandToClient(%client, 'TESTbegin');
   for(%i=0;%i<3;%i++)
      commandToClient(%client, 'TEST', "blah" @ %i);
   commandToClient(%client, 'TESTend');
}
// On client:
function clientCmdTESTbegin() { echo("Testing started!"); }
function clientCmdTEST(%var1) { echo("clientCmdTEEST():" SPC %var1); }
function clientCmdTESTend() { echo("Testing finished!"); }
Result:
> PKLOG 20804 EVENT 64: NetStringEvent - "TESTbegin"
< Mapping string: TESTbegin to index: 17
< Testing started!

> PKLOG 20804 EVENT 73: NetStringEvent - "TEST"
< Mapping string: TEST to index: 18
> PKLOG 20804 EVENT 48: RemoteCommandEvent [Corpse of Razor]
< clientCmdTEST(): blah0

> PKLOG 20804 EVENT 48: RemoteCommandEvent [Corpse of Razor]
< clientCmdTEST(): blah1

> PKLOG 20804 EVENT 46: RemoteCommandEvent [Corpse of Razor]
< clientCmdTEST(): blah2

> PKLOG 20804 EVENT 55: NetStringEvent - "TESTend"
< Mapping string: TESTend to index: 19
< Testing finished!
"Corpse of Razor" is a tagged string stored (during startup) in global var on server like
$mobName["razor","dead"] = 'Corpse of Razor';
but... I don't even have razors spawned on server!
And more - if run more different "commandToClient" I'll get different RemoteCommandEvent [weirds].
Definitely the problem is here:
const char *getDebugName()
   {
      static char buffer[256];
      dSprintf(buffer, sizeof(buffer), "%s [%s]", getClassName(), gNetStringTable->lookupString(dAtoi(mArgv[1] + 1)) );
      return buffer;
   }

Going deeper into the net-logic on Torque... (hey, I need more coffee!)
#2
12/01/2008 (1:45 pm)
Okay.
The problem of "bad reporting" is because while in RemoteCommandEvent() in mArgv[] assigned the netSendId() for current connection.
For example the actual "index" from netstringtable is (f.e.) 22, but on mArgv it's assigned the 13 (netSendId).

So, the output from RemoteCommandEvent::getDebugName() is really worthless.

Now looking for a quick hack to make it working, so I can continue resolving my (original) problem :)

Will post here as soon as I find workaround.
#3
12/01/2008 (1:55 pm)
That was easy task as soon I understood the logic:
Changes in net.cpp
From:
const char *getDebugName()
   {
      static char buffer[256];
      dSprintf(buffer, sizeof(buffer), "%s [%s]", getClassName(), gNetStringTable->lookupString(dAtoi(mArgv[1] + 1)) );
      return buffer;
   }
To:
const char *getDebugName()
   {
      static char buffer[256];
      dSprintf(buffer, sizeof(buffer), "%s [%s]", getClassName(), mTagv[1].isValidString() ? mTagv[1].getString() : "--unknown--");
      return buffer;
   }
I'm validating string "just in case" as not sure for 100% if there is always a valid string :)

As far as I know this applied to all engines.

Thanks for assistance! :) hehe
Now back to debugging network with dedicated serverS and remote client! Phew!
#4
12/01/2008 (2:47 pm)
Confirmed. Thanks for reporting and many more thanks for digging into and even fixing this.