aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarichello <artur@barichello.me>2022-01-25 18:22:51 -0300
committerBarichello <artur@barichello.me>2022-01-25 18:22:51 -0300
commitfb68eb976de5bd6637d3679273748187c32352ab (patch)
treead37688129f7ba3c57657039fd0873e7422fd45f
parent730687c29c73ad8e8222eaa42a2f1eb64d863693 (diff)
downloadNorthstarMods-fb68eb976de5bd6637d3679273748187c32352ab.tar.gz
NorthstarMods-fb68eb976de5bd6637d3679273748187c32352ab.zip
Add "StartsWith" helper function
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_lobby.gnut9
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut7
2 files changed, 10 insertions, 6 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_lobby.gnut b/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_lobby.gnut
index 7304dccd..9744bb64 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_lobby.gnut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/lobby/sh_lobby.gnut
@@ -183,10 +183,9 @@ void function AddPrivateMatchModeSettingEnumUIHack( string category, string play
// Sorts specific gamemode settings to the end of the list
int function SortMatchSettings( string categoryA, string categoryB )
{
- // todo: add a 'startswith' string helper function
- if ( categoryA.find( "#PL_" ) == 0 || categoryA.find( "#GAMEMODE_" ) == 0 )
+ if ( StartsWith( categoryA, "#PL_" ) || StartsWith( categoryA, "#GAMEMODE_" ) )
return 1
- else if (categoryB.find( "#PL_" ) == 0 || categoryB.find( "#GAMEMODE_" ) == 0)
+ else if ( StartsWith( categoryB, "#PL_" ) || StartsWith( categoryB, "#GAMEMODE_" ) )
return 0
return 0
}
@@ -197,8 +196,8 @@ array< string > function GetPrivateMatchSettingCategories( bool uiAllowAllModeCa
foreach ( string k, v in file.customMatchSettingsByCategory )
{
#if UI
- bool differentPlaylist = k.find( "#PL_" ) == 0 && k.slice( 4 ) != PrivateMatch_GetSelectedMode()
- bool differentGamemode = k.find( "#GAMEMODE_" ) == 0 && k.slice( 10 ) != PrivateMatch_GetSelectedMode()
+ bool differentPlaylist = StartsWith( k, "#PL_" ) && k.slice( 4 ) != PrivateMatch_GetSelectedMode()
+ bool differentGamemode = StartsWith( k, "#GAMEMODE_" ) && k.slice( 10 ) != PrivateMatch_GetSelectedMode()
if ( differentPlaylist || differentGamemode )
continue
#endif
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut b/Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut
index 9eb673a1..a6044762 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut
@@ -1582,4 +1582,9 @@ string function JoinStringArray( array<string> strings, string separator )
}
return output;
-} \ No newline at end of file
+}
+
+bool function StartsWith( string target, string startsWith )
+{
+ return target.find( startsWith ) == 0
+}