Skip to content

Commit

Permalink
[s] Another number input guard (#5649)
Browse files Browse the repository at this point in the history
# About the pull request

This PR is a followup to #5633 adding another guard to a handling of
numbers this time in TGUI number input.

# Explain why it's good for the game

Numbers should be numbers.

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>


![image](https://github.com/cmss13-devs/cmss13/assets/76988376/4feb0794-1101-49ef-94ca-501e95380fa1)

</details>


# Changelog
No player facing changes.
  • Loading branch information
Drulikar authored Feb 4, 2024
1 parent 7ded229 commit 2657502
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions code/modules/tgui/tgui_number_input.dm
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,13 @@
return
switch(action)
if("submit")
if(!isnum(params["entry"]))
CRASH("A non number was input into tgui input number by [usr]")
var/choice = params["entry"]
if(!isnum(choice))
CRASH("A non number was input into tgui input number by [usr]")
if(choice != choice) //isnan
CRASH("A NaN was input into tgui input number by [usr]")
if(integer_only)
choice = round(params["entry"])
choice = round(choice)
if(choice > max_value)
CRASH("A number greater than the max value was input into tgui input number by [usr]")
if(choice < min_value)
Expand Down

0 comments on commit 2657502

Please sign in to comment.