Skip to content

Commit

Permalink
Merge pull request #41 from R2NorthstarCN/update-to-v1.15.0
Browse files Browse the repository at this point in the history
Update to v1.15.0
  • Loading branch information
wolf109909 authored Aug 20, 2023
2 parents f67e3a0 + ba9ac23 commit edf2ca3
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Northstar.Client/mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Northstar.Client",
"Description": "Various ui and client changes to fix bugs and add better support for mods",
"Version": "1.14.0",
"Version": "1.15.0",
"LoadPriority": 0,
"ConVars": [
{
Expand Down
12 changes: 11 additions & 1 deletion Northstar.Custom/mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Northstar.Custom",
"Description": "Custom content for Northstar: extra weapons, gamemodes, etc.",
"Version": "1.14.0",
"Version": "1.15.0",
"LoadPriority": 1,
"ConVars": [
{
Expand Down Expand Up @@ -443,6 +443,16 @@
{
"Path": "sh_northstar_http_requests.gnut",
"RunOn": "CLIENT || SERVER || UI"
},
{
"Path": "sh_northstar_matchmaker.gnut",
"RunOn": "CLIENT || SERVER",
"ClientCallback": {
"Before": "Sh_Northstar_MatchMaker_Init"
},
"ServerCallback": {
"Before": "Sh_Northstar_MatchMaker_Init"
}
}
],

Expand Down
26 changes: 26 additions & 0 deletions Northstar.Custom/mod/scripts/vscripts/sh_northstar_matchmaker.gnut
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
global function Sh_Northstar_MatchMaker_Init

#if CLIENT
global function ServerCallback_ClientBackToLobby
#endif

void function Sh_Northstar_MatchMaker_Init()
{
AddCallback_OnRegisteringCustomNetworkVars( RegisterNorthstarMatchMakerNetworkFunctions )
}

void function RegisterNorthstarMatchMakerNetworkFunctions()
{
Remote_RegisterFunction( "ServerCallback_ClientBackToLobby" )
}

#if CLIENT
void function ServerCallback_ClientBackToLobby()
{
entity player = GetLocalClientPlayer()
if ( IsValid( player ) )
{
player.ClientCommand( "ns_start_reauth_and_leave_to_lobby" )
}
}
#endif
13 changes: 12 additions & 1 deletion Northstar.CustomServers/mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Northstar.CustomServers",
"Description": "Attempts to recreate the behaviour of vanilla Titanfall 2 servers, as well as changing some scripts to allow better support for mods",
"Version": "1.14.0",
"Version": "1.15.0",
"LoadPriority": 0,
"ConVars": [
{
Expand Down Expand Up @@ -53,6 +53,10 @@
{
"Name": "ns_allow_kill_commands",
"DefaultValue": "0"
},
{
"Name": "ns_send_clients_back_to_lobby_after_match",
"DefaultValue": "0"
}
],
"Scripts": [
Expand Down Expand Up @@ -157,6 +161,13 @@
"ServerCallback": {
"After": "AiTurretSentry_Init"
}
},
{
"Path": "_northstar_gamestate_update.gnut",
"RunOn": "SERVER && MP",
"ServerCallback": {
"After": "Northstar_GameStateUpdate_Init"
}
}
]
}
1 change: 1 addition & 0 deletions Northstar.CustomServers/mod/cfg/autoexec_ns_server.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ everything_unlocked 1 // 全解锁

// gameserver settings
ns_should_return_to_lobby 1 // 游戏结束后是否返回到大厅
ns_send_clients_back_to_lobby_after_match 0 // 游戏结束后是否将非主机玩家送回本地大厅

net_chan_limit_mode 2 // 踢出客户端netchan处理延迟过高的玩家
net_chan_limit_msec_per_sec 100 // 客户端netchan处理延迟阈值
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
global function Northstar_GameStateUpdate_Init

void function Northstar_GameStateUpdate_Init()
{
RegisterServerVarChangeCallback( "gameState", OnGameStateChanged )
}

void function OnGameStateChanged()
{
NSUpdateSQGameState( GetGameState() )
}
24 changes: 24 additions & 0 deletions Northstar.CustomServers/mod/scripts/vscripts/mp/_changemap.nut
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@ void function CodeCallback_MatchIsOver()
PopulatePostgameData()
#endif

// nscn specific
float serverMapChangeDelay = 0.0 // default is no delay

if ( ShouldSendClientsBackToLobby() )
{
foreach ( entity player in GetPlayerArray() )
{
if ( !NSIsPlayerLocalPlayer( player ) )
Remote_CallFunction_NonReplay( player, "ServerCallback_ClientBackToLobby" )
}

serverMapChangeDelay = 5.0 // add 500ms grace period for clients to disconnect
}

thread ChangeServerMapAfterDelay( serverMapChangeDelay )
//
}


void function ChangeServerMapAfterDelay( float delay = 0.0 )
{
if ( delay > 0 )
wait delay

if ( ShouldReturnToLobby() )
{
SetCurrentPlaylist( "private_match" ) // needed for private lobby to load
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ void function SetGameState( int newState )

SetServerVar( "gameStateChangeTime", Time() )
SetServerVar( "gameState", newState )
NSUpdateSQGameState(newState)
svGlobal.levelEnt.Signal( "GameStateChanged" )

// added in AddCallback_GameStateEnter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ bool function IsNorthstarServer()
bool function ShouldReturnToLobby()
{
return GetConVarBool( "ns_should_return_to_lobby" )
}

// whether the game should send other clients back to lobby on GameRules_EndMatch()
// requires loading "sh_northstar_matchmaker.gnut"
bool function ShouldSendClientsBackToLobby()
{
return GetConVarBool( "ns_send_clients_back_to_lobby_after_match" )
}

0 comments on commit edf2ca3

Please sign in to comment.