forked from StrafesNET/map-tool
collect referent instead of Source
This commit is contained in:
parent
4c1632c0b6
commit
df24bc9945
27
src/main.rs
27
src/main.rs
@ -11,16 +11,15 @@ fn class_is_a(class: &str, superclass: &str) -> bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn recursive_collect_scripts(scripts: &mut std::vec::Vec<String>,dom: &rbx_dom_weak::WeakDom, instance: &rbx_dom_weak::Instance){
|
fn recursive_collect_scripts(scripts: &mut std::vec::Vec<rbx_dom_weak::types::Ref>,dom: &rbx_dom_weak::WeakDom, instance: &rbx_dom_weak::Instance){
|
||||||
for &referent in instance.children() {
|
for &referent in instance.children() {
|
||||||
let c = dom.get_by_ref(referent).unwrap();
|
if let Some(c) = dom.get_by_ref(referent) {
|
||||||
if class_is_a(c.class.as_str(), "LuaSourceContainer") {
|
if class_is_a(c.class.as_str(), "LuaSourceContainer") {
|
||||||
if let Some(rbx_dom_weak::types::Variant::String(s)) = c.properties.get("Source") {
|
scripts.push(c.referent());//copy ref
|
||||||
scripts.push(s.clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
recursive_collect_scripts(scripts,dom,c);
|
recursive_collect_scripts(scripts,dom,c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
@ -35,18 +34,28 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
allowed.insert(std::fs::read_to_string(entry?.path())?);
|
allowed.insert(std::fs::read_to_string(entry?.path())?);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut scripts = std::vec::Vec::<String>::new();
|
let mut scripts = std::vec::Vec::<rbx_dom_weak::types::Ref>::new();
|
||||||
recursive_collect_scripts(&mut scripts, &dom, dom.root());
|
recursive_collect_scripts(&mut scripts, &dom, dom.root());
|
||||||
|
|
||||||
//check scribb
|
//check scribb
|
||||||
let mut any_failed=false;
|
let mut any_failed=false;
|
||||||
for (i,script) in scripts.iter().enumerate() {
|
for (i,&referent) in scripts.iter().enumerate() {
|
||||||
if allowed.contains(script) {
|
if let Some(script) = dom.get_by_ref(referent) {
|
||||||
|
if let Some(rbx_dom_weak::types::Variant::String(s)) = script.properties.get("Source") {
|
||||||
|
if allowed.contains(s) {
|
||||||
println!("pass");
|
println!("pass");
|
||||||
}else{
|
}else{
|
||||||
println!("fail");
|
println!("fail");
|
||||||
any_failed=true;
|
any_failed=true;
|
||||||
std::fs::write(format!("blocked/{}.lua",i),script)?;
|
std::fs::write(format!("blocked/{}.lua",i),s)?;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
println!("failed to get source");
|
||||||
|
any_failed=true;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
println!("failed to deref script");
|
||||||
|
any_failed=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if any_failed {
|
if any_failed {
|
||||||
|
Loading…
Reference in New Issue
Block a user