Skip to content

Commit

Permalink
fix(map): do not create systems if a character has appeared in them u…
Browse files Browse the repository at this point in the history
…nless it is in kspace, also no dragging of systems when offline
  • Loading branch information
updraft0 committed Jun 13, 2024
1 parent d931cee commit 56aff95
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ object MapEntity extends ReactiveEntity[MapEnv, MapId, MapState, Identified[MapR
else Chunk.empty
ZIO.foldLeft(changes)((nextState, locationsUpdate)):
case ((st, responses), asm: LocationUpdateAction.AddMapSystem)
if asm.adjacentTo.isEmpty && !st.hasSystem(asm.system) =>
if asm.adjacentTo.isEmpty && !st.hasSystem(asm.system) && !isKnownSpace(st, asm.system) =>
addSystemFromLocation(mapId, st, responses, asm).orDie
case ((st, responses), asm: LocationUpdateAction.AddMapSystem)
if asm.adjacentTo.exists(fromSystemId =>
Expand Down Expand Up @@ -815,6 +815,9 @@ object MapEntity extends ReactiveEntity[MapEnv, MapId, MapState, Identified[MapR
val isTarget = state.refSystem(fromSystemId).zip(state.refSystem(toSystemId)).exists(isTargetForJumps)
differentSystem && noGate && isTarget

private def isKnownSpace(state: MapState, systemId: SystemId) =
state.refSystem(systemId).exists(_.whClass.spaceType == SpaceType.Known)

private[map] def isTargetForJumps(fromSystem: MapSolarSystem, toSystem: MapSolarSystem) =
(fromSystem.whClass.spaceType, toSystem.whClass.spaceType) match
// wormholes are always jumps
Expand Down
1 change: 1 addition & 0 deletions ui/src/main/scala/controltower/page/map/view/MapView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private class MapView(
controller.selectedSystemId.signal,
controller.allLocations.signal.map(_.getOrElse(constant.SystemId(systemId), Array.empty[CharacterLocation])),
connectingSystem.current,
ws.isConnected,
controller.mapSettings
)
},
Expand Down
5 changes: 3 additions & 2 deletions ui/src/main/scala/controltower/page/map/view/SystemView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class SystemView(
selectedSystem: Signal[Option[Long]],
characters: Signal[Array[CharacterLocation]],
connectingState: Var[MapNewConnectionState],
isConnected: Signal[Boolean],
settings: Signal[MapSettings]
)(using ctx: MapViewContext)
extends ViewController:
Expand All @@ -87,8 +88,8 @@ class SystemView(
val solarSystem = ctx.staticData.solarSystemMap(systemId)

val canDrag = ctx.mapRole
.combineWith(system.map(_.system.isPinned))
.map((role, pinned) => !pinned && RoleController.canRepositionSystem(role))
.combineWith(system.map(_.system.isPinned), isConnected)
.map((role, pinned, connected) => !pinned && RoleController.canRepositionSystem(role) && connected)

inDraggable(
pos.systemPosition(systemId),
Expand Down

0 comments on commit 56aff95

Please sign in to comment.