Skip to content

Commit

Permalink
Implement get-/setDevelopmentMode on the server
Browse files Browse the repository at this point in the history
  • Loading branch information
jushar committed Apr 25, 2017
1 parent 45783b8 commit a805943
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Server/mods/deathmatch/logic/CGame.h
Expand Up @@ -406,6 +406,9 @@ class CGame
void ApplyAseSetting ( void );
bool IsUsingMtaServerConf ( void ) { return m_bUsingMtaServerConf; }

inline void SetDevelopmentMode (bool enabled) { m_DevelopmentModeEnabled = enabled; }
inline bool GetDevelopmentMode () { return m_DevelopmentModeEnabled; }

private:
void AddBuiltInEvents ( void );
void RelayPlayerPuresync ( class CPacket& Packet );
Expand Down Expand Up @@ -593,6 +596,8 @@ class CGame
SString m_strPrevLowestConnectedPlayerVersion;

SharedUtil::CAsyncTaskScheduler* m_pAsyncTaskScheduler;

bool m_DevelopmentModeEnabled;
};

#endif
28 changes: 28 additions & 0 deletions Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.Server.cpp
Expand Up @@ -1240,3 +1240,31 @@ int CLuaFunctionDefs::GetPerformanceStats ( lua_State* luaVM )
lua_pushboolean ( luaVM, false );
return 1;
}

int CLuaFunctionDefs::SetDevelopmentMode(lua_State* luaVM)
{
// bool setDevelopmentMode ( bool enable )
bool enable;

CScriptArgReader argStream(luaVM);
argStream.ReadBool(enable);

if (!argStream.HasErrors())
{
g_pGame->SetDevelopmentMode(enable);
lua_pushboolean(luaVM, true);
return 1;
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean(luaVM, false);
return 1;
}

int CLuaFunctionDefs::GetDevelopmentMode(lua_State* luaVM)
{
// bool getDevelopmentMode ()
lua_pushboolean(luaVM, g_pGame->GetDevelopmentMode());
return 1;
}
3 changes: 3 additions & 0 deletions Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.h
Expand Up @@ -164,6 +164,9 @@ class CLuaFunctionDefs
LUA_DECLARE ( GetModules );
LUA_DECLARE ( GetModuleInfo );

LUA_DECLARE(SetDevelopmentMode);
LUA_DECLARE(GetDevelopmentMode);

private:
// Static references to objects
static CBlipManager* m_pBlipManager;
Expand Down
5 changes: 4 additions & 1 deletion Server/mods/deathmatch/logic/lua/CLuaManager.cpp
Expand Up @@ -328,7 +328,10 @@ void CLuaManager::LoadCFunctions ( void )
CLuaCFunctions::AddFunction ( "getNetworkUsageData", CLuaFunctionDefs::GetNetworkUsageData );
CLuaCFunctions::AddFunction ( "getNetworkStats", CLuaFunctionDefs::GetNetworkStats );
CLuaCFunctions::AddFunction ( "getLoadedModules", CLuaFunctionDefs::GetModules );
CLuaCFunctions::AddFunction ( "getModuleInfo", CLuaFunctionDefs::GetModuleInfo );

This comment has been minimized.

Copy link
@CrosRoad95

CrosRoad95 Apr 25, 2017

Contributor

xd

CLuaCFunctions::AddFunction( "getModuleInfo", CLuaFunctionDefs::GetModuleInfo );

CLuaCFunctions::AddFunction("setDevelopmentMode", CLuaFunctionDefs::SetDevelopmentMode);
CLuaCFunctions::AddFunction("getDevelopmentMode", CLuaFunctionDefs::GetDevelopmentMode);

// Backward compat functions at the end, so the new function name is used in ACL

Expand Down

0 comments on commit a805943

Please sign in to comment.