2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-28 15:45:46 +03:00

Merge pull request #457 from s1lentq/hltv-patch1

HLTV: Fix crash and small refactoring.
This commit is contained in:
Dmitry Novikov 2017-05-05 19:06:31 +03:00 committed by GitHub
commit f2b080ebba
6 changed files with 49 additions and 56 deletions

View File

@ -644,12 +644,6 @@ void System::Sleep(int msec)
bool System::InitFileSystem()
{
char *filesystemmodule = STDIO_FILESYSTEM_LIB;
#ifdef _WIN32
if (CheckParam("-steam")) {
filesystemmodule = STEAM_FILESYSTEM_LIB;
}
#endif // _WIN32
m_FileSystemModule = Sys_LoadModule(filesystemmodule);
if (!m_FileSystemModule)
{

View File

@ -1508,7 +1508,7 @@ void Server::ParseDeltaPacketEntities()
{
int entnum = m_Instream->ReadShort();
if (entnum > MAX_PACKET_ENTITIES) {
m_System->Errorf("Server::ParsePacketEntities: entnum > MAX_PACKET_ENTITIES.\n");
m_System->Errorf("Server::ParseDeltaPacketEntities: entnum > MAX_PACKET_ENTITIES.\n");
}
m_Frame.delta = 0;

View File

@ -234,7 +234,7 @@ protected:
char m_CDKey[32];
int m_AuthProtocol;
frame_t m_Frame;
unsigned char m_EntityBuffer[87040];
unsigned char m_EntityBuffer[MAX_PACKET_ENTITIES * sizeof(entity_state_t)];
int m_Rate;
int m_UpdateRate;
float m_Time;

View File

@ -1060,65 +1060,65 @@ void World::ParseClientData(BitBuffer *stream, unsigned int deltaSeqNr, BitBuffe
}
}
int World::ParseDeltaHeader(BitBuffer *stream, bool *remove, bool *custom, int *numbase, bool *newbl, int *newblindex, bool full, int *offset)
int World::ParseDeltaHeader(BitBuffer *stream, bool &remove, bool &custom, int &numbase, bool &newbl, int &newblindex, bool full, int &offset)
{
int num;
bool isdelta, isnext;
*custom = false;
*newbl = false;
offset = 0;
custom = false;
newbl = false;
if (full)
{
*remove = false;
if (stream->ReadBit() != 0)
{
num = *numbase + 1;
}
else if (stream->ReadBit() == 0)
{
num = stream->ReadBits(6) + *numbase;
}
else
{
num = stream->ReadBits(11);
}
isdelta = stream->ReadBit() ? true : false;
remove = false;
}
else
{
*remove = stream->ReadBit() != 0;
if (stream->ReadBit() == 0)
num = stream->ReadBits(6) + *numbase;
else
num = stream->ReadBits(11);
isdelta = false;
remove = stream->ReadBit() ? true : false;
}
*numbase = num;
if (!*remove)
if (isdelta)
{
*custom = stream->ReadBit() != 0;
num = numbase + 1;
}
else
{
if (stream->ReadBit())
{
num = stream->ReadBits(11);
}
else
{
int delta = stream->ReadBits(6);
num = delta + numbase;
}
}
numbase = num;
if (!remove)
{
custom = stream->ReadBit() ? true : false;
if (m_MaxInstanced_BaseLine)
{
*newbl = stream->ReadBit() != 0;
if (*newbl)
*newblindex = stream->ReadBits(6);
}
else
{
*newbl = false;
isnext = stream->ReadBit() ? true : false;
if (isnext)
{
newbl = true;
newblindex = stream->ReadBits(6);
}
}
if (!full || *newbl)
if (full && !newbl)
{
*offset = 0;
}
else
{
*offset = stream->ReadBit();
if (*offset) {
*offset = stream->ReadBits(6);
isnext = stream->ReadBit() ? true : false;
if (isnext)
{
offset = stream->ReadBits(6);
}
}
}
@ -1498,7 +1498,7 @@ bool World::UncompressEntitiesFromStream(frame_t *frame, BitBuffer *stream, unsi
while (stream->PeekBits(16))
{
newnum = ParseDeltaHeader(stream, &remove, &custom, &numbase, &newbl, &newblindex, false, &offset);
newnum = ParseDeltaHeader(stream, remove, custom, numbase, newbl, newblindex, false, offset);
if ((unsigned)oldindex < deltaFrame.entitynum)
oldnum = deltaEntity[oldindex].number;
@ -1634,7 +1634,7 @@ bool World::UncompressEntitiesFromStream(frame_t *frame, BitBuffer *stream)
break;
}
num = ParseDeltaHeader(stream, &remove, &custom, &numbase, &newbl, &newblindex, true, &offset);
num = ParseDeltaHeader(stream, remove, custom, numbase, newbl, newblindex, true, offset);
if (num >= MAX_ENTITIES)
{
m_System->Errorf("World::GetUncompressedFrame: entity number %i >= MAX_ENTITIES\n", num);
@ -1662,7 +1662,7 @@ bool World::UncompressEntitiesFromStream(frame_t *frame, BitBuffer *stream)
baseline = &m_BaseLines[num];
}
entities[num].entityType = custom ? ENTITY_BEAM : ENTITY_NORMAL;
entities[newindex].entityType = custom ? ENTITY_BEAM : ENTITY_NORMAL;
delta_t *delta = GetDeltaEncoder(num, custom);
m_Delta.ParseDelta(stream, (byte *)baseline, (byte *)&entities[newindex], delta);

View File

@ -139,7 +139,7 @@ public:
private:
int CompressFrame(frame_t *from, BitBuffer *stream);
int ParseDeltaHeader(BitBuffer *stream, bool *remove, bool *custom, int *numbase, bool *newbl, int *newblindex, bool full, int *offset);
int ParseDeltaHeader(BitBuffer *stream, bool &remove, bool &custom, int &numbase, bool &newbl, int &newblindex, bool full, int &offset);
void SetDirector(IDirector *director);
void SetTimeScale(float scale);
void SetGameGroupAddress(NetAddress *addr);
@ -244,7 +244,7 @@ protected:
} player_info_t;
player_info_t m_Players[MAX_CLIENTS];
unsigned char m_EntityBuffer[87040];
unsigned char m_EntityBuffer[MAX_PACKET_ENTITIES * sizeof(entity_state_t)];
entity_state_t m_BaseLines[MAX_ENTITIES];
int m_MaxBaseLines;

View File

@ -316,7 +316,6 @@ Some parameters can only be set in the command line:
-maxfps <n> - sets maximum system cycles per seconds (default "100")
-highpriority - starts the HLTV proxy as high priority process
-multicastttl <n> - sets the Time-To-Live value for multicast packets
-steam - proxy enables special Steam support
-dev - developer mode
</pre>