Skip to content

Commit ee74a54

Browse files
authored
Merge branch 'main' into material_reload
2 parents b559bf7 + 2d3ed5e commit ee74a54

File tree

6 files changed

+85
-10
lines changed

6 files changed

+85
-10
lines changed

.github/nativefuncs.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"name":"NSSetModEnabled",
1717
"helpText":"",
1818
"returnTypeString":"void",
19-
"argTypes":"string modName, bool enabled"
19+
"argTypes":"string modName, string modVersion, bool enabled"
2020
},
2121
{
2222
"name":"DecodeJSON",
@@ -222,7 +222,7 @@
222222
"name":"NSSetModEnabled",
223223
"helpText":"",
224224
"returnTypeString":"void",
225-
"argTypes":"string modName, bool enabled"
225+
"argTypes":"string modName, string modVersion, bool enabled"
226226
},
227227
{
228228
"name":"DecodeJSON",
@@ -392,7 +392,7 @@
392392
"name":"NSSetModEnabled",
393393
"helpText":"",
394394
"returnTypeString":"void",
395-
"argTypes":"string modName, bool enabled"
395+
"argTypes":"string modName, string modVersion, bool enabled"
396396
},
397397
{
398398
"name": "NSFetchVerifiedModsManifesto",

Northstar.Client/mod/scripts/vscripts/client/cl_player.gnut

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ global function GetWaveSpawnTime
4141
global function ServerCallback_HideNextSpawnMessage
4242

4343
global function ClientCodeCallback_OnHealthChanged
44+
45+
// Northstar
46+
global function AddCallback_OnCrosshairCurrentTargetChanged
4447
global function ClientCodeCallback_OnCrosshairCurrentTargetChanged
4548
global function Pressed_TitanNextMode
4649
global function ClientCodeCallback_OnGib
@@ -70,6 +73,9 @@ struct {
7073
var law_missile_tracer = null
7174
float nextSpawnTime = 0.0
7275
entity lastEarnedReward // primarily used to check if we should still show the reward message after a delay
76+
77+
// Northstar
78+
array< void functionref( entity, entity ) > OnCrosshairCurrentTargetChangedCallbacks
7379
} file
7480

7581
struct BloodDecalParams
@@ -1515,6 +1521,14 @@ void function ClientCodeCallback_OnHealthChanged( entity ent, int oldHealth, int
15151521
ent.Signal( "HealthChanged", { oldHealth = oldHealth, newHealth = newHealth } )
15161522
}
15171523

1524+
// Northstar
1525+
void function AddCallback_OnCrosshairCurrentTargetChanged( void functionref( entity, entity ) callbackFunc )
1526+
{
1527+
Assert( !file.OnCrosshairCurrentTargetChangedCallbacks.contains( callbackFunc ), "Already added " + string( callbackFunc ) + " with AddCallback_OnCrosshairCurrentTargetChanged" )
1528+
1529+
file.OnCrosshairCurrentTargetChangedCallbacks.append( callbackFunc )
1530+
}
1531+
15181532
void function ClientCodeCallback_OnCrosshairCurrentTargetChanged( entity player, entity newTarget )
15191533
{
15201534
if ( IsLobby() )
@@ -1524,6 +1538,12 @@ void function ClientCodeCallback_OnCrosshairCurrentTargetChanged( entity player,
15241538

15251539
if ( IsValid( newTarget ) )
15261540
TryOfferRodeoBatteryHint( newTarget )
1541+
1542+
// Northstar
1543+
foreach ( callback in file.OnCrosshairCurrentTargetChangedCallbacks )
1544+
{
1545+
callback( player, newTarget )
1546+
}
15271547
}
15281548

15291549
void function SetupPlayerAnimEvents( entity player )

Northstar.Client/mod/scripts/vscripts/client/cl_sp_player.gnut

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ global function GetWaveSpawnTime
3131
global function ServerCallback_HideNextSpawnMessage
3232

3333
global function ClientCodeCallback_OnHealthChanged
34+
35+
// Northstar
36+
global function AddCallback_OnCrosshairCurrentTargetChanged
37+
global function ClientCodeCallback_OnCrosshairCurrentTargetChanged
38+
3439
global function Pressed_TitanNextMode
3540
global function ClientCodeCallback_OnGib
3641
global function ClientPilotSpawned
@@ -59,6 +64,9 @@ struct {
5964
var law_missile_tracer = null
6065
float nextSpawnTime = 0.0
6166
var UI_friendlyText
67+
68+
// Northstar
69+
array< void functionref( entity, entity ) > OnCrosshairCurrentTargetChangedCallbacks
6270
} file
6371

6472
struct BloodDecalParams
@@ -1261,6 +1269,24 @@ void function ClientCodeCallback_OnHealthChanged( entity ent, int oldHealth, int
12611269
ent.Signal( "HealthChanged", { oldHealth = oldHealth, newHealth = newHealth } )
12621270
}
12631271

1272+
// Northstar
1273+
void function AddCallback_OnCrosshairCurrentTargetChanged( void functionref( entity, entity ) callbackFunc )
1274+
{
1275+
Assert( !file.OnCrosshairCurrentTargetChangedCallbacks.contains( callbackFunc ), "Already added " + string( callbackFunc ) + " with AddCallback_OnCrosshairCurrentTargetChanged" )
1276+
1277+
file.OnCrosshairCurrentTargetChangedCallbacks.append( callbackFunc )
1278+
}
1279+
1280+
void function ClientCodeCallback_OnCrosshairCurrentTargetChanged( entity player, entity newTarget )
1281+
{
1282+
if ( !IsValid( player ) )
1283+
return
1284+
1285+
foreach ( callback in file.OnCrosshairCurrentTargetChangedCallbacks )
1286+
{
1287+
callback( player, newTarget )
1288+
}
1289+
}
12641290

12651291
void function SetupPlayerAnimEvents( entity player )
12661292
{

Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void function OnModMenuClosed()
149149

150150
foreach ( ModInfo enMod in file.enabledMods )
151151
{
152-
if ( mod.name == enMod.name )
152+
if ( mod.name == enMod.name && mod.version == enMod.version )
153153
{
154154
notFound = false
155155
break
@@ -210,7 +210,7 @@ void function OnModButtonPressed( var button )
210210
CoreModToggleDialog( modName )
211211
else
212212
{
213-
NSSetModEnabled( modName, !mod.enabled )
213+
NSSetModEnabled( modName, mod.version, !mod.enabled )
214214

215215
// retrieve state of the mod that just got toggled
216216
array<ModInfo> infos = NSGetModInformation( mod.name )
@@ -304,7 +304,7 @@ void function DisableMod()
304304
{
305305
ModInfo mod = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) + file.scrollOffset - 1 ].mod
306306
string modName = mod.name
307-
NSSetModEnabled( modName, false )
307+
NSSetModEnabled( modName, mod.version, false )
308308

309309
// retrieve state of the mod that just got toggled
310310
array<ModInfo> infos = NSGetModInformation( mod.name )

Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha
11321132
if (!found)
11331133
{
11341134
modsChanged = true
1135-
NSSetModEnabled( modName, false )
1135+
NSSetModEnabled( modName, modVersion, false )
11361136
print(format("Disabled \"%s\" (v%s) since it's not required on server.", modName, modVersion))
11371137
}
11381138
}
@@ -1151,7 +1151,7 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha
11511151
if ( !localModInfos[0].enabled )
11521152
{
11531153
modsChanged = true
1154-
NSSetModEnabled( modName, true )
1154+
NSSetModEnabled( modName, localModInfos[0].version, true )
11551155
print(format("Enabled \"%s\" (v%s) to join server.", modName, localModInfos[0].version))
11561156
}
11571157
}
@@ -1160,10 +1160,10 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha
11601160
{
11611161
foreach( localMod in localModInfos )
11621162
{
1163-
if ( localMod.version == mod.version )
1163+
if ( localMod.version == mod.version && !localMod.enabled)
11641164
{
11651165
modsChanged = true
1166-
NSSetModEnabled( mod.name, true )
1166+
NSSetModEnabled( mod.name, mod.version, true )
11671167
print(format("Enabled \"%s\" (v%s) to join server.", modName, modVersion))
11681168
break
11691169
}

Northstar.Custom/mod/scripts/vscripts/sh_northstar_http_requests.gnut

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ void function NSHandleSuccessfulHttpRequest( int handle, int statusCode, string
8989
response.statusCode = statusCode
9090
response.body = body
9191
response.rawHeaders = headers
92+
response.headers = {}
9293

9394
// Parse the raw headers into key -> values
9495
array<string> values = split( headers, "\n" )
@@ -156,6 +157,13 @@ void function NSHandleFailedHttpRequest( int handle, int errorCode, string error
156157
*/
157158
bool function NSHttpRequest( HttpRequest requestParameters, void functionref( HttpRequestResponse ) onSuccess = null, void functionref( HttpRequestFailure ) onFailure = null )
158159
{
160+
#if CLIENT
161+
if ( IsPlayingDemo() )
162+
{
163+
return false
164+
}
165+
#endif
166+
159167
int handle = NS_InternalMakeHttpRequest( requestParameters.method, requestParameters.url, requestParameters.headers,
160168
requestParameters.queryParameters, requestParameters.contentType, requestParameters.body, requestParameters.timeout, requestParameters.userAgent )
161169

@@ -182,6 +190,13 @@ bool function NSHttpRequest( HttpRequest requestParameters, void functionref( Ht
182190
*/
183191
bool function NSHttpGet( string url, table< string, array< string > > queryParameters = {}, void functionref( HttpRequestResponse ) onSuccess = null, void functionref( HttpRequestFailure ) onFailure = null )
184192
{
193+
#if CLIENT
194+
if ( IsPlayingDemo() )
195+
{
196+
return false
197+
}
198+
#endif
199+
185200
HttpRequest request
186201
request.method = HttpRequestMethod.GET
187202
request.url = url
@@ -201,6 +216,13 @@ bool function NSHttpGet( string url, table< string, array< string > > queryParam
201216
*/
202217
bool function NSHttpPostQuery( string url, table< string, array< string > > queryParameters, void functionref( HttpRequestResponse ) onSuccess = null, void functionref( HttpRequestFailure ) onFailure = null )
203218
{
219+
#if CLIENT
220+
if ( IsPlayingDemo() )
221+
{
222+
return false
223+
}
224+
#endif
225+
204226
HttpRequest request
205227
request.method = HttpRequestMethod.POST
206228
request.url = url
@@ -220,6 +242,13 @@ bool function NSHttpPostQuery( string url, table< string, array< string > > quer
220242
*/
221243
bool function NSHttpPostBody( string url, string body, void functionref( HttpRequestResponse ) onSuccess = null, void functionref( HttpRequestFailure ) onFailure = null )
222244
{
245+
#if CLIENT
246+
if ( IsPlayingDemo() )
247+
{
248+
return false
249+
}
250+
#endif
251+
223252
HttpRequest request
224253
request.method = HttpRequestMethod.POST
225254
request.url = url

0 commit comments

Comments
 (0)