mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Network Code Fixes
This should be backwards compatible with existing network code, however it fixes a bug.
This commit is contained in:
parent
6e60bf5fec
commit
24071f06e2
1 changed files with 10 additions and 4 deletions
|
|
@ -140,7 +140,7 @@ class HuffmanProcessor
|
||||||
|
|
||||||
static HuffmanProcessor g_huffProcessor;
|
static HuffmanProcessor g_huffProcessor;
|
||||||
|
|
||||||
bool readHuffBuffer(BitStream* pStream, char* out_pBuffer);
|
bool readHuffBuffer(BitStream* pStream, char* out_pBuffer, S32 maxLen);
|
||||||
bool writeHuffBuffer(BitStream* pStream, const char* out_pBuffer, S32 maxLen);
|
bool writeHuffBuffer(BitStream* pStream, const char* out_pBuffer, S32 maxLen);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -667,12 +667,12 @@ void BitStream::readString(char buf[256])
|
||||||
if(readFlag())
|
if(readFlag())
|
||||||
{
|
{
|
||||||
S32 offset = readInt(8);
|
S32 offset = readInt(8);
|
||||||
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, stringBuffer + offset);
|
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, stringBuffer + offset, 256 - offset);
|
||||||
dStrcpy(buf, stringBuffer, 256);
|
dStrcpy(buf, stringBuffer, 256);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, buf);
|
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, buf, 256);
|
||||||
if(stringBuffer)
|
if(stringBuffer)
|
||||||
dStrcpy(stringBuffer, buf, 256);
|
dStrcpy(stringBuffer, buf, 256);
|
||||||
}
|
}
|
||||||
|
|
@ -812,13 +812,16 @@ S16 HuffmanProcessor::determineIndex(HuffWrap& rWrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HuffmanProcessor::readHuffBuffer(BitStream* pStream, char* out_pBuffer)
|
bool HuffmanProcessor::readHuffBuffer(BitStream* pStream, char* out_pBuffer, S32 maxLen=256)
|
||||||
{
|
{
|
||||||
if (m_tablesBuilt == false)
|
if (m_tablesBuilt == false)
|
||||||
buildTables();
|
buildTables();
|
||||||
|
|
||||||
if (pStream->readFlag()) {
|
if (pStream->readFlag()) {
|
||||||
S32 len = pStream->readInt(8);
|
S32 len = pStream->readInt(8);
|
||||||
|
if (len >= maxLen) {
|
||||||
|
len = maxLen;
|
||||||
|
}
|
||||||
for (S32 i = 0; i < len; i++) {
|
for (S32 i = 0; i < len; i++) {
|
||||||
S32 index = 0;
|
S32 index = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
@ -839,6 +842,9 @@ bool HuffmanProcessor::readHuffBuffer(BitStream* pStream, char* out_pBuffer)
|
||||||
} else {
|
} else {
|
||||||
// Uncompressed string...
|
// Uncompressed string...
|
||||||
U32 len = pStream->readInt(8);
|
U32 len = pStream->readInt(8);
|
||||||
|
if (len >= maxLen) {
|
||||||
|
len = maxLen;
|
||||||
|
}
|
||||||
pStream->read(len, out_pBuffer);
|
pStream->read(len, out_pBuffer);
|
||||||
out_pBuffer[len] = '\0';
|
out_pBuffer[len] = '\0';
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue