Split the frame loop out of main.cpp (app_loop) for SDL main callbacks
main.cpp moves to app_loop.cpp; its body becomes RunClient, a C++20 coroutine suspended at the top of each frame, driven by ava2::app::AppLoop (Start/Iterate/QueueEvent/Finish/Run). The new main.cpp uses SDL main callbacks (AVA2_MAIN_CALLBACKS, default on except Android) or the classic loop. Screenshots are byte-identical through both drivers; 54/54 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
64d25e3571
commit
f973b24abc
@@ -1378,3 +1378,28 @@ pick-up refusals, attack speed); straight-line walking only, the stuck
|
||||
watchdog is the only obstacle handling; party loot rules ignored (only own /
|
||||
unowned drops); no desktop hotkey (F9 is taken by the preview mode);
|
||||
English labels, no locale strings; does not run in `--preview-data`.
|
||||
|
||||
### 2026-10-12 Mobile step 7a — app_loop split
|
||||
|
||||
- `src/app/main.cpp` moved to `src/app/app_loop.cpp` (history kept). The
|
||||
former `main()` body is now `RunClient`, a C++20 coroutine that suspends
|
||||
at the top of every frame (`co_yield`), so start-up, frame body and
|
||||
teardown stay one function with all their locals in the coroutine frame.
|
||||
`ava2::app::AppLoop` (`app_loop.h`) drives it: `Start` (start-up up to the
|
||||
first frame), `Iterate` (one frame), `QueueEvent`, `Finish` (lets a running
|
||||
client leave the loop and tear down), `Run` (classic loop).
|
||||
- The new `src/app/main.cpp` only picks the driver: SDL main callbacks
|
||||
(`AVA2_MAIN_CALLBACKS`, default ON except Android; iOS requires it because
|
||||
UIKit owns the main thread) or a classic `main` loop (Android for now).
|
||||
With callbacks, SDL_AppEvent queues events and the frame's event pass reads
|
||||
the queue instead of `SDL_PollEvent`.
|
||||
- iOS: no software FPS cap by default (SDL_AppIterate follows the display).
|
||||
|
||||
Verified: 54/54 desktop tests; `ava2_client --phone 2400x1080@2.75
|
||||
--safe-insets 50,0,0,24 --phase game --preview-data --frames 150
|
||||
--screenshot` gives a byte-identical BMP with the callbacks and with the
|
||||
classic loop (`-DAVA2_MAIN_CALLBACKS=OFF`) compared to before the split;
|
||||
bad arguments still exit 1.
|
||||
Outstanding: Android stays on the classic loop until callbacks are tried on
|
||||
a device; the frame body is still one function (state not yet split into
|
||||
classes).
|
||||
|
||||
Reference in New Issue
Block a user