Skip to content
Open
Show file tree
Hide file tree
Changes from 13 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
4 changes: 4 additions & 0 deletions Northstar.Client/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@
}
},
{
"Path": "ui/_atlas_announcements.nut",
"RunOn": "UI"
},
{
"Path": "ui/ns_client_mod_settings.gnut",
"RunOn": "UI",
"UICallback":{
Expand Down
75 changes: 75 additions & 0 deletions Northstar.Client/mod/scripts/vscripts/ui/_atlas_announcements.nut
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
untyped

global function GetAtlasAnnouncement_Threaded

const string ATLAS_ANNOUNCEMENT_SUFFIX = "/client/announcements"

void function GetAtlasAnnouncement_Threaded()
{
// TODO: All Northstar.Client files are loaded before Northstar.Custom currently, so these have to be lambdas because this file is loaded
// before sh_northstar_http_requests so the types used as function parameters cause compile errors.
// A weird quirk of the squirrel compiler seems to be that it gathers global defs first, and compiles them after? So by the time it's compiling the innards of
// GetAtlasAnnouncement_Threaded it knows about the types from sh_northstar_http_requests.
// Anyway a solution to this would be to have sh_northstar_http_requests belong to some
// sort of Northstar.Core or Northstar.Shared. (Same with other APIs such as file IO)
void functionref( HttpRequestResponse ) onRequestSuccess = void function( 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
}

// empty announcement
if ( announcement == "" || announcementVersion == "" )
{
printt( "Found empty announcement data." )
return
}

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

void functionref( HttpRequestFailure ) onRequestFailure = void function( HttpRequestFailure response )
{
printt( format( "Failed to get announcement data! (Code: %i)\nReceived response: %s", response.errorCode, response.errorMessage ) )
}

while ( true )
{
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)" )

wait 300 // check for a new announcement every 5 minutes, why not
}
}
5 changes: 5 additions & 0 deletions Northstar.Client/mod/scripts/vscripts/ui/_menus.nut
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,11 @@ void function UpdateMenusOnConnect( string levelname )
}

thread UpdateAnnouncementDialog()
#if !VANILLA
// this ends up messing with announcementVersionSeen in persistence,
// so we should avoid doing that in vanilla
thread GetAtlasAnnouncement_Threaded()
#endif
}
else
{
Expand Down
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