Syncing Classes between Server and Client
by Triad · in Torque Developer Network · 11/21/2011 (8:13 am) · 2 replies
Hello.
I've recently volunteered to help with a game called Legions Overdrive (used to be called Fallen Empire: Legions) which has lost a lot of its developers, and one of my first tasks is to get the dedicated Linux server binary to communicate properly with Windows client. A previous developer told me that the "classes are out of sync", but I'm not quite sure which classes I need to be looking at yet, and if I should be looking more at the TorqueScript or the C++. I've compiled the dedicated Linux server on Ubuntu running in VirtualBox, but the client crashes every time I try and connect to the server. I haven't been able to see anything in the source that I would need to fix because there's just thousands of lines of networking code as well as the fact that I'm new to Torque. I've been debugging through the application a lot, but there's just so much I don't understand yet because the engine is huge.
The problem I've been able to see so far is the server is sending packets to the client which it doesn't understand and isn't expecting so it ends up crashing with an "out of range error". I've Googled around for all the errors that are occurring such as the one just stated, but they don't say what the cause is because the cause could be many things. One particular post dealing with the "out of range error" said that the client thinks it should be receiving more than what it has gotten so it keeps requesting packets until the buffer overflows.
Before the crash occurs the application is usually trying to download sky information (dml file) or map information (mis file). I'm running both the server and client with the exact same scripts, and it'd be nice if I could debug the scripts, but I don't have the Torsion program to do that. I've spent countless hours trying different debugging techniques to help me figure out what the actual problem is, but I haven't been able to make any real progress. I'm not sure if I need to be spending more time in the scripts with things like datablocks, or more time in the C++ with the network objects to fix the problem.
If you think you have an idea as to what I need to be looking at to fix this problem, please let me know.
Many thanks,
Triad
I've recently volunteered to help with a game called Legions Overdrive (used to be called Fallen Empire: Legions) which has lost a lot of its developers, and one of my first tasks is to get the dedicated Linux server binary to communicate properly with Windows client. A previous developer told me that the "classes are out of sync", but I'm not quite sure which classes I need to be looking at yet, and if I should be looking more at the TorqueScript or the C++. I've compiled the dedicated Linux server on Ubuntu running in VirtualBox, but the client crashes every time I try and connect to the server. I haven't been able to see anything in the source that I would need to fix because there's just thousands of lines of networking code as well as the fact that I'm new to Torque. I've been debugging through the application a lot, but there's just so much I don't understand yet because the engine is huge.
The problem I've been able to see so far is the server is sending packets to the client which it doesn't understand and isn't expecting so it ends up crashing with an "out of range error". I've Googled around for all the errors that are occurring such as the one just stated, but they don't say what the cause is because the cause could be many things. One particular post dealing with the "out of range error" said that the client thinks it should be receiving more than what it has gotten so it keeps requesting packets until the buffer overflows.
Before the crash occurs the application is usually trying to download sky information (dml file) or map information (mis file). I'm running both the server and client with the exact same scripts, and it'd be nice if I could debug the scripts, but I don't have the Torsion program to do that. I've spent countless hours trying different debugging techniques to help me figure out what the actual problem is, but I haven't been able to make any real progress. I'm not sure if I need to be spending more time in the scripts with things like datablocks, or more time in the C++ with the network objects to fix the problem.
If you think you have an idea as to what I need to be looking at to fix this problem, please let me know.
Many thanks,
Triad
#2
While debugging, the application starts unpacking data in this function in net.cpp. It loads things like the mission file (.mis), the game type (CTF or DTM), and the map name, and some other stuff that looks like garbage but it could just be compressed data.
It then pops back out to eventReadPacket also in net.cpp and makes it way down to the line:
evt->unpack(this, bstream);
Inside of that function it jumps down to mObj->unpackData(bstream); (PrecipitationData::unpackData)
then into mDropName = stream->readSTString();
then into Stream::readString(buf);
then into Stream::readFlag()
then into
I've also seen it come here as well in bitStream.cpp since it will crash in different places on different runs.
Thanks for your time.
11/21/2011 (9:18 am)
The game runs fine when connecting to another windows server. We're using the TGEA engine by the way.While debugging, the application starts unpacking data in this function in net.cpp. It loads things like the mission file (.mis), the game type (CTF or DTM), and the map name, and some other stuff that looks like garbage but it could just be compressed data.
virtual void unpack(NetConnection* conn, BitStream *bstream)
{
mArgc = bstream->readInt(CommandArgsBits);
// read it out backwards
for(S32 i = 0; i < mArgc; i++)
{
conn->unpackString(bstream, mBuf);
mArgv[i+1] = dStrdup(mBuf);
}
}It then pops back out to eventReadPacket also in net.cpp and makes it way down to the line:
evt->unpack(this, bstream);
Inside of that function it jumps down to mObj->unpackData(bstream); (PrecipitationData::unpackData)
then into mDropName = stream->readSTString();
then into Stream::readString(buf);
then into Stream::readFlag()
then into
inline bool BitStream::readFlag()
{
if(bitNum > maxReadBitNum)
{
error = true;
AssertFatal(false, "Out of range read");
return false;
}
S32 mask = 1 << (bitNum & 0x7);
bool ret = (*(dataPtr + (bitNum >> 3)) & mask) != 0;
bitNum++;
return ret;
}I've also seen it come here as well in bitStream.cpp since it will crash in different places on different runs.
void BitStream::readBits(S32 bitCount, void *bitPtr)
{
if(!bitCount)
return;
if(bitCount + bitNum > maxReadBitNum)
{
error = true;
//AssertFatal(false, "Out of range read");
AssertWarn(false, "Out of range read");
return;
}
U8 *stPtr = dataPtr + (bitNum >> 3);
S32 byteCount = (bitCount + 7) >> 3;
U8 *ptr = (U8 *) bitPtr;
S32 downShift = bitNum & 0x7;
S32 upShift = 8 - downShift;
U8 curB = *stPtr;
while(byteCount--)
{
U8 nextB = *++stPtr;
*ptr++ = (curB >> downShift) | (nextB << upShift);
curB = nextB;
}
bitNum += bitCount;
}Thanks for your time.
Associate Chris Haigler
Jester Dance
Does the game run correctly when connecting to a Windows-based server?