mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-16 16:48:13 +03:00
Moved optimized MSG_Write*Bits* under REHLDS_FIXES defined because it uses bf_write_s structure incompatible with the original engine
Fixed wrong tex.coords formula in SurfaceAtPoint() Added missing calls to SV_CheckWaterTransition() in SV_Physics_Toss() Flight recorder: Lazy init with HOOK_ENGINE RehldsDemoPlayer: print heartbeat message every 10Mb of demo
This commit is contained in:
parent
f2fe5a6c74
commit
31bfe3db78
@ -457,7 +457,7 @@ typedef struct bf_write_s
|
|||||||
{
|
{
|
||||||
|
|
||||||
//For enhanced and safe bits writing functions
|
//For enhanced and safe bits writing functions
|
||||||
#if defined(REHLDS_OPT_PEDANTIC) || defined(REHLDS_FIXES)
|
#if defined(REHLDS_FIXES)
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
union {
|
union {
|
||||||
@ -471,13 +471,13 @@ typedef struct bf_write_s
|
|||||||
int nCurOutputBit;
|
int nCurOutputBit;
|
||||||
sizebuf_t *pbuf;
|
sizebuf_t *pbuf;
|
||||||
|
|
||||||
#else //defined(REHLDS_OPT_PEDANTIC) || defined(REHLDS_FIXES)
|
#else //defined(REHLDS_FIXES)
|
||||||
|
|
||||||
int nCurOutputBit;
|
int nCurOutputBit;
|
||||||
unsigned char *pOutByte;
|
unsigned char *pOutByte;
|
||||||
sizebuf_t *pbuf;
|
sizebuf_t *pbuf;
|
||||||
|
|
||||||
#endif //defined(REHLDS_OPT_PEDANTIC) || defined(REHLDS_FIXES)
|
#endif //defined(REHLDS_FIXES)
|
||||||
} bf_write_t;
|
} bf_write_t;
|
||||||
|
|
||||||
typedef struct bf_read_s
|
typedef struct bf_read_s
|
||||||
@ -502,7 +502,7 @@ void COM_BitOpsInit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Enhanced and safe bits writing functions
|
//Enhanced and safe bits writing functions
|
||||||
#if defined(REHLDS_OPT_PEDANTIC) || defined(REHLDS_FIXES)
|
#if defined(REHLDS_FIXES)
|
||||||
|
|
||||||
void MSG_WBits_MaybeFlush() {
|
void MSG_WBits_MaybeFlush() {
|
||||||
if (bfwrite.nCurOutputBit < 32)
|
if (bfwrite.nCurOutputBit < 32)
|
||||||
@ -561,7 +561,7 @@ void MSG_EndBitWriting(sizebuf_t *buf)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else //defined(REHLDS_OPT_PEDANTIC) || defined(REHLDS_FIXES)
|
#else // defined(REHLDS_FIXES)
|
||||||
|
|
||||||
void MSG_WriteOneBit(int nValue)
|
void MSG_WriteOneBit(int nValue)
|
||||||
{
|
{
|
||||||
@ -594,13 +594,6 @@ void MSG_StartBitWriting(sizebuf_t *buf)
|
|||||||
bfwrite.pOutByte = &buf->data[buf->cursize];
|
bfwrite.pOutByte = &buf->data[buf->cursize];
|
||||||
}
|
}
|
||||||
|
|
||||||
NOXREF qboolean MSG_IsBitWriting(void)
|
|
||||||
{
|
|
||||||
NOXREFCHECK;
|
|
||||||
|
|
||||||
return bfwrite.pbuf != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MSG_EndBitWriting(sizebuf_t *buf)
|
void MSG_EndBitWriting(sizebuf_t *buf)
|
||||||
{
|
{
|
||||||
if (!(bfwrite.pbuf->flags & SIZEBUF_OVERFLOWED))
|
if (!(bfwrite.pbuf->flags & SIZEBUF_OVERFLOWED))
|
||||||
@ -660,7 +653,14 @@ void MSG_WriteBits(uint32 data, int numbits)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //defined(REHLDS_OPT_PEDANTIC) || defined(REHLDS_FIXES)
|
#endif //defined(REHLDS_FIXES)
|
||||||
|
|
||||||
|
NOXREF qboolean MSG_IsBitWriting(void)
|
||||||
|
{
|
||||||
|
NOXREFCHECK;
|
||||||
|
|
||||||
|
return bfwrite.pbuf != 0;
|
||||||
|
}
|
||||||
|
|
||||||
void MSG_WriteSBits(int data, int numbits)
|
void MSG_WriteSBits(int data, int numbits)
|
||||||
{
|
{
|
||||||
@ -1291,6 +1291,7 @@ void *SZ_GetSpace(sizebuf_t *buf, int length)
|
|||||||
void *data;
|
void *data;
|
||||||
const char *buffername = buf->buffername ? buf->buffername : "???";
|
const char *buffername = buf->buffername ? buf->buffername : "???";
|
||||||
|
|
||||||
|
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
{
|
{
|
||||||
Sys_Error(__FUNCTION__ ": %i negative length on %s", length, buffername);
|
Sys_Error(__FUNCTION__ ": %i negative length on %s", length, buffername);
|
||||||
|
@ -488,8 +488,8 @@ msurface_t *SurfaceAtPoint(model_t *pModel, mnode_t *node, vec_t *start, vec_t *
|
|||||||
{
|
{
|
||||||
surf = &pModel->surfaces[node->firstsurface + i];
|
surf = &pModel->surfaces[node->firstsurface + i];
|
||||||
tex = surf->texinfo;
|
tex = surf->texinfo;
|
||||||
ds = (int)_DotProduct(mid, tex->vecs[0]);
|
ds = (int)(_DotProduct(mid, tex->vecs[0]) + tex->vecs[0][3]);
|
||||||
dt = (int)_DotProduct(mid, tex->vecs[1]);
|
dt = (int)(_DotProduct(mid, tex->vecs[1]) + tex->vecs[1][3]);
|
||||||
if (ds >= surf->texturemins[0])
|
if (ds >= surf->texturemins[0])
|
||||||
{
|
{
|
||||||
if (dt >= surf->texturemins[1])
|
if (dt >= surf->texturemins[1])
|
||||||
|
@ -1097,8 +1097,11 @@ void SV_Physics_Toss(edict_t *ent)
|
|||||||
}
|
}
|
||||||
ClipVelocity(ent->v.velocity, trace.plane.normal, ent->v.velocity, backoff);
|
ClipVelocity(ent->v.velocity, trace.plane.normal, ent->v.velocity, backoff);
|
||||||
|
|
||||||
if (trace.plane.normal[2] <= 0.7f)
|
if (trace.plane.normal[2] <= 0.7)
|
||||||
|
{
|
||||||
|
SV_CheckWaterTransition(ent);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
move[0] = ent->v.basevelocity[0] + ent->v.velocity[0];
|
move[0] = ent->v.basevelocity[0] + ent->v.velocity[0];
|
||||||
move[1] = ent->v.basevelocity[1] + ent->v.velocity[1];
|
move[1] = ent->v.basevelocity[1] + ent->v.velocity[1];
|
||||||
@ -1131,6 +1134,7 @@ void SV_Physics_Toss(edict_t *ent)
|
|||||||
ent->v.avelocity[0] = vec3_origin[0];
|
ent->v.avelocity[0] = vec3_origin[0];
|
||||||
ent->v.avelocity[1] = vec3_origin[1];
|
ent->v.avelocity[1] = vec3_origin[1];
|
||||||
ent->v.avelocity[2] = vec3_origin[2];
|
ent->v.avelocity[2] = vec3_origin[2];
|
||||||
|
SV_CheckWaterTransition(ent);
|
||||||
} /* size: 3408000 */
|
} /* size: 3408000 */
|
||||||
|
|
||||||
/* <b655d> ../engine/sv_phys.c:1668 */
|
/* <b655d> ../engine/sv_phys.c:1668 */
|
||||||
|
@ -570,6 +570,11 @@ void Rehlds_Debug_LogDeltaFlags(delta_t* delta, int counter, bool verbose) {
|
|||||||
g_RehldsDebugLog.flush();
|
g_RehldsDebugLog.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Rehlds_Debug_LogSzAlloc(int counter, int cursize, int maxsize, int flags) {
|
||||||
|
g_RehldsDebugLog << "SZAlloc(c=" << counter << " sz=" << cursize << " maxsz= " << maxsize << " f=" << flags << ")\n";
|
||||||
|
g_RehldsDebugLog.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Rehlds_Debug_Init(Module* engine)
|
void Rehlds_Debug_Init(Module* engine)
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,7 @@ extern void Rehlds_Debug_logRealloc(size_t sz, void* oldPtr, void* newPtr);
|
|||||||
extern void Rehlds_Debug_logFree(void* ptr);
|
extern void Rehlds_Debug_logFree(void* ptr);
|
||||||
|
|
||||||
extern void Rehlds_Debug_LogDeltaFlags(delta_t* delta, int counter, bool verbose);
|
extern void Rehlds_Debug_LogDeltaFlags(delta_t* delta, int counter, bool verbose);
|
||||||
|
extern void Rehlds_Debug_LogSzAlloc(int counter, int cursize, int maxsize, int flags);
|
||||||
|
|
||||||
extern void Rehlds_Debug_Init(Module* engine);
|
extern void Rehlds_Debug_Init(Module* engine);
|
||||||
|
|
||||||
|
@ -987,7 +987,7 @@
|
|||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>REHLDS_OPT_PEDANTIC;REHLDS_SELF;HOOK_ENGINE;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>REHLDS_SELF;HOOK_ENGINE;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
@ -1027,7 +1027,7 @@
|
|||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>REHLDS_FIXES;REHLDS_OPT_PEDANTIC;REHLDS_SELF;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>REHLDS_OPT_PEDANTIC;REHLDS_SELF;REHLDS_CHECKS;USE_BREAKPAD_HANDLER;DEDICATED;SWDS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
@ -23,6 +23,12 @@ uint16 g_FRMsg_Frame;
|
|||||||
uint16 g_FRMsg_FreeEntPrivateData;
|
uint16 g_FRMsg_FreeEntPrivateData;
|
||||||
uint16 g_FRMsg_AllocEntPrivateData;
|
uint16 g_FRMsg_AllocEntPrivateData;
|
||||||
|
|
||||||
|
void FR_CheckInit() {
|
||||||
|
#ifdef HOOK_ENGINE
|
||||||
|
if (!g_FlightRecorder)
|
||||||
|
FR_Init();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void FR_Init() {
|
void FR_Init() {
|
||||||
g_FlightRecorder = new CRehldsFlightRecorder();
|
g_FlightRecorder = new CRehldsFlightRecorder();
|
||||||
@ -33,23 +39,27 @@ void FR_Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FR_StartFrame() {
|
void FR_StartFrame() {
|
||||||
|
FR_CheckInit();
|
||||||
g_FlightRecorder->StartMessage(g_FRMsg_Frame, true);
|
g_FlightRecorder->StartMessage(g_FRMsg_Frame, true);
|
||||||
g_FlightRecorder->WriteDouble(realtime);
|
g_FlightRecorder->WriteDouble(realtime);
|
||||||
g_FlightRecorder->EndMessage(g_FRMsg_Frame, true);
|
g_FlightRecorder->EndMessage(g_FRMsg_Frame, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FR_EndFrame() {
|
void FR_EndFrame() {
|
||||||
|
FR_CheckInit();
|
||||||
g_FlightRecorder->StartMessage(g_FRMsg_Frame, false);
|
g_FlightRecorder->StartMessage(g_FRMsg_Frame, false);
|
||||||
g_FlightRecorder->EndMessage(g_FRMsg_Frame, false);
|
g_FlightRecorder->EndMessage(g_FRMsg_Frame, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FR_AllocEntPrivateData(void* res) {
|
void FR_AllocEntPrivateData(void* res) {
|
||||||
|
FR_CheckInit();
|
||||||
g_FlightRecorder->StartMessage(g_FRMsg_AllocEntPrivateData, true);
|
g_FlightRecorder->StartMessage(g_FRMsg_AllocEntPrivateData, true);
|
||||||
g_FlightRecorder->WriteUInt32((size_t)res);
|
g_FlightRecorder->WriteUInt32((size_t)res);
|
||||||
g_FlightRecorder->EndMessage(g_FRMsg_AllocEntPrivateData, true);
|
g_FlightRecorder->EndMessage(g_FRMsg_AllocEntPrivateData, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FR_FreeEntPrivateData(void* data) {
|
void FR_FreeEntPrivateData(void* data) {
|
||||||
|
FR_CheckInit();
|
||||||
g_FlightRecorder->StartMessage(g_FRMsg_FreeEntPrivateData, true);
|
g_FlightRecorder->StartMessage(g_FRMsg_FreeEntPrivateData, true);
|
||||||
g_FlightRecorder->WriteUInt32((size_t)data);
|
g_FlightRecorder->WriteUInt32((size_t)data);
|
||||||
g_FlightRecorder->EndMessage(g_FRMsg_FreeEntPrivateData, true);
|
g_FlightRecorder->EndMessage(g_FRMsg_FreeEntPrivateData, true);
|
||||||
|
@ -24,6 +24,9 @@ CPlayingEngExtInterceptor::CPlayingEngExtInterceptor(const char* fname, bool str
|
|||||||
m_GameServerWrapper = NULL;
|
m_GameServerWrapper = NULL;
|
||||||
m_SteamBreakpadContext = NULL;
|
m_SteamBreakpadContext = NULL;
|
||||||
|
|
||||||
|
m_HeartBeatInterval = 10000000;
|
||||||
|
m_PrevHeartBeat = 0;
|
||||||
|
|
||||||
uint32 cmdlineLen = 0;
|
uint32 cmdlineLen = 0;
|
||||||
char cmdLine[2048];
|
char cmdLine[2048];
|
||||||
|
|
||||||
@ -134,6 +137,8 @@ IEngExtCall* CPlayingEngExtInterceptor::getNextCallInternal(bool peek) {
|
|||||||
|
|
||||||
IEngExtCall* CPlayingEngExtInterceptor::getNextCall(bool peek, bool processCallbacks, ExtCallFuncs expectedOpcode, bool needStart, const char* callSource) {
|
IEngExtCall* CPlayingEngExtInterceptor::getNextCall(bool peek, bool processCallbacks, ExtCallFuncs expectedOpcode, bool needStart, const char* callSource) {
|
||||||
int size = (int)m_InStream.tellg();
|
int size = (int)m_InStream.tellg();
|
||||||
|
int sizeLeft = m_inStreamSize - size;
|
||||||
|
maybeHeartBeat(size);
|
||||||
IEngExtCall* cmd = getNextCallInternal(peek);
|
IEngExtCall* cmd = getNextCallInternal(peek);
|
||||||
if (peek) {
|
if (peek) {
|
||||||
return cmd;
|
return cmd;
|
||||||
@ -158,7 +163,7 @@ IEngExtCall* CPlayingEngExtInterceptor::getNextCall(bool peek, bool processCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmd->getOpcode() != expectedOpcode) {
|
if (cmd->getOpcode() != expectedOpcode) {
|
||||||
rehlds_syserror("%s: bad opcode; expected %d got %d; size left: %d", __FUNCTION__, expectedOpcode, cmd->getOpcode(), m_inStreamSize - size);
|
rehlds_syserror("%s: bad opcode; expected %d got %d; size left: %d", __FUNCTION__, expectedOpcode, cmd->getOpcode(), sizeLeft);
|
||||||
}
|
}
|
||||||
if (needStart) {
|
if (needStart) {
|
||||||
if (!cmd->m_Start) rehlds_syserror("%s: bad fcall %d; expected start flag", __FUNCTION__, cmd->getOpcode());
|
if (!cmd->m_Start) rehlds_syserror("%s: bad fcall %d; expected start flag", __FUNCTION__, cmd->getOpcode());
|
||||||
@ -235,6 +240,13 @@ int CPlayingEngExtInterceptor::getOrRegisterSteamCallback(CCallbackBase* cb) {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPlayingEngExtInterceptor::maybeHeartBeat(int readPos) {
|
||||||
|
if (m_PrevHeartBeat + m_HeartBeatInterval <= readPos) {
|
||||||
|
m_PrevHeartBeat = readPos;
|
||||||
|
Con_Printf("%s: readPos=%u\n", __FUNCTION__, readPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint32 CPlayingEngExtInterceptor::time(uint32* pTime)
|
uint32 CPlayingEngExtInterceptor::time(uint32* pTime)
|
||||||
{
|
{
|
||||||
CStdTimeCall* playCall = dynamic_cast<CStdTimeCall*>(getNextCall(false, false, ECF_CSTD_TIME, true, __FUNCTION__));
|
CStdTimeCall* playCall = dynamic_cast<CStdTimeCall*>(getNextCall(false, false, ECF_CSTD_TIME, true, __FUNCTION__));
|
||||||
|
@ -132,6 +132,8 @@ private:
|
|||||||
CSteamGameServerPlayingWrapper* m_GameServerWrapper;
|
CSteamGameServerPlayingWrapper* m_GameServerWrapper;
|
||||||
|
|
||||||
void* m_SteamBreakpadContext;
|
void* m_SteamBreakpadContext;
|
||||||
|
int m_HeartBeatInterval;
|
||||||
|
int m_PrevHeartBeat;
|
||||||
|
|
||||||
hostent_data_t m_CurrentHostentData;
|
hostent_data_t m_CurrentHostentData;
|
||||||
struct hostent m_CurrentHostent;
|
struct hostent m_CurrentHostent;
|
||||||
@ -150,6 +152,8 @@ private:
|
|||||||
|
|
||||||
int getOrRegisterSteamCallback(CCallbackBase* cb);
|
int getOrRegisterSteamCallback(CCallbackBase* cb);
|
||||||
|
|
||||||
|
void maybeHeartBeat(int readPos);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void* allocFuncCall();
|
void* allocFuncCall();
|
||||||
void freeFuncCall(void* fcall);
|
void freeFuncCall(void* fcall);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user