From c8217e5ab08986ea9c6842f7dba3e9123bdd79e3 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 13 Jan 2025 01:43:25 -0600 Subject: [PATCH] [jasper/world] Move obj states initialization to initial loading of resources --- src/jasper/modules/world/src/world.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/jasper/modules/world/src/world.cpp b/src/jasper/modules/world/src/world.cpp index c0a6da6..dd81571 100644 --- a/src/jasper/modules/world/src/world.cpp +++ b/src/jasper/modules/world/src/world.cpp @@ -23,6 +23,18 @@ ox::Error World::setupDisplay() noexcept { if (m_worldStatic.objTileRefSets.empty()) { return ox::Error{1, "WorldStatic must have at least one ref set"}; } + m_currentTicks = ticksMs(turbineCtx(m_nctx)); + m_objStates.clear(); + for (uint16_t objIdx{}; auto &obj : m_worldStatic.objTileRefSets) { + if (isUpdatingObj(obj)) { + m_objStates.emplace_back(ObjState{ + .objIdx = objIdx, + .frame = 0, + .nextUpdateTime = m_currentTicks + obj.intervalMs, + }); + } + ++objIdx; + } auto &kctx = keelCtx(m_nctx); if (m_tilesheets.empty()) { for (auto const&tsAddr : m_worldStatic.tilesheets) { @@ -62,7 +74,6 @@ ox::Result World::update() noexcept { } void World::setupTiles() noexcept { - m_objStates.clear(); m_currentTicks = ticksMs(turbineCtx(m_nctx)); ncore::setBgStatus(m_nctx, 0); // disable all backgrounds for (auto layerNo = 0u; auto const&layer : m_worldStatic.map) { @@ -95,13 +106,6 @@ void World::setupTile( .tileIdx = static_cast(obj.cbbIdx + 3), .palBank = obj.palBank, }); - if (isUpdatingObj(obj)) { - m_objStates.emplace_back(ObjState{ - .objIdx = t.objIdxRefSet, - .frame = 0, - .nextUpdateTime = m_currentTicks + obj.intervalMs, - }); - } } ox::Result World::updateObj(ObjState &state) noexcept {