Skip to content

use idx for active camera over pointer#4605

Merged
Loobinex merged 2 commits intodkfans:masterfrom
PieterVdc:active_cam
Mar 9, 2026
Merged

use idx for active camera over pointer#4605
Loobinex merged 2 commits intodkfans:masterfrom
PieterVdc:active_cam

Conversation

@PieterVdc
Copy link
Member

@PieterVdc PieterVdc commented Mar 6, 2026

split off from #4594

Copilot AI review requested due to automatic review settings March 6, 2026 10:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::acamera with active_camera_idx and added get_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>
@Loobinex Loobinex merged commit 7554915 into dkfans:master Mar 9, 2026
@PieterVdc PieterVdc deleted the active_cam branch March 9, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants