Convert raw pointers to coordinate-based access (closes #264, closes #265)

GridPoint and GridPointState Python objects now store (grid, x, y)
coordinates instead of raw C++ pointers. Data addresses are computed
on each property access, preventing dangling pointers after vector
resizes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-03-07 23:30:32 -05:00
commit 115e16f4f2
5 changed files with 182 additions and 61 deletions

View file

@ -22,16 +22,15 @@ class UIGridPointState;
typedef struct {
PyObject_HEAD
UIGridPoint* data;
std::shared_ptr<UIGrid> grid;
int x, y; // Grid coordinates - compute data pointer on access
} PyUIGridPointObject;
typedef struct {
PyObject_HEAD
UIGridPointState* data;
std::shared_ptr<UIGrid> grid;
std::shared_ptr<UIEntity> entity;
int x, y; // Position in grid (needed for .point property)
int x, y; // Position in grid - compute state on access
} PyUIGridPointStateObject;
// UIGridPoint - grid cell data for pathfinding and layer access