Fix simulation_server_stub Entity class conflict + ServerConfig load timing
- 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
This commit is contained in:
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,6 +40,10 @@ var _game_server: Node = null
|
|||||||
# Lifecycle
|
# Lifecycle
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
func _ready() -> void:
|
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.
|
# Config driven — ServerConfig singleton loaded at autoload time.
|
||||||
# Allow port override via env var for backwards compatibility
|
# Allow port override via env var for backwards compatibility
|
||||||
# (container/VPS deployments that set SERVER_PORT).
|
# (container/VPS deployments that set SERVER_PORT).
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://5mvg6r8pob2u
|
||||||
@@ -7,9 +7,9 @@
|
|||||||
extends RefCounted
|
extends RefCounted
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Nested: Entity state data
|
# Nested: StubEntity state data
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
class Entity:
|
class StubEntity:
|
||||||
var id: int = -1
|
var id: int = -1
|
||||||
var peer_id: int = -1
|
var peer_id: int = -1
|
||||||
var position: Vector3 = Vector3.ZERO
|
var position: Vector3 = Vector3.ZERO
|
||||||
@@ -30,7 +30,7 @@ var _movement_config: Dictionary = {}
|
|||||||
var _weapon_config: Dictionary = {}
|
var _weapon_config: Dictionary = {}
|
||||||
var _history_depth: int = 64
|
var _history_depth: int = 64
|
||||||
var _next_entity_id: int = 1
|
var _next_entity_id: int = 1
|
||||||
var _entities: Dictionary = {} # entity_id → Entity
|
var _entities: Dictionary = {} # entity_id → StubEntity
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# SimulationServer API
|
# SimulationServer API
|
||||||
@@ -51,7 +51,7 @@ func set_history_depth(depth: int) -> void:
|
|||||||
_history_depth = depth
|
_history_depth = depth
|
||||||
|
|
||||||
func apply_input(entity_id: int, input_dict: Dictionary) -> void:
|
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:
|
if e == null:
|
||||||
return
|
return
|
||||||
# Apply movement from input (simplified)
|
# Apply movement from input (simplified)
|
||||||
@@ -72,11 +72,11 @@ func fire_weapon(entity_id: int) -> void:
|
|||||||
# Stub: log the event
|
# Stub: log the event
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func get_entity(entity_id: int) -> Entity:
|
func get_entity(entity_id: int) -> StubEntity:
|
||||||
return _entities.get(entity_id)
|
return _entities.get(entity_id)
|
||||||
|
|
||||||
func spawn_player_entity(peer_id: int, pos: Vector3) -> int:
|
func spawn_player_entity(peer_id: int, pos: Vector3) -> int:
|
||||||
var e = Entity.new()
|
var e = StubEntity.new()
|
||||||
e.id = _next_entity_id
|
e.id = _next_entity_id
|
||||||
e.peer_id = peer_id
|
e.peer_id = peer_id
|
||||||
e.position = pos
|
e.position = pos
|
||||||
|
|||||||
Reference in New Issue
Block a user