diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 39891e1..f84a857 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -270,6 +270,7 @@ var _oneshot_callbacks : Dictionary = {} # iid → Callable (animation_finishe # Per-unit model config. var _model_base_angles : Dictionary = {} # iid → float (base facing angle, radians) var _needs_face_rot : Dictionary = {} # iid → bool (team-based 180° flip flag) +var _unit_team_idx : Dictionary = {} # iid → int (team index, for spectate-safe facing) # Model retry tracking (when real GLB failed to download at placement time). var _unit_model_retries : Dictionary = {} # iid → attempt number (1-based, capped at 10) @@ -1246,6 +1247,7 @@ func _safe_arch(player: Dictionary) -> Dictionary: func _rebuild_ownership(state: Dictionary) -> void: _enemy_unit_ids.clear() _friendly_unit_ids.clear() + _unit_team_idx.clear() var my_id := Auth.user_id # Find my team index so allies are treated as friendly too. var my_team_idx : int = -1 @@ -1262,10 +1264,14 @@ func _rebuild_ownership(state: Dictionary) -> void: var target : Dictionary = _friendly_unit_ids if (is_mine or is_ally) else _enemy_unit_ids for u: Dictionary in p.get("field", []): var iid : String = u.get("instanceId", "") - if not iid.is_empty(): target[iid] = true + if not iid.is_empty(): + target[iid] = true + _unit_team_idx[iid] = team_idx var arch : Dictionary = _safe_arch(p) var aid : String = arch.get("instanceId", "") - if not aid.is_empty(): target[aid] = true + if not aid.is_empty(): + target[aid] = true + _unit_team_idx[aid] = team_idx # ── Board building ──────────────────────────────────────────────────────────── @@ -1594,6 +1600,7 @@ func _rebuild_units(state: Dictionary) -> void: _oneshot_callbacks.erase(iid) _model_base_angles.erase(iid) _needs_face_rot.erase(iid) + _unit_team_idx.erase(iid) _unit_model_retries.erase(iid) # 3. Add units not yet present (newly played, or first render after connect). @@ -1925,9 +1932,20 @@ func _idle_rotation(iid: String) -> float: var my_pos : Vector3 = my_body.global_position var best_sq : float = INF var best_dir : Vector3 = Vector3.ZERO - var is_enemy_unit : bool = _is_enemy_unit(iid) - var enemy_ids : Array = _enemy_unit_ids.keys() if not is_enemy_unit \ - else _friendly_unit_ids.keys() + # Build opponent list using team index when available (spectate-safe). + # When spectating, all units land in _enemy_unit_ids so friend/enemy split + # is meaningless — instead find any unit whose team differs from ours. + var my_team : int = int(_unit_team_idx.get(iid, -1)) + var enemy_ids : Array + if my_team >= 0: + enemy_ids = [] + for eid in _unit_bodies: + if int(_unit_team_idx.get(eid, -1)) != my_team: + enemy_ids.append(eid) + else: + var is_enemy_unit : bool = _is_enemy_unit(iid) + enemy_ids = _enemy_unit_ids.keys() if not is_enemy_unit \ + else _friendly_unit_ids.keys() var found_bodies : int = 0 for eid in enemy_ids: var eb := _unit_bodies.get(eid) as StaticBody3D @@ -1942,8 +1960,8 @@ func _idle_rotation(iid: String) -> float: var flat := Vector3(best_dir.x, 0.0, best_dir.z).normalized() return atan2(flat.x, -flat.z) - base # Log why closest-enemy failed. - push_warning("[IdleRot] FALLBACK iid=%s is_enemy=%s enemy_ids=%d bodies_found=%d best_sq=%s dir_xz=(%s,%s)" \ - % [iid.substr(0,8), str(is_enemy_unit), enemy_ids.size(), found_bodies, + push_warning("[IdleRot] FALLBACK iid=%s team=%d enemy_ids=%d bodies_found=%d best_sq=%s dir_xz=(%s,%s)" \ + % [iid.substr(0,8), my_team, enemy_ids.size(), found_bodies, str(best_sq), str(best_dir.x), str(best_dir.z)]) else: push_warning("[IdleRot] FALLBACK iid=%s — body not in _unit_bodies (friendly=%d enemy=%d)" \ diff --git a/Client/origin-client/scenes/main/MainScreen.tscn b/Client/origin-client/scenes/main/MainScreen.tscn index 06f667f..45f65bd 100644 --- a/Client/origin-client/scenes/main/MainScreen.tscn +++ b/Client/origin-client/scenes/main/MainScreen.tscn @@ -1,7 +1,7 @@ -[gd_scene load_steps=8 format=3 uid="uid://dfyan2sntbmwp"] +[gd_scene load_steps=7 format=3 uid="uid://dfyan2sntbmwp"] [ext_resource type="Script" uid="uid://n8qjxx4qlim7" path="res://scenes/main/main_screen.gd" id="1_main"] -[ext_resource type="PackedScene" path="res://scenes/bug_report/BugReportDialog.tscn" id="2_brd"] +[ext_resource type="PackedScene" uid="uid://og17wax7syki" path="res://scenes/bug_report/BugReportDialog.tscn" id="2_brd"] [ext_resource type="FontFile" uid="uid://e5ejn0n3nvp8" path="res://ui/gothic_ultra_ot.otf" id="2_i4qg7"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_31hso"] @@ -152,7 +152,7 @@ theme_override_constants/separation = 10 unique_name_in_owner = true custom_minimum_size = Vector2(0, 52) layout_mode = 2 -text = "Find Match" +text = "Ranked Match" [node name="FreePlayBtn" type="Button" parent="Layout/Scroll/Content/ContentMargin/ContentInner/Panel/NavButtons"] unique_name_in_owner = true diff --git a/Server/src/SOR.Game/GameEngine.cs b/Server/src/SOR.Game/GameEngine.cs index 52707e8..142de30 100644 --- a/Server/src/SOR.Game/GameEngine.cs +++ b/Server/src/SOR.Game/GameEngine.cs @@ -68,7 +68,9 @@ public static class GameEngine { (p1AccountId, p1Deck, p1ArchSpirit, 0, 0), (p2AccountId, p2Deck, p2ArchSpirit, 1, 1), - }, "FFA", rules?.BoardShape is null or "" or "Default" ? "Rectangle" : rules.BoardShape, rules); + }, "FFA", rules?.BoardShape is null or "" or "Default" + ? (rules?.GridType == "Hexagon" ? "Hexagon" : "Rectangle") + : rules.BoardShape, rules); /// /// N-player Initialize overload. Each player entry carries their account ID, diff --git a/Server/src/SOR.Game/Handlers/GameReadyHandler.cs b/Server/src/SOR.Game/Handlers/GameReadyHandler.cs index c5973c2..77d56e8 100644 --- a/Server/src/SOR.Game/Handlers/GameReadyHandler.cs +++ b/Server/src/SOR.Game/Handlers/GameReadyHandler.cs @@ -203,7 +203,7 @@ internal sealed class GameReadyHandler : GameHandlerBase, IMessageHandler } var boardShape = rules?.BoardShape is null or "" or "Default" - ? BoardShapeGenerator.AutoShape(playerList.Count) + ? (rules?.GridType == "Hexagon" ? "Hexagon" : BoardShapeGenerator.AutoShape(playerList.Count)) : rules.BoardShape; state = GameEngine.Initialize( session.Id,