Add tests for controller fire attempt suppression and usecode interpreter functionality
- Enhanced isometric_controls_tests.cpp to include assertions for controller fire attempt suppression under various conditions. - Added tests for the Usecode interpreter in usecode_vm_tests.cpp, verifying script execution and stack manipulation. - Introduced a new PowerShell script, clean-old-build-artifacts.ps1, to facilitate the cleanup of old build artifacts in specified directories.
This commit is contained in:
parent
49a15602b6
commit
ffb1918f35
41 changed files with 3611 additions and 349 deletions
|
|
@ -7,6 +7,7 @@
|
|||
#include "remorse/entity_dispatch_entry.h"
|
||||
#include "remorse/file_system.h"
|
||||
#include "remorse/fixed_map.h"
|
||||
#include "remorse/game_start.h"
|
||||
#include "remorse/glob_archive.h"
|
||||
#include "remorse/isometric_controls.h"
|
||||
#include "remorse/map_renderer.h"
|
||||
|
|
@ -342,7 +343,16 @@ void runUsecodeTasks(AppState& state)
|
|||
remorse::UsecodeOpcodeServices services;
|
||||
services.readFarWord = [task](remorse::u16 offset, remorse::u16 segment)
|
||||
-> std::optional<remorse::u16> {
|
||||
return task->readMappedItemWord(remorse::FarPtr16{offset, segment});
|
||||
return task->readMappedFarWord(remorse::FarPtr16{offset, segment});
|
||||
};
|
||||
services.callEvent = [&app](remorse::u16 classId, remorse::u16 eventSlot)
|
||||
-> std::optional<remorse::UsecodeEventBody> {
|
||||
if (!app.usecodeArchive) {
|
||||
return std::nullopt;
|
||||
}
|
||||
const auto usecodeClass = remorse::loadUsecodeClass(*app.usecodeArchive, classId);
|
||||
return usecodeClass
|
||||
? remorse::readUsecodeEventBody(*usecodeClass, eventSlot) : std::nullopt;
|
||||
};
|
||||
services.setInfo = [&app, processId](remorse::u16 eventType, remorse::u16 sourceItem) {
|
||||
return app.diagnosticKernel.setProcessInfo(processId, eventType, sourceItem);
|
||||
|
|
@ -360,6 +370,12 @@ void runUsecodeTasks(AppState& state)
|
|||
return static_cast<remorse::u16>(keycard < 64 &&
|
||||
(app.heldKeycards & (std::uint64_t{1} << keycard)) != 0);
|
||||
}
|
||||
if (ordinal == 0xac && argumentBytes == 2) {
|
||||
const remorse::u16 shape = static_cast<remorse::u16>(arguments[0] |
|
||||
(static_cast<remorse::u16>(arguments[1]) << 8));
|
||||
return shape < app.shapeTypes.size()
|
||||
? std::optional<remorse::u16>{app.shapeTypes[shape].family} : std::nullopt;
|
||||
}
|
||||
if (ordinal == 0x15 && argumentBytes == 6) {
|
||||
return remorse::u16{0};
|
||||
}
|
||||
|
|
@ -373,10 +389,88 @@ void runUsecodeTasks(AppState& state)
|
|||
(static_cast<remorse::u16>(arguments[1]) << 8));
|
||||
const remorse::u16 segment = static_cast<remorse::u16>(arguments[2] |
|
||||
(static_cast<remorse::u16>(arguments[3]) << 8));
|
||||
const auto itemNumber = task->readMappedItemWord(remorse::FarPtr16{offset, segment});
|
||||
if (ordinal == 0x0a && argumentBytes == 4) {
|
||||
const auto itemNumber = task->readMappedFarWord(remorse::FarPtr16{offset, segment});
|
||||
if (itemNumber && app.liveItems && app.liveItems->destroyItem(*itemNumber)) {
|
||||
app.usecodeWorldMutationPending = true;
|
||||
}
|
||||
return remorse::u16{0};
|
||||
}
|
||||
if (ordinal == 0x30 && argumentBytes == 4) {
|
||||
const auto poppedItem = app.liveItems
|
||||
? app.liveItems->popItemFromEtherealVoid() : std::nullopt;
|
||||
if (poppedItem) {
|
||||
app.usecodeWorldMutationPending = true;
|
||||
}
|
||||
return poppedItem.value_or(0);
|
||||
}
|
||||
if (ordinal == 0x20 && argumentBytes == 10) {
|
||||
const remorse::u16 x = static_cast<remorse::u16>(arguments[4] |
|
||||
(static_cast<remorse::u16>(arguments[5]) << 8));
|
||||
const remorse::u16 y = static_cast<remorse::u16>(arguments[6] |
|
||||
(static_cast<remorse::u16>(arguments[7]) << 8));
|
||||
const auto poppedItem = app.liveItems
|
||||
? app.liveItems->popItemToCoords(x, y, arguments[8]) : std::nullopt;
|
||||
if (poppedItem) {
|
||||
app.usecodeWorldMutationPending = true;
|
||||
}
|
||||
return poppedItem.value_or(0);
|
||||
}
|
||||
if (ordinal == 0x19 && argumentBytes == 14) {
|
||||
const remorse::u16 shape = static_cast<remorse::u16>(arguments[4] |
|
||||
(static_cast<remorse::u16>(arguments[5]) << 8));
|
||||
const remorse::u16 frame = static_cast<remorse::u16>(arguments[6] |
|
||||
(static_cast<remorse::u16>(arguments[7]) << 8));
|
||||
const remorse::u16 x = static_cast<remorse::u16>(arguments[8] |
|
||||
(static_cast<remorse::u16>(arguments[9]) << 8));
|
||||
const remorse::u16 y = static_cast<remorse::u16>(arguments[10] |
|
||||
(static_cast<remorse::u16>(arguments[11]) << 8));
|
||||
const remorse::u8 z = arguments[12];
|
||||
if (!app.liveItems || frame > 0xff ||
|
||||
!app.liveItems->canCreateItemAt(shape, x, y, z, app.shapeTypes)) {
|
||||
return remorse::u16{0};
|
||||
}
|
||||
remorse::StagedFixedMapItem createdItem;
|
||||
createdItem.recordIndex = static_cast<std::size_t>(-1);
|
||||
createdItem.data.x = x;
|
||||
createdItem.data.y = y;
|
||||
createdItem.data.z = z;
|
||||
createdItem.data.shape = shape;
|
||||
createdItem.data.frame = static_cast<remorse::u8>(frame);
|
||||
const auto itemNumber = app.liveItems->allocateItem(createdItem);
|
||||
if (!itemNumber || !task->writeMappedFarWord(
|
||||
remorse::FarPtr16{offset, segment}, *itemNumber)) {
|
||||
return remorse::u16{0};
|
||||
}
|
||||
app.usecodeWorldMutationPending = true;
|
||||
return remorse::u16{1};
|
||||
}
|
||||
const auto itemNumber = task->readMappedFarWord(remorse::FarPtr16{offset, segment});
|
||||
if (ordinal == 0x10 && argumentBytes == 4) {
|
||||
const auto* item = itemNumber && app.liveItems
|
||||
? app.liveItems->findItem(*itemNumber) : nullptr;
|
||||
return item ? static_cast<remorse::u16>(item->data.quality & 0xff)
|
||||
: remorse::u16{0};
|
||||
}
|
||||
if (!itemNumber) {
|
||||
return std::nullopt;
|
||||
}
|
||||
if (ordinal == 0x3c && argumentBytes == 4) {
|
||||
const auto* item = app.liveItems ? app.liveItems->findItem(*itemNumber) : nullptr;
|
||||
return item && item->data.shape < app.shapeTypes.size()
|
||||
? std::optional<remorse::u16>{app.shapeTypes[item->data.shape].family}
|
||||
: std::nullopt;
|
||||
}
|
||||
if (ordinal == 0x22 && argumentBytes == 4) {
|
||||
if (!app.liveItems || !app.liveItems->pushItemToEtherealVoid(*itemNumber)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
app.usecodeWorldMutationPending = true;
|
||||
return remorse::u16{0};
|
||||
}
|
||||
if (ordinal == 0x25) {
|
||||
return remorse::u16{0};
|
||||
}
|
||||
if (ordinal == 0xea && argumentBytes == 4) {
|
||||
const auto* item = app.liveItems ? app.liveItems->findItem(*itemNumber) : nullptr;
|
||||
return item ? std::optional<remorse::u16>{static_cast<remorse::u16>(item->data.quality & 0xff)}
|
||||
|
|
@ -390,6 +484,18 @@ void runUsecodeTasks(AppState& state)
|
|||
const auto* item = app.liveItems ? app.liveItems->findItem(*itemNumber) : nullptr;
|
||||
return item ? std::optional<remorse::u16>{item->data.mapNumber} : std::nullopt;
|
||||
}
|
||||
if (ordinal == 0x09 && argumentBytes == 4) {
|
||||
const auto* item = app.liveItems ? app.liveItems->findItem(*itemNumber) : nullptr;
|
||||
return item ? std::optional<remorse::u16>{item->data.z} : std::nullopt;
|
||||
}
|
||||
if (ordinal == 0x13 && argumentBytes == 4) {
|
||||
const auto* item = app.liveItems ? app.liveItems->findItem(*itemNumber) : nullptr;
|
||||
return item ? std::optional<remorse::u16>{item->data.x} : std::nullopt;
|
||||
}
|
||||
if (ordinal == 0x14 && argumentBytes == 4) {
|
||||
const auto* item = app.liveItems ? app.liveItems->findItem(*itemNumber) : nullptr;
|
||||
return item ? std::optional<remorse::u16>{item->data.y} : std::nullopt;
|
||||
}
|
||||
if (ordinal == 0x24 && argumentBytes == 6) {
|
||||
const remorse::u16 shape = static_cast<remorse::u16>(arguments[4] |
|
||||
(static_cast<remorse::u16>(arguments[5]) << 8));
|
||||
|
|
@ -399,7 +505,7 @@ void runUsecodeTasks(AppState& state)
|
|||
app.usecodeWorldMutationPending = true;
|
||||
return remorse::u16{0};
|
||||
}
|
||||
if (ordinal == 0x59 && argumentBytes == 6) {
|
||||
if ((ordinal == 0x02 || ordinal == 0x59) && argumentBytes == 6) {
|
||||
const remorse::u8 frame = static_cast<remorse::u8>(arguments[4] |
|
||||
(static_cast<remorse::u16>(arguments[5]) << 8));
|
||||
if (!app.liveItems || !app.liveItems->setItemFrame(*itemNumber, frame)) {
|
||||
|
|
@ -621,32 +727,24 @@ void loadSceneAsync(HWND window, AppState& state)
|
|||
: remorse::WorldPoint{(minX + maxX) / 2, (minY + maxY) / 2, 0};
|
||||
remorse::MapRenderOptions options = fullSceneOptions(state.mapIndex, spawn);
|
||||
remorse::LiveFixedMapItems liveItems(std::move(*stagedItems), std::move(containedItems));
|
||||
liveItems.initializeAvatar();
|
||||
if (startingEgg) {
|
||||
std::lock_guard<std::mutex> kernelLock(state.kernelMutex);
|
||||
if (!remorse::runFreshGameTeleporterStartup(state.diagnosticKernel, liveItems,
|
||||
static_cast<remorse::u16>(state.mapIndex), 0x1e, *shapeTypes,
|
||||
state.diagnosticGroupCounts)) {
|
||||
setLoadFailure(state, L"The teleporter process could not resolve its map and egg destination.");
|
||||
if (state.mapIndex != 1 || !remorse::startFreshGameMapOne(state.diagnosticKernel,
|
||||
liveItems, *shapeTypes, state.diagnosticGroupCounts)) {
|
||||
setLoadFailure(state, L"The source-derived fresh-game start could not resolve map 1's level destination.");
|
||||
PostMessageW(window, sceneReadyMessage, 0, 0);
|
||||
return;
|
||||
}
|
||||
const auto* avatar = liveItems.findItem(1);
|
||||
const auto stagingTeleporter = avatar ? remorse::findNearbyActiveTeleportEgg(
|
||||
*avatar, liveItems.mapItems(), *shapeTypes, static_cast<remorse::u8>(state.mapIndex))
|
||||
: std::nullopt;
|
||||
if (!stagingTeleporter || !remorse::runFreshGameTeleporterStartup(
|
||||
state.diagnosticKernel, liveItems, stagingTeleporter->data.mapNumber,
|
||||
static_cast<remorse::u8>(stagingTeleporter->data.quality & 0xff), *shapeTypes,
|
||||
state.diagnosticGroupCounts)) {
|
||||
setLoadFailure(state, L"The staging teleporter could not resolve its level destination.");
|
||||
PostMessageW(window, sceneReadyMessage, 0, 0);
|
||||
return;
|
||||
}
|
||||
avatar = liveItems.findItem(1);
|
||||
spawn = remorse::WorldPoint{avatar->data.x * 2, avatar->data.y * 2, avatar->data.z};
|
||||
options.viewCenter = spawn;
|
||||
} else {
|
||||
if (!liveItems.initializeAvatar()) {
|
||||
setLoadFailure(state, L"The player item could not be initialized.");
|
||||
PostMessageW(window, sceneReadyMessage, 0, 0);
|
||||
return;
|
||||
}
|
||||
remorse::StagedFixedMapItem directStart;
|
||||
directStart.data.x = static_cast<remorse::u16>(spawn.x / 2);
|
||||
directStart.data.y = static_cast<remorse::u16>(spawn.y / 2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue