forked from StrafesNET/map-tool
write edited file and report how many scripts were replaced
This commit is contained in:
parent
b7d04d1f40
commit
29374e4ff5
15
src/main.rs
15
src/main.rs
@ -315,6 +315,7 @@ fn interactive() -> Result<(), Box<dyn std::error::Error>>{
|
|||||||
|
|
||||||
//check scribb
|
//check scribb
|
||||||
let mut script_count=0;
|
let mut script_count=0;
|
||||||
|
let mut replace_count=0;
|
||||||
let mut block_count=0;
|
let mut block_count=0;
|
||||||
let mut fail_type=Interactive::Passed;
|
let mut fail_type=Interactive::Passed;
|
||||||
for script in scripts.iter() {
|
for script in scripts.iter() {
|
||||||
@ -392,6 +393,7 @@ fn interactive() -> Result<(), Box<dyn std::error::Error>>{
|
|||||||
//replace the source
|
//replace the source
|
||||||
let location=get_full_name(&write_dom, script);
|
let location=get_full_name(&write_dom, script);
|
||||||
if let (Some(replace_source),Some(replace_script))=(allowed_map.get(&replace_id),write_dom.get_by_ref_mut(script.referent())){
|
if let (Some(replace_source),Some(replace_script))=(allowed_map.get(&replace_id),write_dom.get_by_ref_mut(script.referent())){
|
||||||
|
replace_count+=1;
|
||||||
println!("replaced source id={} location={}",replace_id,location);
|
println!("replaced source id={} location={}",replace_id,location);
|
||||||
replace_script.properties.insert("Source".to_string(), rbx_dom_weak::types::Variant::String(replace_source.clone()));
|
replace_script.properties.insert("Source".to_string(), rbx_dom_weak::types::Variant::String(replace_source.clone()));
|
||||||
}else{
|
}else{
|
||||||
@ -418,7 +420,18 @@ fn interactive() -> Result<(), Box<dyn std::error::Error>>{
|
|||||||
let mut dest=match fail_type{
|
let mut dest=match fail_type{
|
||||||
Interactive::Passed => {
|
Interactive::Passed => {
|
||||||
println!("map={:?} passed with {} {}",file_thing.file_name(),script_count,if script_count==1 {"script"}else{"scripts"});
|
println!("map={:?} passed with {} {}",file_thing.file_name(),script_count,if script_count==1 {"script"}else{"scripts"});
|
||||||
std::path::PathBuf::from("maps/processed")
|
if replace_count==0{
|
||||||
|
std::path::PathBuf::from("maps/passed")
|
||||||
|
}else{
|
||||||
|
//create new file
|
||||||
|
println!("{} {} replaced - generating new file...",replace_count,if replace_count==1 {"script was"}else{"scripts were"});
|
||||||
|
let mut dest=std::path::PathBuf::from("maps/passed");
|
||||||
|
dest.push(file_thing.file_name());
|
||||||
|
let output = std::io::BufWriter::new(std::fs::File::create(dest)?);
|
||||||
|
rbx_binary::to_writer(output, &dom, &[dom.root_ref()])?;
|
||||||
|
//move original to processed folder
|
||||||
|
std::path::PathBuf::from("maps/unaltered")
|
||||||
|
}
|
||||||
},//write map into maps/processed
|
},//write map into maps/processed
|
||||||
Interactive::Blocked => {
|
Interactive::Blocked => {
|
||||||
println!("map={:?} blocked with {}/{} {} blocked",file_thing.file_name(),block_count,script_count,if script_count==1 {"script"}else{"scripts"});
|
println!("map={:?} blocked with {}/{} {} blocked",file_thing.file_name(),block_count,script_count,if script_count==1 {"script"}else{"scripts"});
|
||||||
|
Loading…
Reference in New Issue
Block a user