@@ -209,23 +209,23 @@ export const commandCallbacks = {
209209 game_set_level : ( client : Client , levelArg : string ) => {
210210 const level = parseInt ( levelArg ) ;
211211 const player = client . camera ?. cameraData . player ;
212- if ( isNaN ( level ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) ) return ;
212+ if ( ! isFinite ( level ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) ) return ;
213213 const finalLevel = client . accessLevel == AccessLevel . FullAccess ? level : Math . min ( maxPlayerLevel , level ) ;
214214 client . camera ?. setLevel ( finalLevel ) ;
215215 } ,
216216 game_set_score : ( client : Client , scoreArg : string ) => {
217217 const score = parseInt ( scoreArg ) ;
218218 const camera = client . camera ?. cameraData ;
219219 const player = client . camera ?. cameraData . player ;
220- if ( isNaN ( score ) || score > Number . MAX_SAFE_INTEGER || score < Number . MIN_SAFE_INTEGER || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
220+ if ( ! isFinite ( score ) || score > Number . MAX_SAFE_INTEGER || score < Number . MIN_SAFE_INTEGER || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
221221 camera . score = score ;
222222 } ,
223223 game_set_stat_max : ( client : Client , statIdArg : string , statMaxArg : string ) => {
224224 const statId = StatCount - parseInt ( statIdArg ) ;
225225 const statMax = parseInt ( statMaxArg ) ;
226226 const camera = client . camera ?. cameraData ;
227227 const player = client . camera ?. cameraData . player ;
228- if ( statId < 0 || statId >= StatCount || isNaN ( statId ) || isNaN ( statMax ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
228+ if ( statId < 0 || statId >= StatCount || ! isFinite ( statId ) || ! isFinite ( statMax ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
229229 const clampedStatMax = Math . max ( statMax , 0 ) ;
230230 camera . statLimits [ statId as Stat ] = clampedStatMax ;
231231 camera . statLevels [ statId as Stat ] = Math . min ( camera . statLevels [ statId as Stat ] , clampedStatMax ) ;
@@ -235,14 +235,14 @@ export const commandCallbacks = {
235235 const statPoints = parseInt ( statPointsArg ) ;
236236 const camera = client . camera ?. cameraData ;
237237 const player = client . camera ?. cameraData . player ;
238- if ( statId < 0 || statId >= StatCount || isNaN ( statId ) || isNaN ( statPoints ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
238+ if ( statId < 0 || statId >= StatCount || ! isFinite ( statId ) || ! isFinite ( statPoints ) || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
239239 camera . statLevels [ statId as Stat ] = statPoints ;
240240 } ,
241241 game_add_upgrade_points : ( client : Client , pointsArg : string ) => {
242242 const points = parseInt ( pointsArg ) ;
243243 const camera = client . camera ?. cameraData ;
244244 const player = client . camera ?. cameraData . player ;
245- if ( isNaN ( points ) || points > Number . MAX_SAFE_INTEGER || points < Number . MIN_SAFE_INTEGER || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
245+ if ( ! isFinite ( points ) || points > Number . MAX_SAFE_INTEGER || points < Number . MIN_SAFE_INTEGER || ! Entity . exists ( player ) || ! TankBody . isTank ( player ) || ! camera ) return ;
246246 camera . statsAvailable += points ;
247247 } ,
248248 game_teleport : ( client : Client , xArg : string , yArg : string ) => {
@@ -254,7 +254,7 @@ export const commandCallbacks = {
254254 const x = xArg . match ( RELATIVE_POS_REGEX ) ? player . positionData . x + parseInt ( xArg . slice ( 1 ) || "0" , 10 ) : parseInt ( xArg , 10 ) ;
255255 const y = yArg . match ( RELATIVE_POS_REGEX ) ? player . positionData . y + parseInt ( yArg . slice ( 1 ) || "0" , 10 ) : parseInt ( yArg , 10 ) ;
256256
257- if ( isNaN ( x ) || isNaN ( y ) ) return ;
257+ if ( ! isFinite ( x ) || ! isFinite ( y ) ) return ;
258258
259259 player . positionData . x = x ;
260260 player . positionData . y = y ;
@@ -355,11 +355,11 @@ export const commandCallbacks = {
355355 [ "Triangle" , Triangle ]
356356 ] as [ string , typeof ObjectEntity ] [ ] ) . get ( entityArg ) ;
357357
358- if ( isNaN ( count ) || count < 0 || ! game || ! TEntity ) return ;
358+ if ( ! isFinite ( count ) || count < 0 || ! game || ! TEntity ) return ;
359359
360360 for ( let i = 0 ; i < count ; ++ i ) {
361361 const boss = new TEntity ( game ) ;
362- if ( ! isNaN ( x ) && ! isNaN ( y ) ) {
362+ if ( isFinite ( x ) && isFinite ( y ) ) {
363363 boss . positionData . x = x ;
364364 boss . positionData . y = y ;
365365 }
0 commit comments