Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
140f4c335f | |||
3e1a266c3e | |||
92663425ef | |||
ffa379e6dd | |||
a41375a791 | |||
ac76e9bb89 |
44
Cargo.lock
generated
44
Cargo.lock
generated
@ -30,7 +30,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.4.7"
|
version = "0.4.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"http_req",
|
"http_req",
|
||||||
"mslnk",
|
"mslnk",
|
||||||
@ -199,23 +199,22 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs"
|
name = "dirs"
|
||||||
version = "5.0.1"
|
version = "3.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-sys",
|
"dirs-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs-sys"
|
name = "dirs-sys"
|
||||||
version = "0.4.1"
|
version = "0.3.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"option-ext",
|
|
||||||
"redox_users",
|
"redox_users",
|
||||||
"windows-sys",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -417,24 +416,12 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nom"
|
|
||||||
version = "1.2.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.17.2"
|
version = "1.17.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b"
|
checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "option-ext"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "password-hash"
|
name = "password-hash"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
@ -767,27 +754,17 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "steamlocate"
|
name = "steamlocate"
|
||||||
version = "1.2.1"
|
version = "2.0.0-alpha.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4ec01c74611d14a808cb212d17c6e03f0e30736a15ed1d5736f8a53154cea3ae"
|
checksum = "2b1568c4a70a26c4373fe1131ffa4eff055459631b6e40c6bc118615f2d870c3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs",
|
"dirs",
|
||||||
"keyvalues-parser",
|
"keyvalues-parser",
|
||||||
"keyvalues-serde",
|
"keyvalues-serde",
|
||||||
"serde",
|
"serde",
|
||||||
"steamy-vdf",
|
|
||||||
"winreg",
|
"winreg",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "steamy-vdf"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "533127ad49314bfe71c3d3fd36b3ebac3d24f40618092e70e1cfe8362c7fac79"
|
|
||||||
dependencies = [
|
|
||||||
"nom",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subtle"
|
name = "subtle"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
@ -1082,11 +1059,10 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winreg"
|
name = "winreg"
|
||||||
version = "0.11.0"
|
version = "0.10.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "76a1a57ff50e9b408431e8f97d5456f2807f8eb2a2cd79b06068fc87f8ecf189"
|
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "alterware-launcher"
|
name = "alterware-launcher"
|
||||||
version = "0.4.7"
|
version = "0.4.8"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "res/build.rs"
|
build = "res/build.rs"
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ semver = "1.0.18"
|
|||||||
zip = "0.6.6"
|
zip = "0.6.6"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
steamlocate = "1.2.1"
|
steamlocate = "2.0.0-alpha.0"
|
||||||
mslnk = "0.1.8"
|
mslnk = "0.1.8"
|
||||||
# https://github.com/mitsuhiko/self-replace/pull/16/
|
# https://github.com/mitsuhiko/self-replace/pull/16/
|
||||||
windows-sys = { version = "0.48", features = [
|
windows-sys = { version = "0.48", features = [
|
||||||
|
48
README.md
48
README.md
@ -1,14 +1,50 @@
|
|||||||
# alterware-launcher
|
# AlterWare Launcher
|
||||||
|
|
||||||
1. Download [latest release](https://github.com/mxve/alterware-launcher/releases/latest/download/alterware-launcher-x86_64-pc-windows-msvc.zip)
|
### [AlterWare.dev](https://alterware.dev)
|
||||||
2. Unpack the archive and place alterware-launcher.exe in the game directory
|
|
||||||
|
##### IW4x | IW4-SP | IW5-Mod | IW6-Mod | S1-Mod
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### Installation
|
||||||
|
|
||||||
|
1. Download the [latest alterware-launcher.exe](https://github.com/mxve/alterware-launcher/releases/latest/download/alterware-launcher.exe)
|
||||||
|
2. Place alterware-launcher.exe in the game directory
|
||||||
3. Run alterware-launcher.exe, after updating the game will launch automatically
|
3. Run alterware-launcher.exe, after updating the game will launch automatically
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
- Passing ```iw4-sp```, ```iw5-mod```, ```iw6-mod``` or ```s1-mod``` as the first argument will skip automatic game detection
|
#### Command line arguments
|
||||||
|
|
||||||
|
- Passing ```iw4-sp```, ```iw4x```, ```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
|
- Passing ```update``` will stop the launcher from launching the game
|
||||||
- ```skip-launcher-update``` skips self-update
|
- ```skip-launcher-update``` skips launcher self-update
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### Support
|
||||||
|
|
||||||
|
Visit the [AlterWare Forum](https://forum.alterware.dev/) or [Discord](https://discord.gg/2ETE8engZM) for support.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### Building from Source
|
||||||
|
|
||||||
|
- [Install Rust](https://rustup.rs/)
|
||||||
|
- Clone the repository
|
||||||
|
- Run ```cargo build --release```
|
||||||
|
- The executable will be located in ```target/release```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Note for server owners:
|
### Note for server owners:
|
||||||
When the launcher updates itself it needs to be restarted. It will return exit code 201 in this case.
|
When the launcher updates itself it needs to be restarted. It will return exit code 201 in this case.
|
||||||
|
|
||||||
|
```
|
||||||
|
@echo off
|
||||||
|
:loop
|
||||||
|
start /wait alterware-launcher.exe update
|
||||||
|
if %errorlevel% equ 201 (
|
||||||
|
goto loop
|
||||||
|
)
|
||||||
|
```
|
@ -1,6 +1,6 @@
|
|||||||
use semver::Version;
|
use semver::Version;
|
||||||
|
|
||||||
pub fn latest(owner: &str, repo: &str) -> String {
|
pub fn latest_tag(owner: &str, repo: &str) -> String {
|
||||||
let github_body = crate::http::get_body_string(
|
let github_body = crate::http::get_body_string(
|
||||||
format!(
|
format!(
|
||||||
"https://api.github.com/repos/{}/{}/releases/latest",
|
"https://api.github.com/repos/{}/{}/releases/latest",
|
||||||
@ -9,13 +9,12 @@ pub fn latest(owner: &str, repo: &str) -> String {
|
|||||||
.as_str(),
|
.as_str(),
|
||||||
);
|
);
|
||||||
let github_json: serde_json::Value = serde_json::from_str(&github_body).unwrap();
|
let github_json: serde_json::Value = serde_json::from_str(&github_body).unwrap();
|
||||||
github_json["tag_name"]
|
github_json["tag_name"].to_string().replace('"', "")
|
||||||
.to_string()
|
|
||||||
.replace(['v', '"'].as_ref(), "")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn latest_version(owner: &str, repo: &str) -> Version {
|
pub fn latest_version(owner: &str, repo: &str) -> Version {
|
||||||
Version::parse(&latest(owner, repo)).unwrap()
|
let tag = latest_tag(owner, repo).replace('v', "");
|
||||||
|
Version::parse(&tag).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn latest_release_url(owner: &str, repo: &str) -> String {
|
pub fn latest_release_url(owner: &str, repo: &str) -> String {
|
||||||
|
@ -2,4 +2,4 @@ pub const MASTER: &str = "https://master.alterware.dev";
|
|||||||
pub const GH_OWNER: &str = "mxve";
|
pub const GH_OWNER: &str = "mxve";
|
||||||
pub const GH_REPO: &str = "alterware-launcher";
|
pub const GH_REPO: &str = "alterware-launcher";
|
||||||
pub const GH_IW4X_OWNER: &str = "iw4x";
|
pub const GH_IW4X_OWNER: &str = "iw4x";
|
||||||
pub const GH_IW4X_REPO: &str = "iw4x-client";
|
pub const GH_IW4X_REPO: &str = "iw4x-client";
|
||||||
|
40
src/iw4x.rs
40
src/iw4x.rs
@ -1,7 +1,7 @@
|
|||||||
use crate::github;
|
use crate::github;
|
||||||
|
use crate::global::*;
|
||||||
use crate::http;
|
use crate::http;
|
||||||
use crate::misc;
|
use crate::misc;
|
||||||
use crate::global::*;
|
|
||||||
|
|
||||||
use std::{fs, path::Path};
|
use std::{fs, path::Path};
|
||||||
|
|
||||||
@ -14,30 +14,24 @@ pub fn local_revision(dir: &Path) -> u16 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn remote_revision() -> u16 {
|
pub fn remote_revision() -> u16 {
|
||||||
misc::rev_to_int(&github::latest(GH_IW4X_OWNER, GH_IW4X_REPO))
|
misc::rev_to_int(&github::latest_tag(GH_IW4X_OWNER, GH_IW4X_REPO))
|
||||||
}
|
|
||||||
|
|
||||||
pub fn update_available(dir: &Path) -> bool {
|
|
||||||
if !dir.join("iw4x.dll").exists() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
local_revision(dir) < remote_revision()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(dir: &Path) {
|
pub fn update(dir: &Path) {
|
||||||
if update_available(dir) {
|
let remote = remote_revision();
|
||||||
println!("Updating IW4x...");
|
let local = local_revision(dir);
|
||||||
http::download_file(
|
|
||||||
&format!(
|
if remote <= local && dir.join("iw4x.dll").exists() {
|
||||||
"{}/download/iw4x.dll",
|
return;
|
||||||
github::latest_release_url(GH_IW4X_OWNER, GH_IW4X_REPO)
|
|
||||||
),
|
|
||||||
&dir.join("iw4x.dll"),
|
|
||||||
);
|
|
||||||
fs::write(
|
|
||||||
dir.join(".iw4xrevision"),
|
|
||||||
github::latest(GH_IW4X_OWNER, GH_IW4X_REPO),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("Updating IW4x...");
|
||||||
|
http::download_file(
|
||||||
|
&format!(
|
||||||
|
"{}/download/iw4x.dll",
|
||||||
|
github::latest_release_url(GH_IW4X_OWNER, GH_IW4X_REPO)
|
||||||
|
),
|
||||||
|
&dir.join("iw4x.dll"),
|
||||||
|
);
|
||||||
|
fs::write(dir.join(".iw4xrevision"), format!("r{}", remote)).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -177,8 +177,9 @@ fn update(game: &Game, dir: &Path) {
|
|||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let engine_str = format!("{}/", game.engine);
|
||||||
for file in cdn_info {
|
for file in cdn_info {
|
||||||
if !file.name.starts_with(game.engine) || file.name == "iw4/iw4x.dll" {
|
if !file.name.starts_with(&engine_str) || file.name == "iw4/iw4x.dll" {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,5 +13,8 @@ pub fn stdin() -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn rev_to_int(rev: &str) -> u16 {
|
pub fn rev_to_int(rev: &str) -> u16 {
|
||||||
rev.strip_prefix('r').unwrap().parse::<u16>().unwrap_or(0)
|
rev.strip_prefix('r')
|
||||||
|
.unwrap_or("0")
|
||||||
|
.parse::<u16>()
|
||||||
|
.unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,10 @@ pub fn self_update_available() -> bool {
|
|||||||
pub fn run(_update_only: bool) {
|
pub fn run(_update_only: bool) {
|
||||||
if self_update_available() {
|
if self_update_available() {
|
||||||
println!("A new version of the AlterWare launcher is available.");
|
println!("A new version of the AlterWare launcher is available.");
|
||||||
println!("Download it at {}", github::latest_release_url(GH_OWNER, GH_REPO));
|
println!(
|
||||||
|
"Download it at {}",
|
||||||
|
github::latest_release_url(GH_OWNER, GH_REPO)
|
||||||
|
);
|
||||||
println!("Launching in 10 seconds..");
|
println!("Launching in 10 seconds..");
|
||||||
thread::sleep(time::Duration::from_secs(10));
|
thread::sleep(time::Duration::from_secs(10));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user