Categorize open issues #53–#304 into 14 system-related groups,
prioritized by impact. Recommends tackling dirty-flag bugs (#288-#291)
and dangling-pointer bugs (#270, #271, #277) first.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All tutorial parts (1-13) used the old string-based key/action
comparison API removed in 6d5e99a. Every handle_keys function now
uses mcrfpy.Key.* and mcrfpy.InputState.PRESSED enums.
Additional fixes across all parts:
- Replace manual FOV computation with ColorLayer.draw_fov() which
handles FOV calculation and explored-state tracking in one call
- Replace old grid.add_layer("color") with ColorLayer() constructor
- Fix entity removal bug: entities.remove(index) -> remove(entity_ref)
- Remove manual exploration tracking (draw_fov handles it internally)
- Use tuple positions for compute_fov/is_in_fov: (x, y) not x, y
All 14 parts (0-13) tested and passing in headless mode.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removed custom __eq__/__ne__ that allowed comparing enums to legacy string
names (e.g., Key.ESCAPE == "Escape"). Removed _legacy_names dicts and
to_legacy_string() functions. Kept from_legacy_string() in PyKey.cpp as
it's used by C++ event dispatch. Updated ~50 Python test/demo/cookbook
files to use enum members instead of string comparisons. Also updates
grid.position -> grid.pos in files that had both types of changes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Grid.position was a redundant alias for Grid.pos. Removed get_position/
set_position functions, getsetters entry, and setProperty/getProperty/
hasProperty branches. Updated all tests to use grid.pos.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sprite_number was a legacy alias for sprite_index. All code should use
sprite_index directly. Removed from getsetters, setProperty/getProperty/
hasProperty in UISprite and UIEntity, animation property handling, and
type stubs.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review of session 1b14b941 found two issues:
- Exported type count was 44 in audit doc but array has 46 entries
(EntityCollection3DIterType and one other were not counted)
- No regression test existed for the Color.__eq__/__ne__ fix
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The previous label IDs were incorrect (possibly from an older state).
Updated to match the live Gitea API as of 2026-04-09. Key differences:
- ID 2 is Minor Feature (was Alpha Release)
- ID 3 is Tiny Feature (was Bugfix)
- ID 8 is Bugfix (was tier2-foundation)
- System labels start at 9 (were at 11)
- Priority labels start at 17 (were at 7)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Color had __hash__ but no __eq__/__ne__, violating the Python convention
that hashable objects must support equality comparison. Two Color objects
with identical RGBA values would not compare equal.
Now supports comparison with Color objects, tuples, and lists:
Color(255, 0, 0) == Color(255, 0, 0) # True
Color(255, 0, 0) == (255, 0, 0) # True
Color(255, 0, 0) != (0, 0, 0) # True
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add find_all(), get_metrics(), set_scale(), and set_dev_console() as
snake_case alternatives to the existing camelCase names. The camelCase
versions remain for backward compatibility but their docstrings now
note the preferred snake_case form. All will be removed in 1.0.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace placeholder docstrings ("SFML Vector Object", "SFML Font Object",
etc.) with comprehensive constructor signatures, argument descriptions,
and property listings matching the documentation standard used by other
types like Color and Frame.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mcrfpy.Grid() now creates a GridView that internally owns a GridData (UIGrid).
The old UIGrid type is renamed to _GridData (internal). Attribute access on Grid
delegates to the underlying UIGrid via tp_getattro/tp_setattro, so all existing
Grid properties (grid_w, grid_h, entities, cells, layers, etc.) work transparently.
Key changes:
- GridView init has two modes: factory (Grid(grid_size=...)) and explicit view
(Grid(grid=existing_grid, ...)) for future multi-view support
- Entity.grid getter returns GridView wrapper via owning_view back-reference
- Entity.grid setter accepts GridView objects
- GridLayer set_grid handles GridView (extracts underlying UIGrid)
- UIDrawable::removeFromParent handles UIGRIDVIEW type correctly
- UIFrame children init accepts GridView objects
- Animation system supports GridView (center, zoom, shader.* properties)
- PythonObjectCache registration preserves subclass identity
- All 263 tests pass (100%)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `collide` kwarg to Grid.find_path() and Grid.get_dijkstra_map() that
treats entities bearing a given label as impassable obstacles via
mark-and-restore on the TCOD walkability map. Dijkstra cache key now
includes collide label for separate caching. Add Entity.find_path()
convenience method that delegates to the grid.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
frame_children_mutation_test: validates remove(), property mutation via
stored refs, fill_color persistence, iteration mutation, pop(), and
while-loop clearing — with visual screenshot verification.
parent_none_removal_test: validates that setting .parent = None removes
children from Frame.children and scene.children, Entity.grid = None
removal, and Grid overlay children removal.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Generates a network of bezier-curved dirt paths connecting POIs placed
via grid-distributed random selection. Uses minimum spanning tree with
extra fork edges, noise-offset control points for organic curves, and
the "pathways" edge-type Wang set for directional path tiles.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Advances to 83b3e6ce which adds Dijkstra distance maps, multi-root
Dijkstra, A* heuristic functions, and pathfinding demo.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Grid.__init__() now auto-creates a GridView that shares the Grid's
data via aliasing shared_ptr. This enables the Grid/GridView split:
- PyUIGridObject gains a `view` member (shared_ptr<UIGridView>)
- Grid.view property exposes the auto-created GridView (read-only)
- Rendering property setters (center_x/y, zoom, camera_rotation, x, y,
w, h) sync changes to the view automatically
- Grid still works as UIDrawable in scenes (no substitution) — backward
compatible with all existing code and subclasses
- GridView.grid returns the original Grid with identity preservation
- Explicit GridViews (created by user) are independent of Grid's own
rendering properties
Addresses #252. All 260 tests pass, no breaking changes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
GridView is a new UIDrawable that renders a GridData object independently.
Multiple GridViews can reference the same Grid for split-screen, minimap,
or different camera/zoom perspectives on shared grid state.
- New files: UIGridView.h/cpp with full rendering pipeline (copied from
UIGrid::render, adapted to use grid_data pointer)
- Add UIGRIDVIEW to PyObjectsEnum
- Add UIGRIDVIEW cases to all switch(derived_type()) sites:
Animation.cpp, UICollection.cpp, UIDrawable.cpp, McRFPy_API.cpp,
ImGuiSceneExplorer.cpp
- Python type: mcrfpy.GridView(grid=, pos=, size=, zoom=, fill_color=)
- Properties: grid, center, zoom, fill_color, texture
- Register type with metaclass for callback support
All 258 existing tests pass. New GridView test suite added.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix Entity3D self-reference cycle: replace raw `self` pointer with
`pyobject` strong-ref pattern matching UIEntity (closes#266)
- TileLayer inherits Grid texture when none set, in all three attachment
paths: constructor, add_layer(), and .grid property (closes#254)
- Add SpatialHash::queryCell() for O(1) entity-at-cell lookup; fix
missing spatial_hash.insert() in Entity.__init__ grid= kwarg path;
use queryCell in GridPoint.entities (closes#253)
- Add FOV dirty flag and parameter cache to skip redundant computeFOV
calls when map unchanged and params match (closes#292)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Phase 3 fix for #266 removed UIEntity::self which prevented
tp_dealloc from ever running. However, this also allowed Python
subclass wrappers (GameEntity, ZoneExit, etc.) to be GC'd while
the C++ entity lived on in a grid. Later access via grid.entities
returned a base Entity wrapper, losing all subclass methods.
Fix: Add UIEntity::pyobject field that holds a strong reference to
the Python wrapper. Set in init(), cleared when the entity leaves
a grid (die(), set_grid(None), collection removal). This keeps
subclass identity alive while in a grid, but allows proper GC when
the entity is removed. Added releasePyIdentity() helper called at
all grid exit points.
Regression test exercises Liber Noster patterns: subclass hierarchy,
isinstance() checks, combat mixins, tooltip/send methods, GC
survival, die(), pop(), remove(), and stress test with 20 entities.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
UniformCollection accessor methods checked the raw collection pointer
but never checked if the owning object was still alive. Changed owner
field from weak_ptr<UIDrawable> to weak_ptr<void> (type-erased) so
both UIDrawable and UIEntity owners can be tracked. Set owner in both
get_uniforms() paths. All accessors now check owner.lock() before
dereferencing the raw collection pointer.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add mutex lock to PythonObjectCache::lookup() - cache.find() was
unprotected against concurrent modification. Document that entity.die()
must not be called during iteration over grid.entities.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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>
UIEntity::init() stored self->data->self = (PyObject*)self with
Py_INCREF(self), creating a reference cycle that prevented entities
from ever being freed. The matching Py_DECREF never existed.
Fix: Remove the `self` field from UIEntity entirely. Replace all
read sites (iter next, getitem, get_perspective, entities_in_radius)
with PythonObjectCache lookups using serial_number, which uses weak
references and doesn't prevent garbage collection.
Also adds tp_dealloc to PyUIEntityType to properly clean up the
shared_ptr and weak references when the Python wrapper is freed.
Closes#266, closes#275
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace ~230 occurrences of PyObject_GetAttrString(McRFPy_API::mcrf_module, "TypeName")
with direct &mcrfpydef::PyXxxType references across 32 source files.
Each PyObject_GetAttrString call returns a new reference. When used inline
in PyObject_IsInstance(), that reference was immediately leaked. When used
for tp_alloc, the reference required careful Py_DECREF management that was
often missing on error paths.
Direct type references are compile-time constants that never need reference
counting, eliminating ~230 potential leak sites and removing ~100 lines of
Py_DECREF/Py_XDECREF cleanup code.
Also adds extractDrawable() helper in UICollection.cpp to replace repeated
8-way type-check-and-extract chains with a single function call.
Closes#267, closes#268
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add ensureGridstate() helper that unconditionally checks gridstate size
against current grid dimensions and resizes if mismatched. Replace all
lazy-init guards (size == 0) with ensureGridstate() calls.
Previously, gridstate was only initialized when empty. When an entity
moved to a differently-sized grid, gridstate kept the old size, causing
heap buffer overflows when updateVisibility() or at() iterated using the
new grid's dimensions.
Also adds spatial_hash.remove() calls in set_grid() before removing
entities from old grids, and replaces PyObject_GetAttrString type lookup
with direct &mcrfpydef::PyUIGridType reference.
Closes#258, closes#259, closes#260, closes#261, closes#262,
closes#263, closes#274, closes#276, closes#278
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Game code uses standard Python file I/O to mcrfpy.save_dir with no platform
branching. On WASM, builtins.open() is monkeypatched so writes to /save/
auto-sync IDBFS on close, making persistence transparent.
API: mcrfpy.save_dir (str), mcrfpy._sync_storage() (auto-called on WASM)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New workflow for game developers: run mcrf-init to create a project
directory with symlinks to a pre-built engine, then just write Python
scripts and assets. Games package for distribution (Linux/Windows/WASM)
without ever rebuilding the engine.
mcrf-init.sh creates:
- build/ with symlinked binary and libs, game content in assets/ + scripts/
- build-windows/ (if engine has a Windows build)
- Makefile with run, wasm, dist-linux, dist-windows, dist-wasm targets
- Starter game.py, .gitignore, pyrightconfig.json, VERSION file
CMakeLists.txt: WASM preload paths (assets, scripts) are now
configurable via MCRF_ASSETS_DIR / MCRF_SCRIPTS_DIR cache variables,
so game project Makefiles can point WASM builds at their own content
without modifying the engine.
Also adds pyrightconfig.json for the engine repo itself (IDE support
via stubs/).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- SoundBuffer.gain(factor): new DSP method for amplitude scaling before
mixing (0.5 = half volume, 2.0 = double, clamped to int16 range)
- Fix sfxr square/saw waveform artifacts: phase now wraps at period
boundary instead of growing unbounded; noise buffer refreshes per period
- Fix PySound construction from SoundBuffer on SDL2 backend: use
loadFromSamples() directly instead of copy-assign (deleted on SDL2)
- Add Image::create(w, h, pixels) overload to HeadlessTypes and
SDL2Types for pixel data initialization
- Waveform test suite (62 lines)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extends the shade_sprite module (for merchant-shade.itch.io character
sprite sheets) with procedural faction generation and asset management:
- FactionGenerator: seed-based faction recipes with Biome, Element,
Aesthetic, and RoleType enums for thematic variety
- AssetLibrary: filesystem scanner that discovers and categorizes
layer PNGs by type (skins, clothes, hair, etc.)
- TextureCache: avoids redundant disk I/O when building many variants
- CharacterAssembler: HSL shift documentation, method improvements
- Demo expanded to 6 interactive scenes (animation viewer, HSL recolor,
character gallery, faction generator, layer compositing, equipment)
- EVALUATION.md: 7DRL readiness assessment of the full module
- 329-line faction generation test suite
Assets themselves are not included -- sprite sheets are external
dependencies, some under commercial license.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
closes#251
Two related bugs where Python garbage collection destroyed callbacks
that were still needed by live C++ objects:
1. **Drawable callbacks (all 8 types)**: tp_dealloc unconditionally called
click_unregister() etc., destroying callbacks even when the C++ object
was still alive in a parent's children vector. Fixed by guarding with
shared_ptr::use_count() <= 1 — only unregister when the Python wrapper
is the last owner.
2. **Timer GC prevention**: Active timers now hold a Py_INCREF'd reference
to their Python wrapper (Timer::py_wrapper), preventing GC while the
timer is registered in the engine. Released on stop(), one-shot fire,
or destruction. mcrfpy.Timer("name", cb, 100) now works without storing
the return value.
Also includes audio synth demo UI fixes: button click handling (don't set
on_click on Caption children), single-column slider layout, improved
Animalese contrast.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All 27 PyTypeObject declarations in namespace mcrfpydef headers changed
from `static` to `inline` (C++17), ensuring a single global instance
across translation units. This fixes the root cause of stale-type-pointer
segfaults where only the McRFPy_API.cpp copy was PyType_Ready'd.
Replaced ~20 PyTypeCache call sites and 2 PyRAII::PyTypeRef lookups with
direct &mcrfpydef::Type references. Deleted PyTypeCache.h/.cpp,
PyObjectUtils.h, and PyRAII.h (all were workarounds for the static bug).
228/228 tests pass.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>