Skip to content

Commit

Permalink
Hopefully fix antag tokens, unusuals, and keybindings being wiped (#5089
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Absolucy authored Jan 25, 2025
1 parent 51a3984 commit 94aa3de
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
7 changes: 5 additions & 2 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ GLOBAL_LIST_EMPTY(preferences_datums)

/datum/preferences
var/client/parent
/// The key of the parent client.
var/parent_key
/// The path to the general savefile for this datum
var/path
/// Whether or not we allow saving/loading. Used for guests, if they're enabled
Expand Down Expand Up @@ -98,13 +100,14 @@ GLOBAL_LIST_EMPTY(preferences_datums)

/datum/preferences/New(client/parent)
src.parent = parent
src.parent_key = parent?.key

for (var/middleware_type in subtypesof(/datum/preference_middleware))
middleware += new middleware_type(src)

if(IS_CLIENT_OR_MOCK(parent))
load_and_save = !is_guest_key(parent.key)
load_path(parent.ckey)
load_and_save = !is_guest_key(parent_key)
load_path(ckey(parent_key))
if(load_and_save && !fexists(path))
try_savefile_type_migration()
unlock_content = !!parent.IsByondMember()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/datum/preferences/proc/try_savefile_type_migration()
load_path(parent.ckey, "preferences.sav") // old save file
var/parent_ckey = ckey(parent_key)
load_path(parent_ckey, "preferences.sav") // old save file
var/old_path = path
load_path(parent.ckey)
load_path(parent_ckey)
if(!fexists(old_path))
return
var/datum/json_savefile/json_savefile = new(path)
Expand Down
5 changes: 3 additions & 2 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
parsed_favs += path
favorite_outfits = unique_list(parsed_favs)

load_metacoins(parent.ckey)
load_inventory(parent.ckey)
var/parent_ckey = ckey(parent_key)
load_metacoins(parent_ckey)
load_inventory(parent_ckey)

load_preferences_monkestation()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
/datum/preferences/proc/level_up_reward(job)
if(!job || !job_level_list[job])
return
adjust_metacoins(parent.ckey, 25*job_level_list[job], "You have leveled up!", TRUE, TRUE, FALSE)
adjust_metacoins(ckey(parent_key), 25*job_level_list[job], "You have leveled up!", TRUE, TRUE, FALSE)

/datum/preferences/proc/return_xp_for_nextlevel()
var/list/jobs_with_xp = list()
Expand Down
11 changes: 6 additions & 5 deletions monkestation/code/modules/loadouts/loadout_middleware.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,18 @@
stack_trace("Failed to locate desired loadout item (path: [params["path"]]) in the global list of loadout datums!")
return null

var/parent_ckey = ckey(preferences.parent_key)
//Here we will perform basic checks to ensure there are no exploits happening
if(interacted_item.donator_only && !preferences.parent.player_details.patreon?.is_donator() && !preferences.parent.player_details.twitch?.is_donator() && !is_admin(preferences.parent))
message_admins("LOADOUT SYSTEM: Possible exploit detected, non-donator [preferences.parent.ckey] tried loading [interacted_item.item_path], but this is donator only.")
message_admins("LOADOUT SYSTEM: Possible exploit detected, non-donator [parent_ckey] tried loading [interacted_item.item_path], but this is donator only.")
return null

if(interacted_item.ckeywhitelist && (!(preferences.parent.ckey in interacted_item.ckeywhitelist)) && !is_admin(preferences.parent))
message_admins("LOADOUT SYSTEM: Possible exploit detected, non-donator [preferences.parent.ckey] tried loading [interacted_item.item_path], but this is ckey locked.")
if(interacted_item.ckeywhitelist && (!(parent_ckey in interacted_item.ckeywhitelist)) && !is_admin(preferences.parent))
message_admins("LOADOUT SYSTEM: Possible exploit detected, non-donator [parent_ckey] tried loading [interacted_item.item_path], but this is ckey locked.")
return null

if(interacted_item.requires_purchase && !(interacted_item.item_path in preferences.inventory))
message_admins("LOADOUT SYSTEM: Possible exploit detected, [preferences.parent.ckey] has tried loading [interacted_item.item_path], but does not own that item.")
message_admins("LOADOUT SYSTEM: Possible exploit detected, [parent_ckey] has tried loading [interacted_item.item_path], but does not own that item.")
return null

return interacted_item
Expand Down Expand Up @@ -152,7 +153,7 @@
if(QDELETED(preferences) || QDELETED(preferences.parent))
return
if(!isnull(item.ckeywhitelist)) //These checks are also performed in the backend.
if(!(preferences.parent.ckey in item.ckeywhitelist) && !is_admin(preferences.parent))
if(!(ckey(preferences.parent_key) in item.ckeywhitelist) && !is_admin(preferences.parent))
formatted_list.len--
continue
if(item.donator_only) //These checks are also performed in the backend.
Expand Down
10 changes: 6 additions & 4 deletions monkestation/code/modules/storytellers/antag_rep/helper_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ GLOBAL_LIST_INIT(blessed_ckeys, list(
/datum/preferences/proc/return_default_antag_rep()
if(!parent)
return 10
if(!(parent.ckey in GLOB.blessed_ckeys))
var/parent_ckey = ckey(parent_key)
if(!(parent_ckey in GLOB.blessed_ckeys))
return 10
return GLOB.blessed_ckeys[parent.ckey][2]
return GLOB.blessed_ckeys[parent_ckey][2]

/datum/preferences/proc/return_rep_multiplier()
if(!parent)
return 1
if(!(parent.ckey in GLOB.blessed_ckeys))
var/parent_ckey = ckey(parent_key)
if(!(parent_ckey in GLOB.blessed_ckeys))
return 1
return GLOB.blessed_ckeys[parent.ckey][1]
return GLOB.blessed_ckeys[parent_ckey][1]


///give it a list of clients and the value aswell if it should be affected by multipliers and let er rip
Expand Down

0 comments on commit 94aa3de

Please sign in to comment.