mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-30 15:38:05 +03:00
SV_AllocPacketEntities optimization moved under REHLDS_OPT_PEDANTIC
Rehlds Demo Player: write duration in the 'rehlds_demo_stats.log' file when demo ends successfully 6132_hooker.cpp: Minimal setup to play/records demos in hook mode with active Rehlds API
This commit is contained in:
parent
31bfe3db78
commit
5abbc92fda
@ -485,13 +485,13 @@ void SV_AllocPacketEntities(client_frame_t *frame, int numents)
|
|||||||
{
|
{
|
||||||
if (frame)
|
if (frame)
|
||||||
{
|
{
|
||||||
#ifdef REHLDS_FIXES
|
#ifdef REHLDS_OPT_PEDANTIC
|
||||||
frame->entities.num_entities = numents;
|
frame->entities.num_entities = numents;
|
||||||
|
|
||||||
// only alloc for max possible numents
|
// only alloc for max possible numents
|
||||||
if (!frame->entities.entities)
|
if (!frame->entities.entities)
|
||||||
frame->entities.entities = (entity_state_t *)Mem_ZeroMalloc(sizeof(entity_state_t) * MAX_PACKET_ENTITIES);
|
frame->entities.entities = (entity_state_t *)Mem_ZeroMalloc(sizeof(entity_state_t) * MAX_PACKET_ENTITIES);
|
||||||
#else // REHLDS_FIXES
|
#else // REHLDS_OPT_PEDANTIC
|
||||||
if (frame->entities.entities)
|
if (frame->entities.entities)
|
||||||
SV_ClearPacketEntities(frame);
|
SV_ClearPacketEntities(frame);
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ void SV_AllocPacketEntities(client_frame_t *frame, int numents)
|
|||||||
|
|
||||||
frame->entities.num_entities = numents;
|
frame->entities.num_entities = numents;
|
||||||
frame->entities.entities = (entity_state_t *)Mem_ZeroMalloc(sizeof(entity_state_t) * allocatedslots);
|
frame->entities.entities = (entity_state_t *)Mem_ZeroMalloc(sizeof(entity_state_t) * allocatedslots);
|
||||||
#endif // REHLDS_FIXES
|
#endif // REHLDS_OPT_PEDANTIC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4395,9 +4395,9 @@ void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg)
|
|||||||
|
|
||||||
packet_entities_t *pack = &frame->entities;
|
packet_entities_t *pack = &frame->entities;
|
||||||
|
|
||||||
// for REHLDS_FIXES: Allocate the MAX_PACKET_ENTITIES ents in the frame's storage
|
// for REHLDS_OPT_PEDANTIC: Allocate the MAX_PACKET_ENTITIES ents in the frame's storage
|
||||||
// This allows us to avoid intermediate 'fullpack' storage
|
// This allows us to avoid intermediate 'fullpack' storage
|
||||||
#ifdef REHLDS_FIXES
|
#ifdef REHLDS_OPT_PEDANTIC
|
||||||
SV_AllocPacketEntities(frame, MAX_PACKET_ENTITIES);
|
SV_AllocPacketEntities(frame, MAX_PACKET_ENTITIES);
|
||||||
packet_entities_t *curPack = &frame->entities;
|
packet_entities_t *curPack = &frame->entities;
|
||||||
curPack->num_entities = 0;
|
curPack->num_entities = 0;
|
||||||
@ -4406,7 +4406,7 @@ void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg)
|
|||||||
full_packet_entities_t fullpack;
|
full_packet_entities_t fullpack;
|
||||||
fullpack.num_entities = 0;
|
fullpack.num_entities = 0;
|
||||||
full_packet_entities_t* curPack = &fullpack;
|
full_packet_entities_t* curPack = &fullpack;
|
||||||
#endif // REHLDS_FIXES
|
#endif // REHLDS_OPT_PEDANTIC
|
||||||
|
|
||||||
qboolean sendping = SV_ShouldUpdatePing(client);
|
qboolean sendping = SV_ShouldUpdatePing(client);
|
||||||
int flags = client->lw != 0;
|
int flags = client->lw != 0;
|
||||||
@ -4433,7 +4433,7 @@ void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg)
|
|||||||
|
|
||||||
edict_t* ent = &g_psv.edicts[e];
|
edict_t* ent = &g_psv.edicts[e];
|
||||||
|
|
||||||
#ifdef REHLDS_FIXES
|
#ifdef REHLDS_OPT_PEDANTIC
|
||||||
//Part of gamedll's code is moved here to decrease amount of calls to AddToFullPack()
|
//Part of gamedll's code is moved here to decrease amount of calls to AddToFullPack()
|
||||||
//We don't even try to transmit entities without model as well as invisible entities
|
//We don't even try to transmit entities without model as well as invisible entities
|
||||||
if (ent->v.modelindex && !(ent->v.effects & EF_NODRAW)) {
|
if (ent->v.modelindex && !(ent->v.effects & EF_NODRAW)) {
|
||||||
@ -4442,15 +4442,15 @@ void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg)
|
|||||||
++curPack->num_entities;
|
++curPack->num_entities;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
qboolean add = gEntityInterface.pfnAddToFullPack(&fullpack.entities[fullpack.num_entities], e, &g_psv.edicts[e], host_client->edict, flags, FALSE, pSet);
|
qboolean add = gEntityInterface.pfnAddToFullPack(&curPack->entities[curPack->num_entities], e, &g_psv.edicts[e], host_client->edict, flags, FALSE, pSet);
|
||||||
if (add)
|
if (add)
|
||||||
++fullpack.num_entities;
|
++curPack->num_entities;
|
||||||
#endif
|
#endif //REHLDS_OPT_PEDANTIC
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//for REHLDS_FIXES: Entities are already in the frame's storage, no need to copy them
|
//for REHLDS_FIXES: Entities are already in the frame's storage, no need to copy them
|
||||||
#ifndef REHLDS_FIXES
|
#ifndef REHLDS_OPT_PEDANTIC
|
||||||
SV_AllocPacketEntities(frame, fullpack.num_entities);
|
SV_AllocPacketEntities(frame, fullpack.num_entities);
|
||||||
if (pack->num_entities)
|
if (pack->num_entities)
|
||||||
Q_memcpy(pack->entities, fullpack.entities, sizeof(entity_state_t) * pack->num_entities);
|
Q_memcpy(pack->entities, fullpack.entities, sizeof(entity_state_t) * pack->num_entities);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -50,6 +50,8 @@ CPlayingEngExtInterceptor::CPlayingEngExtInterceptor(const char* fname, bool str
|
|||||||
|
|
||||||
m_InStream.read(cmdLine, cmdlineLen);
|
m_InStream.read(cmdLine, cmdlineLen);
|
||||||
printf("Playing testsuite\nrecorders's cmdline: %s\n", cmdLine);
|
printf("Playing testsuite\nrecorders's cmdline: %s\n", cmdLine);
|
||||||
|
|
||||||
|
m_StartTick = ::GetTickCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void* CPlayingEngExtInterceptor::allocFuncCall()
|
void* CPlayingEngExtInterceptor::allocFuncCall()
|
||||||
@ -145,6 +147,12 @@ IEngExtCall* CPlayingEngExtInterceptor::getNextCall(bool peek, bool processCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmd->getOpcode() == ECF_NONE) {
|
if (cmd->getOpcode() == ECF_NONE) {
|
||||||
|
DWORD endTick = ::GetTickCount();
|
||||||
|
FILE* fl = fopen("rehlds_demo_stats.log", "w");
|
||||||
|
if (fl) {
|
||||||
|
fprintf(fl, "Finished playing demo; duration=%umsec", (endTick - m_StartTick));
|
||||||
|
fclose(fl);
|
||||||
|
}
|
||||||
TerminateProcess(GetCurrentProcess(), 777);
|
TerminateProcess(GetCurrentProcess(), 777);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +135,8 @@ private:
|
|||||||
int m_HeartBeatInterval;
|
int m_HeartBeatInterval;
|
||||||
int m_PrevHeartBeat;
|
int m_PrevHeartBeat;
|
||||||
|
|
||||||
|
DWORD m_StartTick;
|
||||||
|
|
||||||
hostent_data_t m_CurrentHostentData;
|
hostent_data_t m_CurrentHostentData;
|
||||||
struct hostent m_CurrentHostent;
|
struct hostent m_CurrentHostent;
|
||||||
void setCurrentHostent(hostent_data_t* data);
|
void setCurrentHostent(hostent_data_t* data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user