Skip to content

Commit

Permalink
Revert "Refactor patreon+twitch data to be linked to `/datum/player_d…
Browse files Browse the repository at this point in the history
…etails` than `/client` (Monkestation#4408)"

This reverts commit d61b73e.
  • Loading branch information
Absolucy committed Dec 17, 2024
1 parent db4ef05 commit 810f20c
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 101 deletions.
10 changes: 4 additions & 6 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,13 @@ SUBSYSTEM_DEF(vote)
// monkestation start
if(!current_vote.can_vote(voter))
return
var/patreon_rank = get_player_details(voter)?.patreon?.access_rank
// monkestation end

// If user has already voted, remove their specific vote
if(voter.ckey in current_vote.choices_by_ckey)
var/their_old_vote = current_vote.choices_by_ckey[voter.ckey]
//monkestation edit start
if(current_vote.donator_multiplier && patreon_rank >= 3)
if(current_vote.donator_multiplier && voter?.client?.patreon?.access_rank >= 3)
current_vote.choices[their_old_vote] -= current_vote.donator_multiplier
else
current_vote.choices[their_old_vote]--
Expand All @@ -123,7 +122,7 @@ SUBSYSTEM_DEF(vote)

current_vote.choices_by_ckey[voter.ckey] = their_vote
//monkestation edit start
if(current_vote.donator_multiplier && patreon_rank >= 3)
if(current_vote.donator_multiplier && voter?.client?.patreon?.access_rank >= 3)
current_vote.choices[their_vote] += current_vote.donator_multiplier
else
current_vote.choices[their_vote]++
Expand All @@ -141,7 +140,6 @@ SUBSYSTEM_DEF(vote)
// monkestation start
if(!current_vote.can_vote(voter))
return
var/patreon_rank = get_player_details(voter)?.patreon?.access_rank
// monkestation end
if(CONFIG_GET(flag/no_dead_vote) && voter.stat == DEAD && !voter.client?.holder)
return
Expand All @@ -151,7 +149,7 @@ SUBSYSTEM_DEF(vote)
if(current_vote.choices_by_ckey[voter.ckey + their_vote] == 1)
current_vote.choices_by_ckey[voter.ckey + their_vote] = 0
//monkestation edit start
if(current_vote.donator_multiplier && patreon_rank >= 3)
if(current_vote.donator_multiplier && voter?.client?.patreon?.access_rank >= 3)
current_vote.choices[their_vote] -= current_vote.donator_multiplier
else
current_vote.choices[their_vote]--
Expand All @@ -160,7 +158,7 @@ SUBSYSTEM_DEF(vote)
else
current_vote.choices_by_ckey[voter.ckey + their_vote] = 1
//monkestation edit start
if(current_vote.donator_multiplier && patreon_rank >= 3)
if(current_vote.donator_multiplier && voter?.client?.patreon?.access_rank >= 3)
current_vote.choices[their_vote] += current_vote.donator_multiplier
else
current_vote.choices[their_vote]++
Expand Down
12 changes: 0 additions & 12 deletions code/datums/mocking/client.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
var/datum/interaction_mode/imode
var/context_menu_requires_shift = FALSE

///these persist between logins/logouts during the same round.
var/datum/player_details/player_details
var/reconnecting = FALSE

/datum/client_interface/proc/IsByondMember()
return FALSE

Expand All @@ -41,14 +37,6 @@
if(key)
src.key = key
ckey = ckey(key)
if(GLOB.player_details[ckey])
reconnecting = TRUE
player_details = GLOB.player_details[ckey]
else
player_details = new(ckey)
player_details.byond_version = world.byond_version
player_details.byond_build = world.byond_build
GLOB.player_details[ckey] = player_details

/datum/client_interface/proc/set_macros()
return
Expand Down
20 changes: 10 additions & 10 deletions code/modules/client/player_details.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
GLOBAL_LIST_EMPTY_TYPED(player_details, /datum/player_details)

/datum/player_details
/// The ckey of the player this is tied to.
var/ckey
/// Action datums assigned to this player
var/list/datum/action/player_actions = list()
/// Tracks client action logging
Expand All @@ -23,9 +21,8 @@ GLOBAL_LIST_EMPTY_TYPED(player_details, /datum/player_details)
/// Tracks achievements they have earned
var/datum/achievement_data/achievements

/datum/player_details/New(player_key)
src.ckey = ckey(player_key)
achievements = new(src.ckey)
/datum/player_details/New(key)
achievements = new(key)

/// Returns the full version string (i.e 515.1642) of the BYOND version and build.
/datum/player_details/proc/full_byond_version()
Expand All @@ -34,10 +31,13 @@ GLOBAL_LIST_EMPTY_TYPED(player_details, /datum/player_details)
return "[byond_version].[byond_build || "xxx"]"

/proc/log_played_names(ckey, ...)
if(!ckey || length(args) < 2)
if(!ckey)
return
if(args.len < 2)
return
var/list/names = args.Copy(2)
var/datum/player_details/details = GLOB.player_details[ckey]
for(var/name in names)
if(name)
details.played_names |= name
var/datum/player_details/P = GLOB.player_details[ckey]
if(P)
for(var/name in names)
if(name)
P.played_names |= name
4 changes: 2 additions & 2 deletions code/modules/client/verbs/ooc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8")
var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/chat)
keyname = "[sheet.icon_tag("emoji-heart")][keyname]"

if(player_details.patreon.access_rank > 0)
if(patreon.access_rank > 0)
var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/chat)
keyname = "[sheet.icon_tag("patreon")][keyname]"

if(player_details.twitch.access_rank > 0)
if(twitch.access_rank > 0)
var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/chat)
keyname = "[sheet.icon_tag("twitch")][keyname]"

Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@
if(mind)
mind.name = newname
if(mind.key)
log_played_names(ckey(mind.key) ,newname) //Just in case the mind is unsynced at the moment.
log_played_names(mind.key,newname) //Just in case the mind is unsynced at the moment.

if(oldname)
//update the datacore records! This is goig to be a bit costly.
Expand Down
9 changes: 5 additions & 4 deletions monkestation/code/datums/meta_tokens.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,15 @@ GLOBAL_LIST_INIT(patreon_etoken_values, list(
owner.prefs.save_preferences()

/datum/meta_token_holder/proc/check_for_donator_token()
var/datum/patreon_data/patreon = owner?.player_details?.patreon
if(!patreon?.has_access(ACCESS_COMMAND_RANK))
if(!owner.patreon)
return FALSE
if(!owner.patreon.has_access(ACCESS_COMMAND_RANK))
return
var/month_number = text2num(time2text(world.time, "MM"))
owner.prefs.token_month = month_number
if(owner.prefs.token_month != month_number)
owner.prefs.adjust_metacoins(owner?.ckey, 10000, "Monthly Monkecoin rations.", TRUE, FALSE, FALSE)
if(!patreon.has_access(ACCESS_TRAITOR_RANK))
if(!owner.patreon.has_access(ACCESS_TRAITOR_RANK))
owner.prefs.save_preferences()
return FALSE
if(owner.prefs.token_month == month_number)
Expand Down Expand Up @@ -192,7 +193,7 @@ GLOBAL_LIST_INIT(patreon_etoken_values, list(
var/month_number = text2num(time2text(world.time, "MM"))
if(event_token_month != month_number)
event_token_month = month_number
event_tokens = GLOB.patreon_etoken_values[checked_client.player_details.patreon.owned_rank]
event_tokens = GLOB.patreon_etoken_values[checked_client.patreon.owned_rank]
convert_tokens_to_list()

/datum/meta_token_holder/proc/approve_token_event()
Expand Down
44 changes: 32 additions & 12 deletions monkestation/code/datums/patreon_data.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/client
var/datum/patreon_data/patreon

/datum/patreon_data
/// The details of the linked player.
var/datum/player_details/owner
///the client that owns this data
var/client/owner
///the stored patreon client key for the information
var/client_key
///the stored patreon rank collected from the server
Expand All @@ -9,28 +12,43 @@
var/access_rank = 0


/datum/patreon_data/New(datum/player_details/owner)
/datum/patreon_data/New(client/created_client)
. = ..()
if(!owner)
if(!created_client)
return
src.owner = owner

if(!SSdbcore.IsConnected())
owned_rank = NUKIE_RANK ///this is a testing variable
return

fetch_key_and_rank()
owner = created_client

fetch_key(owner.ckey)
fetch_rank(owner.ckey)

assign_access_rank()

/datum/patreon_data/proc/fetch_key_and_rank()
var/datum/db_query/query_get_key = SSdbcore.NewQuery("SELECT patreon_key, patreon_rank FROM [format_table_name("player")] WHERE ckey = :ckey", list("ckey" = owner.ckey))

/datum/patreon_data/proc/fetch_key(ckey)
var/datum/db_query/query_get_key = SSdbcore.NewQuery("SELECT patreon_key FROM [format_table_name("player")] WHERE ckey = '[ckey]'")
if(query_get_key.warn_execute())
if(query_get_key.NextRow())
client_key = query_get_key.item[1]
owned_rank = query_get_key.item[2]
if(owned_rank == "UNSUBBED2")
owned_rank = NO_RANK
qdel(query_get_key)

/datum/patreon_data/proc/fetch_rank(ckey)
var/datum/db_query/query_get_rank = SSdbcore.NewQuery("SELECT patreon_rank FROM [format_table_name("player")] WHERE ckey = '[ckey]'")
if(query_get_rank.warn_execute())
if(query_get_rank.NextRow())
if(query_get_rank.item[1])
owned_rank = query_get_rank.item[1]
if(owned_rank == "UNSUBBED2")
owned_rank = NO_RANK
else
owned_rank = NO_RANK
qdel(query_get_rank)


/datum/patreon_data/proc/assign_access_rank()
switch(owned_rank)
if(THANKS_RANK)
Expand All @@ -52,4 +70,6 @@
return FALSE

/datum/patreon_data/proc/is_donator()
return owned_rank && owned_rank != NO_RANK && owned_rank != UNSUBBED
if((owned_rank == NO_RANK) || !owned_rank || (owned_rank == UNSUBBED))
return FALSE
return TRUE
37 changes: 27 additions & 10 deletions monkestation/code/datums/twitch_data.dm
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
/client
var/datum/twitch_data/twitch

/datum/twitch_data
/// The details of the linked player.
var/datum/player_details/owner
///the client that owns this data
var/client/owner
///the stored twitch client key for the information
var/client_key
///the stored twitch rank collected from the server
var/owned_rank = NO_TWITCH_SUB
///access rank in numbers
var/access_rank = 0

/datum/twitch_data/New(datum/player_details/owner)



/datum/twitch_data/New(client/created_client)
. = ..()
if(!owner)
if(!created_client)
return
src.owner = owner

if(!SSdbcore.IsConnected())
owned_rank = ACCESS_TWITCH_SUB_TIER_3 ///this is a testing variable
return

fetch_rank()
owner = created_client

fetch_rank(owner.ckey)

assign_twitch_rank()

/datum/twitch_data/proc/fetch_rank()
var/datum/db_query/query_get_rank = SSdbcore.NewQuery("SELECT twitch_rank FROM [format_table_name("player")] WHERE ckey = :ckey", list("ckey" = owner.ckey))

/datum/twitch_data/proc/fetch_rank(ckey)
var/datum/db_query/query_get_rank = SSdbcore.NewQuery("SELECT twitch_rank FROM [format_table_name("player")] WHERE ckey = '[ckey]'")
if(query_get_rank.warn_execute())
if(query_get_rank.NextRow())
owned_rank = query_get_rank.item[1] || NO_TWITCH_SUB
if(query_get_rank.item[1])
owned_rank = query_get_rank.item[1]
if(owned_rank == "")
owned_rank = NO_TWITCH_SUB
else
owned_rank = NO_TWITCH_SUB
qdel(query_get_rank)


Expand All @@ -45,4 +60,6 @@
return FALSE

/datum/twitch_data/proc/is_donator()
return owned_rank != NO_TWITCH_SUB
if(owned_rank != NO_TWITCH_SUB)
return TRUE
return FALSE
32 changes: 0 additions & 32 deletions monkestation/code/modules/client/player_details.dm

This file was deleted.

6 changes: 3 additions & 3 deletions monkestation/code/modules/client/preferences/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@
max_round_coins -= amount

//Patreon Flat Roundend Bonus
if((parent.player_details.patreon?.has_access(2)) && donator_multipler)
if((parent.patreon?.has_access(2)) && donator_multipler)
amount += DONATOR_ROUNDEND_BONUS

//Twitch Flat Roundend Bonus
if((parent.player_details.twitch?.has_access(1)) && donator_multipler)
if((parent.twitch?.has_access(1)) && donator_multipler)
amount += DONATOR_ROUNDEND_BONUS

//Donator Multiplier
if(amount > 0 && donator_multipler)
switch(parent.player_details.patreon.access_rank)
switch(parent.patreon.access_rank)
if(ACCESS_COMMAND_RANK)
amount *= 1.5
if(ACCESS_TRAITOR_RANK)
Expand Down
6 changes: 3 additions & 3 deletions monkestation/code/modules/ghost_critters/client_addons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

mobs_to_pick += return_donator_mobs()

if(!player_details.patreon.has_access(ACCESS_ASSISTANT_RANK) && !is_admin(src) && !length(mobs_to_pick))
if(!patreon.has_access(ACCESS_ASSISTANT_RANK) && !is_admin(src) && !length(mobs_to_pick))
return pick(basic_list)

mobs_to_pick += basic_list
Expand Down Expand Up @@ -47,7 +47,7 @@
var/cooldown_time = get_critter_cooldown()
ghost_critter_cooldown = cooldown_time

if(player_details.patreon.has_access(ACCESS_NUKIE_RANK) || is_admin(src))
if(patreon.has_access(ACCESS_NUKIE_RANK) || is_admin(src))
created_mob.AddComponent(/datum/component/basic_inhands, y_offset = -6)
created_mob.AddComponent(/datum/component/max_held_weight, WEIGHT_CLASS_SMALL)
created_mob.AddElement(/datum/element/dextrous)
Expand All @@ -64,7 +64,7 @@
/client/proc/get_critter_cooldown()
var/base_time = 25 MINUTES

switch(player_details.patreon.access_rank)
switch(patreon.access_rank)
if(0, 1)
return base_time
if(2)
Expand Down
Loading

0 comments on commit 810f20c

Please sign in to comment.