mirror of
https://github.com/R2Northstar/NorthstarMods
synced 2026-08-25 12:29:17 -04:00
Fix client sending invalid args to server commands (#945)
* Fix client sending invalid args to server commands
This commit is contained in:
parent
d15a117eb3
commit
ec88120a97
6 changed files with 89 additions and 15 deletions
|
|
@ -4914,8 +4914,10 @@ string function GetRefFromItem( item )
|
|||
|
||||
function SubitemDefined( string parentRef, string childRef )
|
||||
{
|
||||
Assert( parentRef in file.itemData )
|
||||
return (childRef in file.itemData[parentRef].subitems)
|
||||
if ( !( parentRef in file.itemData ) )
|
||||
return false
|
||||
|
||||
return ( childRef in file.itemData[parentRef].subitems )
|
||||
}
|
||||
|
||||
ItemDisplayData function GetSubitemDisplayData( string parentRef, string childRef )
|
||||
|
|
@ -7971,7 +7973,7 @@ bool function ClientCommand_BuyTicket( entity player, array<string> args )
|
|||
|
||||
|
||||
int numTickets = 1
|
||||
if ( args.len() > 0 )
|
||||
if ( args.len() && int( args[0] ) > 0 )
|
||||
numTickets = int( args[0] )
|
||||
|
||||
int cost = GetItemCost( ref ) * numTickets
|
||||
|
|
|
|||
|
|
@ -212,14 +212,22 @@ bool function ClientCommandCallback_SwapSecondaryAndWeapon3PersistentLoadoutData
|
|||
bool function ClientCommandCallback_SetBurnCardPersistenceSlot( entity player, array<string> args )
|
||||
{
|
||||
if ( args.len() != 1 || GetGameState() >= eGameState.Playing )
|
||||
return true
|
||||
return false
|
||||
|
||||
print( player + " SetBurnCardPersistenceSlot " + args[0] )
|
||||
|
||||
if ( IsRefValidAndOfType( args[0], eItemTypes.BURN_METER_REWARD ) )
|
||||
player.SetPersistentVar( "burnmeterSlot", BurnReward_GetByRef( args[0] ).id )
|
||||
{
|
||||
if ( !IsItemLocked( player, args[0] ) )
|
||||
player.SetPersistentVar( "burnmeterSlot", BurnReward_GetByRef( args[0] ).id )
|
||||
else
|
||||
return false
|
||||
}
|
||||
else
|
||||
{
|
||||
print( player + " invalid ref " + args[0] )
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
@ -227,34 +235,69 @@ bool function ClientCommandCallback_SetBurnCardPersistenceSlot( entity player, a
|
|||
// lobby clientcommands
|
||||
bool function ClientCommandCallback_SetCallsignIcon( entity player, array<string> args )
|
||||
{
|
||||
if ( !args.len() )
|
||||
args.append( "" )
|
||||
|
||||
print( player + " SetCallsignIcon " + args[0] )
|
||||
|
||||
if ( IsRefValidAndOfType( args[0], eItemTypes.CALLSIGN_ICON ) )
|
||||
PlayerCallsignIcon_SetActiveByRef( player, args[0] )
|
||||
{
|
||||
if ( !IsItemLocked( player, args[0] ) )
|
||||
PlayerCallsignIcon_SetActiveByRef( player, args[0] )
|
||||
else
|
||||
return false
|
||||
}
|
||||
else
|
||||
{
|
||||
print( player + " invalid ref " + args[0] )
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
bool function ClientCommandCallback_SetCallsignCard( entity player, array<string> args )
|
||||
{
|
||||
print( player + " SetCallsignIcon " + args[0] )
|
||||
if ( !args.len() )
|
||||
args.append( "" )
|
||||
|
||||
print( player + " SetCallsignCard " + args[0] )
|
||||
|
||||
if ( IsRefValidAndOfType( args[0], eItemTypes.CALLING_CARD ) )
|
||||
PlayerCallingCard_SetActiveByRef( player, args[0] )
|
||||
{
|
||||
if ( !IsItemLocked( player, args[0] ) )
|
||||
PlayerCallingCard_SetActiveByRef( player, args[0] )
|
||||
else
|
||||
return false
|
||||
}
|
||||
else
|
||||
{
|
||||
print( player + " invalid ref " + args[0] )
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
bool function ClientCommandCallback_SetFactionChoicePersistenceSlot( entity player, array<string> args )
|
||||
{
|
||||
if ( !args.len() )
|
||||
args.append( "" )
|
||||
|
||||
print( player + " SetFactionChoicePersistenceSlot " + args[0] )
|
||||
|
||||
if ( IsRefValidAndOfType( args[0], eItemTypes.FACTION ) )
|
||||
player.SetPersistentVar( "factionChoice", args[0] ) // no function for this so gotta set directly lol
|
||||
{
|
||||
if ( !IsItemLocked( player, args[0] ) )
|
||||
player.SetPersistentVar( "factionChoice", args[0] )
|
||||
else
|
||||
return false
|
||||
}
|
||||
else
|
||||
{
|
||||
print( player + " invalid ref " + args[0] )
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,6 +101,9 @@ function AiSoldiers_Init()
|
|||
|
||||
bool function ClientCommand_SpawnViewGrunt( entity player, array<string> args )
|
||||
{
|
||||
if ( !args.len() )
|
||||
return true
|
||||
|
||||
int team = args[0].tointeger()
|
||||
if ( GetDeveloperLevel() < 1 )
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -76,9 +76,16 @@ bool function ClientCommandCallback_PrivateMatchSetMode( entity player, array<st
|
|||
if ( !NSIsPlayerLocalPlayer( player ) )
|
||||
return true
|
||||
|
||||
LogPrivateMatchChange( player , " changed the mode to " , args )
|
||||
if ( GetPrivateMatchModes().contains( args[0] ) )
|
||||
{
|
||||
LogPrivateMatchChange( player , " changed the mode to " , args )
|
||||
}
|
||||
else
|
||||
{
|
||||
LogPrivateMatchChange( player , " attempted to set an invalid mode: " , args )
|
||||
return true
|
||||
}
|
||||
|
||||
// todo: need to verify this value
|
||||
file.mode = args[0]
|
||||
//GameRules_SetGameMode( args[0] ) // can't do this here due to out of sync errors with new clients
|
||||
|
||||
|
|
@ -99,10 +106,18 @@ bool function ClientCommandCallback_SetCustomMap( entity player, array<string> a
|
|||
if ( GetConVarInt( "ns_private_match_only_host_can_change_settings" ) == 2 )
|
||||
if ( !NSIsPlayerLocalPlayer( player ) )
|
||||
return true
|
||||
|
||||
LogPrivateMatchChange( player , " changed the map to " , args )
|
||||
|
||||
// todo: need to verify this value
|
||||
if ( GetPrivateMatchMapsForMode( file.mode ).contains( args[0] ) )
|
||||
{
|
||||
LogPrivateMatchChange( player , " changed the map to " , args )
|
||||
}
|
||||
else
|
||||
{
|
||||
args[0] += " for mode: " + file.mode
|
||||
LogPrivateMatchChange( player , " attempted to set an invalid map: " , args )
|
||||
return true
|
||||
}
|
||||
|
||||
file.map = args[0]
|
||||
|
||||
// todo: this should NOT be necessary, private matches should use an api to register maps in the future rather than hardcoded ids
|
||||
|
|
@ -213,6 +228,9 @@ void function RefreshPlayerTeams()
|
|||
|
||||
bool function ClientCommandCallback_PrivateMatchSetPlaylistVarOverride( entity player, array<string> args )
|
||||
{
|
||||
if ( file.startState == ePrivateMatchStartState.STARTING )
|
||||
return true
|
||||
|
||||
if ( args.len() < 2 )
|
||||
return true
|
||||
|
||||
|
|
@ -243,6 +261,9 @@ bool function ClientCommandCallback_PrivateMatchSetPlaylistVarOverride( entity p
|
|||
|
||||
bool function ClientCommandCallback_ResetMatchSettingsToDefault( entity player, array<string> args )
|
||||
{
|
||||
if ( file.startState == ePrivateMatchStartState.STARTING )
|
||||
return true
|
||||
|
||||
if ( GetConVarInt( "ns_private_match_only_host_can_change_settings" ) >= 1 )
|
||||
if ( !NSIsPlayerLocalPlayer( player ) )
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -96,6 +96,9 @@ function ControlsInit()
|
|||
|
||||
bool function ClientCommand_ModelViewer( entity player, array<string> args )
|
||||
{
|
||||
if ( !args.len() )
|
||||
return true
|
||||
|
||||
string command = args[ 0 ]
|
||||
switch ( command )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ function TitanCommands_Init()
|
|||
|
||||
bool function Prototype_OrderTitanMove( entity player, array<string> args )
|
||||
{
|
||||
Assert( args.len() == 3 )
|
||||
if ( args.len() != 3 )
|
||||
return true
|
||||
|
||||
vector pos = Vector( args[0].tofloat(), args[1].tofloat(), args[2].tofloat() )
|
||||
|
||||
DebugDrawLine( pos, pos + Vector(0,0,500), 255, 0, 0, true, 5.0 )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue