Compare commits
43 Commits
Author | SHA1 | Date | |
---|---|---|---|
546d8c4cdf | |||
12ccc9554f | |||
c117eaeb31 | |||
50c7b9fbd7 | |||
f09271c29c | |||
b71c15cb8e | |||
a3000bd2fa | |||
cc00cad4f2 | |||
6a16299cee | |||
565a69566c | |||
1727446cfc | |||
4282eb7b75 | |||
a2922540c5 | |||
601abd008f | |||
322fd2f98a | |||
e061bca7a3 | |||
87e86cc954 | |||
d5d847df75 | |||
d620bc9838 | |||
76a7d8b2c6 | |||
6c7fbd1ff1 | |||
18651a68ca | |||
79559fe46a | |||
8fd66d16af | |||
4d3c6b9dab | |||
7ca7615222 | |||
2195f42abc | |||
f7635d4089 | |||
9598ec3dfe | |||
37266207e7 | |||
e041df80c5 | |||
b157bcb2c2 | |||
beae0adce5 | |||
f9ec044a15 | |||
0be3adf8d1 | |||
59f347462d | |||
78e4e18176 | |||
e0f4a5102e | |||
c80765d091 | |||
3b77755848 | |||
4c1114f3e0 | |||
b69611e66b | |||
6ec4deed32 |
5
.github/workflows/release.yml
vendored
5
.github/workflows/release.yml
vendored
@ -11,8 +11,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: taiki-e/create-gh-release-action@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
draft: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
upload-assets:
|
||||
strategy:
|
||||
|
266
Cargo.lock
generated
266
Cargo.lock
generated
@ -2,6 +2,23 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "aes"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cipher",
|
||||
"cpufeatures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.0.3"
|
||||
@ -13,7 +30,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "alterware-launcher"
|
||||
version = "0.3.0"
|
||||
version = "0.4.7"
|
||||
dependencies = [
|
||||
"http_req",
|
||||
"mslnk",
|
||||
@ -26,6 +43,7 @@ dependencies = [
|
||||
"steamlocate",
|
||||
"windows-sys",
|
||||
"winres",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -34,6 +52,12 @@ version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||
|
||||
[[package]]
|
||||
name = "base64ct"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
@ -67,11 +91,35 @@ version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
|
||||
[[package]]
|
||||
name = "bzip2"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8"
|
||||
dependencies = [
|
||||
"bzip2-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bzip2-sys"
|
||||
version = "0.1.11+1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
@ -79,6 +127,22 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cipher"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
|
||||
dependencies = [
|
||||
"crypto-common",
|
||||
"inout",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.9"
|
||||
@ -88,6 +152,24 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
@ -98,6 +180,12 @@ dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946"
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
@ -106,6 +194,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -165,6 +254,16 @@ version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
@ -186,6 +285,15 @@ dependencies = [
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
|
||||
dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http_req"
|
||||
version = "0.9.2"
|
||||
@ -198,6 +306,15 @@ dependencies = [
|
||||
"webpki-roots",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inout"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.12"
|
||||
@ -213,6 +330,15 @@ version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.63"
|
||||
@ -271,6 +397,15 @@ version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
|
||||
dependencies = [
|
||||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mslnk"
|
||||
version = "0.1.8"
|
||||
@ -300,12 +435,35 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[package]]
|
||||
name = "password-hash"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"rand_core",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
|
||||
|
||||
[[package]]
|
||||
name = "pbkdf2"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"hmac",
|
||||
"password-hash",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.7.2"
|
||||
@ -350,6 +508,12 @@ dependencies = [
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.17"
|
||||
@ -521,9 +685,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "self-replace"
|
||||
version = "1.3.5"
|
||||
version = "1.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0e7c919783db74b5995f13506069227e4721d388bea4a8ac3055acac864ac16"
|
||||
checksum = "c56335359191626938ef6fdeb478f9f6a7c6020254d7f4641c7d810369fa0ec1"
|
||||
dependencies = [
|
||||
"fastrand 1.9.0",
|
||||
"tempfile",
|
||||
@ -538,18 +702,18 @@ checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.183"
|
||||
version = "1.0.188"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
|
||||
checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.183"
|
||||
version = "1.0.188"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816"
|
||||
checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -558,15 +722,26 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.104"
|
||||
version = "1.0.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c"
|
||||
checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1_smol"
|
||||
version = "1.0.0"
|
||||
@ -613,6 +788,12 @@ dependencies = [
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.28"
|
||||
@ -657,6 +838,23 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"serde",
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.11"
|
||||
@ -900,3 +1098,53 @@ checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c"
|
||||
dependencies = [
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"byteorder",
|
||||
"bzip2",
|
||||
"constant_time_eq",
|
||||
"crc32fast",
|
||||
"crossbeam-utils",
|
||||
"flate2",
|
||||
"hmac",
|
||||
"pbkdf2",
|
||||
"sha1",
|
||||
"time",
|
||||
"zstd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd"
|
||||
version = "0.11.2+zstd.1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
|
||||
dependencies = [
|
||||
"zstd-safe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd-safe"
|
||||
version = "5.0.2+zstd.1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"zstd-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd-sys"
|
||||
version = "2.0.8+zstd.1.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
13
Cargo.toml
13
Cargo.toml
@ -1,11 +1,15 @@
|
||||
[package]
|
||||
name = "alterware-launcher"
|
||||
version = "0.3.0"
|
||||
version = "0.4.7"
|
||||
edition = "2021"
|
||||
build = "res/build.rs"
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
|
||||
# Symbols are a nice thing
|
||||
debug = true
|
||||
|
||||
panic = "abort"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
@ -15,10 +19,11 @@ http_req = { version = "0.9.2", default-features = false, features = [
|
||||
"rust-tls",
|
||||
] }
|
||||
sha1_smol = "1.0.0"
|
||||
serde = { version = "1.0.183", features = ["derive"] }
|
||||
serde_json = "1.0.104"
|
||||
serde = { version = "1.0.188", features = ["derive"] }
|
||||
serde_json = "1.0.105"
|
||||
rand = "0.8.5"
|
||||
semver = "1.0.18"
|
||||
zip = "0.6.6"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
steamlocate = "1.2.1"
|
||||
@ -27,7 +32,7 @@ mslnk = "0.1.8"
|
||||
windows-sys = { version = "0.48", features = [
|
||||
"Win32_Security",
|
||||
] }
|
||||
self-replace = "1.3.5"
|
||||
self-replace = "1.3.6"
|
||||
|
||||
[build-dependencies]
|
||||
winres = "0.1.12"
|
||||
|
@ -8,3 +8,7 @@
|
||||
|
||||
- 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 201 in this case.
|
23
src/github.rs
Normal file
23
src/github.rs
Normal file
@ -0,0 +1,23 @@
|
||||
use semver::Version;
|
||||
|
||||
pub fn latest(owner: &str, repo: &str) -> String {
|
||||
let github_body = crate::http::get_body_string(
|
||||
format!(
|
||||
"https://api.github.com/repos/{}/{}/releases/latest",
|
||||
owner, repo
|
||||
)
|
||||
.as_str(),
|
||||
);
|
||||
let github_json: serde_json::Value = serde_json::from_str(&github_body).unwrap();
|
||||
github_json["tag_name"]
|
||||
.to_string()
|
||||
.replace(['v', '"'].as_ref(), "")
|
||||
}
|
||||
|
||||
pub fn latest_version(owner: &str, repo: &str) -> Version {
|
||||
Version::parse(&latest(owner, repo)).unwrap()
|
||||
}
|
||||
|
||||
pub fn latest_release_url(owner: &str, repo: &str) -> String {
|
||||
format!("https://github.com/{}/{}/releases/latest", owner, repo)
|
||||
}
|
5
src/global.rs
Normal file
5
src/global.rs
Normal file
@ -0,0 +1,5 @@
|
||||
pub const MASTER: &str = "https://master.alterware.dev";
|
||||
pub const GH_OWNER: &str = "mxve";
|
||||
pub const GH_REPO: &str = "alterware-launcher";
|
||||
pub const GH_IW4X_OWNER: &str = "iw4x";
|
||||
pub const GH_IW4X_REPO: &str = "iw4x-client";
|
22
src/io.rs
Normal file
22
src/io.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use std::{fs, path::Path};
|
||||
|
||||
pub fn unzip(zip_path: &Path, out_path: &Path) {
|
||||
let mut archive = zip::ZipArchive::new(fs::File::open(zip_path).unwrap()).unwrap();
|
||||
for i in 0..archive.len() {
|
||||
let mut file = archive.by_index(i).unwrap();
|
||||
let outpath = out_path.join(file.name());
|
||||
|
||||
if (*file.name()).ends_with('/') {
|
||||
fs::create_dir_all(outpath).unwrap();
|
||||
} else {
|
||||
println!("Unpacking {}", file.name());
|
||||
if let Some(p) = outpath.parent() {
|
||||
if !p.exists() {
|
||||
fs::create_dir_all(p).unwrap();
|
||||
}
|
||||
}
|
||||
let mut outfile = fs::File::create(&outpath).unwrap();
|
||||
std::io::copy(&mut file, &mut outfile).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
43
src/iw4x.rs
Normal file
43
src/iw4x.rs
Normal file
@ -0,0 +1,43 @@
|
||||
use crate::github;
|
||||
use crate::http;
|
||||
use crate::misc;
|
||||
use crate::global::*;
|
||||
|
||||
use std::{fs, path::Path};
|
||||
|
||||
pub fn local_revision(dir: &Path) -> u16 {
|
||||
if let Ok(revision) = fs::read_to_string(dir.join(".iw4xrevision")) {
|
||||
misc::rev_to_int(&revision)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remote_revision() -> u16 {
|
||||
misc::rev_to_int(&github::latest(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) {
|
||||
if update_available(dir) {
|
||||
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"),
|
||||
github::latest(GH_IW4X_OWNER, GH_IW4X_REPO),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
343
src/main.rs
343
src/main.rs
@ -1,129 +1,30 @@
|
||||
mod github;
|
||||
mod global;
|
||||
mod http;
|
||||
mod iw4x;
|
||||
mod misc;
|
||||
mod self_update;
|
||||
mod structs;
|
||||
|
||||
use global::*;
|
||||
use structs::*;
|
||||
|
||||
#[cfg(windows)]
|
||||
use mslnk::ShellLink;
|
||||
use semver::Version;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use std::{fs, path::PathBuf};
|
||||
#[cfg(not(windows))]
|
||||
use std::{thread, time};
|
||||
use std::{fs, path::Path, path::PathBuf};
|
||||
#[cfg(windows)]
|
||||
use steamlocate::SteamDir;
|
||||
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
struct CdnFile {
|
||||
name: String,
|
||||
size: u32,
|
||||
hash: String,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
struct Game<'a> {
|
||||
engine: &'a str,
|
||||
client: &'a str,
|
||||
references: Vec<&'a str>,
|
||||
app_id: u32,
|
||||
}
|
||||
|
||||
const MASTER: &str = "https://master.alterware.dev";
|
||||
const REPO: &str = "mxve/alterware-launcher";
|
||||
|
||||
fn get_cache_buster() -> u64 {
|
||||
match SystemTime::now().duration_since(UNIX_EPOCH) {
|
||||
Ok(n) => n.as_secs(),
|
||||
Err(_) => 1,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_file_sha1(path: &PathBuf) -> String {
|
||||
let mut sha1 = sha1_smol::Sha1::new();
|
||||
sha1.update(&fs::read(path).unwrap());
|
||||
sha1.digest().to_string()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn get_input() -> String {
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
input.trim().to_string()
|
||||
}
|
||||
|
||||
fn self_update_available() -> bool {
|
||||
let current_version: Version = Version::parse(env!("CARGO_PKG_VERSION")).unwrap();
|
||||
let github_body = http::get_body_string(
|
||||
format!("https://api.github.com/repos/{}/releases/latest", REPO).as_str(),
|
||||
);
|
||||
let github_json: serde_json::Value = serde_json::from_str(&github_body).unwrap();
|
||||
let latest_version = github_json["tag_name"]
|
||||
.to_string()
|
||||
.replace(['v', '"'].as_ref(), "");
|
||||
let latest_version = Version::parse(&latest_version).unwrap();
|
||||
|
||||
current_version < latest_version
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn self_update() {
|
||||
if self_update_available() {
|
||||
println!("A new version of the AlterWare launcher is available.");
|
||||
println!("Download it at https://github.com/{}/releases/latest", REPO);
|
||||
println!("Launching in 10 seconds..");
|
||||
thread::sleep(time::Duration::from_secs(10));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn self_update() {
|
||||
let working_dir = std::env::current_dir().unwrap();
|
||||
let files = fs::read_dir(&working_dir).unwrap();
|
||||
|
||||
for file in files {
|
||||
let file = file.unwrap();
|
||||
let file_name = file.file_name().into_string().unwrap();
|
||||
|
||||
if file_name.contains("alterware-launcher")
|
||||
&& (file_name.contains(".__relocated__.exe")
|
||||
|| file_name.contains(".__selfdelete__.exe"))
|
||||
{
|
||||
fs::remove_file(file.path()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
if self_update_available() {
|
||||
println!("Performing launcher self-update.");
|
||||
println!("If you run into any issues, please download the latest version at https://github.com/{}/releases/latest", REPO);
|
||||
|
||||
let update_binary = PathBuf::from("alterware-launcher-update.exe");
|
||||
let file_path = working_dir.join(&update_binary);
|
||||
|
||||
if update_binary.exists() {
|
||||
fs::remove_file(&update_binary).unwrap();
|
||||
}
|
||||
|
||||
http::download_file(
|
||||
&format!(
|
||||
"https://github.com/{}/releases/latest/download/alterware-launcher.exe",
|
||||
REPO
|
||||
),
|
||||
&file_path,
|
||||
);
|
||||
|
||||
if !file_path.exists() {
|
||||
println!("Failed to download launcher update.");
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn get_installed_games(games: &Vec<Game>) -> Vec<(u32, PathBuf)> {
|
||||
let mut installed_games = Vec::new();
|
||||
let mut steamdir = SteamDir::locate().unwrap();
|
||||
let mut steamdir = match SteamDir::locate() {
|
||||
Some(steamdir) => steamdir,
|
||||
None => {
|
||||
println!("Steam not found.");
|
||||
return installed_games;
|
||||
}
|
||||
};
|
||||
|
||||
for game in games {
|
||||
if let Some(app) = steamdir.app(&game.app_id) {
|
||||
@ -134,75 +35,156 @@ fn get_installed_games(games: &Vec<Game>) -> Vec<(u32, PathBuf)> {
|
||||
installed_games
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn setup_client_links(game: &Game, game_dir: &Path) {
|
||||
if game.client.len() > 1 {
|
||||
println!("Multiple clients installed, use the shortcuts (launch-<client>.lnk in the game directory or desktop shortcuts) to launch a specific client.");
|
||||
}
|
||||
|
||||
let target = game_dir.join("alterware-launcher.exe");
|
||||
|
||||
for c in game.client.iter() {
|
||||
let lnk = game_dir.join(format!("launch-{}.lnk", c));
|
||||
|
||||
let mut sl = ShellLink::new(target.clone()).unwrap();
|
||||
sl.set_arguments(Some(c.to_string()));
|
||||
sl.set_icon_location(Some(
|
||||
game_dir
|
||||
.join(format!("{}.exe", c))
|
||||
.to_string_lossy()
|
||||
.into_owned(),
|
||||
));
|
||||
sl.create_lnk(&lnk).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn setup_desktop_links(path: &Path, game: &Game) {
|
||||
println!("Create Desktop shortcut? (Y/n)");
|
||||
let input = misc::stdin().to_ascii_lowercase();
|
||||
|
||||
if input == "y" || input.is_empty() {
|
||||
let desktop = PathBuf::from(&format!(
|
||||
"{}\\Desktop",
|
||||
std::env::var("USERPROFILE").unwrap()
|
||||
));
|
||||
|
||||
let target = path.join("alterware-launcher.exe");
|
||||
|
||||
for c in game.client.iter() {
|
||||
let lnk = desktop.join(format!("{}.lnk", c));
|
||||
|
||||
let mut sl = ShellLink::new(target.clone()).unwrap();
|
||||
sl.set_arguments(Some(c.to_string()));
|
||||
sl.set_icon_location(Some(
|
||||
path.join(format!("{}.exe", c))
|
||||
.to_string_lossy()
|
||||
.into_owned(),
|
||||
));
|
||||
sl.create_lnk(lnk).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn auto_install(path: &Path, game: &Game) {
|
||||
setup_client_links(game, path);
|
||||
setup_desktop_links(path, game);
|
||||
update(game, path);
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn windows_launcher_install(games: &Vec<Game>) {
|
||||
println!("No game specified/found. Checking for installed Steam games..");
|
||||
let installed_games = get_installed_games(games);
|
||||
|
||||
if !installed_games.is_empty() {
|
||||
// if current directory is in the steamapps/common folder of a game, use that game
|
||||
let current_dir = std::env::current_dir().unwrap();
|
||||
for (id, path) in installed_games.iter() {
|
||||
if current_dir.starts_with(path) {
|
||||
println!("Found game in current directory.");
|
||||
println!("Installing AlterWare client for {}.", id);
|
||||
let game = games.iter().find(|&g| g.app_id == *id).unwrap();
|
||||
auto_install(path, game);
|
||||
println!("Installation complete. Please run the launcher again or use a shortcut to launch the game.");
|
||||
std::io::stdin().read_line(&mut String::new()).unwrap();
|
||||
std::process::exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
println!("Installed games:");
|
||||
|
||||
for (id, path) in installed_games.iter() {
|
||||
println!("{}: {}", id, path.display());
|
||||
}
|
||||
|
||||
println!("Enter the ID of the game you want to install the AlterWare client for:");
|
||||
let input: u32 = get_input().parse().unwrap();
|
||||
println!("Enter the ID of the game you want to install the AlterWare client for, enter 0 for manual selection:");
|
||||
let input: u32 = misc::stdin().parse().unwrap();
|
||||
|
||||
if input == 0 {
|
||||
return manual_install(games);
|
||||
}
|
||||
|
||||
for (id, path) in installed_games.iter() {
|
||||
if *id == input {
|
||||
let game = games.iter().find(|&g| g.app_id == input).unwrap();
|
||||
|
||||
let launcher_path = std::env::current_exe().unwrap();
|
||||
fs::copy(launcher_path, path.join("alterware-launcher.exe")).unwrap();
|
||||
println!("Launcher copied to {}", path.display());
|
||||
let target_path = path.join("alterware-launcher.exe");
|
||||
|
||||
println!("Create Desktop shortcut? (Y/n)");
|
||||
let input = get_input().to_ascii_lowercase();
|
||||
|
||||
if input == "y" || input.is_empty() {
|
||||
let desktop = PathBuf::from(&format!(
|
||||
"{}\\Desktop",
|
||||
std::env::var("USERPROFILE").unwrap()
|
||||
));
|
||||
|
||||
let target = path.join("alterware-launcher.exe");
|
||||
let lnk = desktop.join(format!("{}.lnk", game.client));
|
||||
|
||||
let mut sl = ShellLink::new(target).unwrap();
|
||||
sl.set_icon_location(Some(
|
||||
path.join(format!("{}.exe", game.client))
|
||||
.to_string_lossy()
|
||||
.into_owned(),
|
||||
));
|
||||
sl.create_lnk(lnk).unwrap();
|
||||
if launcher_path != target_path {
|
||||
fs::copy(launcher_path, target_path).unwrap();
|
||||
println!("Launcher copied to {}", path.display());
|
||||
}
|
||||
|
||||
auto_install(path, game);
|
||||
println!("Installation complete. Please run the launcher again or use a shortcut to launch the game.");
|
||||
std::io::stdin().read_line(&mut String::new()).unwrap();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::process::exit(0);
|
||||
} else {
|
||||
manual_install(games);
|
||||
}
|
||||
}
|
||||
|
||||
println!("No installed Steam games found. Please install a supported game first or place the launcher in the game folder.");
|
||||
fn prompt_client_selection(games: &[Game]) -> String {
|
||||
println!(
|
||||
"Couldn't detect any games, please select a client to install in the current directory:"
|
||||
);
|
||||
for (i, g) in games.iter().enumerate() {
|
||||
for c in g.client.iter() {
|
||||
println!("{}: {}", i, c);
|
||||
}
|
||||
}
|
||||
let input: usize = misc::stdin().parse().unwrap();
|
||||
String::from(games[input].client[0])
|
||||
}
|
||||
|
||||
fn manual_install(games: &[Game]) {
|
||||
let selection = prompt_client_selection(games);
|
||||
let game = games.iter().find(|&g| g.client[0] == selection).unwrap();
|
||||
update(game, &std::env::current_dir().unwrap());
|
||||
println!("Installation complete. Please run the launcher again or use a shortcut to launch the game.");
|
||||
std::io::stdin().read_line(&mut String::new()).unwrap();
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
fn update(game: &Game) {
|
||||
fn update(game: &Game, dir: &Path) {
|
||||
let cdn_info: Vec<CdnFile> = serde_json::from_str(&http::get_body_string(
|
||||
format!("{}/files.json?{}", MASTER, get_cache_buster()).as_str(),
|
||||
format!("{}/files.json", MASTER).as_str(),
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
for file in cdn_info {
|
||||
if !file.name.starts_with(game.engine) {
|
||||
if !file.name.starts_with(game.engine) || file.name == "iw4/iw4x.dll" {
|
||||
continue;
|
||||
}
|
||||
|
||||
let file_path = PathBuf::from(&file.name.replace(&format!("{}/", game.engine), ""));
|
||||
let file_path = dir.join(&file.name.replace(&format!("{}/", game.engine), ""));
|
||||
if file_path.exists() {
|
||||
let sha1_local = get_file_sha1(&file_path).to_lowercase();
|
||||
let sha1_local = misc::get_file_sha1(&file_path).to_lowercase();
|
||||
let sha1_remote = file.hash.to_lowercase();
|
||||
if sha1_local != sha1_remote {
|
||||
println!(
|
||||
@ -211,10 +193,7 @@ fn update(game: &Game) {
|
||||
sha1_local,
|
||||
sha1_remote
|
||||
);
|
||||
http::download_file(
|
||||
&format!("{}/{}?{}", MASTER, file.name, get_cache_buster()),
|
||||
&file_path,
|
||||
);
|
||||
http::download_file(&format!("{}/{}", MASTER, file.name), &file_path);
|
||||
}
|
||||
} else {
|
||||
println!("Downloading {}...", file_path.display());
|
||||
@ -223,12 +202,13 @@ fn update(game: &Game) {
|
||||
fs::create_dir_all(parent).unwrap();
|
||||
}
|
||||
}
|
||||
http::download_file(
|
||||
&format!("{}/{}?{}", MASTER, file.name, get_cache_buster()),
|
||||
&file_path,
|
||||
);
|
||||
http::download_file(&format!("{}/{}", MASTER, file.name), &file_path);
|
||||
}
|
||||
}
|
||||
|
||||
if game.engine == "iw4" {
|
||||
iw4x::update(dir);
|
||||
}
|
||||
}
|
||||
|
||||
fn launch(file_path: &PathBuf) {
|
||||
@ -241,14 +221,8 @@ fn launch(file_path: &PathBuf) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
self_update();
|
||||
|
||||
let mut args: Vec<String> = std::env::args().collect();
|
||||
|
||||
let games_json =
|
||||
http::get_body_string(format!("{}/games.json?{}", MASTER, get_cache_buster()).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;
|
||||
@ -257,6 +231,17 @@ fn main() {
|
||||
.map(|e| args.remove(e));
|
||||
}
|
||||
|
||||
if !args.contains(&String::from("skip-launcher-update")) {
|
||||
self_update::run(update_only);
|
||||
} else {
|
||||
args.iter()
|
||||
.position(|r| r == "skip-launcher-update")
|
||||
.map(|e| args.remove(e));
|
||||
}
|
||||
|
||||
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 game: String = String::new();
|
||||
if args.len() > 1 {
|
||||
game = String::from(&args[1]);
|
||||
@ -264,7 +249,25 @@ fn main() {
|
||||
'main: for g in games.iter() {
|
||||
for r in g.references.iter() {
|
||||
if std::path::Path::new(r).exists() {
|
||||
game = String::from(g.client);
|
||||
if g.client.len() > 1 {
|
||||
if update_only {
|
||||
game = String::from(g.client[0]);
|
||||
break 'main;
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
setup_client_links(g, &std::env::current_dir().unwrap());
|
||||
|
||||
#[cfg(not(windows))]
|
||||
println!("Multiple clients installed, set the client as the first argument to launch a specific client.");
|
||||
println!("Select a client to launch:");
|
||||
for (i, c) in g.client.iter().enumerate() {
|
||||
println!("{}: {}", i, c);
|
||||
}
|
||||
game = String::from(g.client[misc::stdin().parse::<usize>().unwrap()]);
|
||||
break 'main;
|
||||
}
|
||||
game = String::from(g.client[0]);
|
||||
break 'main;
|
||||
}
|
||||
}
|
||||
@ -272,19 +275,23 @@ fn main() {
|
||||
}
|
||||
|
||||
for g in games.iter() {
|
||||
if g.client == game {
|
||||
update(g);
|
||||
if update_only {
|
||||
for c in g.client.iter() {
|
||||
if c == &game {
|
||||
update(g, &std::env::current_dir().unwrap());
|
||||
if !update_only {
|
||||
launch(&PathBuf::from(format!("{}.exe", c)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
launch(&PathBuf::from(format!("{}.exe", g.client)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
windows_launcher_install(&games);
|
||||
|
||||
#[cfg(not(windows))]
|
||||
manual_install(&games);
|
||||
|
||||
println!("Game not found!");
|
||||
println!("Place the launcher in the game folder, if that doesn't work specify the client on the command line (ex. alterware-launcher.exe iw4-sp)");
|
||||
println!("Press enter to exit...");
|
||||
|
17
src/misc.rs
Normal file
17
src/misc.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
pub fn get_file_sha1(path: &PathBuf) -> String {
|
||||
let mut sha1 = sha1_smol::Sha1::new();
|
||||
sha1.update(&fs::read(path).unwrap());
|
||||
sha1.digest().to_string()
|
||||
}
|
||||
|
||||
pub fn stdin() -> String {
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).unwrap();
|
||||
input.trim().to_string()
|
||||
}
|
||||
|
||||
pub fn rev_to_int(rev: &str) -> u16 {
|
||||
rev.strip_prefix('r').unwrap().parse::<u16>().unwrap_or(0)
|
||||
}
|
81
src/self_update.rs
Normal file
81
src/self_update.rs
Normal file
@ -0,0 +1,81 @@
|
||||
use crate::github;
|
||||
use crate::global::*;
|
||||
|
||||
use semver::Version;
|
||||
#[cfg(not(windows))]
|
||||
use std::{thread, time};
|
||||
|
||||
pub fn self_update_available() -> bool {
|
||||
let current_version: Version = Version::parse(env!("CARGO_PKG_VERSION")).unwrap();
|
||||
let latest_version = github::latest_version(GH_OWNER, GH_REPO);
|
||||
|
||||
current_version < latest_version
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn run(_update_only: bool) {
|
||||
if self_update_available() {
|
||||
println!("A new version of the AlterWare launcher is available.");
|
||||
println!("Download it at {}", github::latest_release_url(GH_OWNER, GH_REPO));
|
||||
println!("Launching in 10 seconds..");
|
||||
thread::sleep(time::Duration::from_secs(10));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn run(update_only: bool) {
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
use crate::http;
|
||||
|
||||
let working_dir = std::env::current_dir().unwrap();
|
||||
let files = fs::read_dir(&working_dir).unwrap();
|
||||
|
||||
for file in files {
|
||||
let file = file.unwrap();
|
||||
let file_name = file.file_name().into_string().unwrap();
|
||||
|
||||
if file_name.contains("alterware-launcher")
|
||||
&& (file_name.contains(".__relocated__.exe")
|
||||
|| file_name.contains(".__selfdelete__.exe"))
|
||||
{
|
||||
fs::remove_file(file.path()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
if self_update_available() {
|
||||
println!("Performing launcher self-update.");
|
||||
println!(
|
||||
"If you run into any issues, please download the latest version at {}",
|
||||
github::latest_release_url(GH_OWNER, GH_REPO)
|
||||
);
|
||||
|
||||
let update_binary = PathBuf::from("alterware-launcher-update.exe");
|
||||
let file_path = working_dir.join(&update_binary);
|
||||
|
||||
if update_binary.exists() {
|
||||
fs::remove_file(&update_binary).unwrap();
|
||||
}
|
||||
|
||||
http::download_file(
|
||||
&format!(
|
||||
"{}/download/alterware-launcher.exe",
|
||||
github::latest_release_url(GH_OWNER, GH_REPO)
|
||||
),
|
||||
&file_path,
|
||||
);
|
||||
|
||||
if !file_path.exists() {
|
||||
println!("Failed to download launcher update.");
|
||||
return;
|
||||
}
|
||||
|
||||
self_replace::self_replace("alterware-launcher-update.exe").unwrap();
|
||||
fs::remove_file(&file_path).unwrap();
|
||||
println!("Launcher updated. Please run it again.");
|
||||
if !update_only {
|
||||
std::io::stdin().read_line(&mut String::new()).unwrap();
|
||||
}
|
||||
std::process::exit(201);
|
||||
}
|
||||
}
|
14
src/structs.rs
Normal file
14
src/structs.rs
Normal file
@ -0,0 +1,14 @@
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
pub struct CdnFile {
|
||||
pub name: String,
|
||||
pub size: u32,
|
||||
pub hash: String,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
pub struct Game<'a> {
|
||||
pub engine: &'a str,
|
||||
pub client: Vec<&'a str>,
|
||||
pub references: Vec<&'a str>,
|
||||
pub app_id: u32,
|
||||
}
|
Reference in New Issue
Block a user