[Bugfix] A transition into the first scene leaves mcrfpy.current_scene as None for the whole transition #379

Closed
opened 2026-07-14 22:24:06 +00:00 by john · 0 comments
Owner

Summary

If mcrfpy.default_transition is configured before any scene has ever been active,
activating the first scene starts a transition from nothing — and
mcrfpy.current_scene reads None for the entire duration.

import mcrfpy
s = mcrfpy.Scene("first")
s.children.append(mcrfpy.Frame(pos=(0, 0), size=(10, 10)))

mcrfpy.default_transition = mcrfpy.Transition.FADE
mcrfpy.default_transition_duration = 1.0
mcrfpy.current_scene = s

print(mcrfpy.current_scene)   # None   <-- assigned it one line ago
mcrfpy.step(0.016)
print(mcrfpy.current_scene)   # None   <-- still None
# ... only after ~1.0s of simulated time does it become <Scene 'first'>

For a scene→scene transition the current behaviour is defensible: current_scene
keeps reporting the outgoing scene until the transition completes, so "current"
means "what is on screen". But when there is no outgoing scene, that convention
yields None, and the engine spends a full second with no current scene at all.

Cause

GameEngine::changeScene(name, type, duration) (src/GameEngine.cpp:252) only takes
the immediate path when transitionType == None || duration <= 0. Otherwise it calls
transition.start(type, scene, sceneName, duration) with scene — the outgoing scene
name — which is "" at startup. It then renders the outgoing scene to a texture
(currentScene()->render()), which has nothing to render.

Fix

A transition with no outgoing scene has nothing to transition from. Take the
immediate path when the outgoing scene is empty/unknown.

How it was found

By the new tests/snippets/ gate — the documentation snippets from
mcrogueface.github.io, now executed as part of the suite. 062_scene_transition_fade.py
and 063_scene_transition_slide.py both configure a transition and then activate their
first scene, which is the natural way to write that sample. They are correct; the engine
is wrong. This is the first bug the snippet gate has caught, and it was reachable only
after #350 taught headless step() to progress transitions.

Acceptance

  • Activating the first scene with a transition configured leaves current_scene set to
    that scene immediately
  • Scene→scene transitions keep reporting the outgoing scene until completion (unchanged)
  • Regression test; the two snippets above pass
## Summary If `mcrfpy.default_transition` is configured *before* any scene has ever been active, activating the first scene starts a transition **from nothing** — and `mcrfpy.current_scene` reads `None` for the entire duration. ```python import mcrfpy s = mcrfpy.Scene("first") s.children.append(mcrfpy.Frame(pos=(0, 0), size=(10, 10))) mcrfpy.default_transition = mcrfpy.Transition.FADE mcrfpy.default_transition_duration = 1.0 mcrfpy.current_scene = s print(mcrfpy.current_scene) # None <-- assigned it one line ago mcrfpy.step(0.016) print(mcrfpy.current_scene) # None <-- still None # ... only after ~1.0s of simulated time does it become <Scene 'first'> ``` For a scene→scene transition the current behaviour is defensible: `current_scene` keeps reporting the *outgoing* scene until the transition completes, so "current" means "what is on screen". But when there is no outgoing scene, that convention yields `None`, and the engine spends a full second with no current scene at all. ## Cause `GameEngine::changeScene(name, type, duration)` (`src/GameEngine.cpp:252`) only takes the immediate path when `transitionType == None || duration <= 0`. Otherwise it calls `transition.start(type, scene, sceneName, duration)` with `scene` — the outgoing scene name — which is `""` at startup. It then renders the outgoing scene to a texture (`currentScene()->render()`), which has nothing to render. ## Fix A transition with no outgoing scene has nothing to transition *from*. Take the immediate path when the outgoing scene is empty/unknown. ## How it was found By the new `tests/snippets/` gate — the documentation snippets from mcrogueface.github.io, now executed as part of the suite. `062_scene_transition_fade.py` and `063_scene_transition_slide.py` both configure a transition and then activate their first scene, which is the natural way to write that sample. They are correct; the engine is wrong. This is the first bug the snippet gate has caught, and it was reachable only after #350 taught headless `step()` to progress transitions. ## Acceptance - Activating the first scene with a transition configured leaves `current_scene` set to that scene immediately - Scene→scene transitions keep reporting the outgoing scene until completion (unchanged) - Regression test; the two snippets above pass
john closed this issue 2026-07-15 04:32:56 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
john/McRogueFace#379
No description provided.