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

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions JM/CF/Defines/CFDefines.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
#ifndef DAYZ_1_20 //! DAYZ_1_19 won't be avaliable in 2_GameLib
#define CF_FUNC_OLD
#endif

#define CF_ONUPDATE_RATE_LIMIT
25 changes: 20 additions & 5 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,28 @@ modded class MissionBase

void CF_OnUpdate(float timeslice)
{
if (g_Game.IsLoading())
{
return;
}

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

m_bLoaded = true;
OnMissionLoaded();
}

#ifdef SERVER
m_CF_UpdateTime += timeslice;

if (m_CF_UpdateTime >= 0.025)
{
CF_ModuleGameManager.OnUpdate(this, new CF_EventUpdateArgs(m_CF_UpdateTime));

m_CF_UpdateTime = 0;
}
#else
CF_ModuleGameManager.OnUpdate(this, new CF_EventUpdateArgs(timeslice));
#endif
}
};