aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/server.gd18
-rw-r--r--data/recipes/default.ts2
-rw-r--r--server/src/game.rs13
-rw-r--r--server/src/main.rs23
-rw-r--r--test-client/main.ts7
5 files changed, 45 insertions, 18 deletions
diff --git a/client/server.gd b/client/server.gd
index ce8b671c..8eaaaecb 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
@@ -41,7 +57,7 @@ func stop():
func _test_server():
var output = []
- thread_result = OS.execute(get_server_path(), ["version"], output, true, false)
+ thread_result = OS.execute(get_server_path(), ["-v"], output, true, false)
sem.post()
func _server_exec():
diff --git a/data/recipes/default.ts b/data/recipes/default.ts
index f0a9ef6b..dd662081 100644
--- a/data/recipes/default.ts
+++ b/data/recipes/default.ts
@@ -68,7 +68,7 @@ export function process(from: string, to?: string) {
const i = from + "-foodprocessor"
const o = (to ?? (from + "-juice")) + "-foodprocessor"
out({ action: "instant", inputs: ["foodprocessor", from], outputs: [i] })
- out({ action: "active", duration: 3, inputs: [i], outputs: [o] })
+ out({ action: "passive", duration: 5, inputs: [i], outputs: [o] })
}
export function bake(from: string, to?: string) {
const o = (to ?? ("cooked-" + from))
diff --git a/server/src/game.rs b/server/src/game.rs
index ad777584..4cb5c450 100644
--- a/server/src/game.rs
+++ b/server/src/game.rs
@@ -202,17 +202,18 @@ impl Game {
pub fn packet_in(&mut self, player: PlayerID, packet: PacketS) -> Result<()> {
match packet {
PacketS::Join { name, character } => {
+ let position = if player.0 < 0 {
+ self.data.customer_spawn
+ } else {
+ self.data.chef_spawn
+ };
self.players.insert(
player,
Player {
item: None,
last_position_ts: Instant::now(),
character,
- position: if player.0 < 0 {
- self.data.customer_spawn
- } else {
- self.data.chef_spawn
- },
+ position,
communicate: None,
interacting: None,
name: name.clone(),
@@ -221,7 +222,7 @@ impl Game {
self.packet_out.push_back(PacketC::AddPlayer {
id: player,
name,
- position: self.data.chef_spawn,
+ position,
character,
});
}
diff --git a/server/src/main.rs b/server/src/main.rs
index db667779..5b191365 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -16,9 +16,10 @@
*/
use anyhow::{anyhow, Result};
+use clap::Parser;
use futures_util::{SinkExt, StreamExt};
use log::{debug, info, warn, LevelFilter};
-use std::{env::args, path::PathBuf, process::exit, str::FromStr, sync::Arc, time::Duration};
+use std::{path::PathBuf, process::exit, str::FromStr, sync::Arc, time::Duration};
use tokio::{
net::TcpListener,
spawn,
@@ -32,25 +33,33 @@ use undercooked::{
state::State,
};
+#[derive(Parser)]
+struct Args {
+ #[arg(short, long)]
+ version: bool,
+ #[arg(short, long, default_value = "./data")]
+ data_dir: PathBuf,
+}
+
fn main() -> Result<()> {
env_logger::builder()
.filter_level(LevelFilter::Info)
.parse_env("LOG")
.init();
- if let Some(arg) = args().nth(1) {
- match arg.as_str() {
- "version" => println!("{}", env!("CARGO_PKG_VERSION")),
- _ => panic!("unknown subcommand"),
- }
+ let args = Args::parse();
+
+ if args.version {
+ println!("{}", env!("CARGO_PKG_VERSION"));
exit(0);
}
let data_dir = PathBuf::from_str(
[
+ args.data_dir.to_str().unwrap(),
"/usr/local/share/undercooked/data",
"/usr/share/undercooked/data",
- "./data",
+ "/opt/undercooked/data",
]
.into_iter()
.find(|p| PathBuf::from_str(p).unwrap().join("index.yaml").exists())
diff --git a/test-client/main.ts b/test-client/main.ts
index b0b492ce..4d1e9c53 100644
--- a/test-client/main.ts
+++ b/test-client/main.ts
@@ -19,7 +19,7 @@
import { MovementBase, update_movement } from "./movement.ts";
import { Gamedata, ItemIndex, Message, PacketC, PacketS, PlayerID, TileIndex } from "./protocol.ts";
-import { V2, add_v2, lerp_exp_v2_mut, normalize, lerp_exp, sub_v2, length } from "./util.ts";
+import { V2, add_v2, lerp_exp_v2_mut, normalize, lerp_exp } from "./util.ts";
import { draw_ingame, draw_wait } from "./visual.ts";
const KEY_INTERACT = "KeyJ"
@@ -139,9 +139,10 @@ function packet(p: PacketC) {
case "position": {
const pl = players.get(p.player)!
const pos = { x: p.pos[0], y: p.pos[1] }
- const dist = length(sub_v2(pl.position, pos));
+ // const dist = length(sub_v2(pl.position, pos));a
// TODO this is actually not a good idea if latency is too high
- if (p.player == my_id && dist < 3) return; // we know better where we are
+ // if (p.player == my_id && dist < 3) return; // we know better where we are
+ if (p.player == my_id) return
pl.position.x = pos.x
pl.position.y = pos.y
pl.rot = p.rot