Skip to content

Commit

Permalink
Merge pull request #3216 from Superlagg/the-weight-of-my-dick-is-drag…
Browse files Browse the repository at this point in the history
…ging-the-server-down

Refactors pornhud - READY
  • Loading branch information
Tk420634 authored Sep 29, 2023
2 parents 75a5bca + 9999654 commit 5fb7f93
Show file tree
Hide file tree
Showing 24 changed files with 521 additions and 193 deletions.
13 changes: 13 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -621,3 +621,16 @@
#define TATTOO_VISIBILITY_RANGE 3

#define SIMPLEMOB_IGNORE 1

#define PHUD_NONE "GENITAL_HUD_NONE"
#define PHUD_BUTT "GENITAL_HUD_BUTT"
#define PHUD_BOOB "GENITAL_HUD_BREASTS"
#define PHUD_PENIS "GENITAL_HUD_PEEN"
#define PHUD_BALLS "GENITAL_HUD_BALLS"
#define PHUD_VAG "GENITAL_HUD_VAG"
#define PHUD_BELLY "GENITAL_HUD_BELLY"
#define PHUD_TAIL "GENITAL_HUD_TAIL"
#define PHUD_WINGS "GENITAL_HUD_WINGS"
#define PHUD_SHIRT "GENITAL_HUD_SHIRT"
#define PHUD_PANTS "GENITAL_HUD_PANTS"
#define PHUD_SOCKS "GENITAL_HUD_SOCKS"
1 change: 1 addition & 0 deletions code/__DEFINES/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
/// Changelog entries
#define PMC_OOC_NOTES_UPDATE "update_ur_ooc" // Player Master Changelog
#define PMC_QUIRK_OVERHAUL_2K23 "updated_ur_quirks" // Player Master Changelog
#define PMC_PORNHUD_WHITELIST_RELOCATION "ur_nads_are_here_now" // Player Master Changelog

/// The master Preferences Changelog to check the player's prefs against.
/// includes a list of actions that need to be taken to update the player's prefs.
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/qdel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
/// LISTlover 420
/// Like remove_list_recursive, but returns just a list full of the elements
/// ooh ooh maybe if I make more recursive listfuckers, I'll actually use one!
/// cool huh?
/// cool huh? - its a lot less cool when it procs millions of times and bogs down the game, holy shit
/proc/flatten_list_recursive(list/deeplist)
if(!length(deeplist))
return
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
var/name = input(user, message, title, default) as message|null
if(isnull(name)) // Return null if canceled.
return null
if(!check_rights_for(user?.client, R_ADMIN) || i_will_sanitize_dont_worry)
if(!check_rights(R_ADMIN, FALSE) || i_will_sanitize_dont_worry)
name = strip_html_simple(name, max_length) // I'd prefer not to stab myself with a url
if(length(name) > max_length)
to_chat(user, name)
Expand Down
4 changes: 3 additions & 1 deletion code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1709,13 +1709,15 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
return null
return clint.mob

/// Takes in a ckey, a mob, client, or even prefs, and finds the prefs, one way or another
/// Takes in a ckey, a mob, client, weakref, or even prefs, and finds the prefs, one way or another
/proc/extract_prefs(something) // one way or another, im getting your prefs (to break)
if(isclient(something))
var/client/clint = something
return clint.prefs
if(istype(something, /datum/preferences)) // prefs? good, i'll take it
return something
if(isweakref(something))
something = GET_WEAKREF(something)
if(ismob(something))
var/mob/mobby = something
if(!mobby.client)
Expand Down
331 changes: 331 additions & 0 deletions code/controllers/subsystem/pornhud.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,331 @@
// A cute lil subsystem that draws pictures of peoples butts and wieners on your screen
SUBSYSTEM_DEF(pornhud)
name = "PornHUD"
wait = 0.2 SECONDS

// list of all bits
/// format: list("Jimmy Shits" = /datum/genital_images)
var/list/hoohaws = list()
var/image_cache_max = 1024
var/update_pending = FALSE
var/debug_force_everyone_to_update_when_it_does = TRUE
var/debug_clotheshud = TRUE // coming soon in 2096

/datum/controller/subsystem/pornhud/fire(resumed)
if(update_pending)
if(debug_force_everyone_to_update_when_it_does)
for(var/mob/living/carbon/human/nadhaver in GLOB.human_list)
nadhaver.update_body(TRUE)
update_everyone()
update_pending = FALSE

/datum/controller/subsystem/pornhud/proc/pend_update()
update_pending = TRUE

/datum/controller/subsystem/pornhud/proc/catalogue_part(mob/living/dork, part, list/images = list())
if(!isliving(dork) || !part)
return
var/datum/genital_images/GI = get_genital_datum(dork)
GI.add_part(part, images)
return TRUE

/datum/controller/subsystem/pornhud/proc/get_genital_datum(mob/living/carbon/human/dork)
if(!ishuman(dork))
return
if(!dork.pornhud_key)
generate_key(dork)
var/datum/genital_images/GI = LAZYACCESS(hoohaws, dork.pornhud_key)
if(!GI)
GI = new /datum/genital_images(dork)
hoohaws[dork.pornhud_key] = GI
return GI

/// flush a player's genital images, and give them a fresh copy of everyone's
/// This is the *viewer*, so it'll pull everyone's images
/datum/controller/subsystem/pornhud/proc/update_single(mob/living/dork)
if(!dork.client)
return
var/datum/preferences/P = extract_prefs(dork)
if(!P)
return
for(var/mobname in hoohaws)
var/datum/genital_images/GI = hoohaws[mobname]
GI.show_images_to(dork)

/// Flushed everyone's genital images, and gives them a fresh copy of everyone's
/datum/controller/subsystem/pornhud/proc/update_everyone(hard)
for(var/mob/living/carbon/human/nadhaver in GLOB.human_list)
update_single(nadhaver, hard)

/datum/controller/subsystem/pornhud/proc/flush_genitals(mob/living/carbon/human/flusher)
if(!ishuman(flusher))
return
var/datum/genital_images/GI = get_genital_datum(flusher)
if(!GI)
return
GI.flush_genitals()

/datum/controller/subsystem/pornhud/proc/flush_undies(mob/living/carbon/human/flusher)
if(!ishuman(flusher))
return
var/datum/genital_images/GI = get_genital_datum(flusher)
if(!GI)
return
GI.flush_genitals()

/datum/controller/subsystem/pornhud/proc/update_visibility(mob/living/carbon/human/dork, part, on_off)
if(!ishuman(dork))
return
var/datum/genital_images/GI = get_genital_datum(dork)
if(!GI)
return
GI.update_visibility(part, on_off)

/datum/controller/subsystem/pornhud/proc/generate_key(mob/living/carbon/human/newnadhaver)
if(!ishuman(newnadhaver))
return
if(newnadhaver.pornhud_key)
return
var/key = newnadhaver.ckey ? "[newnadhaver.ckey]-" : "stiff-"
key += "[LAZYLEN(hoohaws) + 1]-"
key += "[newnadhaver.real_name]-"
key += "[world.time]-bepis"
newnadhaver.pornhud_key = key
return key

// scornhud
/mob/living/carbon/human
var/pornhud_key

/// Holds all the genital images of a single human mob
/// This is the *owner*, so it'll only pull their own images
/// also defines if they're visible or not
/// get_all_images() will return a list of all images that should be visible
/// It'll not send images that the viewer has set to be hidden
/datum/genital_images
var/datum/weakref/owner

var/list/butt = list()
var/butt_visible
var/butt_priority = 7

var/list/breasts = list()
var/breasts_visible
var/breasts_priority = 9

var/list/peen = list()
var/peen_visible
var/peen_priority = 6

var/list/balls = list()
var/balls_visible
var/balls_priority = 5

var/list/vag = list()
var/vag_visible
var/vag_priority = 4

var/list/belly = list()
var/belly_visible
var/belly_priority = 8

var/list/tail = list() // nice and suggestive
var/tail_visible

var/list/wings = list() // dingo wings
var/wings_visible

var/image/undershirt
var/shirt_visible

var/image/underpants
var/underpants_visible

var/image/socks
var/socks_visible

var/undies_over_genitals = TRUE

/// massive, unwashed list of all images that were on the player at some point
/// pruned? why? not like we'd be using that ram for anything else
var/list/old_image_cache = list()

/datum/genital_images/New(mob/living/carbon/human/newowner)
. = ..()
owner = WEAKREF(newowner)
var/datum/preferences/P = extract_prefs(newowner)
if(!P)
return

/// is this player whitelisted?
/// if so, they can see genitals even if they're hidden
/datum/genital_images/proc/is_whitelisted(mob/someone)
if(!someone || !someone.client)
return FALSE
if(someone == GET_WEAKREF(owner))
return TRUE // surely you'd like to see your own genitals (or lack thereof)
var/datum/preferences/P = extract_prefs(someone)
var/list/whitelist = splittext(P.genital_whitelist, ",")
for(var/entry in whitelist)
entry = ckey(entry)
if(findtext(ckey(someone.real_name), entry))
return TRUE
if(findtext(entry, ckey(someone.real_name)))
return TRUE
if(findtext(ckey(someone.name), entry))
return TRUE
if(findtext(entry, ckey(someone.name)))
return TRUE

// Updates out owner's appearance
/datum/genital_images/proc/update_owner_appearance(broadcast)
var/mob/living/carbon/human/myowner = GET_WEAKREF(owner)
if(!myowner)
return
myowner.update_body(TRUE)
if(broadcast)
SSpornhud.pend_update()

// add a part to the list
/datum/genital_images/proc/add_part(part, list/images = list())
if(!islist(images))
images = list()
switch(part)
if(PHUD_BUTT)
butt = images
if(PHUD_BOOB)
breasts = images
if(PHUD_PENIS)
peen = images
if(PHUD_BALLS)
balls = images
if(PHUD_VAG)
vag = images
if(PHUD_BELLY)
belly = images
if(PHUD_TAIL)
tail = images
if(PHUD_WINGS)
wings = images
if(PHUD_SHIRT)
undershirt = images
if(PHUD_PANTS)
underpants = images
if(PHUD_SOCKS)
socks = images
cache_images(images)
SSpornhud.pend_update()

/datum/genital_images/proc/add_shirt(image/pic)
undershirt = pic
old_image_cache |= pic

/datum/genital_images/proc/add_pants(image/pic)
underpants = pic
old_image_cache |= pic

/datum/genital_images/proc/add_socks(image/pic)
socks = pic
old_image_cache |= pic

/datum/genital_images/proc/update_visibility(part, on_off)
switch(part)
if(PHUD_BUTT)
butt_visible = on_off
if(PHUD_BOOB)
breasts_visible = on_off
if(PHUD_PENIS)
peen_visible = on_off
if(PHUD_BALLS)
balls_visible = on_off
if(PHUD_VAG)
vag_visible = on_off
if(PHUD_BELLY)
belly_visible = on_off
if(PHUD_TAIL)
tail_visible = on_off
if(PHUD_WINGS)
wings_visible = on_off
if(PHUD_SHIRT)
shirt_visible = on_off
if(PHUD_PANTS)
underpants_visible = on_off
if(PHUD_SOCKS)
socks_visible = on_off

/datum/genital_images/proc/cache_images(list/imgs = list())
old_image_cache |= imgs
if(LAZYLEN(old_image_cache) >= SSpornhud.image_cache_max)
var/num_to_remove = LAZYLEN(old_image_cache) - SSpornhud.image_cache_max
if(num_to_remove > 1)
old_image_cache.Cut(1, num_to_remove)

/datum/genital_images/proc/show_images_to(mob/seer)
if(!seer || !seer.client)
return // they cant see us!
seer.client.images -= old_image_cache
seer.client.images |= get_all_images(extract_prefs(seer))

/datum/genital_images/proc/get_all_images(datum/preferences/P)
if(!P)
return list()
var/mob/living/carbon/human/myowner = GET_WEAKREF(owner)
if(!ishuman(myowner))
return list()
var/list/cockstring = myowner.dna.decode_cockstring()
var/list/image_order = reverseList(cockstring)
var/preflag = is_whitelisted(P.parent.mob) ? NONE : P.features["genital_hide"]
var/list/all_images = list()
for(var/entry in image_order)
switch(entry)
if(CS_BUTT)
if(butt_visible && !CHECK_BITFIELD(preflag, HIDE_BUTT))
all_images += butt
if(CS_BOOB)
if(breasts_visible && !CHECK_BITFIELD(preflag, HIDE_BOOBS))
all_images += breasts
if(CS_PENIS)
if(peen_visible && !CHECK_BITFIELD(preflag, HIDE_PENIS))
all_images += peen
if(CS_BALLS)
if(balls_visible && !CHECK_BITFIELD(preflag, HIDE_BALLS))
all_images += balls
if(CS_VAG)
if(vag_visible && !CHECK_BITFIELD(preflag, HIDE_VAG))
all_images += vag
if(CS_BELLY)
if(belly_visible && !CHECK_BITFIELD(preflag, HIDE_BELLY))
all_images += belly
if(undershirt && shirt_visible)
all_images += undershirt
if(underpants && underpants_visible)
all_images += underpants
if(socks && socks_visible)
all_images += socks
if(tail && tail_visible)
all_images += tail
if(wings && wings_visible)
all_images += wings
for(var/image/img in all_images)
img.loc = myowner // just to be sure they're stuck to the player like a fridge magnet
return all_images

/datum/genital_images/proc/flush_genitals()
cache_images(get_all_images())
butt = list()
breasts = list()
peen = list()
balls = list()
vag = list()
belly = list()
return TRUE

/datum/genital_images/proc/flush_undies()
cache_images(get_all_images())
undershirt = null
underpants = null
socks = null
return TRUE



1 change: 1 addition & 0 deletions code/datums/dna.dm
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@
/// takes in whatever's at features["genital_order"] and spits out a list in order of what's present
/// reverses it cus its more intuitive that way (for everyone but me)
/datum/dna/proc/decode_cockstring()
RETURN_TYPE(/list)
var/list/list_out = list()
list_out = splittext(features["genital_order"], ":")
list_out = reverseList(list_out)
Expand Down
Loading

0 comments on commit 5fb7f93

Please sign in to comment.