3 Commits

Author SHA1 Message Date
7ca7615222 v0.4.2 2023-08-17 20:26:25 +02:00
2195f42abc fix: unix.. again 2023-08-17 20:26:08 +02:00
f7635d4089 return 101 when restart is required after self-update 2023-08-17 18:32:32 +02:00
4 changed files with 20 additions and 15 deletions

2
Cargo.lock generated
View File

@ -13,7 +13,7 @@ dependencies = [
[[package]]
name = "alterware-launcher"
version = "0.4.1"
version = "0.4.2"
dependencies = [
"http_req",
"mslnk",

View File

@ -1,6 +1,6 @@
[package]
name = "alterware-launcher"
version = "0.4.1"
version = "0.4.2"
edition = "2021"
build = "res/build.rs"

View File

@ -9,3 +9,6 @@
- Passing ```iw4-sp```, ```iw5-mod```, ```iw6-mod``` or ```s1-mod``` as the first argument will skip automatic game detection
- Passing ```update``` will stop the launcher from launching the game
- ```skip-launcher-update``` skips self-update
### Note for server owners:
When the launcher updates itself it needs to be restarted. It will return exit code 101 in this case.

View File

@ -53,7 +53,7 @@ fn self_update_available() -> bool {
}
#[cfg(not(windows))]
fn self_update() {
fn self_update(_update_only: bool) {
if self_update_available() {
println!("A new version of the AlterWare launcher is available.");
println!("Download it at https://github.com/{}/releases/latest", REPO);
@ -63,7 +63,7 @@ fn self_update() {
}
#[cfg(windows)]
fn self_update() {
fn self_update(update_only: bool) {
let working_dir = std::env::current_dir().unwrap();
let files = fs::read_dir(&working_dir).unwrap();
@ -106,8 +106,10 @@ fn self_update() {
self_replace::self_replace("alterware-launcher-update.exe").unwrap();
fs::remove_file(&file_path).unwrap();
println!("Launcher updated. Please run it again.");
std::io::stdin().read_line(&mut String::new()).unwrap();
std::process::exit(0);
if !update_only {
std::io::stdin().read_line(&mut String::new()).unwrap();
}
std::process::exit(101);
}
}
@ -260,8 +262,16 @@ fn launch(file_path: &PathBuf) {
fn main() {
let mut args: Vec<String> = std::env::args().collect();
let mut update_only = false;
if args.contains(&String::from("update")) {
update_only = true;
args.iter()
.position(|r| r == "update")
.map(|e| args.remove(e));
}
if !args.contains(&String::from("skip-launcher-update")) {
self_update();
self_update(update_only);
} else {
args.iter()
.position(|r| r == "skip-launcher-update")
@ -271,14 +281,6 @@ fn main() {
let games_json = http::get_body_string(format!("{}/games.json", MASTER).as_str());
let games: Vec<Game> = serde_json::from_str(&games_json).unwrap();
let mut update_only = false;
if args.contains(&String::from("update")) {
update_only = true;
args.iter()
.position(|r| r == "update")
.map(|e| args.remove(e));
}
let mut game: String = String::new();
if args.len() > 1 {
game = String::from(&args[1]);