Skip to content

Commit 5cb6146

Browse files
authored
Fix some IPC and loadout prefs (#5823)
## About The Pull Request This place is not a place of honor... No highly esteemed deed is commemorated here... nothing valued is here. What is here was dangerous and repulsive to us. This message is a warning about danger. i fixed some shitcode with prefs, especially IPC prefs - which should fix some performance issues. and made changing the IPC chassis actually update the character preview in the process. ## Why It's Good For The Game less lag, AND making stuff work better. win-win. code's still yuck tho. ## Changelog :cl: fix: Fixed some performance issues related to character customization. fix: Changing the IPC chassis in preferences now properly updates the preview. /:cl:
1 parent d504eed commit 5cb6146

File tree

7 files changed

+60
-37
lines changed

7 files changed

+60
-37
lines changed

code/modules/client/preferences/species.dm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
return values
2828

2929
/datum/preference/choiced/species/apply_to_human(mob/living/carbon/human/target, value)
30-
target.set_species(value, icon_update = FALSE, pref_load = TRUE)
30+
if(target.dna?.species?.type != value) // don't set species if we're already that species!!!
31+
target.set_species(value, icon_update = FALSE, pref_load = TRUE)
3132

3233
/datum/preference/choiced/species/compile_constant_data()
3334
var/list/data = list()

code/modules/mob/living/carbon/human/_species.dm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -757,12 +757,12 @@ GLOBAL_LIST_EMPTY(features_by_species)
757757

758758

759759
if(mutant_bodyparts["ears"])
760-
if(!source.dna.features["ears"] || source.dna.features["ears"] == "None" || source.head && (source.head.flags_inv & HIDEHAIR) || (source.wear_mask && (source.wear_mask.flags_inv & HIDEHAIR)) || !noggin || !IS_ORGANIC_LIMB(noggin))
760+
if(!source.dna.features["ears"] || source.dna.features["ears"] == "None" || (source.head && (source.head.flags_inv & HIDEHAIR)) || (source.wear_mask && (source.wear_mask.flags_inv & HIDEHAIR)) || !noggin || !IS_ORGANIC_LIMB(noggin))
761761
bodyparts_to_add -= "ears"
762762

763763
// MONKESTATION ADDITION START
764-
if(mutant_bodyparts["ipc_screen"])
765-
if(!source.dna.features["ipc_screen"] || source.dna.features["ipc_screen"] == "None" || source.head && (source.head.flags_inv & HIDEFACE) || (source.wear_mask && (source.head.flags_inv & HIDEFACE)) || !noggin)
764+
if(mutant_bodyparts["ipc_screen"])
765+
if(!source.dna.features["ipc_screen"] || source.dna.features["ipc_screen"] == "None" || (source.head && (source.head.flags_inv & HIDEFACE)) || (source.wear_mask && (source.head.flags_inv & HIDEFACE)) || !noggin)
766766
bodyparts_to_add -= "ipc_screen"
767767
// MONKESTATION ADDITION END
768768

monkestation/code/datums/quirks/neutral_quirks/anime.dm

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "Anime"
33
desc = "You are an anime enjoyer! Show your enthusiasm with some fashionable attire."
44
value = 0
5-
quirk_flags = QUIRK_CHANGES_APPEARANCE | QUIRK_HIDE_FROM_SCAN
5+
quirk_flags = QUIRK_HUMAN_ONLY | QUIRK_CHANGES_APPEARANCE | QUIRK_HIDE_FROM_SCAN
66
mob_trait = TRAIT_ANIME
77
icon = FA_ICON_PAW
88

@@ -13,24 +13,32 @@
1313
)
1414

1515
/datum/quirk/anime/add(client/client_source)
16+
var/mob/living/carbon/human/quirk_holder = src.quirk_holder
1617
RegisterSignal(quirk_holder, COMSIG_SPECIES_GAIN_PRE, PROC_REF(on_species_gain))
1718

18-
var/datum/species/species = quirk_holder.has_dna()?.species
19-
if(species)
20-
for(var/obj/item/organ/external/organ_path as anything in anime_list)
21-
if (!should_external_organ_apply_to(organ_path, quirk_holder))
22-
continue
23-
//Load a persons preferences from DNA
24-
var/obj/item/organ/external/new_organ = SSwardrobe.provide_type(organ_path)
25-
new_organ.Insert(quirk_holder, special = TRUE, drop_if_replaced = FALSE)
26-
species.external_organs |= organ_path
19+
var/datum/species/species = quirk_holder?.dna?.species
20+
if(QDELETED(species))
21+
return
22+
for(var/obj/item/organ/external/organ_path as anything in anime_list)
23+
if (!should_external_organ_apply_to(organ_path, quirk_holder))
24+
continue
25+
//Load a persons preferences from DNA
26+
var/obj/item/organ/external/new_organ = SSwardrobe.provide_type(organ_path)
27+
new_organ.Insert(quirk_holder, special = TRUE, drop_if_replaced = FALSE)
28+
species.external_organs |= organ_path
2729

2830
/datum/quirk/anime/remove()
31+
var/mob/living/carbon/human/quirk_holder = src.quirk_holder
2932
UnregisterSignal(quirk_holder, COMSIG_SPECIES_GAIN_PRE)
30-
var/datum/species/species = quirk_holder.has_dna()?.species
31-
if(species)
32-
for(var/obj/item/organ/external/organ_path as anything in anime_list)
33-
species.external_organs -= organ_path
33+
var/datum/species/species = quirk_holder?.dna?.species
34+
if(QDELETED(species))
35+
return
36+
for(var/obj/item/organ/external/organ_path as anything in anime_list)
37+
species.external_organs -= organ_path
38+
var/obj/item/organ/external/anime_organ = quirk_holder.get_organ_by_type(organ_path)
39+
if(!QDELETED(anime_organ))
40+
anime_organ.Remove(quirk_holder, special = TRUE)
41+
SSwardrobe.stash_object(anime_organ)
3442

3543
/datum/quirk/anime/proc/on_species_gain(datum/source, datum/species/new_species, datum/species/old_species)
3644
for(var/obj/item/organ/external/organ_path as anything in anime_list)

monkestation/code/modules/client/preferences/body.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212

1313
/datum/preference/choiced/body_height/apply_to_human(mob/living/carbon/human/target, value)
1414
target.dna.body_height = value
15+
target.update_mob_height()

monkestation/code/modules/client/preferences/species_features/ipc.dm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@
6161
return values
6262

6363
/datum/preference/choiced/ipc_chassis/apply_to_human(mob/living/carbon/human/target, value)
64-
target.dna.features["ipc_chassis"] = value
65-
target.regenerate_icons()
64+
var/list/features = target.dna.features
65+
if(features["ipc_chassis"] == value)
66+
return
67+
features["ipc_chassis"] = value
68+
var/datum/species/ipc/ipc = target.dna?.species
69+
if(istype(ipc)) // this is awful. i'm sorry.
70+
ipc.update_chassis(target)
6671

6772
/datum/preference/choiced/ipc_screen
6873
savefile_key = "feature_ipc_screen"

monkestation/code/modules/loadouts/loadout_outfit_helper.dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
continue
102102
item.on_equip_item(preference_source, src, visuals_only)
103103

104-
regenerate_icons()
104+
//regenerate_icons()
105105
return TRUE
106106

107107
/*

monkestation/code/modules/mob/living/carbon/human/species_type/ipc.dm

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,10 @@
160160
addtimer(CALLBACK(src, PROC_REF(switch_to_screen), transformer, "Blank"), 5 SECONDS)
161161

162162

163-
/datum/species/ipc/on_species_loss(mob/living/carbon/C)
163+
/datum/species/ipc/on_species_loss(mob/living/carbon/target)
164164
. = ..()
165-
UnregisterSignal(C, COMSIG_ATOM_EMAG_ACT)
166-
if(change_screen)
167-
change_screen.Remove(C)
168-
UnregisterSignal(C, COMSIG_LIVING_DEATH)
165+
UnregisterSignal(target, list(COMSIG_ATOM_EMAG_ACT, COMSIG_LIVING_DEATH))
166+
change_screen?.Remove(target)
169167

170168
/datum/species/ipc/proc/handle_speech(datum/source, list/speech_args)
171169
speech_args[SPEECH_SPANS] |= SPAN_ROBOT //beep
@@ -215,21 +213,31 @@
215213
H.visible_message(span_notice("[H]'s [change_screen ? "monitor lights up" : "eyes flicker to life"]!"), span_notice("All systems nominal. You're back online!"))
216214
return
217215

218-
/datum/species/ipc/replace_body(mob/living/carbon/C, datum/species/new_species)
219-
..()
216+
/datum/species/ipc/replace_body(mob/living/carbon/target, datum/species/new_species)
217+
. = ..()
218+
update_chassis(target)
220219

221-
var/datum/sprite_accessory/ipc_chassis/chassis_of_choice = GLOB.ipc_chassis_list[C.dna.features["ipc_chassis"]]
220+
/datum/species/ipc/proc/update_chassis(mob/living/carbon/target)
221+
if(!iscarbon(target) || QDELING(target))
222+
return
223+
var/list/features = target.dna?.features
224+
if(!features)
225+
return
226+
var/datum/sprite_accessory/ipc_chassis/chassis_of_choice = GLOB.ipc_chassis_list[features["ipc_chassis"]]
222227

223228
if(!chassis_of_choice)
224-
chassis_of_choice = GLOB.ipc_chassis_list[pick(GLOB.ipc_chassis_list)]
225-
C.dna.features["ipc_chassis"] = pick(GLOB.ipc_chassis_list)
226-
227-
for(var/obj/item/bodypart/BP as() in C.bodyparts) //Override bodypart data as necessary
228-
BP.limb_id = chassis_of_choice.icon_state
229-
BP.name = "\improper[chassis_of_choice.name] [parse_zone(BP.body_zone)]"
230-
BP.update_limb()
229+
var/random_chassis = pick(GLOB.ipc_chassis_list)
230+
chassis_of_choice = GLOB.ipc_chassis_list[random_chassis]
231+
features["ipc_chassis"] = random_chassis
232+
233+
for(var/obj/item/bodypart/bodypart as anything in target.bodyparts) //Override bodypart data as necessary
234+
if(QDELETED(bodypart))
235+
return
236+
bodypart.limb_id = chassis_of_choice.icon_state
237+
bodypart.name = "\improper[chassis_of_choice.name] [parse_zone(bodypart.body_zone)]"
238+
bodypart.update_limb()
231239
if(chassis_of_choice.palette_key == MUTANT_COLOR)
232-
BP.should_draw_greyscale = TRUE
240+
bodypart.should_draw_greyscale = TRUE
233241

234242
/datum/species/ipc/proc/on_emag_act(mob/living/carbon/human/owner, mob/user)
235243
SIGNAL_HANDLER

0 commit comments

Comments
 (0)