Skip to content

Commit

Permalink
Fixes the Hive Status error when the Queen dies (#5316)
Browse files Browse the repository at this point in the history
# About the pull request

Fixes the Hive Status window showing an error message when the Queen
dies.

For xeno players, the interface just closes.
For observing players, the interface will show 'The Hive has no Queen!'
where the queen's location was previously.
(The bug actually causing the error should be fixed too now)

(Note: I'm not quite sure what the `tgui-panel.bundle.css` diff is from,
but it kept modifying itself whenever I compiled so I figured it was
something related to this.)

# Explain why it's good for the game

Fixes #4330

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

**Testing queen spawn and death as the queen, as an observer, and as a
xeno:**


https://github.com/cmss13-devs/cmss13/assets/57483089/ba3b2960-d4ce-4be4-af6b-6daae2d10ac1

</details>


# Changelog
:cl:
fix: Fixed the Hive Status window showing an error message when the
Queen dies.
/:cl:
  • Loading branch information
SabreML authored Dec 30, 2023
1 parent c4a5c28 commit 0533a41
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
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(should_block_game_interaction(X))
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.jsx
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.

0 comments on commit 0533a41

Please sign in to comment.