Fresh start: replace with naxIO/netfox-cs-sample foundation
Complete replacement of the tactical-shooter project with the netfox-cs-sample (MIT) — a CS 1.6 inspired multiplayer FPS built with Godot 4 and netfox. ## What's new - Full CS-style gameplay: teams (T/CT), rounds, economy, buy menu - 6 weapons: Knife, Glock, USP, AK-47, M4A1, AWP - Bomb plant/defuse with 2 bombsites - Flashbang & smoke grenades - Proper netfox rollback netcode at 64 tick - Network popup UI for host/join - HUD, crosshair, round timer, scoreboard - All netfox singletons registered as autoloads (works in exported builds) ## Architecture - Listen-server (host from client, no dedicated server binary) - Multiplayer-fps game lives at examples/multiplayer-fps/ - Netfox addons registered as autoloads for exported build compat - Godot 4.7 with Forward+ renderer ## Removed - Old headless-server architecture (client_main, server_main, player.gd, etc.) - Custom netfox bootstrap with ENet fallback - Old ChaffGames FPS template (2,420 lines, 844 KB) - SimulationServer GDExtension stub - Godot-jolt physics (netfox sample uses default Godot physics) - Duplicate weapon_data.gd, anti_cheat.gd, round_manager.gd, etc. - Server browser API Python venv (87 MB) - test_range map and modular assets ## Preserved - Git history - Server config at config/default_server_config.cfg - Windows export preset - Build directory (gitignored) Co-authored-by: naxIO <naxIO@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
extends RefCounted
|
||||
class_name VestCLIRunner
|
||||
|
||||
## Implements functionality to run tests
|
||||
|
||||
var _peer: StreamPeerTCP = null
|
||||
|
||||
## Run tests with [Params]
|
||||
func run(params: VestCLI.Params) -> int:
|
||||
var validation_errors := params.validate()
|
||||
if not validation_errors.is_empty():
|
||||
for error in validation_errors:
|
||||
OS.alert(error)
|
||||
push_error(error)
|
||||
return 1
|
||||
|
||||
await _connect(params)
|
||||
|
||||
var results := await _run_tests(params)
|
||||
_report(params, results)
|
||||
_send_results_over_network(params, results)
|
||||
|
||||
_disconnect()
|
||||
|
||||
if results.get_aggregate_status() == VestResult.TEST_PASS:
|
||||
print_rich("All tests [color=green]passed[/color]!")
|
||||
return 0
|
||||
else:
|
||||
print_rich("There are test [color=red]failures[/color]!")
|
||||
return 1
|
||||
|
||||
func _run_tests(params: VestCLI.Params) -> VestResult.Suite:
|
||||
var runner := VestLocalRunner.new()
|
||||
runner.on_partial_result.connect(func(result: VestResult.Suite):
|
||||
if _peer != null:
|
||||
if result != null:
|
||||
_peer.put_var(result._to_wire(), true)
|
||||
else:
|
||||
_peer.put_var(result, true)
|
||||
)
|
||||
|
||||
var results: VestResult.Suite
|
||||
if params.run_file:
|
||||
results = await runner.run_script_at(params.run_file, params.only_mode)
|
||||
elif params.run_glob:
|
||||
results = await runner.run_glob(params.run_glob, params.only_mode)
|
||||
|
||||
return results
|
||||
|
||||
func _report(params: VestCLI.Params, results: VestResult.Suite):
|
||||
var report := TAPReporter.report(results)
|
||||
|
||||
if params.report_format:
|
||||
if params.report_file in ["", "-"]:
|
||||
print(report)
|
||||
else:
|
||||
var fa := FileAccess.open(params.report_file, FileAccess.WRITE)
|
||||
fa.store_string(report)
|
||||
fa.close()
|
||||
|
||||
func _connect(params: VestCLI.Params):
|
||||
if not params.host and params.port == -1:
|
||||
return
|
||||
|
||||
var host := params.host
|
||||
var port := params.port
|
||||
|
||||
if not host: host = "127.0.0.1"
|
||||
if port == -1: port = 54932
|
||||
|
||||
var peer := StreamPeerTCP.new()
|
||||
var err := peer.connect_to_host(host, port)
|
||||
if err != OK:
|
||||
push_warning("Couldn't connect on port %d! %s" % [port, error_string(err)])
|
||||
return
|
||||
|
||||
await Vest.until(func(): peer.poll(); return peer.get_status() != StreamPeerTCP.STATUS_CONNECTING)
|
||||
if peer.get_status() != StreamPeerTCP.STATUS_CONNECTED:
|
||||
push_warning("Connection failed! Socket status: %d" % [peer.get_status()])
|
||||
return
|
||||
|
||||
peer.set_no_delay(true)
|
||||
_peer = peer
|
||||
|
||||
func _disconnect():
|
||||
if _peer != null:
|
||||
_peer.disconnect_from_host()
|
||||
|
||||
func _send_results_over_network(params: VestCLI.Params, results: VestResult.Suite):
|
||||
if not _peer:
|
||||
return
|
||||
|
||||
_peer.put_var(results._to_wire(), true)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bw0ajf5t50wi0
|
||||
@@ -0,0 +1,21 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dopwc3211i1ce"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_de1pc"]
|
||||
script/source = "extends Node
|
||||
|
||||
# Used to run tests in debug mode
|
||||
|
||||
func _ready():
|
||||
Vest._register_scene_tree(get_tree())
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MINIMIZED)
|
||||
|
||||
var params := Vest.__.LocalSettings.run_params
|
||||
|
||||
var runner := VestCLIRunner.new()
|
||||
var exit_code := await runner.run(params)
|
||||
|
||||
get_tree().quit(exit_code)
|
||||
"
|
||||
|
||||
[node name="vest-cli-scene" type="Node"]
|
||||
script = SubResource("GDScript_de1pc")
|
||||
@@ -0,0 +1,110 @@
|
||||
extends SceneTree
|
||||
class_name VestCLI
|
||||
|
||||
## Class for running vest from the CLI
|
||||
## [br][br]
|
||||
## See [VestCLI.Params]
|
||||
|
||||
## Vest CLI parameters
|
||||
class Params:
|
||||
## Which test script file to run
|
||||
var run_file: String = ""
|
||||
|
||||
## Which test glob to run
|
||||
var run_glob: String = "res://*.test.gd"
|
||||
|
||||
## Reporting format - currently only TAP is supported
|
||||
var report_format: String = ""
|
||||
|
||||
## Path for saving the report
|
||||
var report_file: String = ""
|
||||
|
||||
## How to handle tests marked as `only`
|
||||
var only_mode: int = Vest.__.ONLY_DISABLED
|
||||
|
||||
## Host to connect to for sending results
|
||||
var host: String = ""
|
||||
|
||||
## Port to connect to for sending results
|
||||
var port: int = -1
|
||||
|
||||
## Validate parameters.
|
||||
## [br][br]
|
||||
## Returns an array of error messages, or an empty array of the parameters
|
||||
## are valid.
|
||||
func validate() -> Array[String]:
|
||||
var result: Array[String] = []
|
||||
if not run_file and not run_glob:
|
||||
result.append("No tests specified!")
|
||||
if report_format not in ["", "tap"]:
|
||||
result.append("Unknown report format \"%s\"!" % report_format)
|
||||
if port != -1 and port < 0 or port > 65535:
|
||||
result.append("Specified port %d is invalid!" % port)
|
||||
return result
|
||||
|
||||
## Convert to an array of CLI parameters.
|
||||
func to_args() -> Array[String]:
|
||||
var result: Array[String] = []
|
||||
|
||||
if run_file: result.append_array(["--vest-file", run_file])
|
||||
if run_glob: result.append_array(["--vest-glob", run_glob])
|
||||
if report_format: result.append_array(["--vest-report-format", report_format])
|
||||
if report_file: result.append_array(["--vest-report-file", report_file])
|
||||
if host: result.append_array(["--vest-host", host])
|
||||
if port != -1: result.append_array(["--vest-port", str(port)])
|
||||
|
||||
match only_mode:
|
||||
Vest.__.ONLY_DISABLED: result.append("--no-only")
|
||||
Vest.__.ONLY_AUTO: result.append("--auto-only")
|
||||
Vest.__.ONLY_ENABLED: result.append("--only")
|
||||
|
||||
return result
|
||||
|
||||
## Parse an array of CLI parameters.
|
||||
## [br][br]
|
||||
## See [method OS.get_cmdline_args].
|
||||
static func parse(args: Array[String]) -> Params:
|
||||
var result := Params.new()
|
||||
|
||||
for i in range(args.size()):
|
||||
var arg := args[i]
|
||||
var val := args[i+1] if i+1 < args.size() else ""
|
||||
|
||||
if arg == "--vest-file": result.run_file = val
|
||||
elif arg == "--vest-glob": result.run_glob = val
|
||||
elif arg == "--vest-report-file": result.report_file = val
|
||||
elif arg == "--vest-report-format": result.report_format = val
|
||||
elif arg == "--vest-port": result.port = val.to_int()
|
||||
elif arg == "--vest-host": result.host = val
|
||||
elif arg == "--no-only": result.only_mode = Vest.__.ONLY_DISABLED
|
||||
elif arg == "--only": result.only_mode = Vest.__.ONLY_ENABLED
|
||||
elif arg == "--auto-only": result.only_mode = Vest.__.ONLY_AUTO
|
||||
|
||||
return result
|
||||
|
||||
## Run vest CLI with parameters.
|
||||
## [br][br]
|
||||
## Returns the spawned process' ID.
|
||||
static func run(params: Params) -> int:
|
||||
var args = ["--headless", "-s", (VestCLI as Script).resource_path]
|
||||
return OS.create_instance(args + params.to_args())
|
||||
|
||||
## Run vest in debug mode.
|
||||
static func debug(params: Params):
|
||||
Vest.__.LocalSettings.run_params = params
|
||||
Vest.__.LocalSettings.flush()
|
||||
Vest._get_editor_interface()\
|
||||
.play_custom_scene(preload("res://addons/vest/cli/vest-cli-scene.tscn").resource_path)
|
||||
|
||||
func _init():
|
||||
Vest._register_scene_tree(self)
|
||||
|
||||
# Wait a frame for autoloads to register
|
||||
await process_frame
|
||||
|
||||
var params := Params.parse(OS.get_cmdline_args())
|
||||
var runner := VestCLIRunner.new()
|
||||
|
||||
var exit_code := await runner.run(params)
|
||||
|
||||
quit(exit_code)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dnchvsa0ahjd4
|
||||
Reference in New Issue
Block a user