Add extensive tests for animation, input handling, and map rendering

- Enhanced animation archive tests to validate frame metadata and start frame selection logic.
- Introduced new tests for entity dispatch entry handling, including key event queuing and processing.
- Added tests for fixed map item interactions, including glob egg hatching and item movement.
- Expanded flex archive tests to cover teleport egg spawning and usecode event selection.
- Implemented isometric controls tests to verify directional key handling and animation state changes.
- Improved map renderer tests to ensure correct rendering of map previews and collision detection.
This commit is contained in:
Maddo 2026-09-27 11:48:14 +02:00
commit e757bb33d0
20 changed files with 1247 additions and 142 deletions

View file

@ -1,8 +1,11 @@
#include "remorse/collision.h"
#include "remorse/file_system.h"
#include "remorse/flex_archive.h"
#include "remorse/fixed_map.h"
#include "remorse/glob_archive.h"
#include "remorse/type_flags.h"
#include "remorse/usecode_archive.h"
#include "remorse/usecode_vm.h"
#include <cassert>
#include <filesystem>
@ -69,6 +72,38 @@ int main()
assert(fixedMap && typeFlags);
const auto stagedItems = remorse::stageFixedMapItems(*fixedMap);
assert(stagedItems && !stagedItems->empty());
const auto spawnEgg = remorse::findTeleportEgg(*stagedItems, *typeFlags, 0x1e);
assert(spawnEgg);
const auto globPath = remorse::resolveGameDataPath(*root, std::filesystem::path("STATIC") / "GLOB.FLX");
const auto globs = globPath ? remorse::loadGlobObjects(*globPath) : std::nullopt;
assert(globs);
remorse::LiveFixedMapItems spawnedItems(*stagedItems);
const auto fastArea = remorse::calculateFastAreaRange({
spawnEgg->data.x * 2, spawnEgg->data.y * 2, spawnEgg->data.z});
unsigned hatched = 0;
for (const auto& egg : *stagedItems) {
if (egg.data.shape >= typeFlags->size() || (*typeFlags)[egg.data.shape].family != 3 ||
!remorse::isWorldPointInFastArea(egg.data.x * 2, egg.data.y * 2, fastArea)) continue;
for (const auto& glob : *globs) {
if (glob.index == egg.data.quality) {
const auto children = spawnedItems.hatchGlobEgg(egg.itemNumber, glob, *typeFlags);
if (children) hatched += static_cast<unsigned>(children->size());
break;
}
}
}
unsigned scriptChildren = 0;
for (const auto& item : spawnedItems.mapItems()) {
if (item.recordIndex != static_cast<std::size_t>(-1) || item.data.shape >= typeFlags->size()) continue;
const remorse::UsecodeItemIdentity childIdentity{item.itemNumber, item.data.shape,
item.data.flags, item.data.quality, (*typeFlags)[item.data.shape].family, false};
const auto use = remorse::selectEligibleUsecodeEvent(*usecode, *retailOwnerRows, childIdentity,
remorse::UsecodeClassBases{0, 0x800, 0x900}, 2, 1);
if (use) {
++scriptChildren;
}
}
assert(hatched == 4 && scriptChildren == 0);
const auto& staged = stagedItems->front();
assert(staged.data.shape < typeFlags->size());
const remorse::UsecodeItemIdentity stagedIdentity{staged.itemNumber, staged.data.shape,
@ -100,6 +135,18 @@ int main()
rechargeItem, retailBases, 0x200, 9);
assert(eligibleRelease && eligibleRelease->classId == 0x138 &&
eligibleRelease->className == "RECHFLNS" && eligibleRelease->body.bytes.size() == 102);
auto interpreter = remorse::UsecodeInterpreterState::initialize({0x00, 0x01});
assert(interpreter && interpreter->stackTop == 0xca && interpreter->stackLimit == 199);
assert(interpreter->valueStack[0xca] == 0x00 && interpreter->valueStack[0xcb] == 0x01);
assert(interpreter->pushCodeAddress(eligibleRelease->classId, 9));
assert(interpreter->callFrameCount == 1 && interpreter->callFrames[0].offset == 0x138 &&
interpreter->callFrames[0].segment == 9);
for (unsigned index = 1; index < 0x1f; ++index) {
assert(interpreter->pushCodeAddress(static_cast<remorse::u16>(index), 0));
}
assert(!interpreter->pushCodeAddress(0xffff, 0));
assert(interpreter->callFrameCount == 0x1f && interpreter->callFrames[31].offset == 0);
assert(!remorse::UsecodeInterpreterState::initialize(std::vector<remorse::u8>(0xcd)));
assert(!remorse::selectEligibleUsecodeEvent(*usecode, *retailOwnerRows,
rechargeItem, retailBases, 0, 9));
std::vector<remorse::u8> ownerRows(26);