feat: fix some bug
This commit is contained in:
+19
-10
@@ -985,10 +985,10 @@ func _assign_stop_n_go_spawn_positions(all_players: Array):
|
||||
|
||||
# Collect valid walkable spawn positions from the leftmost columns
|
||||
var valid_spawns: Array[Vector2i] = []
|
||||
for col in range(0, min(5, enhanced_gridmap.columns)): # Check first 5 columns
|
||||
for col in range(0, min(5, enhanced_gridmap.columns)): # Check first 5 columns
|
||||
for row in range(enhanced_gridmap.rows):
|
||||
var tile = enhanced_gridmap.get_cell_item(Vector3i(col, 0, row))
|
||||
if tile == 0 or tile == 3: # Walkable or Start
|
||||
if tile == 0 or tile == 3: # Walkable or Start
|
||||
valid_spawns.append(Vector2i(col, row))
|
||||
if valid_spawns.size() >= all_players.size():
|
||||
break
|
||||
@@ -1036,7 +1036,7 @@ func _assign_portal_mode_spawn_positions(all_players: Array):
|
||||
for dx in range(-radius, radius + 1):
|
||||
for dz in range(-radius, radius + 1):
|
||||
# Only check the "ring" at the current radius
|
||||
if abs(dx) != radius and abs(dz) != radius and radius > 0:
|
||||
if abs(dx) != radius and abs(dz) != radius and radius > 0:
|
||||
continue
|
||||
|
||||
var test_pos = center_pos + Vector2i(dx, dz)
|
||||
@@ -1056,7 +1056,7 @@ func _assign_portal_mode_spawn_positions(all_players: Array):
|
||||
if abs(test_pos.x - reserved.x) <= 2 and abs(test_pos.y - reserved.y) <= 2:
|
||||
is_reserved = true
|
||||
break
|
||||
if is_reserved:
|
||||
if is_reserved:
|
||||
continue
|
||||
|
||||
# 4. Check if occupied by another already-assigned player
|
||||
@@ -1408,6 +1408,7 @@ func add_newly_connected_player_character(new_peer_id: int):
|
||||
|
||||
func _on_peer_disconnected(peer_id: int):
|
||||
if not is_inside_tree(): return
|
||||
if not multiplayer.has_multiplayer_peer(): return
|
||||
if multiplayer.is_server():
|
||||
print("[Main] Peer %d disconnected. Checking for bot replacement..." % peer_id)
|
||||
|
||||
@@ -1506,7 +1507,6 @@ func set_current_turn(player_id: int):
|
||||
player.is_my_turn = is_current_turn
|
||||
|
||||
if is_current_turn and not (player.is_bot or player.is_in_group("Bots")):
|
||||
player.action_points = 2
|
||||
player.has_moved_this_turn = false
|
||||
player.has_performed_action = false
|
||||
player.start_turn()
|
||||
@@ -1585,6 +1585,20 @@ func sync_playerboard(player_id: int, new_playerboard: Array):
|
||||
if player_id == multiplayer.get_unique_id() and GameStateManager.local_player_character:
|
||||
ui_manager.update_playerboard_ui()
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_playerboard_slot(player_id: int, slot_index: int, item_id: int):
|
||||
"""Patch a single playerboard slot without touching other slots.
|
||||
Used by _execute_grab on grab confirmation to avoid overwriting concurrent
|
||||
in-flight optimistic grab updates on high-latency clients."""
|
||||
var player = get_node_or_null(str(player_id))
|
||||
if player and slot_index >= 0 and slot_index < player.playerboard.size():
|
||||
player.playerboard[slot_index] = item_id
|
||||
|
||||
# Update UI for local player only
|
||||
if player_id == multiplayer.get_unique_id() and GameStateManager.local_player_character:
|
||||
ui_manager.update_playerboard_ui()
|
||||
|
||||
|
||||
# =============================================================================
|
||||
|
||||
|
||||
@@ -2076,11 +2090,6 @@ func _on_match_ended():
|
||||
is_match_ended = true
|
||||
print("[Main] Match ended! Showing game over screen...")
|
||||
|
||||
# Disable player controls
|
||||
var local_player = GameStateManager.local_player_character
|
||||
if local_player:
|
||||
local_player.action_points = 0
|
||||
|
||||
# Signal Global Game End (Stops Bot ticks and logic)
|
||||
GameStateManager.end_game()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user