Made sure that the objects are actually in the same movie and added a bit of documentation

This commit is contained in:
michiel2005 2023-06-02 09:41:08 +02:00 committed by kmeisthax
parent 8141e7b54c
commit aaede767fe
1 changed files with 9 additions and 4 deletions

View File

@ -1285,6 +1285,7 @@ impl Player {
display_object = Self::find_first_character_instance(
root_clip,
&down_object.as_displayobject().id(),
&down_object.as_displayobject().movie(),
);
}
@ -1495,19 +1496,23 @@ impl Player {
needs_render
}
///This searches for a display object by it's id
//TODO: is there a better place to place next two functions
///This searches for a display object by it's id.
///When a button is being held down but the mouse stops hovering over the object
///we need to know if th button is still there after goto.
//TODO: is there a better place to place next two functions?
fn find_first_character_instance<'gc>(
obj: DisplayObject<'gc>,
character_id: &CharacterId,
needed_movie: &Arc<SwfMovie>,
) -> Option<DisplayObject<'gc>> {
if let Some(parent) = obj.as_container() {
for child in parent.iter_render_list() {
if &child.id() == character_id && Arc::ptr_eq(&child.movie(), &obj.movie()) {
if &child.id() == character_id && Arc::ptr_eq(&child.movie(), needed_movie) {
return Some(child);
}
let display_object = Self::find_first_character_instance(child, character_id);
let display_object =
Self::find_first_character_instance(child, character_id, needed_movie);
if display_object.is_some() {
return display_object;
}