mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
Merge pull request #2267 from calvinbalke13/feature-netcode-fix
Network Code Fixes
This commit is contained in:
commit
d6784957f4
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -694,12 +694,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);
|
||||||
}
|
}
|
||||||
|
|
@ -839,13 +839,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) {
|
||||||
|
|
@ -866,6 +869,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