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

This commit is contained in:
shweet committed 2026-11-23 22:17:09 -05:00
1 parent 7d407d5c19
commit ee965dad25
19 files changed
+112 -51

No files matched your search

+3 -1
View File
@@ -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,
+13 -6
View File
@@ -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(); });
+5 -5
View File
@@ -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.