mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Add abstracted functions to determine build type
Allow scripters to determine whether or not this is a dedicated server or client only build. Note that these should not be abused in scripts! Since the client dll doesn't support running games locally, loading up the lobby isn't going to work when you leave a match (which is the current implementation in the scripts). with this, the scripter could do other things such as loading the title screen, or connecting to a remote lobby server if this happens to be a client only build.
This commit is contained in:
parent
34f69a5b1e
commit
419bf12e06
r5dev/squirrel
@ -156,6 +156,21 @@ namespace VSquirrel
|
||||
|
||||
return SQ_OK;
|
||||
}
|
||||
#ifndef DEDICATED
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: checks whether this SDK build is a client dll
|
||||
//-----------------------------------------------------------------------------
|
||||
SQRESULT IsClientDLL(HSQUIRRELVM v)
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
constexpr SQBool bClientOnly = true;
|
||||
#else
|
||||
constexpr SQBool bClientOnly = false;
|
||||
#endif
|
||||
sq_pushbool(v, bClientOnly);
|
||||
return SQ_OK;
|
||||
}
|
||||
#endif // !DEDICATED
|
||||
}
|
||||
#ifndef CLIENT_DLL
|
||||
namespace SERVER
|
||||
@ -177,6 +192,15 @@ namespace VSquirrel
|
||||
sq_pushinteger(v, g_pServer->GetNumFakeClients());
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: checks whether this SDK build is a dedicated server
|
||||
//-----------------------------------------------------------------------------
|
||||
SQRESULT IsDedicated(HSQUIRRELVM v)
|
||||
{
|
||||
sq_pushbool(v, *s_bDedicated);
|
||||
return SQ_OK;
|
||||
}
|
||||
}
|
||||
#endif // !CLIENT_DLL
|
||||
#ifndef DEDICATED
|
||||
|
@ -23,6 +23,9 @@ namespace VSquirrel
|
||||
SQRESULT GetAvailableMaps(HSQUIRRELVM v);
|
||||
SQRESULT GetAvailablePlaylists(HSQUIRRELVM v);
|
||||
SQRESULT ShutdownHostGame(HSQUIRRELVM v);
|
||||
#ifndef DEDICATED
|
||||
SQRESULT IsClientDLL(HSQUIRRELVM v);
|
||||
#endif // !DEDICATED
|
||||
#ifndef CLIENT_DLL
|
||||
SQRESULT KickPlayerByName(HSQUIRRELVM v);
|
||||
SQRESULT KickPlayerById(HSQUIRRELVM v);
|
||||
@ -36,6 +39,7 @@ namespace VSquirrel
|
||||
{
|
||||
SQRESULT GetNumHumanPlayers(HSQUIRRELVM v);
|
||||
SQRESULT GetNumFakeClients(HSQUIRRELVM v);
|
||||
SQRESULT IsDedicated(HSQUIRRELVM v);
|
||||
}
|
||||
#endif // !CLIENT_DLL
|
||||
#ifndef DEDICATED
|
||||
|
@ -76,6 +76,8 @@ void Script_RegisterServerFunctions(CSquirrelVM* s)
|
||||
Script_RegisterFunction(s, "UnbanPlayer", "Script_UnbanPlayer", "Unbans a player from the server by nucleus id or ip address", "void", "string", &VSquirrel::SHARED::UnbanPlayer);
|
||||
|
||||
Script_RegisterFunction(s, "ShutdownHostGame", "Script_ShutdownHostGame", "Shuts the local host game down", "void", "", &VSquirrel::SHARED::ShutdownHostGame);
|
||||
|
||||
Script_RegisterFunction(s, "IsDedicated", "Script_IsDedicated", "Returns whether this is a dedicated server", "bool", "", &VSquirrel::SERVER::IsDedicated);
|
||||
}
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
@ -137,6 +139,7 @@ void Script_RegisterUIFunctions(CSquirrelVM* s)
|
||||
Script_RegisterFunction(s, "UnbanPlayer", "Script_UnbanPlayer", "Unbans a player from the server by nucleus id or ip address", "void", "string", &VSquirrel::SHARED::UnbanPlayer);
|
||||
#endif // !CLIENT_DLL
|
||||
Script_RegisterFunction(s, "ShutdownHostGame", "Script_ShutdownHostGame", "Shuts the local host game down", "void", "", &VSquirrel::SHARED::ShutdownHostGame);
|
||||
Script_RegisterFunction(s, "IsClientDLL", "Script_IsClientDLL", "Returns whether this build is client only", "bool", "", &VSquirrel::SHARED::IsClientDLL);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user