@@ -6,13 +6,14 @@ mod manifest;
66mod mod_man;
77mod models;
88mod patching;
9- mod paths ;
9+ mod parameters ;
1010
1111use anyhow:: { Context , Result } ;
1212use downloads:: DownloadConfig ;
1313use log:: { debug, error, warn, Level } ;
1414use mbf_res_man:: res_cache:: ResCache ;
1515use models:: { request, response} ;
16+ use parameters:: { init_parameters, PARAMETERS } ;
1617use serde:: { Deserialize , Serialize } ;
1718use std:: {
1819 io:: { BufRead , BufReader , Write } ,
@@ -22,9 +23,6 @@ use std::{
2223 sync,
2324} ;
2425
25- /// The ID of the APK file that MBF manages.
26- pub const APK_ID : & str = "com.beatgames.beatsaber" ;
27-
2826#[ cfg( feature = "request_timing" ) ]
2927use log:: info;
3028#[ cfg( feature = "request_timing" ) ]
@@ -33,7 +31,7 @@ use std::time::Instant;
3331/// Attempts to delete legacy directories no longer used by MBF to free up space
3432/// Logs on failure
3533pub fn try_delete_legacy_dirs ( ) {
36- for dir in paths :: LEGACY_DIRS {
34+ for dir in & PARAMETERS . legacy_dirs {
3735 if Path :: new ( dir) . exists ( ) {
3836 match std:: fs:: remove_dir_all ( dir) {
3937 Ok ( _) => debug ! ( "Successfully removed legacy dir {dir}" ) ,
@@ -62,16 +60,16 @@ pub fn get_dl_cfg() -> &'static DownloadConfig<'static> {
6260/// Creates a ResCache for downloading files using mbf_res_man
6361/// This should be reused where possible.
6462pub fn load_res_cache ( ) -> Result < ResCache < ' static > > {
65- std:: fs:: create_dir_all ( paths :: RES_CACHE ) . expect ( "Failed to create resource cache folder" ) ;
63+ std:: fs:: create_dir_all ( & PARAMETERS . res_cache ) . expect ( "Failed to create resource cache folder" ) ;
6664 Ok ( ResCache :: new (
67- paths :: RES_CACHE . into ( ) ,
65+ ( & PARAMETERS . res_cache ) . into ( ) ,
6866 mbf_res_man:: default_agent:: get_agent ( ) ,
6967 ) )
7068}
7169
7270pub fn get_apk_path ( ) -> Result < Option < String > > {
7371 let pm_output = Command :: new ( "pm" )
74- . args ( [ "path" , APK_ID ] )
72+ . args ( [ "path" , & PARAMETERS . apk_id ] )
7573 . output ( )
7674 . context ( "Working out APK path" ) ?;
7775 if 8 > pm_output. stdout . len ( ) {
@@ -153,6 +151,9 @@ fn main() -> Result<()> {
153151 reader. read_line ( & mut line) ?;
154152 let req: request:: Request = serde_json:: from_str ( & line) ?;
155153
154+ // Set the parameters for this instance of the agent
155+ init_parameters ( & req. agent_parameters . game_id , req. agent_parameters . ignore_package_id ) ;
156+
156157 // Set a panic hook that writes the panic as a JSON Log
157158 // (we don't do this in catch_unwind as we get an `Any` there, which doesn't implement Display)
158159 panic:: set_hook ( Box :: new ( |info| {
0 commit comments