Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/game/server/entitylist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ class CSimThinkManager : public IEntityListener
// only copy out entities that will simulate or think this frame
if ( m_simThinkList[i].nextThinkTick <= gpGlobals->tickcount )
{
#if defined(NEO) && defined(DBGFLAG_ASSERT)
ConVarRef nb_stop("nb_stop");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a case where nb_stop won’t exist when this runs? If not, it might save a few frames per second to read it directly. ConVarRef does a name lookup each time it is constructed, and here that happens for every thinking entity on every tick. #2319 optimized something similar for other hot-path ConVars.

nb_stop is already defined in the server project as ConVar NextBotStop (NextBot/NextBot.cpp), and NextBot/NextBot.h declares it extern. So no lookup and no IsValid assert are needed.

The change I had in mind is summarized in https://github.com/Rainyan/rebuild/pull/9/changes, and it resolves the Assert in the same way. Feel free to take it or leave it, either by implementing the change directly or merging the PR directly into your branch. I don't care about co-author credit, I was just struggling to summarize how to explain the #include part without making this comment field messy.

Assert(nb_stop.IsValid());
if (!nb_stop.GetBool())
#endif
Assert(m_simThinkList[i].nextThinkTick>=0);
int entinfoIndex = m_simThinkList[i].entEntry;
const CEntInfo *pInfo = gEntList.GetEntInfoPtrByIndex( entinfoIndex );
Expand Down Expand Up @@ -239,6 +244,11 @@ class CSimThinkManager : public IEntityListener
if ( pEntity->IsEFlagSet(EFL_NO_GAME_PHYSICS_SIMULATION) )
{
m_simThinkList[m_entinfoIndex[index]].nextThinkTick = pEntity->GetFirstThinkTick();
#if defined(NEO) && defined(DBGFLAG_ASSERT)
ConVarRef nb_stop("nb_stop");
Assert(nb_stop.IsValid());
if (!nb_stop.GetBool())
#endif
Assert(m_simThinkList[m_entinfoIndex[index]].nextThinkTick>=0);
}
}
Expand Down
Loading