Skip to content

Commit

Permalink
okay you can the stuff again
Browse files Browse the repository at this point in the history
  • Loading branch information
Superlagg committed Jul 16, 2023
1 parent b701972 commit f98ce1c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define DEFAULT_SLOT_AMT 4
#define MAX_FREE_PER_CAT 4
#define HANDS_SLOT_AMT 2
#define BACKPACK_SLOT_AMT 4

Expand Down Expand Up @@ -1304,7 +1304,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)

dat += "<table align='center' width='100%'>"
dat += "<tr><td colspan=4><center><b><font color='[gear_points == 0 ? "#E62100" : "#CCDDFF"]'>[gear_points]</font> loadout points remaining.</b> \[<a href='?_src_=prefs;preference=gear;clear_loadout=1'>Clear Loadout</a>\]</center></td></tr>"
dat += "<tr><td colspan=4><center>You can choose up to [DEFAULT_SLOT_AMT] item per category.</center></td></tr>"
dat += "<tr><td colspan=4><center>You can choose up to [MAX_FREE_PER_CAT] free items per category.</center></td></tr>"
dat += "<tr><td colspan=4><center><b>"

if(!length(GLOB.loadout_items))
Expand Down Expand Up @@ -3795,8 +3795,8 @@ GLOBAL_LIST_EMPTY(preferences_datums)
remove_gear_from_loadout(loadout_slot, "[G.type]")
else if(toggle && !(has_loadout_gear(loadout_slot, "[G.type]")))

if(!is_loadout_slot_available(G.category))
to_chat(user, span_danger("You cannot take this loadout, as you've already chosen too many of the same category!"))
if(!is_loadout_slot_available(G.category, G.cost))
to_chat(user, span_danger("You can only take [MAX_FREE_PER_CAT] free items from this category!"))
return

if(G.donoritem && !G.donator_ckey_check(user.ckey))
Expand Down Expand Up @@ -4044,15 +4044,22 @@ GLOBAL_LIST_EMPTY(preferences_datums)
key_bindings[key] = oldkeys[key]
parent?.ensure_keys_set(src)

/datum/preferences/proc/is_loadout_slot_available(slot)
/datum/preferences/proc/is_loadout_slot_available(category, cost)
if(cost)
return TRUE
var/list/L
LAZYINITLIST(L)
for(var/i in loadout_data["SAVE_[loadout_slot]"])
var/datum/gear/G = i[LOADOUT_ITEM]
var/loadie = i[LOADOUT_ITEM]
var/datum/gear/G = text2path(loadie)
if(initial(G.cost) > 0) // oh right, these are uninitialized, mb
continue // non-free items are self limiting
if(initial(G.category) != category)
continue
var/occupied_slots = L[initial(G.category)] ? L[initial(G.category)] + 1 : 1
LAZYSET(L, initial(G.category), occupied_slots)
for(var/things_got in L)
if(L[things_got] > DEFAULT_SLOT_AMT)
if(L[things_got] > MAX_FREE_PER_CAT)
return FALSE
return TRUE
/* switch(slot)
Expand All @@ -4063,7 +4070,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if(L[LOADOUT_CATEGORY_HANDS] < HANDS_SLOT_AMT)
return TRUE
else
if(L[slot] < DEFAULT_SLOT_AMT)
if(L[slot] < MAX_FREE_PER_CAT)
return TRUE */

/datum/preferences/proc/has_loadout_gear(save_slot, gear_type)
Expand All @@ -4090,6 +4097,6 @@ GLOBAL_LIST_EMPTY(preferences_datums)
to_chat(parent, span_userdanger("Something went wrong! Your quirks have been reset, and you'll need to set up your quirks again."))


#undef DEFAULT_SLOT_AMT
#undef MAX_FREE_PER_CAT
#undef HANDS_SLOT_AMT
#undef BACKPACK_SLOT_AMT

0 comments on commit f98ce1c

Please sign in to comment.