Client: implement GetServerID()

Allow CLIENT and UI VM to retrieve the current game server ID.
This commit is contained in:
Kawe Mazidjatari committed 2025-05-26 22:39:41 +02:00
1 parent 31f37eaef8
commit 2da030ba19
1 file changed
+22
+22
View File
@@ -152,6 +152,15 @@ static SQRESULT ClientScript_DebugScreenTextWithColor(HSQUIRRELVM v)
SCRIPT_CHECK_AND_RETURN(v, SQ_OK);
}
//-----------------------------------------------------------------------------
// Purpose: gets the most recent server id
//-----------------------------------------------------------------------------
static SQRESULT ClientScript_GetServerID(HSQUIRRELVM v)
{
sq_pushstring(v, Host_GetSessionID(), -1);
SCRIPT_CHECK_AND_RETURN(v, SQ_OK);
}
//-----------------------------------------------------------------------------
// Purpose: checks if the server index is valid, raises an error if not
//-----------------------------------------------------------------------------
@@ -380,6 +389,15 @@ static SQRESULT UIScript_GetServerMaxPlayers(HSQUIRRELVM v)
SCRIPT_CHECK_AND_RETURN(v, SQ_OK);
}
//-----------------------------------------------------------------------------
// Purpose: gets the most recent server id
//-----------------------------------------------------------------------------
static SQRESULT UIScript_GetServerID(HSQUIRRELVM v)
{
sq_pushstring(v, Host_GetSessionID(), -1);
SCRIPT_CHECK_AND_RETURN(v, SQ_OK);
}
//-----------------------------------------------------------------------------
// Purpose: get promo data for server browser panels
//-----------------------------------------------------------------------------
@@ -638,6 +656,8 @@ void Script_RegisterCoreClientFunctions(CSquirrelVM* s)
DEFINE_CLIENT_SCRIPTFUNC_NAMED(s, DebugDrawTriangle, "Draw a debug overlay triangle", "void", "vector p1, vector p2, vector p3, vector color, float alpha, bool drawThroughWorld, float duration", false);
DEFINE_CLIENT_SCRIPTFUNC_NAMED(s, DebugDrawSolidSphere, "Draw a debug overlay solid sphere", "void", "vector origin, float radius, int theta, int phi, vector color, float alpha, bool drawThroughWorld, float duration", false);
DEFINE_CLIENT_SCRIPTFUNC_NAMED(s, DebugDrawCapsule, "Draw a debug overlay capsule", "void", "vector start, vector end, float radius, vector color, float alpha, bool drawThroughWorld, float duration", false);
DEFINE_CLIENT_SCRIPTFUNC_NAMED(s, GetServerID, "Gets the ID of the most recent server", "string", "", false);
}
//---------------------------------------------------------------------------------
@@ -663,6 +683,8 @@ void Script_RegisterUIFunctions(CSquirrelVM* s)
DEFINE_UI_SCRIPTFUNC_NAMED(s, GetServerMaxPlayers, "Gets the max player count of the server at the specified index of the server list", "int", "int index", false);
DEFINE_UI_SCRIPTFUNC_NAMED(s, GetServerID, "Gets the ID of the most recent server", "string", "", false);
// Misc main menu functions
DEFINE_UI_SCRIPTFUNC_NAMED(s, RequestEULAContents, "Requests the latest online EULA contents, calls UICodeCallback_OnEULARequestCompleted on completion", "void", "", false);
DEFINE_UI_SCRIPTFUNC_NAMED(s, GetPromoData, "Gets promo data for specified slot type", "string", "int slotType", false);