Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get lobby announcement from Atlas #699

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Northstar.Client/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@
}
}
],
"Dependencies": {
"HAS_NORTHSTAR_CUSTOM": "Northstar.Custom"
},
"Localisation": [
"resource/northstar_client_localisation_%language%.txt"
]
Expand Down
4 changes: 4 additions & 0 deletions Northstar.Client/mod/scripts/vscripts/ui/_menus.nut
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,10 @@ void function UpdateMenusOnConnect( string levelname )
}

thread UpdateAnnouncementDialog()
#if HAS_NORTHSTAR_CUSTOM
// relies on script HTTP which is in Northstar.Custom
thread GetAtlasAnnouncement_Threaded()
#endif // HAS_NORTHSTAR_CUSTOM
Comment on lines +816 to +819
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done to avoid having to override ui/_menus.nut in Northstar.Custom as well.
I could have done the HTTP stuff in Launcher, but that then splits this feature into 3 PRs :/

Unfortunately this does mean that clients who have Northstar.Custom disabled will not see the announcements. This makes up a tiny proportion of the playerbase, so personally I'm not too concerned.

}
else
{
Expand Down
4 changes: 4 additions & 0 deletions Northstar.Custom/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@
"Path": "sh_northstar_safe_io.gnut",
"RunOn": "CLIENT || SERVER || UI"
},
{
"Path": "_atlas_announcements.nut",
"RunOn": "UI"
},
{
"Path": "_testing.nut",
"RunOn": "CLIENT || SERVER || UI",
Expand Down
57 changes: 57 additions & 0 deletions Northstar.Custom/mod/scripts/vscripts/_atlas_announcements.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
untyped

global function GetAtlasAnnouncement_Threaded

const string ATLAS_ANNOUNCEMENT_SUFFIX = "/client/announcement"

void function GetAtlasAnnouncement_Threaded()
{
string url = format( "%s%s", GetConVarString( "ns_masterserver_hostname" ), ATLAS_ANNOUNCEMENT_SUFFIX )
printt( format( "Getting announcement data from %s", url ) )

if ( !NSHttpGet( url, {}, OnRequestSuccess, OnRequestFailure ) )
printt( "Failed to get announcement data! (request failed to start)" )
}

void function OnRequestSuccess( HttpRequestResponse response )
{
if ( response.statusCode != 200 )
{
printt( format( "Failed to get announcement data! (Code: %i)\nReceived response: %s", response.statusCode, response.body ) )
return
}

string announcement
string announcementVersion

table responseBody = DecodeJSON( response.body )

if ( "announcement" in responseBody && typeof( responseBody[ "announcement" ] ) == "string" )
{
announcement = expect string( responseBody[ "announcement" ] )
}
else
{
printt( "Failed to parse announcement data! Couldnt parse \"announcement\" field,\n", response.body )
return
}

if ( "announcementVersion" in responseBody && typeof( responseBody[ "announcementVersion" ] ) == "string" )
{
announcementVersion = expect string( responseBody[ "announcementVersion" ] )
}
else
{
printt( "Failed to parse announcement data! Couldnt parse \"announcementVersion\" field,\n", response.body )
return
}

printt( "Successfully got announcement data!" )
SetConVarString( "announcement", announcement )
SetConVarString( "announcementVersion", announcementVersion )
}

void function OnRequestFailure( HttpRequestFailure response )
{
printt( format( "Failed to get announcement data! (Code: %i)\nReceived response: %s", response.errorCode, response.errorMessage ) )
}
3 changes: 0 additions & 3 deletions Northstar.CustomServers/mod/cfg/autoexec_ns_server.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,3 @@ sv_minupdaterate 20 // unsure if this actually works, but if it does, should set
sv_max_snapshots_multiplayer 300 // this needs to be updaterate * 15, or clients will dc in killreplay
net_data_block_enabled 0 // not really sure on this, have heard datablock could have security issues? doesn't seem to have any adverse effects being disabled
host_skip_client_dll_crc 1 // allow people to run modded client dlls, this is mainly so people running pilot visor colour mods can keep those, since they use a client.dll edit

announcementVersion 1
announcement #PROGRESSION_ANNOUNCEMENT_BODY
Loading