Skip to content

Commit a805943

Browse files
committed
Implement get-/setDevelopmentMode on the server
1 parent 45783b8 commit a805943

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

Server/mods/deathmatch/logic/CGame.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ class CGame
406406
void ApplyAseSetting ( void );
407407
bool IsUsingMtaServerConf ( void ) { return m_bUsingMtaServerConf; }
408408

409+
inline void SetDevelopmentMode (bool enabled) { m_DevelopmentModeEnabled = enabled; }
410+
inline bool GetDevelopmentMode () { return m_DevelopmentModeEnabled; }
411+
409412
private:
410413
void AddBuiltInEvents ( void );
411414
void RelayPlayerPuresync ( class CPacket& Packet );
@@ -593,6 +596,8 @@ class CGame
593596
SString m_strPrevLowestConnectedPlayerVersion;
594597

595598
SharedUtil::CAsyncTaskScheduler* m_pAsyncTaskScheduler;
599+
600+
bool m_DevelopmentModeEnabled;
596601
};
597602

598603
#endif

Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.Server.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,3 +1240,31 @@ int CLuaFunctionDefs::GetPerformanceStats ( lua_State* luaVM )
12401240
lua_pushboolean ( luaVM, false );
12411241
return 1;
12421242
}
1243+
1244+
int CLuaFunctionDefs::SetDevelopmentMode(lua_State* luaVM)
1245+
{
1246+
// bool setDevelopmentMode ( bool enable )
1247+
bool enable;
1248+
1249+
CScriptArgReader argStream(luaVM);
1250+
argStream.ReadBool(enable);
1251+
1252+
if (!argStream.HasErrors())
1253+
{
1254+
g_pGame->SetDevelopmentMode(enable);
1255+
lua_pushboolean(luaVM, true);
1256+
return 1;
1257+
}
1258+
else
1259+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
1260+
1261+
lua_pushboolean(luaVM, false);
1262+
return 1;
1263+
}
1264+
1265+
int CLuaFunctionDefs::GetDevelopmentMode(lua_State* luaVM)
1266+
{
1267+
// bool getDevelopmentMode ()
1268+
lua_pushboolean(luaVM, g_pGame->GetDevelopmentMode());
1269+
return 1;
1270+
}

Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ class CLuaFunctionDefs
164164
LUA_DECLARE ( GetModules );
165165
LUA_DECLARE ( GetModuleInfo );
166166

167+
LUA_DECLARE(SetDevelopmentMode);
168+
LUA_DECLARE(GetDevelopmentMode);
169+
167170
private:
168171
// Static references to objects
169172
static CBlipManager* m_pBlipManager;

Server/mods/deathmatch/logic/lua/CLuaManager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,10 @@ void CLuaManager::LoadCFunctions ( void )
328328
CLuaCFunctions::AddFunction ( "getNetworkUsageData", CLuaFunctionDefs::GetNetworkUsageData );
329329
CLuaCFunctions::AddFunction ( "getNetworkStats", CLuaFunctionDefs::GetNetworkStats );
330330
CLuaCFunctions::AddFunction ( "getLoadedModules", CLuaFunctionDefs::GetModules );
331-
CLuaCFunctions::AddFunction ( "getModuleInfo", CLuaFunctionDefs::GetModuleInfo );
331+
CLuaCFunctions::AddFunction( "getModuleInfo", CLuaFunctionDefs::GetModuleInfo );
332+
333+
CLuaCFunctions::AddFunction("setDevelopmentMode", CLuaFunctionDefs::SetDevelopmentMode);
334+
CLuaCFunctions::AddFunction("getDevelopmentMode", CLuaFunctionDefs::GetDevelopmentMode);
332335

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

0 commit comments

Comments
 (0)