Skip to content

Commit

Permalink
add new function getCurrentFPS (#420)
Browse files Browse the repository at this point in the history
float getCurrentFPS(); (client only function)

this function is more accurate than calculations based on frames in some pre/render events, because is calculated on game loop client.
  • Loading branch information
znvjder authored and saml1er committed Sep 16, 2018
1 parent 0f5b7e5 commit c43b6de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.World.cpp
Expand Up @@ -1764,6 +1764,12 @@ int CLuaFunctionDefs::GetBirdsEnabled(lua_State* luaVM)
return 1;
}

int CLuaFunctionDefs::GetCurrentFPS(lua_State* luaVM)
{
lua_pushnumber(luaVM, g_pGame->GetFPS());
return 1;
}

int CLuaFunctionDefs::SetMoonSize(lua_State* luaVM)
{
int iSize;
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.h
Expand Up @@ -177,6 +177,7 @@ class CLuaFunctionDefs
LUA_DECLARE(ResetMoonSize);
LUA_DECLARE(SetFPSLimit);
LUA_DECLARE(GetFPSLimit);
LUA_DECLARE(GetCurrentFPS);
LUA_DECLARE(FetchRemote);

// Input functions
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/lua/CLuaManager.cpp
Expand Up @@ -301,6 +301,7 @@ void CLuaManager::LoadCFunctions(void)
CLuaCFunctions::AddFunction("resetMoonSize", CLuaFunctionDefs::ResetMoonSize);
CLuaCFunctions::AddFunction("setFPSLimit", CLuaFunctionDefs::SetFPSLimit);
CLuaCFunctions::AddFunction("getFPSLimit", CLuaFunctionDefs::GetFPSLimit);
CLuaCFunctions::AddFunction("getCurrentFPS", CLuaFunctionDefs::GetCurrentFPS);
CLuaCFunctions::AddFunction("fetchRemote", CLuaFunctionDefs::FetchRemote);

// World set funcs
Expand Down

0 comments on commit c43b6de

Please sign in to comment.