use idx for active camera over pointer#4605
Merged
Loobinex merged 2 commits intodkfans:masterfrom Mar 9, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR replaces the PlayerInfo active-camera raw pointer with an index-based approach, introducing accessors and updating call sites to consistently fetch the active camera through a helper.
Changes:
- Replaced
PlayerInfo::acamerawithactive_camera_idxand addedget_player_active_camera()/set_player_active_camera(). - Updated gameplay, rendering, UI, networking, and audio code to use the new active-camera accessor instead of direct struct access.
- Adjusted view-mode switching and a few camera-dependent behaviors to tolerate missing/invalid camera pointers via checks.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/thing_traps.c | Fetches active camera via accessor before using rotation for trap shots. |
| src/thing_creature.c | Uses accessor for possession/control camera operations and zoom restore. |
| src/sounds.c | Uses accessor to locate local camera for footstep/ambient/receiver updates. |
| src/power_process.c | Uses accessor for lightning palette distance checks and lightning rendering. |
| src/player_utils.c | Keeps creature-info camera tracking aligned with active camera accessor. |
| src/player_instances.c | Updates many possession/query/zoom flows to use active camera accessor. |
| src/player_data.h | Replaces acamera field with active_camera_idx and declares new accessors. |
| src/player_data.c | Implements active camera getter/setter using the new index. |
| src/packets.c | Uses accessor for camera-driven packet processing and view restore. |
| src/net_checksums.c | Uses accessor to include camera position in desync snapshots/checksums. |
| src/main.cpp | Uses accessor for lightning proximity checks, save cleanup, and footsteps update. |
| src/local_camera.c | Uses accessor to decide whether first-person camera needs syncing. |
| src/light_data.c | Uses accessor to compute light render constraints from camera position. |
| src/gui_tooltips.c | Uses accessor for screen-to-map conversion when building gameplay tooltips. |
| src/frontmenu_ingame_map.c | Uses accessor for map overlays/rotation computations based on camera. |
| src/front_input.c | Uses accessor for bookmarks, map inputs, and screen-to-map conversion. |
| src/engine_render.c | Uses accessor for view-mode dependent rendering and local camera selection. |
| src/engine_redraw.c | Uses accessor when selecting active camera in view switching / redraw logic. |
| src/engine_camera.c | Uses accessor as the camera source for per-frame camera updates. |
| src/creature_control.c | Uses accessor to snapshot/restore view mode when starting creature control. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
split off from #4594