-
Notifications
You must be signed in to change notification settings - Fork 124
Get lobby announcement from Atlas #699
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
Open
ASpoonPlaysGames
wants to merge
14
commits into
R2Northstar:main
Choose a base branch
from
ASpoonPlaysGames:atlas-announcements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5f475bf
Get lobby announcement from Atlas
ASpoonPlaysGames b4053dd
Merge branch 'main' into atlas-announcements
ASpoonPlaysGames 6f051af
Merge branch 'main' into atlas-announcements
ASpoonPlaysGames 1596265
Merge branch 'main' into atlas-announcements
Alystrasz cf3f8b1
move to Northstar.Client now that HTTP isn't in Custom specifically
ASpoonPlaysGames e02fd13
Merge branch 'main' into atlas-announcements
ASpoonPlaysGames 74bbaeb
Merge branch 'main' into atlas-announcements
Alystrasz 4cc85d7
fix compile and functionality
ASpoonPlaysGames 3d26302
dont run on vanilla
ASpoonPlaysGames eaded94
Merge branch 'main' into atlas-announcements
ASpoonPlaysGames 5a3de42
fix formatting
ASpoonPlaysGames de63d2f
Merge branch 'main' into atlas-announcements
catornot ed6a202
Merge branch 'main' into atlas-announcements
Alystrasz 54c2058
Merge branch 'main' into atlas-announcements
Alystrasz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
Northstar.Custom/mod/scripts/vscripts/_atlas_announcements.nut
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ) ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.