Fixes emergent exploit of iteration order in crew monitors

This commit is contained in:
ShadowLarkens
2020-08-30 19:05:05 -07:00
parent d10cb4aed1
commit dedb854338
3 changed files with 24 additions and 14 deletions
+8 -2
View File
@@ -52,9 +52,15 @@
var/list/map_levels = uniquelist(using_map.get_map_levels(z, TRUE, om_range = DEFAULT_OVERMAP_RANGE))
data["map_levels"] = map_levels
data["crewmembers"] = list()
var/list/crewmembers = list()
for(var/zlevel in map_levels)
data["crewmembers"] += crew_repository.health_data(zlevel)
crewmembers += crew_repository.health_data(zlevel)
// This is apparently necessary, because the above loop produces an emergent behavior
// of telling you what coordinates someone is at even without sensors on,
// because it strictly sorts by zlevel from bottom to top, and by coordinates from top left to bottom right.
shuffle_inplace(crewmembers)
data["crewmembers"] = crewmembers
return data
+8 -4
View File
@@ -1,9 +1,9 @@
import { sortBy } from 'common/collections';
import { flow } from 'common/fp';
import { useBackend, useLocalState } from "../backend";
import { Window } from "../layouts";
import { NanoMap, Box, Table, Button, Tabs, Icon, NumberInput } from "../components";
import { TableCell } from '../components/Table';
import { COLORS } from '../constants.js';
import { Fragment } from 'inferno';
export const CrewMonitor = () => {
@@ -22,9 +22,13 @@ export const CrewMonitor = () => {
export const CrewMonitorContent = (props, context) => {
const { act, data, config } = useBackend(context);
const [tabIndex, setTabIndex] = useLocalState(context, 'tabIndex', 0);
const crew = sortBy(
cm => cm.name,
)(data.crewmembers || []);
const crew = flow([
sortBy(cm => cm.name),
sortBy(cm => cm?.x),
sortBy(cm => cm?.y),
sortBy(cm => cm?.realZ),
])(data.crewmembers || []);
const [
mapZoom,
File diff suppressed because one or more lines are too long