Skip to content

Commit

Permalink
Clears invalid loadout gear/restricts to actual point value. (#7477)
Browse files Browse the repository at this point in the history
# About the pull request
If you're above the cap when it comes to points used in the loadout, now
the loadout item/gear will be removed.

# Explain why it's good for the game
You have a set amount of points for a reason, this hinders people
staying above the point cap after changes are made to cost or even
new/old things are added or removed.


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

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl: Nanu, HarryOb
code: Adds some code so if you're above the pointcap on your loadout,
items will be removed to put you at the point cap limit.
/:cl:

Co-authored-by: harryob <[email protected]>
  • Loading branch information
Nanu308 and harryob authored Nov 4, 2024
1 parent 3f01c2b commit ec28eea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions code/__HELPERS/sanitize_values.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,23 @@
if(65 to 70) . += ascii2text(ascii+32) //letters A to F - translates to lowercase
else return default
return .

/proc/sanitize_gear(list/gear, client/user)
var/list/sanitized_gear = list()
var/running_cost = 0

for(var/gear_option in gear)
if(!GLOB.gear_datums_by_name[gear_option])
continue

var/datum/gear/gear_datum = GLOB.gear_datums_by_name[gear_option]
var/new_total = running_cost + gear_datum.cost

if(new_total > MAX_GEAR_COST)
to_chat(user, SPAN_WARNING("Your [gear_option] was removed from your loadout as it exceeded the point limit."))
continue

running_cost = new_total
sanitized_gear += gear_option

return sanitized_gear
2 changes: 1 addition & 1 deletion code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@
if(!organ_data)
organ_data = list()

gear = sanitize_list(gear)
gear = sanitize_gear(gear, owner)

traits = sanitize_list(traits)
read_traits = FALSE
Expand Down

0 comments on commit ec28eea

Please sign in to comment.