Skip to content

Commit

Permalink
add --voice-server
Browse files Browse the repository at this point in the history
  • Loading branch information
xxshady committed Nov 17, 2024
1 parent 0807d95 commit cfc2eac
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
15 changes: 14 additions & 1 deletion altvup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ It can also download alt:V server binaries & data files.
## How to install

Recommended: (if you don't have it: [cargo-binstall](https://github.com/cargo-bins/cargo-binstall?tab=readme-ov-file#cargo-binaryinstall))<br>
`cargo binstall altvup`
`cargo binstall altvup`

Or you can compile from source code: (but it's gonna take longer)<br>
`cargo install cargo-altvup`
Expand Down Expand Up @@ -41,6 +41,19 @@ Download serverside part of [jsv2](https://github.com/altmp/altv-js-module-v2) m

For example: `cargo altvup release --jsv2`

### `--voice-server`

Download [external voice](https://docs.altv.mp/articles/external_voice_server.html) server binary (disabled by default).

For example: `cargo altvup release --voice-server`

### `--rust-module-releases-pages`

How many pages to fetch from github releases API to search for `rust-module` source code (2 by default).
Increase it if you have "Cannot find altv-rust release of branch..." error

For example: `cargo altvup release --rust-module-releases-pages=5`

## How `rust-module` is installed

It downloads `altv-rust` source code to `.altvup-src` directory (see also: [`--src-dir`](#--src-dir)) and compiles `rust-module` (.so or .dll) to the `modules` directory, after compilation `.altvup-src` directory will be deleted.
18 changes: 16 additions & 2 deletions altvup/src/altv_server_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use colored::Colorize;
use serde::Deserialize;
use sha1_smol::Sha1;

use crate::shared::find_cli_param;

const CDN_ADDRESS: &str = "cdn.alt-mp.com";

type LocalPath = String;
Expand All @@ -30,8 +32,13 @@ struct UpdateJson {
hash_list: HashMap<LocalPath, Sha1String>,
}

pub fn download(agent: &ureq::Agent, branch: &str, load_jsv2: bool) -> anyhow::Result<()> {
let files = fetch_downloadable_files(agent, branch, load_jsv2)?;
pub fn download(
agent: &ureq::Agent,
branch: &str,
load_jsv2: bool,
args: &[String],
) -> anyhow::Result<()> {
let files = fetch_downloadable_files(agent, branch, load_jsv2, args)?;
let outdated_files = check_file_hashes(files)?;

if outdated_files.is_empty() {
Expand Down Expand Up @@ -77,6 +84,7 @@ fn fetch_downloadable_files(
agent: &ureq::Agent,
branch: &str,
load_jsv2: bool,
args: &[String],
) -> anyhow::Result<Vec<CdnFileMetadata>> {
println!("Requesting list of files from alt:V CDN");

Expand All @@ -101,6 +109,12 @@ fn fetch_downloadable_files(
fetch_file_metadata_from(&js_module_v2_url, agent, &mut files)?;
}

let load_voice_server = find_cli_param(args, "voice-server").is_some();
if load_voice_server {
let voice_server_url = format!("https://{CDN_ADDRESS}/voice-server/release/{platform}");
fetch_file_metadata_from(&voice_server_url, agent, &mut files)?;
}

Ok(files)
}

Expand Down
2 changes: 1 addition & 1 deletion altvup/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn altvup() -> anyhow::Result<()> {
let load_jsv2 = find_cli_param(other_args, "jsv2").is_some();

rust_module::compile(&agent, branch, other_args)?;
altv_server_files::download(&agent, branch, load_jsv2)?;
altv_server_files::download(&agent, branch, load_jsv2, other_args)?;
extra::create_server_config(load_jsv2)?;

Ok(())
Expand Down

0 comments on commit cfc2eac

Please sign in to comment.