From db477b4c4834353c2b008eb4414b32c0a51d0e56 Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 2 Jul 2026 10:24:32 -0400 Subject: [PATCH] Fix simulation_server_stub Entity class conflict + ServerConfig load timing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Renamed inner class Entity→StubEntity (Godot has native Entity class) - Added await ServerConfig.config_loaded before reading map_list in server_main.gd - Config loads via call_deferred, so _ready() must wait for signal --- config/default_server_config.json | 48 +++++++++++++++++++ scripts/network/server_main.gd | 4 ++ server/scripts/combat/damage_processor.gd.uid | 1 + server/scripts/simulation_server_stub.gd | 12 ++--- 4 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 config/default_server_config.json create mode 100644 server/scripts/combat/damage_processor.gd.uid diff --git a/config/default_server_config.json b/config/default_server_config.json new file mode 100644 index 0000000..62e99c9 --- /dev/null +++ b/config/default_server_config.json @@ -0,0 +1,48 @@ +{ + "server": { + "server_name": "Tactical Shooter Server", + "description": "", + "bind_ip": "0.0.0.0", + "port": 34197, + "max_players": 16, + "password": "", + "tick_rate": 128 + }, + "game": { + "round_time_seconds": 600, + "warmup_time_seconds": 60, + "friendly_fire": false, + "ff_damage_multiplier": 0.5, + "gravity": -24.0, + "respawn_time_seconds": 5.0, + "spectate_enabled": true + }, + "movement": { + "walk_speed": 5.0, + "sprint_speed": 7.0, + "crouch_speed": 2.0, + "jump_velocity": 6.0, + "acceleration": 20.0, + "air_acceleration": 4.0, + "friction": 8.0 + }, + "match": { + "win_limit": 3, + "time_limit_seconds": 0, + "map_rotation_mode": "sequence", + "maps": "test_range" + }, + "rcon": { + "enabled": true, + "password": "", + "port": 34198 + }, + "logging": { + "log_level": "info", + "log_file": "" + }, + "teams": { + "team_count": 2, + "players_per_team": 8 + } +} \ No newline at end of file diff --git a/scripts/network/server_main.gd b/scripts/network/server_main.gd index 390a816..d64abf6 100644 --- a/scripts/network/server_main.gd +++ b/scripts/network/server_main.gd @@ -40,6 +40,10 @@ var _game_server: Node = null # Lifecycle # --------------------------------------------------------------------------- func _ready() -> void: + # Wait for ServerConfig to finish (it loads via call_deferred) + if ServerConfig and ServerConfig.has_signal(&"config_loaded"): + await ServerConfig.config_loaded + # Config driven — ServerConfig singleton loaded at autoload time. # Allow port override via env var for backwards compatibility # (container/VPS deployments that set SERVER_PORT). diff --git a/server/scripts/combat/damage_processor.gd.uid b/server/scripts/combat/damage_processor.gd.uid new file mode 100644 index 0000000..1e0190a --- /dev/null +++ b/server/scripts/combat/damage_processor.gd.uid @@ -0,0 +1 @@ +uid://5mvg6r8pob2u diff --git a/server/scripts/simulation_server_stub.gd b/server/scripts/simulation_server_stub.gd index aaebcf2..a34b5aa 100644 --- a/server/scripts/simulation_server_stub.gd +++ b/server/scripts/simulation_server_stub.gd @@ -7,9 +7,9 @@ extends RefCounted # --------------------------------------------------------------------------- -# Nested: Entity state data +# Nested: StubEntity state data # --------------------------------------------------------------------------- -class Entity: +class StubEntity: var id: int = -1 var peer_id: int = -1 var position: Vector3 = Vector3.ZERO @@ -30,7 +30,7 @@ var _movement_config: Dictionary = {} var _weapon_config: Dictionary = {} var _history_depth: int = 64 var _next_entity_id: int = 1 -var _entities: Dictionary = {} # entity_id → Entity +var _entities: Dictionary = {} # entity_id → StubEntity # --------------------------------------------------------------------------- # SimulationServer API @@ -51,7 +51,7 @@ func set_history_depth(depth: int) -> void: _history_depth = depth func apply_input(entity_id: int, input_dict: Dictionary) -> void: - var e: Entity = _entities.get(entity_id) + var e: StubEntity = _entities.get(entity_id) if e == null: return # Apply movement from input (simplified) @@ -72,11 +72,11 @@ func fire_weapon(entity_id: int) -> void: # Stub: log the event pass -func get_entity(entity_id: int) -> Entity: +func get_entity(entity_id: int) -> StubEntity: return _entities.get(entity_id) func spawn_player_entity(peer_id: int, pos: Vector3) -> int: - var e = Entity.new() + var e = StubEntity.new() e.id = _next_entity_id e.peer_id = peer_id e.position = pos