Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable building on stable Rust & modernize codebase #48

Draft
wants to merge 15 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ target
*.pak
*.pak.d
.#*
id1
.vscode
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "richter"
version = "0.1.0"
authors = ["Cormac O'Brien <cormac@c-obrien.org>"]
edition = "2018"
edition = "2021"

[dependencies]
arrayvec = "0.7"
Expand All @@ -22,8 +22,7 @@ num-derive = "0.1.42"
png = "0.16"
rand = { version = "0.7", features = ["small_rng"] }
regex = "0.2.6"
# rodio = "0.12"
rodio = { git = "https://github.com/RustAudio/rodio", rev = "82b4952" }
rodio = "0.15.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
shaderc = "0.6.2"
Expand All @@ -34,7 +33,7 @@ strum_macros = "0.18.0"
thiserror = "1.0"
uluru = "2"
wgpu = "0.8"
winit = "0.27.2"

# "winit" = "0.22.2"
# necessary until winit/#1524 is merged
winit = { git = "https://github.com/chemicstry/winit", branch = "optional_drag_and_drop" }
[profile.dev.package."*"]
opt-level = 3
53 changes: 27 additions & 26 deletions src/bin/quake-client/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use std::{
io::{Cursor, Read, Write},
net::SocketAddr,
path::{Path, PathBuf},
process::exit,
rc::Rc,
};

Expand Down Expand Up @@ -57,7 +56,7 @@ use structopt::StructOpt;
use winit::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop, EventLoopWindowTarget},
window::Window,
window::{CursorGrabMode, Window},
};

struct ClientProgram {
Expand Down Expand Up @@ -161,30 +160,32 @@ impl ClientProgram {
// implements "exec" command
let exec_vfs = vfs.clone();
let exec_console = console.clone();
cmds.borrow_mut().insert_or_replace(
"exec",
Box::new(move |args| {
match args.len() {
// exec (filename): execute a script file
1 => {
let mut script_file = match exec_vfs.open(args[0]) {
Ok(s) => s,
Err(e) => {
return format!("Couldn't exec {}: {:?}", args[0], e);
}
};

let mut script = String::new();
script_file.read_to_string(&mut script).unwrap();
cmds.borrow_mut()
.insert_or_replace(
"exec",
Box::new(move |args| {
match args.len() {
// exec (filename): execute a script file
1 => {
let mut script_file = match exec_vfs.open(args[0]) {
Ok(s) => s,
Err(e) => {
return format!("Couldn't exec {}: {:?}", args[0], e);
}
};

let mut script = String::new();
script_file.read_to_string(&mut script).unwrap();

exec_console.borrow().stuff_text(script);
String::new()
}

exec_console.borrow().stuff_text(script);
String::new()
_ => format!("exec (filename): execute a script file"),
}

_ => format!("exec (filename): execute a script file"),
}
}),
).unwrap();
}),
)
.unwrap();

// this will also execute config.cfg and autoexec.cfg (assuming an unmodified quake.rc)
console.borrow().stuff_text("exec quake.rc\n");
Expand Down Expand Up @@ -292,7 +293,7 @@ impl Program for ClientProgram {

match self.input.borrow().focus() {
InputFocus::Game => {
if let Err(e) = self.window.set_cursor_grab(true) {
if let Err(e) = self.window.set_cursor_grab(CursorGrabMode::Locked) {
// This can happen if the window is running in another
// workspace. It shouldn't be considered an error.
log::debug!("Couldn't grab cursor: {}", e);
Expand All @@ -302,7 +303,7 @@ impl Program for ClientProgram {
}

_ => {
if let Err(e) = self.window.set_cursor_grab(false) {
if let Err(e) = self.window.set_cursor_grab(CursorGrabMode::None) {
log::debug!("Couldn't release cursor: {}", e);
};
self.window.set_cursor_visible(true);
Expand Down
Loading