Add comprehensive tests for collision detection, entity dispatch, file system, isometric controls, map rendering, and sorting
- Implemented collision tests to verify overlap and movement logic for collision bodies. - Enhanced entity dispatch entry tests to cover initialization, group ID management, and process handling. - Expanded file system tests to include crash diagnostics and ensure proper game data root detection. - Created isometric controls tests to validate movement requests and screen projection calculations. - Added map renderer tests to check fixed map loading and rendering functionality. - Introduced map sorter tests to confirm correct rendering order for various items.
This commit is contained in:
parent
8907604b84
commit
202679f857
27 changed files with 3530 additions and 81 deletions
|
|
@ -5,9 +5,59 @@
|
|||
#include <regex>
|
||||
#include <sstream>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <crtdbg.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <exception>
|
||||
#endif
|
||||
|
||||
namespace remorse {
|
||||
namespace {
|
||||
|
||||
#ifdef _WIN32
|
||||
void writeCrashMessage(const char* message)
|
||||
{
|
||||
OutputDebugStringA(message);
|
||||
const HANDLE errorOutput = GetStdHandle(STD_ERROR_HANDLE);
|
||||
if (errorOutput != nullptr && errorOutput != INVALID_HANDLE_VALUE) {
|
||||
DWORD written = 0;
|
||||
WriteFile(errorOutput, message, static_cast<DWORD>(std::strlen(message)), &written, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
LONG WINAPI reportUnhandledException(EXCEPTION_POINTERS* exception)
|
||||
{
|
||||
char message[160];
|
||||
std::snprintf(message, sizeof(message), "Unhandled exception 0x%08lX at %p\n",
|
||||
exception->ExceptionRecord->ExceptionCode, exception->ExceptionRecord->ExceptionAddress);
|
||||
writeCrashMessage(message);
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
void reportTermination() noexcept
|
||||
{
|
||||
try {
|
||||
if (const auto error = std::current_exception()) {
|
||||
std::rethrow_exception(error);
|
||||
}
|
||||
} catch (const std::exception& error) {
|
||||
char message[512];
|
||||
std::snprintf(message, sizeof(message), "Unhandled C++ exception: %s\n", error.what());
|
||||
writeCrashMessage(message);
|
||||
std::_Exit(EXIT_FAILURE);
|
||||
} catch (...) {
|
||||
writeCrashMessage("Unhandled C++ exception of unknown type\n");
|
||||
std::_Exit(EXIT_FAILURE);
|
||||
}
|
||||
writeCrashMessage("Program terminated without an active exception\n");
|
||||
std::_Exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string readTextFile(const std::filesystem::path& path)
|
||||
{
|
||||
std::ifstream input(path, std::ios::binary);
|
||||
|
|
@ -42,6 +92,23 @@ u32 readJsonU32(const std::string& json, const char* key)
|
|||
|
||||
} // namespace
|
||||
|
||||
void installCrashDiagnostics()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
||||
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
||||
_set_error_mode(_OUT_TO_STDERR);
|
||||
#ifdef _DEBUG
|
||||
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
|
||||
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
|
||||
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
|
||||
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
|
||||
#endif
|
||||
SetUnhandledExceptionFilter(reportUnhandledException);
|
||||
std::set_terminate(reportTermination);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::optional<ExportManifestSummary> loadExportManifestSummary(const std::filesystem::path& manifestPath)
|
||||
{
|
||||
const std::string json = readTextFile(manifestPath);
|
||||
|
|
@ -73,7 +140,7 @@ void printStartupReport(const ExportManifestSummary& manifest)
|
|||
std::cout << "Fallback function files: " << manifest.fallbackFunctionFiles << '\n';
|
||||
std::cout << "Global buckets: " << manifest.globalBuckets << '\n';
|
||||
std::cout << "Global definitions: " << manifest.globalDefinitions << '\n';
|
||||
std::cout << "Status: host runtime scaffold is alive; exported game code is not linked yet.\n";
|
||||
std::cout << "Status: StandProcess Run, registered timer, and keyboard diagnostic callback active; original key queue, NPC services, and game loop not linked.\n";
|
||||
}
|
||||
|
||||
} // namespace remorse
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue