initial commit

This commit is contained in:
2020-05-09 12:45:05 +02:00
commit a3549d357b
46 changed files with 3051 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
dest_md5="2ded9e7f9060e2b530aab678b135fc5b"

View File

@@ -0,0 +1,26 @@
extends Node
# {game_id:[_game_id, _game_name, _max_players, _player_list]} # player_list is a dict
# {game_id:[_game_id, _game_name, _max_players, {player_id:[_player_name, _player_id, _game_id, _is_host]}]}
var _open_games = {}
var _players_online = []
remote func get_open_games_from_server(id):
rpc_id(id, "update_open_games", _open_games)
remote func add_game_to_game_list(game_id, game_information, host_player):
_open_games[game_id] = game_information
add_player_to_open_game(game_id, host_player)
get_open_games_from_server(game_id)
remote func join_open_game(game_id, player_information):
add_player_to_open_game(game_id, player_information)
func add_player_to_open_game(game_id, player_information):
_open_games[game_id][3][player_information[1]] = player_information
remote func remove_player_from_open_game(game_id, player_id):
_open_games[game_id][3].erase(player_id)
remote func remove_game_from_game_list(game_id):
_open_games.erase(game_id)

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Scenes/Matchmaking/Networking/Networking_sync.gd" type="Script" id=1]
[node name="Networking" type="Node"]
script = ExtResource( 1 )

View File

@@ -0,0 +1,32 @@
extends Node
const SERVER_PORT = 14600
const MAX_PLAYERS = 1000
func _ready():
get_tree().connect("network_peer_connected", self, "_player_connected")
get_tree().connect("network_peer_disconnected", self, "_player_disconnected")
start_server()
func start_server():
print("Try to start the server.")
var peer = NetworkedMultiplayerENet.new()
var result = peer.create_server(SERVER_PORT, MAX_PLAYERS)
if result != OK:
print("Failed creating the server.")
return
else:
print("Created the server.")
get_tree().set_network_peer(peer)
func _player_connected(id):
print(str(id) + " connected to server.")
NetworkingSync._players_online.append(id)
func _player_disconnected(id):
print(str(id) + " left the game.")
NetworkingSync._players_online.erase(id)
if id in NetworkingSync._open_games:
NetworkingSync.remove_game_from_game_list(id)

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Scenes/Matchmaking/Server/Server.gd" type="Script" id=1]
[node name="Server" type="Node"]
script = ExtResource( 1 )

67
Server/export_presets.cfg Normal file
View File

@@ -0,0 +1,67 @@
[preset.0]
name="Linux/X11"
platform="Linux/X11"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="../../Godot_Executables/Server.x86_64"
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.0.options]
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
binary_format/64_bits=true
binary_format/embed_pck=false
custom_template/release=""
custom_template/debug=""
[preset.1]
name="Windows Desktop"
platform="Windows Desktop"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.1.options]
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
binary_format/64_bits=true
binary_format/embed_pck=false
custom_template/release=""
custom_template/debug=""
codesign/enable=false
codesign/identity=""
codesign/password=""
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PoolStringArray( )
application/icon=""
application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""

BIN
Server/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

34
Server/icon.png.import Normal file
View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

24
Server/project.godot Normal file
View File

@@ -0,0 +1,24 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Server_project"
run/main_scene="res://Scenes/Matchmaking/Server/Server.tscn"
config/icon="res://icon.png"
[autoload]
NetworkingSync="*res://Scenes/Matchmaking/Networking/Networking_sync.tscn"