mark get object as unsafe

This commit is contained in:
Corwin Kuiper 2021-03-12 13:44:25 +00:00 committed by Corwin
parent 432c7f12f0
commit bea753d81a
2 changed files with 5 additions and 3 deletions

View file

@ -52,7 +52,7 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize {
object.enable(); object.enable();
unsafe { object.clear_objects() }; unsafe { object.clear_objects() };
let mut chicken = Character { let mut chicken = Character {
object: object.get_object(0), object: unsafe { object.get_object(0) },
position: Vector2D { position: Vector2D {
x: 20 << 8, x: 20 << 8,
y: 20 << 8, y: 20 << 8,

View file

@ -102,7 +102,7 @@ impl ObjectControl {
} }
/// # Safety /// # Safety
/// Temporary /// Temporary, do not call if you currently hold an object
pub unsafe fn clear_objects(&mut self) { pub unsafe fn clear_objects(&mut self) {
let mut o = ObjectAttributeStandard::new(); let mut o = ObjectAttributeStandard::new();
o.set_mode(Mode::Hidden); o.set_mode(Mode::Hidden);
@ -124,7 +124,9 @@ impl ObjectControl {
DISPLAY_CONTROL.set(disp); DISPLAY_CONTROL.set(disp);
} }
pub fn get_object(&self, id: usize) -> ObjectStandard { /// # Safety
/// Temporary function, you must not get multiple objects with the same id
pub unsafe fn get_object(&self, id: usize) -> ObjectStandard {
assert!(id < 128, "object id must be less than 128"); assert!(id < 128, "object id must be less than 128");
ObjectStandard { ObjectStandard {
attributes: ObjectAttributeStandard::new(), attributes: ObjectAttributeStandard::new(),