Skip to content

Commit bfb7bf1

Browse files
committed
Improve location handling when logging in while docked or on foot on a fleet carrier
1 parent 75af42f commit bfb7bf1

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

src/service/lib/event-handlers/cmdr-status.js

+31-5
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,27 @@ class CmdrStatus {
180180

181181
if (cmdrStatus?.flags?.docked && cmdrStatus?.flags?.onFoot === false) {
182182
// If docked and not on foot get the last Embark/Docked event to find out what station we are on
183-
if (!dockedEvent && embarkEvent?.StationName) location.push(embarkEvent.StationName)
184-
if (!embarkEvent && dockedEvent?.StationName) location.push(dockedEvent.StationName)
185-
if (!embarkEvent && !dockedEvent && touchdownEvent?.NearestDestination) location.push(touchdownEvent.NearestDestination)
183+
184+
// FIXME: This is technically incorrect and it should use whatever is the
185+
// most recent event
186+
if (!dockedEvent && embarkEvent?.StationName) {
187+
location.push(embarkEvent.StationName)
188+
} else if (!embarkEvent && dockedEvent?.StationName) {
189+
if (dockedEvent?.StationType === 'FleetCarrier') {
190+
location.push(`Carrier ${dockedEvent.StationName}`)
191+
} else {
192+
location.push(dockedEvent.StationName)
193+
}
194+
} else if (!embarkEvent && !dockedEvent && touchdownEvent?.NearestDestination) {
195+
location.push(touchdownEvent.NearestDestination)
196+
} else if (locationEvent?.StationName) {
197+
if (locationEvent?.StationType === 'FleetCarrier') {
198+
location.push(`Carrier ${locationEvent.StationName}`)
199+
} else {
200+
location.push(locationEvent.StationName)
201+
}
202+
if (locationEvent?.Docked === true) location.push('Docked')
203+
}
186204

187205
if (dockedEvent && embarkEvent) {
188206
if (touchdownEvent &&
@@ -194,7 +212,11 @@ class CmdrStatus {
194212
// If we have both a Docked event and an Embark event with a station
195213
// name, use the newest value
196214
if (Date.parse(dockedEvent?.timestamp) > Date.parse(embarkEvent?.timestamp)) {
197-
location.push(dockedEvent.StationName)
215+
if (dockedEvent?.StationType === 'FleetCarrier') {
216+
location.push(`Carrier ${dockedEvent.StationName}`)
217+
} else {
218+
location.push(dockedEvent.StationName)
219+
}
198220
} else {
199221
location.push(embarkEvent.StationName)
200222
}
@@ -206,7 +228,11 @@ class CmdrStatus {
206228
// FIXME As a simple sanity check, we at least verify the event was
207229
// triggered in the same system (crude, but hopefully good enough).
208230
if (dockedEvent?.StarSystem === currentSystem?.name) {
209-
location.push(dockedEvent.StationName)
231+
if (dockedEvent?.StationType === 'FleetCarrier') {
232+
location.push(`Carrier ${dockedEvent.StationName}`)
233+
} else {
234+
location.push(dockedEvent.StationName)
235+
}
210236
location.push('Docked')
211237
}
212238
}

0 commit comments

Comments
 (0)