From ee965dad2554437376becb1e8d4230416cf183bd Mon Sep 17 00:00:00 2001 From: shweet Date: Mon, 23 Nov 2026 22:17:09 -0500 Subject: [PATCH] Test round 2 fixes (wrong behaviour against the decompile: stats, combat, odds, level generation, visuals, the Lua API and 45 real mods): Blue Womb's last boss room is the start room (0074a500), Font:GetCharacterWidth takes a string and FontRenderSettings' wrap and truncation take a width, the original's callback error names, mod paths under --mods, SetStateFlag with a negative flag, the run timer hidden by default, popup and transformation text keys, room loads premultiply through a lookup table (about 3x faster, traces identical), --screenshot-every for windowed runs --- README.md | 3 ++ generated-src/classes.h | 2 -- generated-src/stubs.cpp | 2 -- src/engine/data.cpp | 10 ++++-- src/engine/harness.cpp | 15 +++++++++ src/engine/harness.h | 2 ++ src/engine/kage_graphics.cpp | 59 +++++++++++++++++++++++++---------- src/engine/platform.cpp | 3 +- src/engine/screenshot.h | 2 ++ src/game/game.cpp | 2 +- src/game/manager.cpp | 1 - src/level/level.cpp | 8 ++--- src/level/minimap.cpp | 7 +++-- src/lua/api_game.cpp | 4 ++- src/lua/api_sprite.cpp | 19 +++++++---- src/lua/callbacks.cpp | 10 +++--- src/ui/info_display.cpp | 2 +- src/ui/menu/online_awards.cpp | 6 ++-- src/ui/popups.cpp | 6 ++-- 19 files changed, 112 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 6cdb576..a686b7c 100644 --- a/README.md +++ b/README.md @@ -95,11 +95,14 @@ Flags on the game binary (`src/engine/harness.cpp`), deterministic: the same inp --frames N quit after N frames --trace F [--trace-every N] [--trace-detail] hashes (or the fields) of the RNGs, players and entities --mods DIR a private mods folder +--screenshot-every N a windowed run saves every Nth frame (as Isaac.GetFrameCount() counts) to screenshots/ ``` `tools/harness/run.sh SAVE WORK [flags]` runs on a fresh copy of a save folder with a private `XDG_DATA_HOME`; `tools/harness/menu.py` writes the boot-to-run menu input; `tools/harness/compare.py A B` prints the first frame and field where two traces differ; `tools/harness/bot/` is a Lua mod that plays through `MC_INPUT_ACTION`. +`tools/harness/goldens/check.sh` replays about 40 recorded runs (every character, the main and alternate floors, +bosses, Greed, challenges, saving and continuing) and names each trace that changed; `--record` re-records them. ## Quick use diff --git a/generated-src/classes.h b/generated-src/classes.h index 58dd50c..7acd03c 100644 --- a/generated-src/classes.h +++ b/generated-src/classes.h @@ -5572,7 +5572,6 @@ void FUN_004d7130(); // 004d7130 void FUN_004d7190(uint32_t *param_1); // 004d7190 void FUN_004d71f0(); // 004d71f0 void FUN_004d7250(uint32_t *param_1); // 004d7250 -void FUN_004d72b0(uint32_t param_1, char param_2); // 004d72b0 void FUN_004d7310(void *param_1, void *param_2); // 004d7310 void FUN_004d73e0(void *param_1, void *param_2, EntitySaveState *param_3); // 004d73e0 void FUN_004d7450(void *param_1, int param_2); // 004d7450 @@ -7325,7 +7324,6 @@ uint32_t FUN_008a8c80(void *param_1); // 008a8c80 uint32_t FUN_008a8ce0(void *param_1); // 008a8ce0 uint32_t FUN_008a8d80(void *param_1); // 008a8d80 uint32_t FUN_008a8dd0(void *param_1); // 008a8dd0 -uint32_t FUN_008a8e40(void *param_1); // 008a8e40 uint32_t FUN_008a8ec0(void *param_1); // 008a8ec0 uint32_t FUN_008a8f60(void *param_1); // 008a8f60 uint32_t FUN_008a8fc0(void *param_1); // 008a8fc0 diff --git a/generated-src/stubs.cpp b/generated-src/stubs.cpp index 9f11995..bc08d4c 100644 --- a/generated-src/stubs.cpp +++ b/generated-src/stubs.cpp @@ -9661,7 +9661,6 @@ void FUN_004d7130() { generated_stub("FUN_004d7130 004d7130"); } void FUN_004d7190(uint32_t *param_1) { generated_stub("FUN_004d7190 004d7190"); } void FUN_004d71f0() { generated_stub("FUN_004d71f0 004d71f0"); } void FUN_004d7250(uint32_t *param_1) { generated_stub("FUN_004d7250 004d7250"); } -void FUN_004d72b0(uint32_t param_1, char param_2) { generated_stub("FUN_004d72b0 004d72b0"); } void FUN_004d7310(void *param_1, void *param_2) { generated_stub("FUN_004d7310 004d7310"); } void FUN_004d73e0(void *param_1, void *param_2, EntitySaveState *param_3) { generated_stub("FUN_004d73e0 004d73e0"); } void FUN_004d7450(void *param_1, int param_2) { generated_stub("FUN_004d7450 004d7450"); } @@ -11419,7 +11418,6 @@ uint32_t FUN_008a8c80(void *param_1) { generated_stub("FUN_008a8c80 008a8c80"); uint32_t FUN_008a8ce0(void *param_1) { generated_stub("FUN_008a8ce0 008a8ce0"); } uint32_t FUN_008a8d80(void *param_1) { generated_stub("FUN_008a8d80 008a8d80"); } uint32_t FUN_008a8dd0(void *param_1) { generated_stub("FUN_008a8dd0 008a8dd0"); } -uint32_t FUN_008a8e40(void *param_1) { generated_stub("FUN_008a8e40 008a8e40"); } uint32_t FUN_008a8ec0(void *param_1) { generated_stub("FUN_008a8ec0 008a8ec0"); } uint32_t FUN_008a8f60(void *param_1) { generated_stub("FUN_008a8f60 008a8f60"); } uint32_t FUN_008a8fc0(void *param_1) { generated_stub("FUN_008a8fc0 008a8fc0"); } diff --git a/src/engine/data.cpp b/src/engine/data.cpp index 1648546..da0b45e 100644 --- a/src/engine/data.cpp +++ b/src/engine/data.cpp @@ -19,12 +19,18 @@ std::string dataDirectory = "resources/"; std::string languageDirectory; // A game path lowercased with forward slashes, as the game normalizes every path before a lookup. A path already under -// the resources, which mods build from their script's path as the original's absolute ones, stays there. +// the resources or the mods folder, which mods build from their script's path as the original's absolute ones, stays +// there. static std::string path_normalize(std::string_view path) { + std::string_view mods = platform.modsDirectory; + bool isModsPath = !mods.empty() && path.starts_with(mods); + if (isModsPath) path.remove_prefix(mods.size()); + std::string normalized(path); for (char& letter : normalized) letter = letter == '\\' ? '/' : (char)std::tolower((unsigned char)letter); - if (normalized.starts_with(MODS_FROM_RESOURCES)) normalized.erase(0, PARENT_FOLDER.size()); + if (isModsPath) normalized.insert(0, MODS_FOLDER); + else if (normalized.starts_with(MODS_FROM_RESOURCES)) normalized.erase(0, PARENT_FOLDER.size()); else if (normalized.starts_with(dataDirectory)) normalized.erase(0, dataDirectory.size()); return normalized; } diff --git a/src/engine/harness.cpp b/src/engine/harness.cpp index 0cd1c35..50043bf 100644 --- a/src/engine/harness.cpp +++ b/src/engine/harness.cpp @@ -3,6 +3,7 @@ #include "engine/kage_input.h" #include "engine/kage_sound.h" #include "engine/platform.h" +#include "engine/screenshot.h" #include "engine/seeds.h" #include "entity/effect/effect.h" #include "entity/familiar/familiar.h" @@ -42,6 +43,7 @@ struct HarnessFlag constexpr HarnessFlag HARNESS_FLAGS[] = { {"--headless", false}, {"--record", true}, {"--replay", true}, {"--frames", true}, {"--trace", true}, {"--trace-every", true}, {"--trace-detail", false}, {"--mods", true}, {"--mute", false}, + {"--screenshot-every", true}, }; Harness harness; @@ -97,6 +99,7 @@ void Harness::arguments_load(int argc, char** argv) else if (argument == "--trace-every") traceEvery = std::max(std::atoi(value), 1); else if (argument == "--trace-detail") traceMode = TRACE_DETAIL; else if (argument == "--mods") modsDirectory = std::string(value) + '/'; + else if (argument == "--screenshot-every") screenshotEvery = std::max(std::atoi(value), 0); } std::vector mods; @@ -241,6 +244,18 @@ void Harness::frame_end() if (frameLimit ? frame >= frameLimit : isReplayOver) platform.isQuitRequested = true; } +// Saves the finished frame as screenshots/harness-.png under the user folder on every screenshotEvery-th frame, +// counted as Isaac.GetFrameCount() counts them so a mod can tell which frames it gets. +void Harness::screenshot_save() +{ + uint64_t count = g_manager ? (uint64_t)g_manager->framecount : frame; + if (!screenshotEvery || isHeadless || count % screenshotEvery != 0) return; + + std::error_code error; + std::filesystem::create_directories(platform.userDataDirectory + SCREENSHOTS_FOLDER, error); + save_screenshot(std::string(SCREENSHOTS_FOLDER) + "/harness-" + std::to_string(count)); +} + // Closes the recording with the frame it ended on, and the trace. void Harness::shutdown() { diff --git a/src/engine/harness.h b/src/engine/harness.h index 1b040b1..6be8cc8 100644 --- a/src/engine/harness.h +++ b/src/engine/harness.h @@ -56,6 +56,7 @@ public: size_t replayNext = 0; SDL_MouseButtonFlags mouseButtons = 0; TraceMode traceMode = TRACE_HASH; + int screenshotEvery = 0; int traceEvery = 30; int traceRoom = -1; int traceStage = -1; @@ -69,6 +70,7 @@ public: void text_add(uint32_t character); SDL_MouseButtonFlags mouse_get(float* x, float* y); void frame_end(); + void screenshot_save(); void shutdown(); private: diff --git a/src/engine/kage_graphics.cpp b/src/engine/kage_graphics.cpp index 74b68ea..2ed1020 100644 --- a/src/engine/kage_graphics.cpp +++ b/src/engine/kage_graphics.cpp @@ -27,6 +27,8 @@ constexpr int RGBA_HEADER_SIZE = 4; constexpr int QUAD_INDICES = 6; constexpr int QUAD_INDEX_ORDER[QUAD_INDICES] = {0, 2, 1, 1, 2, 3}; constexpr double SRGB_GAMMA = 2.2; +constexpr int PREMULTIPLY_ALPHA_SHIFT = 8; +using PremultiplyTable = std::array; // The color draw calls take to mean "the quad's own colors". constexpr float COLOR_UNSET = -1; constexpr GLenum FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8cd9; @@ -978,10 +980,11 @@ bool Manager::shader_create(std::string_view shaderName, std::span(file), {}); - return true; + text.resize((size_t)file.tellg()); + file.seekg(0); + return (bool)file.read(text.data(), (std::streamsize)text.size()); } // 00a147e0 Builds a shader from its two GLSL files, given as the paths in files, and caches it. @@ -1054,22 +1057,42 @@ static int format_bytes(ImageFormat format) return format == IMAGE_RGB ? 3 : format == IMAGE_RGBA ? COLOR_CHANNELS : 1; } -// 00a663c0 Premultiplies RGBA texels by their alpha through the game's rounding, in gamma 2.2 for sRGB. -static void texels_premultiply(std::vector& texels) +// The exe's premultiply tables (00c23640 straight, 00c13640 in gamma 2.2 for sRGB), indexed by alpha << 8 | color. +// Built on first use from the formulas every entry of both matches. +static const PremultiplyTable& premultiply_table_get() { + auto build = [](auto premultiply) + { + PremultiplyTable table{}; + for (int alpha = 0; alpha <= UINT8_MAX; alpha++) + for (int color = 0; color <= UINT8_MAX; color++) + table[alpha << PREMULTIPLY_ALPHA_SHIFT | color] = (uint8_t)premultiply(color, alpha); + return table; + }; + + if (manager.isSrgb) + { + static PremultiplyTable srgb = build([](int color, int alpha) { + double linear = std::pow(color / (double)UINT8_MAX, SRGB_GAMMA) * alpha / UINT8_MAX; + return (int)std::floor(UINT8_MAX * std::pow(linear, 1 / SRGB_GAMMA) + 0.5); + }); + return srgb; + } + static PremultiplyTable straight = + build([](int color, int alpha) { return (color * alpha + UINT8_MAX / 2) / UINT8_MAX; }); + return straight; +} + +// 00a663c0 Premultiplies RGBA texels by their alpha through the game's table. A clear texel turns black. +static void texels_premultiply(std::span texels) +{ + const PremultiplyTable& table = premultiply_table_get(); for (size_t i = 0; i + COLOR_CHANNELS <= texels.size(); i += COLOR_CHANNELS) { int alpha = texels[i + 3]; if (alpha == UINT8_MAX) continue; for (int channel = 0; channel < 3; channel++) - { - int color = alpha ? texels[i + channel] : 0; - double linear = std::pow(color / (double)UINT8_MAX, SRGB_GAMMA) * alpha / UINT8_MAX; - double gamma = std::floor(UINT8_MAX * std::pow(linear, 1 / SRGB_GAMMA) + 0.5); - int premultiplied = (color * alpha + UINT8_MAX / 2) / UINT8_MAX; - texels[i + channel] = (uint8_t)(manager.isSrgb ? (int)gamma : premultiplied); - } - if (!alpha) texels[i + 3] = 0; + texels[i + channel] = alpha ? table[alpha << PREMULTIPLY_ALPHA_SHIFT | texels[i + channel]] : 0; } } @@ -1083,12 +1106,16 @@ static bool image_fill(ImageBase& image, const uint8_t* pixels, int pixelWidth, } int bytes = format_bytes(format); + size_t rowSize = (size_t)pixelWidth * bytes; + bool isPremultiplied = manager.isPremultipliedAlpha && format == IMAGE_RGBA; std::vector texels((size_t)image.textureWidth * image.textureHeight * bytes); for (int row = 0; row < pixelHeight; row++) - std::copy_n(pixels + (size_t)row * pixelWidth * bytes, (size_t)pixelWidth * bytes, - texels.begin() + (size_t)row * image.textureWidth * bytes); + { + uint8_t* destination = texels.data() + (size_t)row * image.textureWidth * bytes; + std::copy_n(pixels + row * rowSize, rowSize, destination); + if (isPremultiplied) texels_premultiply({destination, rowSize}); + } image.format = format; - if (manager.isPremultipliedAlpha && format == IMAGE_RGBA) texels_premultiply(texels); return image.texels_load(texels); } diff --git a/src/engine/platform.cpp b/src/engine/platform.cpp index c4599ac..5824546 100644 --- a/src/engine/platform.cpp +++ b/src/engine/platform.cpp @@ -292,9 +292,10 @@ bool Platform::window_open() return true; } -// Shows the finished frame, as glfwSwapBuffers. +// Shows the finished frame, as glfwSwapBuffers, after the harness's screenshot of it. void Platform::window_swap() { + harness.screenshot_save(); SDL_GL_SwapWindow(window); } diff --git a/src/engine/screenshot.h b/src/engine/screenshot.h index c74151a..c527f7e 100644 --- a/src/engine/screenshot.h +++ b/src/engine/screenshot.h @@ -2,4 +2,6 @@ #include +constexpr const char* SCREENSHOTS_FOLDER = "screenshots"; + void save_screenshot(std::string_view name); diff --git a/src/game/game.cpp b/src/game/game.cpp index aba4e4d..f97351c 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -95,7 +95,7 @@ void coop_awards_load(std::array& awards) const CoopAwardRule& rule = COOP_AWARD_RULES[i]; CoopAward& award = awards[i]; - award.name = g_manager->stringTable.translate(COOP_AWARD_KEYS[i]); + award.name = string_table_translate(g_manager->stringTable, COOP_AWARD_KEYS[i]); award.statId = rule.statId; award.isTieShared = rule.isTieShared; award.isMostWins = rule.isMostWins; diff --git a/src/game/manager.cpp b/src/game/manager.cpp index 84eae88..d070aeb 100644 --- a/src/game/manager.cpp +++ b/src/game/manager.cpp @@ -192,7 +192,6 @@ constexpr int UPDATE_FRAME_PERIOD = 2; constexpr int CURSOR_VISIBLE_FRAMES = 300; constexpr const char* CURSOR_CLICKED_ANIMATION = "Clicked"; constexpr int SCREENSHOT_KEY = 298; -constexpr const char* SCREENSHOTS_FOLDER = "screenshots"; constexpr const char* MANUAL_SCREENSHOT = "screenshots/ManualScreenshot"; // The stage bar's icon for a stage not reached. constexpr int STAGE_ICON_EMPTY = 17; diff --git a/src/level/level.cpp b/src/level/level.cpp index f512968..556fe4c 100644 --- a/src/level/level.cpp +++ b/src/level/level.cpp @@ -3211,9 +3211,9 @@ constexpr std::array BLUE_WOMB_ROOMS = {{ {{6, 4}, ROOMSHAPE_2x2, {6, 5}, DIRECTION_UP, ROOM_BOSS}, }}; -// 0074a500 Lays out the Blue Womb by hand from its own rooms, Tainted Keeper's shop when he plays. Then the rooms off -// the map, all drawn from the generation RNG: the error room, black market, crawl space, Mega Satan's, the Void's -// entrance, the Member Card's shop and the angel shop. +// 0074a500 Lays out the Blue Womb by hand from its own rooms, Tainted Keeper's shop when he plays, the start room +// counted the last boss room as in Greed. Then the rooms off the map, all drawn from the generation RNG: the error +// room, black market, crawl space, Mega Satan's, the Void's entrance, the Member Card's shop and the angel shop. void Level::generate_blue_womb() { RoomConfig& roomConfig = g_game->roomConfig; @@ -3246,7 +3246,7 @@ void Level::generate_blue_womb() nbRooms = 0; for (size_t i = 0; i < BLUE_WOMB_ROOMS.size(); i++) place_room(generator.rooms[i], configs[i], generationRNG.Next(), nullptr); - lastBossRoomListIdx = generator.rooms.back().generationIndex; + lastBossRoomListIdx = generator.rooms[0].generationIndex; RoomQuery voidQuery = room_query(STAGE_ID_BLUE_WOMB, ROOM_DEFAULT, 1); diff --git a/src/level/minimap.cpp b/src/level/minimap.cpp index 535d095..92024c8 100644 --- a/src/level/minimap.cpp +++ b/src/level/minimap.cpp @@ -832,8 +832,9 @@ Vector Minimap::GetDisplayedSize() return vector_make(map.boundsMax.x - map.boundsMin.x, map.boundsMax.y - map.boundsMin.y); } -// 0098e4d0 Draws the maps as far as they show through the room transition's HUD fade, then the time and score, -// outside the no HUD seed. Home's dungeon shows only the time and score, and only in a daily run. +// 0098e4d0 Draws the maps as far as they show through the room transition's HUD fade, then the time and score as far +// as the large map shows (at least half shown under the extra HUD), outside the no HUD seed. Home's dungeon shows +// only the time and score, and only in a daily run. void Minimap::Render() { Game& game = *g_game; @@ -854,7 +855,7 @@ void Minimap::Render() if (largeAlpha > 0) render_large(largeAlpha, isLost); bool isHistoryShown = g_manager->optionsConfig.historyHudMode == HISTORY_HUD_ON; - float scoreAlpha = isHistoryShown ? std::max(SCORE_HISTORY_ALPHA, hudAlpha) : hudAlpha; + float scoreAlpha = isHistoryShown ? std::max(SCORE_HISTORY_ALPHA, largeAlpha) : largeAlpha; if (scoreAlpha > 0) render_score_time(scoreAlpha); } diff --git a/src/lua/api_game.cpp b/src/lua/api_game.cpp index da4579a..56dce22 100644 --- a/src/lua/api_game.cpp +++ b/src/lua/api_game.cpp @@ -251,8 +251,10 @@ static void game_register(lua_State* state) lua_method(state, "IsPaused", [](Game& game) { return game.IsPaused(); }); lua_method(state, "IsGreedMode", [](Game& game) { return game.IsGreedMode(); }); lua_method(state, "GetStateFlag", [](Game& game, GameStateFlag flag) { return game.GetStateFlag(flag); }); + // 004d72b0 A negative flag is flag 0. lua_method(state, "SetStateFlag", [](Game& game, int flag, bool isSet) { - game.gameStateFlags = isSet ? game.gameStateFlags | 1ull << flag : game.gameStateFlags & ~(1ull << flag); + uint64_t mask = 1ull << std::max(flag, 0); + game.gameStateFlags = isSet ? game.gameStateFlags | mask : game.gameStateFlags & ~mask; }); lua_method(state, "ShakeScreen", [](Game&, int timeout) { game_shake_screen(timeout); }); lua_method(state, "Spawn", [](Game& game, int type, int variant, Vector position, Vector velocity, Entity* spawner, diff --git a/src/lua/api_sprite.cpp b/src/lua/api_sprite.cpp index 9ff413f..8a412cc 100644 --- a/src/lua/api_sprite.cpp +++ b/src/lua/api_sprite.cpp @@ -104,12 +104,17 @@ static void font_register(lua_State* state) lua_method(state, "SetMaxCharacters", [](FontSettings& settings, int16_t count) { settings.maxCharacters = count; }); lua_method(state, "GetMaxCharacters", [](FontSettings& settings) { return settings.maxCharacters; }); - lua_method(state, "EnableAutoWrap", [](FontSettings& settings, bool isOn) { - settings.wrapMode = isOn ? FONT_WRAP_WORDS : FONT_WRAP_NONE; + // 0085e450 Wraps lines at a width, resetting the line height modifier. + lua_method(state, "EnableAutoWrap", [](FontSettings& settings, uint16_t width) { + settings.wrapMode = FONT_WRAP_WORDS; + settings.maxLineWidth = width; + settings.lineHeightModifier = 1; }); lua_method(state, "IsAutoWrapEnabled", [](FontSettings& settings) { return settings.wrapMode == FONT_WRAP_WORDS; }); - lua_method(state, "EnableTruncation", [](FontSettings& settings, bool isOn) { - settings.wrapMode = isOn ? FONT_WRAP_TRUNCATE : FONT_WRAP_NONE; + // 00a1a600 Truncates lines at a width. + lua_method(state, "EnableTruncation", [](FontSettings& settings, uint16_t width) { + settings.wrapMode = FONT_WRAP_TRUNCATE; + settings.maxLineWidth = width; }); lua_method(state, "IsTruncationEnabled", [](FontSettings& settings) { return settings.wrapMode == FONT_WRAP_TRUNCATE; }); @@ -128,8 +133,10 @@ static void font_register(lua_State* state) lua_method(state, "Load", [](Font& font, std::string_view path) { return font.Load(path); }); lua_method(state, "Unload", [](Font& font) { font.Unload(); }); lua_method(state, "IsLoaded", [](Font& font) { return font.isLoaded; }); - lua_method(state, "GetCharacterWidth", - [](Font& font, uint32_t character) { return font.GetCharacterWidth(character); }); + // 008a8e40 GetCharacterWidth takes a string and measures its first byte. + lua_method(state, "GetCharacterWidth", [](Font& font, std::string_view text) { + return font.GetCharacterWidth(text.empty() ? 0 : (uint8_t)text[0]); + }); lua_method(state, "GetStringWidth", [](Font& font, std::string_view text) { return font.GetStringWidth(text); }); lua_method(state, "GetLineHeight", [](Font& font) { return font.GetLineHeight(); }); lua_method(state, "GetBaselineHeight", [](Font& font) { return font.GetBaselineHeight(); }); diff --git a/src/lua/callbacks.cpp b/src/lua/callbacks.cpp index 967c4ed..44b1ae0 100644 --- a/src/lua/callbacks.cpp +++ b/src/lua/callbacks.cpp @@ -273,7 +273,7 @@ int LuaEngine::PreGetCollectible(const LuaCollectibleDraw& draw) bool LuaEngine::EntityTakeDamage(Entity* entity, float damage, uint64_t damageFlags, const EntityRef& source, int countdown) { - CallbackRun run = {"EntityTakeDamage", MC_ENTITY_TAKE_DMG, entity->type}; + CallbackRun run = {"PreEntityTakeDamage", MC_ENTITY_TAKE_DMG, entity->type}; return callback_boolean_run(*this, run, true, entity, damage, damageFlags, &source, countdown); } @@ -287,7 +287,7 @@ bool LuaEngine::PreEntityDevolve(Entity* entity) // The original throws past its callers on a Lua error. This logs it and spawns the award. bool LuaEngine::PreSpawnCleanAward(const RNG& rng, const Vector& position) { - return callback_boolean_run(*this, {"PreSpawnCleanAward", MC_PRE_SPAWN_CLEAN_AWARD}, false, rng, position); + return callback_boolean_run(*this, {"PreRoomRewardSpawn", MC_PRE_SPAWN_CLEAN_AWARD}, false, rng, position); } // 00863760 Runs MC_PRE_USE_ITEM for an active item, filtered by its type. Whether a mod skips the use. @@ -370,13 +370,13 @@ void LuaEngine::EvaluateItems(Entity_Player* player, int cacheFlag) // 008635a0 Runs MC_FAMILIAR_INIT, filtered by the familiar's variant. void LuaEngine::FamiliarInit(Entity_Familiar* familiar) { - callback_notify(*this, {"FamiliarInit", MC_FAMILIAR_INIT, familiar->variant}, familiar); + callback_notify(*this, {"PostFamiliarInit", MC_FAMILIAR_INIT, familiar->variant}, familiar); } // 00860f00 Runs MC_FAMILIAR_UPDATE, filtered by the familiar's variant. void LuaEngine::FamiliarUpdate(Entity_Familiar* familiar) { - callback_notify(*this, {"FamiliarUpdate", MC_FAMILIAR_UPDATE, familiar->variant}, familiar); + callback_notify(*this, {"PostFamiliarUpdate", MC_FAMILIAR_UPDATE, familiar->variant}, familiar); } // 00860fe0 Runs MC_POST_FAMILIAR_RENDER with the render offset, filtered by the familiar's variant. @@ -561,7 +561,7 @@ void LuaEngine::PostPlayerInit(Entity_Player* player) // 00863be0 Runs MC_POST_PEFFECT_UPDATE, filtered by the player's character. void LuaEngine::PostPEffectUpdate(Entity_Player* player) { - callback_notify(*this, {"PostPEffectUpdate", MC_POST_PEFFECT_UPDATE, player->playerType}, player); + callback_notify(*this, {"PostPlayerEffectUpdate", MC_POST_PEFFECT_UPDATE, player->playerType}, player); } // 00864130 Runs MC_POST_PLAYER_UPDATE, filtered by the player's variant. diff --git a/src/ui/info_display.cpp b/src/ui/info_display.cpp index e3be0fc..2fcfb22 100644 --- a/src/ui/info_display.cpp +++ b/src/ui/info_display.cpp @@ -372,7 +372,7 @@ int form_progress_get(const ItemConfig_PlayerForm& form, const Entity_Player* pl // A transformation's line in a panel: its name and a count of the items it takes. std::string form_line_get(const ItemConfig_PlayerForm& form, int progress) { - std::string name(g_manager->stringTable.translate(form.name)); + std::string name(string_table_translate(g_manager->stringTable, form.name)); return name + FORM_SEPARATOR + std::to_string(progress) + "/" + std::to_string(FORM_GOAL); } diff --git a/src/ui/menu/online_awards.cpp b/src/ui/menu/online_awards.cpp index cd1d0a9..2e9978f 100644 --- a/src/ui/menu/online_awards.cpp +++ b/src/ui/menu/online_awards.cpp @@ -105,8 +105,8 @@ void MenuManager::online_awards_render() if (award > 0 && award % AWARD_ROWS == 0) label = vector_make(label.x + COLUMN_WIDTH, start.y); FontSettings labelSettings; - font.DrawString(isWon ? g_manager->stringTable.translate(COOP_AWARD_KEYS[award]) : UNKNOWN_TEXT, label, scale, - color, labelSettings); + std::string_view name = string_table_translate(g_manager->stringTable, COOP_AWARD_KEYS[award]); + font.DrawString(isWon ? name : UNKNOWN_TEXT, label, scale, color, labelSettings); FontSettings countSettings(ALIGN_TOP_RIGHT); font.DrawString(std::to_string(count), vector_make(label.x + COUNT_OFFSET_X, label.y), scale, color, countSettings); @@ -116,7 +116,7 @@ void MenuManager::online_awards_render() FontSettings descriptionSettings(ALIGN_TOP_CENTER); descriptionSettings.EnableAutoWrap(DESCRIPTION_WIDTH); std::string key = std::string(COOP_AWARD_KEYS[award]) + DESCRIPTION_SUFFIX; - font.DrawString(isWon ? g_manager->stringTable.translate(key) : UNKNOWN_TEXT, + font.DrawString(isWon ? string_table_translate(g_manager->stringTable, key) : UNKNOWN_TEXT, vector_add(draw.position, description->pos), scale, TEXT_COLOR, descriptionSettings); } } diff --git a/src/ui/popups.cpp b/src/ui/popups.cpp index 762d5fe..1489844 100644 --- a/src/ui/popups.cpp +++ b/src/ui/popups.cpp @@ -411,13 +411,13 @@ void Popup::select_move(int step) } while (desc.lines[selectedLine].id == POPUP_LINE_TEXT); } -// A line's text, looked up in the string tables when it starts with ##GAME## or ##PLATFORM##. +// A line's text, the #key after ##GAME## or ##PLATFORM## translated by the matching string table. static std::string_view line_text_translate(std::string_view text) { if (text.starts_with(GAME_STRING_PREFIX)) - return g_manager->stringTable.translate(text.substr(GAME_STRING_PREFIX.size())); + return string_table_translate(g_manager->stringTable, text.substr(GAME_STRING_PREFIX.size())); if (text.starts_with(PLATFORM_STRING_PREFIX)) - return g_manager->stringTablePc.translate(text.substr(PLATFORM_STRING_PREFIX.size())); + return string_table_translate(g_manager->stringTablePc, text.substr(PLATFORM_STRING_PREFIX.size())); return text; }