From: Ian Jackson Date: Sat, 15 May 2021 16:35:31 +0000 (+0100) Subject: bundles: Actually implement shape loading X-Git-Tag: otter-0.6.0~268 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=e5b139c5f89bcb96664fe235fb95dc34b3084278;p=otter.git bundles: Actually implement shape loading A small amount of glue! Signed-off-by: Ian Jackson --- diff --git a/src/bundles.rs b/src/bundles.rs index 5aa3362e..ecc9319f 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -703,7 +703,7 @@ fn make_usvg(za: &mut IndexedZip, progress_count: &mut usize, //---------- scanning/incorporating/uploading ---------- #[throws(InternalError)] -fn incorporate_bundle(ib: &mut InstanceBundles, _ig: &mut Instance, +fn incorporate_bundle(ib: &mut InstanceBundles, ig: &mut Instance, id: Id, parsed: Parsed) { let Parsed { meta, libs } = parsed; @@ -718,7 +718,9 @@ fn incorporate_bundle(ib: &mut InstanceBundles, _ig: &mut Instance, }) }; - let _ = libs; // xxx actually incorporate + for lib in libs { + ig.local_libs.add(lib); + } let state = State::Loaded(Loaded { meta }); *slot = Some(Note { kind: id.kind, state }); @@ -929,8 +931,7 @@ impl InstanceBundles { } // If we are in UNUSED, become BROKEN - // xxx: make shape libs and specs inaccessible to mgmt commands - let _ = (); + ig.local_libs.clear(); (||{ // If we are in BROKEN, become WRECKAGE diff --git a/src/global.rs b/src/global.rs index 044ace92..bc571fba 100644 --- a/src/global.rs +++ b/src/global.rs @@ -58,6 +58,7 @@ pub struct Instance { pub links: Arc, pub bundle_list: MgmtBundleList, // copy for easy access pub asset_url_key: AssetUrlKey, + pub local_libs: shapelib::Registry, } pub struct PlayerRecord { @@ -350,6 +351,7 @@ impl Instance { links: default(), bundle_list: default(), asset_url_key: AssetUrlKey::new_random()?, + local_libs: default(), }; let c = InstanceContainer { @@ -507,6 +509,7 @@ impl Instance { links: default(), bundle_list: default(), asset_url_key: AssetUrlKey::Dummy, + local_libs: default(), iplayers: default(), } } @@ -1184,6 +1187,7 @@ impl InstanceGuard<'_> { tokens_clients: default(), tokens_players: default(), bundle_list: default(), // set by load_game_bundles + local_libs: default(), // set by load_game_bundles asset_url_key, }; diff --git a/src/shapelib.rs b/src/shapelib.rs index 4d9eaec8..ef1d3913 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -353,11 +353,15 @@ impl Registry { .entry(data.libname.clone()).or_default() .push(data); } + + pub fn clear(&mut self) { + self.libs.clear() + } } pub struct AllRegistries<'ig> { global: RwLockReadGuard<'static, Option>, - #[allow(dead_code)] ig: &'ig Instance, + ig: &'ig Instance, } pub struct AllRegistriesIterator<'i> { regs: &'i AllRegistries<'i>, @@ -370,6 +374,7 @@ impl<'i> Iterator for AllRegistriesIterator<'i> { loop { let r = match self.count { 0 => self.regs.global.as_ref(), + 1 => Some(&self.regs.ig.local_libs), _ => return None, }; self.count += 1;