diff --git a/export_presets.cfg b/export_presets.cfg index 905534a..6239d0e 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -40,3 +40,71 @@ unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") rm -rf \"{temp_dir}\"" + +[preset.1] + +name="Windows Desktop" +platform="Windows Desktop" +runnable=true +advanced_options=false +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="exports/Chelimbalo.exe" +patches=PackedStringArray() +encryption_include_filters="" +encryption_exclude_filters="" +seed=0 +encrypt_pck=false +encrypt_directory=false +script_export_mode=2 + +[preset.1.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +binary_format/embed_pck=true +texture_format/s3tc_bptc=true +texture_format/etc2_astc=false +shader_baker/enabled=false +binary_format/architecture="x86_64" +codesign/enable=false +codesign/timestamp=true +codesign/timestamp_server_url="" +codesign/digest_algorithm=1 +codesign/description="" +codesign/custom_options=PackedStringArray() +application/modify_resources=true +application/icon="" +application/console_wrapper_icon="" +application/icon_interpolation=4 +application/file_version="" +application/product_version="" +application/company_name="" +application/product_name="" +application/file_description="" +application/copyright="" +application/trademarks="" +application/export_angle=0 +application/export_d3d12=0 +application/d3d12_agility_sdk_multiarch=true +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}' +$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}' +$trigger = New-ScheduledTaskTrigger -Once -At 00:00 +$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries +$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings +Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true +Start-ScheduledTask -TaskName godot_remote_debug +while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 } +Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue" +ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue +Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue +Remove-Item -Recurse -Force '{temp_dir}'" diff --git a/exports/Chelimbalo.exe b/exports/Chelimbalo.exe new file mode 100644 index 0000000..423bf76 Binary files /dev/null and b/exports/Chelimbalo.exe differ diff --git a/exports/Chelimbalo.sh b/exports/Chelimbalo.sh deleted file mode 100755 index 61e6bd7..0000000 --- a/exports/Chelimbalo.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -printf '\033c\033]0;%s\a' Chelimbalo -base_path="$(dirname "$(realpath "$0")")" -"$base_path/Chelimbalo.x86_64" "$@" diff --git a/exports/Chelimbalo.x86_64 b/exports/Chelimbalo.x86_64 index f6005a4..0385d0f 100755 Binary files a/exports/Chelimbalo.x86_64 and b/exports/Chelimbalo.x86_64 differ diff --git a/scripts/multiplayer/lobby.gd b/scripts/multiplayer/lobby.gd index da93c49..942b871 100644 --- a/scripts/multiplayer/lobby.gd +++ b/scripts/multiplayer/lobby.gd @@ -14,14 +14,31 @@ var in_lobby: bool = false var attack_team: Array[int] = [] var defence_team: Array[int] = [] var specators_team: Array[int] = [] +var validated_players = [] var win_score = 13 var half_rounds = 12 +var client_hash: String = "" + +const CHUNK_SIZE = 1024 + func _ready() -> void: multiplayer.peer_disconnected.connect(player_left) multiplayer.server_disconnected.connect(server_disconnected) multiplayer.peer_connected.connect(add_and_sync_peer) + multiplayer.connected_to_server.connect(send_validation) + + var ctx = HashingContext.new() + ctx.start(HashingContext.HASH_SHA256) + + var file = FileAccess.open(OS.get_executable_path(),FileAccess.READ) + + while file.get_position() < file.get_length(): + var remaining = file.get_length() - file.get_position() + ctx.update(file.get_buffer(min(remaining,CHUNK_SIZE))) + + client_hash = ctx.finish().hex_encode() func player_left(id: int) -> void: if attack_team.has(id): @@ -42,10 +59,35 @@ func host() -> void: lobby_created.emit() specators_team.append(multiplayer.get_unique_id()) in_lobby = true + multiplayer.peer_connected.connect(check_player_hash) + multiplayer.peer_disconnected.connect(on_player_left) + +func check_player_hash(id: int): + if multiplayer.is_server(): + get_tree().create_timer(1).timeout.connect(kick_untrustworthy.bind(id)) + +func on_player_left(id: int): + if multiplayer.is_server(): + if validated_players.has(id): + validated_players.erase(id) + +func kick_untrustworthy(id: int): + if multiplayer.is_server() and validated_players.has(id) == false: + multiplayer.disconnect_peer(id) + +@rpc("any_peer","call_remote","reliable") +func validate_hash(sender_hash: StringName): + if multiplayer.is_server() == false: + return + if client_hash == sender_hash: + validated_players.append(multiplayer.get_remote_sender_id()) + +func send_validation(): + validate_hash.rpc_id(1,client_hash) func join(ip: String) -> Error: var peer: ENetMultiplayerPeer = ENetMultiplayerPeer.new() - var res = peer.create_client(ip,PORT) + var res = peer.create_client(ip,PORT) if res != 0: return res multiplayer.multiplayer_peer = peer @@ -53,7 +95,10 @@ func join(ip: String) -> Error: in_lobby = true return Error.OK + func leave() -> void: + if multiplayer.is_server(): + multiplayer.peer_connected.disconnect(check_player_hash) multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new() attack_team.clear() defence_team.clear()