Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes the Hive Status error when the Queen dies #5316

Merged
merged 7 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions code/modules/mob/living/carbon/xenomorph/Xenomorph.dm
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@
if(mob_size < MOB_SIZE_BIG)
mob_flags |= SQUEEZE_UNDER_VEHICLES

GLOB.living_xeno_list += src
GLOB.xeno_mob_list += src

// More setup stuff for names, abilities etc
update_icon_source()
generate_name()
Expand All @@ -453,9 +456,6 @@
//Begin SStracking
SStracking.start_tracking("hive_[src.hivenumber]", src)

GLOB.living_xeno_list += src
GLOB.xeno_mob_list += src

//WO GAMEMODE
if(SSticker?.mode?.hardcore)
hardcore = 1 //Prevents healing and queen evolution
Expand Down
19 changes: 9 additions & 10 deletions code/modules/mob/living/carbon/xenomorph/hive_status.dm
Original file line number Diff line number Diff line change
Expand Up @@ -422,28 +422,27 @@
// The idea is that we sort this list, and use it as a "key" for all the other information (especially the nicknumber)
// in the hive status UI. That way we can minimize the amount of sorts performed by only calling this when xenos are created/disposed
/datum/hive_status/proc/get_xeno_keys()
var/list/xenos[totalXenos.len]
var/list/xenos = list()

var/index = 1
var/useless_slots = 0
for(var/mob/living/carbon/xenomorph/X in totalXenos)
if(is_admin_level(X.z))
var/area/A = get_area(X)
if(!(A.flags_atom & AREA_ALLOW_XENO_JOIN))
useless_slots++
continue

// Insert without doing list merging
xenos[index++] = list(
if(!(X in GLOB.living_xeno_list))
continue

// This looks weird, but in DM adding List A to List B actually adds each item in List B to List A, not List B itself.
// Having a nested list like this sort of tricks it into adding the list instead.
// In this case this results in an array of different 'xeno' dictionaries, rather than just a dictionary.
xenos += list(list(
"nicknumber" = X.nicknumber,
"tier" = X.tier, // This one is only important for sorting
"is_leader" = (IS_XENO_LEADER(X)),
"is_queen" = istype(X.caste, /datum/caste_datum/queen),
"caste_type" = X.caste_type
)

// Clear nulls from the xenos list
xenos.len -= useless_slots
))

// Make it all nice and fancy by sorting the list before returning it
var/list/sorted_keys = sort_xeno_keys(xenos)
Expand Down
8 changes: 7 additions & 1 deletion code/modules/mob/living/carbon/xenomorph/hive_status_ui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@
if(isobserver(user))
return UI_INTERACTIVE

// If the Queen died or is otherwise missing.
if(!assoc_hive.living_xeno_queen)
return UI_CLOSE

/datum/hive_status_ui/ui_data(mob/user)
. = list()
.["total_xenos"] = total_xenos
Expand All @@ -131,7 +135,9 @@
.["xeno_keys"] = xeno_keys
.["xeno_info"] = xeno_info
.["xeno_vitals"] = xeno_vitals
.["queen_location"] = get_area_name(assoc_hive.living_xeno_queen)
.["queen_location"] = null
if(assoc_hive.living_xeno_queen)
.["queen_location"] = get_area_name(assoc_hive.living_xeno_queen)
.["hive_location"] = hive_location
.["burrowed_larva"] = burrowed_larva
.["evilution_level"] = evilution_level
Expand Down
14 changes: 10 additions & 4 deletions tgui/packages/tgui/interfaces/HiveStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,16 @@ const GeneralInformation = (props, context) => {

return (
<Flex direction="column" align="center">
<Flex.Item textAlign="center">
<h3 className="whiteTitle">The Queen is in:</h3>
<h1 className="whiteTitle">{queen_location}</h1>
</Flex.Item>
{queen_location === null ? (
<Flex.Item textAlign="center">
<h3 className="whiteTitle">The Hive has no Queen!</h3>
</Flex.Item>
) : (
<Flex.Item textAlign="center">
<h3 className="whiteTitle">The Queen is in:</h3>
<h1 className="whiteTitle">{queen_location}</h1>
</Flex.Item>
)}
{!!hive_location && (
<Flex.Item textAlign="center" mt={2}>
<h3 className="whiteTitle">The Hive location is:</h3>
Expand Down
4 changes: 2 additions & 2 deletions tgui/public/tgui-panel.bundle.css

Large diffs are not rendered by default.