forked from StrafesNET/map-tool
delete recursive function
This commit is contained in:
parent
206bb01c1a
commit
3f15d2f5a8
27
src/main.rs
27
src/main.rs
@ -11,15 +11,16 @@ fn class_is_a(class: &str, superclass: &str) -> bool {
|
||||
return false
|
||||
}
|
||||
|
||||
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() {
|
||||
if let Some(c) = dom.get_by_ref(referent) {
|
||||
if class_is_a(c.class.as_str(), "LuaSourceContainer") {
|
||||
scripts.push(c.referent());//copy ref
|
||||
}
|
||||
recursive_collect_scripts(scripts,dom,c);
|
||||
fn get_scripts(dom:rbx_dom_weak::WeakDom) -> Vec<rbx_dom_weak::Instance>{
|
||||
let mut scripts = std::vec::Vec::<rbx_dom_weak::Instance>::new();
|
||||
|
||||
let (_,mut instances) = dom.into_raw();
|
||||
for (_,instance) in instances.drain() {
|
||||
if class_is_a(instance.class.as_str(), "LuaSourceContainer") {
|
||||
scripts.push(instance);
|
||||
}
|
||||
}
|
||||
scripts
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@ -34,13 +35,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
allowed.insert(std::fs::read_to_string(entry?.path())?);
|
||||
}
|
||||
|
||||
let mut scripts = std::vec::Vec::<rbx_dom_weak::types::Ref>::new();
|
||||
recursive_collect_scripts(&mut scripts, &dom, dom.root());
|
||||
|
||||
//check scribb
|
||||
let mut any_failed=false;
|
||||
for (i,&referent) in scripts.iter().enumerate() {
|
||||
if let Some(script) = dom.get_by_ref(referent) {
|
||||
|
||||
let scripts = get_scripts(dom);
|
||||
|
||||
//check scribb
|
||||
let mut any_failed=false;
|
||||
for script in scripts.iter() {
|
||||
if let Some(rbx_dom_weak::types::Variant::String(s)) = script.properties.get("Source") {
|
||||
if allowed.contains(s) {
|
||||
println!("pass");
|
||||
|
Loading…
Reference in New Issue
Block a user