diff options
| author | metamuffin <metamuffin@disroot.org> | 2024-06-27 17:21:52 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-06-27 17:21:52 +0200 | 
| commit | 82408a6d478ed9f7009482c69f1f4d69025c833d (patch) | |
| tree | 2d27c799917c2d44417882fd04cfff37e25cd18b | |
| parent | 4fa692dae19789e5e766c50ac31874653d02971a (diff) | |
| parent | 86eaa98918760ed829f23a70f15604bf751549be (diff) | |
| download | hurrycurry-82408a6d478ed9f7009482c69f1f4d69025c833d.tar hurrycurry-82408a6d478ed9f7009482c69f1f4d69025c833d.tar.bz2 hurrycurry-82408a6d478ed9f7009482c69f1f4d69025c833d.tar.zst | |
Merge branch 'master' of https://codeberg.org/metamuffin/undercooked
30 files changed, 348 insertions, 21 deletions
| diff --git a/client/game.tscn b/client/game.tscn index 278f31d3..ff6b8da5 100644 --- a/client/game.tscn +++ b/client/game.tscn @@ -29,6 +29,7 @@ script = ExtResource("6_fbxu8")  [node name="FollowCamera" parent="." node_paths=PackedStringArray("target") instance=ExtResource("2_s8y6o")]  transform = Transform3D(0.728777, 0.294253, -0.618303, 0, 0.902961, 0.429723, 0.684751, -0.313173, 0.658057, -2.36537, 1.99403, 3.29507) +far = 150.0  target = NodePath("..")  [node name="WorldEnvironment" type="WorldEnvironment" parent="."] diff --git a/client/global.gd b/client/global.gd index f26a066f..49b5f72e 100644 --- a/client/global.gd +++ b/client/global.gd @@ -28,9 +28,13 @@ var default_settings := {  		"value": true,  		"description": tr("Interpolate the camera rotation")  	}, -	"test": { -		"value": "hehe", -		"description": tr("Just a test value") +	"server_binary": { +		"value": "", +		"description": tr("The path of the server binary (leave empty to search PATH)") +	}, +	"server_data": { +		"value": "", +		"description": tr("The path of the server data directory (leave empty to auto-detect)")  	},  } @@ -68,6 +72,8 @@ func load_dict(path: String, default: Dictionary) -> Dictionary:  		for i in default.keys():  			if saved_dict.has(i):  				res[i] = saved_dict[i] +			else: +				res[i] = default[i]  	print("Loaded dict: ", res)  	return res diff --git a/client/map/item_factory.gd b/client/map/item_factory.gd index 86e69d1d..d3da32ef 100644 --- a/client/map/item_factory.gd +++ b/client/map/item_factory.gd @@ -70,5 +70,17 @@ static func produce(name: String, owned_by: Node3D) -> Item:  			return TomatoSoupPlate.new(owned_by)  		"burned":  			return Burned.new(owned_by) +		"bread-slice-plate": +			return BreadSlicePlate.new(owned_by) +		"bread-slice-steak-plate": +			return BreadSliceSteakPlate.new(owned_by) +		"bread-slice-sliced-tomato-plate": +			return BreadSliceSlicedTomatoPlate.new(owned_by) +		"bread-slice-sliced-tomato-steak-plate": +			return BreadSliceSlicedTomatoSteakPlate.new(owned_by) +		"sliced-tomato-plate": +			return SlicedTomatoPlate.new(owned_by) +		"sliced-tomato-steak-plate": +			return SlicedTomatoSteakPlate.new(owned_by)  		var t:  			return GenericItem.new(owned_by, t) diff --git a/client/map/items/slice.gd b/client/map/items/bread_slice.gd index 0449689a..0449689a 100644 --- a/client/map/items/slice.gd +++ b/client/map/items/bread_slice.gd diff --git a/client/map/items/bread_slice_plate.gd b/client/map/items/bread_slice_plate.gd new file mode 100644 index 00000000..54a393bc --- /dev/null +++ b/client/map/items/bread_slice_plate.gd @@ -0,0 +1,21 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +#  +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +#  +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +# GNU Affero General Public License for more details. +#  +# You should have received a copy of the GNU Affero General Public License +# along with this program.  If not, see <https://www.gnu.org/licenses/>. +#  +class_name BreadSlicePlate +extends Plate + +func _init(owned_by_: Node3D): +	super(owned_by_) +	base.add_child(load("res://map/items/bread_slice.tscn").instantiate()) diff --git a/client/map/items/bread_slice_sliced_tomato_plate.gd b/client/map/items/bread_slice_sliced_tomato_plate.gd new file mode 100644 index 00000000..63e74c21 --- /dev/null +++ b/client/map/items/bread_slice_sliced_tomato_plate.gd @@ -0,0 +1,23 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +#  +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +#  +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +# GNU Affero General Public License for more details. +#  +# You should have received a copy of the GNU Affero General Public License +# along with this program.  If not, see <https://www.gnu.org/licenses/>. +#  +class_name BreadSliceSlicedTomatoPlate +extends BreadSlicePlate + +func _init(owned_by_: Node3D): +	super(owned_by_) +	var tomato = load("res://map/items/sliced_tomato.tscn").instantiate() +	tomato.position.y = .05 +	base.add_child(tomato) diff --git a/client/map/items/bread_slice_sliced_tomato_steak_plate.gd b/client/map/items/bread_slice_sliced_tomato_steak_plate.gd new file mode 100644 index 00000000..157c02e9 --- /dev/null +++ b/client/map/items/bread_slice_sliced_tomato_steak_plate.gd @@ -0,0 +1,23 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +#  +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +#  +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +# GNU Affero General Public License for more details. +#  +# You should have received a copy of the GNU Affero General Public License +# along with this program.  If not, see <https://www.gnu.org/licenses/>. +#  +class_name BreadSliceSlicedTomatoSteakPlate +extends BreadSliceSteakPlate + +func _init(owned_by_: Node3D): +	super(owned_by_) +	var tomato = load("res://map/items/sliced_tomato.tscn").instantiate() +	tomato.position.y = .15 +	base.add_child(tomato) diff --git a/client/map/items/bread_slice_steak_plate.gd b/client/map/items/bread_slice_steak_plate.gd new file mode 100644 index 00000000..902cdf44 --- /dev/null +++ b/client/map/items/bread_slice_steak_plate.gd @@ -0,0 +1,23 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +#  +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +#  +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +# GNU Affero General Public License for more details. +#  +# You should have received a copy of the GNU Affero General Public License +# along with this program.  If not, see <https://www.gnu.org/licenses/>. +#  +class_name BreadSliceSteakPlate +extends BreadSlicePlate + +func _init(owned_by_: Node3D): +	super(owned_by_) +	var steak = load("res://map/items/steak.tscn").instantiate() +	steak.position.y = .05 +	base.add_child(steak) diff --git a/client/map/items/grass.gd b/client/map/items/grass.gd index 3b8d4016..d303f8c7 100644 --- a/client/map/items/grass.gd +++ b/client/map/items/grass.gd @@ -18,6 +18,6 @@ extends Tile  func _init(rename: String, _neighbors: Array):  	super(rename, _neighbors) -	#var grass_tile = load("res://map/tiles/grass.tscn").instantiate() -	#grass_tile.position += Vector3(0.5, 0, 0.5) -	#add_child(floor_tile) +	var grass_tile = load("res://map/tiles/grass.tscn").instantiate() +	grass_tile.position += Vector3(0.5, 0, 0.5) +	add_child(grass_tile) diff --git a/client/map/items/plate.gd b/client/map/items/plate.gd index 91faf0b1..4431a6c8 100644 --- a/client/map/items/plate.gd +++ b/client/map/items/plate.gd @@ -18,7 +18,7 @@ extends Item  func _init(owned_by_: Node3D):  	super(owned_by_) -	base.add_child(load("res://map/items/plate.tscn").instantiate()) +	add_child(load("res://map/items/plate.tscn").instantiate())  static func base_position() -> Vector3:  	return Vector3(0., 0.015, 0.) diff --git a/client/map/items/pot.gd b/client/map/items/pot.gd index ac865329..89cbf4c4 100644 --- a/client/map/items/pot.gd +++ b/client/map/items/pot.gd @@ -20,7 +20,7 @@ var steam: CPUParticles3D = load("res://map/items/steam.tscn").instantiate()  func _init(owned_by_: Node3D):  	super(owned_by_) -	base.add_child(load("res://map/items/pot.tscn").instantiate()) +	add_child(load("res://map/items/pot.tscn").instantiate())  	base.add_child(steam)  func progress(p: float, warn: bool): diff --git a/client/map/items/sliced_tomato_plate.gd b/client/map/items/sliced_tomato_plate.gd new file mode 100644 index 00000000..e8ea2d7b --- /dev/null +++ b/client/map/items/sliced_tomato_plate.gd @@ -0,0 +1,21 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +#  +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +#  +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +# GNU Affero General Public License for more details. +#  +# You should have received a copy of the GNU Affero General Public License +# along with this program.  If not, see <https://www.gnu.org/licenses/>. +#  +class_name SlicedTomatoPlate +extends Plate + +func _init(owned_by_: Node3D): +	super(owned_by_) +	base.add_child(load("res://map/items/sliced_tomato.tscn").instantiate()) diff --git a/client/map/items/sliced_tomato_steak_plate.gd b/client/map/items/sliced_tomato_steak_plate.gd new file mode 100644 index 00000000..8dbb9c71 --- /dev/null +++ b/client/map/items/sliced_tomato_steak_plate.gd @@ -0,0 +1,23 @@ +# Undercooked - a game about cooking +# Copyright 2024 nokoe +#  +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +#  +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +# GNU Affero General Public License for more details. +#  +# You should have received a copy of the GNU Affero General Public License +# along with this program.  If not, see <https://www.gnu.org/licenses/>. +#  +class_name SlicedTomatoSteakPlate +extends SteakPlate + +func _init(owned_by_: Node3D): +	super(owned_by_) +	var tomato = load("res://map/items/sliced_tomato.tscn").instantiate() +	tomato.position.y = .1 +	base.add_child(tomato) diff --git a/client/map/items/exterior_tree.gd b/client/map/tiles/exterior_tree.gd index d1e0b6b3..d1e0b6b3 100644 --- a/client/map/items/exterior_tree.gd +++ b/client/map/tiles/exterior_tree.gd diff --git a/client/map/tiles/grass.res b/client/map/tiles/grass.resBinary files differ new file mode 100644 index 00000000..1c4565a1 --- /dev/null +++ b/client/map/tiles/grass.res diff --git a/client/map/tiles/grass.tscn b/client/map/tiles/grass.tscn new file mode 100644 index 00000000..dd0ef53c --- /dev/null +++ b/client/map/tiles/grass.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=3 format=3 uid="uid://ce14cj7exkvas"] + +[ext_resource type="ArrayMesh" uid="uid://dyu8iuolwqr5l" path="res://map/tiles/grass.res" id="1_pjjrj"] +[ext_resource type="Script" path="res://map/tiles/grass_generation.gd" id="1_u7p1u"] + +[node name="Grass" type="Node3D"] +script = ExtResource("1_u7p1u") + +[node name="Mesh" type="MeshInstance3D" parent="."] +transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) +mesh = ExtResource("1_pjjrj") +skeleton = NodePath("") diff --git a/client/map/tiles/grass_generation.gd b/client/map/tiles/grass_generation.gd new file mode 100644 index 00000000..2031c64a --- /dev/null +++ b/client/map/tiles/grass_generation.gd @@ -0,0 +1,15 @@ +extends Node3D + +const GRASS_COUNT = 16 + +@onready var grass_side = preload("res://map/tiles/grass_side.tscn") + +func _ready(): +	var random = RandomNumberGenerator.new() +	random.randomize() +	 +	for _i in GRASS_COUNT: +		var g: Node3D = grass_side.instantiate() +		add_child(g) +		g.position = Vector3(random.randf_range(-.5, .5), 0, random.randf_range(-.5, .5)) +		g.rotation = Vector3(0, random.randf_range(0, PI), 0) diff --git a/client/map/tiles/grass_side.res b/client/map/tiles/grass_side.resBinary files differ new file mode 100644 index 00000000..1e008942 --- /dev/null +++ b/client/map/tiles/grass_side.res diff --git a/client/map/tiles/grass_side.res.depren b/client/map/tiles/grass_side.res.deprenBinary files differ new file mode 100644 index 00000000..3116171f --- /dev/null +++ b/client/map/tiles/grass_side.res.depren diff --git a/client/map/tiles/grass_side.tscn b/client/map/tiles/grass_side.tscn new file mode 100644 index 00000000..cfa7c97a --- /dev/null +++ b/client/map/tiles/grass_side.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://dbp0ts6tfycev"] + +[ext_resource type="ArrayMesh" uid="uid://bxtxpg4lsk613" path="res://map/tiles/grass_side.res" id="1_u044x"] + +[node name="GrassSide" type="Node3D"] + +[node name="Mesh" type="MeshInstance3D" parent="."] +transform = Transform3D(0.5, 0, 0, 0, 0.00872619, -0.499924, 0, 0.499924, 0.00872619, 0, 0.25, 0) +mesh = ExtResource("1_u044x") +skeleton = NodePath("") diff --git a/client/map/tiles/grass_side.webp b/client/map/tiles/grass_side.webpBinary files differ new file mode 100644 index 00000000..060d0d53 --- /dev/null +++ b/client/map/tiles/grass_side.webp diff --git a/client/map/tiles/grass_side.webp.import b/client/map/tiles/grass_side.webp.import new file mode 100644 index 00000000..5c19b024 --- /dev/null +++ b/client/map/tiles/grass_side.webp.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://p35o0tkyfmrl" +path.s3tc="res://.godot/imported/grass_side.webp-1886940fb35aab66d976c18e081911f4.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://map/tiles/grass_side.webp" +dest_files=["res://.godot/imported/grass_side.webp-1886940fb35aab66d976c18e081911f4.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/client/menu/main_menu.tscn b/client/menu/main_menu.tscn index 03f9cf46..36f417f4 100644 --- a/client/menu/main_menu.tscn +++ b/client/menu/main_menu.tscn @@ -2,7 +2,7 @@  [ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme.tres" id="1_nlcpo"]  [ext_resource type="Script" path="res://menu/main_menu.gd" id="2_qot2j"] -[ext_resource type="Material" path="res://menu/theme/dark_blur_material.tres" id="3_k58q5"] +[ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://menu/theme/dark_blur_material.tres" id="3_k58q5"]  [ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/theme/font-sansita-swashed.woff2" id="4_mfs30"]  [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ukani"] diff --git a/client/multiplayer.gd b/client/multiplayer.gd index db891562..0d9697e8 100644 --- a/client/multiplayer.gd +++ b/client/multiplayer.gd @@ -191,6 +191,14 @@ func send_interact(pos: Vector2i, edge: bool):  		"edge": edge  	}) +func send_chat(message: String): +	send_packet({ +		"type": "communicate", +		"message": { +			"text": message +		} +	}) +  func send_packet(packet):  	var json = JSON.stringify(packet)  	socket.send_text(json) diff --git a/client/player/chat_bubble.gd b/client/player/chat_bubble.gd index 6b09b69b..1329e198 100644 --- a/client/player/chat_bubble.gd +++ b/client/player/chat_bubble.gd @@ -1,7 +1,12 @@  class_name ChatBubble  extends MeshInstance3D +signal submit_message +  @onready var label: Label = $SubViewport/ChatMessage/Label +@onready var input: LineEdit = $LineEdit + +var editing := false  func set_text(t: String):  	visible = true @@ -10,3 +15,20 @@ func set_text(t: String):  func remove_text():  	visible = false  	label.text = "" + +func edit(): +	visible = true +	label.text = "" +	editing = true +	input.grab_focus() + +func stop_edit(): +	visible = false +	editing = false +	input.release_focus() +	if input.text != "": +		submit_message.emit(input.text) +	input.text = "" + +func _on_line_edit_text_changed(new_text): +	label.text = new_text diff --git a/client/player/chat_bubble.tscn b/client/player/chat_bubble.tscn index adb68bc1..8d765156 100644 --- a/client/player/chat_bubble.tscn +++ b/client/player/chat_bubble.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=6 format=3 uid="uid://cgi6vcfrnqp0i"] +[gd_scene load_steps=7 format=3 uid="uid://cgi6vcfrnqp0i"]  [ext_resource type="Script" path="res://player/chat_bubble.gd" id="1_4v1cx"]  [ext_resource type="PackedScene" uid="uid://5rcfoyuiwuya" path="res://player/chat_message.tscn" id="2_lyyq0"] @@ -17,6 +17,8 @@ shading_mode = 0  albedo_texture = SubResource("ViewportTexture_mko8a")  billboard_mode = 1 +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_byl28"] +  [node name="ChatBubble" type="MeshInstance3D"]  transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)  visible = false @@ -25,7 +27,18 @@ surface_material_override/0 = SubResource("StandardMaterial3D_5iy0t")  script = ExtResource("1_4v1cx")  [node name="SubViewport" type="SubViewport" parent="."] +disable_3d = true  transparent_bg = true  size = Vector2i(512, 128)  [node name="ChatMessage" parent="SubViewport" instance=ExtResource("2_lyyq0")] + +[node name="LineEdit" type="LineEdit" parent="."] +modulate = Color(1, 1, 1, 0) +offset_right = 67.0625 +offset_bottom = 31.0 +theme_override_styles/normal = SubResource("StyleBoxEmpty_byl28") +theme_override_styles/focus = SubResource("StyleBoxEmpty_byl28") +theme_override_styles/read_only = SubResource("StyleBoxEmpty_byl28") + +[connection signal="text_changed" from="LineEdit" to="." method="_on_line_edit_text_changed"] diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd index 7501ca0a..8b2da8c2 100644 --- a/client/player/controllable_player.gd +++ b/client/player/controllable_player.gd @@ -26,7 +26,8 @@ const BOOST_RESTORE = 0.5  var facing = Vector2(1, 0)  var velocity_ = Vector2(0, 0)  var stamina = 0 -var boosting = false +var boosting := false +var chat_open := false  var target: Vector2i = Vector2i(0, 0) @@ -40,6 +41,15 @@ func _ready():  		game.mp.send_position(position_, rotation_)  	)  	super() +	bubble.submit_message.connect(submit_message) + +func _input(_event): +	if Input.is_action_just_pressed("chat"): +		if chat_open: +			bubble.stop_edit() +		else: +			bubble.edit() +		chat_open = !chat_open  func _process(delta):  	var input = Input.get_vector("left", "right", "forward", "backwards") @@ -106,8 +116,10 @@ func aabb_point_distance(mi: Vector2, ma: Vector2, p: Vector2) -> float:  	return (p - p.clamp(mi, ma)).length()  func update_position(new_position: Vector2, _new_rotation: float): -	if (new_position - position_).length() > 3.: -		position_ = new_position +	pass + +func submit_message(text: String): +	game.mp.send_chat(text)  func interact():  	var tile = game.map.get_tile_instance(target) diff --git a/client/project.godot b/client/project.godot index ec7780f3..2d8bcbfd 100644 --- a/client/project.godot +++ b/client/project.godot @@ -118,6 +118,12 @@ zoom_out={  , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":4,"axis_value":1.0,"script":null)  ]  } +chat={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194309,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":4,"pressure":0.0,"pressed":true,"script":null) +] +}  [internationalization] diff --git a/client/server.gd b/client/server.gd index 972e1f2d..b0ab5188 100644 --- a/client/server.gd +++ b/client/server.gd @@ -1,3 +1,19 @@ +# Undercooked - a game about cooking +# Copyright 2024 metamuffin +# Copyright 2024 nokoe +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program.  If not, see <https://www.gnu.org/licenses/>. +#  class_name GameServer  extends Node @@ -22,9 +38,11 @@ func _ready():  	thread = Thread.new()  	thread.start(_test_server) +func test(): +	pass  func start(): -	if state != State.STOPPED and state != State.FAILED:  +	if state != State.STOPPED and state != State.FAILED:  		push_error("server cant be started")  		return  	state = State.STARTING @@ -39,11 +57,17 @@ func stop():  func _test_server():  	var output = [] -	thread_result = OS.execute("undercooked-server", ["-v"], output, true, false) +	thread_result = OS.execute(get_server_path(), ["-v"], output, true, false)  	sem.post()  func _server_exec(): -	thread_result = OS.create_process("undercooked-server", [], false) +	var args = [] +	var data_path = get_server_data() +	if data_path != null: +		args.push_back("--data-dir") +		args.push_back(data_path) +	thread_result = OS.create_process(get_server_path(), args, false) +	print(get_server_path(), args)  	if thread_result >= 0:  		var ok = false  		while not ok: @@ -59,6 +83,20 @@ func _server_exec():  				break  	sem.post() +func get_server_path() -> String: +	var path: String = Global.settings["server_binary"]["value"] +	if path != "": +		return path +	else: +		return "undercooked-server" + +func get_server_data(): +	var path: String = Global.settings["server_data"]["value"] +	if path != "": +		return path +	else: +		return null +  func _process(_delta):  	match state:  		State.TESTING: @@ -70,7 +108,7 @@ func _process(_delta):  				thread = null  		State.STARTING:  			if sem.try_wait(): -				if thread_result >= 0:  +				if thread_result >= 0:  					state = State.RUNNING  					pid = thread_result  					print("Server: Started pid=", thread_result) diff --git a/server/src/data.rs b/server/src/data.rs index e2944e3d..6b0442ce 100644 --- a/server/src/data.rs +++ b/server/src/data.rs @@ -19,7 +19,7 @@ use crate::{      interaction::Recipe,      protocol::{DemandIndex, ItemIndex, RecipeIndex, TileIndex},  }; -use anyhow::{anyhow, bail, Result}; +use anyhow::{anyhow, bail, Context, Result};  use glam::{IVec2, Vec2};  use serde::{Deserialize, Serialize};  use std::{ @@ -142,9 +142,12 @@ impl DataIndex {          let map_path = data_dir().join(format!("maps/{map}.yaml"));          let recipes_path = data_dir().join(format!("recipes/{recipes}.yaml")); -        let demands_in = serde_yaml::from_reader(File::open(demands_path).unwrap()).unwrap(); -        let map_in = serde_yaml::from_reader(File::open(map_path).unwrap()).unwrap(); -        let recipes_in = serde_yaml::from_reader(File::open(recipes_path).unwrap()).unwrap(); +        let demands_in = +            serde_yaml::from_reader(File::open(demands_path).context("opening demands failed")?)?; +        let map_in = serde_yaml::from_reader(File::open(map_path).context("opening map failed")?)?; +        let recipes_in = serde_yaml::from_reader( +            File::open(recipes_path).context("opening recipes failed. are they generated yet?")?, +        )?;          Ok(Gamedata::build(recipes_in, map_in, demands_in)?)      } | 
