Compare commits

...

179 Commits
main ... v0.6.3

Author SHA1 Message Date
Diavolo
c3e3d9a7d5 v0.6.3 2023-11-24 14:54:26 +01:00
Diavolo
47a6eaf4cf fix: attempt fix on Linux by "vendoring" OpenSSL 2023-11-24 14:44:40 +01:00
mxve
1451dab658 Merge branch 'main' of github.com:mxve/alterware-launcher 2023-11-13 15:26:32 +01:00
mxve
618033e18f iw4 default arg -stdout; add cfg.engine 2023-11-13 15:26:28 +01:00
mxve
2b891276a4 remove rustls dep
reduces binary size by using os ssl/openssl for http_req and reqwest until #43 gets done
2023-11-10 00:04:00 +01:00
mxve
5ed9fd4710 set useragent header 2023-11-07 17:14:40 +01:00
mxve
4763759997 Merge pull request #42 from mxve/selfrestart
Selfrestart
2023-11-07 00:20:32 +01:00
mxve
6ebb421a7b fix linux 2023-11-06 22:33:58 +01:00
mxve
6ef80be01f v0.6.2 2023-11-06 22:27:53 +01:00
mxve
1a3c090612 cleanup 2023-11-06 22:27:09 +01:00
mxve
fe7c8d2834 self restart 2023-11-06 03:20:46 +01:00
mxve
b3168b0a58 don't panic if cleaning up left over files fails 2023-11-06 02:08:29 +01:00
mxve
b1cffb44ad v0.6.1 2023-11-06 01:56:49 +01:00
mxve
5414213a19 fix existing file hashes always being calculated 2023-11-06 01:56:26 +01:00
mxve
6ce845e761 v0.6.0 2023-11-05 17:20:59 +01:00
mxve
ecff4846ed improve setup_env on Windows
(real)
935a72e05be1a213a12238f522c8b35f872ecf63
2023-11-04 11:48:04 +01:00
mxve
1578924579 lint 2023-11-04 11:35:19 +01:00
mxve
33fc7d0f6a import std::env 2023-11-04 07:48:40 +01:00
Diavolo
461eb05ac5 maint(win): improve setup_env on Windows 2023-11-04 07:27:58 +01:00
mxve
cb210b16e1 Merge pull request #40 from mxve/async
Async
2023-11-02 16:05:10 +01:00
mxve
41ff4acd65 update iw4x first
so we don't have to pass the progressbar to iw4x just to not have it break by a little println
2023-11-02 11:44:08 +01:00
mxve
24672aa500 only show filename in pb 2023-11-02 11:31:50 +01:00
mxve
05def16ba6 use String::default() for empty strings
as suggested by diamante quality control ™️
2023-11-02 11:27:43 +01:00
mxve
c3cda3b845 remove linux i686 2023-11-02 11:05:28 +01:00
mxve
3858e743f3 consume 2023-11-02 10:43:36 +01:00
mxve
d28fed938c Merge branch 'main' of github.com:mxve/alterware-launcher 2023-11-02 10:40:45 +01:00
mxve
ff22c49ced stream files to disk
- Greatly reduced memory usage while downloading
- Added progressbar, download rate
- Added async runtime
- Tweaks to allow usage of async download function
2023-11-02 10:39:58 +01:00
mxve
82a1e4ba53 Merge pull request #38 from mxve/dependabot/cargo/serde-1.0.190
Bump serde from 1.0.189 to 1.0.190
2023-10-30 22:00:19 +01:00
mxve
de7a661465 Merge pull request #39 from mxve/dependabot/cargo/http_req-0.10.1
Bump http_req from 0.10.0 to 0.10.1
2023-10-30 22:00:07 +01:00
dependabot[bot]
7e8e0fbc97 Bump http_req from 0.10.0 to 0.10.1
Bumps [http_req](https://github.com/jayjamesjay/http_req) from 0.10.0 to 0.10.1.
- [Release notes](https://github.com/jayjamesjay/http_req/releases)
- [Commits](https://github.com/jayjamesjay/http_req/compare/v0.10.0...v0.10.1)

---
updated-dependencies:
- dependency-name: http_req
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-30 15:31:10 +00:00
dependabot[bot]
b09b92ee7f Bump serde from 1.0.189 to 1.0.190
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.189 to 1.0.190.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.189...v1.0.190)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-30 15:30:54 +00:00
mxve
917640c4e6 dc 2023-10-28 20:14:39 +02:00
mxve
949ff87bca typo 2023-10-28 19:49:21 +02:00
mxve
8685961eed clippy 2023-10-28 19:38:53 +02:00
mxve
7965314c6b print download size 2023-10-28 19:35:28 +02:00
mxve
cb70b8c415 add av info on permission denied 2023-10-26 06:25:12 +02:00
mxve
79a1533eaa Merge pull request #36 from mxve/dependabot/cargo/serde-1.0.189
Bump serde from 1.0.188 to 1.0.189
2023-10-16 17:46:15 +02:00
mxve
665e580c79 Merge pull request #37 from mxve/dependabot/cargo/semver-1.0.20
Bump semver from 1.0.19 to 1.0.20
2023-10-16 17:46:08 +02:00
dependabot[bot]
d5de7244e3 Bump semver from 1.0.19 to 1.0.20
Bumps [semver](https://github.com/dtolnay/semver) from 1.0.19 to 1.0.20.
- [Release notes](https://github.com/dtolnay/semver/releases)
- [Commits](https://github.com/dtolnay/semver/compare/1.0.19...1.0.20)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-16 15:07:26 +00:00
dependabot[bot]
c2e90e17db Bump serde from 1.0.188 to 1.0.189
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.188 to 1.0.189.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.188...v1.0.189)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-16 15:07:20 +00:00
mxve
c81518aec7 update actions 2023-10-16 16:11:56 +02:00
mxve
f48cd874f0 Merge pull request #35 from mxve/dependabot/cargo/http_req-0.10.0
Bump http_req from 0.9.3 to 0.10.0
2023-10-09 18:29:43 +02:00
dependabot[bot]
228abe5317 Bump http_req from 0.9.3 to 0.10.0
Bumps [http_req](https://github.com/jayjamesjay/http_req) from 0.9.3 to 0.10.0.
- [Release notes](https://github.com/jayjamesjay/http_req/releases)
- [Commits](https://github.com/jayjamesjay/http_req/compare/v0.9.3...v0.10.0)

---
updated-dependencies:
- dependency-name: http_req
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-09 15:58:32 +00:00
mxve
9efd34600a add client-args.md; document config file 2023-10-07 13:24:26 +02:00
mxve
572c66cc16 v0.5.3 2023-10-06 09:03:34 +02:00
mxve
cf87f7c741 misc 2023-10-06 08:34:42 +02:00
mxve
dc8b01b4c8 add changelog link 2023-10-06 08:30:29 +02:00
mxve
9e8893ce75 handle notfound; give tips to fix permission denied 2023-10-02 15:49:01 +02:00
mxve
6f92e1fb71 Create config path if it doesn't exist; don't panic 2023-10-02 15:48:22 +02:00
mxve
96c3e504f8 improve logging of http errors 2023-10-02 04:39:49 +02:00
mxve
00c14d2a02 handle shortcut creation errors 2023-10-01 00:36:12 +02:00
mxve
0378f19a75 set matrix target 2023-09-25 18:57:51 +02:00
mxve
64f4ae6429 v0.5.2 2023-09-25 18:52:35 +02:00
mxve
b2cc21aed0 Merge branch 'main' of github.com:mxve/alterware-launcher 2023-09-25 18:51:54 +02:00
mxve
dc5957ea41 build i686 target 2023-09-25 18:51:43 +02:00
mxve
54abce4d30 Merge pull request #34 from mxve/dependabot/cargo/semver-1.0.19
Bump semver from 1.0.18 to 1.0.19
2023-09-25 17:51:50 +02:00
mxve
6ae33cdcb3 self-replace 1.3.7 2023-09-25 17:51:21 +02:00
dependabot[bot]
c9d30fa95a Bump semver from 1.0.18 to 1.0.19
Bumps [semver](https://github.com/dtolnay/semver) from 1.0.18 to 1.0.19.
- [Release notes](https://github.com/dtolnay/semver/releases)
- [Commits](https://github.com/dtolnay/semver/compare/1.0.18...1.0.19)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-25 15:28:54 +00:00
mxve
dc81430f6b don't ask if --bonus set 2023-09-23 01:29:04 +02:00
mxve
9c122506ce Merge pull request #31 from mxve/dependabot/cargo/http_req-0.9.3
Bump http_req from 0.9.2 to 0.9.3
2023-09-18 20:12:38 +02:00
mxve
f2ba92c31d Merge pull request #32 from mxve/dependabot/cargo/serde_json-1.0.107
Bump serde_json from 1.0.106 to 1.0.107
2023-09-18 20:12:30 +02:00
dependabot[bot]
c92fb88e83 Bump serde_json from 1.0.106 to 1.0.107
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.106 to 1.0.107.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.106...v1.0.107)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-18 15:05:36 +00:00
dependabot[bot]
1e0e0090f5 Bump http_req from 0.9.2 to 0.9.3
Bumps [http_req](https://github.com/jayjamesjay/http_req) from 0.9.2 to 0.9.3.
- [Release notes](https://github.com/jayjamesjay/http_req/releases)
- [Commits](https://github.com/jayjamesjay/http_req/compare/v0.9.2...v0.9.3)

---
updated-dependencies:
- dependency-name: http_req
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-18 15:05:29 +00:00
mxve
48f6a96a01 pwettify comfig file :3 2023-09-18 16:29:37 +02:00
mxve
f4fe1c6699 v0.5.1 2023-09-18 12:27:01 +02:00
mxve
59f1b09337 set current_dir when launching 2023-09-18 12:26:47 +02:00
mxve
237fa8c16f v0.5.0 2023-09-17 17:49:50 +02:00
mxve
78e155408e print passed args when launching; trim args 2023-09-16 16:41:18 +02:00
Edo
3033dd2315 Merge pull request #30 from diamante0018/main
maint(main): simply return out of the main function
2023-09-15 19:22:11 +02:00
Edo
48851fa8d3 maint(main): simply return out of the main function
instead of calling exit()
2023-09-15 19:19:04 +02:00
mxve
84ea4e48af update readme 2023-09-15 01:48:04 +02:00
mxve
b408f13cce add --help, --version/-v 2023-09-15 01:45:47 +02:00
mxve
959c3a8a61 allow loading client args from config 2023-09-14 10:32:03 +02:00
mxve
73df20ebb6 💩 2023-09-14 10:25:44 +02:00
mxve
08814a8c3e Merge pull request #29 from mxve/dependabot/cargo/serde_json-1.0.106
Bump serde_json from 1.0.105 to 1.0.106
2023-09-14 10:24:26 +02:00
mxve
65094d4701 add --pass to allow passing args to the client 2023-09-14 10:23:48 +02:00
mxve
a20b1acdda remove debug print 2023-09-14 10:09:21 +02:00
mxve
75b1d6254b strip value AND arg 😑 2023-09-14 10:08:26 +02:00
mxve
65f05a5a1c add --path, -p 2023-09-14 09:44:35 +02:00
mxve
fa6bdc9f29 prepend args with --, -, add short args 2023-09-14 09:37:35 +02:00
mxve
7595a46b44 update readme 2023-09-12 21:35:50 +02:00
mxve
c41a843315 store file hashes; added "force" arg
close #28
2023-09-12 21:28:53 +02:00
dependabot[bot]
a90a60ec3a Bump serde_json from 1.0.105 to 1.0.106
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.105 to 1.0.106.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.105...v1.0.106)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-11 15:16:24 +00:00
mxve
209b599120 improve progress prints 2023-09-11 13:05:18 +02:00
mxve
9f00b0c0e7 Show more progress 2023-09-10 20:00:04 +02:00
mxve
aaede9b6cb download bonus content 2023-09-10 18:29:30 +02:00
mxve
8a14008706 use config values 2023-09-10 17:36:01 +02:00
mxve
ad7e78ec47 cfg 2023-09-10 16:58:42 +02:00
mxve
140f4c335f v0.4.8 2023-09-10 12:39:44 +02:00
mxve
3e1a266c3e check first dir when matching files to download 2023-09-10 12:38:21 +02:00
mxve
92663425ef update readme 2023-09-03 19:03:46 +02:00
mxve
ffa379e6dd misc
- reduce github calls
- latest_tag returns full tag
- rev_to_int default to 0 on strip_prefix
- lint
2023-08-30 13:06:49 +02:00
mxve
a41375a791 github::latest -> latest_tag 2023-08-30 12:46:13 +02:00
mxve
ac76e9bb89 steamlocate 2.0.0-alpha.0 2023-08-30 12:45:10 +02:00
mxve
546d8c4cdf v0.4.7 2023-08-29 22:13:05 +02:00
mxve
12ccc9554f update iw4x if dll doesn't exist 2023-08-29 22:12:42 +02:00
mxve
c117eaeb31 whoops/v0.4.6 2023-08-29 22:00:31 +02:00
mxve
50c7b9fbd7 v0.4.6 2023-08-29 21:57:35 +02:00
mxve
f09271c29c obtain iw4x.dll from iw4x/iw4x-client 2023-08-29 21:53:47 +02:00
mxve
b71c15cb8e update io::unzip 2023-08-29 06:59:04 +02:00
mxve
a3000bd2fa Merge branch 'main' of github.com:mxve/alterware-launcher 2023-08-29 06:51:52 +02:00
mxve
cc00cad4f2 add io::unzip 2023-08-29 06:51:44 +02:00
mxve
6a16299cee seperate into multiple source files 2023-08-29 06:51:40 +02:00
mxve
565a69566c Merge pull request #26 from mxve/dependabot/cargo/serde-1.0.188
Bump serde from 1.0.185 to 1.0.188
2023-08-28 22:38:55 +02:00
mxve
1727446cfc Merge pull request #25 from mxve/dependabot/cargo/self-replace-1.3.6
Bump self-replace from 1.3.5 to 1.3.6
2023-08-28 22:38:47 +02:00
dependabot[bot]
4282eb7b75 Bump serde from 1.0.185 to 1.0.188
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.185 to 1.0.188.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.185...v1.0.188)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-28 15:52:58 +00:00
dependabot[bot]
a2922540c5 Bump self-replace from 1.3.5 to 1.3.6
Bumps [self-replace](https://github.com/mitsuhiko/self-replace) from 1.3.5 to 1.3.6.
- [Changelog](https://github.com/mitsuhiko/self-replace/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/self-replace/compare/1.3.5...1.3.6)

---
updated-dependencies:
- dependency-name: self-replace
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-28 15:52:49 +00:00
mxve
601abd008f v0.4.5 2023-08-26 21:17:01 +02:00
mxve
322fd2f98a linting 2023-08-26 20:59:38 +02:00
mxve
e061bca7a3 feat: manual client selection
fix: crash if steam not installed/steamdir is none
2023-08-26 20:53:41 +02:00
mxve
87e86cc954 restart required ex.code 101->201
rust panic returns 101, so this wasn't a good choice
2023-08-22 11:37:34 +02:00
mxve
d5d847df75 Merge pull request #23 from mxve/dependabot/cargo/serde-1.0.185
Bump serde from 1.0.183 to 1.0.185
2023-08-21 17:31:09 +02:00
dependabot[bot]
d620bc9838 Bump serde from 1.0.183 to 1.0.185
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.183 to 1.0.185.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.183...v1.0.185)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-21 15:26:04 +00:00
mxve
76a7d8b2c6 Merge pull request #24 from mxve/dependabot/cargo/serde_json-1.0.105
Bump serde_json from 1.0.104 to 1.0.105
2023-08-21 17:25:29 +02:00
dependabot[bot]
6c7fbd1ff1 Bump serde_json from 1.0.104 to 1.0.105
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.104 to 1.0.105.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.104...v1.0.105)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-21 15:10:09 +00:00
mxve
18651a68ca v0.4.4 2023-08-18 14:38:15 +02:00
mxve
79559fe46a Don't ask what client to launch if update is set 2023-08-18 13:36:06 +02:00
mxve
8fd66d16af v0.4.3 2023-08-18 12:53:28 +02:00
mxve
4d3c6b9dab update after windows setup; match cur dir to steam dirs 2023-08-18 12:51:51 +02:00
mxve
7ca7615222 v0.4.2 2023-08-17 20:26:25 +02:00
mxve
2195f42abc fix: unix.. again 2023-08-17 20:26:08 +02:00
mxve
f7635d4089 return 101 when restart is required after self-update 2023-08-17 18:32:32 +02:00
mxve
9598ec3dfe v0.4.1 2023-08-16 13:01:32 +02:00
mxve
37266207e7 create release as draft 2023-08-16 13:01:25 +02:00
mxve
e041df80c5 don't copy if current & target path are the same 2023-08-16 13:00:15 +02:00
mxve
b157bcb2c2 remove cache busting 2023-08-16 12:57:27 +02:00
mxve
beae0adce5 Merge pull request #21 from mxve/build/symbols
build: add symbols
2023-08-15 19:05:22 +02:00
Edo
f9ec044a15 build: add symbols 2023-08-15 19:03:38 +02:00
mxve
0be3adf8d1 v0.4.0 2023-08-15 13:02:32 +02:00
mxve
59f347462d fix: remove windows target from get_input 2023-08-15 11:13:59 +02:00
mxve
78e4e18176 fix: don't run setup_client_links on unix 2023-08-15 11:10:40 +02:00
mxve
e0f4a5102e Merge branch 'main' of github.com:mxve/alterware-launcher 2023-08-15 09:45:21 +02:00
mxve
c80765d091 feat: support multiple clients per game
- Game.client changed from str to Vec<str>
- Create launch shortcuts for multi-client games
- Add prompt if multiple clients available and none specified
2023-08-15 09:45:18 +02:00
mxve
3b77755848 bruh 2023-08-12 15:35:41 +02:00
mxve
4c1114f3e0 Update readme 2023-08-12 15:30:28 +02:00
mxve
b69611e66b v0.3.1 2023-08-12 15:27:39 +02:00
mxve
6ec4deed32 feat(flag): skip-launcher-update 2023-08-12 15:26:35 +02:00
mxve
744e309190 v0.3.0 2023-08-12 15:09:26 +02:00
mxve
83e1f67d0d fix: don't even look at it 2023-08-12 14:33:25 +02:00
mxve
b83720af0a fix: unix build 2023-08-12 14:31:58 +02:00
mxve
7e36b7496c feat: self-update
closes #17

- launcher updates itself (only on windows target for now)
- added cache buster to games.json request
- rearranged some functions
- file description is now "AlterWare Launcher" as it shows up in the task manager
2023-08-12 14:08:59 +02:00
mxve
98cbc2a9a7 mark get_input as windows target 2023-08-12 06:41:08 +02:00
mxve
85e17260eb Merge branch 'main' of github.com:mxve/alterware-launcher 2023-08-12 06:30:08 +02:00
mxve
14181845fb feat(win): setup for installed steam games
steamlocate requires steamy-vdf which requires a in the future unsupported version of nom (1.2.4). This should get fixed with a future release of steamlocate
https://github.com/WilliamVenner/steamlocate-rs/issues/19
2023-08-12 06:30:02 +02:00
mxve
9323f12442 Merge pull request #18 from mxve/dependabot/cargo/serde-1.0.183
Bump serde from 1.0.179 to 1.0.183
2023-08-08 02:29:59 +02:00
dependabot[bot]
a7bf44f105 Bump serde from 1.0.179 to 1.0.183
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.179 to 1.0.183.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.179...v1.0.183)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 15:23:26 +00:00
mxve
e715cd5abf check for launcher update 2023-08-03 02:49:55 +02:00
mxve
a234232751 Merge pull request #14 from mxve/dependabot/cargo/serde_json-1.0.104
Bump serde_json from 1.0.103 to 1.0.104
2023-07-31 22:44:19 +02:00
dependabot[bot]
e84a8db0aa Bump serde_json from 1.0.103 to 1.0.104
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.103 to 1.0.104.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.103...v1.0.104)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-31 20:10:02 +00:00
mxve
fdf35efa81 Merge pull request #13 from mxve/dependabot/cargo/serde-1.0.179
Bump serde from 1.0.175 to 1.0.179
2023-07-31 22:09:28 +02:00
dependabot[bot]
e94d71b80e Bump serde from 1.0.175 to 1.0.179
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.175 to 1.0.179.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.175...v1.0.179)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-31 15:37:10 +00:00
mxve
d233dfb53c minor cleanup 2023-07-25 03:24:52 +02:00
mxve
d04083c473 Merge pull request #12 from mxve/dependabot/cargo/serde-1.0.175
Bump serde from 1.0.171 to 1.0.175
2023-07-24 18:14:48 +02:00
dependabot[bot]
98d43d2627 Bump serde from 1.0.171 to 1.0.175
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.171 to 1.0.175.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.171...v1.0.175)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-24 15:40:30 +00:00
mxve
4fe5ed1f77 dependabot daily -> weekly 2023-07-19 08:54:07 +02:00
mxve
7398ca6ca7 Merge pull request #11 from mxve/dependabot/cargo/serde_json-1.0.103
Bump serde_json from 1.0.102 to 1.0.103
2023-07-19 08:52:21 +02:00
dependabot[bot]
4e6ef5d0e5 Bump serde_json from 1.0.102 to 1.0.103
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.102 to 1.0.103.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.102...v1.0.103)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-17 15:12:34 +00:00
Edo
33463f1a6e fix: remove return statement 2023-07-13 11:18:45 +02:00
mxve
41311ed5ad Merge pull request #10 from diamante0018/main
feat: use current time as cache busting method
2023-07-13 10:39:16 +02:00
mxve
69686b3a09 Merge pull request #9 from mxve/dependabot/cargo/serde_json-1.0.102
Bump serde_json from 1.0.100 to 1.0.102
2023-07-13 10:39:06 +02:00
dependabot[bot]
8be94a31ac Bump serde_json from 1.0.100 to 1.0.102
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.100 to 1.0.102.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.100...v1.0.102)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-13 08:37:53 +00:00
mxve
99da9832ff Merge pull request #8 from mxve/dependabot/cargo/serde-1.0.171
Bump serde from 1.0.167 to 1.0.171
2023-07-13 10:36:56 +02:00
mxve
b175fc2b5f Merge pull request #7 from mxve/dependabot/cargo/http_req-0.9.2
Bump http_req from 0.9.1 to 0.9.2
2023-07-13 10:36:48 +02:00
Diavolo
02ae0459cb feat: use current time as cache busting method 2023-07-13 10:31:23 +02:00
dependabot[bot]
611049ec1b Bump serde from 1.0.167 to 1.0.171
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.167 to 1.0.171.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.167...v1.0.171)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-10 16:08:19 +00:00
dependabot[bot]
2e4467779d Bump http_req from 0.9.1 to 0.9.2
Bumps [http_req](https://github.com/jayjamesjay/http_req) from 0.9.1 to 0.9.2.
- [Release notes](https://github.com/jayjamesjay/http_req/releases)
- [Commits](https://github.com/jayjamesjay/http_req/compare/v0.9.1...v0.9.2)

---
updated-dependencies:
- dependency-name: http_req
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-10 16:08:13 +00:00
mxve
e2c22a716b Merge pull request #6 from mxve/dependabot/cargo/serde-1.0.167
Bump serde from 1.0.166 to 1.0.167
2023-07-07 22:09:54 +02:00
dependabot[bot]
796c67d708 Bump serde from 1.0.166 to 1.0.167
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.166 to 1.0.167.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.166...v1.0.167)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-07 15:26:08 +00:00
mxve
21b7b1ea4b Merge pull request #5 from mxve/dependabot/cargo/serde_json-1.0.100
Bump serde_json from 1.0.99 to 1.0.100
2023-07-05 18:34:45 +02:00
dependabot[bot]
c4046ae148 Bump serde_json from 1.0.99 to 1.0.100
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.99 to 1.0.100.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.99...v1.0.100)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-05 16:05:39 +00:00
mxve
b1decd0b17 Merge pull request #4 from mxve/dependabot/cargo/serde-1.0.166
Bump serde from 1.0.164 to 1.0.166
2023-07-05 03:57:07 +02:00
dependabot[bot]
966a63df62 Bump serde from 1.0.164 to 1.0.166
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.164 to 1.0.166.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.164...v1.0.166)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-04 15:32:28 +00:00
mxve
abb583aeff Revert "windows self-update"
This reverts commit cee51300b27998da0e2351f6f011980d436286e6.
2023-06-28 15:13:41 +02:00
mxve
06584a3195 Merge pull request #2 from mxve/dependabot/cargo/serde_json-1.0.99
Bump serde_json from 1.0.97 to 1.0.99
2023-06-28 13:09:40 +02:00
dependabot[bot]
7fcfa2aa57 Bump serde_json from 1.0.97 to 1.0.99
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.97 to 1.0.99.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.97...v1.0.99)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-26 16:06:00 +00:00
mxve
2e4436ed9a delete update.bat 2023-06-22 16:48:43 +02:00
mxve
d92319e15f windows self-update 2023-06-22 16:45:00 +02:00
mxve
a5cb68e7fa Merge pull request #1 from mxve/dependabot/cargo/serde_json-1.0.97
Bump serde_json from 1.0.96 to 1.0.97
2023-06-16 18:13:57 +02:00
dependabot[bot]
eb161c2375 Bump serde_json from 1.0.96 to 1.0.97
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.96 to 1.0.97.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.96...v1.0.97)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-16 16:04:00 +00:00
18 changed files with 2540 additions and 227 deletions

View File

@ -3,4 +3,4 @@ updates:
- package-ecosystem: "cargo" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
interval: "weekly"

View File

@ -1,9 +1,3 @@
# Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
#
# While our "example" application has the platform-specific code,
# for simplicity we are compiling and testing everything on the Ubuntu environment only.
# For multi-OS testing see the `cross.yml` workflow.
on: [push, pull_request]
name: lint
@ -14,18 +8,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
- name: Run cargo check
uses: actions-rs/cargo@v1
continue-on-error: true # WARNING: only for this example, remove it!
uses: clechasseur/rs-cargo@v2
continue-on-error: true
with:
command: check
@ -34,18 +26,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
- name: Run cargo test
uses: actions-rs/cargo@v1
continue-on-error: true # WARNING: only for this example, remove it!
uses: clechasseur/rs-cargo@v2
continue-on-error: true
with:
command: test
@ -54,26 +44,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Run cargo fmt
uses: actions-rs/cargo@v1
continue-on-error: true # WARNING: only for this example, remove it!
uses: clechasseur/rs-cargo@v2
continue-on-error: true
with:
command: fmt
args: --all -- --check
- name: Run cargo clippy
uses: actions-rs/cargo@v1
continue-on-error: true # WARNING: only for this example, remove it!
uses: clechasseur/rs-cargo@v2
continue-on-error: true
with:
command: clippy
args: -- -D warnings

View File

@ -9,22 +9,28 @@ jobs:
create-release:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
upload-assets:
strategy:
matrix:
os:
- ubuntu-20.04
- windows-latest
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-20.04
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: i686-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: taiki-e/upload-rust-binary-action@v1
with:
target: ${{ matrix.target }}
bin: alterware-launcher
tar: unix
zip: windows

1437
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,44 @@
[package]
name = "alterware-launcher"
version = "0.2.3"
version = "0.6.3"
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
[dependencies]
http_req = { version = "0.9.0", default-features = false, features = [
"rust-tls",
] }
http_req = "0.10.1"
sha1_smol = "1.0.0"
serde = { version = "1.0.164", features = ["derive"] }
serde_json = "1.0.96"
serde = { version = "1.0.190", features = ["derive"] }
serde_json = "1.0.107"
rand = "0.8.5"
semver = "1.0.20"
colored = "2.0.4"
reqwest = { version = "0.11.22", features = ["stream"] }
futures-util = "0.3.29"
indicatif = "0.17.7"
tokio = {version="1.33.0", features = ["rt-multi-thread", "macros"]}
[target.'cfg(unix)'.dependencies]
openssl = { version = "0.10.58", default-features = false, features = ["vendored"] }
[target.'cfg(windows)'.dependencies]
steamlocate = "2.0.0-alpha.0"
mslnk = "0.1.8"
self-replace = "1.3.7"
[build-dependencies]
winres = "0.1.12"
[package.metadata.winres]
OriginalFilename = "alterware-launcher.exe"
FileDescription = "AlterWare mod updater & launcher"
ProductName = "AlterWare Launcher"
FileDescription = "AlterWare Launcher"
ProductName = "AlterWare Launcher"

View File

@ -1,10 +1,94 @@
# 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)
2. Unpack the archive and place alterware-launcher.exe in the game directory
### [AlterWare.dev](https://alterware.dev)
##### 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
---
- 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
#### Command line arguments
- ```iw4-sp```, ```iw4x```, ```iw5-mod```, ```iw6-mod```, ```s1-mod```
- Skip automatic detection and launch the specified game
- This should always be the first argument if used
- ```--update```, ```-u```
- Only update the game, don't launch it
- ```--skip-launcher-update```
- Don't update the launcher
- ```--bonus```
- Download bonus content
- ```--force```, ```-f```
- Force file hash recheck
- ```--path```, ```-p```
- Set the game path
- Do not include a trailing backslash in the path
- ```--pass```
- Pass additional arguments to the game
- See [client-args.md](client-args.md)
- ```--version```, ```-v```
- Print the launcher version
Example: ```alterware-launcher.exe iw4x --bonus -u --path "C:\Games\IW4x" --pass "-console"```
Some arguments can be set in alterware-launcher.json, args generally override the values of the config.
---
#### Config file
alterware-launcher.json
- ```update_only```
- See --update
- Default: false
- ```skip_self_update```
- See --skip-launcher-update
- Default: false
- ```download_bonus_content```
- See --bonus
- Default: false
- ```ask_bonus_content```
- Ask the user if they want to download bonus content
- Default: true; false after asking
- ```force_update```
- See --force
- Default: false
- ```args```
- See --pass
- Default: ""
---
#### 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:
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
)
```

32
client-args.md Normal file
View File

@ -0,0 +1,32 @@
# IW4x
[github.com/iw4x/iw4x-client#command-line-arguments](https://github.com/iw4x/iw4x-client#command-line-arguments)
| Argument | Description |
|:------------------------|:-----------------------------------------------|
| `-tests` | Perform unit tests. |
| `-entries` | Print to the console a list of every asset as they are loaded from zonefiles. |
| `-stdout` | Redirect all logging output to the terminal iw4x is started from, or if there is none, creates a new terminal window to write log information in. |
| `-console` | Allow the game to display its own separate interactive console window. |
| `-dedicated` | Starts the game as a headless dedicated server. |
| `-bigminidumps` | Include all code sections from loaded modules in the dump. |
| `-reallybigminidumps` | Include data sections from all loaded modules in the dump. |
| `-dump` | Write info of loaded assets to the raw folder as they are being loaded. |
| `-nointro` | Skip game's cinematic intro. |
| `-version` | Print IW4x build info on startup. |
| `-nosteam` | Disable friends feature and do not update Steam about the game's current status just like an invisible mode. |
| `-unprotect-dvars` | Allow the server to modify saved/archive dvars. |
| `-zonebuilder` | Start the interactive zonebuilder tool console instead of starting the game. |
| `-disable-notifies` | Disable "Anti-CFG" checks |
| `-disable-mongoose` | Disable Mongoose HTTP server |
| `-disable-rate-limit-check` | Disable RCOn rate limit checks |
| `+<command>` | Execute game command (ex. `+set net_port 1337`)|
# S1-Mod, IW6-Mod
| Argument | Description |
|:------------------------|:-----------------------------------------------|
| `-headless` | Use system console |
| `-dedicated` | Dedicated server |
| `-singleplayer` | Start singleplayer; Skip launcher |
| `-multiplayer` | Start multiplayer; Skip launcher |
| `+<command>` | Execute game command (ex. `+set net_port 1337`)|

52
src/config.rs Normal file
View File

@ -0,0 +1,52 @@
use crate::structs::Config;
use std::{fs, path::PathBuf};
pub fn load(config_path: PathBuf) -> Config {
if config_path.exists() {
let cfg = fs::read_to_string(&config_path).unwrap();
let cfg: Config = serde_json::from_str(&cfg).unwrap_or(Config::default());
return cfg;
}
save(config_path.clone(), Config::default());
Config::default()
}
pub fn save(config_path: PathBuf, config: Config) {
match fs::write(
config_path.clone(),
serde_json::to_string_pretty(&config).unwrap(),
) {
Ok(_) => (),
Err(e) => match e.kind() {
std::io::ErrorKind::NotFound => {
fs::create_dir_all(config_path.parent().unwrap()).unwrap();
save(config_path, config);
}
_ => println!("Could not save config file, got:\n{}\n", e),
},
}
}
pub fn save_value(config_path: PathBuf, key: &str, value: bool) {
let mut config = load(config_path.clone());
match key {
"update_only" => config.update_only = value,
"skip_self_update" => config.skip_self_update = value,
"download_bonus_content" => config.download_bonus_content = value,
"ask_bonus_content" => config.ask_bonus_content = value,
"force_update" => config.force_update = value,
_ => (),
}
save(config_path, config);
}
pub fn save_value_s(config_path: PathBuf, key: &str, value: String) {
let mut config = load(config_path.clone());
match key {
"args" => config.args = value.to_string(),
"engine" => config.engine = value.to_string(),
_ => (),
}
save(config_path, config);
}

22
src/github.rs Normal file
View File

@ -0,0 +1,22 @@
use semver::Version;
pub fn latest_tag(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('"', "")
}
pub fn latest_version(owner: &str, repo: &str) -> Version {
let tag = latest_tag(owner, repo).replace('v', "");
Version::parse(&tag).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
View 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";

View File

@ -1,10 +1,41 @@
use crate::global;
use crate::misc;
use std::{fs, io::Write, path::Path, str};
pub fn get_body(url: &str) -> Vec<u8> {
let mut res: Vec<u8> = Vec::new();
http_req::request::get(url, &mut res).unwrap_or_else(|error| {
panic!("\n\n{}:\n{:?}", "Error", error);
});
match http_req::request::Request::new(&url.try_into().unwrap())
.header(
"User-Agent",
&format!(
"AlterWare Launcher | github.com/{}/{}",
global::GH_OWNER,
global::GH_REPO
),
)
.send(&mut res)
{
Ok(req) => {
if req.status_code() == http_req::response::StatusCode::new(302)
|| req.status_code() == http_req::response::StatusCode::new(301)
{
let location = req.headers().get("Location").unwrap().as_str();
return get_body(location);
}
if req.status_code() != http_req::response::StatusCode::new(200) {
misc::fatal_error(&format!(
"Could not get body from {}, got {}",
url,
req.status_code()
));
}
}
Err(e) => {
misc::fatal_error(&format!("Could not get body from {}, got:\n{}", url, e));
}
}
res
}
@ -16,10 +47,38 @@ pub fn get_body_string(url: &str) -> String {
pub fn download_file(url: &str, file_path: &Path) {
let body = get_body(url);
let mut f = fs::File::create(file_path).unwrap_or_else(|error| {
panic!("\n\n{}:\n{:?}", "Error", error);
});
f.write_all(&body).unwrap_or_else(|error| {
panic!("\n\n{}:\n{:?}", "Error", error);
});
match fs::File::create(file_path) {
Ok(mut file) => match file.write_all(&body) {
Ok(_) => (),
Err(e) => {
misc::fatal_error(&format!(
"Could not write to file {}, got:\n{}",
file_path.to_str().unwrap(),
e
));
}
},
Err(e) => {
match e.kind() {
std::io::ErrorKind::NotFound => {
fs::create_dir_all(file_path.parent().unwrap()).unwrap();
return download_file(url, file_path);
}
std::io::ErrorKind::PermissionDenied => {
misc::fatal_error(&format!(
"Permission to {} denied.\n Please try:\n 1. Running the launcher as administrator.\n 2. Manually deleting the last downloaded file.\n 3. If your game is in the program files directory try moving it to another location.\n 4. Create an exception/exclusion in your Anti-Virus Software for either the last downloaded file or the entire game directory.\n\n\n{}",
file_path.to_str().unwrap(),
e
));
}
_ => (),
}
misc::fatal_error(&format!(
"Could not create file {}, got:\n{}",
file_path.to_str().unwrap(),
e
));
}
}
}

60
src/http_async.rs Normal file
View File

@ -0,0 +1,60 @@
use std::cmp::min;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use colored::*;
use futures_util::StreamExt;
use indicatif::ProgressBar;
use reqwest::Client;
use crate::misc;
pub async fn download_file(
client: &Client,
pb: &ProgressBar,
url: &str,
path: &PathBuf,
size: u64,
) -> Result<(), String> {
let res = client
.get(url)
.header(
"User-Agent",
&format!(
"AlterWare Launcher | github.com/{}/{}",
crate::global::GH_OWNER,
crate::global::GH_REPO
),
)
.send()
.await
.or(Err(format!("Failed to GET from '{}'", &url)))?;
// Fix for CF shenanigans
let total_size = res.content_length().unwrap_or(size);
pb.set_length(total_size);
pb.println(format!(
"[{}] {} ({})",
"Downloading".bright_yellow(),
misc::cute_path(path),
misc::human_readable_bytes(total_size)
));
pb.set_message(path.file_name().unwrap().to_str().unwrap().to_string());
let mut file =
File::create(path).or(Err(format!("Failed to create file '{}'", path.display())))?;
let mut downloaded: u64 = 0;
let mut stream = res.bytes_stream();
while let Some(item) = stream.next().await {
let chunk = item.or(Err("Error while downloading file"))?;
file.write_all(&chunk)
.or(Err("Error while writing to file"))?;
let new = min(downloaded + (chunk.len() as u64), total_size);
downloaded = new;
pb.set_position(new);
}
pb.set_message(String::default());
Ok(())
}

22
src/io.rs Normal file
View 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();
}
}
}

50
src/iw4x.rs Normal file
View File

@ -0,0 +1,50 @@
use crate::github;
use crate::global::*;
use crate::http;
use crate::misc;
use colored::*;
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_tag(GH_IW4X_OWNER, GH_IW4X_REPO))
}
pub fn update(dir: &Path) {
let remote = remote_revision();
let local = local_revision(dir);
if remote <= local && dir.join("iw4x.dll").exists() {
println!(
"[{}] No files to download for IW4x",
"Info".bright_magenta(),
);
return;
}
println!(
"[{}] Downloading outdated or missing files for IW4x",
"Info".bright_magenta()
);
println!(
"[{}] {}",
"Downloading".bright_yellow(),
misc::cute_path(&dir.join("iw4x.dll"))
);
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();
}

View File

@ -1,119 +1,491 @@
mod config;
mod github;
mod global;
mod http;
use std::{fs, path::PathBuf};
mod http_async;
mod iw4x;
mod misc;
mod self_update;
mod structs;
#[derive(serde::Deserialize, serde::Serialize)]
struct CdnFile {
name: String,
size: u32,
hash: String,
}
use global::*;
use structs::*;
#[derive(serde::Deserialize, serde::Serialize)]
struct Game<'a> {
engine: &'a str,
client: &'a str,
references: Vec<&'a str>,
}
use colored::*;
use indicatif::ProgressBar;
#[cfg(windows)]
use mslnk::ShellLink;
use std::{borrow::Cow, collections::HashMap, env, fs, path::Path, path::PathBuf};
#[cfg(windows)]
use steamlocate::SteamDir;
const MASTER: &str = "https://master.alterware.dev";
#[cfg(windows)]
fn get_installed_games(games: &Vec<Game>) -> Vec<(u32, PathBuf)> {
let mut installed_games = Vec::new();
let mut steamdir = match SteamDir::locate() {
Some(steamdir) => steamdir,
None => {
println!("{}", "Steam not found!".yellow());
return installed_games;
}
};
fn file_get_sha1(path: &PathBuf) -> String {
let mut sha1 = sha1_smol::Sha1::new();
sha1.update(&fs::read(path).unwrap());
sha1.digest().to_string()
}
fn update(game: &Game) {
let cdn_info: Vec<CdnFile> = serde_json::from_str(&http::get_body_string(
format!(
"{}/files.json?{}",
MASTER,
rand::Rng::gen_range(&mut rand::thread_rng(), 0..1000)
)
.as_str(),
))
.unwrap();
let mut files_to_update: Vec<CdnFile> = Vec::new();
for file in cdn_info {
if file.name.starts_with(game.engine) {
files_to_update.push(file);
for game in games {
if let Some(app) = steamdir.app(&game.app_id) {
installed_games.push((game.app_id, PathBuf::from(&app.path)));
}
}
for file in files_to_update {
let file_path = PathBuf::from(&file.name.replace(&format!("{}/", game.engine), ""));
if file_path.exists() {
let sha1_local = file_get_sha1(&file_path).to_lowercase();
let sha1_remote = file.hash.to_lowercase();
if sha1_local != sha1_remote {
println!(
"Updating {}...\nLocal hash: {}\nRemote hash: {}",
file_path.display(),
sha1_local,
sha1_remote
);
http::download_file(
&format!(
"{}/{}?{}",
MASTER,
file.name,
rand::Rng::gen_range(&mut rand::thread_rng(), 0..1000)
),
&file_path,
);
}
} else {
println!("Downloading {}...", file_path.display());
if let Some(parent) = file_path.parent() {
if !parent.exists() {
fs::create_dir_all(parent).unwrap();
}
}
http::download_file(
&format!(
"{}/{}?{}",
MASTER,
file.name,
rand::Rng::gen_range(&mut rand::thread_rng(), 0..1000)
),
&file_path,
installed_games
}
#[cfg(windows)]
fn create_shortcut(path: &Path, target: &Path, icon: String, args: String) {
if let Ok(mut sl) = ShellLink::new(target) {
sl.set_arguments(Some(args));
sl.set_icon_location(Some(icon));
sl.create_lnk(path).unwrap_or_else(|error| {
println!("Error creating shortcut.\n{:#?}", error);
});
} else {
println!("Error creating shortcut.");
}
}
#[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 on the desktop) to launch a specific client.");
}
for c in game.client.iter() {
create_shortcut(
&game_dir.join(format!("launch-{}.lnk", c)),
&game_dir.join("alterware-launcher.exe"),
game_dir
.join(format!("{}.exe", c))
.to_string_lossy()
.into_owned(),
c.to_string(),
);
}
}
#[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", env::var("USERPROFILE").unwrap()));
for c in game.client.iter() {
create_shortcut(
&desktop.join(format!("{}.lnk", c)),
&path.join("alterware-launcher.exe"),
path.join(format!("{}.exe", c))
.to_string_lossy()
.into_owned(),
c.to_string(),
);
}
}
}
fn launch(file_path: &PathBuf) {
println!("Launching {}...", file_path.display());
std::process::Command::new(file_path)
.spawn()
.unwrap()
.wait()
.unwrap();
#[cfg(windows)]
async fn auto_install(path: &Path, game: &Game<'_>) {
setup_client_links(game, path);
setup_desktop_links(path, game);
update(game, path, false, false).await;
}
fn main() {
let mut args: Vec<String> = std::env::args().collect();
#[cfg(windows)]
async fn windows_launcher_install(games: &Vec<Game<'_>>) {
println!(
"{}",
"No game specified/found. Checking for installed Steam games..".yellow()
);
let installed_games = get_installed_games(games);
if !installed_games.is_empty() {
let current_dir = 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).await;
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, enter 0 for manual selection:");
let input: u32 = misc::stdin().parse().unwrap();
if input == 0 {
return manual_install(games).await;
}
for (id, path) in installed_games.iter() {
if *id == input {
let game = games.iter().find(|&g| g.app_id == input).unwrap();
let launcher_path = env::current_exe().unwrap();
let target_path = path.join("alterware-launcher.exe");
if launcher_path != target_path {
fs::copy(launcher_path, target_path).unwrap();
println!("Launcher copied to {}", path.display());
}
auto_install(path, game).await;
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).await;
}
}
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])
}
async fn manual_install(games: &[Game<'_>]) {
let selection = prompt_client_selection(games);
let game = games.iter().find(|&g| g.client[0] == selection).unwrap();
update(game, &env::current_dir().unwrap(), false, false).await;
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 total_download_size(cdn_info: &Vec<CdnFile>, remote_dir: &str) -> u64 {
let remote_dir = format!("{}/", remote_dir);
let mut size: u64 = 0;
for file in cdn_info {
if !file.name.starts_with(&remote_dir) || file.name == "iw4/iw4x.dll" {
continue;
}
size += file.size as u64;
}
size
}
async fn update_dir(
cdn_info: &Vec<CdnFile>,
remote_dir: &str,
dir: &Path,
hashes: &mut HashMap<String, String>,
pb: &ProgressBar,
) {
misc::pb_style_download(pb, false);
let remote_dir_pre = format!("{}/", remote_dir);
let mut files_to_download: Vec<CdnFile> = vec![];
for file in cdn_info {
if !file.name.starts_with(&remote_dir_pre) || file.name == "iw4/iw4x.dll" {
continue;
}
let sha1_remote = file.hash.to_lowercase();
let file_name = &file.name.replace(remote_dir_pre.as_str(), "");
let file_path = dir.join(file_name);
if file_path.exists() {
let sha1_local = hashes
.get(file_name)
.map(Cow::Borrowed)
.unwrap_or_else(|| Cow::Owned(misc::get_file_sha1(&file_path)))
.to_string();
if sha1_local != sha1_remote {
files_to_download.push(file.clone());
} else {
pb.println(format!(
"[{}] {}",
"Checked".bright_blue(),
misc::cute_path(&file_path)
));
hashes.insert(file_name.to_owned(), file.hash.to_lowercase());
}
} else {
files_to_download.push(file.clone());
}
}
if files_to_download.is_empty() {
pb.println(format!(
"[{}] No files to download for {}",
"Info".bright_magenta(),
remote_dir
));
return;
}
pb.println(format!(
"[{}] Downloading outdated or missing files for {}, {}",
"Info".bright_magenta(),
remote_dir,
misc::human_readable_bytes(total_download_size(&files_to_download, remote_dir))
));
misc::pb_style_download(pb, true);
let client = reqwest::Client::new();
for file in files_to_download {
let file_name = &file.name.replace(&remote_dir_pre, "");
let file_path = dir.join(file_name);
if let Some(parent) = file_path.parent() {
if !parent.exists() {
fs::create_dir_all(parent).unwrap();
}
}
http_async::download_file(
&client,
pb,
&format!("{}/{}", MASTER, file.name),
&file_path,
file.size as u64,
)
.await
.unwrap();
hashes.insert(file_name.to_owned(), file.hash.to_lowercase());
}
misc::pb_style_download(pb, false);
}
async fn update(game: &Game<'_>, dir: &Path, bonus_content: bool, force: bool) {
let cdn_info: Vec<CdnFile> = serde_json::from_str(&http::get_body_string(
format!("{}/files.json", MASTER).as_str(),
))
.unwrap();
let mut hashes = HashMap::new();
let hash_file = dir.join(".sha-sums");
if hash_file.exists() && !force {
let hash_file = fs::read_to_string(hash_file).unwrap();
for line in hash_file.lines() {
let mut split = line.split_whitespace();
let hash = split.next().unwrap();
let file = split.next().unwrap();
hashes.insert(file.to_owned(), hash.to_owned());
}
}
if game.engine == "iw4" {
iw4x::update(dir);
}
let pb = ProgressBar::new(0);
update_dir(&cdn_info, game.engine, dir, &mut hashes, &pb).await;
if bonus_content && !game.bonus.is_empty() {
for bonus in game.bonus.iter() {
update_dir(&cdn_info, bonus, dir, &mut hashes, &pb).await;
}
}
pb.finish();
let mut hash_file_content = String::new();
for (file, hash) in hashes.iter() {
hash_file_content.push_str(&format!("{} {}\n", hash, file));
}
fs::write(dir.join(".sha-sums"), hash_file_content).unwrap();
}
fn launch(file_path: &PathBuf, args: &str) {
println!("\n\nJoin the AlterWare Discord server:\nhttps://discord.gg/2ETE8engZM\n\n");
println!("Launching {} {}", file_path.display(), args);
std::process::Command::new(file_path)
.args(args.trim().split(' '))
.current_dir(file_path.parent().unwrap())
.spawn()
.expect("Failed to launch the game")
.wait()
.expect("Failed to wait for the game process to finish");
}
#[cfg(windows)]
fn setup_env() {
colored::control::set_virtual_terminal(true).unwrap_or_else(|error| {
println!("{:#?}", error);
colored::control::SHOULD_COLORIZE.set_override(false);
});
if let Ok(system_root) = env::var("SystemRoot") {
if let Ok(current_dir) = env::current_dir() {
if current_dir.starts_with(system_root) {
if let Ok(current_exe) = env::current_exe() {
if let Some(parent) = current_exe.parent() {
if let Err(error) = env::set_current_dir(parent) {
eprintln!("{:#?}", error);
} else {
println!("Running from the system directory. Changed working directory to the executable location.");
}
}
}
}
}
}
}
fn arg_value(args: &[String], arg: &str) -> Option<String> {
args.iter()
.position(|r| r == arg)
.map(|e| args[e + 1].clone())
}
fn arg_bool(args: &[String], arg: &str) -> bool {
args.iter().any(|r| r == arg)
}
fn arg_remove(args: &mut Vec<String>, arg: &str) {
args.iter().position(|r| r == arg).map(|e| args.remove(e));
}
fn arg_remove_value(args: &mut Vec<String>, arg: &str) {
if let Some(e) = args.iter().position(|r| r == arg) {
args.remove(e);
args.remove(e);
};
}
#[tokio::main]
async fn main() {
#[cfg(windows)]
setup_env();
let mut args: Vec<String> = env::args().collect();
if arg_bool(&args, "--help") {
println!("CLI Args:");
println!(" <client>: Specify the client to launch");
println!(" --help: Display this help message");
println!(" --version: Display the launcher version");
println!(" --path/-p <path>: Specify the game directory");
println!(" --update/-u: Update only, don't launch the game");
println!(" --bonus: Download bonus content");
println!(" --force/-f: Force file hash recheck");
println!(" --pass <args>: Pass arguments to the game");
println!(" --skip-launcher-update: Skip launcher self-update");
println!(
"\nExample:\n alterware-launcher.exe iw4x --bonus --pass \"-console -nointro\""
);
return;
}
if arg_bool(&args, "--version") || arg_bool(&args, "-v") {
println!(
"{} v{}",
"AlterWare Launcher".bright_green(),
env!("CARGO_PKG_VERSION")
);
println!("https://github.com/{}/{}", GH_OWNER, GH_REPO);
println!(
"\n{}{}{}{}{}{}{}",
"For ".on_black(),
"Alter".bright_blue().on_black().underline(),
"Ware".white().on_black().underline(),
".dev".on_black().underline(),
" by ".on_black(),
"mxve".bright_magenta().on_black().underline(),
".de".on_black().underline()
);
return;
}
let install_path: PathBuf;
if let Some(path) = arg_value(&args, "--path") {
install_path = PathBuf::from(path);
arg_remove_value(&mut args, "--path");
} else if let Some(path) = arg_value(&args, "-p") {
install_path = PathBuf::from(path);
arg_remove_value(&mut args, "-p");
} else {
install_path = env::current_dir().unwrap();
}
let mut cfg = config::load(install_path.join("alterware-launcher.json"));
if !arg_bool(&args, "--skip-launcher-update") && !cfg.skip_self_update {
self_update::run(cfg.update_only);
} else {
arg_remove(&mut args, "--skip-launcher-update");
}
if arg_bool(&args, "--update") || arg_bool(&args, "-u") {
cfg.update_only = true;
arg_remove(&mut args, "--update");
arg_remove(&mut args, "-u");
}
if arg_bool(&args, "--bonus") {
cfg.download_bonus_content = true;
cfg.ask_bonus_content = false;
arg_remove(&mut args, "--bonus");
}
if arg_bool(&args, "--force") || arg_bool(&args, "-f") {
cfg.force_update = true;
arg_remove(&mut args, "--force");
arg_remove(&mut args, "-f");
}
if let Some(pass) = arg_value(&args, "--pass") {
cfg.args = pass;
arg_remove_value(&mut args, "--pass");
} else if cfg.args.is_empty() {
cfg.args = String::default();
}
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]);
} else {
'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 install_path.join(r).exists() {
if g.client.len() > 1 {
if cfg.update_only {
game = String::from(g.client[0]);
break 'main;
}
#[cfg(windows)]
setup_client_links(g, &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;
}
}
@ -121,17 +493,63 @@ 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 {
if cfg.engine.is_empty() {
cfg.engine = String::from(g.engine);
config::save_value_s(
install_path.join("alterware-launcher.json"),
"engine",
cfg.engine.clone(),
);
if cfg.engine == "iw4" && cfg.args.is_empty() {
cfg.args = String::from("-stdout");
config::save_value_s(
install_path.join("alterware-launcher.json"),
"args",
cfg.args.clone(),
);
}
}
if cfg.ask_bonus_content && !g.bonus.is_empty() {
println!("Download bonus content? (Y/n)");
let input = misc::stdin().to_ascii_lowercase();
cfg.download_bonus_content = input != "n";
config::save_value(
install_path.join("alterware-launcher.json"),
"download_bonus_content",
cfg.download_bonus_content,
);
config::save_value(
install_path.join("alterware-launcher.json"),
"ask_bonus_content",
false,
);
}
update(
g,
install_path.as_path(),
cfg.download_bonus_content,
cfg.force_update,
)
.await;
if !cfg.update_only {
launch(&install_path.join(format!("{}.exe", c)), &cfg.args);
}
return;
}
launch(&PathBuf::from(format!("{}.exe", g.client)));
return;
}
}
println!("Game not found!");
#[cfg(windows)]
windows_launcher_install(&games).await;
#[cfg(not(windows))]
manual_install(&games).await;
println!("{}", "Game not found!".bright_red());
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...");
std::io::stdin().read_line(&mut String::new()).unwrap();

58
src/misc.rs Normal file
View File

@ -0,0 +1,58 @@
use std::{
fs,
path::{Path, PathBuf},
};
use colored::Colorize;
use indicatif::{ProgressBar, ProgressStyle};
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_or("0")
.parse::<u16>()
.unwrap_or(0)
}
pub fn fatal_error(error: &str) {
println!("\n\n{}:\n{}", "Error".bright_red(), error);
stdin();
std::process::exit(1);
}
pub fn human_readable_bytes(bytes: u64) -> String {
let mut bytes = bytes as f64;
let mut i = 0;
let units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
while bytes > 1024.0 {
bytes /= 1024.0;
i += 1;
}
format!("{:.2}{}", bytes, units[i])
}
pub fn pb_style_download(pb: &ProgressBar, state: bool) {
if state {
pb.set_style(
ProgressStyle::with_template("{spinner:.magenta} {msg:.magenta} > {bytes}/{total_bytes} | {bytes_per_sec} | {eta}")
.unwrap(),
);
} else {
pb.set_style(ProgressStyle::with_template("{spinner:.magenta} {msg}").unwrap());
}
}
pub fn cute_path(path: &Path) -> String {
path.to_str().unwrap().replace('\\', "/")
}

111
src/self_update.rs Normal file
View File

@ -0,0 +1,111 @@
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 restart() -> std::io::Error {
use std::os::windows::process::CommandExt;
match std::process::Command::new(std::env::current_exe().unwrap())
.args(std::env::args().skip(1))
.creation_flags(0x00000010) // CREATE_NEW_CONSOLE
.spawn()
{
Ok(_) => std::process::exit(0),
Err(err) => err,
}
}
#[cfg(windows)]
pub fn run(update_only: bool) {
use std::{fs, path::PathBuf};
use crate::http;
use crate::misc;
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_or_else(|_| {
println!("Failed to remove old launcher file.");
});
}
}
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();
}
let launcher_name = if cfg!(target_arch = "x86") {
"alterware-launcher-x86.exe"
} else {
"alterware-launcher.exe"
};
http::download_file(
&format!(
"{}/download/{}",
github::latest_release_url(GH_OWNER, GH_REPO),
launcher_name
),
&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();
// restarting spawns a new console, automation should manually restart on exit code 201
if !update_only {
let restart_error = restart().to_string();
println!("Failed to restart launcher: {}", restart_error);
println!("Please restart the launcher manually.");
misc::stdin();
}
std::process::exit(201);
}
}

41
src/structs.rs Normal file
View File

@ -0,0 +1,41 @@
#[derive(serde::Deserialize, serde::Serialize, Clone)]
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,
pub bonus: Vec<&'a str>,
}
#[derive(serde::Deserialize, serde::Serialize)]
pub struct Config {
pub update_only: bool,
pub skip_self_update: bool,
pub download_bonus_content: bool,
pub ask_bonus_content: bool,
pub force_update: bool,
pub args: String,
#[serde(default)]
pub engine: String,
}
impl Default for Config {
fn default() -> Self {
Self {
update_only: false,
skip_self_update: false,
download_bonus_content: false,
ask_bonus_content: true,
force_update: false,
args: String::default(),
engine: String::default(),
}
}
}