Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TINSEL: Refactor a few Multi-object details #3863

Merged
merged 3 commits into from May 7, 2022
Merged

Conversation

somaen
Copy link
Member

@somaen somaen commented May 6, 2022

Some refactoring to simplify a few changes that are incoming with Noir:

  • Add a convenience version of MultiDeleteObject that behaves similarly to free/delete when nullptr is passed.
    This simplifies code in a few places, as we can then avoid some nullptr checks.

  • Combine MultiSetAniXY and MultiSetZPosition into MultiSetAniXYZ.
    The menu/inventory logic in Noir (but also the former games) does a lot of this.

  • Add a MultiBounds function so that we can get all 4 bounds in one call.
    Making for more readable code (this happens more often in Noir), as we can get shorter, more concise results when using Common::Rect

somaen added 3 commits May 6, 2022
This behaves closer to how free() and delete works, in that it's a no-op
for nullptr. Also to be slightly safer, it will set the pointer to nullptr
afterwards.

The application is slightly indiscriminate, so a few extra nullptr
writes are added, even where the pointer would be immediately assigned
a new value afterwards.
We'll need to query all 4 corners of a multi-object a few times in Noir,
so we might as well put that in a single function.
@somaen somaen requested a review from bluegr May 6, 2022
@bluegr
Copy link
Member

@bluegr bluegr commented May 7, 2022

A straightforward and well-done code cleanup. Kudos!
Merging

@bluegr bluegr merged commit 30b7ab7 into scummvm:master May 7, 2022
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants