Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit CF_OnUpdate rate for perf boost #130

Merged
merged 6 commits into from
Jan 9, 2025
Merged
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
26 changes: 24 additions & 2 deletions JM/CF/Scripts/5_Mission/CommunityFramework/Mission/MissionBase.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
modded class MissionBase
{
#ifdef SERVER
float m_CF_UpdateTime;
#endif
lava76 marked this conversation as resolved.
Show resolved Hide resolved

protected bool m_bLoaded = false;

void MissionBase()
Expand All @@ -19,17 +23,35 @@ modded class MissionBase

void CF_OnUpdate(float timeslice)
{
if (g_Game.IsLoading())
#ifdef SERVER
lava76 marked this conversation as resolved.
Show resolved Hide resolved
float updateTime = GetGame().GetTickTime();
float elapsed = updateTime - m_CF_UpdateTime;
bool update = elapsed >= 0.025;

if (update)
{
return;
m_CF_UpdateTime = updateTime;
}
#endif

if (!m_bLoaded)
{
if (g_Game.IsLoading())
{
return;
}

m_bLoaded = true;
OnMissionLoaded();
}

#ifdef SERVER
if (update)
{
CF_ModuleGameManager.OnUpdate(this, new CF_EventUpdateArgs(elapsed));
}
#else
CF_ModuleGameManager.OnUpdate(this, new CF_EventUpdateArgs(timeslice));
#endif
}
};