chore(vm): clean up spelling and RC usage

This commit is contained in:
Rachel Powers
2024-05-14 05:23:00 -07:00
parent de2698c2e2
commit 7b8523d2ea
3 changed files with 16 additions and 16 deletions

View File

@@ -11,7 +11,7 @@ use crate::{
enums::script_enums::{LogicBatchMethod, LogicSlotType, LogicType}, enums::script_enums::{LogicBatchMethod, LogicSlotType, LogicType},
object::{ object::{
templates::ObjectTemplate, templates::ObjectTemplate,
traits::{Object, ParentSlotInfo}, traits::ParentSlotInfo,
ObjectID, VMObject, ObjectID, VMObject,
}, },
}, },
@@ -43,7 +43,7 @@ pub struct VM {
} }
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct VMTransationNetwork { pub struct VMTransactionNetwork {
pub objects: Vec<ObjectID>, pub objects: Vec<ObjectID>,
pub power_only: Vec<ObjectID>, pub power_only: Vec<ObjectID>,
} }
@@ -51,7 +51,7 @@ pub struct VMTransationNetwork {
#[derive(Debug)] #[derive(Debug)]
/// used as a temp structure to add objects in case /// used as a temp structure to add objects in case
/// there are errors on nested templates /// there are errors on nested templates
pub struct VMTransation { pub struct VMTransaction {
pub objects: BTreeMap<ObjectID, VMObject>, pub objects: BTreeMap<ObjectID, VMObject>,
pub circuit_holders: Vec<ObjectID>, pub circuit_holders: Vec<ObjectID>,
pub program_holders: Vec<ObjectID>, pub program_holders: Vec<ObjectID>,
@@ -59,7 +59,7 @@ pub struct VMTransation {
pub wireless_transmitters: Vec<ObjectID>, pub wireless_transmitters: Vec<ObjectID>,
pub wireless_receivers: Vec<ObjectID>, pub wireless_receivers: Vec<ObjectID>,
pub id_space: IdSpace, pub id_space: IdSpace,
pub networks: BTreeMap<ObjectID, VMTransationNetwork>, pub networks: BTreeMap<ObjectID, VMTransactionNetwork>,
vm: Rc<VM>, vm: Rc<VM>,
} }
@@ -94,12 +94,12 @@ impl VM {
self: &Rc<Self>, self: &Rc<Self>,
template: ObjectTemplate, template: ObjectTemplate,
) -> Result<u32, VMError> { ) -> Result<u32, VMError> {
let mut transaction = VMTransation::new(self); let mut transaction = VMTransaction::new(self);
let obj_id = transaction.add_device_from_template(template)?; let obj_id = transaction.add_device_from_template(template)?;
let transation_ids = transaction.id_space.in_use_ids(); let transaction_ids = transaction.id_space.in_use_ids();
self.id_space.borrow_mut().use_new_ids(&transation_ids); self.id_space.borrow_mut().use_new_ids(&transaction_ids);
self.objects.borrow_mut().extend(transaction.objects); self.objects.borrow_mut().extend(transaction.objects);
self.wireless_transmitters self.wireless_transmitters
@@ -120,7 +120,7 @@ impl VM {
.borrow() .borrow()
.get(&net_id) .get(&net_id)
.expect(&format!( .expect(&format!(
"desync between vm and transation networks: {net_id}" "desync between vm and transaction networks: {net_id}"
)) ))
.borrow_mut() .borrow_mut()
.as_mut_network() .as_mut_network()
@@ -883,9 +883,9 @@ impl VM {
} }
} }
impl VMTransation { impl VMTransaction {
pub fn new(vm: &Rc<VM>) -> Self { pub fn new(vm: &Rc<VM>) -> Self {
VMTransation { VMTransaction {
objects: BTreeMap::new(), objects: BTreeMap::new(),
circuit_holders: Vec::new(), circuit_holders: Vec::new(),
program_holders: Vec::new(), program_holders: Vec::new(),
@@ -897,7 +897,7 @@ impl VMTransation {
.networks .networks
.borrow() .borrow()
.keys() .keys()
.map(|net_id| (*net_id, VMTransationNetwork::default())) .map(|net_id| (*net_id, VMTransactionNetwork::default()))
.collect(), .collect(),
vm: vm.clone() vm: vm.clone()
} }
@@ -920,7 +920,7 @@ impl VMTransation {
self.id_space.next() self.id_space.next()
}; };
let obj = template.build(obj_id, self.vm); let obj = template.build(obj_id, self.vm.clone());
if let Some(storage) = obj.borrow_mut().as_mut_storage() { if let Some(storage) = obj.borrow_mut().as_mut_storage() {
for (slot_index, occupant_template) in for (slot_index, occupant_template) in
@@ -962,7 +962,7 @@ impl VMTransation {
_ => net.objects.push(obj_id), _ => net.objects.push(obj_id),
} }
} else { } else {
return Err(VMError::InvalidNetwork(net_id)); return Err(VMError::InvalidNetwork(*net_id));
} }
} }
} }

View File

@@ -9,7 +9,7 @@ use super::ObjectID;
pub mod structs; pub mod structs;
#[allow(unused)] #[allow(unused)]
pub fn object_from_prefab_template(template: &ObjectTemplate, id: ObjectID, vm: &Rc<VM>) -> Option<VMObject> { pub fn object_from_prefab_template(template: &ObjectTemplate, id: ObjectID, vm: Rc<VM>) -> Option<VMObject> {
let prefab = StationpediaPrefab::from_repr(template.prefab_info().prefab_hash); let prefab = StationpediaPrefab::from_repr(template.prefab_info().prefab_hash);
match prefab { match prefab {
// Some(StationpediaPrefab::ItemIntegratedCircuit10) => { // Some(StationpediaPrefab::ItemIntegratedCircuit10) => {

View File

@@ -73,7 +73,7 @@ impl ObjectTemplate {
} }
} }
pub fn build(&self, id: ObjectID, vm: &Rc<VM>) -> VMObject { pub fn build(&self, id: ObjectID, vm: Rc<VM>) -> VMObject {
if let Some(obj) = stationpedia::object_from_prefab_template(&self, id, vm) { if let Some(obj) = stationpedia::object_from_prefab_template(&self, id, vm) {
obj obj
} else { } else {
@@ -195,7 +195,7 @@ impl ObjectTemplate {
} }
} }
fn build_generic(&self, id: ObjectID, vm: &Rc<VM>) -> VMObject { fn build_generic(&self, id: ObjectID, vm: Rc<VM>) -> VMObject {
use ObjectTemplate::*; use ObjectTemplate::*;
match self { match self {
Structure(s) => VMObject::new( Structure(s) => VMObject::new(