Record original-alignment implementation and traceability checkpoint
Capture current source, content data, tests, asset licenses, and original-specification traceability. Original implementation remains incomplete. The accepted matching UI generation passed 154 suites and 12,253 checks, with eight rendered staff-contract screens reviewed. Latest native Windows and full-original acceptance remain outstanding.
This commit is contained in:
@@ -174,6 +174,34 @@ func request_trip(actor_id: StringName, from: Vector3i, to: Vector3i, minute: in
|
||||
return {&"ok": true, &"replay": false, &"trip": trip.duplicate(true)}
|
||||
|
||||
|
||||
## Reserve two real seats atomically; no synthetic passenger or hidden capacity.
|
||||
func request_pair(first: StringName, second: StringName, from: Vector3i, to: Vector3i,
|
||||
minute: int, access: Array[StringName] = []) -> Dictionary:
|
||||
if first.is_empty() or second.is_empty() or first == second:
|
||||
return _failure(&"INVALID_PAIR", "Two distinct passengers are required.")
|
||||
if _trips.has(first) or _trips.has(second):
|
||||
if _trips.has(first) and _trips.has(second) and _trips[first].get(&"companion_id", &"") == second and _trips[second].get(&"companion_id", &"") == first and _trips[first][&"from"] == from and _trips[first][&"to"] == to:
|
||||
return {&"ok": true, &"replay": true, &"trip": _trips[first].duplicate(true)}
|
||||
return _failure(&"ACTOR_ALREADY_TRAVELLING", "Pair member already owns another trip.")
|
||||
var path_before := _path.create_snapshot()
|
||||
var sequence_before := _sequence
|
||||
var a := request_trip(first, from, to, minute, access)
|
||||
if not a[&"ok"]:
|
||||
_path.restore_snapshot(path_before)
|
||||
_sequence = sequence_before
|
||||
return a
|
||||
var b := request_trip(second, from, to, minute, access)
|
||||
if not b[&"ok"] or _shafts[_trips[first][&"shaft_id"]][&"config"][&"capacity"] < 2:
|
||||
_path.restore_snapshot(path_before)
|
||||
_trips.erase(first)
|
||||
_trips.erase(second)
|
||||
_sequence = sequence_before
|
||||
return _failure(&"PAIR_REJECTED", "Both passengers must fit in the same cabin queue.")
|
||||
_trips[first][&"companion_id"] = second
|
||||
_trips[second][&"companion_id"] = first
|
||||
return {&"ok": true, &"replay": false, &"trip": _trips[first].duplicate(true)}
|
||||
|
||||
|
||||
func advance_one_minute(minute: int) -> Array[Dictionary]:
|
||||
var arrivals: Array[Dictionary] = []
|
||||
if minute == _minute: return arrivals
|
||||
@@ -206,6 +234,22 @@ func get_actor_trip(actor_id: StringName) -> Dictionary:
|
||||
|
||||
|
||||
func cancel_actor(actor_id: StringName) -> bool:
|
||||
var partner: StringName = _trips.get(actor_id, {}).get(&"companion_id", &"")
|
||||
if not partner.is_empty():
|
||||
if _trips[actor_id][&"state"] == PathService.ELEVATOR_REQUEST_BOARDED:
|
||||
last_error = "An onboard pair must alight together at a real landing."
|
||||
return false
|
||||
var path_before := _path.create_snapshot()
|
||||
var trips_before := _trips.duplicate(true)
|
||||
if not _cancel_single(actor_id) or not _cancel_single(partner):
|
||||
_path.restore_snapshot(path_before)
|
||||
_trips = trips_before
|
||||
return false
|
||||
return true
|
||||
return _cancel_single(actor_id)
|
||||
|
||||
|
||||
func _cancel_single(actor_id: StringName) -> bool:
|
||||
if not _trips.has(actor_id): return true
|
||||
var trip: Dictionary = _trips[actor_id]
|
||||
if trip[&"state"] == PathService.ELEVATOR_REQUEST_BOARDED:
|
||||
@@ -259,8 +303,9 @@ func _apply_operational(shaft_id: StringName, operational: bool, minute: int) ->
|
||||
# landing; movement remains held and requests remain owned.
|
||||
car[&"operational"] = false
|
||||
for actor_id: StringName in _names(_trips):
|
||||
if not _trips.has(actor_id): continue
|
||||
var waiting: Dictionary = _trips[actor_id]
|
||||
if waiting[&"shaft_id"] == shaft_id and waiting[&"state"] == PathService.ELEVATOR_REQUEST_QUEUED and cancel_actor(actor_id):
|
||||
if waiting[&"shaft_id"] == shaft_id and waiting[&"state"] == PathService.ELEVATOR_REQUEST_QUEUED and _cancel_single(actor_id):
|
||||
arrivals.append({&"actor_id": actor_id, &"request_id": waiting[&"request_id"], &"cell": waiting[&"from"], &"emergency": false, &"cancelled": true})
|
||||
_publish_cabin(car)
|
||||
return arrivals
|
||||
@@ -364,7 +409,11 @@ func restore_snapshot(snapshot: Dictionary) -> bool:
|
||||
for value: Variant in snapshot[&"trips"]:
|
||||
if not value is Dictionary: return _invalid("Elevator trip must be a Dictionary.")
|
||||
var trip: Dictionary = value
|
||||
if not _exact_keys(trip, [&"actor_id", &"request_id", &"shaft_id", &"connector_id", &"from", &"to", &"enqueued_at", &"state"]):
|
||||
var keys: Array = [&"actor_id", &"request_id", &"shaft_id", &"connector_id", &"from", &"to", &"enqueued_at", &"state"]
|
||||
if trip.has(&"companion_id"):
|
||||
if not (trip[&"companion_id"] is String or trip[&"companion_id"] is StringName) or String(trip[&"companion_id"]).is_empty(): return _invalid("Invalid companion identity.")
|
||||
keys.append(&"companion_id")
|
||||
if not _exact_keys(trip, keys):
|
||||
return _invalid("Elevator trip fields are invalid.")
|
||||
for key: StringName in [&"actor_id", &"request_id", &"shaft_id", &"connector_id", &"state"]:
|
||||
if not (trip[key] is String or trip[key] is StringName) or str(trip[key]).is_empty(): return _invalid("Elevator trip names are invalid.")
|
||||
@@ -395,6 +444,15 @@ func restore_snapshot(snapshot: Dictionary) -> bool:
|
||||
if not found: return _invalid("Queued trip details disagree with Path queue.")
|
||||
else: return _invalid("Unknown elevator trip state.")
|
||||
next_trips[actor_id] = trip.duplicate(true)
|
||||
for actor_id: StringName in next_trips:
|
||||
var trip: Dictionary = next_trips[actor_id]
|
||||
var partner: StringName = trip.get(&"companion_id", &"")
|
||||
if partner.is_empty(): continue
|
||||
if partner == actor_id or not next_trips.has(partner): return _invalid("Missing companion trip.")
|
||||
var other: Dictionary = next_trips[partner]
|
||||
if other.get(&"companion_id", &"") != actor_id: return _invalid("Companion ownership is not reciprocal.")
|
||||
for key: StringName in [&"shaft_id", &"connector_id", &"from", &"to", &"state", &"enqueued_at"]:
|
||||
if trip[key] != other[key]: return _invalid("Companion trip was split.")
|
||||
for actor_id: StringName in boarded_owners:
|
||||
if not next_trips.has(actor_id): return _invalid("Cabin seat has no matching trip.")
|
||||
var path_snapshot := _path.create_snapshot()
|
||||
@@ -444,7 +502,10 @@ func _dispatch(car: Dictionary) -> void:
|
||||
func _board(car: Dictionary) -> void:
|
||||
var config: Dictionary = car[&"config"]
|
||||
var connector_id := _connector_id(config[&"shaft_id"], car[&"boarding_floor"], car[&"target_floor"])
|
||||
var boarded := _path.dequeue_elevator_boarding(connector_id, car[&"current_floor"], _minute, config[&"capacity"])
|
||||
var companions: Dictionary = {}
|
||||
for actor: StringName in _trips:
|
||||
if _trips[actor].has(&"companion_id"): companions[actor] = _trips[actor][&"companion_id"]
|
||||
var boarded := _path.dequeue_elevator_boarding(connector_id, car[&"current_floor"], _minute, config[&"capacity"], companions)
|
||||
car[&"boarded"] = []
|
||||
for request: Dictionary in boarded:
|
||||
var actor_id: StringName = request[&"unit_id"]
|
||||
|
||||
Reference in New Issue
Block a user