From 4ff67e2e9629dc8304153ad45aa6855053b646ad Mon Sep 17 00:00:00 2001 From: shweet Date: Tue, 24 Nov 2026 18:02:02 -0500 Subject: [PATCH] REPENTOGON phase 5, complete: the render pipeline API, the last functions, XML and behaviour patches, EntitySaveStateEx, the Log window; ASMPatch and Steam-only tests not applicable (13 rows); the REPENTOGON global exposed as version 1.1.3 (e2c5aec); LuaBridge class __type and require search fixes; coverage 2,834 of 2,834; the 12 REPENTOGON mods run without errors alone and together; 72 goldens identical from converted resources and the install --- README.md | 4 +- analysis/repentogon_coverage.tsv | 210 ++--- analysis/repentogon_overrides.tsv | 64 +- assets/repentogon/resources/font/luamini.fnt | Bin 0 -> 1975 bytes .../repentogon/resources/font/luamini_0.png | Bin 0 -> 1192 bytes .../resources/gfx/ui/bestiary_tabs.anm2 | 79 ++ .../resources/gfx/ui/bestiary_tabs.png | Bin 0 -> 22343 bytes .../resources/gfx/ui/challengesmenustuff.anm2 | 32 + .../resources/gfx/ui/changelog.anm2 | 162 ++++ .../resources/gfx/ui/changelog_tab_note.png | Bin 0 -> 1448 bytes .../resources/gfx/ui/changelog_tab_paper.anm2 | 27 + .../resources/gfx/ui/changelogpaper.png | Bin 0 -> 7907 bytes .../resources/gfx/ui/daily_destinations.anm2 | 46 + .../gfx/ui/leaderboardgoals_sketchAlt.png | Bin 0 -> 6113 bytes .../resources/gfx/ui/modsmenupentogon.anm2 | 49 + .../resources/gfx/ui/modsmenusearchbar.png | Bin 0 -> 2871 bytes .../resources/gfx/ui/modsmenuundo.png | Bin 0 -> 5307 bytes .../resources/gfx/ui/simplelazystreak.png | Bin 0 -> 571 bytes .../shaders/coloroffset_gold_mesafix.fs | 49 + assets/repentogon/scripts/main_ex.lua | 28 +- generated-src/classes.h | 2 + scripts/repentogon_coverage.py | 3 + src/engine/anm2.cpp | 5 + src/engine/filesys.cpp | 36 +- src/engine/filesys.h | 2 + src/engine/kage_graphics.cpp | 25 +- src/engine/kage_graphics.h | 2 + src/engine/kage_input.cpp | 7 + src/engine/platform.cpp | 1 + src/engine/platform.h | 3 + src/entity/collision.cpp | 11 +- src/entity/config.cpp | 39 +- src/entity/config.h | 1 + src/entity/effect/hazard.cpp | 12 +- src/entity/entity.cpp | 6 + src/entity/list.cpp | 7 + src/entity/npc/portal.cpp | 19 +- src/entity/npc/render.cpp | 2 + src/entity/pickup/item_config.cpp | 14 +- src/entity/pickup/item_config.h | 4 + src/entity/pickup/item_pool.cpp | 46 +- src/entity/pickup/pickup.cpp | 11 +- src/entity/pickup/slot.cpp | 4 + src/entity/player/frame.cpp | 2 + src/entity/player/items.cpp | 4 + src/entity/player/manager.cpp | 14 +- src/entity/player/player.cpp | 6 +- src/entity/player/player.h | 4 + src/entity/player/pockets.cpp | 2 +- src/entity/weapon/tear_flags.cpp | 9 +- src/game/debug_renderer.cpp | 9 +- src/game/end.cpp | 2 + src/game/exit.cpp | 8 + src/game/game.cpp | 26 +- src/game/manager.cpp | 29 +- src/game/mod_manager.cpp | 21 +- src/game/over.cpp | 6 + src/game/persistent_game_data.cpp | 5 + src/game/restore.cpp | 13 + src/level/backdrop.cpp | 2 +- src/level/generator.h | 2 +- src/level/greed.cpp | 16 +- src/level/grid/rock.cpp | 4 + src/level/level.cpp | 8 + src/level/path_finder.cpp | 6 +- src/level/room.cpp | 7 +- src/level/room_config.cpp | 40 +- src/level/room_config.h | 3 + src/level/room_render.cpp | 24 +- src/level/room_update.cpp | 10 + src/lua/api.cpp | 5 +- src/lua/api_isaac.cpp | 25 +- src/lua/engine.h | 9 + src/repentogon/achievements.cpp | 118 ++- src/repentogon/achievements.h | 7 + src/repentogon/api_console.cpp | 11 +- src/repentogon/api_entities.cpp | 3 + src/repentogon/api_game.cpp | 20 +- src/repentogon/api_items.cpp | 31 +- src/repentogon/api_level.cpp | 184 +++- src/repentogon/api_npc.cpp | 2 + src/repentogon/api_room.cpp | 3 +- src/repentogon/api_saves.cpp | 46 +- src/repentogon/console.cpp | 126 ++- src/repentogon/console.h | 2 + src/repentogon/controllers.cpp | 61 ++ src/repentogon/controllers.h | 14 + src/repentogon/custom_cache.cpp | 7 + src/repentogon/custom_cache.h | 1 + src/repentogon/custom_pools.cpp | 348 +++++++ src/repentogon/custom_pools.h | 25 + src/repentogon/entities.cpp | 20 + src/repentogon/entities.h | 4 + src/repentogon/gl_pipeline.cpp | 660 +++++++++++++ src/repentogon/gl_pipeline.h | 32 + src/repentogon/item_spoof.cpp | 56 +- src/repentogon/level.cpp | 143 +++ src/repentogon/level.h | 7 + src/repentogon/lua_render.cpp | 22 +- src/repentogon/lua_render.h | 8 + src/repentogon/lua_sprite.cpp | 2 +- src/repentogon/mods_menu.cpp | 284 ++++++ src/repentogon/player_api.cpp | 62 ++ src/repentogon/player_config.cpp | 29 +- src/repentogon/player_config.h | 17 + src/repentogon/player_features.cpp | 51 + src/repentogon/player_features.h | 7 + src/repentogon/pool_items.cpp | 449 +++++++++ src/repentogon/pool_items.h | 17 + src/repentogon/progress.cpp | 386 ++++++++ src/repentogon/progress.h | 40 + src/repentogon/render.cpp | 51 + src/repentogon/render.h | 7 + src/repentogon/repentogon.cpp | 2 - src/repentogon/repentogon.h | 7 +- src/repentogon/save_state_ex.cpp | 263 ++++++ src/repentogon/save_state_ex.h | 17 + src/repentogon/save_state_manager.cpp | 21 +- src/repentogon/saves.cpp | 8 +- src/repentogon/ui_patches.cpp | 44 + src/repentogon/ui_patches.h | 10 + src/repentogon/vanilla_fixes.cpp | 15 + src/repentogon/vanilla_fixes.h | 1 + src/repentogon/virtual_rooms.cpp | 385 ++++++++ src/repentogon/virtual_rooms.h | 17 + src/repentogon/xml.cpp | 8 + src/repentogon/xml.h | 1 + src/repentogon/xml_data.cpp | 869 ++++++++++++++++++ src/repentogon/xml_data.h | 6 + src/ui/console.cpp | 10 + src/ui/console.h | 1 + src/ui/console_commands.cpp | 8 +- src/ui/hud.cpp | 2 +- src/ui/menu/character.cpp | 26 +- src/ui/menu/custom_challenge.cpp | 67 +- src/ui/menu/manager.cpp | 2 +- src/ui/menu/mods.cpp | 32 +- src/ui/menu/mods.h | 1 + src/ui/menu/options.cpp | 6 + src/ui/menu/stats.cpp | 111 ++- src/ui/menu/stats.h | 10 + src/ui/nightmare_scene.cpp | 17 +- src/ui/overlay/console.cpp | 52 +- src/ui/overlay/overlay.cpp | 11 +- src/ui/overlay/overlay.h | 10 +- 145 files changed, 6414 insertions(+), 322 deletions(-) create mode 100644 assets/repentogon/resources/font/luamini.fnt create mode 100644 assets/repentogon/resources/font/luamini_0.png create mode 100644 assets/repentogon/resources/gfx/ui/bestiary_tabs.anm2 create mode 100644 assets/repentogon/resources/gfx/ui/bestiary_tabs.png create mode 100644 assets/repentogon/resources/gfx/ui/challengesmenustuff.anm2 create mode 100644 assets/repentogon/resources/gfx/ui/changelog.anm2 create mode 100644 assets/repentogon/resources/gfx/ui/changelog_tab_note.png create mode 100644 assets/repentogon/resources/gfx/ui/changelog_tab_paper.anm2 create mode 100644 assets/repentogon/resources/gfx/ui/changelogpaper.png create mode 100644 assets/repentogon/resources/gfx/ui/daily_destinations.anm2 create mode 100644 assets/repentogon/resources/gfx/ui/leaderboardgoals_sketchAlt.png create mode 100644 assets/repentogon/resources/gfx/ui/modsmenupentogon.anm2 create mode 100644 assets/repentogon/resources/gfx/ui/modsmenusearchbar.png create mode 100644 assets/repentogon/resources/gfx/ui/modsmenuundo.png create mode 100644 assets/repentogon/resources/gfx/ui/simplelazystreak.png create mode 100644 assets/repentogon/resources/shaders/coloroffset_gold_mesafix.fs create mode 100644 src/repentogon/controllers.cpp create mode 100644 src/repentogon/controllers.h create mode 100644 src/repentogon/custom_pools.cpp create mode 100644 src/repentogon/custom_pools.h create mode 100644 src/repentogon/gl_pipeline.cpp create mode 100644 src/repentogon/gl_pipeline.h create mode 100644 src/repentogon/mods_menu.cpp create mode 100644 src/repentogon/player_features.cpp create mode 100644 src/repentogon/player_features.h create mode 100644 src/repentogon/pool_items.cpp create mode 100644 src/repentogon/pool_items.h create mode 100644 src/repentogon/progress.cpp create mode 100644 src/repentogon/progress.h create mode 100644 src/repentogon/save_state_ex.cpp create mode 100644 src/repentogon/save_state_ex.h create mode 100644 src/repentogon/virtual_rooms.cpp create mode 100644 src/repentogon/virtual_rooms.h create mode 100644 src/repentogon/xml_data.cpp create mode 100644 src/repentogon/xml_data.h diff --git a/README.md b/README.md index 3bd607d..61944f8 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ scripts/ decompile.sh (print decompiled C for a function, by name regex or tools/ gitignored local tools: the resource importer and the test harness (tools/harness/) external/ static submodules: SDL3, Lua 5.3, pugixml, simdjson, Ogg, Vorbis, Theora, stb, Dear ImGui (docking) assets/ files the repository ships itself: the overlay's fonts (git-lfs), with their licences, and REPENTOGON's Lua - scripts (assets/repentogon/, GPL-2), adapted where they reach API not ported yet + scripts and the resources its menus load (assets/repentogon/, GPL-2, searched after every mount) repentogon/ shallow clone of TeamREPENTOGON/REPENTOGON (libzhl/functions/*.zhl = sigs, structs, enums) bin/ private copy of the exe (analysis input; also used to read constants) jdk/ ghidra_12.2_PUBLIC/ Temurin 21 (system java is 8, too old) and Ghidra @@ -101,7 +101,7 @@ entity/ Entity and its list, factory, config, collision, combat ui/ HUDs, popups, pause screen, cutscenes, console menu/ every menu screen (ui/menu/character, ui/menu/mods ...) overlay/ the developer overlay (CMake option ISAAC_OVERLAY, on by default): ` shows it in place of the console, - with the Console, Game Options, Mods and Debug windows on Dear ImGui + with the Console, Game Options, Mods, Debug and Log windows on Dear ImGui lua/ the Lua engine, API bindings and callbacks online/ online-only code, kept as offline stubs repentogon/ REPENTOGON's modding API built in (CMake option ISAAC_REPENTOGON, on by default, OFF builds the vanilla diff --git a/analysis/repentogon_coverage.tsv b/analysis/repentogon_coverage.tsv index 5b6ca4c..c0d3f15 100644 --- a/analysis/repentogon_coverage.tsv +++ b/analysis/repentogon_coverage.tsv @@ -1,8 +1,8 @@ kind class name location docs area status summary -function ASMPatchTest AddBytes repentogon/LuaInterfaces/LuaASM.cpp:172 misc todo debug builds only -function ASMPatchTest AddCJump repentogon/LuaInterfaces/LuaASM.cpp:174 misc todo debug builds only -function ASMPatchTest AddJump repentogon/LuaInterfaces/LuaASM.cpp:173 misc todo debug builds only -function ASMPatchTest ToASM repentogon/LuaInterfaces/LuaASM.cpp:175 misc todo debug builds only +function ASMPatchTest AddBytes repentogon/LuaInterfaces/LuaASM.cpp:172 misc na debug builds only +function ASMPatchTest AddCJump repentogon/LuaInterfaces/LuaASM.cpp:174 misc na debug builds only +function ASMPatchTest AddJump repentogon/LuaInterfaces/LuaASM.cpp:173 misc na debug builds only +function ASMPatchTest ToASM repentogon/LuaInterfaces/LuaASM.cpp:175 misc na debug builds only function Ambush GetCurrentWave repentogon/LuaInterfaces/LuaAmbush.cpp:258 Ambush.md game done function Ambush GetMaxBossChallengeWaves repentogon/LuaInterfaces/LuaAmbush.cpp:256 Ambush.md game done function Ambush GetMaxBossrushWaves repentogon/LuaInterfaces/LuaAmbush.cpp:252 Ambush.md game done @@ -194,7 +194,7 @@ function ColorParams SetShared repentogon/LuaInterfaces/LuaColorParams.cpp:129 C function Config CanRerollCollectible repentogon/LuaInterfaces/LuaItemConfig.cpp:317 ItemConfig.md items and pools done function Config GetItemsWithCustomTag repentogon/LuaInterfaces/LuaItemConfig.cpp:316 ItemConfig.md items and pools done function Config GetTaggedItems repentogon/LuaInterfaces/LuaItemConfig.cpp:315 ItemConfig.md items and pools done -function Config IsValidTrinket ItemConfig.md items and pools todo docs only: no registration found +function Config IsValidTrinket ItemConfig.md items and pools done docs only: no registration found function Console GetCommandHistory repentogon/LuaInterfaces/LuaConsole.cpp:127 Console.md console and debug done function Console GetHistory repentogon/LuaInterfaces/LuaConsole.cpp:128 Console.md console and debug done function Console PopHistory repentogon/LuaInterfaces/LuaConsole.cpp:129 Console.md console and debug done @@ -202,7 +202,7 @@ function Console PrintError repentogon/LuaInterfaces/LuaConsole.cpp:126 Console. function Console PrintWarning repentogon/LuaInterfaces/LuaConsole.cpp:130 Console.md console and debug done function Console RegisterCommand repentogon/LuaInterfaces/LuaConsole.cpp:131 Console.md console and debug done function Console RegisterMacro repentogon/LuaInterfaces/LuaConsole.cpp:132 Console.md console and debug done -function Context __pairs repentogon/LuaInterfaces/LuaRender.cpp:2402 misc todo +function Context __pairs repentogon/LuaInterfaces/LuaRender.cpp:2402 misc done function ControllerSelectMenu GetSelectedElement repentogon/LuaInterfaces/Menus/LuaControllerSelectMenu.cpp:37 hud and menus done function ControllerSelectMenu GetSprite repentogon/LuaInterfaces/Menus/LuaControllerSelectMenu.cpp:36 hud and menus done function ControllerSelectMenu SetSelectedElement repentogon/LuaInterfaces/Menus/LuaControllerSelectMenu.cpp:38 hud and menus done @@ -260,7 +260,7 @@ function DestinationQuad SetTopRight repentogon/LuaInterfaces/LuaRender.cpp:765 function DestinationQuad Shear repentogon/LuaInterfaces/LuaRender.cpp:771 render and sprites done function DestinationQuad Translate repentogon/LuaInterfaces/LuaRender.cpp:768 render and sprites done function DestinationQuad __tostring repentogon/LuaInterfaces/LuaRender.cpp:774 render and sprites done -function ElementsArray __len repentogon/LuaInterfaces/LuaRender.cpp:1807 misc todo +function ElementsArray __len repentogon/LuaInterfaces/LuaRender.cpp:1807 misc done function EntitiesSaveStateVector Clear repentogon/LuaInterfaces/LuaEntitySaveState.cpp:480 EntitiesSaveStateVector.md entities done function EntitiesSaveStateVector Get repentogon/LuaInterfaces/LuaEntitySaveState.cpp:478 EntitiesSaveStateVector.md entities done function EntitiesSaveStateVector GetByType repentogon/LuaInterfaces/LuaEntitySaveState.cpp:479 EntitiesSaveStateVector.md entities done @@ -353,7 +353,7 @@ function Entity SetWaterClipFlags repentogon/LuaInterfaces/Entities/LuaEntity.cp function Entity SetWeaknessCountdown repentogon/LuaInterfaces/Entities/LuaEntity.cpp:939 Entity.md entities done function Entity SpawnBloodEffect repentogon/LuaInterfaces/Entities/LuaEntity.cpp:902 Entity.md entities done function Entity SpawnWaterImpactEffects repentogon/LuaInterfaces/Entities/LuaEntity.cpp:903 Entity.md entities done -function Entity TeleportToRandomPosition repentogon/LuaInterfaces/Entities/LuaEntity.cpp:904 Entity.md entities todo +function Entity TeleportToRandomPosition repentogon/LuaInterfaces/Entities/LuaEntity.cpp:904 Entity.md entities done function Entity ToDelirium repentogon/LuaInterfaces/LuaDelirium.cpp:242 Entity.md entities done function Entity ToSlot repentogon/LuaInterfaces/Entities/LuaEntitySlot.cpp:167 Entity.md entities done function Entity TryThrow repentogon/LuaInterfaces/Entities/LuaEntity.cpp:905 Entity.md entities done @@ -583,7 +583,7 @@ function EntityNPC SetFlyingOverride repentogon/LuaInterfaces/Entities/LuaEntity function EntityNPC SetShieldStrength repentogon/LuaInterfaces/Entities/LuaEntityNPC.cpp:451 EntityNPC.md npc done function EntityNPC ShootMaggotProjectile repentogon/LuaInterfaces/Entities/LuaEntityNPC.cpp:482 EntityNPC.md npc done function EntityNPC SpawnBloodCloud repentogon/LuaInterfaces/Entities/LuaEntityNPC.cpp:439 EntityNPC.md npc done -function EntityNPC SpawnBloodSplash repentogon/LuaInterfaces/Entities/LuaEntityNPC.cpp:440 EntityNPC.md npc todo +function EntityNPC SpawnBloodSplash repentogon/LuaInterfaces/Entities/LuaEntityNPC.cpp:440 EntityNPC.md npc done function EntityNPC ThrowLeech repentogon/LuaInterfaces/Entities/LuaEntityNPC.cpp:485 EntityNPC.md npc done function EntityNPC ThrowMaggot repentogon/LuaInterfaces/Entities/LuaEntityNPC.cpp:480 EntityNPC.md npc done function EntityNPC ThrowMaggotAtPos repentogon/LuaInterfaces/Entities/LuaEntityNPC.cpp:481 EntityNPC.md npc done @@ -636,7 +636,7 @@ function EntityPlayer AddCacheFlags repentogon/LuaInterfaces/Entities/LuaEntityP function EntityPlayer AddCandyHeartBonus repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3822 EntityPlayer.md player done function EntityPlayer AddCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3554 player done function EntityPlayer AddCollectibleEffect repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3776 EntityPlayer.md player done -function EntityPlayer AddCustomCacheTag repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3796 EntityPlayer.md player todo +function EntityPlayer AddCustomCacheTag repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3796 EntityPlayer.md player done function EntityPlayer AddInnateCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3651 EntityPlayer.md player done function EntityPlayer AddInnateTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3657 EntityPlayer.md player done function EntityPlayer AddLeprosy repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3715 EntityPlayer.md player done @@ -698,7 +698,7 @@ function EntityPlayer GetCollectiblesList repentogon/LuaInterfaces/Entities/LuaE function EntityPlayer GetConceptionFamiliarFlags repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3671 EntityPlayer.md player done function EntityPlayer GetCostumeLayerMap repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3700 EntityPlayer.md player done function EntityPlayer GetCostumeSpriteDescs repentogon/LuaInterfaces/LuaCostumeSpriteDesc.cpp:96 EntityPlayer.md player done -function EntityPlayer GetCustomCacheValue repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3797 EntityPlayer.md player todo +function EntityPlayer GetCustomCacheValue repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3797 EntityPlayer.md player done function EntityPlayer GetD8DamageModifier repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3612 EntityPlayer.md player done function EntityPlayer GetD8FireDelayModifier repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3618 EntityPlayer.md player done function EntityPlayer GetD8RangeModifier repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3616 EntityPlayer.md player done @@ -761,7 +761,7 @@ function EntityPlayer GetMetronomeCollectibleID repentogon/LuaInterfaces/Entitie function EntityPlayer GetMontezumaRevengeCharge repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3851 EntityPlayer.md player done function EntityPlayer GetMovingBoxContents repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3596 EntityPlayer.md player done function EntityPlayer GetMultiShotParams repentogon/LuaInterfaces/LuaMultiShotParams.cpp:211 EntityPlayer.md player done -function EntityPlayer GetMultiShotPositionVelocity repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3555 EntityPlayer.md player review +function EntityPlayer GetMultiShotPositionVelocity repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3555 EntityPlayer.md player done function EntityPlayer GetNextUrethraBlockFrame repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3680 EntityPlayer.md player done function EntityPlayer GetPeeBurstCooldown repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3621 EntityPlayer.md player done function EntityPlayer GetPlanCKillCountdown repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3845 EntityPlayer.md player done @@ -788,14 +788,14 @@ function EntityPlayer GetSoulLocketBonus repentogon/LuaInterfaces/Entities/LuaEn function EntityPlayer GetSpecialGridCollision repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3737 EntityPlayer.md player done function EntityPlayer GetSpeedModifier repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3597 EntityPlayer.md player done function EntityPlayer GetSpoofedCollectiblesList repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3786 EntityPlayer.md player done -function EntityPlayer GetStatMultiplier repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3799 EntityPlayer.md player todo +function EntityPlayer GetStatMultiplier repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3799 EntityPlayer.md player done function EntityPlayer GetSuplexAimCountdown repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3828 EntityPlayer.md player done function EntityPlayer GetSuplexLandPosition repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3832 EntityPlayer.md player done function EntityPlayer GetSuplexState repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3826 EntityPlayer.md player done function EntityPlayer GetSuplexTargetPosition repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3830 EntityPlayer.md player done function EntityPlayer GetTearDisplacement repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3803 EntityPlayer.md player done function EntityPlayer GetTearRangeModifier EntityPlayer.md player done docs only: no registration found -function EntityPlayer GetTearsCap repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3798 EntityPlayer.md player todo +function EntityPlayer GetTearsCap repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3798 EntityPlayer.md player done function EntityPlayer GetTotalActiveCharge repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3562 EntityPlayer.md player done function EntityPlayer GetTrinketMultiplier repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3789 player done function EntityPlayer GetUrnSouls repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3716 EntityPlayer.md player done @@ -836,7 +836,7 @@ function EntityPlayer MorphToCoopGhost repentogon/LuaInterfaces/Entities/LuaEnti function EntityPlayer NeedsCharge repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3570 player done function EntityPlayer PlayCollectibleAnim repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3704 EntityPlayer.md player done function EntityPlayer PlayDelayedSFX repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3695 EntityPlayer.md player done -function EntityPlayer PlayItemNullAnimation repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3854 EntityPlayer.md player todo +function EntityPlayer PlayItemNullAnimation repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3854 EntityPlayer.md player done function EntityPlayer RemoveCollectibleByHistoryIndex repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3582 EntityPlayer.md player done function EntityPlayer RemoveInnateCollectible repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3652 EntityPlayer.md player done function EntityPlayer RemoveInnateTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3658 EntityPlayer.md player done @@ -939,7 +939,7 @@ function EntityPlayer Teleport repentogon/LuaInterfaces/Entities/LuaEntityPlayer function EntityPlayer TriggerRoomClear repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3644 EntityPlayer.md player done function EntityPlayer TryAddToBagOfCrafting repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3757 EntityPlayer.md player done function EntityPlayer TryDecreaseGlowingHourglassUses repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3758 EntityPlayer.md player done -function EntityPlayer TryFakeDeath repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3588 EntityPlayer.md player todo +function EntityPlayer TryFakeDeath repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3588 EntityPlayer.md player done function EntityPlayer TryForgottenThrow repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3759 EntityPlayer.md player done function EntityPlayer TryPreventDeath repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3579 EntityPlayer.md player done function EntityPlayer TryRemoveSmeltedTrinket repentogon/LuaInterfaces/Entities/LuaEntityPlayer.cpp:3760 EntityPlayer.md player done @@ -1039,13 +1039,13 @@ function Font DrawStringScaledUTF8 Font.md render and sprites done docs only: v function Font DrawStringUTF8 Font.md render and sprites done docs only: vanilla changed through a hook function Font GetStringWidth Font.md render and sprites done docs only: vanilla changed through a hook function Font GetStringWidthUTF8 Font.md render and sprites done docs only: vanilla changed through a hook -function GLShader BindFloat repentogon/LuaInterfaces/LuaRender.cpp:2141 misc todo -function GLShader BindMat2 repentogon/LuaInterfaces/LuaRender.cpp:2145 misc todo -function GLShader BindMat3 repentogon/LuaInterfaces/LuaRender.cpp:2146 misc todo -function GLShader BindMat4 repentogon/LuaInterfaces/LuaRender.cpp:2147 misc todo -function GLShader BindVec2 repentogon/LuaInterfaces/LuaRender.cpp:2142 misc todo -function GLShader BindVec3 repentogon/LuaInterfaces/LuaRender.cpp:2143 misc todo -function GLShader BindVec4 repentogon/LuaInterfaces/LuaRender.cpp:2144 misc todo +function GLShader BindFloat repentogon/LuaInterfaces/LuaRender.cpp:2141 misc done +function GLShader BindMat2 repentogon/LuaInterfaces/LuaRender.cpp:2145 misc done +function GLShader BindMat3 repentogon/LuaInterfaces/LuaRender.cpp:2146 misc done +function GLShader BindMat4 repentogon/LuaInterfaces/LuaRender.cpp:2147 misc done +function GLShader BindVec2 repentogon/LuaInterfaces/LuaRender.cpp:2142 misc done +function GLShader BindVec3 repentogon/LuaInterfaces/LuaRender.cpp:2143 misc done +function GLShader BindVec4 repentogon/LuaInterfaces/LuaRender.cpp:2144 misc done function Game AchievementUnlocksDisallowed repentogon/LuaInterfaces/LuaGame.cpp:410 Game.md game done function Game AddDebugFlags repentogon/LuaInterfaces/LuaGame.cpp:419 Game.md game done function Game AddErasedEnemy repentogon/LuaInterfaces/LuaGame.cpp:425 Game.md game done @@ -1321,8 +1321,8 @@ function Isaac RemoveModData repentogon/resources/scripts/main_ex.lua:2035 misc function Isaac RenderCollectionItem repentogon/LuaInterfaces/LuaIsaac.cpp:1104 Isaac.md render and sprites done function Isaac RenderToWorld repentogon/LuaInterfaces/LuaIsaac.cpp:1055 Isaac.md render and sprites done function Isaac ReworkBirthright repentogon/LuaInterfaces/LuaIsaac.cpp:1099 Isaac.md player done -function Isaac ReworkCollectible repentogon/LuaInterfaces/LuaIsaac.cpp:1098 Isaac.md items and pools todo -function Isaac ReworkTrinket repentogon/LuaInterfaces/LuaIsaac.cpp:1100 Isaac.md items and pools todo +function Isaac ReworkCollectible repentogon/LuaInterfaces/LuaIsaac.cpp:1098 Isaac.md items and pools done +function Isaac ReworkTrinket repentogon/LuaInterfaces/LuaIsaac.cpp:1100 Isaac.md items and pools done function Isaac RunAdditiveCallback repentogon/resources/scripts/main_ex.lua:1888 misc done defined in Lua function Isaac RunCallback repentogon/resources/scripts/main_ex.lua:1985 misc done defined in Lua function Isaac RunCallbackOverIterator repentogon/resources/scripts/main_ex.lua:1976 misc done defined in Lua @@ -1365,9 +1365,9 @@ function ItemOverlay GetPlayer repentogon/LuaInterfaces/LuaItemOverlay.cpp:83 It function ItemOverlay GetSprite repentogon/LuaInterfaces/LuaItemOverlay.cpp:81 ItemOverlay.md hud and menus done function ItemOverlay Show repentogon/LuaInterfaces/LuaItemOverlay.cpp:80 ItemOverlay.md hud and menus done function ItemPool AddBibleUpgrade repentogon/LuaInterfaces/LuaItemPool.cpp:775 ItemPool.md items and pools done -function ItemPool AddCollectible repentogon/LuaInterfaces/LuaItemPool.cpp:799 ItemPool.md items and pools todo +function ItemPool AddCollectible repentogon/LuaInterfaces/LuaItemPool.cpp:799 ItemPool.md items and pools done function ItemPool AddRoomBlacklist repentogon/LuaInterfaces/LuaItemPool.cpp:776 items and pools done -function ItemPool AddTemporaryCollectible repentogon/LuaInterfaces/LuaItemPool.cpp:800 ItemPool.md items and pools todo +function ItemPool AddTemporaryCollectible repentogon/LuaInterfaces/LuaItemPool.cpp:800 ItemPool.md items and pools done function ItemPool CanSpawnCollectible repentogon/LuaInterfaces/LuaItemPool.cpp:791 ItemPool.md items and pools done function ItemPool GetBibleUpgrades repentogon/LuaInterfaces/LuaItemPool.cpp:796 ItemPool.md items and pools done function ItemPool GetCardEx repentogon/LuaInterfaces/LuaItemPool.cpp:779 ItemPool.md items and pools done @@ -1384,7 +1384,7 @@ function ItemPool GetTrinket repentogon/LuaInterfaces/LuaItemPool.cpp:777 items function ItemPool HasCollectible repentogon/LuaInterfaces/LuaItemPool.cpp:786 ItemPool.md items and pools done function ItemPool HasTrinket repentogon/LuaInterfaces/LuaItemPool.cpp:792 ItemPool.md items and pools done function ItemPool PickCollectible repentogon/LuaInterfaces/LuaItemPool.cpp:781 ItemPool.md items and pools done -function ItemPool RemoveTemporaryCollectible repentogon/LuaInterfaces/LuaItemPool.cpp:801 ItemPool.md items and pools todo +function ItemPool RemoveTemporaryCollectible repentogon/LuaInterfaces/LuaItemPool.cpp:801 ItemPool.md items and pools done function ItemPool ResetCollectible repentogon/LuaInterfaces/LuaItemPool.cpp:797 ItemPool.md items and pools done function ItemPool SetLastPool repentogon/LuaInterfaces/LuaItemPool.cpp:790 ItemPool.md items and pools done function ItemPool UnidentifyPill repentogon/LuaInterfaces/LuaItemPool.cpp:794 ItemPool.md items and pools done @@ -1451,7 +1451,7 @@ function Level GetNeighboringRooms repentogon/LuaInterfaces/LuaLevel.cpp:367 Lev function Level HasAbandonedMineshaft repentogon/LuaInterfaces/LuaLevel.cpp:349 Level.md level and room done function Level HasMirrorDimension repentogon/LuaInterfaces/LuaLevel.cpp:350 Level.md level and room done function Level HasPhotoDoor repentogon/LuaInterfaces/LuaLevel.cpp:351 Level.md level and room done -function Level IsStageAvailable repentogon/LuaInterfaces/LuaLevel.cpp:353 Level.md level and room todo +function Level IsStageAvailable repentogon/LuaInterfaces/LuaLevel.cpp:353 Level.md level and room done function Level PlaceRoom repentogon/LuaInterfaces/LuaLevelGeneratorEntry.cpp:54 Level.md level and room done function Level SetForceSpecialQuest repentogon/LuaInterfaces/LuaLevel.cpp:356 Level.md level and room done function Level SetGreedWavesClearedWithoutRedHeartDamage repentogon/LuaInterfaces/LuaLevel.cpp:359 Level.md level and room done @@ -1461,7 +1461,7 @@ function Level TryPlaceRoomAtDoor repentogon/LuaInterfaces/LuaLevel.cpp:365 Leve function LevelGenerator GetAllRooms repentogon/LuaInterfaces/LuaLevelGenerator.cpp:794 LevelGenerator.md level and room done function LevelGenerator GetDeadEnds repentogon/LuaInterfaces/LuaLevelGenerator.cpp:795 LevelGenerator.md level and room done function LevelGenerator GetNonDeadEnds repentogon/LuaInterfaces/LuaLevelGenerator.cpp:796 LevelGenerator.md level and room done -function LevelGenerator PlaceRoom repentogon/LuaInterfaces/LuaLevelGenerator.cpp:797 LevelGenerator.md level and room todo +function LevelGenerator PlaceRoom repentogon/LuaInterfaces/LuaLevelGenerator.cpp:797 LevelGenerator.md level and room done function LevelGeneratorEntry SetAllowedDoors repentogon/LuaInterfaces/LuaLevelGeneratorEntry.cpp:59 LevelGeneratorEntry.md level and room done function LevelGeneratorEntry SetColIdx repentogon/LuaInterfaces/LuaLevelGeneratorEntry.cpp:57 LevelGeneratorEntry.md level and room done function LevelGeneratorEntry SetLineIdx repentogon/LuaInterfaces/LuaLevelGeneratorEntry.cpp:58 LevelGeneratorEntry.md level and room done @@ -1591,7 +1591,7 @@ function PersistentGameData IsItemInCollection repentogon/LuaInterfaces/LuaPersi function PersistentGameData TryUnlock repentogon/LuaInterfaces/LuaPersistentGameData.cpp:189 PersistentGameData.md persistent data and saves done function PersistentGameData Unlock repentogon/LuaInterfaces/LuaPersistentGameData.cpp:188 PersistentGameData.md persistent data and saves done function PersistentGameData Unlocked repentogon/LuaInterfaces/LuaPersistentGameData.cpp:190 PersistentGameData.md persistent data and saves done -function Pipeline NewPass repentogon/LuaInterfaces/LuaRender.cpp:2236 misc todo +function Pipeline NewPass repentogon/LuaInterfaces/LuaRender.cpp:2236 misc done function PlayerHUD GetFlashGoldHearts repentogon/LuaInterfaces/HUD/LuaPlayerHUD.cpp:142 PlayerHUD.md hud and menus done function PlayerHUD GetFlashRedHearts repentogon/LuaInterfaces/HUD/LuaPlayerHUD.cpp:138 PlayerHUD.md hud and menus done function PlayerHUD GetFlashSoulHearts repentogon/LuaInterfaces/HUD/LuaPlayerHUD.cpp:140 PlayerHUD.md hud and menus done @@ -1680,8 +1680,8 @@ function RNG RandomInt repentogon/LuaInterfaces/LuaRNG.cpp:254 RNG.md misc done function RNG RandomVector repentogon/LuaInterfaces/LuaRNG.cpp:257 RNG.md misc done function RNG SetSeed repentogon/LuaInterfaces/LuaRNG.cpp:249 RNG.md misc done function RailManager GetRailsSprite repentogon/LuaInterfaces/Room/LuaRailManager.cpp:27 RailManager.md level and room done -function RenderSet SlicePipeline repentogon/LuaInterfaces/LuaRender.cpp:2437 misc todo -function RenderSet SliceSingle repentogon/LuaInterfaces/LuaRender.cpp:2436 misc todo +function RenderSet SlicePipeline repentogon/LuaInterfaces/LuaRender.cpp:2437 misc done +function RenderSet SliceSingle repentogon/LuaInterfaces/LuaRender.cpp:2436 misc done function Renderer CreateImage repentogon/LuaInterfaces/LuaRender.cpp:3247 render and sprites done function Renderer GetClipPaneNormal repentogon/LuaInterfaces/LuaRender.cpp:3261 render and sprites done function Renderer GetClipPaneThreshold repentogon/LuaInterfaces/LuaRender.cpp:3262 render and sprites done @@ -1745,14 +1745,14 @@ function Room TriggerRestock repentogon/LuaInterfaces/Room/LuaRoom.cpp:578 Room. function Room TryGetShopDiscount repentogon/LuaInterfaces/Room/LuaRoom.cpp:557 Room.md level and room done function Room TrySpawnSpecialQuestDoor repentogon/LuaInterfaces/Room/LuaRoom.cpp:563 Room.md level and room done function Room UpdateColorModifier repentogon/LuaInterfaces/Room/LuaRoom.cpp:556 Room.md level and room done -function RoomConfig AddRooms repentogon/LuaInterfaces/Room/LuaRoomConfig.cpp:181 RoomConfig.md level and room todo +function RoomConfig AddRooms repentogon/LuaInterfaces/Room/LuaRoomConfig.cpp:181 RoomConfig.md level and room done function RoomConfig GetRandomRoom repentogon/LuaInterfaces/Room/LuaRoomConfig.cpp:179 RoomConfig.md level and room done function RoomConfig GetRoomByStageTypeAndVariant repentogon/LuaInterfaces/Room/LuaRoomConfig.cpp:178 RoomConfig.md level and room done function RoomConfig GetStage repentogon/LuaInterfaces/Room/LuaRoomConfig.cpp:180 RoomConfig.md level and room done -function RoomConfig LoadStb repentogon/LuaInterfaces/Room/LuaRoomConfig.cpp:182 RoomConfig.md level and room todo -function RoomConfigSet AddRooms repentogon/LuaInterfaces/Room/LuaRoomConfigSet.cpp:98 CcpContainer_RoomConfigSet.md level and room todo +function RoomConfig LoadStb repentogon/LuaInterfaces/Room/LuaRoomConfig.cpp:182 RoomConfig.md level and room done +function RoomConfigSet AddRooms repentogon/LuaInterfaces/Room/LuaRoomConfigSet.cpp:98 CcpContainer_RoomConfigSet.md level and room done function RoomConfigSet Get repentogon/LuaInterfaces/Room/LuaRoomConfigSet.cpp:96 CcpContainer_RoomConfigSet.md level and room done -function RoomConfigSet LoadStb repentogon/LuaInterfaces/Room/LuaRoomConfigSet.cpp:99 CcpContainer_RoomConfigSet.md level and room todo +function RoomConfigSet LoadStb repentogon/LuaInterfaces/Room/LuaRoomConfigSet.cpp:99 CcpContainer_RoomConfigSet.md level and room done function RoomConfigSet __len repentogon/LuaInterfaces/Room/LuaRoomConfigSet.cpp:97 CcpContainer_RoomConfigSet.md level and room done function RoomConfigStage GetBackdrop repentogon/LuaInterfaces/Room/LuaRoomConfigStage.cpp:168 RoomConfigStage.md level and room done function RoomConfigStage GetBossSpot repentogon/LuaInterfaces/Room/LuaRoomConfigStage.cpp:177 RoomConfigStage.md level and room done @@ -1903,25 +1903,25 @@ function Transformer Apply repentogon/LuaInterfaces/LuaRender.cpp:525 render an function Transformer IsValid repentogon/LuaInterfaces/LuaRender.cpp:526 render and sprites done function Transformer Render repentogon/LuaInterfaces/LuaRender.cpp:523 render and sprites done function Transformer RenderEx repentogon/LuaInterfaces/LuaRender.cpp:524 render and sprites done -function UnitTests Build repentogon/RoomConfigUtility.cpp:1009 misc todo debug builds only -function UnitTests CompareSaves repentogon/SaveSyncing/SaveSyncing.cpp:865 persistent data and saves todo debug builds only -function UnitTests Deserialize repentogon/RoomConfigUtility.cpp:1011 misc todo debug builds only -function UnitTests GetTestRoom repentogon/RoomConfigUtility.cpp:1008 level and room todo debug builds only -function UnitTests Serialize repentogon/RoomConfigUtility.cpp:1010 misc todo debug builds only -function UnitTests TestSync repentogon/SaveSyncing/SaveSyncing.cpp:864 misc todo debug builds only -function UnitTests ValidateCloudSave repentogon/SaveSyncing/SaveSyncing.cpp:862 persistent data and saves todo debug builds only -function UnitTests ValidateLocalSave repentogon/SaveSyncing/SaveSyncing.cpp:861 persistent data and saves todo debug builds only +function UnitTests Build repentogon/RoomConfigUtility.cpp:1009 misc na debug builds only +function UnitTests CompareSaves repentogon/SaveSyncing/SaveSyncing.cpp:865 persistent data and saves na debug builds only +function UnitTests Deserialize repentogon/RoomConfigUtility.cpp:1011 misc na debug builds only +function UnitTests GetTestRoom repentogon/RoomConfigUtility.cpp:1008 level and room na debug builds only +function UnitTests Serialize repentogon/RoomConfigUtility.cpp:1010 misc na debug builds only +function UnitTests TestSync repentogon/SaveSyncing/SaveSyncing.cpp:864 misc na debug builds only +function UnitTests ValidateCloudSave repentogon/SaveSyncing/SaveSyncing.cpp:862 persistent data and saves na debug builds only +function UnitTests ValidateLocalSave repentogon/SaveSyncing/SaveSyncing.cpp:861 persistent data and saves na debug builds only function Vector FromAngle repentogon/LuaInterfaces/LuaVector.cpp:159 Vector.md misc done function Vector Lerp repentogon/LuaInterfaces/LuaVector.cpp:182 misc done function Vector __add repentogon/LuaInterfaces/LuaVector.cpp:176 Vector.md misc done function Vector __div repentogon/LuaInterfaces/LuaVector.cpp:173 Vector.md misc done function Vector __mul repentogon/LuaInterfaces/LuaVector.cpp:170 Vector.md misc done function Vector __sub repentogon/LuaInterfaces/LuaVector.cpp:179 Vector.md misc done -function Vertex Dump repentogon/LuaInterfaces/LuaRender.cpp:1941 misc todo -function VertexBuffer GetElements repentogon/LuaInterfaces/LuaRender.cpp:2029 misc todo -function VertexBuffer GetVertex repentogon/LuaInterfaces/LuaRender.cpp:2028 misc todo -function VertexBuffer __len repentogon/LuaInterfaces/LuaRender.cpp:2030 misc todo -function VertexDescriptor AddAttribute repentogon/LuaInterfaces/LuaRender.cpp:1670 misc todo +function Vertex Dump repentogon/LuaInterfaces/LuaRender.cpp:1941 misc done +function VertexBuffer GetElements repentogon/LuaInterfaces/LuaRender.cpp:2029 misc done +function VertexBuffer GetVertex repentogon/LuaInterfaces/LuaRender.cpp:2028 misc done +function VertexBuffer __len repentogon/LuaInterfaces/LuaRender.cpp:2030 misc done +function VertexDescriptor AddAttribute repentogon/LuaInterfaces/LuaRender.cpp:1670 misc done function Weapon ClearItemAnim repentogon/LuaInterfaces/LuaWeapon.cpp:220 Weapon.md tear and weapons done function Weapon GetCharge repentogon/LuaInterfaces/LuaWeapon.cpp:210 Weapon.md tear and weapons done function Weapon GetDirection repentogon/LuaInterfaces/LuaWeapon.cpp:212 Weapon.md tear and weapons done @@ -1947,16 +1947,16 @@ function WeightedOutcomePicker GetNumOutcomes repentogon/LuaInterfaces/LuaWeight function WeightedOutcomePicker GetOutcomes repentogon/LuaInterfaces/LuaWeightedOutcomePicker.cpp:115 WeightedOutcomePicker.md items and pools done function WeightedOutcomePicker PickOutcome repentogon/LuaInterfaces/LuaWeightedOutcomePicker.cpp:116 WeightedOutcomePicker.md items and pools done function WeightedOutcomePicker RemoveOutcome repentogon/LuaInterfaces/LuaWeightedOutcomePicker.cpp:117 WeightedOutcomePicker.md items and pools done -function XMLData GetBossColorByTypeVarSub repentogon/Patches/XMLData.cpp:2489 XMLData.md items and pools todo -function XMLData GetCurrentMod repentogon/Patches/XMLData.cpp:2492 XMLData.md items and pools todo -function XMLData GetEntityByTypeVarSub repentogon/Patches/XMLData.cpp:2488 XMLData.md items and pools todo -function XMLData GetEntryById repentogon/Patches/XMLData.cpp:2485 XMLData.md items and pools todo -function XMLData GetEntryByName repentogon/Patches/XMLData.cpp:2484 XMLData.md items and pools todo -function XMLData GetEntryByOrder repentogon/Patches/XMLData.cpp:2486 XMLData.md items and pools todo -function XMLData GetEntryFromEntity repentogon/Patches/XMLData.cpp:2490 XMLData.md items and pools todo -function XMLData GetModById repentogon/Patches/XMLData.cpp:2491 XMLData.md items and pools todo -function XMLData GetNumEntries repentogon/Patches/XMLData.cpp:2487 XMLData.md items and pools todo -function _G ASMPatch repentogon/LuaInterfaces/LuaASM.cpp:276 console and debug todo debug builds only +function XMLData GetBossColorByTypeVarSub repentogon/Patches/XMLData.cpp:2489 XMLData.md items and pools done +function XMLData GetCurrentMod repentogon/Patches/XMLData.cpp:2492 XMLData.md items and pools done +function XMLData GetEntityByTypeVarSub repentogon/Patches/XMLData.cpp:2488 XMLData.md items and pools done +function XMLData GetEntryById repentogon/Patches/XMLData.cpp:2485 XMLData.md items and pools done +function XMLData GetEntryByName repentogon/Patches/XMLData.cpp:2484 XMLData.md items and pools done +function XMLData GetEntryByOrder repentogon/Patches/XMLData.cpp:2486 XMLData.md items and pools done +function XMLData GetEntryFromEntity repentogon/Patches/XMLData.cpp:2490 XMLData.md items and pools done +function XMLData GetModById repentogon/Patches/XMLData.cpp:2491 XMLData.md items and pools done +function XMLData GetNumEntries repentogon/Patches/XMLData.cpp:2487 XMLData.md items and pools done +function _G ASMPatch repentogon/LuaInterfaces/LuaASM.cpp:276 console and debug na debug builds only function _G Benchmark repentogon/LuaInit.cpp:366 persistent data and saves done function _G DumpRegistry repentogon/LuaInit.cpp:362 console and debug done function _G ExtractFunctions repentogon/LuaInit.cpp:365 console and debug done @@ -2347,7 +2347,7 @@ callback ModCallbacks MC_PRE_EFFECT_UPDATE repentogon/resources/scripts/enums_ex callback ModCallbacks MC_PRE_ENTITY_SET_COLOR repentogon/resources/scripts/enums_ex.lua:400 enums/ModCallbacks.md render and sprites done id 1486 callback ModCallbacks MC_PRE_ENTITY_THROW repentogon/resources/scripts/enums_ex.lua:42 enums/ModCallbacks.md entities done id 1040 callback ModCallbacks MC_PRE_FAMILIAR_CAN_CHARM repentogon/resources/scripts/enums_ex.lua:387 enums/ModCallbacks.md familiar done id 1473 -callback ModCallbacks MC_PRE_FAMILIAR_COLLISION enums/ModCallbacks.md familiar review id 26, vanilla callback REPENTOGON changes +callback ModCallbacks MC_PRE_FAMILIAR_COLLISION enums/ModCallbacks.md familiar done id 26, vanilla callback REPENTOGON changes callback ModCallbacks MC_PRE_FAMILIAR_GRID_COLLISION repentogon/resources/scripts/enums_ex.lua:167 enums/ModCallbacks.md familiar done id 1175 callback ModCallbacks MC_PRE_FAMILIAR_RENDER repentogon/resources/scripts/enums_ex.lua:82 enums/ModCallbacks.md familiar done id 1080 callback ModCallbacks MC_PRE_FAMILIAR_UPDATE repentogon/resources/scripts/enums_ex.lua:154 enums/ModCallbacks.md familiar done id 1162 @@ -2418,7 +2418,7 @@ callback ModCallbacks MC_PRE_NPC_MORPH repentogon/resources/scripts/enums_ex.lua callback ModCallbacks MC_PRE_NPC_RENDER repentogon/resources/scripts/enums_ex.lua:83 enums/ModCallbacks.md npc done id 1081 callback ModCallbacks MC_PRE_NPC_SPLIT repentogon/resources/scripts/enums_ex.lua:179 enums/ModCallbacks.md npc done id 1191 callback ModCallbacks MC_PRE_NPC_UPDATE_GHOST_PICKUPS repentogon/resources/scripts/enums_ex.lua:301 npc done id 1338 -callback ModCallbacks MC_PRE_OPENGL_RENDER repentogon/resources/scripts/enums_ex.lua:138 render and sprites todo id 1136 +callback ModCallbacks MC_PRE_OPENGL_RENDER repentogon/resources/scripts/enums_ex.lua:138 render and sprites done id 1136 callback ModCallbacks MC_PRE_OPEN_CHEST repentogon/resources/scripts/enums_ex.lua:405 enums/ModCallbacks.md misc done id 1491 callback ModCallbacks MC_PRE_PAUSE_SCREEN_RENDER repentogon/resources/scripts/enums_ex.lua:193 enums/ModCallbacks.md hud and menus done id 1218 callback ModCallbacks MC_PRE_PICKUP_COLLISION enums/ModCallbacks.md pickup done id 38, vanilla callback REPENTOGON changes @@ -2516,17 +2516,17 @@ xml_attribute babies.xml skin xml/babies.md player done Babies: Path to the bab xml_attribute backdrops.xml name repentogon/Patches/XMLData.cpp:269 xml/backdrops.md level and room done File "backdrops.xml": The name of the custom backdrop, for use with Isaac.GetBackdropIdByName xml_attribute backdrops.xml reftype repentogon/Patches/XMLData.cpp:615 xml/backdrops.md level and room done File "backdrops.xml": Defines the id of the backdrop to use as a base for the custom backdrop. This is useful to grab el xml_attribute bosscolors.xml name repentogon/Patches/XMLData.cpp:269 xml/bosscolors.md npc done File "bosscolors.xml": used for the GetXByName functions, should be assigned to the color node -xml_attribute challenges.xml achievements repentogon/Patches/XMLData.cpp:3443 xml/challenges.md persistent data and saves todo File "challenges.xml": Same as vanilla, comma-separated list (without spaces) of achievements required to unlock the cha -xml_attribute challenges.xml hidden repentogon/Patches/XMLData.cpp:1479 xml/challenges.md persistent data and saves todo File "challenges.xml": Anything but "false" would result in a hidden challenge that wont show up in the menu -xml_attribute challenges.xml lockeddesc repentogon/Patches/XMLData.cpp:1153 xml/challenges.md persistent data and saves todo File "challenges.xml": Hint to display instead of the challenge name when its locked, the default phrase is "LOCKED :(" -xml_attribute challenges.xml playertype repentogon/Patches/XMLData.cpp:3438 xml/challenges.md persistent data and saves todo File "challenges.xml": This now supports modded characters by using the name of the character instead of an id. For a ta -xml_attribute challenges.xml startingcard repentogon/Patches/XMLData.cpp:3442 xml/challenges.md persistent data and saves todo File "challenges.xml": This now supports modded cards by using the names of the card instead of the id. -xml_attribute challenges.xml startingitems repentogon/Patches/XMLData.cpp:3439 xml/challenges.md persistent data and saves todo File "challenges.xml": This now supports modded items by using the names of the items instead of the ids. Same format as -xml_attribute challenges.xml startingitems2 repentogon/Patches/XMLData.cpp:3440 xml/challenges.md persistent data and saves todo File "challenges.xml": This now supports modded items by using the names of the items instead of the ids. Same format as -xml_attribute challenges.xml startingtrinkets repentogon/Patches/XMLData.cpp:3441 xml/challenges.md persistent data and saves todo File "challenges.xml": This now supports modded trinkets by using the names of the trinkets instead of the ids. Same for -xml_attribute challenges.xml unlockachievement repentogon/Patches/XMLData.cpp:3444 xml/challenges.md persistent data and saves todo File "challenges.xml": Sets the achievement(preferably a modded one using the name of the achievement) to unlock when th +xml_attribute challenges.xml achievements repentogon/Patches/XMLData.cpp:3443 xml/challenges.md persistent data and saves done File "challenges.xml": Same as vanilla, comma-separated list (without spaces) of achievements required to unlock the cha +xml_attribute challenges.xml hidden repentogon/Patches/XMLData.cpp:1479 xml/challenges.md persistent data and saves done File "challenges.xml": Anything but "false" would result in a hidden challenge that wont show up in the menu +xml_attribute challenges.xml lockeddesc repentogon/Patches/XMLData.cpp:1153 xml/challenges.md persistent data and saves done File "challenges.xml": Hint to display instead of the challenge name when its locked, the default phrase is "LOCKED :(" +xml_attribute challenges.xml playertype repentogon/Patches/XMLData.cpp:3438 xml/challenges.md persistent data and saves done File "challenges.xml": This now supports modded characters by using the name of the character instead of an id. For a ta +xml_attribute challenges.xml startingcard repentogon/Patches/XMLData.cpp:3442 xml/challenges.md persistent data and saves done File "challenges.xml": This now supports modded cards by using the names of the card instead of the id. +xml_attribute challenges.xml startingitems repentogon/Patches/XMLData.cpp:3439 xml/challenges.md persistent data and saves done File "challenges.xml": This now supports modded items by using the names of the items instead of the ids. Same format as +xml_attribute challenges.xml startingitems2 repentogon/Patches/XMLData.cpp:3440 xml/challenges.md persistent data and saves done File "challenges.xml": This now supports modded items by using the names of the items instead of the ids. Same format as +xml_attribute challenges.xml startingtrinkets repentogon/Patches/XMLData.cpp:3441 xml/challenges.md persistent data and saves done File "challenges.xml": This now supports modded trinkets by using the names of the trinkets instead of the ids. Same for +xml_attribute challenges.xml unlockachievement repentogon/Patches/XMLData.cpp:3444 xml/challenges.md persistent data and saves done File "challenges.xml": Sets the achievement(preferably a modded one using the name of the achievement) to unlock when th xml_attribute costumes2.xml id repentogon/Patches/XMLData.cpp:250 xml/costumes.md player done File "costumes2.xml": Assign the same "id" to a type="none" costume and a corresponding "null" item in [items.xml](items -xml_attribute costumes2.xml name repentogon/Patches/XMLData.cpp:269 xml/costumes.md player todo File "costumes2.xml": used as a general way to identify xml nodes (when this is not present, the filename of the anm2pat +xml_attribute costumes2.xml name repentogon/Patches/XMLData.cpp:269 xml/costumes.md player done File "costumes2.xml": used as a general way to identify xml nodes (when this is not present, the filename of the anm2pat xml_attribute cutscenes.xml music repentogon/Patches/XMLData.cpp:2578 xml/cutscenes.md hud and menus done File "cutscenes.xml": used for the anm2 cutscenes, its available in vanilla but in rgon it now allows to set it to a mod xml_attribute cutscenes.xml name repentogon/Patches/XMLData.cpp:269 xml/cutscenes.md hud and menus done File "cutscenes.xml": used for the GetXByName functions (when this is not present, the filename of the gfx attribute is xml_attribute edenhair.xml gfx repentogon/Patches/XMLData.cpp:450 xml/edenhair.md player done Eden Hair: Path to the hair spritesheet, starting from the `root` (see example below). @@ -2560,7 +2560,7 @@ xml_attribute players.xml bloodytears repentogon/Patches/EntityConfigEx.cpp:156 xml_attribute players.xml bonehearts repentogon/Patches/XMLPlayerExtras.cpp:23 xml/players.md player done File "players.xml": The amount of empty bone hearts the character should start with. 1 unit = 1 bone heart xml_attribute players.xml brokenhearts repentogon/Patches/XMLPlayerExtras.cpp:27 xml/players.md player done File "players.xml": The amount of broken hearts the character should start with. 1 unit = 1 broken heart xml_attribute players.xml card repentogon/Patches/XMLData.cpp:1354 xml/players.md player done File "players.xml": This now supports a modded card by using the name of the card instead of the id. -xml_attribute players.xml completionparent repentogon/Patches/CompletionTracker.cpp:723 xml/players.md player todo File "players.xml": Used for characters that have shared completion marks with a preexistent character, like Dark Judas +xml_attribute players.xml completionparent repentogon/Patches/CompletionTracker.cpp:723 xml/players.md player done File "players.xml": Used for characters that have shared completion marks with a preexistent character, like Dark Judas xml_attribute players.xml damagemodifier xml/players.md player done File "players.xml": An inherent offset to the damage stat the character should start with. Base this offset off of Isaac xml_attribute players.xml damagemultiplier xml/players.md player done File "players.xml": Assigns a character damage multiplier, akin to those of Judas (1.35), Azazel (1.5), or Eve (0.75). N xml_attribute players.xml deathsound repentogon/Patches/ASMPatches/ASMPlayer.cpp:121 xml/players.md player done File "players.xml": Set this to define a death sound for the character whenever they would die or touch a White Fireplac @@ -2578,7 +2578,7 @@ xml_attribute players.xml innatetrinkets repentogon/Patches/ItemSpoofSystem.cpp: xml_attribute players.xml items repentogon/Patches/XMLData.cpp:3431 xml/players.md player done File "players.xml": This now supports modded items by using the names of the items instead of the ids. Same format as in xml_attribute players.xml luckmodifier xml/players.md player done File "players.xml": An inherent offset to the luck stat the character should start with. Base this offset off of Isaac's xml_attribute players.xml modcostume repentogon/Patches/NullItemsAndCostumes.cpp:13 xml/players.md player done File "players.xml": Set this to match the "id" attribute of a costume with type="none" defined in the same mod (in [cost -xml_attribute players.xml nomarks repentogon/Patches/CompletionTracker.cpp:764 xml/players.md player todo File "players.xml": If it has any value other than 'false', it will hide the completion marks for the given character +xml_attribute players.xml nomarks repentogon/Patches/CompletionTracker.cpp:764 xml/players.md player done File "players.xml": If it has any value other than 'false', it will hide the completion marks for the given character xml_attribute players.xml noshake repentogon/Patches/EntityConfigEx.cpp:145 xml/players.md player done File "players.xml": Will prevent character's shaking during stage/boss screen transition (similarly to Keeper) if set to xml_attribute players.xml rangemodifier xml/players.md player done File "players.xml": An inherent offset to the range stat the character should start with. Base this offset off of Isaac' xml_attribute players.xml redhearts repentogon/Patches/XMLPlayerExtras.cpp:22 xml/players.md player done File "players.xml": The amount of red hearts the character should start with. 1 unit = 1/2 a heart @@ -2603,7 +2603,7 @@ xml_tag backdrops.xml backdrop repentogon/Patches/XMLData.cpp:1991 xml/backdrops xml_tag backdrops.xml backdrops xml/backdrops.md level and room done tag in the docs' examples xml_tag backdrops.xml backdrops.xml xml/backdrops.md level and room done file: content and resources support xml_tag bosscolors.xml bosscolors.xml xml/bosscolors.md npc done file: content and resources support -xml_tag challenges.xml challenges.xml xml/challenges.md persistent data and saves todo file: content and resources support +xml_tag challenges.xml challenges.xml xml/challenges.md persistent data and saves done file: content and resources support xml_tag costumes2.xml costumes2.xml xml/costumes.md player done file: content and resources support xml_tag cutscenes.xml cutscenes.xml xml/cutscenes.md hud and menus done file: content and resources support xml_tag edenhair.xml edenhair repentogon/Patches/EntityConfigEx.cpp:201 xml/edenhair.md player done tag in the docs' examples @@ -2611,7 +2611,7 @@ xml_tag edenhair.xml edenhair.xml xml/edenhair.md player done file: content and xml_tag edenhair.xml hair repentogon/Patches/EntityConfigEx.cpp:201 xml/edenhair.md player done tag in the docs' examples xml_tag entities2.xml entities2.xml xml/entities.md entities done file: content and resources support xml_tag giantbook.xml giantbook.xml xml/giantbook.md hud and menus done file: content and resources support -xml_tag itempools.xml itempools.xml xml/itempools.md items and pools todo file: content and resources support +xml_tag itempools.xml itempools.xml xml/itempools.md items and pools done file: content and resources support xml_tag items.xml items.xml xml/items.md items and pools done file: content and resources support xml_tag items.xml null repentogon/Patches/XMLData.cpp:998 xml/items.md items and pools done tag in the docs' examples xml_tag items.xml passive repentogon/Patches/XMLData.cpp:1369 xml/items.md items and pools done tag in the docs' examples @@ -2765,71 +2765,71 @@ option internal LastSaveFile repentogon/REPENTOGONOptions.h:64 misc done option option internal RenderDebugFindInRadius repentogon/REPENTOGONOptions.h:68 console and debug done options.ini option internal SkipArchiveChecks repentogon/REPENTOGONOptions.h:67 misc done options.ini option internal UnifontRenderMode repentogon/REPENTOGONOptions.h:63 console and debug done options.ini -behaviour_patch Patches ASMPatches.cpp repentogon/Patches/ASMPatches.cpp:1 console and debug todo Applies every byte patch at startup: log and console routing, mod and save folders moved to REPENTOGON's data folder +behaviour_patch Patches ASMPatches.cpp repentogon/Patches/ASMPatches.cpp:1 console and debug done Applies every byte patch at startup: log and console routing, mod and save folders moved to REPENTOGON's data folder behaviour_patch Patches ASMPatches/ASMBagOfCrafting.cpp repentogon/Patches/ASMPatches/ASMBagOfCrafting.cpp:1 items and pools done Bag of Crafting pickup adds: MC_TRY_ADD_TO_BAG_OF_CRAFTING and modded pickups -behaviour_patch Patches ASMPatches/ASMCallbacks.cpp repentogon/Patches/ASMPatches/ASMCallbacks.cpp:1 misc started Inline patches firing the callbacks a hook cannot reach (pause, HUD messages, room placement, NPC removal and many more) +behaviour_patch Patches ASMPatches/ASMCallbacks.cpp repentogon/Patches/ASMPatches/ASMCallbacks.cpp:1 misc done Inline patches firing the callbacks a hook cannot reach (pause, HUD messages, room placement, NPC removal and many more) behaviour_patch Patches ASMPatches/ASMCamera.cpp repentogon/Patches/ASMPatches/ASMCamera.cpp:1 level and room done Keeps the room's single Camera alive for Lua and restores it on destruction behaviour_patch Patches ASMPatches/ASMDelirium.cpp repentogon/Patches/ASMPatches/ASMDelirium.cpp:1 npc done Delirium transformation callbacks (pre, transform, post) behaviour_patch Patches ASMPatches/ASMEntityKnife.cpp repentogon/Patches/ASMPatches/ASMEntityKnife.cpp:1 tear and weapons done Melee knife hitbox initialisation behaviour_patch Patches ASMPatches/ASMEntityNPC.cpp repentogon/Patches/ASMPatches/ASMEntityNPC.cpp:1 npc done NPC speed and active enemy checks driven by entity config -behaviour_patch Patches ASMPatches/ASMFixes.cpp repentogon/Patches/ASMPatches/ASMFixes.cpp:1 misc started Vanilla bug fixes: modded crafting quality, smelted trinkets, pill identification and effects, game state load, render target overflow, familiar pathing +behaviour_patch Patches ASMPatches/ASMFixes.cpp repentogon/Patches/ASMPatches/ASMFixes.cpp:1 misc done Vanilla bug fixes: modded crafting quality, smelted trinkets, pill identification and effects, game state load, render target overflow, familiar pathing behaviour_patch Patches ASMPatches/ASMGridEntityCollision.cpp repentogon/Patches/ASMPatches/ASMGridEntityCollision.cpp:1 level and room done Grid collision callbacks, deduplicated per frame and grid index behaviour_patch Patches ASMPatches/ASMGridEntitySpawn.cpp repentogon/Patches/ASMPatches/ASMGridEntitySpawn.cpp:1 level and room done Routes inlined grid spawns through MC_PRE/POST_GRID_ENTITY_SPAWN behaviour_patch Patches ASMPatches/ASMGridEntitySpawn_Definitions.cpp repentogon/Patches/ASMPatches/ASMGridEntitySpawn_Definitions.cpp:1 level and room done Signature table of the inlined grid spawn sites behaviour_patch Patches ASMPatches/ASMHud.cpp repentogon/Patches/ASMPatches/ASMHud.cpp:1 hud and menus done HistoryHUD render and recompute callbacks, smelted item images -behaviour_patch Patches ASMPatches/ASMLevel.cpp repentogon/Patches/ASMPatches/ASMLevel.cpp:1 level and room started Custom stage ids, level generation and room placement callbacks, stage binaries -behaviour_patch Patches ASMPatches/ASMLocalization.cpp repentogon/Patches/ASMPatches/ASMLocalization.cpp:1 hud and menus started Localised resource lookup in archives with an English fallback -behaviour_patch Patches ASMPatches/ASMMenu.cpp repentogon/Patches/ASMPatches/ASMMenu.cpp:1 hud and menus started Mods menu font, language change from options, online and daily menu selection -behaviour_patch Patches ASMPatches/ASMPlayer.cpp repentogon/Patches/ASMPatches/ASMPlayer.cpp:1 player started Familiar checks, Mars double tap window, active charge, custom hurt and death sounds, Lost Soul puddle -behaviour_patch Patches ASMPatches/ASMPlayerManager.cpp repentogon/Patches/ASMPatches/ASMPlayerManager.cpp:1 player todo Controller reassignment on restore and disconnect +behaviour_patch Patches ASMPatches/ASMLevel.cpp repentogon/Patches/ASMPatches/ASMLevel.cpp:1 level and room done Custom stage ids, level generation and room placement callbacks, stage binaries +behaviour_patch Patches ASMPatches/ASMLocalization.cpp repentogon/Patches/ASMPatches/ASMLocalization.cpp:1 hud and menus done Localised resource lookup in archives with an English fallback +behaviour_patch Patches ASMPatches/ASMMenu.cpp repentogon/Patches/ASMPatches/ASMMenu.cpp:1 hud and menus done Mods menu font, language change from options, online and daily menu selection +behaviour_patch Patches ASMPatches/ASMPlayer.cpp repentogon/Patches/ASMPatches/ASMPlayer.cpp:1 player done Familiar checks, Mars double tap window, active charge, custom hurt and death sounds, Lost Soul puddle +behaviour_patch Patches ASMPatches/ASMPlayerManager.cpp repentogon/Patches/ASMPatches/ASMPlayerManager.cpp:1 player done Controller reassignment on restore and disconnect behaviour_patch Patches ASMPatches/ASMRender.cpp repentogon/Patches/ASMPatches/ASMRender.cpp:1 hud and menus done Planetarium chance on the stat HUD (option) behaviour_patch Patches ASMPatches/ASMRoom.cpp repentogon/Patches/ASMPatches/ASMRoom.cpp:1 level and room done Ambush wave count, boss wave difficulty, Mega Satan ending, water, room save state, clear delay, Blue Womb door behaviour_patch Patches ASMPatches/ASMSplitTears.cpp repentogon/Patches/ASMPatches/ASMSplitTears.cpp:1 tear and weapons done MC_POST_FIRE_SPLIT_TEAR for every tear split behaviour_patch Patches ASMPatches/ASMStatusEffects.cpp repentogon/Patches/ASMPatches/ASMStatusEffects.cpp:1 entities done Status effect targets and Weakness for custom status effects -behaviour_patch Patches ASMPatches/ASMTweaks.cpp repentogon/Patches/ASMPatches/ASMTweaks.cpp:1 misc started Small tweaks: Godhead partition, Tear Detonator, Hush veins, archive checksums, console online, resource paths, exit prompt, music bound, language -behaviour_patch Patches AchievementsStuff.cpp repentogon/Patches/AchievementsStuff.cpp:1 persistent data and saves started Modded achievements: XML, saving, popups, lockachievement, Isaac.GetAchievementIdByName -behaviour_patch Patches Anm2Extras.cpp repentogon/Patches/Anm2Extras.cpp:1 render and sprites todo Per ANM2 and per layer extras: shaders and render flags +behaviour_patch Patches ASMPatches/ASMTweaks.cpp repentogon/Patches/ASMPatches/ASMTweaks.cpp:1 misc done Small tweaks: Godhead partition, Tear Detonator, Hush veins, archive checksums, console online, resource paths, exit prompt, music bound, language +behaviour_patch Patches AchievementsStuff.cpp repentogon/Patches/AchievementsStuff.cpp:1 persistent data and saves done Modded achievements: XML, saving, popups, lockachievement, Isaac.GetAchievementIdByName +behaviour_patch Patches Anm2Extras.cpp repentogon/Patches/Anm2Extras.cpp:1 render and sprites done Per ANM2 and per layer extras: shaders and render flags behaviour_patch Patches CardsExtras.cpp repentogon/Patches/CardsExtras.cpp:1 items and pools done Card XML extras: availability conditions, hidden cards, weights in GetCard -behaviour_patch Patches ChallengesStuff.cpp repentogon/Patches/ChallengesStuff.cpp:1 persistent data and saves todo Modded challenge completion, saving and menus -behaviour_patch Patches CompletionTracker.cpp repentogon/Patches/CompletionTracker.cpp:1 persistent data and saves todo Completion marks for modded characters: saving, the character menu and Isaac's completion functions -behaviour_patch Patches ConsoleHooks.cpp repentogon/Patches/ConsoleHooks.cpp:1 console and debug started Console: REPENTOGON branding, command history kept on crash, new commands, autocomplete +behaviour_patch Patches ChallengesStuff.cpp repentogon/Patches/ChallengesStuff.cpp:1 persistent data and saves done Modded challenge completion, saving and menus +behaviour_patch Patches CompletionTracker.cpp repentogon/Patches/CompletionTracker.cpp:1 persistent data and saves done Completion marks for modded characters: saving, the character menu and Isaac's completion functions +behaviour_patch Patches ConsoleHooks.cpp repentogon/Patches/ConsoleHooks.cpp:1 console and debug done Console: REPENTOGON branding, command history kept on crash, new commands, autocomplete behaviour_patch Patches CustomCache.cpp repentogon/Patches/CustomCache.cpp:1 items and pools done Custom cache flags (customcache XML) evaluated on item, trinket and effect changes behaviour_patch Patches CustomDevilPlanetariumChance.cpp repentogon/Patches/CustomDevilPlanetariumChance.cpp:1 items and pools done Devil and planetarium chance split into callback steps behaviour_patch Patches CustomModManager.cpp repentogon/Patches/CustomModManager.cpp:1 misc done Per mod curses and mod entry extras behaviour_patch Patches CutsceneSkip.cpp repentogon/Patches/CutsceneSkip.cpp:1 hud and menus done Cutscenes skippable with input -behaviour_patch Patches EntityConfigEx.cpp repentogon/Patches/EntityConfigEx.cpp:1 entities todo entities2.xml extras: tags, erased enemies, Jera and reroll flags, familiar buddies -behaviour_patch Patches EntityManager.cpp repentogon/Patches/EntityManager.cpp:1 entities started Entity lifetime tracking: factory, list reset, removal -behaviour_patch Patches EntityPlus.cpp repentogon/Patches/EntityPlus.cpp:1 entities todo Extra per entity data: water clip, flying override, init and remove +behaviour_patch Patches EntityConfigEx.cpp repentogon/Patches/EntityConfigEx.cpp:1 entities done entities2.xml extras: tags, erased enemies, Jera and reroll flags, familiar buddies +behaviour_patch Patches EntityManager.cpp repentogon/Patches/EntityManager.cpp:1 entities done Entity lifetime tracking: factory, list reset, removal +behaviour_patch Patches EntityPlus.cpp repentogon/Patches/EntityPlus.cpp:1 entities done Extra per entity data: water clip, flying override, init and remove behaviour_patch Patches EvaluateStats.cpp repentogon/Patches/EvaluateStats.cpp:1 items and pools done XML item stats (tears, damage, range ...) applied at the vanilla steps of EvaluateItems behaviour_patch Patches ExtraDebugRender.cpp repentogon/Patches/ExtraDebugRender.cpp:1 console and debug done Draws FindInRadius and capsule queries (debug option) behaviour_patch Patches ExtraLives.cpp repentogon/Patches/ExtraLives.cpp:1 player done Custom extra lives and revives, MC_PRE_TRIGGER_PLAYER_DEATH behaviour_patch Patches ExtraRenderSteps.cpp repentogon/Patches/ExtraRenderSteps.cpp:1 render and sprites done Cursor initialised and rendered for the mouse control option behaviour_patch Patches FamiliarTags.cpp repentogon/Patches/FamiliarTags.cpp:1 familiar done Familiar XML tags: damageable, blocks projectiles, charmable -behaviour_patch Patches GetCoinValue.cpp repentogon/Patches/GetCoinValue.cpp:1 pickup todo Custom coin values, MC_PICKUP_GET_COIN_VALUE +behaviour_patch Patches GetCoinValue.cpp repentogon/Patches/GetCoinValue.cpp:1 pickup done Custom coin values, MC_PICKUP_GET_COIN_VALUE behaviour_patch Patches GridEntityPlus.cpp repentogon/Patches/GridEntityPlus.cpp:1 level and room done Extra per grid entity data and water clip behaviour_patch Patches ImagePatches.cpp repentogon/Patches/ImagePatches.cpp:1 render and sprites done Transparent render batch reuse fixes behaviour_patch Patches Init.cpp repentogon/Patches/Init.cpp:1 misc done Starts REPENTOGON's systems in Manager::Init behaviour_patch Patches InterpolV2.cpp repentogon/Patches/InterpolV2.cpp:1 render and sprites done Interpolated rendering between updates (option) -behaviour_patch Patches ItemConfigEx.cpp repentogon/Patches/ItemConfigEx.cpp:1 items and pools started items.xml extras and custom item sounds -behaviour_patch Patches ItemPoolManager.cpp repentogon/Patches/ItemPoolManager.cpp:1 items and pools todo Custom item pools from XML, pool queries, Isaac.GetPoolIdByName -behaviour_patch Patches ItemSpoofSystem.cpp repentogon/Patches/ItemSpoofSystem.cpp:1 player started Innate collectibles and trinkets counted by HasCollectible and friends +behaviour_patch Patches ItemConfigEx.cpp repentogon/Patches/ItemConfigEx.cpp:1 items and pools done items.xml extras and custom item sounds +behaviour_patch Patches ItemPoolManager.cpp repentogon/Patches/ItemPoolManager.cpp:1 items and pools done Custom item pools from XML, pool queries, Isaac.GetPoolIdByName +behaviour_patch Patches ItemSpoofSystem.cpp repentogon/Patches/ItemSpoofSystem.cpp:1 player done Innate collectibles and trinkets counted by HasCollectible and friends behaviour_patch Patches JsonSavedata.h repentogon/Patches/JsonSavedata.h:1 persistent data and saves done JSON helpers for REPENTOGON's own save data behaviour_patch Patches LagMetric.cpp repentogon/Patches/LagMetric.cpp:1 render and sprites done Lag metric and laser sample caching behaviour_patch Patches MainMenuBlock.cpp repentogon/Patches/MainMenuBlock.cpp:1 hud and menus done Main menu input mask (MenuManager.SetInputMask) -behaviour_patch Patches MesaShaderFix.cpp repentogon/Patches/MesaShaderFix.cpp:1 render and sprites todo Shader loading fix for Mesa drivers +behaviour_patch Patches MesaShaderFix.cpp repentogon/Patches/MesaShaderFix.cpp:1 render and sprites done Shader loading fix for Mesa drivers behaviour_patch Patches MinimapPatches.cpp repentogon/Patches/MinimapPatches.cpp:1 hud and menus done Minimap shader before its image renders -behaviour_patch Patches MiscFixes.cpp repentogon/Patches/MiscFixes.cpp:1 misc started Fixes: null frames, missing entity configs, familiar followers, innate collectibles, font drawing +behaviour_patch Patches MiscFixes.cpp repentogon/Patches/MiscFixes.cpp:1 misc done Fixes: null frames, missing entity configs, familiar followers, innate collectibles, font drawing behaviour_patch Patches ModReloading.cpp repentogon/Patches/ModReloading.cpp:1 misc done Mod reloading and workshop updates -behaviour_patch Patches ModsMenuStuff.cpp repentogon/Patches/ModsMenuStuff.cpp:1 hud and menus todo Mods menu search bar and input +behaviour_patch Patches ModsMenuStuff.cpp repentogon/Patches/ModsMenuStuff.cpp:1 hud and menus done Mods menu search bar and input behaviour_patch Patches NullItemsAndCostumes.cpp repentogon/Patches/NullItemsAndCostumes.cpp:1 player done Custom null items and their costumes -behaviour_patch Patches PlayerFeatures.cpp repentogon/Patches/PlayerFeatures.cpp:1 player started Modded character trinket handling, Greed donations, per save state -behaviour_patch Patches PlayerTags.cpp repentogon/Patches/PlayerTags.cpp:1 player started players.xml tags: no shake, no Metronome, no expansion pack, nightmare portraits -behaviour_patch Patches PocketItems.cpp repentogon/Patches/PocketItems.cpp:1 player started Pocket item adds and removals with callbacks +behaviour_patch Patches PlayerFeatures.cpp repentogon/Patches/PlayerFeatures.cpp:1 player done Modded character trinket handling, Greed donations, per save state +behaviour_patch Patches PlayerTags.cpp repentogon/Patches/PlayerTags.cpp:1 player done players.xml tags: no shake, no Metronome, no expansion pack, nightmare portraits +behaviour_patch Patches PocketItems.cpp repentogon/Patches/PocketItems.cpp:1 player done Pocket item adds and removals with callbacks behaviour_patch Patches Quickstart.cpp repentogon/Patches/Quickstart.cpp:1 hud and menus done Quickstart into the last save slot behaviour_patch Patches RoomConfigExtras.h repentogon/Patches/RoomConfigExtras.h:1 level and room done Stage id mapping for Greed and alternate stages behaviour_patch Patches SaveImport.cpp repentogon/Patches/SaveImport.cpp:1 persistent data and saves done Imports vanilla saves into REPENTOGON's save folder behaviour_patch Patches StagesStuff.cpp repentogon/Patches/StagesStuff.cpp:1 level and room done Custom floor music, backdrop and name, stage config ids, stage command behaviour_patch Patches VanillaTweaks.cpp repentogon/Patches/VanillaTweaks.cpp:1 misc done Option tweaks: better Void generation, Hush laser speed, quick room clear, Hornfel, archive checks -behaviour_patch Patches XMLData.cpp repentogon/Patches/XMLData.cpp:1 misc todo Loads every content XML into XMLData, merges content and resources, custom backdrops, cutscenes and stages -behaviour_patch Patches XMLPlayerExtras.cpp repentogon/Patches/XMLPlayerExtras.cpp:1 player started players.xml extras: starting health and stats, health limit, custom character menu +behaviour_patch Patches XMLData.cpp repentogon/Patches/XMLData.cpp:1 misc done Loads every content XML into XMLData, merges content and resources, custom backdrops, cutscenes and stages +behaviour_patch Patches XMLPlayerExtras.cpp repentogon/Patches/XMLPlayerExtras.cpp:1 player done players.xml extras: starting health and stats, health limit, custom character menu behaviour_patch Patches Xml/XmlBossPools.cpp repentogon/Patches/Xml/XmlBossPools.cpp:1 npc done bosspools.xml parsing for custom boss pools diff --git a/analysis/repentogon_overrides.tsv b/analysis/repentogon_overrides.tsv index 44fc70a..57781f2 100644 --- a/analysis/repentogon_overrides.tsv +++ b/analysis/repentogon_overrides.tsv @@ -281,12 +281,68 @@ function EntityPlayer SetWeapon done function Isaac ReworkBirthright done Birthright counts for the character only in Lua's checks callback ModCallbacks MC_POST_PLAYER_GET_MULTI_SHOT_PARAMS done run with MC_EVALUATE_MULTI_SHOT_PARAMS through main_ex.lua's legacy wrapper callback ModCallbacks MC_PRE_PLAYER_COLLISION done vanilla dispatch with parity, collision_callbacks_run around HandleCollision without -behaviour_patch Patches ItemSpoofSystem.cpp started innates, blocks, reworked Birthrights, players.xml innates and the Lua context; groups are not saved in the run's state yet -behaviour_patch Patches XMLPlayerExtras.cpp started starting health and bombs, health limit, locked and hidden modded characters; not its SelectRandomChar rewrite +behaviour_patch Patches ItemSpoofSystem.cpp done innates, blocks, reworked Birthrights, players.xml innates and the Lua context; the named groups kept in the saved states and written beside the game state file (EntitySaveStateEx, repentogon/save_state_ex.cpp) +behaviour_patch Patches XMLPlayerExtras.cpp done starting health and bombs, health limit, locked and hidden modded characters on the wheel, co-op carousel and tainted page; SelectRandomChar's rewrite is the rebuild's own pick leaving out locked and unselectable characters, which keeps the vanilla draw behaviour_patch Patches NullItemsAndCostumes.cpp done null items (items.xml) and their costumes, modcostume, AddCostume's null guard -behaviour_patch Patches PlayerTags.cpp started noshake; not nometronome, noexpansionpack or the stage portraits -behaviour_patch Patches ASMPatches/ASMPlayer.cpp started hurt and death sounds (three of five sites), bloody tears, the Mars double tap window without parity +behaviour_patch Patches PlayerTags.cpp done noshake (nightmare and boss screens), nometronome, noexpansionpack, stageportrait and extrastageportrait under bigportraitroot (nightmare_scene.cpp) +behaviour_patch Patches ASMPatches/ASMPlayer.cpp done hurt and death sounds at every site this exe has (the statue's too; Soul of Lazarus plays none here), bloody tears, Mars double tap window, the Lost's health skips the low-health splat (parity off); CheckFamiliar is CheckFamiliarEx; AddActiveCharge already passes its flags in order xml_attribute edenhair.xml gfx done a mod's hairstyles appended to Eden's, under the file's root xml_tag edenhair.xml edenhair done a mod's content edenhair.xml xml_tag edenhair.xml hair done a mod's content edenhair.xml xml_tag edenhair.xml edenhair.xml done content only, as REPENTOGON reads it +behaviour_patch Patches ASMPatches/ASMPlayerManager.cpp done controller hand-outs for mods' twins and co-players on a continue and after a disconnect, with the Jacob and Esau disconnect fix (repentogon/controllers.cpp, parity off), the co-op carousel hides locked or achievement-hidden modded characters; SpawnSelectedBaby has no effect (the only caller passes -1); twins linked again after a restore from EntitySaveStateEx's saved twin index (repentogon/save_state_ex.cpp, parity off) +behaviour_patch Patches PocketItems.cpp done pre and post add, remove, collect, drop, lost slots, used cards and pills, SetCard and SetPill, Soul of Lazarus, each at its site (pockets.cpp, collectibles.cpp, forgotten.cpp, death.cpp) +behaviour_patch Patches PlayerFeatures.cpp done modded characters' Greed donations counted in playerdata.json and their jam chance from it (repentogon/player_features.cpp, parity off); MC_PRE_ADD_TRINKET and AddSmeltedTrinket were ported before +behaviour_patch Patches ASMPatches/ASMCallbacks.cpp done every callback it fires is fired at its site (phase 1), with MC_PRE_UPDATE's pause, the hidden charge bar and the custom active gfx and crop +behaviour_patch Patches ASMPatches/ASMFixes.cpp done parity off: modded crafting quality, the variant set merge compare, ENTCOLL_PLAYERONLY meeting a player, UsePill's identify of a bad color, the failed item pool read, the room reset in place; already safe here: GetPillEffect and the HUD's bad colors, axis wander of a fleeing familiar, inputconfigs.dat parsing; na: the 1.9.7.12 smelted trinket and pill effect checks (fixed in this exe), the render target stack (unbounded here), OpenAL attributes (SDL audio) +behaviour_patch Patches ASMPatches/ASMTweaks.cpp done parity off: Godhead queries enemies only, the challenges.xml warning silenced, grid debug views in the Lua mini font, Lua music volume up to 1, the Womb exemption (before), exit prompt (before); na or inherent: Tear Detonator's list is a copy here, no archive checksums to skip, the leaderboard is online only, resources-repentogon is assets/repentogon, the language is the rebuild's own options.ini +behaviour_patch Patches MiscFixes.cpp done parity off: the death screen's modded portrait cleared, familiar lines, bad pill colors, spawn seeds, crawlspaces under Mist, metadata.xml writes, knife paths, gold and spiked rocks, entity config keys, Double Trouble variants reserved, redirected XML logged, BlockUnknownDevices for nameless SDL gamepads, nil DrawString; null frames and mods/ font paths are safe here; na: online and daily menu, lobbies and mod bans (offline); Present before PushCurrentRenderTarget, in RenderToSurface (repentogon/lua_render.cpp, its only caller here) +behaviour_patch Patches ConsoleHooks.cpp done parity off: REPENTOGON greeting, history saved after every command, commands from the menus (the overlay) with its refused list, luareset, fullrestart, cleanbestiary (SDL prompt, no Steam Cloud), clearcache forgets redirected paths, help, giveeffect and removeeffect, mods' macros; reloadshaders is the game's +behaviour_patch Patches ASMPatches.cpp done console commands without a player (ConsoleHooks); the other patches are each file's own; na: mods and mod data folders moved out of the Repentogon folder (the rebuild has none); the KAGE log in the overlay's Log window (REPENTOGON's Log Viewer) +function _G ASMPatch na writes raw x86 bytes into the Windows exe: registered to raise "ASMPatch is not supported in the native build" +function ASMPatchTest AddBytes na debug builds only, an ASMPatch method (raw x86 bytes) +function ASMPatchTest AddCJump na debug builds only, an ASMPatch method (raw x86 bytes) +function ASMPatchTest AddJump na debug builds only, an ASMPatch method (raw x86 bytes) +function ASMPatchTest ToASM na debug builds only, an ASMPatch method (raw x86 bytes) +behaviour_patch Patches Anm2Extras.cpp done custom sprite and layer shaders (lua_sprite.cpp, anm2.cpp RenderFrame), cleared on Reset and copy; RenderFrameEx's flag order, gold shimmer and procedural pass match the native RenderFrame; its PauseScreen::Show check reads the full-size paper (mainsprite) the rebuild leaves out, so it has nothing to fix +behaviour_patch Patches MesaShaderFix.cpp done render.cpp mesa_shader_load: with vanilla parity off the gold shader builds from coloroffset_gold_mesafix.fs (assets/repentogon/resources/shaders), its inputs fed from the rebuild's uniforms; REPENTOGON has no ini key for it +callback ModCallbacks MC_PRE_OPENGL_RENDER done gl_pipeline.cpp, fired from RenderBatch::submit into a render target with its VertexBuffer, ShaderType and Context; behind REPENTOGON's EnableCustomRendering (off), so it does not run, as main_ex.lua warns +function EntityPlayer GetMultiShotPositionVelocity done REPENTOGON's override reads its MultiShotParams (player_api.cpp), an argument error past NumTears where the game's binding cannot take one +callback ModCallbacks MC_PRE_FAMILIAR_COLLISION done collision_callbacks_run table results (Collide, SkipCollisionEffects) without vanilla parity, tested with a familiar touching an enemy +function UnitTests GetTestRoom na debug builds only: RoomConfigUtility's unit test hooks, absent from REPENTOGON's release builds +function UnitTests Build na debug builds only: RoomConfigUtility's unit test hooks, absent from REPENTOGON's release builds +function UnitTests Serialize na debug builds only: RoomConfigUtility's unit test hooks, absent from REPENTOGON's release builds +function UnitTests Deserialize na debug builds only: RoomConfigUtility's unit test hooks, absent from REPENTOGON's release builds +function UnitTests ValidateLocalSave na debug builds only: SaveSyncing's Steam Cloud save tests, Steam only +function UnitTests ValidateCloudSave na debug builds only: SaveSyncing's Steam Cloud save tests, Steam only +function UnitTests TestSync na debug builds only: SaveSyncing's Steam Cloud save tests, Steam only +function UnitTests CompareSaves na debug builds only: SaveSyncing's Steam Cloud save tests, Steam only +xml_attribute challenges.xml achievements done a mod's challenge by achievement names (repentogon/progress.cpp); without parity it stays locked on the menu until they unlock (r5a2 test) +xml_attribute challenges.xml hidden done anything but false keeps a mod's challenge off the custom challenge menu +xml_attribute challenges.xml lockeddesc done a locked challenge's row (translated, else LOCKED :(), parity off as the locked rows are +xml_attribute challenges.xml playertype done a character's name, resolved once the mods' players loaded (r5a2 test: a modded character starts the challenge) +xml_attribute challenges.xml startingcard done a card's name (r5a2 test) +xml_attribute challenges.xml startingitems done names and ids mixed (r5a2 test) +xml_attribute challenges.xml startingitems2 done names and ids mixed, as startingitems +xml_attribute challenges.xml startingtrinkets done trinket names (r5a2 test) +xml_attribute challenges.xml unlockachievement done unlocked by number or name when the challenge completes (r5a2 test) +xml_tag challenges.xml challenges.xml done mods' content challenges.xml as the game reads it, plus REPENTOGON's names, hidden, locked and saved clears (challenges.json) +xml_tag itempools.xml itempools.xml done repentogon/custom_pools.cpp: a of a new name makes a pool from 31 (ChaosMode, items by id or name), drawn, picked by Chaos and kept in the run's states (r5a2 test) +xml_attribute players.xml completionparent done a character shares the marks of the one it names, its own mod's first (r5a2 test) +xml_attribute players.xml nomarks done hides a modded character's completion widget, which shows without parity +xml_attribute costumes2.xml name done ItemConfig_Costume::name, else the anm2path's file name, for XMLData lookups +behaviour_patch Patches AchievementsStuff.cpp done mods' achievements, event conditions (r5a2 test), console achievement and lockachievement, and the secrets menu's mod pages (parity off); the Steam achievement block and the dummy popup trick are not needed natively +behaviour_patch Patches ChallengesStuff.cpp done repentogon/progress.cpp: modded challenge clears saved per slot, unlockachievement, hidden and locked rows, translated names and the streak (parity off) +behaviour_patch Patches CompletionTracker.cpp done repentogon/progress.cpp: modded characters' marks recorded and saved per slot (only written when one is given), completionparent, the widget on the character menu and pause screen without parity, the localized name import +behaviour_patch Patches ItemConfigEx.cpp done items.xml stats and tags (stats.cpp, item_config.cpp), the raw name in the name map, a null item's revive tag as reviveeffect +behaviour_patch Patches ItemPoolManager.cpp done custom pools (repentogon/custom_pools.cpp: draws, Chaos, Bible, Genesis, reset, states, debug names) and the mod items of pool_items.cpp; saved custom pool states are written to their own .custom.json, and pool ids are not remapped when the pool list changed +behaviour_patch Patches GetCoinValue.cpp done Entity_Pickup::coin_worth, so Ultra Greed's coin search counts mods' coins too +behaviour_patch Patches EntityConfigEx.cpp done entities2.xml extras and tags at their game sites, babies, edenhair (ported with their xml rows) +behaviour_patch Patches EntityManager.cpp done entity creation and deletion notices to the save state manager; an entity removed after its own update leaves in the same pass, parity off +behaviour_patch Patches EntityPlus.cpp done the per entity overrides live on the entities and are cleared as a pooled entity starts again (entity_plus_reset) +behaviour_patch Patches ASMPatches/ASMLocalization.cpp done -repentogon folders, localized character animation fallbacks and the raw bSkinParent match (parity off), Repentance's language archives cut to their fonts (parity off) +behaviour_patch Patches ASMPatches/ASMMenu.cpp done online menu selection, a language change restarting the game (parity off) and the mods menu's own rows (ModsMenuStuff) +behaviour_patch Patches ModsMenuStuff.cpp done repentogon/mods_menu.cpp, parity off: enabled mods first, search past 15 mods, undo of the session's changes +behaviour_patch Patches ASMPatches/ASMLevel.cpp done Blue Womb curse, deal rooms, end room slots, quest doors, and the Void: its stages and BetterVoidGeneration, void_ex rooms' stage, backdrop and portals, portals kept on later floors (parity off; r5a2 test: 19 Repentance rooms of 57) +behaviour_patch Patches XMLData.cpp done the XMLData store and Lua table (repentogon/xml_data.cpp), content and resources merges (repentogon/xml.cpp), backdrops, giant books, cutscenes, bosscolors, challenges, achievements; Lua Fadeout's Repentance title and new run targets (parity off); its stage hooks are commented out at e2c5aec; na: the daily challenge seed and practice change and the daily and online menu redirects (dailies and netplay are offline) +behaviour_patch Patches SaveStateManagement/EntitySaveStateEx.cpp done repentogon/save_state_ex.cpp: player twin index and innate groups, pickup reroll override, ex_.json beside the game state file diff --git a/assets/repentogon/resources/font/luamini.fnt b/assets/repentogon/resources/font/luamini.fnt new file mode 100644 index 0000000000000000000000000000000000000000..4c8abe0fc5643d883ef2b8283e11877cbfceb748 GIT binary patch literal 1975 zcmZ9Ni#JqJ6o>bndj}1=mMp7UDvuKK?x6>TiV8(VMTH`bG$a(2)qk#U-?`1&_RKo$ z-*6=M?A-;B4r(+$k6G?tJ()_Lv z>5MkNPV`xPnPiR}c}m;`Yl210EK-r=*G<%&GewWJ#Y{0Qm*q~$gVIz(` zfQ>o!5H{i17;M_HaoDV5k6`nTJ%*ij>v#fNbiN7Lier@rcy+Y?`w(o1Sj%j^w z(Aq4UN56M$0ewKN>>hdx8>ja6E_s*qJH97%tor0WU?(T_mUxkA~e zUi9%dUWU!NIX=KX(rnJEXPj>Z_SN}T(UZ>i3048KYg>cmN_(Stj`VIhUt(p{R^mLY zg}(MqT!-l=#QT4}Ux=#Q92>Ak*H`oHgJoHro?k|Y3q%VrTjx#Kl4D!2mQsGjoWH@^ z9Mii`xFf=J4z2xn$hsSE2ewCFTbEtfrt|H=b{x~YbO2`8@e{V{eEYC2m)`+w-}!#Q f3N9DD*AHR#xA70Gfxb59Ls&KYD$<)Y{Z07?Y9&s+ literal 0 HcmV?d00001 diff --git a/assets/repentogon/resources/font/luamini_0.png b/assets/repentogon/resources/font/luamini_0.png new file mode 100644 index 0000000000000000000000000000000000000000..f94c633013a51778fef77b2081294e92dc96a408 GIT binary patch literal 1192 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJaJHUG(7oa?!LfAMqk;-{9S&wZ?mUagyR?7rrim5)=lB)_<_e`U#p@OL6# z_X!`#cd+3&a| z-S2(P^R}=YF2~xbK6V<*y&iJ9bUHyl&z1?dADTM5kLFiLG*9 zu3$C!vCZ2#`|j_ZxPBMQrviHp#>%g5e($u+53T%I-sKiM>z&Chlk|MC0Jd4O8b9$`K>&h@8Y~Z&$#!O`#yxVFZsRueO&3BUDfOEUDWKk zm-+l`&6j@yh0o`{e`gV2*i-)RU0?FNz1EiROP+^J*v(gYt?<`6g*xS3%FDM;w`Xv( z_Wks(VtM(TUB!0AcO>6R)Hg4A|0SCBW9(wt$L~e^f!eRkmnpt#f2YdeSI1r1<1cqx z`<3(T);{l-{;K4;4a8XO_Bk=TCQdFE*grA&d%@}-6YA9$%Q`Pt*rj|=x$5`1N~VV? zd(yw`eK)WEp@C@se&;W;d&_oJZ*i~L|4Q)Qarpxpil-P3|Gg6Xwd3Bc<$tdf-h2D? z*_XSr%NOr_Y*Mor=+Sd??iKF3TvJk0QMJZyulK*m=jMxInLNL*o~#gFUes}a)|X?l zMaK)>E2`g{7Zol4ec8ToJ{QN#j;a>(x%b`)yuAYQ^viEQ*F697_tZ}JE!9UA@0Y%G ztNH%&uX^9ne1W;=_cZOPQqH_S`|@9HkO_8;FV5X5oRjJ9H+P@ojkz{ORn0YfF0$Xb zTNqcV@^+8p-o5_T_g|cS`TGY`mBO5!Z;#o9QW-AJoa2B0t6%VAzU|E__IU?dFV4Ma zzOPuVe3rWTKjt6JHX>|`ivI|FU=MtGG4GGT2lh%0H}=3jxkWOzE|ygtMPCG-zEC`M q(Rs?^b`5v_Q3+ClMC{)EI>u+o3GUU~lmmbT34^DrpUXO@geCwoB}(o9 literal 0 HcmV?d00001 diff --git a/assets/repentogon/resources/gfx/ui/bestiary_tabs.anm2 b/assets/repentogon/resources/gfx/ui/bestiary_tabs.anm2 new file mode 100644 index 0000000..fb977e4 --- /dev/null +++ b/assets/repentogon/resources/gfx/ui/bestiary_tabs.anm2 @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/repentogon/resources/gfx/ui/bestiary_tabs.png b/assets/repentogon/resources/gfx/ui/bestiary_tabs.png new file mode 100644 index 0000000000000000000000000000000000000000..bf25826dee4346352b00c600b2210e30bbb17aba GIT binary patch literal 22343 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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/repentogon/resources/gfx/ui/changelog.anm2 b/assets/repentogon/resources/gfx/ui/changelog.anm2 new file mode 100644 index 0000000..e0f60b6 --- /dev/null +++ b/assets/repentogon/resources/gfx/ui/changelog.anm2 @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/repentogon/resources/gfx/ui/changelog_tab_note.png b/assets/repentogon/resources/gfx/ui/changelog_tab_note.png new file mode 100644 index 0000000000000000000000000000000000000000..8cf2e1b4f729d67b31e12d0a8e4e2efbc0319747 GIT binary patch literal 1448 zcmV;Z1y}lsP)Px)Vo5|nRCt{2T)|2lK@fe0{DugM=UkFMSXfw8P!EB8fwGc=hvXX)&_Hl-zaWr9 zBCJ6W{Db6@vnT{VWOB&Xq^72-r>Cc9c3bzs;_lefGxnQ$^}4Iq6$l(39p>^F$LZPm zitG1Fbc@p9*OBGIlE{9b688S>yHcau`#S)@_aEPaFSH~y4phSSw)U~PzEOK}3?ey} zq}HP{Kut+=Ats?qGXFsx1WOvbKq#qCl|VDXfPM&bp$VB!g+S9K#*oC=@FDQA6W7>u z?CkCU0HznyuJ5fDz7hDCNPOP5gR7fsOtK6>|0L2w_5STU+}_`r#QDxIQy`WTwoPw* zq>vM}2-sZTDCOJ`Gjn`&m@hhMjUw#o=DK(<$vPO1Xl7e0Lc z*vDm$j25{Ny4K% zl4T}2R(m>!Ua@d{e9gN4`L{2ZJy-4Wh`bI?xHPRj) z{&apXu~5ljF0DTpj| z^_4;?hbiPQ;D3Z|J6p}b^H<&A#EdR^Y?5UavO=zxlAR|6uO*Tc0&$k9c>a-nh4y`Q zbM17kiX1L<{sLx_=(Eb7rM(DdXrV(YyX{vGv2wP89 zmnOXQYHQJBfe7%)i&muoNLLO4Bf_j)G0C!0ysU&TLFBof zY~F63dqPrM-QcLKbZARG+A4zuNvtKS^OD_^^B3S)nzEvV2$74t8eCfnw9gcMlFXQe z%#`yN06Yu%#)`If$YEJ*jabb{ks3ezDc&3sc0A21gw{FpQ^F4N-Llw(P=G(vS|2hgj`si6{Kb#okPt*!R1O0sX2 zTIMyYfBH;qWDc~D=Xp|c2r$BE(kvxPi!KgHp0+tho-5b=EYi6gy7q3!inrA^b;AKP zC}2)6rnQnIqmPc!PyPT{9|D%6(zZm;gfw{*5Uc<x80kCxTwPr&8WD-We5|n*aju*yrS>rx4q*0$ zz9y?3L?kECg|0Vi(gVaxLt0+s-%gq3uuGaWudFQeH;hW)cUtV6YP!e6ibjbp$oq2f zwYa9Me + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/repentogon/resources/gfx/ui/changelogpaper.png b/assets/repentogon/resources/gfx/ui/changelogpaper.png new file mode 100644 index 0000000000000000000000000000000000000000..883a28474774ec0aebc3a1b988275c35b148b59b GIT binary patch literal 7907 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 literal 0 HcmV?d00001 diff --git a/assets/repentogon/resources/gfx/ui/daily_destinations.anm2 b/assets/repentogon/resources/gfx/ui/daily_destinations.anm2 new file mode 100644 index 0000000..6ade1cf --- /dev/null +++ b/assets/repentogon/resources/gfx/ui/daily_destinations.anm2 @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/repentogon/resources/gfx/ui/leaderboardgoals_sketchAlt.png b/assets/repentogon/resources/gfx/ui/leaderboardgoals_sketchAlt.png new file mode 100644 index 0000000000000000000000000000000000000000..e5a1623746bdba5abbdf0409bd69f2f1641db197 GIT binary patch literal 6113 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 mf#tSd1gK^Izcy30_V*wD;Nb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/repentogon/resources/gfx/ui/modsmenusearchbar.png b/assets/repentogon/resources/gfx/ui/modsmenusearchbar.png new file mode 100644 index 0000000000000000000000000000000000000000..dc9505189a543c5052fbaa7270e8aa804cddd024 GIT binary patch literal 2871 zcmb_e2~-nz8Xp7^Fy6CX>klBoiiq1Qd%$6>mgE z5vY&#wp(0Q5UB-qK@<;GYtV|QD=JWq@-T{MJa)qM+OF;P?e4rcGvEB@_Z`3Q`~Kg| zrtr`|xsIAL3IG6Ckx&o;0Cp5o<~TW$*Ms4!EaYvZP8h8R0OxVG(+=35KN$cVUDQ!h zgH-Y{jN%#wBFAMI!=%xXXaJbM(4<4q1k3=+Fr`|{r*@q^M+Mb#K6M#a!jkBMFqK-E zMqrU?p;2gB0?Lz97cKzjn_$v_1~VX_Nt3A6!zMnp&n`^Lwq+(2?1LB*_|!m~Lr^LS z2ZL||19=QK9c8iDpg$@3`auCa-dqr3K^!K_j|p+<5DR9pVJ;UOIH;sMLau-#1R(>? z$R|EkWiaSqCevs%GK?GsPAHjd9*@UlK}-mulL)##Rck;@bgkZN(1HNdql8*#P~%$A zW)YF$$p$`^47HzwMmJv4abjd_wpL03N#1b(LrZwnE zEPDv6Q{e_&ufl)B^w8^HI3RN?kqr6xU@RKVkPE#bIEAD!kdP0e^--xhj2VIH@nizU zf>X#ay=-iBa1enZ2Aqh(@x;MOg%5@dLR>AUex0itP{k@?eNfXK`Q_s~;-CXGGA>=l_4T789A5=J08#jJP!1+%Biup#FhWi4IwbMGwqx6iwr+ui zYCT!U)Pcfbx_|IBKj7^n)-Dlu~SGO0G6Oxu*|FD3KW zRqlKDvxzncCs92(H%!_bJww4`Z*9N;~NP2@Mj;igCs7-h=uEQsA~UNn9Y?r8MP zoXuEdptNnYUn>qbyAS{DVlM|`1de`Ql|AD#JkfgEA`hj`1O5~++xd*)LFMnEp4w?9#20>L$`lsU9~Pd^>wRMATJ4w@Ok89 z*HfGQx;y^V#4&f($|#8XK3L!0tVvz{<}YfmOJL62C&TE{CFiWqI=_DN&LS2xo;uyi z&n-7%e@nm=?J*gjHq$<+%6Eju3YG@@hzDEWC$CbYkVH$UemQ%tp8vN z?15ND5yPlp_Zz_}v>HF&y6>se_F!t2<$JdUbd5n#DNy%9SR69wm2&W+iz*bm#(kQ#1p!4>8mbR z^+xS-skLrAaz5G^1yyqsp_S8n|ez$Rws3O(H+Bf zDa`qJTi}x=5p{7Vr|EV+@7i}owBhaT_+t%mKPAN&vWq7_Ue4vs-i9SkjQKuHTy|%7 z{oHNq%FOG8XByXSL587EVa?(LZk203e;oPk>DtH>8xLoZpFhr?slB7R_GWP=F1H@a zsW)#;9fRGRv$N#ypA^|2?m!=p-Em>k=!XmTXM_dMVP|bW5LCM+1a7$6o!`xwp>#Pq zu_!`(WPP#YlJ*SyYSoJiF?kK?>0Q}Lg=2P%6l$V9C#WP}FUaGpj)6qAW_i5bq@-2+ z>NOV)bsawbksU`%!^I&pruP<{Jh;3S*!+p37(3pbFtXe`h*MerWwp_dc+)L?)||gP zW}1IZKKjEbA~Lk@2e-~$Gjhke(I{wgsC2s6!~Qz$@%&@d*5>MjS)-1huT<6V)z{Qd s?g)msx$$v!5z@u)`KDUne90^4^)K`VH;TVnYWuYn1&0cX7RRmq7e{PNpa1{> literal 0 HcmV?d00001 diff --git a/assets/repentogon/resources/gfx/ui/modsmenuundo.png b/assets/repentogon/resources/gfx/ui/modsmenuundo.png new file mode 100644 index 0000000000000000000000000000000000000000..5101b3b009ee560977233b0a57a1ac1174453e85 GIT binary patch literal 5307 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 B=I;Oi literal 0 HcmV?d00001 diff --git a/assets/repentogon/resources/shaders/coloroffset_gold_mesafix.fs b/assets/repentogon/resources/shaders/coloroffset_gold_mesafix.fs new file mode 100644 index 0000000..571eebf --- /dev/null +++ b/assets/repentogon/resources/shaders/coloroffset_gold_mesafix.fs @@ -0,0 +1,49 @@ +#ifndef GL_ES +# define lowp +# define mediump +#endif + +varying lowp vec4 Color0; +varying mediump vec2 TexCoord0; +varying lowp vec4 ColorizeOut; +varying lowp vec3 ColorOffsetOut; +varying lowp vec2 TextureSizeOut; +varying lowp float PixelationAmountOut; +varying lowp vec3 ClipPlaneOut; + +uniform sampler2D Texture0; +const vec3 _lum = vec3(0.212671, 0.715160, 0.072169); + +float cubic(float x, float a1, float b1, float a2, float b2, float xt) +{ + return x < xt ? (a1*pow(x,3.0)+b1*x) : (a2*sign(x-1.0)*pow(abs(x-1.0),3.0)+b2*(x-1.0)+1.0); +} + +void main(void) +{ + // Clip + if(dot(gl_FragCoord.xy, ClipPlaneOut.xy) < ClipPlaneOut.z) + discard; + + // Pixelate + vec2 pa = vec2(1.0+PixelationAmountOut, 1.0+PixelationAmountOut) / TextureSizeOut; + vec4 Color = Color0 * texture2D(Texture0, PixelationAmountOut > 0.0 ? TexCoord0 - mod(TexCoord0, pa) + pa * 0.5 : TexCoord0); + + //Color.rgb = dot(Color.rgb, _lum) * vec3(1.0, 1.0, 1.0); + //Color.rgb = clamp((Color.rgb - vec3(0.6, 0.6, 0.6)) * 1.4 + vec3(0.5, 0.5, 0.5), vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0)); + + float t = ColorizeOut.a*10.0*3.1415926535 + 3.1415926535*(TexCoord0.x * (TextureSizeOut.x / TextureSizeOut.y) + TexCoord0.y); + t = 1.0-pow(max(0.0,sin(t)), 20.0)-sin(t)/4.0; + Color.rgb = clamp(Color.rgb * vec3(2.0 - t, 1.8 - t, 1.0 - t) + step( 0.007,dot(Color.rgb, _lum))*(-0.2*t+0.2)*vec3(1.0,1.0,1.0), vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0)); + + Color.r = clamp(cubic(Color.r, -6.52644, 3.05795, 1.36096, -0.320444, 0.172549), 0.0, 1.0); + Color.g = clamp(cubic(Color.g, -1.65228, 2.07291, 1.138, 0.0512927, 0.407843), 0.0, 1.0); + Color.b = clamp(cubic(Color.b, 4.86766, -3.82087, -44.7824, 9.35043, 0.901961), 0.0, 1.0); + + //vec3 Colorized = mix(Color.rgb, dot(Color.rgb, _lum) * vec3(1.0,1.0,0.0), 1.0); + vec3 Colorized = Color.rgb; + gl_FragColor = vec4(Colorized + ColorOffsetOut * Color.a, Color.a); + + gl_FragColor.rgb = mix(gl_FragColor.rgb, gl_FragColor.rgb - mod(gl_FragColor.rgb, 1.0/16.0) + 1.0/32.0, clamp(PixelationAmountOut, 0.0, 1.0)); +} + diff --git a/assets/repentogon/scripts/main_ex.lua b/assets/repentogon/scripts/main_ex.lua index 56dda6b..4873969 100644 --- a/assets/repentogon/scripts/main_ex.lua +++ b/assets/repentogon/scripts/main_ex.lua @@ -1,7 +1,7 @@ REPENTOGON = { ["Real"] = true, ["Name"] = "REPENTOGON", --I avoid having to do RegisterMod this way, sorry ;P - ["Version"] = "dev build", + ["Version"] = "1.1.3", ["Extras"] = { ["Misc"]={}, }, -- Tables containing additional REPENTOGON data structures, example: ChangeLog or StatsMenu } @@ -70,13 +70,12 @@ function _GetModule(modName) end local RaiseModError = _CBindings.RaiseModError --- rebuild: the vanilla parity option and whether the REPENTOGON global is exposed +-- rebuild: the vanilla parity option local IsVanillaParity = _CBindings.IsVanillaParity -local IsExposed = _CBindings.IsExposed local ModManager = _GetModule("repentogon_extras.mod_manager") local function MeetsVersion(targetVersion) - if (REPENTOGON.Version == "dev build") then return true end + if (REPENTOGON.Version == "1.1.3") then return true end local version = {} local target = {} @@ -750,14 +749,6 @@ local err_dupecount = 1 ---@type string[] local printedWarnings = {} --- rebuild: the console prints until REPENTOGON's Console is ported -local Console = Console or { - GetHistory = function() return {} end, - PopHistory = function() end, - PrintError = print, - PrintWarning = print, -} - local function logWarning(callbackID, modName, warn) local cbName = callbackIDToName[callbackID] or callbackID for _, printedWarning in pairs(printedWarnings) do @@ -1312,10 +1303,10 @@ end function _UnloadMod(mod) -- _UnloadMod is called late into the shutdown process where it is not safe to run a callback. -- We separately trigger MC_PRE_MOD_UNLOAD earlier in the shutdown process. - -- rebuild: vanilla parity runs it as main.lua does, and IsShuttingDown is not ported yet + -- rebuild: vanilla parity runs it as main.lua does if IsVanillaParity() then Isaac.RunCallback(ModCallbacks.MC_PRE_MOD_UNLOAD, mod) - elseif not (Isaac.IsShuttingDown and Isaac.IsShuttingDown()) then + elseif not Isaac.IsShuttingDown() then Isaac.RunCallback(ModCallbacks.MC_PRE_MOD_UNLOAD, mod, false) end @@ -2044,7 +2035,6 @@ local ModReference_SaveModFile = _CBindings.ModReference_SaveModFile local ModReference_LoadModFile = _CBindings.ModReference_LoadModFile local ModReference_RemoveModFile = _CBindings.ModReference_RemoveModFile -if ModReference_HasModFile then -- rebuild: until the mod file bindings are ported rawset(Isaac, "HasModData", function(modRef, filename) if type(filename) == "string" then return ModReference_HasModFile(modRef, filename) @@ -2076,7 +2066,6 @@ rawset(Isaac, "RemoveModData", function(modRef, filename) return Original_RemoveModData(modRef) end end) -end --Menuman Hub MenuManager.MainMenu = MainMenu @@ -2237,8 +2226,7 @@ end -- This can allow us to circumvent how the old wrappers handled certain inputs, as well as make -- errors report the actual call site instead of the line in `scripts/main.lua`. -- Make sure you understand what the old wrapper was doing, and that the new hook maintains any features like optional args. --- rebuild: only once the REPENTOGON global is exposed, as these need its own versions of the functions -local LuaWrappersToRemove = IsExposed and { +local LuaWrappersToRemove = { { ItemPool, {"GetCollectible"} }, { EntityPlayer, { @@ -2258,7 +2246,7 @@ local LuaWrappersToRemove = IsExposed and { } }, } -for _, tab in ipairs(LuaWrappersToRemove or {}) do +for _, tab in ipairs(LuaWrappersToRemove) do local class = tab[1] local mt = getmetatable(class).__class @@ -2276,7 +2264,7 @@ end LuaWrappersToRemove = nil -if IsExposed then -- rebuild: the menu extras need the REPENTOGON global and the menu API +if not IsVanillaParity() then -- rebuild: the menu extras change the vanilla menus pcall(require, "repentogon_extras/changelog") pcall(require, "repentogon_extras/daily_stats") pcall(require, "repentogon_extras/stats_menu") diff --git a/generated-src/classes.h b/generated-src/classes.h index 04b09fc..9e10e19 100644 --- a/generated-src/classes.h +++ b/generated-src/classes.h @@ -475,6 +475,7 @@ struct Manager; struct MapNodeIntInt; struct MapNodeRecipe; struct MapNodeStringInt; +struct MarksShown; struct MemMapBase; struct MenuDialog; struct MenuManager; @@ -609,6 +610,7 @@ struct RedirectedPath; struct ReferenceCountBase; struct RenderBatch; struct RenderConfig; +struct RenderContextScope; struct RenderTarget; struct RepentogonOptions; struct RerollEntry; diff --git a/scripts/repentogon_coverage.py b/scripts/repentogon_coverage.py index 8ba225a..4e1b894 100644 --- a/scripts/repentogon_coverage.py +++ b/scripts/repentogon_coverage.py @@ -48,6 +48,8 @@ Status rules (against this repository) xml_attribute, xml_tag todo analysis/repentogon_overrides.tsv (kind, class, name, status, optional), when present, is applied last: a later phase that verifies an item by hand (an xml attribute, a patch, a reviewed vanilla change) records it there. + na not applicable to the native build (raw x86 patches of the Windows exe, Steam or Windows only), with its + reason in the overrides' note. It counts as complete, as done does. """ import argparse @@ -1077,6 +1079,7 @@ def summary_print(rows, rawCount, problems, elapsed): "".join(f"{counts[name][status]:>9}" for status in statuses)) totals = Counter(item.status for item in rows) print(f"{'all':<28}{len(rows):>7}" + "".join(f"{totals[status]:>9}" for status in statuses)) + print(f"complete (done and na): {totals['done'] + totals['na']} of {len(rows)}") docsOnly = sum(1 for item in rows if item.summary.startswith("docs only")) undocumented = sum(1 for item in rows if item.kind in ("function", "property", "constructor") and not item.docs) print(f"\nfunction rows only in the docs: {docsOnly}, registered but undocumented: {undocumented}") diff --git a/src/engine/anm2.cpp b/src/engine/anm2.cpp index 22926ef..7a3c999 100644 --- a/src/engine/anm2.cpp +++ b/src/engine/anm2.cpp @@ -18,6 +18,7 @@ #include #include #ifdef ISAAC_REPENTOGON +#include "repentogon/gl_pipeline.h" #include "repentogon/render.h" #include "repentogon/ui_patches.h" #endif @@ -1039,6 +1040,7 @@ void AnimationState::Render(const SpriteDraw& draw, const ANM2& animation) const if (!animData) return; #ifdef ISAAC_REPENTOGON + RenderContextScope context(RENDER_CONTEXT_ANIMATION_STATE, &animation); rendered_state_set(this); #endif for (size_t i = 0; i < animData->animLayers.size(); i++) @@ -1451,6 +1453,9 @@ bool render_flags_shader_select(unsigned int flags) void AnimationLayer::RenderFrame(const SpriteDraw& draw, int frameIndex, const ANM2& animation) const { if (!isVisible || frameIndex < 0 || frameIndex >= (int)frames.size()) return; +#ifdef ISAAC_REPENTOGON + RenderContextScope context(RENDER_CONTEXT_ANIMATION_LAYER, this); +#endif #ifdef ISAAC_REPENTOGON AnimationFrame lerped; diff --git a/src/engine/filesys.cpp b/src/engine/filesys.cpp index 74b0c53..bb033ab 100644 --- a/src/engine/filesys.cpp +++ b/src/engine/filesys.cpp @@ -44,6 +44,9 @@ constexpr std::string_view MODS_FOLDER = "mods/"; // The game's own folder name, which the exe writes in front of some paths ("resources/gfx/1000.034_Fart.anm2"). constexpr std::string_view GAME_RESOURCES_FOLDER = "resources/"; constexpr std::string_view ASSETS_FOLDER = "assets"; +// REPENTOGON's resources-repentogon, shipped in assets/, and the folder mods reach it by in its install. +constexpr std::string_view REPENTOGON_RESOURCES = "repentogon/resources/"; +constexpr std::string_view REPENTOGON_INSTALL_RESOURCES = "repentogon/resources-repentogon/"; // Room for simdjson's padding after a file's bytes, so a JSON document parses where it was read. constexpr size_t READ_PADDING = 64; @@ -109,6 +112,7 @@ enum ArchiveType : uint8_t struct Archive { std::string bytes; + std::string_view name; std::FILE* file = nullptr; ArchiveType type = ARCHIVE_XORSHIFT; }; @@ -442,6 +446,7 @@ static bool entry_read(const ArchiveEntry& entry, std::string& bytes) static bool archive_index(std::string_view name) { Archive& archive = archives.emplace_back(); + archive.name = name; auto nested = archiveEntries.find(path_hash(BASE_MOUNT, name)); std::string header; std::string rows; @@ -496,6 +501,21 @@ void archives_load() } } +// Unmounts an archive's files but the kept ones (full paths, as "resources.jp/font/mplus_10r.fnt"), so the paths fall +// back to the files mounted before. +void archive_files_restrict(std::string_view name, std::span kept) +{ + auto archive = std::ranges::find(archives, name, &Archive::name); + if (archive == archives.end()) return; + + uint16_t index = (uint16_t)(archive - archives.begin()); + std::vector keys; + for (std::string_view path : kept) keys.push_back(path_hash({}, path)); + std::erase_if(archiveEntries, [&](auto& row) { + return row.second.archive == index && std::ranges::find(keys, row.first) == keys.end(); + }); +} + // Whether the resources are an install's, read from its packed archives. Its folders are only read. bool is_archive_mounted() { @@ -551,7 +571,9 @@ static std::string disk_find(std::string directory, std::string_view normalized) } // 00a16c60 (find_mount) The first of some game paths in the language's mount, then in the resources, each mount's -// archives before its folder. A mod's files are only in its folder. +// archives before its folder. A mod's files are only in its folder. REPENTOGON's own resources come last, also by +// the path mods take to its install's folder (../../../Repentogon/resources-repentogon/). An absolute path outside +// every mount (a file in assets/) is read where it is. static ResourceFile resource_find(std::initializer_list paths) { ResourceFile file; @@ -574,6 +596,18 @@ static ResourceFile resource_find(std::initializer_list paths) else file.path = disk_find(std::string(directory), path); if (file.entry || !file.path.empty()) return file; } +#ifdef ISAAC_REPENTOGON + for (std::string_view path : normalized) + { + size_t found = path.starts_with(PARENT_FOLDER) ? path.find(REPENTOGON_INSTALL_RESOURCES) : path.npos; + if (found != path.npos) path.remove_prefix(found + REPENTOGON_INSTALL_RESOURCES.size()); + file.path = disk_find(asset_path(REPENTOGON_RESOURCES), path); + if (!file.path.empty()) return file; + } +#endif + std::error_code error; + for (std::string_view path : paths) + if (path.starts_with('/') && std::filesystem::is_regular_file(path, error)) return {.path = std::string(path)}; return file; } diff --git a/src/engine/filesys.h b/src/engine/filesys.h index d1ed9fa..56f7bcf 100644 --- a/src/engine/filesys.h +++ b/src/engine/filesys.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -9,6 +10,7 @@ extern std::string dataDirectory; extern std::string languageDirectory; void archives_load(); +void archive_files_restrict(std::string_view name, std::span kept); bool is_archive_mounted(); void reload_resource_paths(); std::string resource_path(std::string_view path); diff --git a/src/engine/kage_graphics.cpp b/src/engine/kage_graphics.cpp index 825ef30..81810f9 100644 --- a/src/engine/kage_graphics.cpp +++ b/src/engine/kage_graphics.cpp @@ -2,6 +2,9 @@ #include "engine/data.h" #include "engine/gl.h" #include "engine/platform.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/gl_pipeline.h" +#endif #include #include #include @@ -349,7 +352,7 @@ ShaderUniform* Shader::find_uniform(std::string_view uniformName) } // The floats in an attribute of this format, logging an unknown one. -static int components_get(VertexFormat format) +int components_get(VertexFormat format) { if (format > VERTEX_END && format < VERTEX_FORMAT_COUNT) return VERTEX_COMPONENTS[format]; log_printf(LOG_ASSERT, "Unknown attribute format specified\n"); @@ -670,6 +673,9 @@ float* RenderBatch::quads_add(std::span sources, std::spanattributes_enable(vertices.data(), stride); +#ifdef ISAAC_REPENTOGON + if (!opengl_render_hook(*this, vertexCount)) manager.quads_draw(vertexCount); +#else manager.quads_draw(vertexCount); +#endif shader->attributes_disable(); vertices.clear(); @@ -942,13 +952,20 @@ RenderBatch* Manager::batch_get(ImageBase* image) return currentBatch; } -// (00a189a0, 00a12a60) Draws vertexCount vertices as quads, growing the shared index buffer to cover them. -void Manager::quads_draw(int vertexCount) +// (00a189a0, 00a12a60) The shared index buffer's indices of vertexCount vertices as quads, grown to cover them. +std::span Manager::quad_indices_get(int vertexCount) { size_t quadCount = vertexCount / QUAD_CORNERS; for (size_t quad = quadIndices.size() / QUAD_INDICES; quad < quadCount; quad++) for (int index : QUAD_INDEX_ORDER) quadIndices.push_back((uint16_t)(quad * QUAD_CORNERS + index)); - gl.DrawElements(GL_TRIANGLES, (int)quadCount * QUAD_INDICES, GL_UNSIGNED_SHORT, quadIndices.data()); + return {quadIndices.data(), quadCount * QUAD_INDICES}; +} + +// Draws vertexCount vertices as quads. +void Manager::quads_draw(int vertexCount) +{ + std::span indices = quad_indices_get(vertexCount); + gl.DrawElements(GL_TRIANGLES, (int)indices.size(), GL_UNSIGNED_SHORT, indices.data()); } // The width the projection spans: a render target's own, or the screen's orthographic width. diff --git a/src/engine/kage_graphics.h b/src/engine/kage_graphics.h index 8cd2027..eaac170 100644 --- a/src/engine/kage_graphics.h +++ b/src/engine/kage_graphics.h @@ -364,6 +364,7 @@ public: void blend_set(BlendType type); void batches_flush(); RenderBatch* batch_get(ImageBase* image); + std::span quad_indices_get(int vertexCount); void quads_draw(int vertexCount); float view_width_get(); float view_height_get(); @@ -387,6 +388,7 @@ public: extern Manager manager; +int components_get(VertexFormat format); std::string path_key(std::string_view path); uint8_t* texels_load(std::string_view path, int& width, int& height); ColorQuad color_quad_rect(const Vector& position, const Vector& size, const KColor& color); diff --git a/src/engine/kage_input.cpp b/src/engine/kage_input.cpp index f822386..3511506 100644 --- a/src/engine/kage_input.cpp +++ b/src/engine/kage_input.cpp @@ -1,6 +1,9 @@ #include "engine/kage_input.h" #include "engine/harness.h" #include "engine/platform.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/options.h" +#endif #include #include #include @@ -303,10 +306,14 @@ bool Manager::is_device_connected(int id) const // 00a21d40 (00a20df0, 00a211d0) Logs a connected gamepad, opens it as a new device and tells the connect listeners. // The axis and button counts it also logged are the same for every SDL gamepad, so they are left out. +// REPENTOGON's BlockUnknownDevices keeps out a gamepad SDL has no name for, as Windows names it "Unknown Device". void Manager::gamepad_add(SDL_JoystickID joystick) { const char* gamepadName = SDL_GetGamepadNameForID(joystick); std::string name = gamepadName ? gamepadName : "unknown"; +#ifdef ISAAC_REPENTOGON + if (!gamepadName && is_tweak_on(repentogonOptions.isBlockUnknownDevices)) return; // Patches/MiscFixes.cpp +#endif log_printf(LOG_INFO, "Gamepad Connected:\n"); log_printf(LOG_INFO, " Description: %s\n", name.c_str()); diff --git a/src/engine/platform.cpp b/src/engine/platform.cpp index 060b456..4940e22 100644 --- a/src/engine/platform.cpp +++ b/src/engine/platform.cpp @@ -140,6 +140,7 @@ void log_printf(LogLevel level, const char* format, ...) std::fputs(text.c_str(), logFile); std::fflush(logFile); } + if (logListener) logListener(text); if (!text.empty()) isLogLineStart = text.back() == '\n'; } diff --git a/src/engine/platform.h b/src/engine/platform.h index 5bd77c6..f82a920 100644 --- a/src/engine/platform.h +++ b/src/engine/platform.h @@ -130,3 +130,6 @@ uint64_t GetTimeNs(); std::time_t wall_time_get(); void log_open(const std::string& path); void log_printf(LogLevel level, const char* format, ...) __attribute__((format(printf, 2, 3))); + +// Where every logged text also goes, with the log's lock held (the overlay's Log window), or nowhere. +inline void (*logListener)(const std::string& text) = nullptr; diff --git a/src/entity/collision.cpp b/src/entity/collision.cpp index 626a08d..97243cb 100644 --- a/src/entity/collision.cpp +++ b/src/entity/collision.cpp @@ -17,6 +17,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/collision.h" +#include "repentogon/options.h" #endif // What crushes rocks on contact: The Nail, Leo (worn or rolled by Zodiac), Thunder Thighs, Stompy and Mega Mush. @@ -807,7 +808,8 @@ static int collision_class_get(Entity& entity) } // 006b2410 Whether two entities pass through each other: by their collision classes (the first's player-only class -// meets nothing), either being dead, or else either's HandleCollision ignoring the other. +// meets nothing, or only a player without vanilla parity), either being dead, or else either's HandleCollision ignoring +// the other. bool is_collision_ignored(Entity& first, Entity& second) { int firstClass = collision_class_get(first); @@ -815,8 +817,11 @@ bool is_collision_ignored(Entity& first, Entity& second) bool isNone = firstClass == ENTCOLL_NONE || secondClass == ENTCOLL_NONE; bool isNotPlayerObject = (firstClass == ENTCOLL_PLAYEROBJECTS && !is_player_object(second)) || (secondClass == ENTCOLL_PLAYEROBJECTS && !is_player_object(first)); - bool isNotPlayer = firstClass == ENTCOLL_PLAYERONLY || - (secondClass == ENTCOLL_PLAYERONLY && first.type != ENTITY_PLAYER); + bool isFirstPlayerOnly = firstClass == ENTCOLL_PLAYERONLY; +#ifdef ISAAC_REPENTOGON + isFirstPlayerOnly &= repentogonOptions.isVanillaParity || second.type != ENTITY_PLAYER; // ASMFixes.cpp +#endif + bool isNotPlayer = isFirstPlayerOnly || (secondClass == ENTCOLL_PLAYERONLY && first.type != ENTITY_PLAYER); bool isNotEnemy = (firstClass == ENTCOLL_ENEMIES && !Entity::is_enemy_type(second.type)) || (secondClass == ENTCOLL_ENEMIES && !Entity::is_enemy_type(first.type)); if (first.isDead || second.isDead || isNone || isNotPlayerObject || isNotPlayer || isNotEnemy) return true; diff --git a/src/entity/config.cpp b/src/entity/config.cpp index 4a70ceb..b748874 100644 --- a/src/entity/config.cpp +++ b/src/entity/config.cpp @@ -11,6 +11,7 @@ #include #ifdef ISAAC_REPENTOGON #include "entity/pickup/pickup.h" +#include "repentogon/options.h" #include "repentogon/xml.h" #include "repentogon/vanilla_fixes.h" #endif @@ -374,28 +375,27 @@ static void entity_children_read(EntityConfig_Entity& entity, DataNode node, Ent } // The mod sprite in slot that has an animation named after the character, or null. -static ANM2* mod_sprite_find(ModEntry& mod, ModContentSprite slot, std::string_view name) +static ANM2* mod_sprite_find(ModEntry& mod, ModContentSprite slot, EntityConfig_Player& player) { ANM2& sprite = mod.contentSprites[slot]; - return sprite.isLoaded && sprite.GetAnimationData(name) ? &sprite : nullptr; + return sprite.isLoaded && sprite.GetAnimationData(player.animation_name_get(sprite)) ? &sprite : nullptr; } // A modded character's menu sprites from its mod, a tainted one's own first, and whether its menu draws a background. static void player_sprites_load(EntityConfig_Player& player, ModEntry& mod) { - std::string name = player.GetDisplayName(); ANM2* background = nullptr; if (!player.bSkinParentName.empty()) for (int i = 0; i < PLAYER_SPRITE_COUNT; i++) - player.moddedSprites[i] = mod_sprite_find(mod, PLAYER_SPRITE_SLOTS_TAINTED[i], name); + player.moddedSprites[i] = mod_sprite_find(mod, PLAYER_SPRITE_SLOTS_TAINTED[i], player); for (int i = 0; i < PLAYER_SPRITE_COUNT; i++) - if (!player.moddedSprites[i]) player.moddedSprites[i] = mod_sprite_find(mod, PLAYER_SPRITE_SLOTS[i], name); + if (!player.moddedSprites[i]) player.moddedSprites[i] = mod_sprite_find(mod, PLAYER_SPRITE_SLOTS[i], player); background = player.moddedSprites[PLAYER_SPRITE_MENU_BACKGROUND]; if (!background) return; - background->SetFrame(name, 0); + background->SetFrame(player.animation_name_get(*background), 0); LayerState* layer = background->GetLayer("Background"); if (!layer) return; @@ -448,6 +448,21 @@ std::string EntityConfig_Player::GetDisplayName() return name_translate(name, "Players", NAME_LANGUAGE_CURRENT); } +// The animation a sprite of the character's menus plays: its display name. (Patches/ASMPatches/ASMLocalization.cpp, +// parity off) When the sprite lacks the translation of a #key name, the raw name's, else the English name's. +std::string EntityConfig_Player::animation_name_get(ANM2& sprite) +{ + std::string displayName = GetDisplayName(); +#ifdef ISAAC_REPENTOGON + if (repentogonOptions.isVanillaParity || sprite.GetAnimationData(displayName) || !name.starts_with('#')) + return displayName; + if (sprite.GetAnimationData(name)) return name; + std::string english = name_translate(name, "Players", LANGUAGE_ENGLISH); + if (sprite.GetAnimationData(english)) return english; +#endif + return displayName; +} + // 00694fb0 The config of an entity, falling back to subtype 0, then to variant 0, or null without one. EntityConfig_Entity* EntityConfig::GetEntity(int id, int variant, int subtype) { @@ -817,6 +832,16 @@ bool EntityConfig::boss_portraits_load(std::string_view path) return true; } +// (Patches/ASMPatches/ASMLocalization.cpp) Whether a tainted character's bSkinParent names its regular one by raw +// name, as the original matches the other way, parity off. +static bool is_tainted_raw_name_matched() +{ +#ifdef ISAAC_REPENTOGON + return !repentogonOptions.isVanillaParity; +#endif + return false; +} + // 0069d290 Points each visible modded character at its tainted twin: the visible modded one whose bSkinParent is the // first's display name. When names repeat, the first character of a name is the one linked. void EntityConfig::tainted_players_link() @@ -825,7 +850,7 @@ void EntityConfig::tainted_players_link() for (int i = PLAYER_TYPE_COUNT; i < (int)players.size(); i++) if (!players[i].isHidden && players[i].bSkinParentName.empty()) - regulars.emplace(players[i].GetDisplayName(), i); + regulars.emplace(is_tainted_raw_name_matched() ? players[i].name : players[i].GetDisplayName(), i); for (int i = PLAYER_TYPE_COUNT; i < (int)players.size(); i++) { diff --git a/src/entity/config.h b/src/entity/config.h index 5d965b9..c59e51a 100644 --- a/src/entity/config.h +++ b/src/entity/config.h @@ -261,6 +261,7 @@ struct EntityConfig_Player #endif std::string GetDisplayName(); + std::string animation_name_get(ANM2& sprite); }; // Destruction (00694ea0, 0069d5a0, 0069d780, 0069deb0) is the default. diff --git a/src/entity/effect/hazard.cpp b/src/entity/effect/hazard.cpp index e4db261..ed31e08 100644 --- a/src/entity/effect/hazard.cpp +++ b/src/entity/effect/hazard.cpp @@ -10,6 +10,9 @@ #include "level/room.h" #include "level/room_grid.h" #include "game/sfx_manager.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/player_config.h" +#endif #include // The hazard effects: the farts, the shockwaves and crackwaves that break the floor and crush what stands there, the @@ -414,7 +417,8 @@ static EffectUpdateEnd hallowed_ground_update(Entity_Effect& ground) return EFFECT_UPDATE_FINISH; } -// 005efb10 (Update's statue case) Sinks into its cell on its first frame. Dying, it cries in its player's voice. +// 005efb10 (Update's statue case) Sinks into its cell on its first frame. Dying, it cries in its player's voice, the +// character's own deathsound with REPENTOGON. static void statue_update(Entity_Effect& statue) { if (statue.state == 0) @@ -426,7 +430,11 @@ static void statue_update(Entity_Effect& statue) Entity* spawner = statue.spawnerEntity; Entity_Player* player = spawner ? spawner->ToPlayer() : nullptr; - npc_sound_play(SOUND_ISAACDIES, 1, 2, player ? player->get_voice_pitch() : 1); + int sound = SOUND_ISAACDIES; +#ifdef ISAAC_REPENTOGON + if (player) sound = player_sound_get(*player, PLAYER_SOUND_DEATH); // Patches/ASMPatches/ASMPlayer.cpp +#endif + npc_sound_play(sound, 1, 2, player ? player->get_voice_pitch() : 1); } // The fissure spawner (Ashpit) ripples the floor every 10 ticks and, every 150 frames over one more than its subtype's diff --git a/src/entity/entity.cpp b/src/entity/entity.cpp index d6126cf..fd7af88 100644 --- a/src/entity/entity.cpp +++ b/src/entity/entity.cpp @@ -670,6 +670,9 @@ int Entity::GetBossID() // 006a93a0 Sets it up as a fresh entity of the type: config stats, full health, default state and no status. void Entity::Init(int entityType, int entityVariant, int entitySubType, uint32_t seed) { +#ifdef ISAAC_REPENTOGON + entity_plus_reset(*this); +#endif type = entityType; variant = entityVariant; subtype = entitySubType; @@ -1286,6 +1289,9 @@ bool Entity::IsValidTarget(Entity* other) // 006acb00 Takes it out of the game: it stops existing and counts as dead, and Lua forgets it. void Entity::Remove() { +#ifdef ISAAC_REPENTOGON + isEntityRemoveStaged = isEntityRemoveStaged || !isRemovedByFactory; +#endif isExists = false; isDead = true; ReleaseLuaRef(this); diff --git a/src/entity/list.cpp b/src/entity/list.cpp index eee57d8..e81454c 100644 --- a/src/entity/list.cpp +++ b/src/entity/list.cpp @@ -16,6 +16,8 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/entities.h" +#include "repentogon/options.h" #endif constexpr const char* SHADOW_PNG = "gfx/shadow.png"; @@ -295,6 +297,9 @@ void EntityList::Reset() enemyDamageInflicted = 0; isAnyBaited = false; typeCache.clear(); +#ifdef ISAAC_REPENTOGON + isEntityRemoveStaged = false; +#endif } // 00418500 Adds a new entity to its lists, the render list in depth order, counting the enemies that shut the doors. @@ -411,6 +416,8 @@ void EntityList::Update(UpdateMode mode) #ifdef ISAAC_REPENTOGON if (mode == UPDATE_NORMAL) callback_notify(lua_engine_get(), {"PreRoomCollisionPass", MC_PRE_ROOM_COLLISION_PASS, std::nullopt}); + // (Patches/EntityManager.cpp) An entity removed after its own update leaves in this pass too. + if (std::exchange(isEntityRemoveStaged, false) && !repentogonOptions.isVanillaParity) tally.isAnyRemoved = true; #endif if (tally.isAnyRemoved || isBakedAway) removed_drop(); if (mode == UPDATE_NORMAL) rebuild_sublists(); diff --git a/src/entity/npc/portal.cpp b/src/entity/npc/portal.cpp index da591cf..a5b89d3 100644 --- a/src/entity/npc/portal.cpp +++ b/src/entity/npc/portal.cpp @@ -6,6 +6,9 @@ #include "level/level.h" #include "game/manager.h" #include "level/room.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/level.h" +#endif // The Portal hangs 30 up and summons a stage's enemy every 90 to 149 frames while fewer than three of its own live // (rechecking every 60 to 89), 1 to 5 times before it closes. Outside the chapters (the Blue Womb, the Dark Room and @@ -80,8 +83,12 @@ constexpr int SWARMER_PORTAL_VARIANT = 10; static int portal_group_get() { Game& game = *g_game; - bool isAlt = game.stageType != STAGETYPE_ORIGINAL; int stage = game.stage; + int stageType = game.stageType; +#ifdef ISAAC_REPENTOGON + portal_stage_override(stage, stageType); +#endif + bool isAlt = stageType != STAGETYPE_ORIGINAL; if (stage == STAGE_VOID) { int layout = game.room->GetRoomConfigStage(); @@ -113,8 +120,8 @@ static int portal_group_get() { case STAGE_BASEMENT_I: case STAGE_BASEMENT_II: - if (game.stageType == STAGETYPE_REPENTANCE) return PORTAL_GROUP_DOWNPOUR; - if (game.stageType == STAGETYPE_REPENTANCE_B) return PORTAL_GROUP_DROSS; + if (stageType == STAGETYPE_REPENTANCE) return PORTAL_GROUP_DOWNPOUR; + if (stageType == STAGETYPE_REPENTANCE_B) return PORTAL_GROUP_DROSS; return PORTAL_GROUP_BASEMENT; case STAGE_CAVES_I: case STAGE_CAVES_II: return PORTAL_GROUP_CAVES; @@ -256,7 +263,11 @@ void npc_portal_update(Entity_NPC& npc) return; } int stage = g_game->stage; - if (!isLil && (stage == STAGE_BLUE_WOMB || (stage >= STAGE_DARK_ROOM && stage != STAGE_VOID))) npc.Remove(); + bool isRemoved = !isLil && (stage == STAGE_BLUE_WOMB || (stage >= STAGE_DARK_ROOM && stage != STAGE_VOID)); +#ifdef ISAAC_REPENTOGON + isRemoved = isRemoved && !is_portal_kept(); +#endif + if (isRemoved) npc.Remove(); if (isLil) lil_portal_eye_update(npc); if (npc.state == NPC_STATE_IDLE) portal_wait(npc); diff --git a/src/entity/npc/render.cpp b/src/entity/npc/render.cpp index 8d1ae28..4d4f4ff 100644 --- a/src/entity/npc/render.cpp +++ b/src/entity/npc/render.cpp @@ -18,6 +18,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/gl_pipeline.h" #endif constexpr float NPC_SCREEN_SCALE = 0.65f; @@ -389,6 +390,7 @@ static bool npc_is_health_bar_shown(Entity_NPC& npc) void Entity_NPC::Render(const Vector& renderOffset) { #ifdef ISAAC_REPENTOGON + RenderContextScope context(RENDER_CONTEXT_NPC, this); std::optional moved = render_pre_run({"PreNPCRender", MC_PRE_NPC_RENDER, (int)type}, this, renderOffset); if (!moved) return; const Vector& offset = *moved; diff --git a/src/entity/pickup/item_config.cpp b/src/entity/pickup/item_config.cpp index f255a06..54152f1 100644 --- a/src/entity/pickup/item_config.cpp +++ b/src/entity/pickup/item_config.cpp @@ -7,6 +7,8 @@ #include "game/mod_manager.h" #ifdef ISAAC_REPENTOGON #include "repentogon/items.h" +#include "repentogon/options.h" +#include "repentogon/xml.h" #endif #include #include @@ -611,7 +613,8 @@ void ItemConfig::Unload() } // An item element read into a new item: its type from its tag, then its attributes, its gfx under gfxRoot. -// An unknown tag asserts and leaves a null item. +// An unknown tag asserts and leaves a null item. Without a craftquality the item crafts as 0, as the original's check +// for an unset one never sees it, unless REPENTOGON's fix makes it its quality. static std::unique_ptr item_parse(DataNode node, std::string_view gfxRoot) { auto item = std::make_unique(); @@ -635,7 +638,9 @@ static std::unique_ptr item_parse(DataNode node, std::string_vi else if (tag != "null") log_print(LOG_ASSERT, "ItemConfig: unknown item type: %.*s\n", (int)tag.size(), tag.data()); item->achievementId = -1; - item->craftingQuality = CRAFTING_QUALITY_UNSET; +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) item->craftingQuality = CRAFTING_QUALITY_UNSET; // ASMFixes.cpp +#endif attr_read(node, "id", item->id); attr_read(node, "name", item->name); @@ -647,6 +652,7 @@ static std::unique_ptr item_parse(DataNode node, std::string_vi if (auto tags = node_attr_find(node, "tags")) item->tags = tags_parse(*tags); #ifdef ISAAC_REPENTOGON if (auto tags = node_attr_find(node, "customtags")) custom_tags_parse(*tags, item->customTags); + if (item->IsNull() && item->customTags.erase("revive")) item->customTags.insert("reviveeffect"); if (auto caches = node_attr_find(node, "customcache")) custom_tags_parse(*caches, item->customCaches); if (item->customTags.contains(CUSTOM_TAG_FLYING) || item->customTags.contains(CUSTOM_TAG_FLYING_EFFECT)) item->cacheFlags |= CACHE_FLYING; @@ -766,6 +772,10 @@ static ItemConfig_Costume costume_parse(DataNode node, std::string_view anm2Root attr_read(node, "overwriteColor", costume.isOverwriteColor); attr_read(node, "forceHeadColor", costume.isForceHeadColor); attr_read(node, "forceBodyColor", costume.isForceBodyColor); +#ifdef ISAAC_REPENTOGON + std::optional name = node_attr_find(node, "name"); + costume.name = name ? std::string(*name) : file_name_get(node_attr_find(node, "anm2path").value_or("")); +#endif return costume; } diff --git a/src/entity/pickup/item_config.h b/src/entity/pickup/item_config.h index e0e9963..51305e9 100644 --- a/src/entity/pickup/item_config.h +++ b/src/entity/pickup/item_config.h @@ -297,6 +297,10 @@ constexpr uint32_t PILL_HORSE_FLAG = 0x800; struct ItemConfig_Costume { std::string anm2Path; +#ifdef ISAAC_REPENTOGON + // (XMLData.cpp's XMLCostume) The name XMLData knows it by: its name attribute, else its anm2path's file name. + std::string name; +#endif int id = -1; int priority = 0; int skinColor = -1; diff --git a/src/entity/pickup/item_pool.cpp b/src/entity/pickup/item_pool.cpp index 7ec7d11..8171ad5 100644 --- a/src/entity/pickup/item_pool.cpp +++ b/src/entity/pickup/item_pool.cpp @@ -18,6 +18,8 @@ #include "repentogon/callbacks.h" #include "repentogon/items.h" #include "repentogon/level.h" +#include "repentogon/custom_pools.h" +#include "repentogon/pool_items.h" #include "repentogon/vanilla_fixes.h" #endif @@ -302,6 +304,9 @@ void ItemPool::load_pools(std::string_view path, PoolsLoad load) auto found = std::ranges::find(POOL_NAMES, *name); if (found == std::end(POOL_NAMES)) { +#ifdef ISAAC_REPENTOGON + if (pool_id_find(*name) >= 0) continue; // Patches/ItemPoolManager.cpp: a mod's own pool +#endif std::string text(*name); log_printf(LOG_INFO, "Pool %s not found, please recheck config or item pool list", text.c_str()); continue; @@ -321,9 +326,16 @@ void ItemPool::shuffle_pools() { std::mt19937 twister(itemPoolRNG._seed); +#ifdef ISAAC_REPENTOGON + pool_items_load(); + custom_pools_fill(itemPoolRNG); +#endif for (ItemPool_Item& pool : pools) for (size_t last = pool.poolList.size() - std::min(pool.poolList.size(), 1); last > 0; last--) std::swap(pool.poolList[last], pool.poolList[twister() % (last + 1)]); +#ifdef ISAAC_REPENTOGON + pool_items_finalize(); +#endif } // 007367d0 Saves the pools into a game state: each pool's item weights and Bible chance, the seeds, the removed @@ -356,6 +368,9 @@ void ItemPool::StoreGameState(GameStateItemPool& state) // 00732c70 ItemPool_Item& ItemPool::GetPool(ItemPoolType poolType) { +#ifdef ISAAC_REPENTOGON + if (ItemPool_Item* custom = custom_pool_get(poolType)) return *custom; +#endif return pools[poolType]; } @@ -451,6 +466,12 @@ int ItemPool::get_chaos_pool(RNG& rng) int weight = (int)(pools[id].totalWeight * CHAOS_WEIGHT_SCALE); if (isGreedPool == isGreed && weight > 0) outcomes.push_back({id, weight}); } +#ifdef ISAAC_REPENTOGON + std::vector> custom; + custom_pools_chaos_add(custom, isGreed, CHAOS_WEIGHT_SCALE); + for (auto [id, weight] : custom) + if (weight > 0) outcomes.push_back({id, weight}); +#endif rng.Next(); return outcome_pick(outcomes, rng_make(rng._seed, POOL_SHIFT)); @@ -464,6 +485,9 @@ std::vector ItemPool::GetItemPoolsForCollectible(int collectible) for (int id = 0; id < POOL_COUNT; id++) if (std::ranges::any_of(pools[id].poolList, [&](PoolItem& item) { return item.itemId == collectible; })) found.push_back(id); +#ifdef ISAAC_REPENTOGON + custom_pools_with_collectible_add(collectible, found); +#endif return found; } @@ -486,7 +510,11 @@ int ItemPool::GetCollectible(ItemPoolType poolType, uint32_t drawSeed, uint32_t uint32_t daily = g_game->dailyChallenge.specialDailyId; if (drawSeed == 0) log_printf(LOG_ASSERT, "ItemPool::GetCollectible Seed is 0\n"); - if (poolType < 0 || poolType >= POOL_COUNT || drawSeed == 0) return 0; + int poolCount = POOL_COUNT; +#ifdef ISAAC_REPENTOGON + poolCount += custom_pool_count(); +#endif + if (poolType < 0 || poolType >= poolCount || drawSeed == 0) return 0; if (defaultItem < 0 || defaultItem > MAX_DEFAULT_ITEM) defaultItem = 0; bool isDecrease = !(flags & POOL_FLAG_NO_DECREASE); @@ -519,7 +547,7 @@ int ItemPool::GetCollectible(ItemPoolType poolType, uint32_t drawSeed, uint32_t if (!list.empty()) if (int item = GetCollectibleFromList(list, pickRng.Next(), 0, listFlags)) return item; - ItemPool_Item* items = &pools[pool]; + ItemPool_Item* items = &GetPool((ItemPoolType)pool); PoolItem* pick = pick_weighted(*items, flags, pickRng.RandomFloat() * items->totalWeight); std::optional drawn; for (int rerolls = REROLLS; pick && !drawn;) @@ -528,7 +556,7 @@ int ItemPool::GetCollectible(ItemPoolType poolType, uint32_t drawSeed, uint32_t if (pick->isUnlocked && !isKept) break; if (!isKept) { - if (isChaos) items = &pools[lastPool = get_chaos_pool(poolRng)]; + if (isChaos) items = &GetPool((ItemPoolType)(lastPool = get_chaos_pool(poolRng))); pick = pick_weighted(*items, flags, pickRng.RandomFloat() * items->totalWeight); continue; } @@ -718,6 +746,9 @@ void ItemPool::ResetCollectible(int collectible) for (ItemPool_Item& pool : pools) for (PoolItem& item : pool.poolList) if (item.itemId == collectible) item.weight = item.initialWeight; +#ifdef ISAAC_REPENTOGON + custom_pools_collectible_reset(collectible); +#endif } // 005b14b0 Keeps a collectible out of draws until the room changes. @@ -736,6 +767,15 @@ void ItemPool::ResetRoomBlacklist() // treasure pool. void ItemPool::AddBibleUpgrade(int add, int poolType) { +#ifdef ISAAC_REPENTOGON + // (Patches/ItemPoolManager.cpp) A mod's pool by its id, and every pool past the last of them. + if (ItemPool_Item* custom = custom_pool_get(poolType)) + { + custom->bibleUpgrade += add; + return; + } + if (poolType >= POOL_COUNT) custom_pools_bible_add(add); +#endif if (poolType < POOL_COUNT) pools[std::max(poolType, 0)].bibleUpgrade += add; else for (ItemPool_Item& pool : pools) pool.bibleUpgrade += add; diff --git a/src/entity/pickup/pickup.cpp b/src/entity/pickup/pickup.cpp index a900a74..d63d76f 100644 --- a/src/entity/pickup/pickup.cpp +++ b/src/entity/pickup/pickup.cpp @@ -2704,15 +2704,20 @@ int Entity_Pickup::GetCoinValue() { #ifdef ISAAC_REPENTOGON CallbackRun run = {"PickupGetCoinValue", MC_PICKUP_GET_COIN_VALUE, subtype}; - if (variant == PICKUP_COIN) return callback_integer_run(lua_engine_get(), run, coin_value_get(*this, coin_worth()), this); + if (variant == PICKUP_COIN) return callback_integer_run(lua_engine_get(), run, coin_worth(), this); #endif return coin_worth(); } -// GetCoinValue without mods, as Ultra Greed's search for coins reads it. +// GetCoinValue without mods' callbacks, as Ultra Greed's search for coins reads it. A mod's coin is worth what its +// entities2.xml says (Patches/GetCoinValue.cpp). int Entity_Pickup::coin_worth() { - return variant == PICKUP_COIN && subtype >= COIN_PENNY && subtype <= COIN_GOLDEN ? COIN_VALUES[subtype] : 0; + int worth = variant == PICKUP_COIN && subtype >= COIN_PENNY && subtype <= COIN_GOLDEN ? COIN_VALUES[subtype] : 0; +#ifdef ISAAC_REPENTOGON + if (variant == PICKUP_COIN) worth = coin_value_get(*this, worth); +#endif + return worth; } // 006ee390 Whether a player can collect the kind straight into their counters or pockets, if it is free or the price diff --git a/src/entity/pickup/slot.cpp b/src/entity/pickup/slot.cpp index ed144b3..b2417dd 100644 --- a/src/entity/pickup/slot.cpp +++ b/src/entity/pickup/slot.cpp @@ -26,6 +26,7 @@ #include "repentogon/callbacks.h" #include "repentogon/items.h" #include "repentogon/player.h" +#include "repentogon/player_features.h" #endif // The run's state flags of a broken or jammed donation machine, and of one blown up. @@ -1364,6 +1365,9 @@ void Entity_Slot::greed_donation_pay(Entity_Player& player) { if ((uint32_t)player.playerType < (uint32_t)COMPLETION_PLAYER_TYPE_COUNT) data.IncreaseEventCounter(COMPLETION_MARKS[player.playerType][COMPLETION_GREED_DONATION].counter, 1); +#ifdef ISAAC_REPENTOGON + else greed_donation_add(player.playerType); // Patches/PlayerFeatures.cpp +#endif data.IncreaseEventCounter(EVENT_COUNTER_GREED_DONATIONS, 1); count++; } diff --git a/src/entity/player/frame.cpp b/src/entity/player/frame.cpp index 8bc6575..ec6f469 100644 --- a/src/entity/player/frame.cpp +++ b/src/entity/player/frame.cpp @@ -1,5 +1,6 @@ #include "entity/player/player.h" #ifdef ISAAC_REPENTOGON +#include "repentogon/gl_pipeline.h" #include "repentogon/options.h" #endif #include "entity/config.h" @@ -1971,6 +1972,7 @@ void Entity_Player::Render(const Vector& drawOffset) { Vector offset = drawOffset; #ifdef ISAAC_REPENTOGON + RenderContextScope context(RENDER_CONTEXT_PLAYER, this); if (!render_pre_run({"PrePlayerRender", MC_PRE_PLAYER_RENDER, variant}, this, offset)) return; #endif if (target) diff --git a/src/entity/player/items.cpp b/src/entity/player/items.cpp index fa00b25..e6abc33 100644 --- a/src/entity/player/items.cpp +++ b/src/entity/player/items.cpp @@ -20,6 +20,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/custom_pools.h" #include "repentogon/items.h" #include "repentogon/player.h" #endif @@ -1632,6 +1633,9 @@ void Entity_Player::AddCollectible(int type, int charge, bool isFirstTime, int a if (charge < 0) charge = item->initCharge; if (charge < 0) charge = GetCollectibleMaxCharge(type, varData); std::string_view poolName = poolType >= 0 && poolType < POOL_COUNT ? POOL_NAMES[poolType] : ""; +#ifdef ISAAC_REPENTOGON + poolName = pool_name_get(poolType); +#endif log_printf(LOG_INFO, "Adding collectible %d (%s) to player %d (%s) from pool %s\n", type, item->GetLocalizedName(LANGUAGE_CURRENT).c_str(), playerIndex, name.c_str(), std::string(poolName).c_str()); diff --git a/src/entity/player/manager.cpp b/src/entity/player/manager.cpp index 8c42cd5..a55a7ec 100644 --- a/src/entity/player/manager.cpp +++ b/src/entity/player/manager.cpp @@ -21,6 +21,9 @@ #include "level/room_grid.h" #include "engine/seeds.h" #include "engine/texture_cache.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/player_config.h" +#endif #include #include @@ -205,7 +208,8 @@ void PlayerManager::init_main_player(int playerType, uint32_t seed) } // 009bdc60 Draws the run's co-op unlocks: up to five of the unlocked babies the game ships, shuffled by seed, and the -// characters the join carousel offers (a random pick, the unlocked ones, Eden with tokens, and the mods' visible ones). +// characters the join carousel offers (a random pick, the unlocked ones, Eden with tokens, and the mods' visible ones, +// which REPENTOGON's ASMPlayerManager.cpp also keeps out while locked or hidden by an achievement). // The original reads 71 babies and a config for every character unchecked. Fewer babies or a missing config is skipped. void PlayerManager::init_random_unlocks(uint32_t seed) { @@ -235,7 +239,13 @@ void PlayerManager::init_random_unlocks(uint32_t seed) coopPlayerTypes.push_back(type); } for (size_t type = PLAYER_MODDED_FIRST; type < players.size(); type++) - if (!players[type].isHidden) coopPlayerTypes.push_back((int)type); + { + bool isShown = !players[type].isHidden; +#ifdef ISAAC_REPENTOGON + isShown = isShown && is_player_unlocked((int)type) && !is_player_hidden_by_achievement((int)type); +#endif + if (isShown) coopPlayerTypes.push_back((int)type); + } } // 009b9cd0 Spawns a co-op player of a type into the room, up to 64 players, on the Glowing Hourglass slot after the diff --git a/src/entity/player/player.cpp b/src/entity/player/player.cpp index 608dda7..6202a50 100644 --- a/src/entity/player/player.cpp +++ b/src/entity/player/player.cpp @@ -1364,13 +1364,17 @@ void Entity_Player::wooden_cross_mantles_add() } // 007a49e0 Leaves a blood splat where a player with health is down to its last heart, red unless its blood is -// white (Kidney Stone, Eve and Tainted Eve keep the effect's own color). +// white (Kidney Stone, Eve and Tainted Eve keep the effect's own color). Without vanilla parity no character of the +// Lost's health leaves one, modded ones too. void Entity_Player::spawn_low_health_blood_splat() { if (variant != PLAYER_VARIANT_PLAYER || boneHearts + soulHearts + redHearts >= 2 || isCoopGhost) return; for (int type : {PLAYER_THELOST, PLAYER_THEFORGOTTEN, PLAYER_THESOUL, PLAYER_THELOST_B, PLAYER_THEFORGOTTEN_B, PLAYER_THESOUL_B, PLAYER_JACOB2_B}) if (playerType == type) return; +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity && GetHealthType() == HEALTH_NO_HEALTH) return; // ASMPlayer.cpp +#endif Entity* splat = g_game->Spawn({.position = pos, .type = ENTITY_EFFECT, .variant = EFFECT_BLOOD_SPLAT, .seed = Random()}); diff --git a/src/entity/player/player.h b/src/entity/player/player.h index 8c93266..dd09ae4 100644 --- a/src/entity/player/player.h +++ b/src/entity/player/player.h @@ -1848,6 +1848,10 @@ public: bool isEvaluatingHealthType = false; // REPENTOGON's camoOverride (EntityPlayerPlus): a mod's SetForceCamoEffect fades the player as Camo Undies does. bool isCamoForced = false; + // REPENTOGON's previousControllerIndex (EntityPlayerPlus): the controller it shared until a hand-out took it, -1. + int previousControllerIndex = -1; + // REPENTOGON's restoreTwinID (EntityPlayerPlus): the main twin's index a restored player was saved with, -1. + int restoreTwinIndex = -1; // REPENTOGON's itemSpoofs (EntityPlayerPlus): its innate and blocked collectibles and trinkets. PlayerItemSpoofs itemSpoofs; CustomCacheState customCache; diff --git a/src/entity/player/pockets.cpp b/src/entity/player/pockets.cpp index 5f8cecc..193e996 100644 --- a/src/entity/player/pockets.cpp +++ b/src/entity/player/pockets.cpp @@ -431,7 +431,7 @@ void Entity_Player::UsePill(int pillEffect, int pillColor, uint32_t useFlags) RNG& rng = GetCollectibleRNG(COLLECTIBLE_PHD); game.itemPool.on_pill_used(pillColor, rng.Next(), rng._seed); } - else game.itemPool.identifiedPillEffects[std::min(color, PILL_COLOR_GOLD)] = true; + else game.itemPool.IdentifyPill(pillColor); ItemConfig& config = g_manager->itemConfig; ItemConfig_Pill* pill = pillEffect >= 0 ? config.GetPillEffect(pillEffect) : nullptr; diff --git a/src/entity/weapon/tear_flags.cpp b/src/entity/weapon/tear_flags.cpp index bb8ae44..2679604 100644 --- a/src/entity/weapon/tear_flags.cpp +++ b/src/entity/weapon/tear_flags.cpp @@ -23,6 +23,7 @@ #include #include #ifdef ISAAC_REPENTOGON +#include "repentogon/options.h" #include "repentogon/weapons.h" #endif @@ -904,11 +905,15 @@ void Entity_Tear::gfuel_trail_spawn(float angle) } // (006670f0's Godhead) The glowing tear burns the vulnerable enemies in a ring around it every frame, beyond its -// own touch, but not its spawner's kin. +// own touch, but not its spawner's kin. Without vanilla parity it only looks among the enemies. void Entity_Tear::glow_burn() { if (!tearFlags[TEAR_GLOW]) return; - for (Entity* enemy : entity_query_radius(pos, size * GLOW_QUERY_SCALE + GLOW_QUERY_REACH, QUERY_ALL)) + uint32_t partitions = QUERY_ALL; +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) partitions = QUERY_ENEMIES; // Patches/ASMPatches/ASMTweaks.cpp +#endif + for (Entity* enemy : entity_query_radius(pos, size * GLOW_QUERY_SCALE + GLOW_QUERY_REACH, partitions)) { if (!enemy->IsVulnerableEnemy(nullptr)) continue; if (spawnerEntity && spawnerEntity->IsDescendantOf(enemy)) continue; diff --git a/src/game/debug_renderer.cpp b/src/game/debug_renderer.cpp index f70121e..b00b629 100644 --- a/src/game/debug_renderer.cpp +++ b/src/game/debug_renderer.cpp @@ -12,6 +12,9 @@ #include "level/room.h" #include "level/room_config.h" #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/custom_pools.h" +#endif #include constexpr KColor SHAPE_DEFAULT_COLOR = kcolor_rgba(1, 1, 0, 1); @@ -312,10 +315,14 @@ static void info_history_render(Entity_Player& player, Vector origin) row.y += INFO_ROW_HEIGHT; ItemConfig_Item* item = entry.isTrinket ? items.GetTrinket((uint32_t)entry.id) : items.GetCollectible(entry.id); bool isPool = entry.itemPoolType >= 0 && entry.itemPoolType < POOL_COUNT; + std::string_view poolName = isPool ? POOL_NAMES[entry.itemPoolType] : std::string_view(); +#ifdef ISAAC_REPENTOGON + poolName = pool_name_get(entry.itemPoolType); // Patches/ItemPoolManager.cpp's Debug 12 pool names +#endif info_row_draw(row, entry.isTrinket ? INFO_TRINKET_COLOR : WHITE, std::format("{}: time: {}, stage: {}.{}, room type: {}, pool: {}", info_item_name(item), entry.time, entry.levelStage, entry.stageType, room_type_name(entry.roomType), - isPool ? POOL_NAMES[entry.itemPoolType] : std::string_view()), + poolName), INFO_HISTORY_ROW_WIDTH); } } diff --git a/src/game/end.cpp b/src/game/end.cpp index 980ea78..df3d495 100644 --- a/src/game/end.cpp +++ b/src/game/end.cpp @@ -17,6 +17,7 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" #include "repentogon/player.h" +#include "repentogon/progress.h" #include "repentogon/saves.h" #endif @@ -199,6 +200,7 @@ void PlayerManager::unlock_completion_mark(int completionType) CallbackRun run = {"PostCompletionEvent", MC_POST_COMPLETION_EVENT, completionType}; callback_notify(lua_engine_get(), run, completionType); }}; + modded_marks_record(completionType); // Patches/CompletionTracker.cpp #endif Game* game = g_game; if (!game) return; diff --git a/src/game/exit.cpp b/src/game/exit.cpp index ab8f740..597519f 100644 --- a/src/game/exit.cpp +++ b/src/game/exit.cpp @@ -9,6 +9,10 @@ #include "level/room_transition.h" #include "level/stage_transition.h" #include "engine/texture_cache.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/pool_items.h" +#include "repentogon/virtual_rooms.h" +#endif constexpr int EXIT_STAGE_TRANSITION_DURATION = 50; @@ -145,4 +149,8 @@ void Game::Exit(bool isSaving) pause_screen_reset(game.pauseScreen); game.framesSinceRoomTransition = 0; game.isStarted = false; +#ifdef ISAAC_REPENTOGON + pool_items_unready(); + virtual_rooms_weights_reset_all(); +#endif } diff --git a/src/game/game.cpp b/src/game/game.cpp index 786dc93..4e9d644 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -25,6 +25,7 @@ extern "C" } #ifdef ISAAC_REPENTOGON #include "repentogon/level.h" +#include "repentogon/pool_items.h" #include "repentogon/ui_patches.h" #include "repentogon/xml.h" #endif @@ -452,12 +453,23 @@ void Game::ResetState() } // 007384d0 Replaces the current room with a new one and clears the floor: no rooms, stage, curses or Greed waves. -// The old room stays current while it is deleted, as its entities' removal reads it. +// The old room stays current while it is deleted, as its entities' removal reads it. Without vanilla parity the new +// room is made in the old one's place, so a pointer to the room stays good. void Game::level_reset() { - delete room.get(); - room.release(); - room = std::make_unique(); +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity && room) // Patches/ASMPatches/ASMFixes.cpp: the room keeps its address + { + room->~Room(); + new (room.get()) Room(); + } + else +#endif + { + delete room.get(); + room.release(); + room = std::make_unique(); + } startingRoomIdx = -1; nbRooms = 0; stage = 0; @@ -681,6 +693,9 @@ void Game::NextVictoryLap() constexpr RNG LAP_SEED_SHIFTS = {0, 1, 9, 29}; Manager& manager = *g_manager; +#ifdef ISAAC_REPENTOGON + pool_items_unready(); +#endif manager.persistentGameData.SetReadOnly(true); if (++victoryLap == 1) difficulty = DIFFICULTY_HARD; for (Entity_Player* player : std::vector(playerManager.playerList)) @@ -1145,6 +1160,9 @@ bool Game::IsGreedMode() // Certificate floor in its dimension, else the floor's stage and type. It never used its argument. int Game::GetStageID() { +#ifdef ISAAC_REPENTOGON + if (std::optional voidEx = void_ex_room_stage_get()) return *voidEx; +#endif if (g_game->challenge == CHALLENGE_RED_REDEMPTION) return RoomConfig::GetStageID(stage, GetRoomStageType(currentRoomIdx), ROOM_MODE_CURRENT); if (currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE) return STAGE_ID_HOME; diff --git a/src/game/manager.cpp b/src/game/manager.cpp index 9d012f8..1ab763f 100644 --- a/src/game/manager.cpp +++ b/src/game/manager.cpp @@ -16,9 +16,13 @@ #include "repentogon/achievements.h" #include "repentogon/callbacks.h" #include "repentogon/collision.h" +#include "repentogon/render.h" #include "repentogon/player.h" +#include "repentogon/progress.h" #include "repentogon/ui_patches.h" +#include "repentogon/controllers.h" #include "repentogon/options.h" +#include "repentogon/player_features.h" #include "repentogon/repentogon.h" #include "repentogon/save_state_manager.h" #include "repentogon/vanilla_fixes.h" @@ -522,6 +526,9 @@ static void shaders_load() std::string fragment = std::string(SHADERS_FOLDER) + shader.fragment + FRAGMENT_EXTENSION; log_printf(LOG_INFO, "Initialize %s\n", shader.message); +#ifdef ISAAC_REPENTOGON + if (mesa_shader_load(shader.name, shader.attributes)) continue; +#endif KAGE::Graphics::manager.shader_load(shader.name, shader.attributes, {vertex, fragment}); } log_printf(LOG_INFO, "%s", SHADER_BANNER); @@ -559,6 +566,7 @@ void IsaacStartup(int argc, uint8_t** argv) } #ifdef ISAAC_REPENTOGON repentogonOptions.load(); + language_archives_restrict(); #endif LuaEngine* luaEngine = new LuaEngine(); g_luaEngine = luaEngine; @@ -786,7 +794,13 @@ bool Manager::LoadChallenges(std::string_view path, ChallengeSource source) if (name == CHALLENGE_ID) challengeId = std::atoi(text.data()); else if (found != CHALLENGE_ATTRIBUTES.end()) found->second(param, text); - else log_printf(LOG_ASSERT, "Got invald parameter %s when reading challenges!\n", nameText.c_str()); + else + { +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) continue; // Patches/ASMPatches/ASMTweaks.cpp +#endif + log_printf(LOG_ASSERT, "Got invald parameter %s when reading challenges!\n", nameText.c_str()); + } } if (source == CHALLENGES_MOD) challengeParams.push_back(std::move(param)); @@ -1098,7 +1112,11 @@ static void controller_popup_open(Manager& manager, int slot) } manager.controllerDisconnectedPopupId = manager.popupQueue.push(popup); +#ifdef ISAAC_REPENTOGON + if (!g_menuManager && g_game) controller_unassign(*g_game->playerManager.GetPlayer(slot)); +#else if (!g_menuManager && g_game) g_game->playerManager.GetPlayer(slot)->SetControllerIndex(-1, 1); +#endif if (!g_menuManager || g_menuManager->selectedMenuId != MENU_KEY_CONFIG) return; std::vector& history = g_menuManager->menuStateHistory; @@ -1172,11 +1190,18 @@ void Manager::update_controller_popups() if (g_menuManager) g_menuControllerIndex = answer; else if (g_game) { +#ifdef ISAAC_REPENTOGON + controller_reassign(*g_game->playerManager.GetPlayer(slot), answer, HANDOUT_DISCONNECT); +#else g_game->playerManager.GetPlayer(slot)->SetControllerIndex(answer, 1); +#endif if (slot == 0) g_menuControllerIndex = answer; g_game->playerManager.coop_slots_reset(); } KAGE::Input::manager.update_devices(); +#ifdef ISAAC_REPENTOGON + if (is_controller_handout_ended()) break; +#endif } } @@ -1202,6 +1227,8 @@ void Manager::SetSaveSlot(uint32_t slot) currentSaveSlot = slot; #ifdef ISAAC_REPENTOGON achievements_slot_load(slot); + progress_slot_load(slot); + player_features_slot_load(slot); save_slot_post(slot); #endif } diff --git a/src/game/mod_manager.cpp b/src/game/mod_manager.cpp index ab17674..28f6548 100644 --- a/src/game/mod_manager.cpp +++ b/src/game/mod_manager.cpp @@ -17,9 +17,13 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/achievements.h" #include "repentogon/callbacks.h" +#include "repentogon/custom_pools.h" #include "repentogon/items.h" #include "repentogon/mod_curses.h" +#include "repentogon/progress.h" #include "repentogon/vanilla_fixes.h" +#include "repentogon/virtual_rooms.h" +#include "repentogon/xml_data.h" #include "repentogon/render.h" #include "repentogon/repentogon.h" #endif @@ -332,7 +336,7 @@ static ANM2* character_sprite_play(int playerType, PlayerSprite which) EntityConfig_Player* player = g_manager->entityConfig.GetPlayer(playerType); ANM2* sprite = player ? player->moddedSprites[which] : nullptr; - if (sprite) sprite->Play(player->GetDisplayName()); + if (sprite) sprite->Play(player->animation_name_get(*sprite)); return sprite; } @@ -574,6 +578,9 @@ void ModManager::ListMods() void ModManager::LoadModContent() { #ifdef ISAAC_REPENTOGON + isModsLoaded = false; + xml_data_reset(); + virtual_rooms_clear(); achievements_mods_load(); #endif for (auto& mod : mods) @@ -598,7 +605,10 @@ void ModManager::LoadModContent() #ifdef ISAAC_REPENTOGON achievements_reload(); player_content_post_load(); + challenges_content_load(); + custom_pools_load(); unfiltered_notify("PostModsLoaded", MC_POST_MODS_LOADED); + isModsLoaded = true; #endif } @@ -652,8 +662,11 @@ void ModManager::LoadModRooms(int stageId, int mode) if (!is_resource_found(path)) continue; if (set.mod_rooms_merge(path, stageId, (RoomMode)mode)) continue; log_printf(LOG_INFO, "[ModManager] bad room config header in %s!\n", path.c_str()); - return; + break; } +#ifdef ISAAC_REPENTOGON + double_trouble_variants_reserve(stageId, mode); +#endif } // 008f4a30 Reads and loads the shaders of each loaded mod's shaders.xml. @@ -722,6 +735,10 @@ std::string ModManager::TryRedirectPath(std::string_view filePath) if (!redirect.modEntry && !path.empty() && is_resource_found(path.append(filePath))) redirect = {&mod, path}; } +#ifdef ISAAC_REPENTOGON + if (redirect.modEntry && !repentogonOptions.isVanillaParity && redirect.filePath.ends_with(".xml")) + log_printf(LOG_INFO, "[warn] Redirected .xml config %s\n", redirect.filePath.c_str()); // Patches/MiscFixes.cpp +#endif return redirect.modEntry ? redirect.filePath : std::string(filePath); } diff --git a/src/game/over.cpp b/src/game/over.cpp index 1f0d0b6..0d2be23 100644 --- a/src/game/over.cpp +++ b/src/game/over.cpp @@ -9,6 +9,9 @@ #include "game/mod_manager.h" #include "engine/platform.h" #include "engine/render_passes.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/options.h" +#endif #include #include #include @@ -141,6 +144,9 @@ void GameOver::Show() Manager& manager = *g_manager; if (game.pauseScreen.state != PAUSE_HIDDEN) game.pauseScreen.hide(); +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) moddedEnemy = nullptr; // Patches/MiscFixes.cpp +#endif state = GAME_OVER_SHOWN; isStopSoundsPending = true; manager.popupButtons.reset(BUTTONS_SLIDE_IN); diff --git a/src/game/persistent_game_data.cpp b/src/game/persistent_game_data.cpp index 654988c..c5fb0e6 100644 --- a/src/game/persistent_game_data.cpp +++ b/src/game/persistent_game_data.cpp @@ -16,6 +16,7 @@ #include "repentogon/achievements.h" #include "repentogon/callbacks.h" #include "repentogon/level.h" +#include "repentogon/progress.h" #include "repentogon/saves.h" #endif @@ -1106,6 +1107,7 @@ bool PersistentGameData::Unlocked(int achievementID) void PersistentGameData::IncreaseEventCounter(int eventCounter, int num) { #ifdef ISAAC_REPENTOGON + if (!is_hook_inner()) achievement_events_run(*this, eventCounter); if (!is_hook_inner() && completion_mark_hook(*this, eventCounter, num)) return; #endif if (isReadOnly || eventCounter < 0 || eventCounter >= EVENT_COUNTER_COUNT) return; @@ -1243,6 +1245,9 @@ void PersistentGameData::AddChallenge(int challengeID) challenges[challengeID] = true; TryUnlock(CHALLENGE_WIN_ACHIEVEMENTS[challengeID]); } +#ifdef ISAAC_REPENTOGON + if (challengeID >= CHALLENGE_COUNT) mod_challenge_complete(challengeID); // Patches/ChallengesStuff.cpp +#endif #ifdef ISAAC_REPENTOGON callback_notify(lua_engine_get(), {"PostChallengeDone", MC_POST_CHALLENGE_DONE, challengeID}, challengeID); #endif diff --git a/src/game/restore.cpp b/src/game/restore.cpp index ff7a213..d0d1320 100644 --- a/src/game/restore.cpp +++ b/src/game/restore.cpp @@ -17,7 +17,9 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/controllers.h" #include "repentogon/items.h" +#include "repentogon/save_state_ex.h" #include "repentogon/saves.h" #include "repentogon/ui_patches.h" #endif @@ -585,6 +587,9 @@ void PlayerManager::RestoreGameState(GameState& state) } coop_slots_reset(); g_game->hud.AssignPlayerHUDs(); +#ifdef ISAAC_REPENTOGON + twins_restore(*this); +#endif } // 009bd010 Finishes the saved players once their floor is entered (their familiars, charmed enemies, effects and @@ -608,7 +613,11 @@ void PlayerManager::restore_controller_assignment() { std::vector controllers = {g_manager->activeControllerIndex}; +#ifdef ISAAC_REPENTOGON + for (Entity_Player* player : playerList) controller_unassign(*player); +#else for (Entity_Player* player : playerList) player->SetControllerIndex(-1, true); +#endif for (int i = 0; i < KAGE::Input::manager.get_device_count(); i++) { std::shared_ptr device = KAGE::Input::manager.get_device(i); @@ -620,7 +629,11 @@ void PlayerManager::restore_controller_assignment() for (Entity_Player* player : playerList) { if (next == controllers.end()) break; +#ifdef ISAAC_REPENTOGON + if (player->controllerIndex == -1) controller_reassign(*player, *next++, HANDOUT_CONTINUE); +#else if (player->controllerIndex == -1) player->SetControllerIndex(*next++, true); +#endif } coop_slots_reset(); g_game->hud.AssignPlayerHUDs(); diff --git a/src/level/backdrop.cpp b/src/level/backdrop.cpp index b8b2f48..19681cf 100644 --- a/src/level/backdrop.cpp +++ b/src/level/backdrop.cpp @@ -916,7 +916,7 @@ static ANM2& controls_picture_pick(Backdrop& backdrop, int playerType) ANM2* modded = config ? config->moddedSprites[PLAYER_SPRITE_CONTROLS] : nullptr; if (modded) { - modded->SetFrame(config->GetDisplayName(), 0); + modded->SetFrame(config->animation_name_get(*modded), 0); return *modded; } backdrop.controlsSprite.SetFrame(CONTROLS_ANIMATION, 0); diff --git a/src/level/generator.h b/src/level/generator.h index 5fbdd7c..efe5ef5 100644 --- a/src/level/generator.h +++ b/src/level/generator.h @@ -144,10 +144,10 @@ public: int count_neighbor_rooms(XY position); void update_room_neighbors(LevelGenerator_Room& room); void update_dead_end_lists(); + bool is_placement_valid(XY position, RoomShape shape); private: void generate_rooms(int roomCount, const LevelGenerator_Room& startRoom); - bool is_placement_valid(XY position, RoomShape shape); bool try_resize_room(LevelGenerator_Room& room, RoomShape shape, uint32_t possibleDoors); void mark_dead_ends(); }; diff --git a/src/level/greed.cpp b/src/level/greed.cpp index 4c492ce..7b7055c 100644 --- a/src/level/greed.cpp +++ b/src/level/greed.cpp @@ -22,10 +22,12 @@ #include #include #include +#include #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" #include "repentogon/level.h" +#include "repentogon/player_features.h" #endif // A room of a Greed floor's fixed layout: its cell, shape and type, and the cell and side it joins the layout through @@ -702,13 +704,19 @@ constexpr float DONATION_JAM_MAX = 100; constexpr float DONATION_JAM_SHARE = 0.2f; constexpr float DONATION_JAM_GREEDIER_MAX = 1; -// 007cbb90 The chance in percent the Greed donation machine jams, from a save's donation counter. +// 007cbb90 The chance in percent the Greed donation machine jams, from a save's donation counter. Without vanilla +// parity a modded character's comes from REPENTOGON's own count. float Entity_Player::GetGreedDonationJamChance(PersistentGameData& data) { - if ((uint32_t)playerType >= (uint32_t)COMPLETION_PLAYER_TYPE_COUNT) return DONATION_JAM_UNKNOWN; + std::optional donated; + if ((uint32_t)playerType < (uint32_t)COMPLETION_PLAYER_TYPE_COUNT) + donated = data.eventCounters[COMPLETION_MARKS[playerType][COMPLETION_GREED_DONATION].counter]; +#ifdef ISAAC_REPENTOGON + else if (std::optional modded = greed_donations_get(playerType)) donated = (uint32_t)*modded; +#endif + if (!donated) return DONATION_JAM_UNKNOWN; - uint32_t donated = data.eventCounters[COMPLETION_MARKS[playerType][COMPLETION_GREED_DONATION].counter]; - float chance = std::min(exp_float((float)donated * DONATION_JAM_GROWTH) - 1, DONATION_JAM_MAX); + float chance = std::min(exp_float((float)*donated * DONATION_JAM_GROWTH) - 1, DONATION_JAM_MAX); chance = std::floor(chance * DONATION_JAM_SHARE + HALF); return g_game->difficulty == DIFFICULTY_GREEDIER ? std::min(DONATION_JAM_GREEDIER_MAX, chance) : chance; } diff --git a/src/level/grid/rock.cpp b/src/level/grid/rock.cpp index 5cdf12e..204e4a4 100644 --- a/src/level/grid/rock.cpp +++ b/src/level/grid/rock.cpp @@ -25,6 +25,7 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" #include "repentogon/vanilla_fixes.h" +#include "repentogon/gl_pipeline.h" #endif // A big rock's last frame. @@ -553,6 +554,9 @@ void GridEntity_Rock::Update() // A missing rubble animation leaves the floor's color on the sprite. void GridEntity_Rock::Render(const Vector& offset) { +#ifdef ISAAC_REPENTOGON + RenderContextScope context(RENDER_CONTEXT_ROCK, this); +#endif Vector position = get_render_position(); SpriteDraw draw = {.position = vector_make(position.x + offset.x, position.y + offset.y)}; ColorMod saved = sprite.color; diff --git a/src/level/level.cpp b/src/level/level.cpp index 12914ab..dfa4392 100644 --- a/src/level/level.cpp +++ b/src/level/level.cpp @@ -34,6 +34,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/custom_pools.h" #include "repentogon/items.h" #include "repentogon/level.h" #include "repentogon/saves.h" @@ -643,6 +644,9 @@ void Level::Init(bool isResetLilPortalRoom) { for (int stageId = 1; stageId <= VOID_STAGE_ID_LAST; stageId++) if (stageId != STAGE_ID_BLUE_WOMB) game.roomConfig.ResetRoomWeights(stageId, ROOM_MODE_CURRENT); +#ifdef ISAAC_REPENTOGON + void_stages_select(game.roomConfig); +#endif } else game.roomConfig.ResetRoomWeights(RoomConfig::GetStageID((int)stage, (int)stageType, ROOM_MODE_CURRENT), @@ -2757,7 +2761,11 @@ void greed_reset_collectibles_collect(Entity_Player& player) else if (item.time > 0) { g_game->itemPool.ResetCollectible(item.id); +#ifdef ISAAC_REPENTOGON + if (uint16_t* genesis = genesis_items_get(item.itemPoolType)) (*genesis)++; // a mod's pool too +#else g_game->itemPool.remainingGenesisItems[item.itemPoolType]++; +#endif } } if (current->HasCollectible(COLLECTIBLE_BOOK_OF_BELIAL_PASSIVE)) diff --git a/src/level/path_finder.cpp b/src/level/path_finder.cpp index ce0e057..67c8446 100644 --- a/src/level/path_finder.cpp +++ b/src/level/path_finder.cpp @@ -643,6 +643,7 @@ static int axis_direction_pick(PathFinder& finder, const std::array(entity); + if (isFleeing && npc) { - Vector toward = vector_sub(static_cast(entity)->GetPlayerTarget()->pos, entity->pos); + Vector toward = vector_sub(npc->GetPlayerTarget()->pos, entity->pos); if (vector_dot(vector_normalized(toward), axis) > AXIS_FLEE_AWAY_DOT) return; } diff --git a/src/level/room.cpp b/src/level/room.cpp index 280a128..2380916 100644 --- a/src/level/room.cpp +++ b/src/level/room.cpp @@ -1724,6 +1724,9 @@ int Room::GetDeliriumDistance() // 007eece0 The stage id of the layout, or the special rooms' (0) without one. int Room::GetRoomConfigStage() { +#ifdef ISAAC_REPENTOGON + if (descriptor && descriptor->data) return void_ex_stage_get(*descriptor); +#endif if (descriptor && descriptor->data) return descriptor->data->stageId; KAGE_LogMessage(LOG_WARN, (uint8_t*)"Room stage config is missing, returning a default one (SPECIAL)!\n"); return 0; @@ -2369,7 +2372,7 @@ static int backdrop_by_stage(Room& room, int& fxStage, int& stageType) } int stageId = RoomConfig::GetStageID(stage, stageType, ROOM_MODE_CURRENT); - if (stage == STAGE_VOID && descriptor.data->stageId != 0) stageId = descriptor.data->stageId; + if (stage == STAGE_VOID && descriptor.data->stageId != 0) stageId = room.GetRoomConfigStage(); if (stageId == STAGE_ID_VOID) { RNG rng = {descriptor.decorationSeed, 1, 21, 20}; @@ -2546,7 +2549,7 @@ void Room::LoadBackdropGraphics() backdrop.rng = {descriptor->decorationSeed, 5, 9, 7}; backdrop.Init((uint32_t)backdropId, false); backdropType = (int)backdrop.backdropId; - if (fxStage == STAGE_VOID) void_fx_stage_get(descriptor->data->stageId, fxStage, stageType); + if (fxStage == STAGE_VOID) void_fx_stage_get(GetRoomConfigStage(), fxStage, stageType); bool isNoLayers = roomType == ROOM_DUNGEON || backdropId == BACKDROP_MEGA_SATAN; if (isNoLayers) fxLayers.clear(); diff --git a/src/level/room_config.cpp b/src/level/room_config.cpp index 1096298..84c0f8d 100644 --- a/src/level/room_config.cpp +++ b/src/level/room_config.cpp @@ -4,6 +4,9 @@ #include "entity/pickup/item_config.h" #include "game/manager.h" #include "engine/platform.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/options.h" +#endif #include #include #include @@ -13,6 +16,7 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/level.h" #include "repentogon/vanilla_fixes.h" +#include "repentogon/virtual_rooms.h" #endif // One way the Curse of the Giant splits a big shape into two rooms: each part's shape, whether it sits a room width or @@ -280,6 +284,17 @@ RoomEntry* RoomSpawn::PickEntry(float value) return &first; } +// The rooms of a .stb file of the game's resources, for a stage. None when it is missing or its header is wrong. +std::optional> stb_rooms_read(std::string_view path, int stageId) +{ + std::optional reader = file_read(path); + if (!reader || !is_stb_header_read(*reader)) return std::nullopt; + + std::vector rooms(reader->get()); + for (RoomConfig_Room& room : rooms) read_room(*reader, stageId, room); + return rooms; +} + // 00829290 Adds a variant to the set, merging it into its neighbouring ranges. Whether it was new. bool RoomConfig_VariantSet::Add(uint32_t variant) { @@ -342,7 +357,12 @@ bool RoomSet::mod_rooms_merge(std::string_view path, int stageId, RoomMode mode) if (GetVariantSet(room.type).Add((uint32_t)room.variant)) continue; std::vector& taken = GetVariantSet(room.type).ranges; - if (taken.size() > 1 && taken[1].lowerBound + 2 == taken[0].upperBound) + bool isGapOne = taken.size() > 1 && taken[1].lowerBound + 2 == taken[0].upperBound; +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) // Patches/ASMPatches/ASMFixes.cpp + isGapOne = taken.size() > 1 && taken[0].upperBound + 2 == taken[1].lowerBound; +#endif + if (isGapOne) { room.variant = (int)(taken[1].lowerBound + 1); taken[0].upperBound = taken[1].upperBound; @@ -492,6 +512,7 @@ void RoomConfig::LoadStageBinary(int stageId, RoomMode mode) set.isLoaded = true; #ifdef ISAAC_REPENTOGON stage_binary_load_post(*this, stageId, mode); + virtual_rooms_commit(stageId, mode); #endif } @@ -501,6 +522,9 @@ void RoomConfig::ResetRoomWeights(int stageId, RoomMode mode) mode = mode_resolve(mode); RoomSet& set = stages[stageId].rooms[mode]; +#ifdef ISAAC_REPENTOGON + virtual_rooms_weights_reset(stageId, mode); +#endif if (!set.isLoaded) return LoadStageBinary(stageId, mode); for (RoomConfig_Room& room : set.configs) room.weight = room.initialWeight; } @@ -621,6 +645,9 @@ RoomConfig_Room* RoomConfig::GetRoomByStageTypeAndVariant(int stageId, int type, { for (RoomConfig_Room& room : set_loaded_get(*this, stageId, mode).configs) if (room.type == type && room.variant == variant) return &room; +#ifdef ISAAC_REPENTOGON + if (RoomConfig_Room* room = virtual_room_find(stageId, type, variant, mode)) return room; +#endif log_printf(LOG_INFO, "[warn] StageID %d Room type %d, variant %d not found!\n", stageId, type, variant); return nullptr; @@ -645,6 +672,9 @@ std::vector RoomConfig::GetRooms(RoomQuery& query) if (room.type == query.type && isShape && isVariant && isDifficulty && isDoors && isSubtype && !isPlate) rooms.push_back(&room); } +#ifdef ISAAC_REPENTOGON + virtual_rooms_filter(query, rooms); +#endif return rooms; } @@ -674,7 +704,11 @@ RoomConfig_Room* RoomConfig::GetRandomRoom(uint32_t seed, WeightReduction reduct std::vector rooms; bool isVoid = g_game->stage == STAGE_VOID && query.stageId != STAGE_ID_SPECIAL_ROOMS && query.stageId != STAGE_ID_HOME; - if (isVoid) + bool isVoidDrawn = false; +#ifdef ISAAC_REPENTOGON + isVoidDrawn = isVoid && void_rooms_get(*this, query, rooms); +#endif + if (isVoid && !isVoidDrawn) { RoomQuery chapter = query; chapter.maxDifficulty = VOID_MAX_DIFFICULTY; @@ -682,7 +716,7 @@ RoomConfig_Room* RoomConfig::GetRandomRoom(uint32_t seed, WeightReduction reduct for (chapter.stageId = 1; chapter.stageId <= VOID_STAGE_LAST; chapter.stageId++) if (chapter.stageId != STAGE_ID_BLUE_WOMB) std::ranges::copy(GetRooms(chapter), std::back_inserter(rooms)); } - else + else if (!isVoid) rooms = GetRooms(query); std::vector exactRooms; diff --git a/src/level/room_config.h b/src/level/room_config.h index bf478b6..5e09aa1 100644 --- a/src/level/room_config.h +++ b/src/level/room_config.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "classes.h" #include #include @@ -216,3 +218,4 @@ public: }; std::string_view room_type_name(int type); +std::optional> stb_rooms_read(std::string_view path, int stageId); diff --git a/src/level/room_render.cpp b/src/level/room_render.cpp index c60cb84..ffd81c9 100644 --- a/src/level/room_render.cpp +++ b/src/level/room_render.cpp @@ -23,6 +23,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/options.h" #include "repentogon/render.h" #endif @@ -30,6 +31,8 @@ constexpr float DEBUG_CELL_HALF = 13; constexpr float DEBUG_TEXT_LEFT = 12; constexpr float DEBUG_TEXT_UP = 10; +constexpr float DEBUG_TEXT_LEFT_MINI = 11; +constexpr float DEBUG_TEXT_UP_MINI = 17; constexpr KColor DEBUG_GRID_COLOR = kcolor_rgba(1, 1, 0, 0.2f); // The debug room info line: the room types' names, its color and its height over the screen's bottom. constexpr std::array ROOM_TYPE_NAMES = { @@ -1450,10 +1453,23 @@ static void shockwave_surface_resolve(Room& room, Vector surfaceOffset) graphics.blend_set(KAGE::Graphics::BLEND_NORMAL); } +// (ASMTweaks.cpp's FixGridDebugInfo) Whether the grid debug views write in the outlined Lua mini font, placed for it. +static bool is_debug_grid_font_mini() +{ +#ifdef ISAAC_REPENTOGON + return !repentogonOptions.isVanillaParity; +#else + return false; +#endif +} + // 008128f0 The debug view of the grid paths (debug 2): each cell outlined in faint yellow with its path's value. void Room::render_debug_grid_values(Vector offset) { - Font& font = g_manager->font6_PFTempestaSevenCondensed; + bool isMini = is_debug_grid_font_mini(); + Font& font = isMini ? g_manager->font8_LuaMiniOutlined : g_manager->font6_PFTempestaSevenCondensed; + Vector text = + isMini ? vector_make(DEBUG_TEXT_LEFT_MINI, DEBUG_TEXT_UP_MINI) : vector_make(DEBUG_TEXT_LEFT, DEBUG_TEXT_UP); for (int i = 0; i < gridWidth * gridHeight; i++) { @@ -1462,8 +1478,8 @@ void Room::render_debug_grid_values(Vector offset) Vector size = vector_make(DEBUG_CELL_HALF * 2, DEBUG_CELL_HALF * 2); FontSettings settings; quad_outline_render(KAGE::Graphics::color_quad_rect(corner, size, DEBUG_GRID_COLOR), 1); - font.DrawString(std::to_string(gridPaths[i]), vector_make(cell.x - DEBUG_TEXT_LEFT, cell.y - DEBUG_TEXT_UP), - vector_make(1, 1), DEBUG_GRID_COLOR, settings); + font.DrawString(std::to_string(gridPaths[i]), vector_sub(cell, text), vector_make(1, 1), DEBUG_GRID_COLOR, + settings); } } @@ -1471,7 +1487,7 @@ void Room::render_debug_grid_values(Vector offset) // index above its column and row. void Room::render_debug_grid_indices(Vector offset) { - Font& font = g_manager->font2_TeamMeatEx12; + Font& font = is_debug_grid_font_mini() ? g_manager->font8_LuaMiniOutlined : g_manager->font2_TeamMeatEx12; Vector halfCell = vector_make(GRID_CELL_SIZE / 2, GRID_CELL_SIZE / 2); float cellSize = DEBUG_CELL_HALF * 2; auto cornerGet = [&](int gridIndex) diff --git a/src/level/room_update.cpp b/src/level/room_update.cpp index c87ad02..d0acfcd 100644 --- a/src/level/room_update.cpp +++ b/src/level/room_update.cpp @@ -29,6 +29,7 @@ #include #include #ifdef ISAAC_REPENTOGON +#include "repentogon/custom_pools.h" #include "repentogon/level.h" #endif @@ -1080,6 +1081,11 @@ static void genesis_items_spawn(Room& room) for (int pool = 0; pool < POOL_COUNT; pool++) if ((int16_t)game.itemPool.remainingGenesisItems[pool] > 0) picker.AddOutcomeWeight(pool, (int16_t)game.itemPool.remainingGenesisItems[pool]); +#ifdef ISAAC_REPENTOGON + // (Patches/ItemPoolManager.cpp's GetNextGenesisPool patch) The mods' pools after the game's. + for (int pool = POOL_COUNT; pool < POOL_COUNT + custom_pool_count(); pool++) + if ((int16_t)*genesis_items_get(pool) > 0) picker.AddOutcomeWeight(pool, (int16_t)*genesis_items_get(pool)); +#endif if (picker.outcomes.empty()) { room.genesisTimer = GENESIS_RETRY_FRAMES; @@ -1093,7 +1099,11 @@ static void genesis_items_spawn(Room& room) room.genesisTimer = GENESIS_RETRY_FRAMES; return; } +#ifdef ISAAC_REPENTOGON + (*genesis_items_get(pool))--; +#else game.itemPool.remainingGenesisItems[pool]--; +#endif for (RoomSpawn& spawn : room.descriptor->data->spawns) { if (spawn.entries.size() != 1) continue; diff --git a/src/lua/api.cpp b/src/lua/api.cpp index 5ef3ea7..997bc53 100644 --- a/src/lua/api.cpp +++ b/src/lua/api.cpp @@ -144,7 +144,8 @@ static void table_init(lua_State* state, const char* name) // (0085d040, 0085d2c0, 0085d500) Begins a class as LuaBridge lays one out: a static table that is its own metatable, holding the constructor and // static functions with __class pointing at the class table, the metatable its objects get. The class table keeps the -// methods and properties, with __parent pointing at the parent class's. Leaves the static and class tables on top. +// methods and properties, with __parent pointing at the parent class's and __type naming it (createClassTable). +// Leaves the static and class tables on top. void lua_class_begin(lua_State* state, const char* name, LuaClass luaClass, LuaClass parent) { lua_newtable(state); @@ -154,6 +155,8 @@ void lua_class_begin(lua_State* state, const char* name, LuaClass luaClass, LuaC lua_newtable(state); table_init(state, name); + lua_pushstring(state, name); + lua_table_set(state, -2, "__type"); if (parent != LUA_CLASS_COUNT) { lua_rawgetp(state, LUA_REGISTRYINDEX, lua_class_key(parent)); diff --git a/src/lua/api_isaac.cpp b/src/lua/api_isaac.cpp index e15f11b..06b8306 100644 --- a/src/lua/api_isaac.cpp +++ b/src/lua/api_isaac.cpp @@ -26,6 +26,7 @@ #include "repentogon/lua_render.h" #include "repentogon/menus.h" #include "repentogon/npc.h" +#include "repentogon/options.h" #include "repentogon/repentogon.h" #include "repentogon/weapons.h" #endif @@ -52,6 +53,7 @@ constexpr int LUA_TYPE_NONE = 0; constexpr float OPTION_GAMMA_MAX = 1.5f; constexpr float OPTION_GAMMA_MIN = 0.5f; constexpr float OPTION_RATIO_MAX = 0.01f; +constexpr float MUSIC_VOLUME_MAX_FIXED = 1; constexpr int MOUSE_BUTTON_LAST = 7; constexpr int OPTION_SCALE_MAX = 99; constexpr int SAVE_SLOT_DEFAULT = 1; @@ -297,7 +299,8 @@ static int mod_data_remove(lua_State* state) } // 0085f0f0 The file a module name is in: dots become folders and .lua is added, searched in resources/scripts/, the -// running script's folder, and that folder under the mods folder, with REPENTOGON's scripts folder first. The name is +// running script's folder, and that folder under the mods folder, with REPENTOGON's scripts folder first as part of +// the resources' mount, so tried lists the original's paths (mods read their own folder from it). The name is // lowercased, as the import tool lowercases every path a mod ships. Empty when none exists, with tried listing them. static std::string module_path_find(std::string_view name, std::string& tried) { @@ -311,13 +314,13 @@ static std::string module_path_find(std::string_view name, std::string& tried) std::string scriptPath = lua_engine_get().scriptPath; std::string local = scriptPath.substr(0, scriptPath.find_last_of(PATH_SEPARATORS)) + "/" + module; std::string resource = resource_path(SCRIPTS_FOLDER + module); - for (const std::string& path : { + std::error_code error; #ifdef ISAAC_REPENTOGON - repentogon_script_path(module), + std::string repentogon = repentogon_script_path(module); + if (std::filesystem::exists(repentogon, error)) return repentogon; #endif - resource, local, platform.modsDirectory + local}) + for (const std::string& path : {resource, local, platform.modsDirectory + local}) { - std::error_code error; if (path == resource ? resource_exists(path) : std::filesystem::exists(path, error)) return path; tried += "\n\tno file '" + path + "'"; } @@ -687,6 +690,16 @@ static void option_clamped_add(lua_State* state, const char* name) [](LuaIgnored, T value) { g_manager->optionsConfig.*Member = std::clamp(value, (T)Low, (T)High); }); } +// (ASMTweaks.cpp's PatchOptionsSetMusicBound) The highest music volume Lua may set: the whole range without vanilla +// parity. +static float music_volume_max() +{ +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) return MUSIC_VOLUME_MAX_FIXED; +#endif + return OPTION_RATIO_MAX; +} + // (00896810 to 008973e0) Registers the Options namespace. Setters keep each option in its range and apply the volumes, // the fullscreen, vsync and the cursor. The volumes, the map opacity and the HUD offset stop at 0.01, as the // original's do. @@ -695,7 +708,7 @@ static void options_register(lua_State* state) lua_namespace_begin(state, "Options"); lua_property( state, "MusicVolume", [](LuaIgnored) { return g_manager->optionsConfig.musicVolume; }, - [](LuaIgnored, float volume) { g_manager->optionsConfig.SetMusicVolume(std::clamp(volume, 0.0f, OPTION_RATIO_MAX)); }); + [](LuaIgnored, float volume) { g_manager->optionsConfig.SetMusicVolume(std::clamp(volume, 0.0f, music_volume_max())); }); lua_property( state, "SFXVolume", [](LuaIgnored) { return g_manager->optionsConfig.sfxVolume; }, [](LuaIgnored, float volume) { diff --git a/src/lua/engine.h b/src/lua/engine.h index de36d47..2c3a3c5 100644 --- a/src/lua/engine.h +++ b/src/lua/engine.h @@ -151,6 +151,15 @@ enum LuaClass LUA_CLASS_SOURCE_QUAD, LUA_CLASS_SURFACE_RENDER_CONTROLLER, LUA_CLASS_TRANSFORMER, + // REPENTOGON's render pipeline classes. + LUA_CLASS_ELEMENTS_ARRAY, + LUA_CLASS_GL_SHADER, + LUA_CLASS_PIPELINE, + LUA_CLASS_RENDER_CONTEXT, + LUA_CLASS_RENDER_SET, + LUA_CLASS_VERTEX, + LUA_CLASS_VERTEX_BUFFER, + LUA_CLASS_VERTEX_DESCRIPTOR, // REPENTOGON's level, room and save classes. LUA_CLASS_BACKDROP, LUA_CLASS_CAMERA, diff --git a/src/repentogon/achievements.cpp b/src/repentogon/achievements.cpp index 418c872..47c37fb 100644 --- a/src/repentogon/achievements.cpp +++ b/src/repentogon/achievements.cpp @@ -1,6 +1,7 @@ // Mods' achievements (Patches/AchievementsStuff.cpp): loaded from their content folders, saved apart from the game's, // unlocked and shown like the game's own. #include "repentogon/achievements.h" +#include "entity/player/player.h" #include "game/game.h" #include "game/manager.h" #include "game/mod_manager.h" @@ -16,6 +17,8 @@ constexpr const char* ACHIEVEMENTS_FILE = "achievements.xml"; constexpr const char* ACHIEVEMENTS_SAVE_MEMBER = "Achievements"; constexpr const char* DEFAULT_PAPER = "gfx/ui/achievement/paper.png"; constexpr int PAPER_SHEET = 2; +constexpr int PICTURE_SHEET = 3; +constexpr const char* LOCKED_PICTURE = "gfx/ui/achievement/achievement_locked.png"; constexpr int CHARACTER_ANY = -1; // REPENTOGON's progress of a mod's achievement: notified once unlocked, unlocked from 1, and locked by the console. constexpr int PROGRESS_NOTIFIED = 2; @@ -32,6 +35,44 @@ constexpr std::pair MARK_NAMES[] = { {"Hush", 9}, {"UltraGreedier", 11}, {"GREEDIER", 11}, {"Greedier", 11}, {"Delirium", 12}, {"Mother", 13}, {"Beast", 14}}; +// The event counters an "event" condition names (AchievementsStuff.h's simplifiedeventsenum). An unknown one is 0. +constexpr std::pair EVENT_NAMES[] = { + {"MOM_KILLS", 1}, + {"ROCKS_DESTROYED", 2}, + {"TINTED_ROCKS_DESTROYED", 3}, + {"SUPER_SPECIAL_ROCKS_DESTROYED", 4}, + {"POOP_DESTROYED", 5}, + {"PILLS_EATEN", 6}, + {"XIII_DEATH_CARD_USED", 7}, + {"UNKNOWN_EVENT_8", 8}, + {"ARCADES_ENTERED", 9}, + {"DEATHS", 10}, + {"ISAAC_KILLS", 11}, + {"SHOPKEEPER_KILLED", 12}, + {"SATAN_KILLS", 13}, + {"SHELLGAMES_PLAYED", 14}, + {"ANGEL_DEALS_TAKEN", 15}, + {"DEVIL_DEALS_TAKEN", 16}, + {"BLOOD_DONATION_MACHINE_USED", 17}, + {"SLOT_MACHINES_BROKEN", 18}, + {"DONATE_MACHINE_COUNTER", 20}, + {"DONATION_MACHINE_COUNTER", 20}, + {"EDEN_TOKENS", 21}, + {"STREAK_COUNTER", 22}, + {"BEST_STREAK", 23}, + {"BLUE_BABY_KILLS", 24}, + {"LAMB_KILLS", 25}, + {"MEGA_SATAN_KILLS", 26}, + {"KILL_MOMS_HEART_WITH_ISAAC", 27}, + {"KILL_MOMS_HEART_WITH_MAGDALENE", 28}, + {"KILL_MOMS_HEART_WITH_CAIN", 29}, + {"KILL_MOMS_HEART_WITH_JUDAS", 30}, + {"KILL_MOMS_HEART_WITH_BLUE_BABY", 31}, + {"KILL_MOMS_HEART_WITH_EVE", 32}, + {"KILL_MOMS_HEART_WITH_SAMSON", 33}, + {"BATTERY_BUMS_KILLED", 494}, + {"BATTERY_BUM_COLLECTIBLE_PAYOUTS", 495}}; + // A mod's achievement as its achievements.xml gives it (attributes by lowercase name, the root's inherited, and its // s), or one of those conditions, which counts as a hidden achievement of its own. Its progress is saved by // its name and mod. @@ -50,8 +91,10 @@ struct CustomAchievement static std::vector customAchievements; static std::vector achievementConditions; static JsonCounts achievementProgress; -// The achievements a completion mark (by mark and character, or any) or another achievement raises. +// The achievements a completion mark or an event counter (by mark or counter and character, or any) or another +// achievement raises. static std::map, std::vector> markListeners; +static std::map, std::vector> eventListeners; static std::map> achievementListeners; static std::string achievementsPath; static bool isPaperReplaced = false; @@ -88,7 +131,7 @@ void achievements_mods_load() if (node_tag(condition) == "condition") achievement.conditions.push_back(xml_attributes_read(condition)); achievement.id = CUSTOM_ACHIEVEMENT_FIRST + (int)customAchievements.size() - 1; - achievement.sourceId = mod.metadataWorkshopID.empty() ? mod.directory : mod.metadataWorkshopID; + achievement.sourceId = mod_source_id_get(&mod); achievement.name = attributes.contains("name") ? attributes["name"] : attributes["text"]; if (achievement.name.empty()) achievement.name = attributes["steam_name"]; achievement.isHidden = attributes.contains("hidden") && attributes["hidden"] != "false"; @@ -167,6 +210,11 @@ static void achievement_trackers_add(CustomAchievement& achievement) auto mark = std::ranges::find(MARK_NAMES, value, &std::pair::first); listeners_add(markListeners[{mark == std::end(MARK_NAMES) ? 0 : mark->second, character}], achievement.id); } + if (type == "event") + { + auto event = std::ranges::find(EVENT_NAMES, value, &std::pair::first); + listeners_add(eventListeners[{event == std::end(EVENT_NAMES) ? 0 : event->second, character}], achievement.id); + } if (type != "achievement") return; for (size_t start = 0, end = 0; end != value.npos; start = end + 1) { @@ -185,6 +233,7 @@ static void achievements_progress_load() achievementProgress.clear(); achievementConditions.clear(); markListeners.clear(); + eventListeners.clear(); achievementListeners.clear(); for (CustomAchievement& achievement : customAchievements) @@ -277,6 +326,19 @@ void achievement_marks_run(int completion, int playerType) for (int id : markListeners[{completion, CHARACTER_ANY}]) achievement_progress_raise(id); } +// (AchievementsStuff.cpp's IncreaseEventCounter hook) Raises the achievements waiting on an event counter, once for +// each player in the run, for its character and then for any, unless the save is read only. +void achievement_events_run(PersistentGameData& data, int counter) +{ + if (eventListeners.empty() || data.isReadOnly || !g_game) return; + for (Entity_Player* player : g_game->playerManager.playerList) + { + for (int id : eventListeners[{counter, player->playerType}]) achievement_progress_raise(id); + if (player->playerType >= 0) + for (int id : eventListeners[{counter, CHARACTER_ANY}]) achievement_progress_raise(id); + } +} + bool achievement_marks_is_tracked() { return !markListeners.empty(); @@ -301,3 +363,55 @@ AchievementEntry* achievement_entry_get(AchievementOverlay& overlay, int id) custom = {achievement->attributes["gfxroot"] + achievement->attributes["gfx"], achievement->name, id}; return &custom; } + +// (SetUpReverseSourcesVec) The secrets page's sources: the game's achievements ("BaseGame"), then each mod with ones +// not hidden, in mod order. +std::vector achievement_sources_get() +{ + std::vector sources = {"BaseGame"}; + for (CustomAchievement& achievement : customAchievements) + if (!achievement.isHidden && std::ranges::find(sources, achievement.sourceId) == sources.end()) + sources.push_back(achievement.sourceId); + return sources; +} + +// The achievements a mod's secrets page lists, not hidden, in order. +std::vector achievement_source_ids_get(std::string_view source) +{ + std::vector ids; + for (CustomAchievement& achievement : customAchievements) + if (!achievement.isHidden && achievement.sourceId == source) ids.push_back(achievement.id); + return ids; +} + +// The title the secrets page shows over a source's achievements: Repentance for the game's, else the mod's name. +std::string achievement_source_name_get(std::string_view source) +{ + for (auto& mod : g_manager->modManager.mods) + if (mod_source_id_get(mod.get()) == source) return mod->name; + return "Repentance"; +} + +// (ReplaceAchievementSprite) Shows a mod's achievement on the secrets page's picture: its paper (the default one +// without gfxback) and its picture, or the locked one. A game's achievement after a mod's gets the default paper back. +// Whether it was a mod's. +bool achievement_picture_replace(ANM2& sprite, int id) +{ + static bool isPaperReplaced = false; + CustomAchievement* achievement = id >= CUSTOM_ACHIEVEMENT_FIRST ? custom_achievement_get(id) : nullptr; + if (!achievement && !std::exchange(isPaperReplaced, false)) return false; + + std::string paper = DEFAULT_PAPER; + if (achievement && achievement->attributes.contains("gfxback")) + paper = achievement->attributes["gfxroot"] + achievement->attributes["gfxback"]; + sprite.ReplaceSpritesheet(PAPER_SHEET, paper); + sprite.LoadGraphics(); + if (!achievement) return false; + + isPaperReplaced = true; + bool isUnlocked = custom_achievement_is_unlocked(id); + sprite.ReplaceSpritesheet(PICTURE_SHEET, isUnlocked ? achievement->attributes["gfxroot"] + achievement->attributes["gfx"] + : LOCKED_PICTURE); + sprite.LoadGraphics(); + return true; +} diff --git a/src/repentogon/achievements.h b/src/repentogon/achievements.h index be469d4..d024fb3 100644 --- a/src/repentogon/achievements.h +++ b/src/repentogon/achievements.h @@ -2,9 +2,11 @@ #include "engine/data.h" #include +#include #include class AchievementOverlay; +struct ANM2; class PersistentGameData; struct AchievementEntry; @@ -23,4 +25,9 @@ int achievement_id_find(std::string_view name); void achievement_attr_read(DataNode node, int& id); void achievement_marks_run(int completion, int playerType); bool achievement_marks_is_tracked(); +void achievement_events_run(PersistentGameData& data, int counter); AchievementEntry* achievement_entry_get(AchievementOverlay& overlay, int id); +std::vector achievement_sources_get(); +std::vector achievement_source_ids_get(std::string_view source); +std::string achievement_source_name_get(std::string_view source); +bool achievement_picture_replace(ANM2& sprite, int id); diff --git a/src/repentogon/api_console.cpp b/src/repentogon/api_console.cpp index 4eba350..9951202 100644 --- a/src/repentogon/api_console.cpp +++ b/src/repentogon/api_console.cpp @@ -507,7 +507,13 @@ void isaac_console_register(lua_State* state) }); } -// (LuaConsole.cpp, LuaDebug.cpp, LuaInit.cpp, LuaImGui.cpp) Registers REPENTOGON's Console, ImGui and Debug, and its +// (LuaASM.cpp) ASMPatch writes raw x86 bytes into the Windows exe, which the native build has no equivalent of. +static int asm_patch_refuse(lua_State* state) +{ + return luaL_error(state, "ASMPatch is not supported in the native build"); +} + +// (LuaConsole.cpp, LuaDebug.cpp, LuaInit.cpp, LuaImGui.cpp, LuaASM.cpp) Registers REPENTOGON's Console, ImGui and Debug, and its // global functions. void console_classes_register(lua_State* state) { @@ -524,7 +530,8 @@ void console_classes_register(lua_State* state) lua_functions_add(state, {{"DumpRegistry", registry_dump}, {"Benchmark", code_benchmark}, {"ExtractFunctions", functions_extract}, - {"RandomFloat", random_float_get}}); + {"RandomFloat", random_float_get}, + {"ASMPatch", asm_patch_refuse}}); lua_method(state, "ToRadians", [](float angle) { return angle * std::numbers::pi / DEGREES_HALF_TURN; }); lua_method(state, "ToDegrees", [](float angle) { return angle * DEGREES_HALF_TURN / std::numbers::pi; }); lua_pop(state, 1); diff --git a/src/repentogon/api_entities.cpp b/src/repentogon/api_entities.cpp index 3d73501..0ef1127 100644 --- a/src/repentogon/api_entities.cpp +++ b/src/repentogon/api_entities.cpp @@ -7,6 +7,7 @@ #include "entity/player/player.h" #include "entity/save_state.h" #include "entity/weapon/laser.h" +#include "entity/weapon/tear.h" #include "entity/weapon/weapon.h" #include "game/debug_renderer.h" #include "game/game.h" @@ -407,6 +408,8 @@ void entity_api_register(lua_State* state) lua_method(state, "SetInvincible", [](Entity& entity, LuaCheckedBool isInvincible) { entity.isInvincible = isInvincible.value; }); lua_method(state, "GetHitListIndex", [](Entity& entity) { return entity.GetHitListIndex(); }); + // Entity::TeleportToRandomPosition (006b5320) is what a teleporting tear does to an enemy it hits. + lua_method(state, "TeleportToRandomPosition", [](Entity& entity) { tear_hit_teleport(entity); }); lua_method(state, "TryThrow", [](Entity& entity, const EntityRef& source, Vector& direction, float force) { return entity.TryThrow(source, direction, force); }); diff --git a/src/repentogon/api_game.cpp b/src/repentogon/api_game.cpp index 6df1f07..4735b2d 100644 --- a/src/repentogon/api_game.cpp +++ b/src/repentogon/api_game.cpp @@ -19,6 +19,8 @@ #include "repentogon/api.h" #include "repentogon/hud.h" #include "repentogon/lua_render.h" +#include "repentogon/options.h" +#include "repentogon/progress.h" #include "repentogon/saves.h" #include "ui/generic_prompt.h" #include "ui/victory_run_prompt.h" @@ -228,9 +230,15 @@ static int game_chain_lightning(lua_State* state) return 1; } +// The title screen and new run targets as Repentance numbered them, which REPENTOGON's FadeoutTarget keeps +// (XMLData.cpp's FadeOut hook on the Lua binder). They mean this game's title screen and restart. +constexpr FadeOutTarget REPENTANCE_FADEOUT_TITLE = FADEOUT_MENU_ONLINE; +constexpr FadeOutTarget REPENTANCE_FADEOUT_RESTART = FADEOUT_MENU_TITLE; + // (LuaGame.cpp, LuaChallengeParam.cpp) Adds REPENTOGON's Game functions: its counters and state, the erased enemies, // the color modifiers, bloom and dizziness, and the fixed GetPlayer, MoveToRandomRoom, StartStageTransition and stage -// getters. Difficulty becomes writable within the four difficulties. +// getters. Difficulty becomes writable within the four difficulties, and Fadeout takes Repentance's targets without +// vanilla parity. void game_repentogon_register(lua_State* state) { lua_method(state, "ClearErasedEnemies", [](Game& game) { game.erasedEntities.clear(); }); @@ -314,6 +322,11 @@ void game_repentogon_register(lua_State* state) lua_method(state, "GetGenericPrompt", [](Game& game) { return game.genericPrompt; }); lua_method(state, "IsStartingFromState", [](Game& game) { return game.isStartingFromState; }); lua_method(state, "GetChallengeParams", [](Game& game) { return &game.GetChallengeParams(); }); + lua_method(state, "Fadeout", [](Game& game, float speed, FadeOutTarget target, KColor color) { + if (!repentogonOptions.isVanillaParity && target == REPENTANCE_FADEOUT_TITLE) target = FADEOUT_MENU_TITLE; + else if (!repentogonOptions.isVanillaParity && target == REPENTANCE_FADEOUT_RESTART) target = FADEOUT_RESTART; + game.Fadeout(speed, target, color); + }); lua_property( state, "Difficulty", [](Game& game) { return game.difficulty; }, [](Game& game, int difficulty) { @@ -363,8 +376,7 @@ static int new_game_start(lua_State* state) } // (LuaIsaac.cpp) Adds REPENTOGON's Isaac functions over runs: whether one is on or true co-op may start, starting a -// new run or a practice daily, and the challenges' completion. The rebuild keeps no modded challenge's clears, so -// GetModChallengeClearCount counts none. +// new run or a practice daily, and the challenges' completion. void isaac_game_register(lua_State* state) { lua_method(state, "CanStartTrueCoop", []() { return !PlayerManager::CoopBabiesOnly(); }); @@ -381,7 +393,7 @@ void isaac_game_register(lua_State* state) }}, {"StartNewGame", new_game_start}}); lua_method(state, "UnClearChallenge", [](int challenge) { challenge_completion_reset(challenge); }); - lua_method(state, "GetModChallengeClearCount", [](int) { return 0; }); + lua_method(state, "GetModChallengeClearCount", [](int challenge) { return mod_challenge_clears_get(challenge); }); lua_method(state, "StartDailyGame", [](uint32_t date) { g_manager->StartNewGame(PLAYER_ISAAC, 0, Seeds(), 0); g_manager->dailyChallenge.Init(date); diff --git a/src/repentogon/api_items.cpp b/src/repentogon/api_items.cpp index 16e9a8f..a33ff1a 100644 --- a/src/repentogon/api_items.cpp +++ b/src/repentogon/api_items.cpp @@ -9,6 +9,9 @@ #include "repentogon/api.h" #include "repentogon/api_items.h" #include "repentogon/items.h" +#include "repentogon/custom_pools.h" +#include "repentogon/pool_items.h" +#include "repentogon/xml_data.h" #include #include #include @@ -16,7 +19,7 @@ // REPENTOGON's item and pool bindings (LuaInterfaces/LuaItemPool.cpp, LuaItemConfig.cpp, LuaWeightedOutcomePicker.cpp, // ProcedualItems/*.cpp, LuaIsaac.cpp's GetNullItemIdByName and GetCollectibleSpawnPosition and ItemPoolManager.cpp's -// GetPoolIdByName). Without REPENTOGON's custom pools every pool is the game's. +// GetPoolIdByName). constexpr int POOL_NULL = -1; constexpr int DEFAULT_LIST_ITEM = 25; @@ -52,8 +55,8 @@ static bool is_pool_ready(ItemPool& pool) static ItemPool_Item& pool_check(lua_State* state, ItemPool& itemPool, int index) { lua_Integer poolType = luaL_checkinteger(state, index); - if (poolType < 0 || poolType >= POOL_COUNT) luaL_argerror(state, index, "Invalid ItemPoolType"); - return itemPool.pools[poolType]; + if (poolType < 0 || poolType >= POOL_COUNT + custom_pool_count()) luaL_argerror(state, index, "Invalid ItemPoolType"); + return itemPool.GetPool((ItemPoolType)poolType); } static bool is_marked(const std::vector& marks, lua_Integer id) @@ -142,9 +145,10 @@ static int random_pool_get(lua_State* state) } WeightedOutcomePicker picker; - for (int poolType = 0; poolType < POOL_COUNT; poolType++) + for (int poolType = 0; poolType < POOL_COUNT + custom_pool_count(); poolType++) if (isWhitelist == filter.contains(poolType)) - picker.AddOutcomeWeight(poolType, (int)(uint32_t)(itemPool.pools[poolType].totalWeight * RANDOM_POOL_WEIGHT_SCALE)); + picker.AddOutcomeWeight(poolType, (int)(uint32_t)(itemPool.GetPool((ItemPoolType)poolType).totalWeight * + RANDOM_POOL_WEIGHT_SCALE)); rng.Next(); RNG pickerRng; @@ -241,7 +245,8 @@ static int bible_upgrade_add(lua_State* state) ItemPool& itemPool = lua_get(state, 1); int add = (int)luaL_checkinteger(state, 2); int poolType = (int)luaL_checkinteger(state, 3); - if ((uint32_t)poolType > POOL_COUNT) return luaL_argerror(state, 3, "Invalid ItemPoolType"); + if ((uint32_t)poolType > (uint32_t)(POOL_COUNT + custom_pool_count())) + return luaL_argerror(state, 3, "Invalid ItemPoolType"); itemPool.AddBibleUpgrade(add, poolType); return 0; } @@ -283,9 +288,10 @@ static int bible_upgrades_get(lua_State* state) } // Adds REPENTOGON's functions to ItemPool, GetCollectible, GetTrinket, AddRoomBlacklist and AddBibleUpgrade in place of -// the game's. Its virtual and temporary pool items (AddCollectible and the like) need its custom pools. +// the game's, and its pool items (repentogon/pool_items.cpp). void item_pool_api_register(lua_State* state) { + pool_items_api_register(state); lua_functions_add(state, {{"GetCollectible", pool_collectible_get}, {"AddBibleUpgrade", bible_upgrade_add}, {"GetRandomPool", random_pool_get}, @@ -476,6 +482,11 @@ void item_config_api_register(lua_State* state) lua_functions_add(state, {{"GetTaggedItems", tagged_items_get}, {"GetItemsWithCustomTag", custom_tag_items_get}, {"CanRerollCollectible", collectible_reroll_check}}); + // ItemConfig::IsValidTrinket, which REPENTOGON documents but leaves unregistered: an existing trinket, golden or not. + lua_method(state, "IsValidTrinket", [](ItemConfig& config, uint32_t id) { + uint32_t plain = id & TRINKET_ID_MASK; + return plain != 0 && plain < config.trinkets.size() && config.GetTrinket((int)plain); + }); } // Adds REPENTOGON's item functions to the Isaac namespace. @@ -487,10 +498,7 @@ void isaac_items_register(lua_State* state) if (item && item->name == name) return item->id; return -1; }); - lua_method(state, "GetPoolIdByName", [](std::string name) { - auto pool = std::ranges::find(POOL_NAMES, name); - return pool == std::end(POOL_NAMES) ? POOL_NULL : (int)(pool - std::begin(POOL_NAMES)); - }); + lua_method(state, "GetPoolIdByName", [](std::string name) { return pool_id_find(name); }); } // WeightedOutcomePicker:GetOutcomes: each outcome as a table of its Value and Weight. @@ -661,4 +669,5 @@ void items_classes_register(lua_State* state) loot_list_entry_register(state); outcome_picker_register(state); procedural_register(state); + xml_data_api_register(state); } diff --git a/src/repentogon/api_level.cpp b/src/repentogon/api_level.cpp index eb1153b..4a4995e 100644 --- a/src/repentogon/api_level.cpp +++ b/src/repentogon/api_level.cpp @@ -9,8 +9,11 @@ #include "level/room_config.h" #include "repentogon/api.h" #include "repentogon/level.h" +#include "repentogon/virtual_rooms.h" #include +#include #include +#include #include constexpr int ROOM_TYPE_LAST = 29; @@ -595,12 +598,10 @@ static int stage_is_loaded(lua_State* state) return 1; } -// RoomConfigSet:Get(index): a room of the set, nil past it or below 0. +// RoomConfigSet:Get(index): a room of the set, its virtual rooms after the game's, nil past them or below 0. static int room_set_get(lua_State* state) { - RoomSet& set = *lua_get(state, 1).set; - auto index = (lua_Integer)lua_tointeger(state, 2); - lua_push(state, index >= 0 && index < (lua_Integer)set.configs.size() ? &set.configs[index] : nullptr); + lua_push(state, virtual_room_set_get(*lua_get(state, 1).set, lua_tointeger(state, 2))); return 1; } @@ -634,9 +635,10 @@ static void room_config_classes_register(lua_State* state) lua_class_hidden_end(state); lua_class_begin(state, "RoomConfigSet", LUA_CLASS_ROOM_CONFIG_SET); - lua_property(state, "Size", [](RoomConfigSetRef& ref) { return (int)ref.set->configs.size(); }); + lua_property(state, "Size", [](RoomConfigSetRef& ref) { return virtual_room_set_size(*ref.set); }); lua_functions_add(state, {{"Get", room_set_get}}); - lua_method(state, "__len", [](RoomConfigSetRef& ref) { return (int)ref.set->configs.size(); }); + lua_method(state, "__len", [](RoomConfigSetRef& ref) { return virtual_room_set_size(*ref.set); }); + virtual_rooms_room_set_register(state); lua_class_hidden_end(state); } @@ -652,6 +654,170 @@ static void generator_rooms_push(lua_State* state, LevelGenerator& generator, co } } +// LuaLevelGenerator.cpp's LinkDirection: the side of a placed room its neighbour joins it on, as the generator's +// connect direction and its adjusted door slot number them. +enum LinkDirection +{ + LINK_INVALID = -1, + LINK_RIGHT, + LINK_DOWN, + LINK_LEFT, + LINK_UP, + LINK_ADJUSTED_RIGHT, + LINK_ADJUSTED_DOWN, + LINK_ADJUSTED_LEFT, + LINK_ADJUSTED_UP +}; + +constexpr int GRID_LINE_LAST = LEVEL_GRID_WIDTH - 1; + +// ShapeToIndices: the grid indexes a shape covers from its top left cell, counted without wrapping checks. +static std::vector shape_cells_get(XY position, RoomShape shape) +{ + std::vector cells; + for (XY offset : LevelGenerator::get_room_placement_offsets(shape)) + cells.push_back((position.y + offset.y) * LEVEL_GRID_WIDTH + position.x + offset.x); + return cells; +} + +// ComputeLinkDirection: the side target lies on from source, two neighbouring grid indexes. +static int link_direction_get(int source, int target) +{ + if (target == source - LEVEL_GRID_WIDTH) return LINK_UP; + if (target == source + LEVEL_GRID_WIDTH) return LINK_DOWN; + if (target == source - 1) return LINK_LEFT; + return target == source + 1 ? LINK_RIGHT : LINK_INVALID; +} + +// ComputeAdjustedLinkDirection: the adjusted side of a bigger room from its top left cell to the neighbour's cell. +// REPENTOGON tests the left offset twice, so the adjusted up side is never returned. +static int link_adjusted_get(const LevelGenerator_Room& room, int index) +{ + constexpr int OFFSET_LEFT = -(LEVEL_GRID_WIDTH - 1); + constexpr int OFFSET_RIGHT = LEVEL_GRID_WIDTH + 1; + constexpr int OFFSET_RIGHT_WIDE = LEVEL_GRID_WIDTH + 2; + constexpr int OFFSET_DOWN = LEVEL_GRID_WIDTH * 2 + 1; + int offset = index - room.position.ToGridIdx(); + if (offset == OFFSET_LEFT) return LINK_ADJUSTED_LEFT; + if (offset == OFFSET_RIGHT || offset == OFFSET_RIGHT_WIDE) return LINK_ADJUSTED_RIGHT; + return offset == OFFSET_DOWN ? LINK_ADJUSTED_DOWN : LINK_INVALID; +} + +// ComputeSafeConnection: the cell of a placed room its neighbour links through, by its shape and joined side. None for +// a side the shape cannot join on. +static std::optional link_cell_get(const LevelGenerator_Room& neighbor, const LevelGenerator_Room& room) +{ + XY at = room.position; + XY right = at + XY{1, 0}; + XY below = at + XY{0, 1}; + XY corner = at + XY{1, 1}; + bool isNeighborAbove = neighbor.position.y <= at.y; + bool isNeighborRight = at.x <= neighbor.position.x; + RoomShape shape = room.shape; + int side = room.connectDirection; + + if (shape == ROOMSHAPE_1x1 || shape == ROOMSHAPE_IH || shape == ROOMSHAPE_IV) return at; + if (shape == ROOMSHAPE_1x2 || shape == ROOMSHAPE_IIV) + { + if (side == LINK_UP || ((side == LINK_RIGHT || side == LINK_LEFT) && isNeighborAbove)) return at; + return side == LINK_INVALID || side > LINK_UP ? std::nullopt : std::optional(below); + } + if (shape == ROOMSHAPE_2x1 || shape == ROOMSHAPE_IIH) + { + if (side == LINK_LEFT || ((side == LINK_UP || side == LINK_DOWN) && isNeighborRight)) return at; + return side == LINK_INVALID || side > LINK_UP ? std::nullopt : std::optional(right); + } + switch (side) + { + case LINK_UP: + if (shape == ROOMSHAPE_LTL) return right; + return shape == ROOMSHAPE_LTR || isNeighborRight ? at : right; + case LINK_LEFT: + if (shape == ROOMSHAPE_LTL) return right; + return shape == ROOMSHAPE_LBL || isNeighborAbove ? at : below; + case LINK_RIGHT: + if (shape == ROOMSHAPE_LTR) return corner; + return shape == ROOMSHAPE_LBR || isNeighborAbove ? right : corner; + case LINK_DOWN: + if (shape == ROOMSHAPE_LBL) return corner; + return shape == ROOMSHAPE_LBR || isNeighborRight ? below : corner; + default: + return std::nullopt; + } +} + +// LevelGenerator:PlaceRoom(column, line, shape, neighbour): adds a room beside a LevelGeneratorRoom, linked to it as +// the generator links its own, then refreshes the doors and dead ends. Its generation index, nil when a cell fell off +// the grid. Raises an error for a cell taken, no shared side or a placement the neighbours' doors refuse. +static int generator_room_place(lua_State* state) +{ + LevelGenerator& generator = lua_get(state, 1); + int column = (int)luaL_checkinteger(state, 2); + if (column < 0 || column > GRID_LINE_LAST) + return luaL_error(state, "Invalid column %d, value must be between 0 and 12 (inclusive)", column); + int line = (int)luaL_checkinteger(state, 3); + if (line < 0 || line > GRID_LINE_LAST) + return luaL_error(state, "Invalid line %d, value must be between 0 and 12 (inclusive)", line); + int shape = (int)luaL_checkinteger(state, 4); + if (shape < 0 || shape >= ROOMSHAPE_ANY) + return luaL_error(state, "Invalid room shape %d, value must be between 0 and %d (inclusive)", shape, + ROOMSHAPE_ANY); + + LevelGenerator_Room room; + room.position = {column, line}; + room.shape = (RoomShape)shape; + std::vector cells = shape_cells_get(room.position, room.shape); + std::string conflicts; + int conflictCount = 0; + for (LevelGenerator_Room& other : generator.rooms) + { + std::vector taken = shape_cells_get(other.position, other.shape); + if (std::ranges::none_of(cells, [&](int cell) { return std::ranges::find(taken, cell) != taken.end(); })) + continue; + conflictCount++; + conflicts += std::format("{} at ({}, {}); ", other.generationIndex, other.position.y, other.position.x); + } + if (conflictCount > 0) + return luaL_error(state, "Invalid room data (shape = %d, coordinates (%d, %d)), this would collide with room%s: %s", + shape, line, column, conflictCount > 1 ? "s" : "", conflicts.c_str()); + + LevelGenerator_Room& neighbor = lua_get(state, 5); + room.distanceFromStart = neighbor.distanceFromStart + 1; + std::optional> joint; + for (int cell : cells) + for (int other : shape_cells_get(neighbor.position, neighbor.shape)) + if (!joint && link_direction_get(cell, other) != LINK_INVALID) joint = {cell, other}; + if (!joint) return luaL_error(state, "Source room placement does not allow a connection with the target room"); + + room.connectDirection = link_direction_get(joint->first, joint->second); + bool isSmall = room.shape == ROOMSHAPE_1x1 || room.shape == ROOMSHAPE_IH || room.shape == ROOMSHAPE_IV; + room.connectDoorSlot = isSmall ? room.connectDirection : link_adjusted_get(room, joint->second); + if (room.connectDoorSlot == LINK_INVALID) + return luaL_error(state, "Unable to compute adjusted link direction with the neighbor"); + std::optional link = link_cell_get(neighbor, room); + if (!link) + return luaL_error(state, + "[ERROR] Unable to compute safe connection between room at (%d, %d) and tentative room at " + "(%d, %d)\n", + neighbor.position.x, neighbor.position.y, column, line); + room.linkPos = *link; + if (!generator.is_placement_valid(room.position, room.shape)) + return luaL_error(state, "Error while adding room: placement is invalid (%d, %d) from (%d, %d)", column, line, + neighbor.position.x, neighbor.position.y); + + bool isOnGrid = std::ranges::all_of(LevelGenerator::get_room_placement_offsets(room.shape), + [&](XY offset) { return (room.position + offset).ToGridIdx() >= 0; }); + generator.place_room(room); + if (!isOnGrid) + { + lua_pushnil(state); + return 1; + } + generator.update_dead_end_lists(); + lua_pushinteger(state, generator.rooms.back().generationIndex); + return 1; +} + // (LuaLevelGenerator.cpp, LuaLevelGeneratorEntry.cpp) Registers LevelGenerator, a layout as it grows, its rooms as // LevelGeneratorRoom, and LevelGeneratorEntry, a slot a script builds. static void level_generator_register(lua_State* state) @@ -671,6 +837,7 @@ static void level_generator_register(lua_State* state) generator_rooms_push(L, generator, generator.deadEnds); return 1; }}, + {"PlaceRoom", generator_room_place}, {"GetNonDeadEnds", [](lua_State* L) { LevelGenerator& generator = lua_get(L, 1); generator_rooms_push(L, generator, generator.nonDeadEnds); @@ -717,6 +884,10 @@ void repentogon_level_register(lua_State* state) lua_method(state, "HasMirrorDimension", [](Level& level) { return level.HasMirrorDimension(); }); lua_method(state, "HasPhotoDoor", [](Level& level) { return level.HasPhotoDoor(); }); lua_method(state, "SetName", [](Level&, std::string name) { levelNameOverride = name; }); + // Level::IsStageAvailable is IsStageWithinEnd (0074b830), its stage type read as the alternate path when 1. + lua_method(state, "IsStageAvailable", [](Level&, int levelStage, int stageType) { + return Level::IsStageWithinEnd(levelStage, stageType == STAGETYPE_WOTL); + }); lua_method(state, "GetDimension", [](Level& level) { return level.currentDimensionIdx; }); lua_method(state, "GetForceSpecialQuest", [](LuaIgnored) { return specialQuestForce; }); lua_method(state, "SetForceSpecialQuest", [](LuaIgnored, int quest) { specialQuestForce = quest; }); @@ -790,6 +961,7 @@ void repentogon_room_config_register(lua_State* state) lua_table_set(state, -2, "GetRandomRoom"); lua_pushcfunction(state, stage_get); lua_table_set(state, -2, "GetStage"); + virtual_rooms_room_config_register(state); room_config_classes_register(state); } diff --git a/src/repentogon/api_npc.cpp b/src/repentogon/api_npc.cpp index c2be15e..b1e5439 100644 --- a/src/repentogon/api_npc.cpp +++ b/src/repentogon/api_npc.cpp @@ -355,6 +355,8 @@ void npc_api_register(lua_State* state) return npc.MakeBloodCloud(position.value ? *position.value : npc.pos, color.value ? *color.value : COLOR_DEFAULT, BLOOD_CLOUD_SCALE); }); + // Entity_NPC::MakeBloodSplash is the burst an enemy's death leaves (PlayDeathEffects, 006d4e00). + lua_method(state, "SpawnBloodSplash", [](N& npc) { npc.PlayDeathEffects(); }); lua_method(state, "UpdateDirtColor", [](N& npc, LuaCheckedBool isImmediate) { npc.UpdateDirtColor(isImmediate.value); }); lua_method(state, "GetDirtColor", [](N& npc) { return npc.dirtColor; }); diff --git a/src/repentogon/api_room.cpp b/src/repentogon/api_room.cpp index ddb6cfa..381e0da 100644 --- a/src/repentogon/api_room.cpp +++ b/src/repentogon/api_room.cpp @@ -9,6 +9,7 @@ #include "level/room_special.h" #include "repentogon/api.h" #include "repentogon/api_level.h" +#include "repentogon/custom_pools.h" #include "repentogon/level.h" #include "repentogon/lua_render.h" #include "repentogon/npc.h" @@ -232,7 +233,7 @@ static int lightning_strike(lua_State* state) static int item_pool_set(lua_State* state) { int pool = (int)luaL_checkinteger(state, 2); - if (pool < POOL_NONE || pool >= POOL_COUNT) return luaL_argerror(state, 2, "Invalid ItemPoolType"); + if (pool < POOL_NONE || pool >= POOL_COUNT + custom_pool_count()) return luaL_argerror(state, 2, "Invalid ItemPoolType"); forcedItemPool = pool; return 0; } diff --git a/src/repentogon/api_saves.cpp b/src/repentogon/api_saves.cpp index 5813deb..bcdeb92 100644 --- a/src/repentogon/api_saves.cpp +++ b/src/repentogon/api_saves.cpp @@ -5,6 +5,7 @@ #include "repentogon/api.h" #include "repentogon/api_level.h" #include "repentogon/callbacks.h" +#include "repentogon/progress.h" #include "repentogon/saves.h" #include #include @@ -45,11 +46,6 @@ constexpr int MARKS_SET_ORDER[] = {COMPLETION_MOMS_HEART, COMPLETION_SATAN, using Marks = std::array; -// The completion marks of modded characters, and the completions of modded challenges by name and mod, which only -// REPENTOGON's XML data fills. -static std::map moddedMarks; -static std::map moddedChallenges; - // The event counter holding a game character's mark, 0 for none (REPENTOGON's MarksToEvents). static int mark_counter_get(int playerType, int completion) { @@ -99,7 +95,7 @@ static void mark_post(int completion, int playerType) // Every mark of a character. static Marks marks_get(int playerType) { - if (is_modded_character(playerType)) return moddedMarks[playerType]; + if (is_modded_character(playerType)) return modded_marks_read(playerType); Marks marks{}; for (int i = 0; i < MARK_SLOTS; i++) marks[i] = mark_get(playerType, i); return marks; @@ -168,7 +164,7 @@ static int marks_table_set(lua_State* state) marks[COMPLETION_ULTRA_GREED] = marks[COMPLETION_ULTRA_GREEDIER] = MARK_HARD; if (is_modded_character(playerType)) { - Marks& kept = moddedMarks[playerType]; + Marks& kept = modded_marks_get(playerType); for (int i = 0; i < MARK_SLOTS; i++) { if (marks[i] <= MARK_NONE) continue; @@ -176,6 +172,7 @@ static int marks_table_set(lua_State* state) else marks[i] = kept[i]; } kept = marks; + modded_marks_save(); return 1; } for (int i : MARKS_SET_ORDER) @@ -196,8 +193,9 @@ static int mark_value_set(lua_State* state) if (value < MARK_NONE || value > MARK_HARD) return luaL_error(state, "Invalid Completion Marks value!(%d)", value); if (value != MARK_NONE && !mark_pre(completion, playerType)) return 1; - if (is_modded_character(playerType)) moddedMarks[playerType][completion] = value; + if (is_modded_character(playerType)) modded_marks_get(playerType)[completion] = value; else mark_set(playerType, completion, value); + if (is_modded_character(playerType)) modded_marks_save(); if (value > MARK_NONE) mark_post(completion, playerType); return 1; } @@ -213,10 +211,11 @@ static int marks_fill(lua_State* state) !isModded && (i == MARK_SCRAPPED_FIRST || i == MARK_SCRAPPED_SECOND || i == COMPLETION_ULTRA_GREEDIER || event_counter_get(mark_counter_get(playerType, i)) >= MARK_HARD); if (isSkipped || !mark_pre(i, playerType)) continue; - if (isModded) moddedMarks[playerType][i] = MARK_HARD; + if (isModded) modded_marks_get(playerType)[i] = MARK_HARD; else g_manager->persistentGameData.IncreaseEventCounter(mark_counter_get(playerType, i), MARK_HARD); mark_post(i, playerType); } + if (is_modded_character(playerType)) modded_marks_save(); lua_pushinteger(state, MARK_HARD); return 1; } @@ -227,7 +226,8 @@ static int marks_clear(lua_State* state) int playerType = (int)luaL_checkinteger(state, 1); if (is_modded_character(playerType)) { - moddedMarks[playerType] = {}; + modded_marks_get(playerType) = {}; + modded_marks_save(); return 1; } PersistentGameData& data = g_manager->persistentGameData; @@ -245,7 +245,7 @@ static int marks_filled_get(lua_State* state) { int playerType = (int)luaL_checkinteger(state, 1); bool isModded = is_modded_character(playerType); - Marks marks = isModded ? moddedMarks[playerType] : Marks{}; + Marks marks = isModded ? modded_marks_get(playerType) : Marks{}; int lowest = MARK_HARD; for (int i = 0; i < MARK_SLOTS; i++) { @@ -268,7 +268,7 @@ static int marks_tainted_get(lua_State* state) bool isModded = is_modded_character(playerType); int lowest = MARK_HARD; for (int completion : marks) - lowest = std::min(lowest, isModded ? moddedMarks[playerType][completion] + lowest = std::min(lowest, isModded ? modded_marks_get(playerType)[completion] : event_counter_get(mark_counter_get(playerType, completion))); lua_pushinteger(state, lowest); return 1; @@ -280,17 +280,18 @@ static int mark_value_get(lua_State* state) int completion = (int)luaL_checkinteger(state, 2); int playerType = (int)luaL_checkinteger(state, 1); bool isModded = is_modded_character(playerType); - lua_pushinteger(state, isModded ? moddedMarks[playerType][completion] : mark_get(playerType, completion)); + lua_pushinteger(state, isModded ? modded_marks_read(playerType)[completion] : mark_get(playerType, completion)); return 1; } // Isaac.GetCompletionMarkData(mod, player name, tainted): a modded character's marks, nil for none. static int marks_data_get(lua_State* state) { - luaL_checkstring(state, 1); - luaL_checkstring(state, 2); - lua_get(state, 3); - lua_pushnil(state); + std::string mod = luaL_checkstring(state, 1); + std::string name = luaL_checkstring(state, 2); + std::optional marks = modded_marks_find(mod, name, lua_get(state, 3).value); + if (marks) marks_push(state, -1, *marks); + else lua_pushnil(state); return 1; } @@ -299,7 +300,7 @@ bool challenge_is_completed(int challenge) { if (challenge <= 0) return false; if (challenge <= CHALLENGE_LAST) return g_manager->persistentGameData.challenges[challenge]; - return false; + return mod_challenge_clears_get(challenge) > 0; } // (ChallengesStuff.cpp MarkChallengeCompleted) Counts a challenge completed, saving at once. @@ -314,7 +315,8 @@ void challenge_completed_mark(int challenge) // (ChallengesStuff.cpp ResetChallengeCompletion) Counts a challenge not completed, saving at once. void challenge_completion_reset(int challenge) { - if (challenge < 0 || challenge > CHALLENGE_LAST) return; + if (challenge > CHALLENGE_LAST) return mod_challenge_reset(challenge); + if (challenge < 0) return; PersistentGameData& data = g_manager->persistentGameData; data.challenges[challenge] = false; data.Save(); @@ -336,9 +338,9 @@ static int mod_challenge_completion_get(lua_State* state) { std::string mod = luaL_checkstring(state, 1); std::string name = luaL_checkstring(state, 2); - auto found = moddedChallenges.find(name + mod); - if (found == moddedChallenges.end()) lua_pushnil(state); - else lua_pushboolean(state, found->second > 0); + std::optional clears = mod_challenge_clears_find(mod, name); + if (clears) lua_pushboolean(state, *clears > 0); + else lua_pushnil(state); return 1; } diff --git a/src/repentogon/console.cpp b/src/repentogon/console.cpp index cf76e56..d645ee1 100644 --- a/src/repentogon/console.cpp +++ b/src/repentogon/console.cpp @@ -6,12 +6,123 @@ #include "repentogon/achievements.h" #include "repentogon/api_game.h" #include "repentogon/options.h" +#include "repentogon/vanilla_fixes.h" +#include "level/room.h" +#include "lua/engine.h" #include "ui/console.h" +#include "ui/menu/manager.h" +#include #include +#include #include +#include #include +#include +#include +#include +#include constexpr std::string_view REPENTOGON_GREETING = "REPENTOGON Console\n"; +constexpr std::string_view HELP_OUTSIDE_RUN_HINT = + "(Only commands enabled to show outside of the game will appear right now.)\n"; +constexpr const char* CLEAN_BESTIARY_PROMPT = + "This will erase the bestiary data (encounters, kills etc) for any enemies that cannot appear in the bestiary, or " + "do not currently exist in your game (such as enemies from mods you do not currently have enabled).\n\nDoing this " + "is only reccomended if your save file is nearing the limit of 64KB (current size: {}).\n\nWould you like to " + "proceed?"; +constexpr int BESTIARY_KEY_ENTITY_SHIFT = 8; +constexpr int BESTIARY_KEY_TYPE_SHIFT = 12; +constexpr int BESTIARY_KEY_VARIANT_MASK = 0xff; +constexpr float BYTES_PER_KILOBYTE = 1024; +constexpr int SAVE_SLOT_LAST = 3; + +// The commands REPENTOGON refuses outside a run, which need one. +constexpr std::array MENU_REFUSED_COMMANDS = { + "challenge", "clearseeds", "combo", "costumetest", "curse", "debug", "delirious", "goto", "giveitem", "giveitem2", + "g", "g2", "giveeffect", "ge", "gridspawn", "listcollectibles", "macro", "m", "metro", "remove", "remove2", "r", + "r2", "removeeffect", "re", "reseed", "restart", "seed", "spawn", "time"}; + +// Whether a run is going, where commands act for a player. +bool is_console_in_run() +{ + return g_manager->state == MANAGER_STATE_GAME && g_game; +} + +// (ConsoleHooks.cpp) Whether a command is refused: REPENTOGON's console runs commands from the menus too, but not those +// that need a run. +bool is_console_command_refused(Console& console, std::string_view name) +{ + if (repentogonOptions.isVanillaParity || is_console_in_run()) return false; + if (std::ranges::find(MENU_REFUSED_COMMANDS, name) == MENU_REFUSED_COMMANDS.end()) return false; + console.PrintError(std::format("[ERROR] {} can't be used if not in-game!", name)); + return true; +} + +// luareset: closes Lua and opens it anew, then runs every loaded mod's main.lua again by name, without loading XML. +// The room's entities forget their Lua data, which lived in the closed state. +static void lua_reset() +{ + LuaEngine& engine = lua_engine_get(); + std::map mods; + + for (auto& mod : g_manager->modManager.mods) + if (mod->isLoaded) mods[mod->name] = mod->directory; + LuaMode mode = engine.mode; + engine.destroy(); + engine.Init(mode); + for (Entity* entity : g_game->room->entityList.updateEL) entity->dataRef = LUA_REF_NONE; + for (auto& [name, directory] : mods) engine.LuamodCMD(directory); +} + +// The size of the current save file, as the prompt shows it. +static std::string save_size_text() +{ + std::error_code error; + auto size = std::filesystem::file_size(g_manager->persistentGameData.filePath, error); + if (error || size == 0) return "?KB"; + return std::to_string((int)std::ceil((float)size / BYTES_PER_KILOBYTE)) + "KB"; +} + +// cleanbestiary: once asked, erases the bestiary counts of every entity the bestiary cannot show or the game does not +// have (a disabled mod's), the one part of a save without a limit, then saves. +static void bestiary_clean(Console& console) +{ + PersistentGameData& data = g_manager->persistentGameData; + bool isFileMenu = !is_console_in_run() && g_menuManager && + (g_menuManager->selectedMenuId == MENU_TITLE || g_menuManager->selectedMenuId == MENU_SAVE); + uint32_t slot = g_manager->currentSaveSlot; + if (isFileMenu || slot < 1 || slot > SAVE_SLOT_LAST || !data.isFileLoaded) + return console.Print("Cannot clean bestiary data - no save file loaded.\n"); + + std::string prompt = std::format(CLEAN_BESTIARY_PROMPT, save_size_text()); + SDL_MessageBoxButtonData buttons[] = {{SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "Yes"}, + {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, "No"}}; + SDL_MessageBoxData box = {SDL_MESSAGEBOX_INFORMATION, nullptr, "REPENTOGON", prompt.c_str(), 2, buttons, nullptr}; + int answer = 0; + if (!SDL_ShowMessageBox(&box, &answer) || answer != 1) return; + + PersistentGameData_Bestiary& bestiary = data.bestiary; + std::set keys; + for (std::map* counts : {&bestiary.deaths, &bestiary.encounters, &bestiary.hits, &bestiary.kills}) + for (auto& [key, count] : *counts) keys.insert(key); + + int removed = 0; + for (int key : keys) + { + int type = (key >> BESTIARY_KEY_ENTITY_SHIFT) >> BESTIARY_KEY_TYPE_SHIFT; + int variant = (key >> BESTIARY_KEY_ENTITY_SHIFT) & BESTIARY_KEY_VARIANT_MASK; + EntityConfig_Entity* entity = g_manager->entityConfig.GetBestiaryConfig(type, variant); + bool isShown = entity && entity->variant == variant && entity->portrait > -1 && entity->baseHP > 0 && + entity->isBestiary; + if (isShown) continue; + + for (std::map* counts : {&bestiary.deaths, &bestiary.encounters, &bestiary.hits, &bestiary.kills}) + counts->erase(key); + removed++; + } + if (removed > 0) data.Save(); + console.Print(std::format("Bestiary cleanup completed. {}/{} enemies removed.\n", removed, keys.size())); +} // giveeffect and removeeffect (ge and re): c for a collectible's effect, t for a trinket's, a bare id for a null // item's. @@ -36,7 +147,7 @@ static void effect_command_run(const std::vector& words, bool isGiv static void help_command_run(Console& console, const std::vector& words) { std::vector names = command_names_get(); - std::string text; + std::string text = is_console_in_run() ? "" : std::string(HELP_OUTSIDE_RUN_HINT); std::ranges::sort(names); for (std::string_view name : names) @@ -67,13 +178,22 @@ static void achievement_command_run(Console& console, const std::vector& words, Entity_Player*) { if (repentogonOptions.isVanillaParity) return false; std::string_view name = words[0]; - if (name == "help") help_command_run(console, words); + if (name == "luareset") lua_reset(); + else if (name == "fullrestart") is_game_restarted(); + else if (name == "cleanbestiary") bestiary_clean(console); + else if (name == "clearcache") + { + g_manager->modManager.redirectedPaths.clear(); + return false; + } + else if (name == "help") help_command_run(console, words); else if (name == "achievement" || name == "lockachievement") achievement_command_run(console, words, name == "lockachievement"); else if (name == "giveeffect" || name == "ge" || name == "removeeffect" || name == "re") diff --git a/src/repentogon/console.h b/src/repentogon/console.h index 89a8e3a..a9b97b8 100644 --- a/src/repentogon/console.h +++ b/src/repentogon/console.h @@ -9,6 +9,8 @@ struct Capsule; struct Entity_Player; struct Vector; +bool is_console_in_run(); +bool is_console_command_refused(Console& console, std::string_view name); bool is_console_hook_run(Console& console, const std::vector& words, Entity_Player* player); std::string_view console_greeting_get(std::string_view greeting); void query_debug_render(const Vector& position, float radius); diff --git a/src/repentogon/controllers.cpp b/src/repentogon/controllers.cpp new file mode 100644 index 0000000..f5439b3 --- /dev/null +++ b/src/repentogon/controllers.cpp @@ -0,0 +1,61 @@ +#include "repentogon/controllers.h" +#include "engine/platform.h" +#include "entity/player/player.h" +#include "game/game.h" +#include "repentogon/options.h" +#include + +// REPENTOGON's controller hand-outs (Patches/ASMPatches/ASMPlayerManager.cpp), each only without vanilla parity. The +// players a mod spawns sharing a controller (its twins and co-players) lose it and get it back together, where the +// game counts each as a co-op player of its own and asks for their controllers. + +static bool isDisconnectReassigned = false; + +// Takes a player's controller, and every other player's sharing it, each remembering it. +void controller_unassign(Entity_Player& player) +{ + int previous = player.controllerIndex; + + player.SetControllerIndex(-1, true); + if (repentogonOptions.isVanillaParity || previous < 0) return; + + for (Entity_Player* other : g_game->playerManager.playerList) + { + if (other->controllerIndex != previous) continue; + log_printf(LOG_INFO, "[ASMPlayerManager::UnassignController] Transitively unassigning ControllerIndex %d from " + "player %d (via player %d)\n", previous, other->playerIndex, player.playerIndex); + other->SetControllerIndex(-1, false); + other->previousControllerIndex = previous; + } + player.previousControllerIndex = previous; +} + +// Gives a player a controller, and every player without one that shared its last one. After a disconnect, the game's +// hand-out stops for the frame and checks every controller again on the next, where the original sticks on Jacob and +// Esau as a co-op player. +void controller_reassign(Entity_Player& player, int index, ControllerHandout handout) +{ + bool isUnset = player.controllerIndex == -1; + int previous = player.previousControllerIndex; + + player.SetControllerIndex(index, true); + if (repentogonOptions.isVanillaParity || !isUnset) return; + + isDisconnectReassigned |= handout == HANDOUT_DISCONNECT; + if (previous < 0) return; + for (Entity_Player* other : g_game->playerManager.playerList) + { + if (other->controllerIndex != -1 || other->previousControllerIndex != previous) continue; + log_printf(LOG_INFO, "[ASMPlayerManager::ReassignController] Transitively re-assigning ControllerIndex %d to " + "player %d (via player %d)\n", index, other->playerIndex, player.controllerIndex); + other->SetControllerIndex(index, false); + other->previousControllerIndex = -1; + } + player.previousControllerIndex = -1; +} + +// Whether the disconnect hand-out stops for the frame, as it just gave a controller back. +bool is_controller_handout_ended() +{ + return std::exchange(isDisconnectReassigned, false); +} diff --git a/src/repentogon/controllers.h b/src/repentogon/controllers.h new file mode 100644 index 0000000..2511b16 --- /dev/null +++ b/src/repentogon/controllers.h @@ -0,0 +1,14 @@ +#pragma once + +struct Entity_Player; + +// Whether a controller is handed out on a continue, or after a disconnect, which then ends the hand-outs of the frame. +enum ControllerHandout +{ + HANDOUT_CONTINUE, + HANDOUT_DISCONNECT +}; + +void controller_unassign(Entity_Player& player); +void controller_reassign(Entity_Player& player, int index, ControllerHandout handout); +bool is_controller_handout_ended(); diff --git a/src/repentogon/custom_cache.cpp b/src/repentogon/custom_cache.cpp index 493fe32..0ef99a2 100644 --- a/src/repentogon/custom_cache.cpp +++ b/src/repentogon/custom_cache.cpp @@ -174,6 +174,13 @@ std::string consumable_format_get(ConsumableLimit kind, const char* vanilla) return "%0" + std::to_string(digits) + "d"; } +// (GetCustomCacheValue) A custom cache's value: what a mod's evaluation made of it, else the game's number. +double custom_cache_value_get(Entity_Player& player, const std::string& cache) +{ + auto result = player.customCache.results.find(cache); + return result == player.customCache.results.end() ? cache_default_get(player, cache) : result->second; +} + // (TearsCapHook) The least fire delay: from a mod's tears cap, else the game's. float tears_cap_get(Entity_Player& player, float vanilla) { diff --git a/src/repentogon/custom_cache.h b/src/repentogon/custom_cache.h index eaa5057..c8f4c00 100644 --- a/src/repentogon/custom_cache.h +++ b/src/repentogon/custom_cache.h @@ -35,6 +35,7 @@ enum ConsumableLimit void custom_caches_known_add(const std::set& caches); void custom_cache_trigger(Entity_Player& player, ItemConfig_Item* item, CustomCacheTiming timing); void custom_caches_evaluate(Entity_Player& player); +double custom_cache_value_get(Entity_Player& player, const std::string& cache); int consumable_limit_get(ConsumableLimit kind, int vanilla); std::string consumable_format_get(ConsumableLimit kind, const char* vanilla); float tears_cap_get(Entity_Player& player, float vanilla); diff --git a/src/repentogon/custom_pools.cpp b/src/repentogon/custom_pools.cpp new file mode 100644 index 0000000..ed4953b --- /dev/null +++ b/src/repentogon/custom_pools.cpp @@ -0,0 +1,348 @@ +// Mods' own item pools (Patches/ItemPoolManager.cpp's CustomItemPool): an itempools.xml whose name is none of +// the game's makes a pool numbered after them, drawn from, picked by Chaos and kept in the run's states like theirs. +#include "repentogon/custom_pools.h" +#include "engine/log.h" +#include "game/game.h" +#include "game/manager.h" +#include "game/mod_manager.h" +#include "lua/engine.h" +#include "repentogon/json_save.h" +#include "repentogon/xml.h" +#include "simdjson.h" +#include +#include +#include +#include +#include + +constexpr const char* ITEM_POOLS_FILE = "itempools.xml"; +constexpr int STATE_SLOT_COUNT = 3; +constexpr uint32_t POOL_RNG_SHIFT = 35; +constexpr std::string_view STATE_FOLDER = "ItemPoolManager/"; +constexpr std::string_view STATE_SUFFIX = ".custom.json"; + +// What a pool's ChaosMode attribute lets Chaos draw it in. +enum ChaosMode : uint8_t +{ + CHAOS_MODE_NONE = 0, + CHAOS_MODE_NORMAL = 1, + CHAOS_MODE_GREED = 2, + CHAOS_MODE_ALL = CHAOS_MODE_NORMAL | CHAOS_MODE_GREED +}; + +// What a run's state keeps of a mod's pool (CustomPoolSaveState): its items' weights, Bible chance and Genesis count. +struct CustomPoolState +{ + std::vector weights; + int bibleUpgrade = 0; + uint16_t genesisItems = 0; +}; + +// A mod's pool: its name, its items as the last itempools.xml naming it lists them, the Chaos modes it is drawn in, +// and the states the run keeps of it. +struct CustomPool +{ + std::string name; + ItemPool_Item pool; + std::vector items; + std::array, STATE_SLOT_COUNT> states; + uint16_t genesisItems = 0; + uint8_t chaosModes = CHAOS_MODE_NORMAL; +}; + +static std::vector customPools; + +// The pool of an id, none for the game's or an unknown one. +static CustomPool* custom_pool_find(int id) +{ + int index = id - POOL_COUNT; + return index >= 0 && index < (int)customPools.size() ? &customPools[index] : nullptr; +} + +ItemPool_Item* custom_pool_get(int id) +{ + CustomPool* custom = custom_pool_find(id); + return custom ? &custom->pool : nullptr; +} + +// (CustomItemPool::get_remaining_genesis_items) The Genesis count of a pool, the game's or a mod's, none for an unknown +// id. +uint16_t* genesis_items_get(int id) +{ + if (id >= 0 && id < POOL_COUNT) return &g_game->itemPool.remainingGenesisItems[id]; + CustomPool* custom = custom_pool_find(id); + return custom ? &custom->genesisItems : nullptr; +} + +int custom_pool_count() +{ + return (int)customPools.size(); +} + +// (ItemPoolManager::GetPoolIdByName) A pool's id by name, the game's or a mod's, -1 for none. +int pool_id_find(std::string_view name) +{ + auto base = std::ranges::find(POOL_NAMES, name); + if (base != std::end(POOL_NAMES)) return (int)(base - std::begin(POOL_NAMES)); + auto custom = std::ranges::find(customPools, name, &CustomPool::name); + return custom == customPools.end() ? -1 : POOL_COUNT + (int)(custom - customPools.begin()); +} + +std::string_view pool_name_get(int id) +{ + if (id >= 0 && id < POOL_COUNT) return POOL_NAMES[id]; + CustomPool* custom = custom_pool_find(id); + return custom ? std::string_view(custom->name) : std::string_view(); +} + +// (parse_chaos_mode) The words of a ChaosMode attribute: none and all decide at once, normal and greed add up. +static uint8_t chaos_modes_parse(std::string_view text) +{ + uint8_t modes = CHAOS_MODE_NONE; + for (size_t start = 0; start < text.size();) + { + size_t end = std::min(text.find_first_of(" ,", start), text.size()); + std::string word(text.substr(start, end - start)); + std::ranges::transform(word, word.begin(), [](unsigned char letter) { return (char)std::tolower(letter); }); + if (word == "none") return CHAOS_MODE_NONE; + if (word == "all") return CHAOS_MODE_ALL; + if (word == "normal") modes |= CHAOS_MODE_NORMAL; + else if (word == "greed") modes |= CHAOS_MODE_GREED; + else if (!word.empty()) log_printf(LOG_INFO, "[ItemPoolManager] [WARN] - invalid chaos mode: \"%s\"\n", word.c_str()); + start = end + 1; + } + return modes; +} + +// (parse_xml_pool_item) An of a mod's pool: by id, else by name, with its weights. +static PoolItem pool_item_read(DataNode node) +{ + XmlAttributes attributes = xml_attributes_read(node); + PoolItem item; + if (auto id = attributes.find("id"); id != attributes.end()) item.itemId = std::atoi(id->second.c_str()); + else if (auto name = attributes.find("name"); name != attributes.end()) + item.itemId = std::max(LuaEngine::Isaac_GetItemIdByName(name->second), 0); + if (auto weight = attributes.find("weight"); weight != attributes.end()) + item.initialWeight = item.weight = std::strtof(weight->second.c_str(), nullptr); + if (auto decrease = attributes.find("decreaseby"); decrease != attributes.end()) + item.decreaseBy = std::strtof(decrease->second.c_str(), nullptr); + if (auto remove = attributes.find("removeon"); remove != attributes.end()) + item.removeOn = std::strtof(remove->second.c_str(), nullptr); + return item; +} + +// (finalize_pool_item) A pool item's special and unlocked marks from its collectible, as a run fills the pool. +static void pool_item_finalize(PoolItem& item) +{ + ItemConfig_Item* config = g_manager->itemConfig.GetCollectible(item.itemId); + if (!config) return; + item.isSpecial = config->isSpecial; + item.isUnlocked = config->achievementId < 0 || g_manager->persistentGameData.Unlocked(config->achievementId); +} + +// Reads one itempools.xml's pools of names the game lacks: a new name makes a pool, its first ChaosMode stays, and +// its items are this file's. +static void pools_file_read(std::string_view path) +{ + Data data; + data_load(data, path); + std::optional root = data_root_get(data, "ItemPools"); + if (!root) return; + + for (DataNode node : node_children(*root)) + { + std::optional name = node_attr_find(node, "Name"); + if (node_tag(node) != "Pool" || !name || std::ranges::find(POOL_NAMES, *name) != std::end(POOL_NAMES)) continue; + + auto found = std::ranges::find(customPools, *name, &CustomPool::name); + bool isNew = found == customPools.end(); + CustomPool& custom = isNew ? customPools.emplace_back() : *found; + custom.name = *name; + if (std::optional modes = node_attr_find(node, "ChaosMode"); isNew && modes) + custom.chaosModes = chaos_modes_parse(*modes); + + custom.items.clear(); + for (DataNode item : node_children(node)) + if (node_tag(item) == "Item") custom.items.push_back(pool_item_read(item)); + if (custom.items.empty()) + log_printf(LOG_INFO, "[ItemPoolManager] [WARN] - itempool \"%s\" has no items\n", custom.name.c_str()); + } +} + +// (ItemPoolManager::__Init, add_modded_pools) Finds the mods' pools: in the game's itempools.xml, then each loaded +// mod's. +void custom_pools_load() +{ + customPools.clear(); + pools_file_read(g_manager->modManager.TryRedirectPath(ITEM_POOLS_FILE)); + for (auto& mod : g_manager->modManager.mods) + { + std::string path = mod->GetContentPath(ITEM_POOLS_FILE); + bool isFound = resource_exists(path) || resource_exists(path + std::string(JSON_EXTENSION)); + if (mod->isLoaded && isFound) pools_file_read(path); + } +} + +// (CustomItemPool::load_pool, __FinalizePools) Fills the mods' pools for a run, seeding each from a copy of the item +// pool's RNG, then shuffles them in order with a Mersenne Twister of its seed. +void custom_pools_fill(const RNG& itemPoolRNG) +{ + RNG rng = itemPoolRNG; + std::mt19937 twister(itemPoolRNG._seed); + + for (CustomPool& custom : customPools) + { + ItemPool_Item& pool = custom.pool; + pool = ItemPool_Item(); + pool.rng1.SetSeed(rng.Next(), POOL_RNG_SHIFT); + pool.rng2.SetSeed(rng.Next(), POOL_RNG_SHIFT); + pool.poolList = custom.items; + for (PoolItem& item : pool.poolList) pool_item_finalize(item); + for (PoolItem& item : pool.poolList) pool.totalWeight += item.initialWeight; + custom.genesisItems = 0; + } + for (CustomPool& custom : customPools) + { + std::vector& list = custom.pool.poolList; + for (size_t last = list.size() - std::min(list.size(), 1); last > 0; last--) + std::swap(list[last], list[twister() % (last + 1)]); + } +} + +// (__GetChaosPool) The mods' pools Chaos may draw, by their weights, in Greed mode or not. +void custom_pools_chaos_add(std::vector>& outcomes, bool isGreed, float scale) +{ + for (size_t i = 0; i < customPools.size(); i++) + if (customPools[i].chaosModes & (isGreed ? CHAOS_MODE_GREED : CHAOS_MODE_NORMAL)) + outcomes.emplace_back(POOL_COUNT + (int)i, (int)(customPools[i].pool.totalWeight * scale)); +} + +// (__GetItemPoolsForCollectible) Adds the mods' pools holding a collectible. +void custom_pools_with_collectible_add(int collectible, std::vector& found) +{ + for (size_t i = 0; i < customPools.size(); i++) + if (std::ranges::any_of(customPools[i].pool.poolList, [&](PoolItem& item) { return item.itemId == collectible; })) + found.push_back(POOL_COUNT + (int)i); +} + +// (__ResetCollectible) A collectible back at full weight in the mods' pools. +void custom_pools_collectible_reset(int collectible) +{ + for (CustomPool& custom : customPools) + for (PoolItem& item : custom.pool.poolList) + if (item.itemId == collectible) item.weight = item.initialWeight; +} + +// (__AddBibleUpgrade) Raises the Bible's chance in every mod's pool. +void custom_pools_bible_add(int add) +{ + for (CustomPool& custom : customPools) custom.pool.bibleUpgrade += add; +} + +// (CustomItemPool::store_state) Keeps the mods' pools in a game state's slot: 0 the save file's, 1 and 2 the Glowing +// Hourglass's. +void custom_pools_store(int slot) +{ + if (slot < 0 || slot >= STATE_SLOT_COUNT) return; + for (CustomPool& custom : customPools) + { + CustomPoolState& state = custom.states[slot].emplace(); + for (PoolItem& item : custom.pool.poolList) state.weights.push_back(item.weight); + state.bibleUpgrade = custom.pool.bibleUpgrade; + state.genesisItems = custom.genesisItems; + } +} + +// (CustomItemPool::restore_state) Gives the mods' pools back what a slot kept, those it kept nothing of untouched. +void custom_pools_restore(int slot) +{ + if (slot < 0 || slot >= STATE_SLOT_COUNT) return; + for (CustomPool& custom : customPools) + { + std::optional& state = custom.states[slot]; + if (!state) continue; + std::vector& list = custom.pool.poolList; + for (size_t i = 0; i < list.size() && i < state->weights.size(); i++) list[i].weight = state->weights[i]; + custom.pool.bibleUpgrade = state->bibleUpgrade; + custom.genesisItems = state->genesisItems; + } +} + +void custom_pools_clear(int slot) +{ + if (slot < 0 || slot >= STATE_SLOT_COUNT) return; + for (CustomPool& custom : customPools) custom.states[slot].reset(); +} + +static std::string state_path_get(std::string_view fileName) +{ + return json_save_path(std::string(STATE_FOLDER) + std::string(fileName) + std::string(STATE_SUFFIX)); +} + +// (__SaveToDisk) Writes the save file slot's mods' pools beside a game state file, by name, for its checksum. Without +// any the file is removed. +void custom_pools_save(std::string_view fileName, uint32_t checksum) +{ + std::string path = state_path_get(fileName); + std::error_code error; + std::string text = std::format("{{\"Checksum\":{},\"Pools\":{{", checksum); + bool isAny = false; + for (CustomPool& custom : customPools) + { + std::optional& state = custom.states[0]; + if (!state) continue; + std::string name = custom.name; + std::erase_if(name, [](char letter) { return letter == '"' || letter == '\\'; }); + text += std::format("{}\"{}\":{{\"BibleUpgrade\":{},\"RemainingGenesisItems\":{},\"ItemWeights\":[", + isAny ? "," : "", name, state->bibleUpgrade, state->genesisItems); + for (size_t i = 0; i < state->weights.size(); i++) text += std::format("{}{}", i ? "," : "", state->weights[i]); + text += "]}"; + isAny = true; + } + if (!isAny) + { + std::filesystem::remove(path, error); + return; + } + std::filesystem::create_directories(std::filesystem::path(path).parent_path(), error); + std::ofstream(path) << text << "}}\n"; +} + +// (__LoadFromDisk) Reads the mods' pools written beside a game state file into the save file slot, when written for +// that state. +void custom_pools_read(std::string_view fileName, uint32_t checksum) +{ + custom_pools_clear(0); + simdjson::dom::parser parser; + simdjson::dom::object root; + simdjson::dom::object pools; + int64_t written = 0; + if (parser.load(state_path_get(fileName)).get_object().get(root) != simdjson::SUCCESS) return; + if (root["Checksum"].get_int64().get(written) != simdjson::SUCCESS || (uint32_t)written != checksum) return; + if (root["Pools"].get_object().get(pools) != simdjson::SUCCESS) return; + + for (CustomPool& custom : customPools) + { + simdjson::dom::object saved; + simdjson::dom::array weights; + int64_t number = 0; + if (pools[custom.name].get_object().get(saved) != simdjson::SUCCESS) continue; + + CustomPoolState& state = custom.states[0].emplace(); + if (saved["BibleUpgrade"].get_int64().get(number) == simdjson::SUCCESS) state.bibleUpgrade = (int)number; + if (saved["RemainingGenesisItems"].get_int64().get(number) == simdjson::SUCCESS) + state.genesisItems = (uint16_t)number; + if (saved["ItemWeights"].get_array().get(weights) != simdjson::SUCCESS) continue; + for (simdjson::dom::element weight : weights) + { + double value = 0; + if (weight.get_double().get(value) == simdjson::SUCCESS) state.weights.push_back((float)value); + } + } +} + +void custom_pools_delete(std::string_view fileName) +{ + std::error_code error; + std::filesystem::remove(state_path_get(fileName), error); +} diff --git a/src/repentogon/custom_pools.h b/src/repentogon/custom_pools.h new file mode 100644 index 0000000..4ecdfbe --- /dev/null +++ b/src/repentogon/custom_pools.h @@ -0,0 +1,25 @@ +#pragma once + +#include "entity/pickup/item_pool.h" +#include +#include +#include +#include + +void custom_pools_load(); +void custom_pools_fill(const RNG& itemPoolRNG); +ItemPool_Item* custom_pool_get(int id); +int custom_pool_count(); +uint16_t* genesis_items_get(int id); +int pool_id_find(std::string_view name); +std::string_view pool_name_get(int id); +void custom_pools_chaos_add(std::vector>& outcomes, bool isGreed, float scale); +void custom_pools_with_collectible_add(int collectible, std::vector& found); +void custom_pools_collectible_reset(int collectible); +void custom_pools_bible_add(int add); +void custom_pools_store(int slot); +void custom_pools_restore(int slot); +void custom_pools_clear(int slot); +void custom_pools_save(std::string_view fileName, uint32_t checksum); +void custom_pools_read(std::string_view fileName, uint32_t checksum); +void custom_pools_delete(std::string_view fileName); diff --git a/src/repentogon/entities.cpp b/src/repentogon/entities.cpp index 1092b2e..28e0375 100644 --- a/src/repentogon/entities.cpp +++ b/src/repentogon/entities.cpp @@ -3,6 +3,9 @@ #include "entity/npc/npc.h" #include "entity/pickup/pickup.h" #include "entity/player/player.h" +#include "entity/weapon/knife.h" +#include "entity/weapon/laser.h" +#include "entity/weapon/tear.h" #include "game/manager.h" #include "repentogon/callbacks.h" #include @@ -222,6 +225,23 @@ bool is_custom_tagged(Entity& entity, const char* tag) return entity.config && entity.config->customTags.contains(tag); } +// (Patches/EntityPlus.cpp's Entity::Init hook) Drops what mods set on a pooled entity before it starts again as +// another: the shared overrides and its kind's own. +void entity_plus_reset(Entity& entity) +{ + entity.waterClipFlagsOverride.reset(); + entity.flyingOverride.reset(); + if (auto* player = dynamic_cast(&entity)) player->isCamoForced = false; + if (auto* pickup = dynamic_cast(&entity)) pickup->canRerollOverride.reset(); + if (auto* tear = dynamic_cast(&entity)) tear->initSound.reset(); + if (auto* knife = dynamic_cast(&entity)) knife->hitboxSource = nullptr; + if (auto* laser = dynamic_cast(&entity)) + { + laser->initSound.reset(); + laser->isRecalculateSamplesNextUpdate = false; + } +} + // (Patches/FamiliarTags.cpp) Whether a laser hurts a familiar: always with the familiarcantakedamage tag, else as its // deprecated familiarallowlasercollision attribute says, else as the game decides. bool familiar_laser_hit_get(Entity& familiar, bool isHit) diff --git a/src/repentogon/entities.h b/src/repentogon/entities.h index 41a03ff..0326696 100644 --- a/src/repentogon/entities.h +++ b/src/repentogon/entities.h @@ -43,6 +43,10 @@ struct ExtraDamageSource ~ExtraDamageSource(); }; +// Whether an entity stopped existing since the room's last removal pass (Patches/EntityManager.cpp's s_stagedRemove). +inline bool isEntityRemoveStaged = false; + +void entity_plus_reset(Entity& entity); bool is_custom_tagged(int type, int variant, int subtype, const char* tag); bool is_custom_tagged(Entity& entity, const char* tag); bool familiar_laser_hit_get(Entity& familiar, bool isHit); diff --git a/src/repentogon/gl_pipeline.cpp b/src/repentogon/gl_pipeline.cpp new file mode 100644 index 0000000..41b8c95 --- /dev/null +++ b/src/repentogon/gl_pipeline.cpp @@ -0,0 +1,660 @@ +#include "repentogon/gl_pipeline.h" +#include "engine/gl.h" +#include "engine/kage_graphics.h" +#include "engine/platform.h" +#include "lua/callback_run.h" +#include "lua/engine.h" +#include "repentogon/callbacks.h" +#include "repentogon/lua_render.h" +#include +#include + +// REPENTOGON's EnableCustomRendering, off there: MC_PRE_OPENGL_RENDER never runs, as main_ex.lua warns the mods adding +// it. Everything behind it works when it is turned on. +constexpr bool IS_CUSTOM_RENDERING_ENABLED = false; +constexpr const char* OPENGL_RENDER_NAME = "MC_PRE_OPENGL_RENDER"; +constexpr const char* PROJECTION_UNIFORM = "Transform"; +constexpr const char* GLSL_FLOAT_FIELD = "value"; +constexpr const char* GLSL_VECTOR_FIELDS[] = {"x", "y", "z", "w"}; +constexpr int NO_SHADER = -1; +constexpr int SLICE_END = -1; +constexpr int MATRIX_SIZE = 16; +constexpr int MATRIX_SCALE_X = 0; +constexpr int MATRIX_OFFSET_X = 3; +constexpr int MATRIX_SCALE_Y = 5; +constexpr int MATRIX_OFFSET_Y = 7; +constexpr int MATRIX_SCALE_Z = 10; +constexpr int MATRIX_ONE = 15; +constexpr float PROJECTION_DEPTH_SCALE = -0.001f; + +// REPENTOGON's GLSLType (the attribute types, the first four) and the GL value classes scripts read vertices and +// uniforms through: a float, vectors of 2 to 4 floats and square matrices of 2 to 4 rows. +enum GlslType +{ + GLSL_FLOAT, + GLSL_VEC2, + GLSL_VEC3, + GLSL_VEC4, + GLSL_MAT2, + GLSL_MAT3, + GLSL_MAT4, + GLSL_TYPE_COUNT +}; +constexpr const char* GLSL_TYPE_NAMES[] = {"GLFloat", "GLVec2", "GLVec3", "GLVec4", "GLMat2", "GLMat3", "GLMat4"}; +constexpr int GLSL_TYPE_FLOATS[] = {1, 2, 3, 4, 4, 9, 16}; + +// One attribute of a vertex: its name, offset in floats and type. +struct VertexSlot +{ + std::string name; + GlslType type; + int offset; +}; + +// REPENTOGON's VertexDescriptor: the attributes of a vertex in order and its size in floats. +struct VertexDescriptor +{ + std::vector slots; + int size = 0; +}; + +// REPENTOGON's VertexBuffer: vertices in a descriptor's format and the elements drawing them. A draw's own, which +// MC_PRE_OPENGL_RENDER hands out, is valid while the callback runs, its serial the live one. NewPass makes one owning +// both, serial 0. +struct VertexBuffer +{ + std::vector ownedVertices; + std::vector ownedElements; + std::vector* elements = nullptr; + float* vertices = nullptr; + const VertexDescriptor* descriptor = nullptr; + uint32_t serial = 0; + uint32_t vertexCount = 0; +}; + +// A vertex of a buffer, and a buffer's elements (REPENTOGON's Vertex and ElementsArray). Each keeps its buffer alive. +struct Vertex +{ + VertexBuffer* buffer; + float* data; +}; + +struct ElementsArray +{ + VertexBuffer* buffer; +}; + +// A GL value viewing floats of a vertex or of a matrix. +struct GlslValue +{ + VertexBuffer* buffer; + float* data; + GlslType type; +}; + +// REPENTOGON's GL shader: a program and the format of its vertices. Its Renderer.GLShader constructor is not exposed. +struct GlShader +{ + VertexDescriptor descriptor; + unsigned int program = 0; +}; + +// One object drawing as quads were recorded. +struct RenderContextEntry +{ + const void* object; + RenderContextType type; +}; + +using RenderContextQueue = std::vector; + +// MC_PRE_OPENGL_RENDER's Context: the objects drawing at each recording of the batch's quads. +struct RenderContext +{ + std::vector queues; + uint32_t serial = 0; +}; + +template <> inline constexpr LuaClass LUA_CLASS_OF = LUA_CLASS_ELEMENTS_ARRAY; +template <> inline constexpr LuaClass LUA_CLASS_OF = LUA_CLASS_GL_SHADER; +template <> inline constexpr LuaClass LUA_CLASS_OF = LUA_CLASS_RENDER_CONTEXT; +template <> inline constexpr LuaClass LUA_CLASS_OF = LUA_CLASS_VERTEX; +template <> inline constexpr LuaClass LUA_CLASS_OF = LUA_CLASS_VERTEX_BUFFER; +template <> inline constexpr LuaClass LUA_CLASS_OF = LUA_CLASS_VERTEX_DESCRIPTOR; + +static RenderContextQueue renderQueue; +static std::unordered_map batchContexts; +static uint32_t liveSerial = 0; +static uint32_t lastSerial = 0; + +// Whether MC_PRE_OPENGL_RENDER runs, which is also what records draws' contexts: a mod listening, with REPENTOGON's +// custom rendering on. +static bool is_opengl_render_hooked() +{ + return IS_CUSTOM_RENDERING_ENABLED && g_luaEngine && lua_engine_get().is_callback_enabled(MC_PRE_OPENGL_RENDER); +} + +RenderContextScope::RenderContextScope(RenderContextType type, const void* object) : isPushed(is_opengl_render_hooked()) +{ + if (isPushed) renderQueue.push_back({object, type}); +} + +RenderContextScope::~RenderContextScope() +{ + if (isPushed && !renderQueue.empty()) renderQueue.pop_back(); +} + +// (GraphicsBufferObject::Allocate hook) Records what is drawing as quads go into a batch. +void render_context_record(const KAGE::Graphics::RenderBatch& batch) +{ + if (is_opengl_render_hooked()) batchContexts[&batch].queues.push_back(renderQueue); +} + +// An error once a draw's buffer outlived its callback. +static void buffer_check(lua_State* state, const VertexBuffer* buffer) +{ + if (buffer && buffer->serial && buffer->serial != liveSerial) + luaL_error(state, "**VertexBuffer is no longer valid"); +} + +static void descriptor_attribute_add(VertexDescriptor& descriptor, GlslType type, std::string name) +{ + descriptor.slots.push_back({std::move(name), type, descriptor.size}); + descriptor.size += GLSL_TYPE_FLOATS[type]; +} + +// The format of a game shader's vertices, as REPENTOGON's descriptors of each ShaderType give it. +static VertexDescriptor shader_descriptor_get(const KAGE::Graphics::Shader& shader) +{ + VertexDescriptor descriptor; + for (const KAGE::Graphics::VertexAttribute& attribute : shader.attributes) + descriptor_attribute_add(descriptor, (GlslType)(KAGE::Graphics::components_get(attribute.format) - 1), + attribute.name); + return descriptor; +} + +// The ShaderType of a game shader, NO_SHADER for another. +static int shader_type_find(const KAGE::Graphics::Shader& shader) +{ + for (int type = 0; type < SHADER_TYPE_COUNT; type++) + if (KAGE::Graphics::manager.shader_find(SHADER_TYPE_NAMES[type]) == &shader) return type; + return NO_SHADER; +} + +// VertexBuffer::Bind: points a program's attributes of the buffer's names into its vertices, keeping their locations. +static void buffer_bind(const VertexBuffer& buffer, unsigned int program, std::vector& locations) +{ + int stride = buffer.descriptor->size * (int)sizeof(float); + for (const VertexSlot& slot : buffer.descriptor->slots) + { + int location = gl.GetAttribLocation(program, slot.name.c_str()); + if (location < 0) continue; + + gl.EnableVertexAttribArray(location); + gl.VertexAttribPointer(location, GLSL_TYPE_FLOATS[slot.type], GL_FLOAT, GL_FALSE, stride, + buffer.vertices + slot.offset); + locations.push_back(location); + } +} + +// REPENTOGON's ProjectionMatrix: the orthographic view, row major. +static std::array projection_get() +{ + std::array matrix = {}; + matrix[MATRIX_SCALE_X] = 2 / KAGE::Graphics::manager.orthographicWidth; + matrix[MATRIX_SCALE_Y] = 2 / KAGE::Graphics::manager.orthographicHeight; + matrix[MATRIX_SCALE_Z] = PROJECTION_DEPTH_SCALE; + matrix[MATRIX_OFFSET_X] = -1; + matrix[MATRIX_OFFSET_Y] = -1; + matrix[MATRIX_ONE] = 1; + return matrix; +} + +// What MC_PRE_OPENGL_RENDER's result on top draws with: a ShaderType or a GLShader, bound to the buffer, else the +// batch's own shader (nil, -1, or a Pipeline, whose Render draws nothing yet). The program it switched to, else 0. +static unsigned int render_result_apply(lua_State* state, const VertexBuffer& buffer, std::vector& locations) +{ + GlShader* glShader = (GlShader*)lua_object_test(state, -1, LUA_CLASS_GL_SHADER); + unsigned int program = glShader ? glShader->program : 0; + if (lua_type(state, -1) == LUA_TNUMBER) + { + lua_Integer type = lua_tointeger(state, -1); + KAGE::Graphics::Shader* shader = type >= 0 && type < SHADER_TYPE_COUNT ? + KAGE::Graphics::manager.shader_find(SHADER_TYPE_NAMES[type]) : nullptr; + if (shader) program = shader->program; + else if (type != NO_SHADER) + log_printf(LOG_ERROR, "[FATAL] Invalid shader ID %d (neither a native shader, nor a registered shader)\n", + (int)type); + } + else if (!glShader && !lua_isnil(state, -1) && !lua_object_test(state, -1, LUA_CLASS_PIPELINE)) + log_printf(LOG_ERROR, "[ERROR] Invalid return value for MC_PRE_OPENGL_RENDER\n"); + if (!program) return 0; + + gl.UseProgram(program); + if (glShader) + gl.UniformMatrix4fv(gl.GetUniformLocation(program, PROJECTION_UNIFORM), 1, GL_TRUE, projection_get().data()); + buffer_bind(buffer, program, locations); + return program; +} + +// (LuaPreDrawElements) Draws a batch drawing into a render target through MC_PRE_OPENGL_RENDER, with its vertices, +// ShaderType (-1 for another) and context, its elements as the callback left them. Whether it drew it, false when no +// mod listens. +bool opengl_render_hook(KAGE::Graphics::RenderBatch& batch, int vertexCount) +{ + RenderContext context; + auto found = batchContexts.find(&batch); + if (found != batchContexts.end()) + { + context.queues = std::move(found->second.queues); + batchContexts.erase(found); + } + if (!KAGE::Graphics::manager.renderTarget || !is_opengl_render_hooked()) return false; + + std::span indices = KAGE::Graphics::manager.quad_indices_get(vertexCount); + std::vector elements(indices.begin(), indices.end()); + VertexDescriptor descriptor = shader_descriptor_get(*batch.shader); + liveSerial = context.serial = ++lastSerial; + VertexBuffer buffer = {.elements = &elements, + .vertices = batch.vertices.data(), + .descriptor = &descriptor, + .serial = liveSerial, + .vertexCount = (uint32_t)vertexCount}; + int shaderType = shader_type_find(*batch.shader); + + LuaEngine& engine = lua_engine_get(); + CallbackRun run = {OPENGL_RENDER_NAME, MC_PRE_OPENGL_RENDER}; + bool isRun = context.queues.empty() ? callback_run(engine, run, buffer, shaderType, (RenderContext*)nullptr) : + callback_run(engine, run, buffer, shaderType, context); + std::vector locations; + unsigned int program = 0; + if (isRun) + { + program = render_result_apply(engine.state, buffer, locations); + lua_pop(engine.state, 1); + } + liveSerial = 0; + + gl.DrawElements(GL_TRIANGLES, (int)elements.size(), GL_UNSIGNED_INT, elements.data()); + for (int location : locations) gl.DisableVertexAttribArray(location); + if (program) gl.UseProgram(batch.shader->program); + return true; +} + +// Pushes a GL value whose floats belong to the userdata at anchor, which it keeps alive. +static void glsl_value_push(lua_State* state, GlslValue value, int anchor) +{ + anchor = lua_absindex(state, anchor); + *(GlslValue*)lua_newuserdata(state, sizeof(GlslValue)) = value; + luaL_setmetatable(state, GLSL_TYPE_NAMES[value.type]); + lua_pushvalue(state, anchor); + lua_setuservalue(state, -2); +} + +// The GL value of the class name at index, an error for another or one whose vertices are gone. +static GlslValue& glsl_value_check(lua_State* state, int index, const char* name) +{ + GlslValue& value = *(GlslValue*)luaL_checkudata(state, index, name); + buffer_check(state, value.buffer); + return value; +} + +static bool is_glsl_matrix(GlslType type) +{ + return type >= GLSL_MAT2; +} + +// The float key 2 names in a float or vector, an error for none. +static float* glsl_field_get(lua_State* state, GlslValue& value) +{ + if (!lua_isstring(state, 2)) luaL_error(state, "Invalid type for field access"); + + std::string_view key = lua_tostring(state, 2); + if (value.type == GLSL_FLOAT && key == GLSL_FLOAT_FIELD) return value.data; + for (int field = 0; value.type != GLSL_FLOAT && field < GLSL_TYPE_FLOATS[value.type]; field++) + if (key == GLSL_VECTOR_FIELDS[field]) return value.data + field; + luaL_error(state, "Invalid field name"); + return nullptr; +} + +// The row key 2 names in a matrix, an error for none. +static GlslValue glsl_row_get(lua_State* state, const GlslValue& matrix) +{ + if (!lua_isinteger(state, 2)) luaL_error(state, "Invalid type for row access"); + + GlslType rowType = (GlslType)(GLSL_VEC2 + matrix.type - GLSL_MAT2); + int rowFloats = GLSL_TYPE_FLOATS[rowType]; + lua_Integer row = lua_tointeger(state, 2); + if (row < 0 || row >= rowFloats) luaL_error(state, "Invalid row index %d", (int)row); + return {matrix.buffer, matrix.data + row * rowFloats, rowType}; +} + +// Copies the GL value argument 3 holds, of value's type, into value's floats. +static void glsl_value_assign(lua_State* state, const GlslValue& value) +{ + GlslValue& source = glsl_value_check(state, 3, GLSL_TYPE_NAMES[value.type]); + std::copy_n(source.data, GLSL_TYPE_FLOATS[value.type], value.data); +} + +// The GL values' __index and __newindex: a float's value, a vector's x to w, a matrix's rows from 0. +static int glsl_value_index(lua_State* state) +{ + GlslValue& value = *(GlslValue*)lua_touserdata(state, 1); + buffer_check(state, value.buffer); + if (is_glsl_matrix(value.type)) glsl_value_push(state, glsl_row_get(state, value), 1); + else lua_pushnumber(state, *glsl_field_get(state, value)); + return 1; +} + +static int glsl_value_new_index(lua_State* state) +{ + GlslValue& value = *(GlslValue*)lua_touserdata(state, 1); + buffer_check(state, value.buffer); + if (is_glsl_matrix(value.type)) return glsl_value_assign(state, glsl_row_get(state, value)), 0; + if (!lua_isnumber(state, 3)) luaL_error(state, "Invalid type of assignment"); + *glsl_field_get(state, value) = (float)lua_tonumber(state, 3); + return 0; +} + +// GLShader's BindFloat to BindMat4: sets one of its uniforms to a GL value of the type. +template +static int shader_uniform_bind(lua_State* state) +{ + GlShader& shader = lua_get(state, 1); + const char* name = luaL_checkstring(state, 2); + GlslValue& value = glsl_value_check(state, 3, GLSL_TYPE_NAMES[Type]); + int location = gl.GetUniformLocation(shader.program, name); + if (location == -1) return luaL_error(state, "Invalid uniform name %s for shader program %d", name, shader.program); + + int previous = 0; + gl.GetIntegerv(GL_CURRENT_PROGRAM, &previous); + gl.UseProgram(shader.program); + switch (Type) + { + case GLSL_FLOAT: gl.Uniform1fv(location, 1, value.data); break; + case GLSL_VEC2: gl.Uniform2fv(location, 1, value.data); break; + case GLSL_VEC3: gl.Uniform3fv(location, 1, value.data); break; + case GLSL_VEC4: gl.Uniform4fv(location, 1, value.data); break; + case GLSL_MAT2: gl.UniformMatrix2fv(location, 1, GL_TRUE, value.data); break; + case GLSL_MAT3: gl.UniformMatrix3fv(location, 1, GL_TRUE, value.data); break; + default: gl.UniformMatrix4fv(location, 1, GL_TRUE, value.data); + } + gl.UseProgram(previous); + return 0; +} + +// Pushes an object of a buffer that keeps the buffer argument 1 holds alive. +template +static int buffer_part_push(lua_State* state, const T& part) +{ + lua_push(state, part); + lua_pushvalue(state, 1); + lua_setuservalue(state, -2); + return 1; +} + +// The slot of the vertex attribute key 2 names, null for none. +static const VertexSlot* vertex_slot_find(lua_State* state, const Vertex& vertex) +{ + const char* name = luaL_checkstring(state, 2); + for (const VertexSlot& slot : vertex.buffer->descriptor->slots) + if (slot.name == name) return &slot; + return nullptr; +} + +// The vertex argument 1 holds, an error once its buffer is gone. +static Vertex& vertex_check(lua_State* state) +{ + Vertex& vertex = lua_get(state, 1); + buffer_check(state, vertex.buffer); + return vertex; +} + +// Vertex's __index: an attribute as a GL value, else a method. +static int vertex_index(lua_State* state) +{ + Vertex& vertex = vertex_check(state); + if (const VertexSlot* slot = vertex_slot_find(state, vertex)) + return glsl_value_push(state, {vertex.buffer, vertex.data + slot->offset, slot->type}, 1), 1; + + lua_getmetatable(state, 1); + lua_pushvalue(state, 2); + if (lua_rawget(state, -2) == LUA_TNIL) + luaL_error(state, "No field or method with name %s\n", lua_tostring(state, 2)); + return 1; +} + +// Vertex's __newindex: an attribute set to a GL value of its type. +static int vertex_new_index(lua_State* state) +{ + Vertex& vertex = vertex_check(state); + const VertexSlot* slot = vertex_slot_find(state, vertex); + if (!slot) luaL_error(state, "Invalid attribute name %s", lua_tostring(state, 2)); + glsl_value_assign(state, {vertex.buffer, vertex.data + slot->offset, slot->type}); + return 0; +} + +// Vertex's Dump: each attribute's Offset and Type by name. +static int vertex_dump(lua_State* state) +{ + lua_newtable(state); + for (const VertexSlot& slot : vertex_check(state).buffer->descriptor->slots) + { + lua_newtable(state); + lua_pushinteger(state, slot.offset); + lua_setfield(state, -2, "Offset"); + lua_pushinteger(state, slot.type); + lua_setfield(state, -2, "Type"); + lua_setfield(state, -2, slot.name.c_str()); + } + return 1; +} + +// The element key 2 indexes from 0, an error past the last or once the buffer is gone. +static uint32_t& element_get(lua_State* state, ElementsArray& elements) +{ + buffer_check(state, elements.buffer); + std::vector& values = *elements.buffer->elements; + lua_Integer index = luaL_checkinteger(state, 2); + if (index < 0 || index >= (lua_Integer)values.size()) + luaL_error(state, "Invalid index %d, max: %d", (int)index, (int)values.size() - 1); + return values[index]; +} + +static int elements_index(lua_State* state) +{ + lua_pushinteger(state, element_get(state, lua_get(state, 1))); + return 1; +} + +// ElementsArray's __newindex: an element set to a vertex of the buffer. +static int elements_new_index(lua_State* state) +{ + ElementsArray& elements = lua_get(state, 1); + uint32_t& element = element_get(state, elements); + lua_Integer value = luaL_checkinteger(state, 3); + int last = (int)elements.buffer->vertexCount - 1; + if (value < 0 || value > last) + luaL_error(state, "Invalid value %d for index %d, max: %d", (int)value, (int)lua_tointeger(state, 2), last); + element = (uint32_t)value; + return 0; +} + +static int elements_length(lua_State* state) +{ + ElementsArray& elements = lua_get(state, 1); + buffer_check(state, elements.buffer); + lua_pushinteger(state, (lua_Integer)elements.buffer->elements->size()); + return 1; +} + +// VertexBuffer's GetVertex: a vertex by index from 0. +static int buffer_vertex_get(lua_State* state) +{ + VertexBuffer& buffer = lua_get(state, 1); + buffer_check(state, &buffer); + lua_Integer index = luaL_checkinteger(state, 2); + if (index < 0 || index >= buffer.vertexCount) + luaL_error(state, "Invalid index %d in vertex buffer (max %d)", (int)index, (int)buffer.vertexCount - 1); + return buffer_part_push(state, Vertex{&buffer, buffer.vertices + index * buffer.descriptor->size}); +} + +static int buffer_elements_get(lua_State* state) +{ + return buffer_part_push(state, ElementsArray{&lua_get(state, 1)}); +} + +static int buffer_length(lua_State* state) +{ + lua_pushinteger(state, lua_get(state, 1).vertexCount); + return 1; +} + +// VertexDescriptor's AddAttribute: an attribute of a GLSLType and a name after the others. +static int descriptor_attribute_add_lua(lua_State* state) +{ + VertexDescriptor& descriptor = lua_get(state, 1); + lua_Integer type = luaL_checkinteger(state, 2); + if (type < GLSL_FLOAT || type > GLSL_VEC4) return luaL_error(state, "Invalid attribute type %d", (int)type); + descriptor_attribute_add(descriptor, (GlslType)type, luaL_checkstring(state, 3)); + return 0; +} + +// Pipeline's NewPass: a vertex buffer of its own in a shader's format, with its count of vertices and elements. +// REPENTOGON's Render draws no pass yet, so the pipeline keeps none. +static int pipeline_pass_new(lua_State* state) +{ + lua_object_check(state, 1, LUA_CLASS_PIPELINE); + lua_Integer vertexCount = luaL_checkinteger(state, 2); + GlShader& shader = lua_get(state, 3); + lua_Integer elementCount = luaL_checkinteger(state, 4); + luaL_argcheck(state, vertexCount >= 0, 2, "negative vertex count"); + luaL_argcheck(state, elementCount >= 0, 4, "negative element count"); + + lua_push(state, VertexBuffer{}); + VertexBuffer& buffer = lua_get(state, -1); + buffer.ownedVertices.resize(vertexCount * shader.descriptor.size); + buffer.ownedElements.resize(elementCount); + buffer.vertices = buffer.ownedVertices.data(); + buffer.elements = &buffer.ownedElements; + buffer.descriptor = &shader.descriptor; + buffer.vertexCount = (uint32_t)vertexCount; + return 1; +} + +// RenderSet's SliceSingle: checks a buffer, a shader and a range of it, which REPENTOGON slices into nothing yet. +static int render_set_slice(lua_State* state) +{ + lua_get(state, 1); + lua_get(state, 2); + luaL_checkinteger(state, 3); + lua_Integer first = luaL_checkinteger(state, 4); + lua_Integer last = luaL_optinteger(state, 5, SLICE_END); + if (last != SLICE_END && last < first) return luaL_error(state, "Invalid slice range %d:%d", (int)first, (int)last); + return 0; +} + +// Context's iterator: the objects drawing at the recording after the control index (from 0), as tables of their Type +// and Data, nil past the last. +static int context_next(lua_State* state) +{ + RenderContext& context = lua_get(state, 1); + if (context.serial != liveSerial) luaL_error(state, "**Context is no longer valid"); + + lua_Integer index = lua_isnil(state, 2) ? 0 : luaL_checkinteger(state, 2) + 1; + if (index < 0 || index >= (lua_Integer)context.queues.size()) + { + lua_pushnil(state); + lua_pushnil(state); + return 2; + } + + lua_pushinteger(state, index); + lua_newtable(state); + int position = 1; + for (const RenderContextEntry& entry : context.queues[index]) + { + lua_newtable(state); + lua_pushinteger(state, entry.type); + lua_setfield(state, -2, "Type"); + switch (entry.type) + { + case RENDER_CONTEXT_NPC: lua_push(state, (Entity_NPC*)entry.object); break; + case RENDER_CONTEXT_PLAYER: lua_push(state, (Entity_Player*)entry.object); break; + case RENDER_CONTEXT_ROCK: lua_push(state, (GridEntity_Rock*)entry.object); break; + case RENDER_CONTEXT_ANIMATION_STATE: lua_push(state, (ANM2*)entry.object); break; + default: lua_pushinteger(state, ((const AnimationLayer*)entry.object)->layerId); + } + lua_setfield(state, -2, "Data"); + lua_rawseti(state, -2, position++); + } + return 2; +} + +static int context_pairs(lua_State* state) +{ + lua_get(state, 1); + lua_pushcfunction(state, context_next); + lua_pushvalue(state, 1); + lua_pushnil(state); + return 3; +} + +// (LuaRender.cpp) REPENTOGON's render pipeline classes: GL values, vertices and their buffers, shaders, pipelines and +// render sets, and the context MC_PRE_OPENGL_RENDER passes. Their constructors (Renderer.GLShader, Pipeline, +// RenderSet, Vec2 and the rest) stay unexposed, as REPENTOGON leaves them. +void gl_pipeline_register(lua_State* state) +{ + for (const char* name : GLSL_TYPE_NAMES) + { + luaL_newmetatable(state, name); + lua_pushcfunction(state, glsl_value_index); + lua_setfield(state, -2, "__index"); + lua_pushcfunction(state, glsl_value_new_index); + lua_setfield(state, -2, "__newindex"); + lua_pop(state, 1); + } + + lua_class_begin(state, "Vertex", LUA_CLASS_VERTEX); + lua_functions_add(state, {{"__index", vertex_index}, {"__newindex", vertex_new_index}, {"Dump", vertex_dump}}); + lua_class_hidden_end(state); + + lua_class_begin(state, "ElementsArray", LUA_CLASS_ELEMENTS_ARRAY); + lua_functions_add(state, + {{"__index", elements_index}, {"__newindex", elements_new_index}, {"__len", elements_length}}); + lua_class_hidden_end(state); + + lua_class_begin(state, "VertexDescriptor", LUA_CLASS_VERTEX_DESCRIPTOR); + lua_functions_add(state, {{"AddAttribute", descriptor_attribute_add_lua}}); + lua_class_hidden_end(state); + + lua_class_begin(state, "GLShader", LUA_CLASS_GL_SHADER); + lua_functions_add(state, {{"BindFloat", shader_uniform_bind}, + {"BindVec2", shader_uniform_bind}, + {"BindVec3", shader_uniform_bind}, + {"BindVec4", shader_uniform_bind}, + {"BindMat2", shader_uniform_bind}, + {"BindMat3", shader_uniform_bind}, + {"BindMat4", shader_uniform_bind}}); + lua_class_hidden_end(state); + + lua_class_begin(state, "Pipeline", LUA_CLASS_PIPELINE); + lua_functions_add(state, {{"NewPass", pipeline_pass_new}}); + lua_class_hidden_end(state); + + lua_class_begin(state, "RenderSet", LUA_CLASS_RENDER_SET); + lua_functions_add(state, {{"SliceSingle", render_set_slice}, {"SlicePipeline", [](lua_State*) { return 0; }}}); + lua_class_hidden_end(state); + + lua_class_begin(state, "VertexBuffer", LUA_CLASS_VERTEX_BUFFER); + lua_gc_set(state); + lua_functions_add(state, {{"GetVertex", buffer_vertex_get}, + {"GetElements", buffer_elements_get}, + {"__len", buffer_length}}); + lua_class_hidden_end(state); + + lua_class_begin(state, "Context", LUA_CLASS_RENDER_CONTEXT); + lua_gc_set(state); + lua_functions_add(state, {{"__pairs", context_pairs}}); + lua_class_hidden_end(state); +} diff --git a/src/repentogon/gl_pipeline.h b/src/repentogon/gl_pipeline.h new file mode 100644 index 0000000..da54155 --- /dev/null +++ b/src/repentogon/gl_pipeline.h @@ -0,0 +1,32 @@ +#pragma once + +struct lua_State; + +namespace KAGE::Graphics +{ +class RenderBatch; +} + +// What is drawing while quads are recorded, as MC_PRE_OPENGL_RENDER's context names it (REPENTOGON's ContextType). +enum RenderContextType +{ + RENDER_CONTEXT_NPC = 5, + RENDER_CONTEXT_PLAYER = 7, + RENDER_CONTEXT_ROCK = 11, + RENDER_CONTEXT_ANIMATION_STATE = 12, + RENDER_CONTEXT_ANIMATION_LAYER = 13 +}; + +// REPENTOGON's ScopedContext: names an object as drawing until the scope ends, while a mod listens to +// MC_PRE_OPENGL_RENDER. +struct RenderContextScope +{ + bool isPushed; + + RenderContextScope(RenderContextType type, const void* object); + ~RenderContextScope(); +}; + +void render_context_record(const KAGE::Graphics::RenderBatch& batch); +bool opengl_render_hook(KAGE::Graphics::RenderBatch& batch, int vertexCount); +void gl_pipeline_register(lua_State* state); diff --git a/src/repentogon/item_spoof.cpp b/src/repentogon/item_spoof.cpp index 70040e2..2cdf57a 100644 --- a/src/repentogon/item_spoof.cpp +++ b/src/repentogon/item_spoof.cpp @@ -1,10 +1,14 @@ #include "repentogon/item_spoof.h" #include "entity/player/player.h" +#include "game/game.h" #include "game/manager.h" #include "repentogon/api.h" #include "repentogon/callbacks.h" #include "repentogon/items.h" +#include "repentogon/repentogon.h" +#include "ui/console.h" #include +#include #include // What the next spoofed call was asked from (ItemSpoofCallContext): from Lua, which sees reworked items, and whether @@ -17,7 +21,19 @@ struct SpoofContext static SpoofContext spoofContext; static bool isSpoofInner = false; -static std::set reworkedBirthrights; +// The ids reworked of each kind: collectibles, characters' Birthrights and trinkets. +enum ReworkKind +{ + REWORK_COLLECTIBLE, + REWORK_BIRTHRIGHT, + REWORK_TRINKET, + REWORK_COUNT +}; + +constexpr int VANILLA_COLLECTIBLE_COUNT = 733; +constexpr int VANILLA_TRINKET_COUNT = 190; + +static std::array, REWORK_COUNT> reworked; static ItemSpoof& spoof_get(Entity_Player& player, SpoofKind kind) { @@ -299,9 +315,11 @@ static void block_set(Entity_Player& player, SpoofKind kind, int id, bool isBloc player.EvaluateItems(); } +// IsReworkedCollectible: a reworked collectible, or Birthright reworked for the character. static bool is_reworked(int id, int playerType) { - return id == COLLECTIBLE_BIRTHRIGHT && reworkedBirthrights.contains(playerType); + if (id == COLLECTIBLE_BIRTHRIGHT) return reworked[REWORK_BIRTHRIGHT].contains(playerType); + return reworked[REWORK_COLLECTIBLE].contains(id); } // (ItemSpoofSystem.cpp) HasCollectible's spoofs: a reworked Birthright is missing outside Lua, then a blocked @@ -340,6 +358,7 @@ std::optional collectible_spoof_count(Entity_Player& player, int id, bool i std::optional trinket_spoof_has(Entity_Player& player, uint32_t id, bool isOwnedOnly) { SpoofContext context = context_take(); + if (!context.isLuaRequest && reworked[REWORK_TRINKET].contains((int)id)) return false; if (isOwnedOnly || context.isIgnoreSpoof) return std::nullopt; ItemSpoof& spoof = player.itemSpoofs.trinkets; @@ -355,6 +374,7 @@ std::optional trinket_spoof_multiplier(Entity_Player& player, uint32_t id) { if (std::exchange(isSpoofInner, false)) return std::nullopt; SpoofContext context = context_take(); + if (!context.isLuaRequest && reworked[REWORK_TRINKET].contains((int)id)) return 0; if (context.isIgnoreSpoof) return std::nullopt; ItemSpoof& spoof = player.itemSpoofs.trinkets; @@ -374,6 +394,7 @@ std::optional trinket_spoof_multiplier(Entity_Player& player, uint32_t id) std::optional golden_trinket_spoof_has(Entity_Player& player, uint32_t id) { SpoofContext context = context_take(); + if (!context.isLuaRequest && reworked[REWORK_TRINKET].contains((int)id)) return false; if (context.isIgnoreSpoof) return std::nullopt; ItemSpoof& spoof = player.itemSpoofs.trinkets; @@ -599,10 +620,33 @@ void item_spoof_api_register(lua_State* state) {"GetSpoofedCollectiblesList", spoofed_list_get_lua}}); } -// (LuaIsaac.cpp) Isaac.ReworkBirthright: a character's Birthright stops counting outside Lua, for a mod to redo. +// (LuaIsaac.cpp) Isaac.ReworkCollectible, ReworkBirthright and ReworkTrinket: a game item (or a character's +// Birthright) stops counting outside Lua, for a mod to redo. Only while the mods load, a warning after. +template +static int rework_lua(lua_State* state) +{ + constexpr std::array LIMITS = {VANILLA_COLLECTIBLE_COUNT, PLAYER_TYPE_COUNT, VANILLA_TRINKET_COUNT}; + constexpr std::array NAMES = {"Collectible", "Birthright", "Trinket"}; + constexpr std::array TYPES = {"CollectibleType", "PlayerType", "TrinketType"}; + int id = (int)luaL_checkinteger(state, 1); + if (id < (Kind == REWORK_BIRTHRIGHT ? 0 : 1) || id >= LIMITS[Kind]) + return luaL_argerror(state, 1, (std::string("invalid ") + TYPES[Kind]).c_str()); + if (reworked[Kind].contains(id)) return 0; + if (isModsLoaded) + { + if (g_game) + g_game->console.Print(std::string("[WARN] Rework") + NAMES[Kind] + + "() ignored: Reworks can only be set during startup.\n", + CONSOLE_WARNING, CONSOLE_FADE_FRAMES); + return 0; + } + reworked[Kind].insert(id); + return 0; +} + void item_spoof_isaac_register(lua_State* state) { - lua_method(state, "ReworkBirthright", [](int playerType) { - if (playerType >= 0 && playerType < PLAYER_TYPE_COUNT) reworkedBirthrights.insert(playerType); - }); + lua_functions_add(state, {{"ReworkCollectible", rework_lua}, + {"ReworkBirthright", rework_lua}, + {"ReworkTrinket", rework_lua}}); } diff --git a/src/repentogon/level.cpp b/src/repentogon/level.cpp index 57f599f..718ef64 100644 --- a/src/repentogon/level.cpp +++ b/src/repentogon/level.cpp @@ -2,6 +2,7 @@ #include "classes.h" #include "engine/platform.h" #include "game/game.h" +#include "game/manager.h" #include "level/generator.h" #include "level/grid/grid_entity.h" #include "level/level.h" @@ -11,6 +12,7 @@ #include "repentogon/callbacks.h" #include #include +#include constexpr int LEVEL_STAGE_LAST = 14; constexpr int GREED_STAGE_LAST = 7; @@ -338,3 +340,144 @@ RoomConfig_Room* deal_room_get(uint32_t seed, WeightReduction reduction, RoomQue if (room && reduction == WEIGHT_REDUCE) room->weight = std::max(DEAL_WEIGHT_MIN, room->weight * DEAL_WEIGHT_SCALE); return room; } + +// The stages the Void's rooms come from (ASMLevel.cpp's generateLevels), chosen as the Void generates. +constexpr int STAGE_ID_COUNT = STAGE_ID_BACKWARDS + 1; +static std::bitset voidStages; +// The achievement unlocking each stage's floor (stageidToAchievement), -1 for always open. The Void's own rooms are. +constexpr std::array STAGE_ACHIEVEMENTS = { + -1, -1, 86, 342, -1, 87, 343, -1, 88, 344, 4, 4, 345, 234, 32, 32, 78, 57, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 407, 412, 407, 413, 407, 414, 411, -1, 415}; +// A void_ex room of no stage of its own looks like a Repentance floor a third of the time with BetterVoidGeneration, +// else like a chapter floor, its decoration seed picking. +constexpr uint32_t VOID_EX_SHIFT = 7; +constexpr uint32_t VOID_EX_ALT_CHANCE = 3; +constexpr int VOID_DIFFICULTY_MAX = 20; + +// (IsFloorUnlocked) Whether a stage's floor is unlocked: never the Greed stages or the Ascent's. +static bool is_floor_unlocked(int stageId) +{ + if ((stageId >= STAGE_ID_GREED_SPECIAL && stageId <= STAGE_ID_ULTRA_GREED) || stageId >= STAGE_ID_BACKWARDS) + return false; + int achievement = STAGE_ACHIEVEMENTS[stageId]; + return achievement == -1 || g_manager->persistentGameData.Unlocked(achievement); +} + +// (ASMLevel.cpp's Level::generate_dungeon hook, parity off) The stages the Void draws from: the chapters but the Blue +// Womb, and its own rooms (26.The Void_ex), or with BetterVoidGeneration every unlocked floor but Greed's, Mortis and +// Home. Their rooms' weights start over. +void void_stages_select(RoomConfig& config) +{ + if (repentogonOptions.isVanillaParity) return; + + voidStages.reset(); + for (int id = STAGE_ID_BASEMENT; id < STAGE_ID_COUNT; id++) + { + bool isGreed = id >= STAGE_ID_GREED_SPECIAL && id <= STAGE_ID_ULTRA_GREED; + bool isSkipped = repentogonOptions.isBetterVoidGeneration + ? isGreed || id == STAGE_ID_MORTIS || id == STAGE_ID_HOME || !is_floor_unlocked(id) + : (id > STAGE_ID_CHEST && id != STAGE_ID_VOID) || id == STAGE_ID_BLUE_WOMB; + if (isSkipped) continue; + voidStages.set(id); + config.ResetRoomWeights(id, ROOM_MODE_CURRENT); + } +} + +// (VoidGenerationOverride, parity off) The rooms a Void draw picks from, outside Death Certificate's floor: each chosen +// stage's, the Void's own of any subtype for a draw of none, those standing for a chosen stage or none. Whether it +// gave them. +bool void_rooms_get(RoomConfig& config, const RoomQuery& query, std::vector& rooms) +{ + if (repentogonOptions.isVanillaParity || g_game->currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE) return false; + + bool isAnySubtype = query.subtype <= 0; + for (int id = STAGE_ID_BASEMENT; id < STAGE_ID_COUNT; id++) + { + if (id != STAGE_ID_VOID && !voidStages.test(id)) continue; + RoomQuery stage = query; + stage.stageId = id; + stage.maxDifficulty = VOID_DIFFICULTY_MAX; + if (id == STAGE_ID_VOID && isAnySubtype) stage.subtype = -1; + + std::vector found = config.GetRooms(stage); + if (id != STAGE_ID_VOID || !isAnySubtype) + { + rooms.insert(rooms.begin(), found.begin(), found.end()); + continue; + } + for (RoomConfig_Room* room : found) + { + bool isChosen = room->subtype > 0 && room->subtype < STAGE_ID_COUNT && voidStages.test(room->subtype); + if (room->subtype == 0 || room->subtype == STAGE_ID_VOID || isChosen) rooms.push_back(room); + } + } + return true; +} + +// (GetVoidExRoomStageId, parity off) The stage a room of the Void's own (26.The Void_ex) looks and plays as: the stage +// its subtype names, else one its decoration seed picks. Any other room's layout stage as it is. +int void_ex_stage_get(const RoomDescriptor& descriptor) +{ + int stageId = descriptor.data->stageId; + if (repentogonOptions.isVanillaParity || stageId != STAGE_ID_VOID) return stageId; + + int subtype = descriptor.data->subtype; + bool isChapter = subtype >= STAGE_ID_BASEMENT && subtype <= STAGE_ID_CHEST; + if (isChapter || (subtype >= STAGE_ID_DOWNPOUR && subtype <= STAGE_ID_HOME)) return subtype; + + RNG rng; + rng.SetSeed(descriptor.decorationSeed, VOID_EX_SHIFT); + if (repentogonOptions.isBetterVoidGeneration && rng.RandomInt(VOID_EX_ALT_CHANCE) == 0) + { + int id = STAGE_ID_DOWNPOUR + (int)rng.RandomInt(1 + STAGE_ID_CORPSE - STAGE_ID_DOWNPOUR); + if (is_floor_unlocked(id)) return id; + } + return (int)rng.RandomInt(STAGE_ID_CHEST) + 1; +} + +// The stage the current room's layout plays as when it is a void_ex room, none otherwise (ASMLevel.cpp's +// Level::GetStageID hook). +std::optional void_ex_room_stage_get() +{ + Room* room = g_game ? g_game->room.get() : nullptr; + bool isVoidEx = room && room->descriptor && room->descriptor->data && room->descriptor->data->stageId == STAGE_ID_VOID; + if (repentogonOptions.isVanillaParity || !isVoidEx) return std::nullopt; + return void_ex_stage_get(*room->descriptor); +} + +// (PortalsVoidExTrampoline1 and 2, parity off) The floor and floor type a Portal summons for. In the Void, a room of +// an alternate or Repentance layout stage counts as that floor (the Downpour's and Dross's by their type, the Chest +// as the Cathedral, Home as the Basement). Elsewhere the Blue Womb counts as the Womb, the Dark Room and Chest as +// Sheol or the Cathedral, Home as the Basement. +void portal_stage_override(int& stage, int& stageType) +{ + if (repentogonOptions.isVanillaParity) return; + + if (stage != STAGE_VOID) + { + if (stage == STAGE_BLUE_WOMB) stage = STAGE_WOMB_I; + else if (stage == STAGE_DARK_ROOM) stage = STAGE_SHEOL; + else if (stage >= STAGE_HOME) stageType = STAGETYPE_ORIGINAL; + if (stage >= STAGE_HOME) stage = STAGE_BASEMENT_I; + return; + } + + int layout = g_game->room->GetRoomConfigStage(); + if (layout == STAGE_ID_DOWNPOUR) stageType = STAGETYPE_REPENTANCE; + else if (layout == STAGE_ID_DROSS) stageType = STAGETYPE_REPENTANCE_B; + else if (layout == STAGE_ID_MINES || layout == STAGE_ID_ASHPIT) stage = STAGE_CAVES_I; + else if (layout == STAGE_ID_MAUSOLEUM || layout == STAGE_ID_GEHENNA) stage = STAGE_DEPTHS_I; + else if (layout == STAGE_ID_MORTIS || layout == STAGE_ID_CORPSE || layout == STAGE_ID_BLUE_WOMB) stage = STAGE_WOMB_I; + else if (layout == STAGE_ID_CHEST || layout == STAGE_ID_DARK_ROOM) stage = STAGE_SHEOL; + else if (layout >= STAGE_ID_HOME) stage = STAGE_BASEMENT_I; + + if (layout == STAGE_ID_CHEST || layout == STAGE_ID_DARK_ROOM) + stageType = layout == STAGE_ID_CHEST ? STAGETYPE_WOTL : STAGETYPE_ORIGINAL; + if (layout >= STAGE_ID_HOME) stageType = STAGETYPE_ORIGINAL; +} + +// (PortalUnaliveSelf, parity off) Whether a Portal stays on floors the game removes it from. +bool is_portal_kept() +{ + return !repentogonOptions.isVanillaParity; +} diff --git a/src/repentogon/level.h b/src/repentogon/level.h index e0686e5..1212f15 100644 --- a/src/repentogon/level.h +++ b/src/repentogon/level.h @@ -4,6 +4,7 @@ #include #include #include +#include class Room; struct BackwardsStageDesc; @@ -56,6 +57,12 @@ int room_item_pool_forced_get(); void stage_binary_load_post(RoomConfig& config, int stageId, RoomMode mode); RoomConfig_Room* deal_room_get(uint32_t seed, WeightReduction reduction, RoomQuery& query); void room_item_pool_reset(); +void void_stages_select(RoomConfig& config); +bool void_rooms_get(RoomConfig& config, const RoomQuery& query, std::vector& rooms); +int void_ex_stage_get(const RoomDescriptor& descriptor); +std::optional void_ex_room_stage_get(); +void portal_stage_override(int& stage, int& stageType); +bool is_portal_kept(); // Runs MC_PRE_GRID_HURT, which may change the damage or cancel the hurt, then hurt, then MC_POST_GRID_HURT once it // hurt. Only a grid entity that can still be hurt runs them. diff --git a/src/repentogon/lua_render.cpp b/src/repentogon/lua_render.cpp index ca16575..001be64 100644 --- a/src/repentogon/lua_render.cpp +++ b/src/repentogon/lua_render.cpp @@ -5,7 +5,9 @@ #include "game/game.h" #include "game/manager.h" #include "level/room.h" +#include "repentogon/gl_pipeline.h" #include "repentogon/lua_render.h" +#include "repentogon/options.h" #include "ui/menu/collection.h" #include #include @@ -28,14 +30,6 @@ constexpr float WORLD_RENDER_ORIGIN_X = 60; constexpr float WORLD_RENDER_ORIGIN_Y = 140; constexpr float WORLD_TO_SCREEN_SCALE = 0.65f; -// The game's shaders by REPENTOGON's ShaderType. -constexpr const char* SHADER_TYPE_NAMES[] = { - "ColorOffset", "Pixelation", "Bloom", "ColorCorrection", "HQ4X", - "Shockwave", "OldTV", "WaterSurface", "Hallucination", "ColorMod", - "ColorOffsetChampion", "WaterSurfaceV2", "Background", "WaterOverlay", "ColorOffsetAttr", - "ColorOffsetDogma", "ColorOffsetGold", "Dizzy", "HeatWave", "Mirror"}; -constexpr int SHADER_TYPE_COUNT = (int)std::size(SHADER_TYPE_NAMES); - // A quad corner REPENTOGON's RenderMatrix moves: x' = a x + b y + tx and y' = c x + d y + ty. struct RenderMatrix { @@ -424,14 +418,17 @@ static float* image_shader_render(KAGE::Graphics::ImageBase& image, KAGE::Graphi return vertices; } -// RenderToSurface: draws into a render target, then back to the one before. +// RenderToSurface: draws into a render target, presented before going back to the one before. Without vanilla parity +// the draws still pending go to their own target first (MiscFixes.cpp's PushCurrentRenderTarget hook). template static void surface_render(KAGE::Graphics::ImageBase& surface, Draw draw) { - KAGE::Graphics::manager.render_target_push(&surface, KAGE::Graphics::TARGET_OWN_SIZE, - KAGE::Graphics::PRESENT_FLUSH); + KAGE::Graphics::Manager& manager = KAGE::Graphics::manager; + if (!repentogonOptions.isVanillaParity && !manager.pendingBatches.empty()) + manager.Present(KAGE::Graphics::PRESENT_FLUSH); + manager.render_target_push(&surface, KAGE::Graphics::TARGET_OWN_SIZE, KAGE::Graphics::PRESENT_FLUSH); draw(); - KAGE::Graphics::manager.render_target_pop(KAGE::Graphics::PRESENT_FLUSH); + manager.render_target_pop(KAGE::Graphics::PRESENT_FINISH); } static KAGE::Graphics::ImagePtr& procedural_image_get(lua_State* state) @@ -1029,6 +1026,7 @@ void render_classes_register(lua_State* state) beam_register(state); color_classes_register(state); debug_renderer_register(state); + gl_pipeline_register(state); } // (LuaIsaac.cpp) REPENTOGON's drawing functions of Isaac: a HUD position in the world, lines and quad outlines, diff --git a/src/repentogon/lua_render.h b/src/repentogon/lua_render.h index 8b41574..3cc94a3 100644 --- a/src/repentogon/lua_render.h +++ b/src/repentogon/lua_render.h @@ -4,6 +4,14 @@ #include "engine/kage_graphics.h" #include "repentogon/api.h" +// The game's shaders by REPENTOGON's ShaderType. +inline constexpr const char* SHADER_TYPE_NAMES[] = { + "ColorOffset", "Pixelation", "Bloom", "ColorCorrection", "HQ4X", + "Shockwave", "OldTV", "WaterSurface", "Hallucination", "ColorMod", + "ColorOffsetChampion", "WaterSurfaceV2", "Background", "WaterOverlay", "ColorOffsetAttr", + "ColorOffsetDogma", "ColorOffsetGold", "Dizzy", "HeatWave", "Mirror"}; +inline constexpr int SHADER_TYPE_COUNT = (int)std::size(SHADER_TYPE_NAMES); + // A blend mode as LayerState keeps it, which REPENTOGON's BlendMode also holds by value. using BlendParts = std::array; diff --git a/src/repentogon/lua_sprite.cpp b/src/repentogon/lua_sprite.cpp index 093fc36..bd7fddf 100644 --- a/src/repentogon/lua_sprite.cpp +++ b/src/repentogon/lua_sprite.cpp @@ -106,7 +106,7 @@ static bool is_custom_shader(lua_State* state, const std::shared_ptrpaths[slot] == shader_path_normalize(path); } -// Anm2Extras' GetCustomShaderForLayer: makes the layer's custom shader current, else the sprite's. +// (Patches/Anm2Extras.cpp) GetCustomShaderForLayer: makes the layer's custom shader current, else the sprite's. void custom_shader_select(const ANM2& sprite, const LayerState& layer, CustomShaderSlot slot) { for (const std::shared_ptr& shaders : {layer.customShaders, sprite.customShaders}) diff --git a/src/repentogon/mods_menu.cpp b/src/repentogon/mods_menu.cpp new file mode 100644 index 0000000..57b436c --- /dev/null +++ b/src/repentogon/mods_menu.cpp @@ -0,0 +1,284 @@ +// REPENTOGON's mods menu (Patches/ModsMenuStuff.cpp, ASMPatches/ASMMenu.cpp's font patch), parity off: the enabled +// mods listed first, a search bar filtering them once more than fit on the paper, and an undo of this session's +// changes. +#include "repentogon/ui_patches.h" +#include "engine/filesys.h" +#include "engine/kage_input.h" +#include "game/manager.h" +#include "game/mod_manager.h" +#include "repentogon/options.h" +#include "ui/menu/manager.h" +#include "ui/menu/mods.h" +#include + +constexpr const char* MODS_MENU_ANM2 = "repentogon/resources/gfx/ui/modsmenupentogon.anm2"; +constexpr const char* SEARCH_PROMPT = "Press CTRL and type to filter"; +constexpr const char* SEARCH_CURSOR = "|"; +// The paper fits this many mods. The search only opens past them. +constexpr size_t SEARCH_MOD_MIN = 15; +constexpr int KEY_FIRST_TYPED = 32; +constexpr int KEY_DELAY = 20; +constexpr float KEY_REPEAT_SHARE = 0.7f; +constexpr int CURSOR_BLINK_FRAMES = 10; +constexpr float SEARCH_WIDTH_MAX = 225; +constexpr float ROW_SCALE = 0.9f; +constexpr float ENABLED_ALPHA = 1; +constexpr float DISABLED_ALPHA = 0.5f; +constexpr float MODS_OFF_ALPHA = 0.3f; +constexpr float SEARCH_IDLE_ALPHA = 0.5f; +constexpr float CURSOR_ALPHA = 0.8f; +constexpr float CURSOR_BLINK_ALPHA = 0.3f; +constexpr float CURSOR_SCALE_Y = 1.2f; +// Where the undo note, the search bar and its text sit from the paper's first row, the bar never below the paper's +// edge (25 per mod past its top) or the screen's bottom. +constexpr float UNDO_X = 150; +constexpr float UNDO_Y = 3; +constexpr float BAR_X = 90; +constexpr float BAR_SCREEN_MARGIN = 30; +constexpr float PAPER_TOP = -25; +constexpr float PAPER_ROW_HEIGHT = 25; +constexpr float PAPER_EDGE_MARGIN = 40; +constexpr float SEARCH_TEXT_X = -20; +constexpr int UNDO_KEYBOARD_FRAME = 0; +constexpr int UNDO_CONTROLLER_FRAME = 1; +// The menu sprite's layers below its widget: hidden while the widget draws over REPENTOGON's rows. +constexpr int WIDGET_LAYER_FIRST = 11; +constexpr const char* WIDGET_LAYERS[] = {"WidgetTab", "WidgetText", "Widget"}; + +static std::string searchText; +static std::vector initialEnabled; +static std::array keyFrames{}; +static int cursorBlinkFrame = 0; +static bool isSearching = false; +static bool isCursorShown = false; +static bool wereModsEnabled = true; + +// Whether the mods menu is REPENTOGON's: parity off. +bool is_mods_menu_reworked() +{ + return !repentogonOptions.isVanillaParity; +} + +// Whether the mods menu, open, has its search take the keyboard, which then triggers no action. +static bool is_mods_menu_open() +{ + return is_mods_menu_reworked() && g_menuManager && g_menuManager->selectedMenuId == MENU_MODS; +} + +bool is_mods_search_active() +{ + return isSearching && is_mods_menu_open(); +} + +static bool is_key(int key, bool isTriggered) +{ + std::shared_ptr keyboard = KAGE::Input::manager.get_device(KEYBOARD_DEVICE); + if (!keyboard) return false; + return isTriggered ? keyboard->is_button_triggered(key) : keyboard->is_button_pressed(key); +} + +static std::string text_lower(std::string text) +{ + for (char& letter : text) letter = (char)std::tolower((unsigned char)letter); + return text; +} + +// The mods the paper lists, numbered from 1: the enabled ones, then the others, each only when its numbered name has +// the search text. +static std::vector mods_shown_get() +{ + std::vector shown; + int number = 1; + for (bool isEnabled : {true, false}) + for (auto& mod : g_manager->modManager.mods) + { + if (mod->isEnabled != isEnabled) continue; + std::string name = text_lower(std::to_string(number) + "." + mod->name); + if (!searchText.empty() && name.find(searchText) == std::string::npos) continue; + shown.push_back(mod.get()); + number++; + } + return shown; +} + +// (SetupEnabledStates, RestoreEnabledStates) The mods' states when the menu first opened this session, which undo +// writes back with whether mods are on. +static void enabled_states_save() +{ + if (!initialEnabled.empty()) return; + for (auto& mod : g_manager->modManager.mods) initialEnabled.push_back(mod->isEnabled); + wereModsEnabled = g_manager->optionsConfig.isModsEnabled; +} + +static void enabled_states_restore() +{ + std::vector>& mods = g_manager->modManager.mods; + for (size_t i = 0; i < mods.size() && i < initialEnabled.size(); i++) + { + if (mods[i]->isEnabled == initialEnabled[i]) continue; + mods[i]->isEnabled = initialEnabled[i]; + mods[i]->disable_marker_save(); + } + g_manager->optionsConfig.isModsEnabled = wereModsEnabled; +} + +// Types into the search: letters (lowercased), digits and spaces while it fits, backspace erasing, each held key +// repeating after a delay. Control, enter and escape close it. Whether the text changed. +static bool search_type(int frame) +{ + Font& font = g_manager->font1_TeamMeatEx10; + bool isChanged = false; + for (int key = KEY_FIRST_TYPED; key < KAGE::Input::KEY_COUNT; key++) + { + if (!is_key(key, false)) + { + keyFrames[key] = 0; + continue; + } + if (frame - keyFrames[key] < KEY_DELAY) continue; + if (key == KEY_LEFT_CONTROL || key == KEY_ENTER || key == KEY_ESCAPE) + { + isSearching = false; + keyFrames[key] = frame; + break; + } + + bool isTyped = false; + if (key == KEY_BACKSPACE && !searchText.empty()) + { + searchText.pop_back(); + isTyped = true; + } + else if (key != KEY_BACKSPACE && font.GetStringWidth(searchText) < SEARCH_WIDTH_MAX && key < UINT8_MAX && + (std::isalnum(key) || key == KEY_SPACE)) + { + searchText += (char)std::tolower(key); + isTyped = true; + } + if (isTyped) keyFrames[key] = keyFrames[key] > 0 ? frame - (int)(KEY_DELAY * KEY_REPEAT_SHARE) : frame; + isChanged = isChanged || isTyped; + } + return isChanged; +} + +// (ModsMenuStuff.cpp's Menu_Mods::Update and Render hooks) Takes the menu's input before the game's: the search's +// keys, the undo, and confirm turning the listed mod under the cursor on or off. Whether confirm was taken. +bool mods_menu_update_pre(Menu_Mods& menu) +{ + if (!is_mods_menu_open()) + { + isSearching = false; + return false; + } + enabled_states_save(); + + int frame = (int)g_manager->framecount; + bool isSearchAllowed = g_manager->modManager.mods.size() > SEARCH_MOD_MIN; + bool isController = g_menuControllerIndex > KEYBOARD_DEVICE; + if (isSearching && isSearchAllowed && search_type(frame)) menu.selectedMod = 0; + else if (!isSearching && isSearchAllowed && is_key(KEY_LEFT_CONTROL, true) && + frame - keyFrames[KEY_LEFT_CONTROL] > KEY_DELAY) + { + isSearching = true; + keyFrames[KEY_LEFT_CONTROL] = frame; + } + else if (!isSearching && ((!isController && is_key(KEY_BACKSPACE, true) && frame - keyFrames[KEY_BACKSPACE] > KEY_DELAY) || + (isController && is_action(ACTION_MENU_LB, ACTION_TRIGGERED)))) + { + enabled_states_restore(); + menu.isChanged = false; + } + + if (!is_action(ACTION_MENU_CONFIRM, ACTION_TRIGGERED)) return false; + std::vector shown = mods_shown_get(); + if (!isSearching && menu.selectedMod < (int)shown.size() && !is_key(KEY_LEFT_CONTROL, true)) + { + ModEntry& mod = *shown[menu.selectedMod]; + mod.isEnabled = !mod.isEnabled; + mod.disable_marker_save(); + menu.isChanged = true; + } + return true; +} + +// Keeps the cursor on a listed mod after the game's moves: past the last it goes back to the first, or to the last +// when it came from the top. +void mods_menu_update_post(Menu_Mods& menu, int previousSelected) +{ + if (!is_mods_menu_open()) return; + int last = (int)mods_shown_get().size() - 1; + if (menu.selectedMod > last) menu.selectedMod = previousSelected <= 0 ? std::max(last, 0) : 0; +} + +static void widget_layers_show(ANM2& sprite, bool isShown) +{ + for (const char* name : WIDGET_LAYERS) + if (LayerState* layer = sprite.GetLayer(name)) layer->isVisible = isShown; +} + +// Draws the listed mods over the paper in place of the game's names: black, half faded when off, faint while mods are +// off. Then the undo note, the search bar with its text or prompt and blinking cursor, and the widget over them. +void mods_menu_render(Menu_Mods& menu, Vector origin) +{ + static ANM2 searchBar; + static ANM2 undoNote; + if (!searchBar.isLoaded) + { + searchBar.Load(asset_path(MODS_MENU_ANM2), GRAPHICS_LOAD); + searchBar.Play("SearchBar"); + undoNote.Load(asset_path(MODS_MENU_ANM2), GRAPHICS_LOAD); + } + + Font& font = g_manager->font1_TeamMeatEx10; + FontSettings settings; + bool isModsEnabled = g_manager->optionsConfig.isModsEnabled; + std::vector shown = mods_shown_get(); + for (size_t row = 0; row < shown.size(); row++) + { + float alpha = (shown[row]->isEnabled ? ENABLED_ALPHA : DISABLED_ALPHA) * (isModsEnabled ? 1 : MODS_OFF_ALPHA); + std::string text = std::to_string(row + 1) + "." + shown[row]->name; + font.DrawString(text, paper_row_position(origin, (int)row), vector_make(ROW_SCALE, ROW_SCALE), + kcolor_make(0, 0, 0, alpha), settings); + } + + Vector first = paper_row_position(origin, 0); + undoNote.SetFrame("UndoPop", g_menuControllerIndex > KEYBOARD_DEVICE ? UNDO_CONTROLLER_FRAME : UNDO_KEYBOARD_FRAME); + undoNote.Render({.position = vector_make(origin.x + UNDO_X, origin.y + UNDO_Y)}); + + if (g_manager->modManager.mods.size() > SEARCH_MOD_MIN) + { + float edge = first.y + PAPER_TOP + (float)g_manager->modManager.mods.size() * PAPER_ROW_HEIGHT + PAPER_EDGE_MARGIN; + Vector bar = vector_make(first.x + BAR_X, std::min(g_screenHeight - BAR_SCREEN_MARGIN, edge)); + searchBar.Render({.position = bar}); + + Vector text = vector_make(first.x + SEARCH_TEXT_X, bar.y); + font.DrawString(searchText.empty() ? SEARCH_PROMPT : searchText, text, vector_make(1, 1), + kcolor_make(0, 0, 0, isSearching ? ENABLED_ALPHA : SEARCH_IDLE_ALPHA), settings); + if (isSearching) + { + if (cursorBlinkFrame < (int)g_manager->framecount) + { + isCursorShown = !isCursorShown; + cursorBlinkFrame = (int)g_manager->framecount + CURSOR_BLINK_FRAMES; + } + text.x += (float)font.GetStringWidth(searchText); + font.DrawString(SEARCH_CURSOR, text, vector_make(1, CURSOR_SCALE_Y), + kcolor_make(0, 0, 0, isCursorShown ? CURSOR_BLINK_ALPHA : CURSOR_ALPHA), settings); + } + } + + ANM2& sprite = menu.modsMenuSprite; + size_t hidden = std::min((size_t)WIDGET_LAYER_FIRST, sprite.layerStates.size()); + sprite.Play("Main"); + for (size_t layer = 0; layer < hidden; layer++) sprite.layerStates[layer].isVisible = false; + widget_layers_show(sprite, true); + if (LayerState* tab = sprite.GetLayer(WIDGET_LAYERS[0])) tab->isVisible = g_menuControllerIndex == KEYBOARD_DEVICE; + sprite.Render({.position = origin}); + for (size_t layer = 0; layer < hidden; layer++) sprite.layerStates[layer].isVisible = true; +} + +// The game's paper drawn without its widget, which mods_menu_render draws over the rows. +void mods_menu_widget_hide(Menu_Mods& menu) +{ + widget_layers_show(menu.modsMenuSprite, false); +} diff --git a/src/repentogon/player_api.cpp b/src/repentogon/player_api.cpp index 400123b..d33d99e 100644 --- a/src/repentogon/player_api.cpp +++ b/src/repentogon/player_api.cpp @@ -1180,12 +1180,74 @@ static void player_effects_api_register(lua_State* state) [](P& player) { return g_manager->entityConfig.GetPlayer(player.playerType); }); } +// EntityPlayer:AddCustomCacheTag(tag or tags, evaluate): custom caches, lowercased, its next EvaluateItems evaluates, +// at once when asked. A list stops at its first nil. +static int custom_cache_tag_add(lua_State* state) +{ + Entity_Player& player = lua_get(state, 1); + auto tag_add = [&](int index) { + std::string tag = luaL_checkstring(state, index); + std::ranges::transform(tag, tag.begin(), [](unsigned char c) { return (char)std::tolower(c); }); + player.customCache.pending.insert(tag); + }; + if (lua_type(state, 2) == LUA_TTABLE) + { + for (lua_Integer i = 1; i <= (lua_Integer)lua_rawlen(state, 2); i++) + { + bool isEnd = lua_geti(state, 2, i) == LUA_TNIL; + if (!isEnd) tag_add(-1); + lua_pop(state, 1); + if (isEnd) break; + } + } + else tag_add(2); + if (LuaOptionalBool::lua_read(state, 3).value) player.EvaluateItems(); + return 0; +} + +// The multi shot lanes REPENTOGON's EntityPlayer:GetMultiShotPositionVelocity reads from its MultiShotParams, which +// the game's binding cannot take. A loop index past the shots is an argument error. +static int multi_shot_position_velocity_get(lua_State* state) +{ + lua_get(state, 1); + int loopIndex = (int)luaL_checkinteger(state, 2); + int weaponType = (int)luaL_checkinteger(state, 3); + Vector direction = lua_get(state, 4); + float shotSpeed = (float)luaL_checknumber(state, 5); + Weapon_MultiShotParams& params = lua_get(state, 6); + if (params.numTears < loopIndex) + return luaL_argerror(state, 2, "LoopIndex cannot be higher than MultiShotParams.NumTears"); + lua_push(state, Entity_Player::GetMultiShotPositionVelocity(loopIndex, (WeaponType)weaponType, direction, shotSpeed, + params)); + return 1; +} + +// REPENTOGON's custom cache readers, its fake death (spawn_ghost_corpse, 007d87a0) and its held item animation +// (PlayExtraAnimation on the body sprite, 007abe90), true when the player's sprite has the animation. +static void player_extra_api_register(lua_State* state) +{ + using P = Entity_Player; + lua_functions_add(state, {{"AddCustomCacheTag", custom_cache_tag_add}, + {"GetMultiShotPositionVelocity", multi_shot_position_velocity_get}}); + lua_method(state, "GetCustomCacheValue", + [](P& player, std::string cache) { return custom_cache_value_get(player, cache); }); + lua_method(state, "GetTearsCap", [](P& player) { return custom_cache_value_get(player, "tearscap"); }); + lua_method(state, "GetStatMultiplier", [](P& player) { return custom_cache_value_get(player, "statmultiplier"); }); + lua_method(state, "TryFakeDeath", [](P& player) { return player.spawn_ghost_corpse(); }); + lua_method(state, "PlayItemNullAnimation", [](P& player, std::string animation) { + bool isFound = player.sprite.GetAnimationData(animation) != nullptr; + player.PlayExtraAnimation(animation, false); + return isFound; + }); +} + // Ends EntityPlayer's REPENTOGON functions, run in its class. void player_api_register(lua_State* state) { player_state_api_register(state); player_actions_api_register(state); player_effects_api_register(state); + player_extra_api_register(state); item_spoof_api_register(state); } diff --git a/src/repentogon/player_config.cpp b/src/repentogon/player_config.cpp index 692222b..6dc7bc2 100644 --- a/src/repentogon/player_config.cpp +++ b/src/repentogon/player_config.cpp @@ -34,17 +34,8 @@ constexpr std::array PAGE_UNLOCKED_LAYERS = { "Power Stat", "Speed Stat", "Life Stat", "Power Icon", "Speed Icon", "Life Icon"}; constexpr std::string_view PAGE_LOCKED_LAYER = "Unlocked By"; -// The lists a players.xml name may stand for an id of. -enum IdList -{ - ID_LIST_COLLECTIBLES, - ID_LIST_TRINKETS, - ID_LIST_CARDS, - ID_LIST_SOUNDS -}; - // An id as XMLData's isvalidid takes it: a whole number strtol reads to the end, nonzero unless written "0". -static bool is_id_text(std::string_view text) +bool is_id_text(std::string_view text) { std::string copy(text); char* end = nullptr; @@ -58,7 +49,7 @@ static int text_int(std::string_view text) } // The id a name stands for in a list (the last entry of the name, as XMLData's byname keeps it), or -1. -static int id_by_name_find(IdList list, std::string_view name) +int id_by_name_find(IdList list, std::string_view name) { ItemConfig& items = g_manager->itemConfig; auto last = [&](auto& entries, auto entryName) { @@ -82,13 +73,19 @@ static int id_by_name_find(IdList list, std::string_view name) for (SoundEffect& sound : g_manager->sfxManager.sounds | std::views::reverse) if (sound.name == name) return sound.id; return -1; + case ID_LIST_PLAYERS: + for (EntityConfig_Player& player : g_manager->entityConfig.players | std::views::reverse) + if (player.name == name) return player.id; + return -1; + case ID_LIST_ACHIEVEMENTS: + return achievement_id_find(name); } return -1; } // XMLData's ComaSeparatedNamesToIds: the ids of a comma separated list, numbers as written and names looked up, the // names that find nothing dropped. -static std::vector ids_parse(std::string_view text, IdList list) +std::vector ids_parse(std::string_view text, IdList list) { std::vector ids; @@ -380,6 +377,14 @@ bool is_player_no_shake(int playerType) return ex && ex->isNoShake; } +// (PlayerTags.cpp) A character's stageportrait or extrastageportrait under its bigportraitroot, empty for none. +std::string player_stage_portrait_get(int playerType, std::string_view attribute) +{ + std::string_view portrait = player_attribute_get(playerType, attribute); + if (portrait.empty()) return {}; + return std::string(player_attribute_get(playerType, "bigportraitroot")) + std::string(portrait); +} + // (ASMPlayer.cpp) Whether a character's tears bleed of its own. bool is_player_bloody_tears(Entity_Player& player) { diff --git a/src/repentogon/player_config.h b/src/repentogon/player_config.h index 4b3ba17..dc220a9 100644 --- a/src/repentogon/player_config.h +++ b/src/repentogon/player_config.h @@ -6,7 +6,9 @@ #include #include #include +#include #include +#include struct ANM2; struct EntityConfig_Baby; @@ -28,6 +30,17 @@ enum PlayerStat PLAYER_STAT_COUNT }; +// The lists an XML name may stand for an id of (XMLData's byname lookups). +enum IdList +{ + ID_LIST_COLLECTIBLES, + ID_LIST_TRINKETS, + ID_LIST_CARDS, + ID_LIST_SOUNDS, + ID_LIST_PLAYERS, + ID_LIST_ACHIEVEMENTS +}; + // The voice lines a character's players.xml entry may replace. enum PlayerSound { @@ -55,6 +68,9 @@ void player_config_ex_load(EntityConfig_Player& player, DataNode node, ModEntry* void player_content_post_load(); PlayerConfigEx* player_config_ex_get(int playerType); std::string_view player_attribute_get(int playerType, std::string_view name); +bool is_id_text(std::string_view text); +int id_by_name_find(IdList list, std::string_view name); +std::vector ids_parse(std::string_view text, IdList list); int achievement_id_parse(std::string_view text); bool is_achievement_text_unlocked(std::string_view text); bool is_player_unlocked(int playerType); @@ -64,6 +80,7 @@ void player_hearts_init(Entity_Player& player, int subType); std::optional player_health_limit_get(int playerType); int player_health_type_get(int playerType, int healthType); bool is_player_no_shake(int playerType); +std::string player_stage_portrait_get(int playerType, std::string_view attribute); bool is_player_bloody_tears(Entity_Player& player); int player_sound_get(Entity_Player& player, PlayerSound sound); void player_cache_pre_evaluate(Entity_Player& player, int cacheFlag); diff --git a/src/repentogon/player_features.cpp b/src/repentogon/player_features.cpp new file mode 100644 index 0000000..f05cab1 --- /dev/null +++ b/src/repentogon/player_features.cpp @@ -0,0 +1,51 @@ +#include "repentogon/player_features.h" +#include "entity/config.h" +#include "game/manager.h" +#include "repentogon/json_save.h" +#include "repentogon/options.h" +#include "repentogon/xml.h" +#include +#include + +// REPENTOGON's PlayerFeatures (Patches/PlayerFeatures.cpp): the coins each modded character gave Greed's donation +// machine, which the game counts for its own characters only, saved per save file in playerdata.json. Without +// it a modded character's machine jams 99.9% of the time. Only without vanilla parity. + +constexpr const char* GREED_DONATIONS_MEMBER = "GreedDonationCounter"; +constexpr const char* TAINTED_KEY_SUFFIX = "-Tainted-"; + +static JsonCounts greedDonations; +static std::string playerDataPath; + +// (Manager::SetSaveSlot) Reads the modded characters' donations saved for a save file, the first for none. +void player_features_slot_load(unsigned int slot) +{ + playerDataPath = json_save_path(std::format("playerdata{}.json", std::max(slot, 1u))); + greedDonations.clear(); + json_save_load(playerDataPath, GREED_DONATIONS_MEMBER, &greedDonations, nullptr); +} + +// (GetPlayerIdx) A modded character's key: its mod, its name, and whether it is a tainted one. +static std::string player_key_get(EntityConfig_Player& player) +{ + std::string_view tainted = player.bSkinParentName.empty() ? "" : TAINTED_KEY_SUFFIX; + return std::format("{}-{}{}", mod_source_id_get(player.modEntry), player.name, tainted); +} + +// (GetGreedDonationCoinCount) The coins a modded character donated, nothing for the game's or with vanilla parity. +std::optional greed_donations_get(int playerType) +{ + EntityConfig_Player* player = g_manager->entityConfig.GetPlayer(playerType); + if (repentogonOptions.isVanillaParity || playerType < PLAYER_TYPE_COUNT || !player) return std::nullopt; + return greedDonations[player_key_get(*player)]; +} + +// (IncreaseGreedDonationCoinCount) Counts a coin a modded character donated, and saves the counts. +void greed_donation_add(int playerType) +{ + EntityConfig_Player* player = g_manager->entityConfig.GetPlayer(playerType); + if (repentogonOptions.isVanillaParity || playerType < PLAYER_TYPE_COUNT || !player) return; + + greedDonations[player_key_get(*player)]++; + json_save_write(playerDataPath, GREED_DONATIONS_MEMBER, &greedDonations, nullptr); +} diff --git a/src/repentogon/player_features.h b/src/repentogon/player_features.h new file mode 100644 index 0000000..afde145 --- /dev/null +++ b/src/repentogon/player_features.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +void player_features_slot_load(unsigned int slot); +std::optional greed_donations_get(int playerType); +void greed_donation_add(int playerType); diff --git a/src/repentogon/pool_items.cpp b/src/repentogon/pool_items.cpp new file mode 100644 index 0000000..641cb2b --- /dev/null +++ b/src/repentogon/pool_items.cpp @@ -0,0 +1,449 @@ +// REPENTOGON's mod items in the pools, the game's and the mods' own (Patches/ItemPoolManager.cpp, LuaItemPool.cpp's +// AddCollectible, AddTemporaryCollectible and RemoveTemporaryCollectible). A virtual item stays in its pool for the +// session: one added before the first pool load joins a game pool before it is shuffled, one added after is appended +// once shuffled. A mod's pool shuffles as it fills (repentogon/custom_pools.cpp), so it appends both. A temporary +// item lasts the run, kept in the game's states (the save file's and the Glowing Hourglass's) and written beside the +// save file. Without mods every pool is the game's and nothing is written. +#include "repentogon/pool_items.h" +#include "engine/log.h" +#include "entity/pickup/item_pool.h" +#include "game/game.h" +#include "game/manager.h" +#include "lua/engine.h" +#include "repentogon/api.h" +#include "repentogon/custom_pools.h" +#include "repentogon/json_save.h" +#include "simdjson.h" +#include "ui/console.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +constexpr int STATE_SLOT_COUNT = 3; +constexpr int SLOT_SAVE_FILE = 0; +constexpr int SLOT_HOURGLASS_FIRST = 1; +constexpr int SLOT_HOURGLASS_SECOND = 2; +constexpr int GAME_STATE_VERSION = 1; +constexpr std::string_view STATE_FOLDER = "ItemPoolManager/"; +constexpr std::string_view STATE_EXTENSION = ".json"; + +// A pool item a mod describes (PoolItemDesc). +struct PoolItemDesc +{ + float decreaseBy = 0.5f; + float removeOn = 0.1f; + float weight = 1; + int itemId = 0; + + bool operator==(const PoolItem& item) const + { + return itemId == item.itemId && weight == item.initialWeight && decreaseBy == item.decreaseBy && + removeOn == item.removeOn; + } +}; + +// A pool's mod items: its virtual items (those before appendIndex joined before the first load), how many of +// its items the XML gave, and the temporary items each kept game state holds, none for a state that cannot be used. +struct PoolMods +{ + std::array>, STATE_SLOT_COUNT> states; + std::vector virtualItems; + size_t appendIndex = 0; + size_t regularCount = 0; +}; + +static std::vector poolMods; +static bool isAppendMode = false; +static bool isPoolReady = false; + +// How many pools there are: the game's, then the mods' own. +static int pool_count_get() +{ + return POOL_COUNT + custom_pool_count(); +} + +// ItemPool::GetPoolData: a pool's items, the game's or a mod's. +static ItemPool_Item& pool_data_get(int pool) +{ + return pool < POOL_COUNT ? g_game->itemPool.pools[pool] : *custom_pool_get(pool); +} + +static PoolMods& pool_mods_get(int pool) +{ + if (poolMods.size() <= (size_t)pool) poolMods.resize(pool + 1); + return poolMods[pool]; +} + +static size_t temporary_start_get(int pool) +{ + PoolMods& mods = pool_mods_get(pool); + return std::min(mods.regularCount + mods.virtualItems.size(), pool_data_get(pool).poolList.size()); +} + +// finalize_pool_item: a collectible's special and unlocked marks from its config. +static PoolItem pool_item_finalize(PoolItem item) +{ + ItemConfig_Item* config = g_manager->itemConfig.GetCollectible(item.itemId); + if (!config) return item; + item.isSpecial = config->isSpecial; + item.isUnlocked = config->achievementId < 0 || g_manager->persistentGameData.Unlocked(config->achievementId); + return item; +} + +// EmplaceItem: a described item put into a pool at a place, its weight added. +static void pool_item_emplace(int pool, size_t position, const PoolItemDesc& desc) +{ + ItemPool_Item& data = pool_data_get(pool); + PoolItem item = {.decreaseBy = desc.decreaseBy, .initialWeight = desc.weight, .removeOn = desc.removeOn, + .weight = desc.weight, .itemId = desc.itemId}; + data.poolList.insert(data.poolList.begin() + std::min(position, data.poolList.size()), pool_item_finalize(item)); + data.totalWeight += desc.weight; +} + +// (The shuffle_pools hook, before) Pools take their virtual items added before the first load, to be shuffled. Mods +// added later only append from now on. +void pool_items_load() +{ + isAppendMode = true; + isPoolReady = true; + for (int pool = 0; pool < POOL_COUNT; pool++) + { + PoolMods& mods = pool_mods_get(pool); + mods.regularCount = pool_data_get(pool).poolList.size(); + for (size_t i = 0; i < mods.appendIndex; i++) pool_item_emplace(pool, SIZE_MAX, mods.virtualItems[i]); + } +} + +// (The shuffle_pools hook, after) Pools take their virtual items added after the first load, past the shuffle. A +// mod's pool, filled and shuffled since, takes all of them. +void pool_items_finalize() +{ + for (int pool = 0; pool < pool_count_get(); pool++) + { + PoolMods& mods = pool_mods_get(pool); + bool isCustom = pool >= POOL_COUNT; + if (isCustom) mods.regularCount = pool_data_get(pool).poolList.size(); + for (size_t i = isCustom ? 0 : mods.appendIndex; i < mods.virtualItems.size(); i++) + pool_item_emplace(pool, SIZE_MAX, mods.virtualItems[i]); + } +} + +// (The Game::Exit and NextVictoryLap hooks) The pools are no longer the run's. +void pool_items_unready() +{ + isPoolReady = false; +} + +// Keeps each pool's temporary items in a game state slot, as the game saved its state there. +void pool_items_store(int slot) +{ + if (slot < 0 || slot >= STATE_SLOT_COUNT) return; + for (int pool = 0; pool < pool_count_get(); pool++) + { + std::vector& list = pool_data_get(pool).poolList; + pool_mods_get(pool).states[slot].emplace(list.begin() + (long)temporary_start_get(pool), list.end()); + } +} + +// Gives each pool back the temporary items a usable slot kept, after the game restored its state. Restoring one +// Glowing Hourglass slot spends the other. +void pool_items_restore(int slot) +{ + if (slot < 0 || slot >= STATE_SLOT_COUNT) return; + for (int pool = 0; pool < pool_count_get(); pool++) + { + std::optional>& kept = pool_mods_get(pool).states[slot]; + if (!kept) continue; + + std::vector& list = pool_data_get(pool).poolList; + list.resize(temporary_start_get(pool)); + list.insert(list.end(), kept->begin(), kept->end()); + } + if (slot == SLOT_HOURGLASS_FIRST) pool_items_clear(SLOT_HOURGLASS_SECOND); + if (slot == SLOT_HOURGLASS_SECOND) pool_items_clear(SLOT_HOURGLASS_FIRST); +} + +// A cleared game state's slot keeps nothing usable. +void pool_items_clear(int slot) +{ + if (slot < 0 || slot >= STATE_SLOT_COUNT) return; + for (PoolMods& mods : poolMods) mods.states[slot].reset(); +} + +static std::string state_path_get(std::string_view fileName) +{ + return json_save_path(std::string(STATE_FOLDER) + std::string(fileName) + std::string(STATE_EXTENSION)); +} + +// (__SaveToDisk) Writes the save file slot's temporary items beside a game state file, by name for a mod's +// collectible (REPENTOGON compares the id with the pool count). Without any the file is removed instead. +void pool_items_save(std::string_view fileName, uint32_t checksum) +{ + std::string path = state_path_get(fileName); + std::error_code error; + bool isEmpty = std::ranges::all_of(poolMods, [](PoolMods& mods) { + return !mods.states[SLOT_SAVE_FILE] || mods.states[SLOT_SAVE_FILE]->empty(); + }); + if (isEmpty) + { + std::filesystem::remove(path, error); + return; + } + + std::string text = std::format("{{\"Version\":{},\"Checksum\":{},\"PoolIndex\":[", GAME_STATE_VERSION, checksum); + for (int pool = POOL_COUNT; pool < pool_count_get(); pool++) + text += std::format("{}\"{}\"", pool > POOL_COUNT ? "," : "", pool_name_get(pool)); + text += "],\"PoolData\":["; + for (int pool = 0; pool < pool_count_get(); pool++) + { + text += pool ? ",{\"TemporaryItems\":[" : "{\"TemporaryItems\":["; + const std::optional>& kept = pool_mods_get(pool).states[SLOT_SAVE_FILE]; + for (size_t i = 0; kept && i < kept->size(); i++) + { + const PoolItem& item = (*kept)[i]; + ItemConfig_Item* config = g_manager->itemConfig.GetCollectible(item.itemId); + std::string name = config ? config->name : ""; + std::erase_if(name, [](char letter) { return letter == '"' || letter == '\\'; }); + std::string id = item.itemId >= POOL_COUNT && config ? std::format("\"Name\":\"{}\"", name) + : std::format("\"ItemId\":{}", item.itemId); + text += std::format("{}{{{},\"InitialWeight\":{},\"Weight\":{},\"DecreaseBy\":{},\"RemoveOn\":{}}}", + i ? "," : "", id, item.initialWeight, item.weight, item.decreaseBy, item.removeOn); + } + text += "]}"; + } + std::filesystem::create_directories(std::filesystem::path(path).parent_path(), error); + std::ofstream(path) << text << "]}\n"; +} + +// A number member of a JSON object, the fallback when it is missing or not a number. +static float json_number_get(simdjson::dom::object object, std::string_view member, float fallback) +{ + double number = 0; + return object[member].get_double().get(number) == simdjson::SUCCESS ? (float)number : fallback; +} + +// (__LoadFromDisk) Reads the temporary items written beside a game state file into the save file slot, when it was +// written for that state, a mod's pool found again by its name. A missing or stale file leaves the slot with nothing +// to restore. +void pool_items_read(std::string_view fileName, uint32_t checksum) +{ + pool_items_clear(SLOT_SAVE_FILE); + simdjson::dom::parser parser; + simdjson::dom::object root; + simdjson::dom::array pools; + simdjson::dom::array names; + int64_t version = 0; + int64_t written = 0; + if (parser.load(state_path_get(fileName)).get_object().get(root) != simdjson::SUCCESS) return; + if (root["Version"].get_int64().get(version) != simdjson::SUCCESS || version != GAME_STATE_VERSION) return; + if (root["Checksum"].get_int64().get(written) != simdjson::SUCCESS || (uint32_t)written != checksum) + return log_printf(LOG_INFO, "[ItemPoolManager] [ERROR] - unable to restore %s: checksum mismatch\n", + std::string(fileName).c_str()); + if (root["PoolData"].get_array().get(pools) != simdjson::SUCCESS) return; + + std::vector remap(POOL_COUNT); + std::iota(remap.begin(), remap.end(), 0); + if (root["PoolIndex"].get_array().get(names) == simdjson::SUCCESS) + for (simdjson::dom::element name : names) + { + std::string_view text; + remap.push_back(name.get_string().get(text) == simdjson::SUCCESS ? pool_id_find(text) : -1); + } + size_t index = 0; + for (simdjson::dom::element entry : pools) + { + simdjson::dom::array items; + int pool = index < remap.size() ? remap[index] : -1; + index++; + if (pool < 0 || pool >= pool_count_get()) continue; + std::optional>& kept = pool_mods_get(pool).states[SLOT_SAVE_FILE]; + kept.emplace(); + if (entry["TemporaryItems"].get_array().get(items) != simdjson::SUCCESS) continue; + for (simdjson::dom::element value : items) + { + simdjson::dom::object object; + std::string_view name; + int64_t id = 0; + PoolItem item; + if (value.get_object().get(object) != simdjson::SUCCESS) continue; + if (object["ItemId"].get_int64().get(id) == simdjson::SUCCESS) + item.itemId = g_manager->itemConfig.GetCollectible((int)id) ? (int)id : 0; + else if (object["Name"].get_string().get(name) == simdjson::SUCCESS) + item.itemId = std::max(LuaEngine::Isaac_GetItemIdByName(name), 0); + item.initialWeight = json_number_get(object, "InitialWeight", item.initialWeight); + item.weight = json_number_get(object, "Weight", item.weight); + item.decreaseBy = json_number_get(object, "DecreaseBy", item.decreaseBy); + item.removeOn = json_number_get(object, "RemoveOn", item.removeOn); + kept->push_back(pool_item_finalize(item)); + } + } +} + +// (__DeleteGameState) Removes the temporary items written beside a deleted game state file. +void pool_items_delete(std::string_view fileName) +{ + std::error_code error; + std::filesystem::remove(state_path_get(fileName), error); +} + +// The fields of a Lua pool item, named without regard to case: an item by id or by name, whichever comes first. +enum PoolItemField +{ + FIELD_ITEM_ID, + FIELD_NAME, + FIELD_WEIGHT, + FIELD_DECREASE_BY, + FIELD_REMOVE_ON, + FIELD_COUNT +}; + +constexpr std::array FIELD_KEYS = {"itemid", "name", "weight", "decreaseby", "removeon"}; +constexpr std::array FIELD_NAMES = {"ItemID", "Name", "Weight", "DecreaseBy", "RemoveOn"}; + +// PoolItemDesc(lua_State*): a pool item from a table's fields, each read once, a wrong type warned about. +static PoolItemDesc pool_item_read(lua_State* state, int index, std::vector& warnings) +{ + PoolItemDesc desc; + std::bitset isRead; + index = lua_absindex(state, index); + if (!lua_istable(state, index)) + { + warnings.push_back("argument is not a lua table"); + return desc; + } + + lua_pushnil(state); + while (lua_next(state, index) != 0) + { + std::string key = lua_type(state, -2) == LUA_TSTRING ? lua_tostring(state, -2) : ""; + std::ranges::transform(key, key.begin(), [](unsigned char c) { return (char)std::tolower(c); }); + auto found = std::ranges::find(FIELD_KEYS, key); + int field = (int)(found - FIELD_KEYS.begin()); + bool isNumberField = field >= FIELD_WEIGHT && field < FIELD_COUNT; + bool isValid = field == FIELD_ITEM_ID ? lua_isinteger(state, -1) + : field == FIELD_NAME ? (bool)lua_isstring(state, -1) + : (bool)lua_isnumber(state, -1); + if (found == FIELD_KEYS.end() || isRead[field]) + { + lua_pop(state, 1); + continue; + } + if (!isValid) + warnings.push_back(std::format("invalid parameter for \"{}\" ({} expected got {})", FIELD_NAMES[field], + field == FIELD_ITEM_ID ? "integer" : field == FIELD_NAME ? "string" : "number", + lua_typename(state, lua_type(state, -1)))); + else if (isNumberField) + { + std::array targets = {nullptr, nullptr, &desc.weight, &desc.decreaseBy, &desc.removeOn}; + *targets[field] = (float)lua_tonumber(state, -1); + isRead.set(field); + } + else + { + desc.itemId = field == FIELD_ITEM_ID ? (int)lua_tointeger(state, -1) + : std::max(LuaEngine::Isaac_GetItemIdByName(lua_tostring(state, -1)), 0); + isRead.set(FIELD_ITEM_ID); + isRead.set(FIELD_NAME); + } + lua_pop(state, 1); + if (isRead.all()) + { + lua_pop(state, 1); + break; + } + } + return desc; +} + +// What a pool function does with each item: add it for the session, add it for the run, or take a run's one out. +enum PoolItemChange +{ + CHANGE_ADD_VIRTUAL, + CHANGE_ADD_TEMPORARY, + CHANGE_REMOVE_TEMPORARY +}; + +// An error for a temporary change while no run's pools exist, else none. +static std::optional temporary_change_check(PoolItemChange change) +{ + std::string_view verb = change == CHANGE_ADD_TEMPORARY ? "add" : "remove"; + if (g_manager->state != MANAGER_STATE_GAME) + return std::format("Cannot {} a temporary item while not in game", verb); + if (!isPoolReady) + return std::format("Cannot {} a temporary item when ItemPool has not yet been initialized", verb); + return std::nullopt; +} + +// AddVirtualItem, AddTemporaryItem and RemoveTemporaryItem on one pool. +static std::optional pool_item_change(int pool, const PoolItemDesc& desc, PoolItemChange change) +{ + PoolMods& mods = pool_mods_get(pool); + std::vector& list = pool_data_get(pool).poolList; + if (change == CHANGE_ADD_VIRTUAL) + { + if (isPoolReady) pool_item_emplace(pool, temporary_start_get(pool), desc); + mods.virtualItems.push_back(desc); + if (!isAppendMode) mods.appendIndex++; + return std::nullopt; + } + if (std::optional error = temporary_change_check(change)) return error; + if (change == CHANGE_ADD_TEMPORARY) + { + pool_item_emplace(pool, SIZE_MAX, desc); + return std::nullopt; + } + + for (size_t i = temporary_start_get(pool); i < list.size(); i++) + { + if (!(desc == list[i])) continue; + pool_data_get(pool).totalWeight -= list[i].initialWeight; + list.erase(list.begin() + (long)i); + break; + } + return std::nullopt; +} + +// ItemPool:AddCollectible, AddTemporaryCollectible and RemoveTemporaryCollectible(pool, item or items): a table with +// entries is a list of pool items, else one. Errors stop at the first, warnings print to the console after. +template +static int pool_items_change_lua(lua_State* state) +{ + lua_get(state, 1); + lua_Integer pool = luaL_checkinteger(state, 2); + if (pool < 0 || pool >= pool_count_get()) return luaL_argerror(state, 2, "Invalid ItemPoolType"); + if (!lua_istable(state, 3)) return luaL_argerror(state, 3, "Expected table"); + + std::vector warnings; + std::vector descs; + lua_Integer length = (lua_Integer)lua_rawlen(state, 3); + for (lua_Integer i = 1; i <= std::max(length, 1); i++) + { + std::vector itemWarnings; + if (length > 0) lua_rawgeti(state, 3, i); + descs.push_back(pool_item_read(state, length > 0 ? -1 : 3, itemWarnings)); + if (length > 0) lua_pop(state, 1); + if (itemWarnings.empty()) continue; + warnings.push_back(length > 0 ? std::format("Something went wrong when building PoolItem {}:\n", i) + : "Something went wrong when building PoolItem :\n"); + warnings.insert(warnings.end(), itemWarnings.begin(), itemWarnings.end()); + } + for (const PoolItemDesc& desc : descs) + if (std::optional error = pool_item_change((int)pool, desc, Change)) + return luaL_error(state, "%s", error->c_str()); + for (const std::string& warning : warnings) g_game->console.Print(warning, CONSOLE_WARNING, CONSOLE_FADE_FRAMES); + return 0; +} + +// Adds REPENTOGON's pool item functions to ItemPool, begun last. +void pool_items_api_register(lua_State* state) +{ + lua_functions_add(state, {{"AddCollectible", pool_items_change_lua}, + {"AddTemporaryCollectible", pool_items_change_lua}, + {"RemoveTemporaryCollectible", pool_items_change_lua}}); +} diff --git a/src/repentogon/pool_items.h b/src/repentogon/pool_items.h new file mode 100644 index 0000000..0dbf985 --- /dev/null +++ b/src/repentogon/pool_items.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include + +struct lua_State; + +void pool_items_load(); +void pool_items_finalize(); +void pool_items_unready(); +void pool_items_store(int slot); +void pool_items_restore(int slot); +void pool_items_clear(int slot); +void pool_items_save(std::string_view fileName, uint32_t checksum); +void pool_items_read(std::string_view fileName, uint32_t checksum); +void pool_items_delete(std::string_view fileName); +void pool_items_api_register(lua_State* state); diff --git a/src/repentogon/progress.cpp b/src/repentogon/progress.cpp new file mode 100644 index 0000000..5beedbd --- /dev/null +++ b/src/repentogon/progress.cpp @@ -0,0 +1,386 @@ +// Mods' challenges and modded characters' completion marks (Patches/ChallengesStuff.cpp, Patches/CompletionTracker.cpp): +// REPENTOGON's challenges.xml and players.xml extras, and their progress saved apart from the game's, per save file. +#include "repentogon/progress.h" +#include "engine/anm2.h" +#include "engine/filesys.h" +#include "entity/player/player.h" +#include "game/game.h" +#include "game/manager.h" +#include "game/mod_manager.h" +#include "repentogon/achievements.h" +#include "repentogon/callbacks.h" +#include "repentogon/json_save.h" +#include "repentogon/options.h" +#include "repentogon/player_config.h" +#include +#include +#include + +constexpr const char* CHALLENGES_FILE = "challenges.xml"; +constexpr const char* CHALLENGES_SAVE_MEMBER = "Challenges"; +constexpr const char* MARKS_SAVE_MEMBER = "CompletionMarks"; +constexpr const char* LOCKED_DEFAULT = "LOCKED :("; +constexpr const char* TAINTED_KEY_SUFFIX = "-Tainted-"; +// The streak struck through a completed challenge's name: REPENTOGON's sprite, its six looks picked as MSVC's first rand() +// after srand(id - 40) does, stretched over a name 294 wide at 1, and placed under the number. +constexpr const char* STREAK_ANM2 = "repentogon/resources/gfx/ui/challengesmenustuff.anm2"; +constexpr int STREAK_FRAMES = 6; +constexpr int STREAK_SEED_OFFSET = 40; +constexpr uint32_t MSVC_RAND_FACTOR = 214013; +constexpr uint32_t MSVC_RAND_INCREMENT = 2531011; +constexpr int MSVC_RAND_SHIFT = 16; +constexpr uint32_t MSVC_RAND_MAX = 0x7fff; +constexpr float STREAK_FULL_WIDTH = 294; +constexpr float STREAK_NUMBER_OVERLAP = 10; +constexpr float STREAK_DROP = 20; +constexpr int MARK_NORMAL = 1; +constexpr int MARK_HARD = 2; +// The languages TryImportNonLocalizedCompletionData looks for a character's old, translated name in. +constexpr int LANGUAGE_LAST = 13; + +// A mod's challenge as its challenges.xml gives it: its attributes by lowercase name and the mod it came from. +struct ModChallenge +{ + XmlAttributes attributes; + std::string sourceId; +}; + +static std::vector modChallenges; +static JsonCounts challengeClears; +static std::map moddedMarks; +static std::string challengesPath; +static std::string marksPath; + +// The text a #key stands for in a string table category in the current language, else the text itself. +static std::string text_translate(std::string_view text, std::string_view category) +{ + StringTable& strings = g_manager->stringTable; + bool isMissing = false; + if (!text.starts_with('#')) return std::string(text); + + std::string_view translated = strings.get_string(category, strings.language, text.substr(1), &isMissing); + return isMissing || translated.empty() ? std::string(text) : std::string(translated); +} + +static ModChallenge* mod_challenge_get(int id) +{ + int index = id - CHALLENGE_COUNT; + return index >= 0 && index < (int)modChallenges.size() ? &modChallenges[index] : nullptr; +} + +// (GetChallengeSaveKey) What a mod's challenge's clears are saved under: its raw name and its mod. +static std::string challenge_key_get(ModChallenge& challenge) +{ + return challenge.attributes["name"] + challenge.sourceId; +} + +// Whether a comma separated list names anything in place of an id. +static bool is_names_text(std::string_view text) +{ + for (size_t start = 0; start <= text.size();) + { + size_t end = std::min(text.find(',', start), text.size()); + if (!is_id_text(text.substr(start, end - start))) return true; + start = end + 1; + } + return false; +} + +// (ParseModdedXMLAttributes, the late playertype fix) A mod's challenge's character, starting items, trinkets, card and +// required achievements by name, in place of the ids the game reads. +static void challenge_names_resolve(XmlAttributes& attributes, ChallengeParam& param) +{ + auto list = [&](std::string_view name, IdList ids, std::vector& target) { + auto found = attributes.find(name); + if (found != attributes.end() && is_names_text(found->second)) target = ids_parse(found->second, ids); + }; + auto single = [&](std::string_view name, IdList ids, int& target) { + auto found = attributes.find(name); + if (found == attributes.end() || is_id_text(found->second)) return; + if (int id = id_by_name_find(ids, found->second); id >= 0) target = id; + }; + + list("startingitems", ID_LIST_COLLECTIBLES, param.collectibleList); + list("startingitems2", ID_LIST_COLLECTIBLES, param.collectibleTwinList); + list("startingtrinkets", ID_LIST_TRINKETS, param.trinketList); + list("achievements", ID_LIST_ACHIEVEMENTS, param.achievementList); + single("startingcard", ID_LIST_CARDS, param.startingCard); + if (param.playerType <= 0) single("playertype", ID_LIST_PLAYERS, param.playerType); +} + +// (XMLData.cpp's challenges) Reads each loaded mod's challenges.xml again as the game did, numbering its challenges +// after the game's, then gives the game's params what they name. Runs once the mods' characters are known. +void challenges_content_load() +{ + std::vector& params = g_manager->challengeParams; + modChallenges.clear(); + + for (auto& mod : g_manager->modManager.mods) + { + std::string path = mod->GetContentPath(CHALLENGES_FILE); + bool isFound = resource_exists(path) || resource_exists(path + std::string(JSON_EXTENSION)); + Data data; + if (!mod->isLoaded || !isFound) continue; + data_load(data, path); + if (!data.isLoaded || node_tag(data.root) != "challenges") continue; + + bool isFirstFound = false; + for (DataNode node : node_children(data.root)) + { + isFirstFound = isFirstFound || node_tag(node) == "challenge"; + if (!isFirstFound) continue; + + int id = CHALLENGE_COUNT + (int)modChallenges.size(); + ModChallenge& challenge = modChallenges.emplace_back(xml_attributes_read(node), mod_source_id_get(mod.get())); + if (id < (int)params.size()) challenge_names_resolve(challenge.attributes, params[id]); + } + } +} + +// Whether a mod's challenge says hidden: anything but "false" keeps it off the menu. +bool is_challenge_hidden(int id) +{ + ModChallenge* challenge = mod_challenge_get(id); + if (!challenge) return false; + auto found = challenge->attributes.find("hidden"); + return found != challenge->attributes.end() && found->second != "false"; +} + +// (MeetsComaSeparatedAchievs, parity off) Whether a mod's challenge waits on an achievement it lists. +bool is_challenge_locked(int id) +{ + ModChallenge* challenge = mod_challenge_get(id); + if (repentogonOptions.isVanillaParity || !challenge || !challenge->attributes.contains("achievements")) return false; + + PersistentGameData& data = g_manager->persistentGameData; + std::vector& achievements = g_manager->GetChallengeParams(id).achievementList; + return std::ranges::any_of(achievements, [&](int achievement) { return !data.Unlocked(achievement); }); +} + +// (Menu_CustomChallenge::Render's streak, parity off) Whether a mod's challenge shows as completed. +bool is_challenge_shown_completed(int id) +{ + return !repentogonOptions.isVanillaParity && mod_challenge_clears_get(id) > 0; +} + +// The name a mod's challenge shows on the menu, translated without parity. Locked, its lockeddesc (translated) or +// "LOCKED :(". +std::string challenge_row_name_get(int id) +{ + ModChallenge* challenge = mod_challenge_get(id); + std::string& name = g_manager->GetChallengeParams(id).name; + if (repentogonOptions.isVanillaParity || !challenge) return name; + if (!is_challenge_locked(id)) return text_translate(name, "Challenges"); + + auto found = challenge->attributes.find("lockeddesc"); + bool isDescribed = found != challenge->attributes.end() && !found->second.empty(); + return isDescribed ? text_translate(found->second, "Challenges") : LOCKED_DEFAULT; +} + +// (Menu_CustomChallenge::Render) Strikes the streak through a completed challenge's name on its row. +void challenge_streak_render(int id, int row, std::string_view name, Vector textPosition) +{ + static ANM2 streak; + Font& font = g_manager->font2_TeamMeatEx12; + if (!streak.isLoaded) streak.Load(asset_path(STREAK_ANM2), GRAPHICS_LOAD); + + uint32_t seed = (uint32_t)(id - STREAK_SEED_OFFSET); + int look = (int)(((seed * MSVC_RAND_FACTOR + MSVC_RAND_INCREMENT) >> MSVC_RAND_SHIFT) & MSVC_RAND_MAX) % STREAK_FRAMES; + streak.SetFrame("Idle", look); + streak.scale.x = (float)font.GetStringWidth(name) / STREAK_FULL_WIDTH; + streak.offset.x = (float)font.GetStringWidth(std::format("{}.", row + 1)) - STREAK_NUMBER_OVERLAP; + streak.Render({.position = vector_make(textPosition.x, textPosition.y + STREAK_DROP)}); +} + +// How often a mod's challenge was completed on this save file. +int mod_challenge_clears_get(int id) +{ + ModChallenge* challenge = mod_challenge_get(id); + if (!challenge) return 0; + auto found = challengeClears.find(challenge_key_get(*challenge)); + return found == challengeClears.end() ? 0 : found->second; +} + +// (Isaac.GetModChallengeCompletionData) A challenge's clears by its mod and raw name, none when never saved. +std::optional mod_challenge_clears_find(std::string_view mod, std::string_view name) +{ + auto found = challengeClears.find(std::string(name) + std::string(mod)); + return found == challengeClears.end() ? std::nullopt : std::optional(found->second); +} + +static void challenges_save() +{ + if (!challengesPath.empty()) json_save_write(challengesPath, CHALLENGES_SAVE_MEMBER, &challengeClears, nullptr); +} + +// (PersistentGameData::AddChallenge) Counts a mod's challenge completed, unlocking its unlockachievement, by number or +// name, and saves. +void mod_challenge_complete(int id) +{ + ModChallenge* challenge = mod_challenge_get(id); + if (!challenge) return; + + int clears = ++challengeClears[challenge_key_get(*challenge)]; + if (auto found = challenge->attributes.find("unlockachievement"); found != challenge->attributes.end()) + g_manager->persistentGameData.TryUnlock(achievement_id_parse(found->second)); + challenges_save(); + log_printf(LOG_INFO, "[Callenge] %s completed (total: %d)\n", challenge->attributes["name"].c_str(), clears); +} + +// (ResetChallengeCompletion) A mod's challenge counted as never completed. +void mod_challenge_reset(int id) +{ + ModChallenge* challenge = mod_challenge_get(id); + if (!challenge) return; + challengeClears[challenge_key_get(*challenge)] = 0; + challenges_save(); +} + +// (GetPlayerDataForMarks) The character whose marks a character shares: the one its completionparent names, in its +// own mod first, else itself. +static EntityConfig_Player* marks_owner_get(int playerType) +{ + std::vector& players = g_manager->entityConfig.players; + if (playerType < 0 || playerType >= (int)players.size()) return nullptr; + + EntityConfig_Player& player = players[playerType]; + std::string_view parent = player.ex.attribute_get("completionparent"); + if (parent.empty()) return &player; + + EntityConfig_Player* found = nullptr; + for (EntityConfig_Player& other : players | std::views::reverse) + { + if (other.name != parent) continue; + if (other.modEntry == player.modEntry) return &other; + if (!found) found = &other; + } + return found ? found : &player; +} + +// (GetMarksIdxByName) What a character's marks are saved under: its mod, its raw name and whether it is tainted. +static std::string marks_key_make(std::string_view mod, std::string_view name, bool isTainted) +{ + return std::format("{}-{}{}", mod, name, isTainted ? TAINTED_KEY_SUFFIX : ""); +} + +static std::string marks_key_get(EntityConfig_Player& owner) +{ + return marks_key_make(mod_source_id_get(owner.modEntry), owner.name, !owner.bSkinParentName.empty()); +} + +// A modded character's marks as saved, made empty when it has none. +MarkSet& modded_marks_get(int playerType) +{ + static MarkSet none; + EntityConfig_Player* owner = marks_owner_get(playerType); + if (!owner) return none = {}; + return moddedMarks[marks_key_get(*owner)]; +} + +// (GetMarksForPlayer) A modded character's marks as read: a hard Ultra Greed mark gives Ultra Greedier's, and any +// Ultra Greedier mark makes both hard. +MarkSet modded_marks_read(int playerType) +{ + MarkSet marks = modded_marks_get(playerType); + if (marks[COMPLETION_ULTRA_GREED] == MARK_HARD) marks[COMPLETION_ULTRA_GREEDIER] = MARK_HARD; + if (marks[COMPLETION_ULTRA_GREEDIER] > 0) marks[COMPLETION_ULTRA_GREED] = marks[COMPLETION_ULTRA_GREEDIER] = MARK_HARD; + return marks; +} + +// (Isaac.GetCompletionMarkData) A character's marks by its mod, raw name and taint, none when never saved. +std::optional modded_marks_find(std::string_view mod, std::string_view name, bool isTainted) +{ + auto found = moddedMarks.find(marks_key_make(mod, name, isTainted)); + return found == moddedMarks.end() ? std::nullopt : std::optional(found->second); +} + +void modded_marks_save() +{ + if (marksPath.empty()) return; + JsonLists lists; + for (auto& [key, marks] : moddedMarks) lists[key].assign(marks.begin(), marks.end()); + json_save_write(marksPath, MARKS_SAVE_MEMBER, nullptr, &lists); +} + +// (TryImportNonLocalizedCompletionData) A modded character with a #key name and no marks takes those saved under one +// of its translated names, from before REPENTOGON saved raw names. +static void marks_localized_import() +{ + std::vector& players = g_manager->entityConfig.players; + StringTable& strings = g_manager->stringTable; + + for (int playerType = PLAYER_TYPE_COUNT; playerType < (int)players.size(); playerType++) + { + EntityConfig_Player* owner = marks_owner_get(playerType); + if (!owner || moddedMarks.contains(marks_key_get(*owner)) || !owner->name.starts_with('#')) continue; + + std::string mod = mod_source_id_get(owner->modEntry); + for (int language = 0; language <= LANGUAGE_LAST; language++) + { + bool isMissing = false; + std::string_view name = strings.get_string("Players", language, owner->name.substr(1), &isMissing); + auto found = moddedMarks.find(marks_key_make(mod, name, !owner->bSkinParentName.empty())); + if (isMissing || name.empty() || found == moddedMarks.end()) continue; + moddedMarks[marks_key_get(*owner)] = found->second; + break; + } + } +} + +// (Manager::RecordPlayerCompletion) Gives each modded character in the run the completion's mark, hard on the hard +// difficulties, unless it has it or MC_COMPLETION_MARK_GET refuses it, raising the achievements waiting on it. Only +// while achievements may unlock. Saved when one was given (REPENTOGON saves on every completion). +void modded_marks_record(int completion) +{ + PersistentGameData& data = g_manager->persistentGameData; + if (!g_game || Manager::AchievementUnlocksDisallowed() || data.isReadOnly || completion >= MARK_SET_SIZE) return; + + bool isHard = g_game->difficulty == DIFFICULTY_HARD || g_game->difficulty == DIFFICULTY_GREEDIER; + int mark = isHard ? MARK_HARD : MARK_NORMAL; + bool isRecorded = false; + for (Entity_Player* player : g_game->playerManager.playerList) + { + int playerType = player->playerType; + if (playerType < PLAYER_TYPE_COUNT) continue; + int& kept = modded_marks_get(playerType)[completion]; + if (kept >= mark) continue; + if (!boolean_run({"CompletionMarkGet", MC_COMPLETION_MARK_GET, playerType}, true, completion, playerType)) + continue; + + kept = mark; + isRecorded = true; + achievement_marks_run(completion, playerType); + callback_notify(lua_engine_get(), {"PostCompletionMarkGet", MC_POST_COMPLETION_MARK_GET, playerType}, completion, + playerType); + } + if (isRecorded) modded_marks_save(); +} + +// (GetMarksForPlayer, parity off) A modded character's marks as its widget shows them, none under nomarks. +std::optional modded_marks_shown_get(int playerType) +{ + EntityConfig_Player* owner = marks_owner_get(playerType); + if (repentogonOptions.isVanillaParity || playerType < PLAYER_TYPE_COUNT || !owner) return std::nullopt; + std::string_view noMarks = owner->ex.attribute_get("nomarks"); + if (!noMarks.empty() && noMarks != "false") return std::nullopt; + + return MarksShown{modded_marks_read(playerType), !owner->bSkinParentName.empty()}; +} + +// (Manager::SetSaveSlot) Reads the mods' challenge clears and the modded characters' marks saved for a save file, the +// first for none. +void progress_slot_load(unsigned int slot) +{ + unsigned int shown = std::max(slot, 1u); + challengesPath = json_save_path(std::format("challenges{}.json", shown)); + marksPath = json_save_path(std::format("completionmarks{}.json", shown)); + + challengeClears.clear(); + json_save_load(challengesPath, CHALLENGES_SAVE_MEMBER, &challengeClears, nullptr); + JsonLists lists; + moddedMarks.clear(); + json_save_load(marksPath, MARKS_SAVE_MEMBER, nullptr, &lists); + for (auto& [key, values] : lists) + std::copy_n(values.begin(), std::min(values.size(), (size_t)MARK_SET_SIZE), moddedMarks[key].begin()); + marks_localized_import(); +} diff --git a/src/repentogon/progress.h b/src/repentogon/progress.h new file mode 100644 index 0000000..a1d3eeb --- /dev/null +++ b/src/repentogon/progress.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include +#include + +struct Vector; + +// A character's completion marks by completion type, 0 to 2 (REPENTOGON's CompletionMarks entry). +constexpr int MARK_SET_SIZE = 15; +using MarkSet = std::array; + +// A modded character's marks as its completion widget shows them, and whether its Delirium mark takes the tainted +// frames. +struct MarksShown +{ + MarkSet marks; + bool isTainted = false; +}; + +void progress_slot_load(unsigned int slot); + +void challenges_content_load(); +bool is_challenge_hidden(int id); +bool is_challenge_locked(int id); +bool is_challenge_shown_completed(int id); +std::string challenge_row_name_get(int id); +void challenge_streak_render(int id, int row, std::string_view name, Vector textPosition); +int mod_challenge_clears_get(int id); +std::optional mod_challenge_clears_find(std::string_view mod, std::string_view name); +void mod_challenge_complete(int id); +void mod_challenge_reset(int id); + +MarkSet& modded_marks_get(int playerType); +MarkSet modded_marks_read(int playerType); +std::optional modded_marks_find(std::string_view mod, std::string_view name, bool isTainted); +void modded_marks_save(); +void modded_marks_record(int completion); +std::optional modded_marks_shown_get(int playerType); diff --git a/src/repentogon/render.cpp b/src/repentogon/render.cpp index f6e78e7..ec3df67 100644 --- a/src/repentogon/render.cpp +++ b/src/repentogon/render.cpp @@ -1,4 +1,6 @@ #include "repentogon/render.h" +#include "engine/filesys.h" +#include "engine/kage_graphics.h" #include "entity/player/player.h" #include "level/grid/door.h" #include "level/grid/pit.h" @@ -9,6 +11,42 @@ #include "level/grid/tnt.h" #include "level/room.h" #include "repentogon/callbacks.h" +#include "repentogon/options.h" +#include + +constexpr std::string_view GOLD_SHADER = "ColorOffsetGold"; +constexpr const char* MESA_GOLD_FRAGMENT = "repentogon/resources/shaders/coloroffset_gold_mesafix.fs"; +// coloroffset_gold_mesafix.vs with the rebuild's inputs: the sprite parameters the game's gold shader takes as +// uniforms pass on as the varyings the Mesa fragment reads. +constexpr const char* MESA_GOLD_VERTEX = R"(attribute vec3 Position; +attribute vec4 Color; +attribute vec2 TexCoord; +uniform mat4 ProjectionMatrix; +uniform vec4 Colorize; +uniform vec3 ColorOffset; +uniform vec2 TextureSize; +uniform float PixelationAmount; +uniform vec3 ClipPlane; +varying vec4 Color0; +varying vec2 TexCoord0; +varying vec4 ColorizeOut; +varying vec3 ColorOffsetOut; +varying vec2 TextureSizeOut; +varying float PixelationAmountOut; +varying vec3 ClipPlaneOut; + +void main(void) +{ + ColorizeOut = Colorize; + ColorOffsetOut = ColorOffset; + Color0 = Color; + TextureSizeOut = TextureSize; + PixelationAmountOut = PixelationAmount; + ClipPlaneOut = ClipPlane; + gl_Position = ProjectionMatrix * vec4(Position.xyz, 1.0); + TexCoord0 = TexCoord; +} +)"; // The game's own player types, whose pages and portraits run the character menu's callbacks as REPENTOGON's patches // of the game's drawing do. Modded ones beyond them run them from their mods' drawing. @@ -225,3 +263,16 @@ bool character_page_render(ANM2& sprite, Vector position, int playerType) if (playerType < GAME_PLAYER_TYPE_COUNT) character_page_post(page); return true; } + +// (Patches/MesaShaderFix.cpp) Builds the gold shader from REPENTOGON's coloroffset_gold_mesafix.fs, whose cubic stays +// defined for the negative bases the game's raises to a power, which Mesa leaves undefined. Whether it built it, never +// with vanilla parity on. +bool mesa_shader_load(std::string_view shaderName, std::span attributes) +{ + if (shaderName != GOLD_SHADER || repentogonOptions.isVanillaParity) return false; + + std::ifstream file(asset_path(MESA_GOLD_FRAGMENT)); + std::string fragment(std::istreambuf_iterator(file), {}); + return !fragment.empty() && + KAGE::Graphics::manager.shader_create(shaderName, attributes, {MESA_GOLD_VERTEX, fragment}); +} diff --git a/src/repentogon/render.h b/src/repentogon/render.h index d342980..6762463 100644 --- a/src/repentogon/render.h +++ b/src/repentogon/render.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include class Room; @@ -10,6 +11,11 @@ struct Entity; struct GridEntity; struct Vector; +namespace KAGE::Graphics +{ +struct VertexAttribute; +} + // Which of a sprite's custom shaders replaces the color offset shader: the plain one or the champion one. enum CustomShaderSlot { @@ -38,3 +44,4 @@ bool character_page_pre(CharacterPage page); void character_page_post(CharacterPage page); bool character_page_render(ANM2& sprite, Vector position, int playerType); void custom_shader_select(const ANM2& sprite, const LayerState& layer, CustomShaderSlot slot); +bool mesa_shader_load(std::string_view shaderName, std::span attributes); diff --git a/src/repentogon/repentogon.cpp b/src/repentogon/repentogon.cpp index f1c2302..634b290 100644 --- a/src/repentogon/repentogon.cpp +++ b/src/repentogon/repentogon.cpp @@ -84,8 +84,6 @@ void repentogon_scripts_run(LuaEngine& engine) {"IsVanillaParity", vanilla_parity_get}}); internals_mod_data_register(state); save_state_internals_register(state); - lua_pushboolean(state, IS_REPENTOGON_EXPOSED); - lua_table_set(state, -2, "IsExposed"); lua_namespace_plain_end(state); color_constructor_set(state); diff --git a/src/repentogon/repentogon.h b/src/repentogon/repentogon.h index 42e66da..1d29b1b 100644 --- a/src/repentogon/repentogon.h +++ b/src/repentogon/repentogon.h @@ -7,8 +7,11 @@ struct LuaEngine; struct LuaMod; struct lua_State; -// Whether mods see the REPENTOGON global and its version. It stays off until the whole API is ported, which flips it. -constexpr bool IS_REPENTOGON_EXPOSED = false; +// Whether mods see the REPENTOGON global and its version (repentogon/version.txt, as its release build reports it). +constexpr bool IS_REPENTOGON_EXPOSED = true; + +// Whether the mods' scripts all ran (LuaIsaac.cpp's s_modsLoaded), past which reworks are refused. +inline bool isModsLoaded = false; // Whether the game started shutting down (REPENTOGON's Isaac.IsShuttingDown). inline bool isShuttingDown = false; diff --git a/src/repentogon/save_state_ex.cpp b/src/repentogon/save_state_ex.cpp new file mode 100644 index 0000000..3e3bf63 --- /dev/null +++ b/src/repentogon/save_state_ex.cpp @@ -0,0 +1,263 @@ +#include "repentogon/save_state_ex.h" +#include "engine/platform.h" +#include "entity/pickup/pickup.h" +#include "entity/player/manager.h" +#include "entity/player/player.h" +#include "repentogon/json_save.h" +#include "repentogon/options.h" +#include "simdjson.h" +#include +#include +#include +#include + +// (SaveStateManagement/EntitySaveStateEx.cpp) What REPENTOGON keeps itself on a saved player, familiar or pickup, +// under the same ids as mods' data: a player's twin and innate item groups, a pickup's reroll override. A game state +// file's are written beside it as JSON and read back for its checksum. Only kept while mods' data is. + +constexpr int STATE_FORMAT_VERSION = 1; +constexpr std::string_view STATE_FOLDER = "EntitySaveStateManagement/ex_"; +constexpr std::string_view STATE_EXTENSION = ".json"; + +using InnateGroups = std::map>; + +// A saved entity's state, by its type. +struct EntityStateEx +{ + InnateGroups innateCollectibles; + InnateGroups innateTrinkets; + std::optional canRerollOverride; + int mainTwinIndex = -1; + int type = 0; +}; + +static std::unordered_map entityStates; + +static bool is_type_kept(int type) +{ + return type == ENTITY_PLAYER || type == ENTITY_FAMILIAR || type == ENTITY_PICKUP; +} + +// A state's innate groups without the legacy one (SaveInnateItems). +static InnateGroups innates_copy(const InnateGroups& groups) +{ + InnateGroups copy = groups; + copy.erase(""); + return copy; +} + +// A saved state's groups in place of the player's, its legacy group kept (LoadInnateItems). +static void innates_load(InnateGroups& groups, const InnateGroups& saved) +{ + auto legacy = groups.extract(""); + groups = saved; + if (!legacy.empty() && (!legacy.mapped().persistent.empty() || !legacy.mapped().temporary.empty())) + groups.insert(std::move(legacy)); +} + +void entity_state_ex_save(Entity& entity, uint32_t id) +{ + if (!is_type_kept(entity.type)) return (void)entityStates.erase(id); + + EntityStateEx& state = entityStates[id] = {.type = entity.type}; + if (Entity_Player* player = entity.ToPlayer()) + { + Entity_Player* twin = player->twin_get(); + state.mainTwinIndex = twin ? std::min(player->playerIndex, twin->playerIndex) : -1; + state.innateCollectibles = innates_copy(player->itemSpoofs.collectibles.innates); + state.innateTrinkets = innates_copy(player->itemSpoofs.trinkets.innates); + } + if (entity.type == ENTITY_PICKUP) state.canRerollOverride = ((Entity_Pickup&)entity).canRerollOverride; +} + +// Gives an entity its state back, a missing one restoring the defaults as REPENTOGON's fresh state does. +void entity_state_ex_restore(Entity& entity, uint32_t id) +{ + if (!is_type_kept(entity.type)) return; + EntityStateEx& state = entityStates[id]; + if (state.type != entity.type) state = {.type = entity.type}; + + if (Entity_Player* player = entity.ToPlayer()) + { + player->restoreTwinIndex = state.mainTwinIndex; + innates_load(player->itemSpoofs.collectibles.innates, state.innateCollectibles); + innates_load(player->itemSpoofs.trinkets.innates, state.innateTrinkets); + } + if (entity.type == ENTITY_PICKUP) ((Entity_Pickup&)entity).canRerollOverride = state.canRerollOverride; +} + +void entity_state_ex_clear(uint32_t id) +{ + entityStates.erase(id); +} + +void entity_state_ex_copy(uint32_t source, uint32_t target) +{ + auto found = entityStates.find(source); + if (found == entityStates.end()) return entity_state_ex_clear(target); + EntityStateEx copy = found->second; + entityStates[target] = std::move(copy); +} + +static std::string state_path_get(std::string_view fileName) +{ + return json_save_path(std::string(STATE_FOLDER) + std::string(fileName) + std::string(STATE_EXTENSION)); +} + +// SerializeInnateItems: each named group's live copies, for good or with the frames left. +static std::string innates_serialize(const InnateGroups& groups) +{ + std::string text; + for (auto& [key, group] : groups) + { + std::string items; + for (auto [id, count] : group.persistent) + if (count > 0) items += std::format("{}{{\"id\":{},\"count\":{}}}", items.empty() ? "" : ",", id, count); + for (const TemporaryInnate& item : group.temporary) + if (item.count > 0 && item.timer > 0) + items += std::format("{}{{\"id\":{},\"count\":{},\"timer\":{}}}", items.empty() ? "" : ",", item.id, + item.count, item.timer); + if (key.empty() || items.empty()) continue; + std::string name = key; + std::erase_if(name, [](char letter) { return letter == '"' || letter == '\\'; }); + text += std::format("{}\"{}\":[{}]", text.empty() ? "" : ",", name, items); + } + return text; +} + +static std::string state_serialize(const EntityStateEx& state) +{ + std::string text; + auto member_add = [&text](std::string member) { text += (text.empty() ? "" : ",") + member; }; + + if (state.mainTwinIndex > -1) member_add(std::format("\"mainTwinIndex\":{}", state.mainTwinIndex)); + if (std::string items = innates_serialize(state.innateCollectibles); !items.empty()) + member_add(std::format("\"innateCollectibles\":{{{}}}", items)); + if (std::string items = innates_serialize(state.innateTrinkets); !items.empty()) + member_add(std::format("\"innateTrinkets\":{{{}}}", items)); + if (state.canRerollOverride) member_add(std::format("\"canRerollOverride\":{}", *state.canRerollOverride)); + return text; +} + +// (WriteSaveFile) Writes the states of a game state file's saved entities, each under its place in the file's order. +void entity_states_ex_save(std::string_view fileName, const std::vector& ids, uint32_t checksum) +{ + std::string path = state_path_get(fileName); + std::string states; + for (size_t i = 0; i < ids.size(); i++) + { + auto found = ids[i] ? entityStates.find(ids[i]) : entityStates.end(); + if (found == entityStates.end()) continue; + std::string data = state_serialize(found->second); + if (data.empty()) continue; + states += std::format("{}{{\"ID\":{},\"Type\":{},\"Data\":{{{}}}}}", states.empty() ? "" : ",", i + 1, + found->second.type, data); + } + + std::error_code error; + std::filesystem::create_directories(std::filesystem::path(path).parent_path(), error); + std::ofstream(path) << std::format("{{\"Version\":{},\"Checksum\":{},\"EntitySaveStates\":[{}]}}\n", + STATE_FORMAT_VERSION, checksum, states); +} + +// DeserializeInnateItems: the groups of a JSON object, a malformed item skipped. +static InnateGroups innates_deserialize(simdjson::dom::element element) +{ + InnateGroups groups; + simdjson::dom::object object; + if (element.get_object().get(object) != simdjson::SUCCESS) return groups; + + for (auto [key, value] : object) + { + simdjson::dom::array items; + if (value.get_array().get(items) != simdjson::SUCCESS) continue; + for (simdjson::dom::element item : items) + { + int64_t id = 0; + int64_t count = 0; + int64_t timer = -1; + if (item["id"].get_int64().get(id) || item["count"].get_int64().get(count)) continue; + simdjson::dom::element timerElement; + if (!item["timer"].get(timerElement) && (timerElement.get_int64().get(timer) || timer <= 0)) continue; + if (count <= 0) continue; + + InnateGroup& group = groups[std::string(key)]; + if (timer > 0) group.temporary.push_back({(int)count, (int)id, (int)timer}); + else group.persistent[(int)id] += (int)count; + } + } + return groups; +} + +// (LoadSaveFile) Reads back the states of a game state file's saved entities, for its checksum, every older state +// dropped. +void entity_states_ex_load(std::string_view fileName, const std::vector& ids, uint32_t checksum) +{ + entityStates.clear(); + std::string path = state_path_get(fileName); + std::error_code error; + if (!std::filesystem::exists(path, error)) return; + + simdjson::dom::parser parser; + simdjson::dom::object root; + simdjson::dom::array states; + int64_t version = 0; + int64_t written = 0; + if (parser.load(path).get_object().get(root)) return; + if (root["Version"].get_int64().get(version) || version != STATE_FORMAT_VERSION) + return log_printf(LOG_INFO, "[EntitySaveStateEx] [ERROR] - State version mismatch, data will not be loaded.\n"); + if (root["Checksum"].get_int64().get(written) || (uint32_t)written != checksum) + return log_printf(LOG_INFO, "[EntitySaveStateEx] [ERROR] - Checksum mismatch, data will not be loaded.\n"); + if (root["EntitySaveStates"].get_array().get(states)) return; + + for (simdjson::dom::element entry : states) + { + int64_t serializeId = 0; + int64_t type = 0; + simdjson::dom::object data; + if (entry["ID"].get_int64().get(serializeId) || serializeId < 1 || (size_t)serializeId > ids.size()) continue; + if (entry["Type"].get_int64().get(type) || entry["Data"].get_object().get(data)) continue; + if (!is_type_kept((int)type) || !ids[serializeId - 1]) continue; + + EntityStateEx& state = entityStates[ids[serializeId - 1]] = {.type = (int)type}; + int64_t twinIndex = -1; + bool isRerollable = false; + if (!data["mainTwinIndex"].get_int64().get(twinIndex)) state.mainTwinIndex = (int)twinIndex; + if (!data["canRerollOverride"].get_bool().get(isRerollable)) state.canRerollOverride = isRerollable; + simdjson::dom::element groups; + if (!data["innateCollectibles"].get(groups)) state.innateCollectibles = innates_deserialize(groups); + if (!data["innateTrinkets"].get(groups)) state.innateTrinkets = innates_deserialize(groups); + } +} + +void entity_states_ex_delete(std::string_view fileName) +{ + std::error_code error; + std::filesystem::remove(state_path_get(fileName), error); +} + +// (ASMPlayerManager.cpp's RestoreGameState hook) Links again the players saved as twins: each pair sharing the main +// twin's index they were saved with. Only without vanilla parity. +void twins_restore(PlayerManager& manager) +{ + std::vector& players = manager.playerList; + if (repentogonOptions.isVanillaParity) return; + + for (size_t i = 0; i < players.size(); i++) + { + Entity_Player* player = players[i]; + if (player->restoreTwinIndex < 0) continue; + for (size_t j = i + 1; j < players.size(); j++) + { + Entity_Player* other = players[j]; + if (other->restoreTwinIndex != player->restoreTwinIndex) continue; + log_printf(LOG_INFO, "[ASMPlayerManager] Restoring twin relationship for players %d and %d\n", + player->playerIndex, other->playerIndex); + player->twinPlayer = other; + other->twinPlayer = player; + player->restoreTwinIndex = -1; + other->restoreTwinIndex = -1; + break; + } + } +} diff --git a/src/repentogon/save_state_ex.h b/src/repentogon/save_state_ex.h new file mode 100644 index 0000000..2fa4717 --- /dev/null +++ b/src/repentogon/save_state_ex.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include +#include + +struct Entity; +class PlayerManager; + +void entity_state_ex_save(Entity& entity, uint32_t id); +void entity_state_ex_restore(Entity& entity, uint32_t id); +void entity_state_ex_clear(uint32_t id); +void entity_state_ex_copy(uint32_t source, uint32_t target); +void entity_states_ex_save(std::string_view fileName, const std::vector& ids, uint32_t checksum); +void entity_states_ex_load(std::string_view fileName, const std::vector& ids, uint32_t checksum); +void entity_states_ex_delete(std::string_view fileName); +void twins_restore(PlayerManager& manager); diff --git a/src/repentogon/save_state_manager.cpp b/src/repentogon/save_state_manager.cpp index 904f832..2913a4d 100644 --- a/src/repentogon/save_state_manager.cpp +++ b/src/repentogon/save_state_manager.cpp @@ -1,4 +1,6 @@ #include "repentogon/save_state_manager.h" +#include "repentogon/custom_pools.h" +#include "repentogon/pool_items.h" #include "entity/save_state.h" #include "game/game.h" #include "game/manager.h" @@ -6,6 +8,7 @@ #include "repentogon/callbacks.h" #include "repentogon/entities.h" #include "repentogon/repentogon.h" +#include "repentogon/save_state_ex.h" #include "repentogon/ui_patches.h" #include #include @@ -253,13 +256,16 @@ uint32_t save_state_id_make() void save_state_id_clear(uint32_t id) { - if (is_save_state_managed()) binding_call(BINDING_CLEAR_STATES, std::vector{id}); + if (!is_save_state_managed()) return; + entity_state_ex_clear(id); + binding_call(BINDING_CLEAR_STATES, std::vector{id}); } uint32_t save_state_id_copy(uint32_t id) { if (!is_save_state_managed()) return 0; uint32_t copy = save_state_id_make(); + entity_state_ex_copy(id, copy); binding_call(BINDING_COPY_STATES, std::vector{id}, std::vector{copy}); return copy; } @@ -287,6 +293,7 @@ void entity_store_notify(Entity& entity, SaveStateId& id) { if (!is_save_state_managed()) return unfiltered_notify("EntitySave", MC_ENTITY_SAVE, &entity); id.renew(); + entity_state_ex_save(entity, id.id); binding_call(BINDING_STORE_ENTITY, &entity, entity_id_get(entity), id.id); } @@ -294,6 +301,7 @@ void entity_store_notify(Entity& entity, SaveStateId& id) void entity_restore_notify(Entity& entity, uint32_t id) { if (!is_save_state_managed()) return unfiltered_notify("EntityRestore", MC_ENTITY_RESTORE, &entity); + entity_state_ex_restore(entity, id); binding_call(BINDING_RESTORE_ENTITY, &entity, entity_id_get(entity), id); } @@ -324,6 +332,8 @@ void game_state_restore_notify(int slot) void game_state_clear_notify(GameState& state) { int slot = game_state_slot_get(state); + pool_items_clear(slot); + custom_pools_clear(slot); if (slot >= 0 && is_save_state_managed()) binding_call(BINDING_CLEAR_GAME_STATE, slot); } @@ -346,6 +356,9 @@ static std::string game_state_file_name(GameState& state, GameStateFile file) void game_state_delete_notify(GameState& state, GameStateFile file) { std::string name = game_state_file_name(state, file); + if (!name.empty() && file == GAME_STATE_FILE_RUN) pool_items_delete(name); + if (!name.empty() && file == GAME_STATE_FILE_RUN) custom_pools_delete(name); + if (!name.empty()) entity_states_ex_delete(name); if (!name.empty() && is_save_state_managed()) binding_call(BINDING_DELETE_GAME_STATE, name); } @@ -374,8 +387,11 @@ void game_state_write_end(GameState& state, GameStateFile file) { std::optional> ids = std::exchange(bindings.collected, std::nullopt); std::string name = game_state_file_name(state, file); + if (!name.empty() && file == GAME_STATE_FILE_RUN) pool_items_save(name, state.checksum); + if (!name.empty() && file == GAME_STATE_FILE_RUN) custom_pools_save(name, state.checksum); if (!ids || name.empty()) return; + entity_states_ex_save(name, *ids, state.checksum); binding_call(BINDING_SERIALIZE, *ids, name, state.checksum); binding_call(BINDING_SERIALIZE_GAME_STATE, GameStateInfo{name, state.checksum}); } @@ -386,6 +402,8 @@ void game_state_read_end(GameState& state, GameStateFile file, bool isRead) { std::optional> ids = std::exchange(bindings.collected, std::nullopt); std::string name = game_state_file_name(state, file); + if (isRead && !name.empty() && file == GAME_STATE_FILE_RUN) pool_items_read(name, state.checksum); + if (isRead && !name.empty() && file == GAME_STATE_FILE_RUN) custom_pools_read(name, state.checksum); if (!ids || !isRead || name.empty()) return; ModTables tables; @@ -398,6 +416,7 @@ void game_state_read_end(GameState& state, GameStateFile file, bool isRead) modIds.push_back(mod.scriptPath); } binding_call(BINDING_PRE_DESERIALIZE, tables, modIds); + entity_states_ex_load(name, *ids, state.checksum); std::vector serializedIds(ids->size()); std::iota(serializedIds.begin(), serializedIds.end(), 1); diff --git a/src/repentogon/saves.cpp b/src/repentogon/saves.cpp index a0231b7..1e50b01 100644 --- a/src/repentogon/saves.cpp +++ b/src/repentogon/saves.cpp @@ -3,17 +3,23 @@ #include "game/manager.h" #include "repentogon/achievements.h" #include "repentogon/callbacks.h" +#include "repentogon/custom_pools.h" +#include "repentogon/pool_items.h" #include // (GameStateManagement.cpp) Runs a callback around a save or restore of a game state the game keeps, the save file's // or a Glowing Hourglass slot's, then for a slot its hourglass callback with the slot. Mods' game data is restored -// before and kept after. +// before and kept after, the pools' temporary items kept and restored first. void game_state_callbacks_run(GameState& state, int callback, int hourglassCallback) { int slot = game_state_slot_get(state); if (slot < 0) return; if (callback == MC_PRE_GAME_STATE_RESTORE) game_state_restore_notify(slot); + if (callback == MC_POST_GAME_STATE_SAVE) pool_items_store(slot); + if (callback == MC_POST_GAME_STATE_RESTORE) pool_items_restore(slot); + if (callback == MC_POST_GAME_STATE_SAVE) custom_pools_store(slot); + if (callback == MC_POST_GAME_STATE_RESTORE) custom_pools_restore(slot); unfiltered_notify("GameState", callback); if (slot > 0) unfiltered_notify("GlowingHourglass", hourglassCallback, slot - 1); if (callback == MC_POST_GAME_STATE_SAVE) game_state_store_notify(slot); diff --git a/src/repentogon/ui_patches.cpp b/src/repentogon/ui_patches.cpp index 42f2427..9c0b343 100644 --- a/src/repentogon/ui_patches.cpp +++ b/src/repentogon/ui_patches.cpp @@ -1,5 +1,6 @@ #include "repentogon/ui_patches.h" #include "engine/anm2.h" +#include "engine/filesys.h" #include "engine/harness.h" #include "engine/kage_graphics.h" #include "engine/platform.h" @@ -34,6 +35,41 @@ constexpr float ERROR_BOX_HEIGHT = 18; constexpr float ERROR_CLICK_TEXT_Y = 7; constexpr float ERROR_HOVER_TINT = 0.5f; +// Patches/ASMPatches/ASMLocalization.cpp: Repentance's language archives, which Repentance+'s own translations outdate, +// and the only files of theirs still mounted, the Japanese, Korean and Chinese fonts. +constexpr std::array LANGUAGE_ARCHIVES = { + "packed/repentance_de.a", "packed/repentance_es.a", "packed/repentance_fr.a", "packed/repentance_ru.a", + "packed/repentance_jp.a", "packed/repentance_kr.a", "packed/repentance_zh.a"}; +constexpr std::array LANGUAGE_ARCHIVE_FONTS = { + "resources.jp/font/mplus_10r.fnt", + "resources.jp/font/mplus_10r_0.png", + "resources.jp/font/mplus_12b.fnt", + "resources.jp/font/mplus_12b_0.png", + "resources.kr/font/kr_font12.fnt", + "resources.kr/font/kr_font12_0.png", + "resources.kr/font/kr_font12_1.png", + "resources.kr/font/kr_font12_2.png", + "resources.kr/font/kr_font12_3.png", + "resources.kr/font/kr_font12_4.png", + "resources.kr/font/kr_font14.fnt", + "resources.kr/font/kr_font14_0.png", + "resources.kr/font/kr_font14_1.png", + "resources.kr/font/kr_meatfont14.fnt", + "resources.kr/font/kr_meatfont14_0.png", + "resources.kr/font/kr_meatfont14_1.png", + "resources.zh/font/teammeatfontextended10.fnt", + "resources.zh/font/teammeatfontextended10_0.png", + "resources.zh/font/teammeatfontextended10_1.png", + "resources.zh/font/teammeatfontextended12.fnt", + "resources.zh/font/teammeatfontextended12_0.png", + "resources.zh/font/teammeatfontextended12_1.png", + "resources.zh/font/teammeatfontextended16bold.fnt", + "resources.zh/font/teammeatfontextended16bold_0.png", + "resources.zh/font/teammeatfontextended16bold_1.png", + "resources.zh/font/upheavalextended.fnt", + "resources.zh/font/upheavalextended_0.png", + "resources.zh/font/upheavalextended_1.png"}; + // Patches/CutsceneSkip.cpp: whether the first cutscene SkipIntro let through was skipped, and whether the menu still // has to take the black it fades in from. static bool isFirstCutsceneSkipped = false; @@ -246,3 +282,11 @@ void cursor_render_post(Manager& manager) { manager.cursorSprite.color = cursorColor; } + +// (ASMLocalization.cpp's LoadArchiveFile patch) Leaves only the fonts of Repentance's language archives mounted, the +// rest falling back to English, parity off. +void language_archives_restrict() +{ + if (repentogonOptions.isVanillaParity) return; + for (std::string_view archive : LANGUAGE_ARCHIVES) archive_files_restrict(archive, LANGUAGE_ARCHIVE_FONTS); +} diff --git a/src/repentogon/ui_patches.h b/src/repentogon/ui_patches.h index 3e8bad6..099cf68 100644 --- a/src/repentogon/ui_patches.h +++ b/src/repentogon/ui_patches.h @@ -10,6 +10,8 @@ struct AnimationState; struct Entity_Laser; class Manager; class MenuManager; +class Menu_Mods; +struct Vector; // REPENTOGON's changes to the menus, the HUD, rendering and debugging (its Patches/), each behind its option (where it // has one) and the parity switch. @@ -17,6 +19,7 @@ bool is_cutscene_skipped(); void intro_skip_fade(MenuManager& menu); void save_slot_remember(uint32_t slot); void quickstart_try(Manager& manager); +void language_archives_restrict(); bool is_planetarium_chance_shown(); float planetarium_chance_get(); @@ -30,4 +33,11 @@ void cursor_render_post(Manager& manager); const AnimationFrame& frame_interpolate(const AnimationLayer& layer, int frameIndex, const ANM2& animation, AnimationFrame& lerped); +bool is_mods_menu_reworked(); +bool is_mods_search_active(); +bool mods_menu_update_pre(Menu_Mods& menu); +void mods_menu_update_post(Menu_Mods& menu, int previousSelected); +void mods_menu_render(Menu_Mods& menu, Vector origin); +void mods_menu_widget_hide(Menu_Mods& menu); + extern bool isQuickstartAsked; diff --git a/src/repentogon/vanilla_fixes.cpp b/src/repentogon/vanilla_fixes.cpp index 70e24b8..49729c7 100644 --- a/src/repentogon/vanilla_fixes.cpp +++ b/src/repentogon/vanilla_fixes.cpp @@ -7,6 +7,7 @@ #include "game/game.h" #include "game/manager.h" #include "level/room.h" +#include "level/room_config.h" #include "repentogon/options.h" #include #include @@ -27,6 +28,8 @@ constexpr const char* SELF_COMMAND_LINE = "/proc/self/cmdline"; constexpr const char* SELF_EXECUTABLE = "/proc/self/exe"; constexpr uint32_t ECO_SLEEP_MS = 5; constexpr uint32_t ECO_SLEEP_IDLE_MS = 333; +constexpr uint32_t DOUBLE_TROUBLE_VARIANT_FIRST = 3700; +constexpr uint32_t DOUBLE_TROUBLE_VARIANT_END = 3850; // (VanillaTweaks.cpp) Whether a console command is refused in a daily run that is not practice. bool is_daily_command_refused() @@ -130,3 +133,15 @@ void knife_homing_path_init(Entity_Knife& knife) Entity* parent = knife.parent.get(); knife.InitHomingPath(knife.velocity, parent ? parent : &knife, knife.pathOffset); } + +// (MiscFixes.cpp) After the mods' special rooms are merged, holds every Double Trouble boss variant taken, so a mod's +// boss room is never moved into that range by accident. Mods' own Double Trouble rooms move out of it too. +void double_trouble_variants_reserve(int stageId, int mode) +{ + if (repentogonOptions.isVanillaParity || !g_game || stageId != STAGE_ID_SPECIAL_ROOMS || mode != ROOM_MODE_NORMAL) + return; + + RoomConfig_VariantSet& variants = g_game->roomConfig.stages[stageId].rooms[mode].GetVariantSet(ROOM_BOSS); + for (uint32_t variant = DOUBLE_TROUBLE_VARIANT_FIRST; variant < DOUBLE_TROUBLE_VARIANT_END; variant++) + variants.Add(variant); +} diff --git a/src/repentogon/vanilla_fixes.h b/src/repentogon/vanilla_fixes.h index 1495a8d..d488d72 100644 --- a/src/repentogon/vanilla_fixes.h +++ b/src/repentogon/vanilla_fixes.h @@ -10,6 +10,7 @@ struct EntityConfig_Entity; struct Room; bool is_daily_command_refused(); +void double_trouble_variants_reserve(int stageId, int mode); bool is_crawlspace_refused(Room& room); bool is_entity_config_matched(EntityConfig_Entity& config, int id, int variant, int subtype); bool is_game_restarted(); diff --git a/src/repentogon/virtual_rooms.cpp b/src/repentogon/virtual_rooms.cpp new file mode 100644 index 0000000..374756b --- /dev/null +++ b/src/repentogon/virtual_rooms.cpp @@ -0,0 +1,385 @@ +// REPENTOGON's virtual rooms (VirtualRoomConfig/VirtualRoomSetManager.cpp, RoomConfigUtility.cpp's Lua room reader, +// LuaRoomConfig.cpp's and LuaRoomConfigSet.cpp's AddRooms and LoadStb): rooms mods add to a stage's room set at run +// time, from Lua tables or their own .stb files, kept beside the game's rooms for the session. Lookups, room picks +// and weight resets see them after the game's own. Each takes a variant its set does not hold yet, so a saved run +// (which names rooms by stage, type and variant) finds it again once the mod adds it again. +// REPENTOGON also writes the added rooms beside the save file to restore them without the mod. The rebuild resolves +// them by id. Without mods every room set is the game's. +#include "repentogon/virtual_rooms.h" +#include "engine/log.h" +#include "game/game.h" +#include "game/manager.h" +#include "game/mod_manager.h" +#include "level/generator.h" +#include "level/room.h" +#include "repentogon/api.h" +#include "repentogon/api_level.h" +#include +#include + +constexpr int ROOM_TYPE_END = ROOM_ULTRASECRET + 1; +constexpr int DIFFICULTY_DEFAULT = 1; +constexpr uint32_t QUEST_DOOR_VARIANT = 2; +constexpr uint32_t ENTITY_ENVIRONMENT_TYPE = 970; +constexpr uint32_t PRESSURE_PLATE_TYPE = 4500; +constexpr std::string_view ROOMS_FOLDER = "rooms/"; +// RoomConfigUtility's shape dimensions: a room's width and height by its shape. +constexpr std::array, ROOMSHAPE_ANY> SHAPE_DIMENSIONS = { + {{0, 0}, {13, 7}, {13, 3}, {5, 7}, {13, 14}, {5, 14}, {26, 7}, {26, 3}, {26, 14}, {26, 14}, {26, 14}, {26, 14}, + {26, 14}}}; + +// Every virtual room (the room chunks, which never move one) and each stage's sets in both modes. +static std::deque rooms; +static std::array, 2>, STAGE_SLOTS> roomSets; + +static RoomMode mode_resolve(int mode) +{ + if (mode != ROOM_MODE_CURRENT) return (RoomMode)mode; + return g_game && g_game->IsGreedMode() ? ROOM_MODE_GREED : ROOM_MODE_NORMAL; +} + +// (Init, the ModManager::LoadConfigs hook) Forgets every virtual room, as the mods load again. +void virtual_rooms_clear() +{ + for (auto& modes : roomSets) + for (std::vector& set : modes) set.clear(); + rooms.clear(); +} + +// (The GetRoomByStageTypeAndVariant hook) A virtual room by type and variant, when the game's set lacks it. +RoomConfig_Room* virtual_room_find(int stageId, int type, int variant, RoomMode mode) +{ + if (stageId < 0 || stageId >= STAGE_SLOTS) return nullptr; + for (RoomConfig_Room* room : roomSets[stageId][mode_resolve(mode)]) + if (room->type == type && room->variant == variant) return room; + return nullptr; +} + +// (The GetRooms hook, RoomPassesFilter) Adds the virtual rooms a query matches after the game's. +void virtual_rooms_filter(const RoomQuery& query, std::vector& found) +{ + if (query.stageId < 0 || query.stageId >= STAGE_SLOTS) return; + bool isPlateBanned = g_game && g_game->seedEffects.HasSeedEffect(SEED_G_FUEL); + for (RoomConfig_Room* room : roomSets[query.stageId][mode_resolve(query.mode)]) + { + bool isShape = query.shape == ROOMSHAPE_ANY || room->shape == query.shape; + bool isVariant = (uint32_t)room->variant >= query.minVariant && (uint32_t)room->variant <= query.maxVariant; + bool isDifficulty = room->difficulty >= query.minDifficulty && room->difficulty <= query.maxDifficulty; + bool isDoors = (room->doors & query.requiredDoors) == query.requiredDoors; + bool isSubtype = query.subtype == -1 || room->subtype == query.subtype; + bool isPlate = isPlateBanned && (room->flags & ROOM_FLAG_PRESSURE_PLATE); + if (room->type == query.type && isShape && isVariant && isDifficulty && isDoors && isSubtype && !isPlate) + found.push_back(room); + } +} + +// (The ResetRoomWeights hook) A set's virtual rooms get their weights back. +void virtual_rooms_weights_reset(int stageId, RoomMode mode) +{ + for (RoomConfig_Room* room : roomSets[stageId][mode_resolve(mode)]) room->weight = room->initialWeight; +} + +// (The Game::Exit hook) Every virtual room gets its weight back. +void virtual_rooms_weights_reset_all() +{ + for (RoomConfig_Room& room : rooms) room.weight = room.initialWeight; +} + +// (commit_vanilla_room_set_insertion) Files rooms under their stage and mode, each taking its own variant when its set +// lacks it, else the one past the type's first range. +static void rooms_commit(std::vector& set, size_t begin, int stageId, RoomMode mode) +{ + RoomSet& vanilla = g_game->roomConfig.stages[stageId].rooms[mode]; + for (size_t i = begin; i < set.size(); i++) + { + RoomConfig_Room& room = *set[i]; + RoomConfig_VariantSet& variants = vanilla.GetVariantSet(room.type); + room.stageId = stageId; + room.mode = mode; + room.variant = room.originalVariant; + if (variants.Add((uint32_t)room.variant)) continue; + room.variant = (int)variants.ranges.front().upperBound + 1; + variants.Add((uint32_t)room.variant); + } +} + +// (The LoadStageBinary hook) A set loaded again files its virtual rooms' variants again. +void virtual_rooms_commit(int stageId, RoomMode mode) +{ + rooms_commit(roomSets[stageId][mode_resolve(mode)], 0, stageId, mode_resolve(mode)); +} + +// LogUtility's field readers: a field's value, none when missing (an error for a required one) or of the wrong type. +template +static std::optional field_read(lua_State* state, int index, const char* name, std::vector& errors, + bool isRequired = false) +{ + lua_getfield(state, index, name); + std::optional value; + bool isNil = lua_isnil(state, -1); + int isNumber = 0; + if constexpr (std::is_same_v) + { + if (lua_isboolean(state, -1)) value = (bool)lua_toboolean(state, -1); + } + else if constexpr (std::is_same_v) + { + if (lua_type(state, -1) == LUA_TSTRING) value = lua_tostring(state, -1); + } + else if constexpr (std::is_floating_point_v) + { + lua_Number number = lua_tonumberx(state, -1, &isNumber); + if (isNumber) value = (T)number; + } + else + { + lua_Integer number = lua_tointegerx(state, -1, &isNumber); + if (isNumber) value = (T)number; + } + if (!value && (!isNil || isRequired)) + errors.push_back(std::format("invalid argument for \"{}\" ({})", name, lua_typename(state, lua_type(state, -1)))); + lua_pop(state, 1); + return value; +} + +// GetDoorSlotFromLua: a door entry's slot when it exists, by its SLOT if the shape has it, else by its grid position. +static int door_slot_read(lua_State* state, int index, RoomShape shape, std::vector& errors) +{ + if (!field_read(state, index, "EXISTS", errors).value_or(false)) return DOOR_NONE; + std::optional slot = field_read(state, index, "SLOT", errors); + if (slot && LevelGenerator::has_shape_slot(shape, (int)*slot, THIN_SHAPES_RESTRICTED)) return (int)*slot; + if (slot) errors.push_back(std::format("provided door slot is invalid for shape {}: {}", (int)shape, *slot)); + + std::optional x = field_read(state, index, "GRIDX", errors, true); + std::optional y = field_read(state, index, "GRIDY", errors, true); + if (!x || !y) return DOOR_NONE; + int door = RoomConfig::get_door_from_position(*x, *y, shape); + if (door <= DOOR_NONE || door >= DOOR_SLOT_COUNT) + errors.push_back(std::format("door slot position is invalid for shape {}: ({}, {})", (int)shape, *x, *y)); + return door <= DOOR_NONE || door >= DOOR_SLOT_COUNT ? DOOR_NONE : door; +} + +// BuildSpawnFromLua: a spawn point's position and its entries, each counted into the room's quest doors and plates. +static std::optional spawn_read(lua_State* state, int index, RoomConfig_Room& room, + std::vector& errors) +{ + std::optional x = field_read(state, index, "GRIDX", errors, true); + std::optional y = field_read(state, index, "GRIDY", errors, true); + if (!x || !y) return std::nullopt; + + RoomSpawn spawn = {.x = *x, .y = *y}; + for (lua_Integer i = 1; i <= (lua_Integer)lua_rawlen(state, index); i++) + { + lua_rawgeti(state, index, i); + int entryIndex = lua_absindex(state, -1); + std::optional type = lua_istable(state, entryIndex) + ? field_read(state, entryIndex, "TYPE", errors, true) + : std::nullopt; + if (type) + { + RoomEntry& entry = spawn.entries.emplace_back(RoomEntry{.type = (uint32_t)*type}); + entry.variant = (uint16_t)field_read(state, entryIndex, "VARIANT", errors).value_or(0); + entry.subtype = (uint16_t)field_read(state, entryIndex, "SUBTYPE", errors).value_or(0); + entry.weight = std::max(field_read(state, entryIndex, "WEIGHT", errors).value_or(0), 0.0f); + spawn.sumWeights += entry.weight; + int door = RoomConfig::get_door_from_position(spawn.x, spawn.y, room.shape); + if (entry.type == ENTITY_ENVIRONMENT_TYPE && entry.variant == QUEST_DOOR_VARIANT && door != DOOR_NONE) + room.questDoors |= 1u << door; + if (entry.type == PRESSURE_PLATE_TYPE && entry.variant == 0) room.flags |= ROOM_FLAG_PRESSURE_PLATE; + } + else errors.push_back(std::format("spawn entry #{} -> unable to build spawn entry.", i)); + lua_pop(state, 1); + } + return spawn; +} + +// BuildRoomFromLua: a room from a Lua table of its TYPE, VARIANT, NAME and SHAPE (needed), SUBTYPE, DIFFICULTY and +// WEIGHT, and its spawns and doors in order. A room type or shape out of range falls back to the default ones, and +// the shape's own dimensions are used. +static std::optional room_read(lua_State* state, int index, std::vector& errors) +{ + index = lua_absindex(state, index); + if (!lua_istable(state, index)) + { + errors.push_back(std::format("invalid argument (table expected, got {})", luaL_typename(state, index))); + return std::nullopt; + } + std::optional type = field_read(state, index, "TYPE", errors, true); + std::optional variant = field_read(state, index, "VARIANT", errors, true); + std::optional name = field_read(state, index, "NAME", errors, true); + std::optional shape = field_read(state, index, "SHAPE", errors, true); + if (!type || !variant || !name || !shape) return std::nullopt; + + RoomConfig_Room room; + room.type = *type >= ROOM_DEFAULT && *type < ROOM_TYPE_END ? *type : ROOM_DEFAULT; + room.shape = *shape > ROOMSHAPE_NULL && *shape < ROOMSHAPE_ANY ? (RoomShape)*shape : ROOMSHAPE_1x1; + if (room.type != *type) errors.push_back(std::format("invalid argument for \"TYPE\" (invalid room type {})", *type)); + if (room.shape != *shape) errors.push_back(std::format("invalid argument for \"SHAPE\" (invalid room shape {})", *shape)); + room.originalVariant = room.variant = (int)*variant; + room.subtype = field_read(state, index, "SUBTYPE", errors).value_or(0); + room.difficulty = field_read(state, index, "DIFFICULTY", errors).value_or(DIFFICULTY_DEFAULT); + room.name = *name; + room.initialWeight = room.weight = std::max(field_read(state, index, "WEIGHT", errors).value_or(0), 0.0f); + std::tie(room.width, room.height) = SHAPE_DIMENSIONS[room.shape]; + room.flags = 0; + + for (lua_Integer i = 1; i <= (lua_Integer)lua_rawlen(state, index); i++) + { + lua_rawgeti(state, index, i); + int spawnIndex = lua_absindex(state, -1); + if (!lua_istable(state, spawnIndex)) errors.push_back(std::format("spawn #{} -> table expected", i)); + else if (field_read(state, spawnIndex, "ISDOOR", errors).value_or(false)) + { + int door = door_slot_read(state, spawnIndex, room.shape, errors); + if (door != DOOR_NONE) room.doors |= 1u << door; + } + else if (std::optional spawn = spawn_read(state, spawnIndex, room, errors)) + room.spawns.push_back(std::move(*spawn)); + else errors.push_back(std::format("spawn #{} -> unable to build spawn.", i)); + lua_pop(state, 1); + } + return room; +} + +// The set a stage id and mode name, raising REPENTOGON's argument errors for either out of range. +static std::pair set_check(lua_State* state, int stageIndex) +{ + lua_Integer stageId = luaL_checkinteger(state, stageIndex); + lua_Integer mode = luaL_checkinteger(state, stageIndex + 1); + if (stageId < 0 || stageId >= STAGE_SLOTS) + luaL_argerror(state, stageIndex, std::format("invalid stage {}", stageId).c_str()); + if (mode < ROOM_MODE_CURRENT || mode > ROOM_MODE_GREED) + luaL_argerror(state, stageIndex + 1, std::format("invalid mode {}", stageId).c_str()); + return {(int)stageId, mode_resolve((int)mode)}; +} + +// The stage and mode of a RoomConfigSet's room set. +static std::pair set_locate(RoomSet* set) +{ + for (int stageId = 0; stageId < STAGE_SLOTS; stageId++) + for (int mode : {ROOM_MODE_NORMAL, ROOM_MODE_GREED}) + if (&g_game->roomConfig.stages[stageId].rooms[mode] == set) return {stageId, (RoomMode)mode}; + return {0, ROOM_MODE_NORMAL}; +} + +// The set's game rooms load before rooms join it. +static std::vector& set_ready(int stageId, RoomMode mode) +{ + if (!g_game->roomConfig.stages[stageId].rooms[mode].isLoaded) g_game->roomConfig.LoadStageBinary(stageId, mode); + return roomSets[stageId][mode]; +} + +// Lua_AddLuaRooms: each table of the list made a room and added, the list of the rooms back with nil for each that +// failed. Problems are logged. +static int lua_rooms_add(lua_State* state, int stageId, RoomMode mode, int tableIndex) +{ + std::vector& set = set_ready(stageId, mode); + size_t begin = set.size(); + size_t count = lua_rawlen(state, tableIndex); + std::vector isBuilt(count); + for (size_t i = 0; i < count; i++) + { + std::vector errors; + lua_rawgeti(state, tableIndex, (lua_Integer)i + 1); + std::optional room = room_read(state, -1, errors); + lua_pop(state, 1); + for (const std::string& error : errors) + log_printf(LOG_INFO, "[ERROR] [VirtualRoomSetManager] - room #%d -> %s\n", (int)i + 1, error.c_str()); + if (!room) continue; + set.push_back(&rooms.emplace_back(std::move(*room))); + isBuilt[i] = true; + } + rooms_commit(set, begin, stageId, mode); + + lua_createtable(state, (int)count, 0); + for (size_t i = 0, placed = begin; i < count; i++) + { + if (isBuilt[i]) lua_push(state, set[placed++]); + else lua_pushnil(state); + lua_rawseti(state, -2, (lua_Integer)i + 1); + } + return 1; +} + +// Lua_AddStbRooms: the rooms of every loaded mod's content/rooms/ added, those of a valid room type, the list +// of them back. +static int stb_rooms_add(lua_State* state, int stageId, RoomMode mode, std::string_view fileName) +{ + std::vector& set = set_ready(stageId, mode); + size_t begin = set.size(); + log_printf(LOG_INFO, "[INFO] [VirtualRoomSetManager] - Adding Rooms from `/content/rooms/%s`\n", + std::string(fileName).c_str()); + for (auto& mod : g_manager->modManager.mods) + { + if (!mod->isLoaded) continue; + std::optional> read = + stb_rooms_read(mod->GetContentPath(std::string(ROOMS_FOLDER) + std::string(fileName)), stageId); + for (RoomConfig_Room& room : read ? *read : std::vector{}) + if (room.type >= ROOM_DEFAULT && room.type < ROOM_TYPE_END) set.push_back(&rooms.emplace_back(std::move(room))); + } + rooms_commit(set, begin, stageId, mode); + lua_createtable(state, (int)(set.size() - begin), 0); + for (size_t i = begin; i < set.size(); i++) + { + lua_push(state, set[i]); + lua_rawseti(state, -2, (lua_Integer)(i - begin) + 1); + } + return 1; +} + +// RoomConfig.AddRooms(stage, mode, rooms) and LoadStb(stage, mode, file). +static int room_config_rooms_add(lua_State* state) +{ + auto [stageId, mode] = set_check(state, 1); + if (!lua_istable(state, 3)) return luaL_argerror(state, 3, "table expected"); + return lua_rooms_add(state, stageId, mode, 3); +} + +static int room_config_stb_load(lua_State* state) +{ + auto [stageId, mode] = set_check(state, 1); + return stb_rooms_add(state, stageId, mode, luaL_checkstring(state, 3)); +} + +// RoomConfigSet:AddRooms(rooms) and LoadStb(file). +static int room_set_rooms_add(lua_State* state) +{ + auto [stageId, mode] = set_locate(lua_get(state, 1).set); + if (!lua_istable(state, 2)) return luaL_argerror(state, 2, "table expected"); + return lua_rooms_add(state, stageId, mode, 2); +} + +static int room_set_stb_load(lua_State* state) +{ + auto [stageId, mode] = set_locate(lua_get(state, 1).set); + return stb_rooms_add(state, stageId, mode, luaL_checkstring(state, 2)); +} + +// A RoomConfigSet's size and its room at an index from 0: the game's rooms, then its virtual ones. +int virtual_room_set_size(RoomSet& set) +{ + auto [stageId, mode] = set_locate(&set); + return (int)(set.configs.size() + roomSets[stageId][mode].size()); +} + +RoomConfig_Room* virtual_room_set_get(RoomSet& set, long long index) +{ + auto [stageId, mode] = set_locate(&set); + std::vector& added = roomSets[stageId][mode]; + if (index < 0) return nullptr; + if (index < (lua_Integer)set.configs.size()) return &set.configs[index]; + index -= (lua_Integer)set.configs.size(); + return index < (lua_Integer)added.size() ? added[index] : nullptr; +} + +// Adds AddRooms and LoadStb to the RoomConfig namespace, begun last. +void virtual_rooms_room_config_register(lua_State* state) +{ + lua_functions_add(state, {{"AddRooms", room_config_rooms_add}, {"LoadStb", room_config_stb_load}}); +} + +// Adds AddRooms and LoadStb to RoomConfigSet, begun last. +void virtual_rooms_room_set_register(lua_State* state) +{ + lua_functions_add(state, {{"AddRooms", room_set_rooms_add}, {"LoadStb", room_set_stb_load}}); +} diff --git a/src/repentogon/virtual_rooms.h b/src/repentogon/virtual_rooms.h new file mode 100644 index 0000000..6552942 --- /dev/null +++ b/src/repentogon/virtual_rooms.h @@ -0,0 +1,17 @@ +#pragma once + +#include "level/room_config.h" +#include + +struct lua_State; + +void virtual_rooms_clear(); +RoomConfig_Room* virtual_room_find(int stageId, int type, int variant, RoomMode mode); +void virtual_rooms_filter(const RoomQuery& query, std::vector& found); +void virtual_rooms_weights_reset(int stageId, RoomMode mode); +void virtual_rooms_weights_reset_all(); +void virtual_rooms_commit(int stageId, RoomMode mode); +int virtual_room_set_size(RoomSet& set); +RoomConfig_Room* virtual_room_set_get(RoomSet& set, long long index); +void virtual_rooms_room_config_register(lua_State* state); +void virtual_rooms_room_set_register(lua_State* state); diff --git a/src/repentogon/xml.cpp b/src/repentogon/xml.cpp index 220f892..460cb6f 100644 --- a/src/repentogon/xml.cpp +++ b/src/repentogon/xml.cpp @@ -92,6 +92,14 @@ void content_files_load(std::string_view fileName, const std::functionmetadataWorkshopID.empty() ? mod->directory : mod->metadataWorkshopID; +} + // XMLData's getFileName: a path's file name without its extension. std::string file_name_get(std::string_view path) { diff --git a/src/repentogon/xml.h b/src/repentogon/xml.h index ca73f6e..18168d5 100644 --- a/src/repentogon/xml.h +++ b/src/repentogon/xml.h @@ -29,6 +29,7 @@ XmlAttributes xml_attributes_read(DataNode node, std::initializer_list std::optional data_root_get(Data& data, std::string_view tag); void content_files_load(std::string_view fileName, const std::function& load); std::string file_name_get(std::string_view path); +std::string mod_source_id_get(ModEntry* mod); void backdrops_content_load(DataNode root); BackdropDraw backdrop_custom_apply(Backdrop& backdrop, uint32_t& id); diff --git a/src/repentogon/xml_data.cpp b/src/repentogon/xml_data.cpp new file mode 100644 index 0000000..ff3bf7e --- /dev/null +++ b/src/repentogon/xml_data.cpp @@ -0,0 +1,869 @@ +// REPENTOGON's XMLData (Patches/XMLData.cpp's store and its Lua table): every content XML's entries as the game reads +// them, the game's file and then each loaded mod's content copy in mod order, with their attributes lowercased by +// name, their child elements by tag, the mod each came from (sourceid) and the ids the game gives mods' entries +// (a mod's own id kept as relativeid). Built on the first query once the mods loaded, and again after they reload. +#include "repentogon/xml_data.h" +#include "engine/data.h" +#include "engine/platform.h" +#include "entity/entity.h" +#include "game/manager.h" +#include "game/mod_manager.h" +#include "game/string_table.h" +#include "repentogon/api.h" +#include "repentogon/xml.h" +#include +#include +#include +#include + +using XmlChildren = std::map, std::less<>>; +using EntityKey = std::tuple; + +// XMLNode, the kinds of entries Lua asks for. +enum XmlNodeType +{ + XML_MOD, + XML_ENTITY, + XML_PLAYER, + XML_ITEM, + XML_TRINKET, + XML_PILL, + XML_CARD, + XML_MUSIC, + XML_SOUND, + XML_CHALLENGE, + XML_ITEMPOOL, + XML_NIGHTMARE, + XML_COSTUME, + XML_NULLCOSTUME, + XML_WISP, + XML_WISPCOLOR, + XML_CURSE, + XML_LOCUST, + XML_LOCUSTCOLOR, + XML_BOMBCOSTUME, + XML_RECIPE, + XML_BOSSPOOL, + XML_BOSSPORTRAIT, + XML_CUTSCENE, + XML_STAGE, + XML_BACKDROP, + XML_ACHIEVEMENT, + XML_GIANTBOOK, + XML_BOSSRUSHWAVE, + XML_PLAYERFORM, + XML_NULLITEM, + XML_BOSSCOLOR, + XML_FXLAYER, + XML_FXPARAM, + XML_FXRAY, + XML_BABY, + XML_TYPE_COUNT +}; + +// How a kind numbers its entries: the generic XMLDataHolder::AssignId, its own rule, or none (filled in by hand). +enum XmlIdRule +{ + ID_GENERIC, + ID_VARIANT, + ID_ATTRIBUTE, + ID_COSTUME, + ID_NULL_COSTUME, + ID_SEQUENTIAL, + ID_ITEM_LINKED, + ID_UNMODDED +}; + +// One kind's entries (XMLDataHolder): by id, by insertion order from 1, by name, and by mod id plus relativeid. +struct XmlTable +{ + std::map nodes; + std::map children; + std::map byOrder; + std::map> byName; + std::map> byRelative; + int maxId = 0; +}; + +// The entities (XMLEntity), keyed by type, variant and subtype. +struct XmlEntities +{ + std::map nodes; + std::map children; + std::map byOrder; + std::map> byName; +}; + +// Where a file's entries come from: the game's (not content) or a mod's content copy, and its source id. +struct XmlSource +{ + std::string sourceId; + bool isContent = false; +}; + +constexpr std::string_view BASE_GAME = "BaseGame"; +constexpr std::string_view MODS_FOLDER = "mods"; +constexpr std::string_view METADATA_FILE = "/metadata.xml"; +constexpr std::string_view TAINTED_SUFFIX = "-Tainted-"; +constexpr int ENGLISH = 0; +constexpr int VANILLA_TAINTED_FIRST = 21; +constexpr int VANILLA_TAINTED_LAST = 40; +constexpr int ENTITY_VARIANT_TYPES_END = 10; +constexpr int ENTITY_EFFECT_TYPES_START = 1000; +constexpr int SPECIAL_WISP_BASE = 0x10000; +constexpr int UNNUMBERED_ID_FIRST = 2000; +constexpr int UNNUMBERED_COSTUME_FIRST = 5000; +constexpr int VANILLA_BOSS_COUNT = 103; +constexpr int VANILLA_ACHIEVEMENT_COUNT = 638; +constexpr int PICKUP_COLLECTIBLE = 100; +constexpr int PICKUP_CARD = 300; +constexpr int PICKUP_TRINKET = 350; +// A backdrop's gfx without its ".png", and the place before which an underscore ends its number prefix. +constexpr size_t BACKDROP_EXTENSION_SIZE = 4; +constexpr size_t BACKDROP_PREFIX_END = 4; +// The highest ids REPENTOGON starts some kinds from (its constructors and xmlmaxnode). +constexpr std::array, 8> MAX_ID_STARTS = {{{XML_MUSIC, 119}, + {XML_SOUND, 914}, + {XML_NULLCOSTUME, 130}, + {XML_BOMBCOSTUME, 19}, + {XML_CURSE, 1}, + {XML_GIANTBOOK, 46}, + {XML_PLAYERFORM, 14}, + {XML_CUTSCENE, 26}}}; + +static std::array tables; +static XmlEntities entities; +static std::map> modsById; +static std::map> modsByDirectory; +static std::map, int> bossColorsByTypeVariant; +static bool isBuilt = false; + +static int text_int(std::string_view text) +{ + return std::atoi(std::string(text).c_str()); +} + +static std::string text_lower(std::string_view text) +{ + std::string lower(text); + std::ranges::transform(lower, lower.begin(), [](unsigned char c) { return (char)std::tolower(c); }); + return lower; +} + +static bool is_present(const XmlAttributes& node, std::string_view name) +{ + return node.find(name) != node.end(); +} + +// CheckTranslatedAttribute: a "#key" attribute replaced by its English text, the key kept as untranslated. +static void attribute_translate(XmlAttributes& node, const std::string& name, std::string_view category) +{ + auto found = node.find(name); + if (category.empty() || found == node.end() || !found->second.starts_with('#')) return; + bool isMissing = false; + std::string_view english = + g_manager->stringTable.get_string(category, ENGLISH, std::string_view(found->second).substr(1), &isMissing); + if (isMissing || english.empty()) return; + node["untranslated" + name] = found->second; + found->second = english; +} + +// The child elements of an entry by tag, lowercased unless the entities' raw tags are kept. +static XmlChildren children_read(DataNode element, bool isTagLowered) +{ + XmlChildren children; + for (DataNode child : node_children(element)) + children[isTagLowered ? text_lower(node_tag(child)) : std::string(node_tag(child))].push_back( + xml_attributes_read(child)); + return children; +} + +// The string table category a kind's names translate from. +static std::string_view translation_category_get(XmlNodeType type) +{ + switch (type) + { + case XML_ITEM: + case XML_TRINKET: + return "Items"; + case XML_PILL: + case XML_CARD: + return "PocketItems"; + case XML_PLAYER: + return "Players"; + case XML_CHALLENGE: + return "Challenges"; + case XML_FXLAYER: + case XML_FXPARAM: + case XML_FXRAY: + case XML_BOSSRUSHWAVE: + case XML_PLAYERFORM: + case XML_BABY: + return "Default"; + default: + return ""; + } +} + +// The id an entry takes (AssignId and its overrides), noting a mod's own id as relativeid. +static int id_assign(XmlNodeType type, XmlIdRule rule, XmlAttributes& node, const XmlSource& source) +{ + XmlTable& table = tables[type]; + bool isOwnId = is_present(node, "id") && (node["sourceid"] == BASE_GAME || !source.isContent); + auto relative_note = [&] { + if (is_present(node, "id")) node["relativeid"] = node["id"]; + }; + int id = 0; + switch (rule) + { + case ID_VARIANT: + case ID_ATTRIBUTE: + { + std::string_view attribute = rule == ID_VARIANT ? "variant" : "id"; + if (is_present(node, attribute)) id = text_int(node[std::string(attribute)]); + else node["id"] = std::to_string(id = table.maxId + 1); + break; + } + case ID_SEQUENTIAL: + node["id"] = std::to_string(id = table.maxId + 1); + break; + case ID_UNMODDED: + isOwnId = is_present(node, "id") && (!is_present(node, "sourceid") || !source.isContent); + if (isOwnId) id = text_int(node["id"]); + else + { + relative_note(); + node["id"] = std::to_string(id = table.maxId + 1); + } + break; + case ID_COSTUME: + case ID_ITEM_LINKED: + { + bool isSpecialWisp = rule == ID_ITEM_LINKED && type == XML_WISP && node["id"].starts_with('s'); + if (isSpecialWisp) id = SPECIAL_WISP_BASE + text_int(node["id"].substr(1)); + else if (isOwnId) id = text_int(node["id"]); + else if (is_present(node, "id")) + { + relative_note(); + XmlTable& items = tables[type == XML_COSTUME && node["type"] == "trinket" ? XML_TRINKET : XML_ITEM]; + auto linked = items.byRelative.find(node["sourceid"] + node["relativeid"]); + id = linked == items.byRelative.end() ? 0 : linked->second; + } + auto item = tables[XML_ITEM].nodes.find(id); + if (rule == ID_ITEM_LINKED && !isSpecialWisp && is_present(node, "id")) + node["name"] = item == tables[XML_ITEM].nodes.end() ? "" : item->second["name"]; + if (id == 0) + for (id = rule == ID_COSTUME ? UNNUMBERED_COSTUME_FIRST : UNNUMBERED_ID_FIRST; table.nodes.contains(id);) + id++; + node["id"] = std::to_string(id); + break; + } + case ID_NULL_COSTUME: + { + if (isOwnId) + { + id = text_int(node["id"]); + break; + } + relative_note(); + XmlTable& nullItems = tables[XML_NULLITEM]; + auto linked = nullItems.byRelative.find(node["sourceid"] + node["relativeid"]); + id = is_present(node, "relativeid") && linked != nullItems.byRelative.end() ? linked->second + : ++nullItems.maxId; + node["id"] = std::to_string(id); + break; + } + default: + if (isOwnId) id = text_int(node["id"]); + else + { + relative_note(); + node["id"] = std::to_string(id = table.maxId + 1); + } + } + table.maxId = std::max(table.maxId, id); + return id; +} + +// XMLDataHolder::AddNode: an entry's children, its kind's own touches, its translated name and lookups, then itself. +static void node_add(XmlNodeType type, DataNode element, XmlAttributes node, int id) +{ + XmlTable& table = tables[type]; + table.children[id] = children_read(element, true); + auto name_default = [&](std::string_view attribute) { + if (!is_present(node, "name") && is_present(node, attribute)) + node["name"] = file_name_get(node[std::string(attribute)]); + }; + switch (type) + { + case XML_PLAYER: + if (!is_present(node, "achievement") && is_present(node, "hideachievement")) + node["achievement"] = node["hideachievement"]; + attribute_translate(node, "birthright", "Players"); + break; + case XML_ITEM: + case XML_TRINKET: + case XML_NULLITEM: + node["type"] = text_lower(node_tag(element)); + break; + case XML_BOMBCOSTUME: + if (!is_present(node, "name")) node["name"] = node["variant"]; + break; + case XML_SOUND: + if (!is_present(node, "name") && !table.children[id]["sample"].empty() && + is_present(table.children[id]["sample"][0], "path")) + node["name"] = file_name_get(table.children[id]["sample"][0]["path"]); + break; + case XML_NIGHTMARE: + name_default("anm2"); + break; + case XML_COSTUME: + case XML_NULLCOSTUME: + name_default("anm2path"); + break; + case XML_GIANTBOOK: + case XML_PLAYERFORM: + name_default("gfx"); + break; + case XML_CHALLENGE: + attribute_translate(node, "lockeddesc", "Challenges"); + break; + case XML_RECIPE: + if (is_present(node, "input") && !is_present(node, "name")) node["name"] = node["input"]; + break; + case XML_BACKDROP: + if (!is_present(node, "name")) + { + std::string& gfx = node["gfx"]; + size_t extension = std::min(gfx.size(), BACKDROP_EXTENSION_SIZE); + std::string name = gfx.substr(0, gfx.size() - extension); + size_t prefix = name.find('_'); + node["name"] = prefix > 0 && prefix < BACKDROP_PREFIX_END ? name.substr(prefix + 1) : name; + } + break; + default: + break; + } + std::string_view category = translation_category_get(type); + attribute_translate(node, "name", category); + attribute_translate(node, "description", category); + + bool isTainted = type == XML_PLAYER && + (is_present(node, "bskinparent") || (id >= VANILLA_TAINTED_FIRST && id <= VANILLA_TAINTED_LAST)); + std::string suffix = isTainted ? std::string(TAINTED_SUFFIX) : ""; + bool isFirstNameKept = type == XML_BOSSPORTRAIT || type == XML_CURSE; + for (std::string_view key : {"name", "untranslatedname"}) + if (is_present(node, key) && (!isFirstNameKept || !table.byName.contains(node[std::string(key)] + suffix))) + table.byName[node[std::string(key)] + suffix] = id; + if (is_present(node, "relativeid")) table.byRelative[node["sourceid"] + node["relativeid"]] = id; + bool isNew = !table.nodes.contains(id); + table.nodes[id] = std::move(node); + if (isNew) table.byOrder[(int)table.nodes.size()] = id; +} + +// CreateAndAddNode: an entry read with its parents' attributes, its source set unless it names one, then numbered. +static void element_add(XmlNodeType type, XmlIdRule rule, DataNode element, std::initializer_list parents, + const XmlSource& source) +{ + XmlAttributes node = xml_attributes_read(element, parents); + if (type == XML_COSTUME || type == XML_NULLCOSTUME) + for (auto& [name, value] : node) value = text_lower(value); + if (type == XML_NULLCOSTUME && node["type"].empty()) node["type"] = "none"; + bool isSourceGiven = is_present(node, "sourceid"); + if (!isSourceGiven && rule != ID_UNMODDED) node["sourceid"] = source.sourceId; + int id = id_assign(type, rule, node, source); + if (!isSourceGiven) node["sourceid"] = source.sourceId; + node_add(type, element, std::move(node), id); +} + +// The entities pass: an entity without a variant (below type 10 or from 1000) takes the next free one, and a mod's +// entity colliding with one before moves on by variant there, else by type, as the game resolves it. +static void entities_add(DataNode root, const XmlSource& source) +{ + for (DataNode element : node_children(root)) + { + XmlAttributes entity = xml_attributes_read(element, {root}); + int type = text_int(entity["id"]); + int variant = 0; + int subtype = is_present(entity, "subtype") ? text_int(entity["subtype"]) : 0; + bool isByVariant = type < ENTITY_VARIANT_TYPES_END || type >= ENTITY_EFFECT_TYPES_START; + if (is_present(entity, "variant")) variant = text_int(entity["variant"]); + else if (isByVariant) + while (entities.nodes.contains({type, variant, subtype})) variant++; + if (source.isContent) + while (entities.nodes.contains({type, variant, subtype})) (isByVariant ? variant : type)++; + + EntityKey key = {type, variant, subtype}; + entity["id"] = entity["type"] = std::to_string(type); + entity["variant"] = std::to_string(variant); + entity["sourceid"] = source.sourceId; + attribute_translate(entity, "name", "Entities"); + auto color = bossColorsByTypeVariant.find({type, variant}); + if (source.isContent && entity["boss"] == "1" && color != bossColorsByTypeVariant.end()) + { + tables[XML_BOSSCOLOR].nodes[color->second]["name"] = entity["name"]; + tables[XML_BOSSCOLOR].nodes[color->second]["sourceid"] = entity["sourceid"]; + tables[XML_BOSSCOLOR].byName[entity["name"]] = color->second; + } + entities.children[key] = children_read(element, false); + for (std::string_view name : {"name", "untranslatedname"}) + if (is_present(entity, name)) entities.byName[entity[std::string(name)]] = key; + entities.nodes[key] = std::move(entity); + entities.byOrder[(int)entities.nodes.size()] = key; + } +} + +// A pass over each child of a file's root with the same kind and rule, inheriting from the root when asked. +static void children_add(DataNode root, XmlNodeType type, XmlIdRule rule, const XmlSource& source, bool isInherited) +{ + for (DataNode element : node_children(root)) + element_add(type, rule, element, isInherited ? std::initializer_list{root} + : std::initializer_list{}, source); +} + +// One file's entries, by the kind its root names (ProcessXmlNode's switch). +static void root_add(DataNode root, const XmlSource& source) +{ + std::string tag = text_lower(node_tag(root)); + if (tag == "entities") return entities_add(root, source); + if (tag == "players") return children_add(root, XML_PLAYER, ID_GENERIC, source, true); + if (tag == "music") return children_add(root, XML_MUSIC, ID_GENERIC, source, true); + if (tag == "sounds") return children_add(root, XML_SOUND, ID_GENERIC, source, true); + if (tag == "challenges") return children_add(root, XML_CHALLENGE, ID_GENERIC, source, false); + if (tag == "nightmares") return children_add(root, XML_NIGHTMARE, ID_GENERIC, source, true); + if (tag == "bombcostumes") return children_add(root, XML_BOMBCOSTUME, ID_VARIANT, source, true); + if (tag == "backdrops") return children_add(root, XML_BACKDROP, ID_ATTRIBUTE, source, true); + if (tag == "recipes") return children_add(root, XML_RECIPE, ID_SEQUENTIAL, source, false); + if (tag == "babies") return children_add(root, XML_BABY, ID_GENERIC, source, true); + if (tag == "giantbook") return children_add(root, XML_GIANTBOOK, ID_UNMODDED, source, true); + if (tag == "playerforms") return children_add(root, XML_PLAYERFORM, ID_UNMODDED, source, true); + if (tag == "fxlayers" || tag == "fxparams" || tag == "fxrays") + return children_add(root, tag == "fxlayers" ? XML_FXLAYER : tag == "fxparams" ? XML_FXPARAM : XML_FXRAY, + ID_UNMODDED, source, true); + int sequence = 0; + for (DataNode element : node_children(root)) + { + std::string child = text_lower(node_tag(element)); + XmlAttributes node = xml_attributes_read(element, {root}); + if (tag == "items") + { + bool isItem = child == "active" || child == "passive" || child == "familiar"; + element_add(isItem ? XML_ITEM : child == "trinket" ? XML_TRINKET : XML_NULLITEM, ID_GENERIC, element, + {root}, source); + } + else if (tag == "pocketitems" && (child == "card" || child == "rune" || child == "pilleffect")) + element_add(child == "pilleffect" ? XML_PILL : XML_CARD, ID_GENERIC, element, {}, source); + else if (tag == "wisps" || tag == "locusts") + { + bool isWisp = tag == "wisps"; + if (child == "color") element_add(isWisp ? XML_WISPCOLOR : XML_LOCUSTCOLOR, ID_GENERIC, element, {root}, source); + else if (child == (isWisp ? "wisp" : "locust")) + element_add(isWisp ? XML_WISP : XML_LOCUST, ID_ITEM_LINKED, element, {root}, source); + } + else if (tag == "costumes") + { + std::string type = text_lower(node["type"]); + bool isItem = type == "passive" || type == "active" || type == "trinket" || type == "familiar"; + element_add(isItem ? XML_COSTUME : XML_NULLCOSTUME, isItem ? ID_COSTUME : ID_NULL_COSTUME, element, {root}, + source); + } + else if (tag == "cutscenes" || tag == "stages") + { + XmlNodeType type = tag == "stages" ? XML_STAGE : XML_CUTSCENE; + if (is_present(node, "realid")) node["id"] = node["realid"]; + if (!is_present(node, "sourceid")) node["sourceid"] = source.sourceId; + int id = source.isContent ? id_assign(type, ID_GENERIC, node, source) : text_int(node["id"]); + if (type == XML_STAGE) attribute_translate(node, "name", "Stages"); + tables[type].maxId = std::max(tables[type].maxId, id); + node_add(type, element, std::move(node), id); + } + else if (tag == "curses") + { + XmlTable& curses = tables[XML_CURSE]; + if (is_present(node, "id")) node["relativeid"] = node["id"]; + int id = curses.maxId; + curses.maxId *= 2; + node["id"] = std::to_string(id); + node["sourceid"] = source.sourceId; + attribute_translate(node, "name", "Curses"); + node_add(XML_CURSE, element, std::move(node), id); + } + else if (tag == "achievements") + { + XmlTable& achievements = tables[XML_ACHIEVEMENT]; + bool isOwnId = !node["id"].empty() && achievements.maxId < VANILLA_ACHIEVEMENT_COUNT - 1; + if (!isOwnId && !node["id"].empty()) node["relativeid"] = node["id"]; + int id = isOwnId ? text_int(node["id"]) : achievements.maxId + 1; + node["id"] = std::to_string(id); + achievements.maxId = std::max(achievements.maxId, id); + if (!is_present(node, "sourceid")) node["sourceid"] = source.sourceId; + if (!is_present(node, "name")) node["name"] = node["text"]; + if (node["name"].empty()) node["name"] = node["steam_name"]; + node_add(XML_ACHIEVEMENT, element, std::move(node), id); + } + else if (tag == "bosses") + { + XmlTable& portraits = tables[XML_BOSSPORTRAIT]; + int id = source.isContent ? std::max(portraits.maxId, VANILLA_BOSS_COUNT) : text_int(node["id"]); + if (!source.isContent && (id < 0 || id >= VANILLA_BOSS_COUNT)) id = 0; + portraits.maxId = std::max(portraits.maxId, source.isContent ? id + 1 : id); + node["id"] = std::to_string(id); + node["sourceid"] = source.sourceId; + node_add(XML_BOSSPORTRAIT, element, std::move(node), id); + } + else if (tag == "itempools") + { + XmlTable& pools = tables[XML_ITEMPOOL]; + auto found = pools.byName.find(node["name"]); + int id = found == pools.byName.end() ? ++pools.maxId : found->second; + XmlChildren items = children_read(element, true); + for (auto& [childTag, list] : items) + pools.children[id][childTag].insert(pools.children[id][childTag].end(), list.begin(), list.end()); + if (found != pools.byName.end()) continue; + node["sourceid"] = source.sourceId; + pools.byName[node["name"]] = id; + pools.nodes[id] = std::move(node); + pools.byOrder[(int)pools.nodes.size()] = id; + } + else if (tag == "bossrush" || tag == "bosscolors") + { + XmlNodeType type = tag == "bossrush" ? XML_BOSSRUSHWAVE : XML_BOSSCOLOR; + int id = type == XML_BOSSRUSHWAVE ? ++sequence : ++tables[type].maxId; + tables[type].maxId = std::max(tables[type].maxId, id); + if (type == XML_BOSSRUSHWAVE) + { + node["id"] = std::to_string(id); + if (!is_present(node, "sourceid")) node["sourceid"] = std::string(BASE_GAME); + node_add(type, element, std::move(node), id); + continue; + } + auto entity = entities.nodes.find({text_int(node["id"]), text_int(node["variant"]), 0}); + if (entity != entities.nodes.end()) node["name"] = entity->second["name"]; + node["sourceid"] = std::string(BASE_GAME); + bossColorsByTypeVariant[{text_int(node["id"]), text_int(node["variant"])}] = id; + node_add(type, element, std::move(node), id); + } + } +} + +// The items_metadata.xml pass: an item's or trinket's tags and quality, a mod's found by its own id. +static void metadata_add(DataNode root, const XmlSource& source) +{ + for (DataNode element : node_children(root)) + { + std::string child = text_lower(node_tag(element)); + if (child != "item" && child != "trinket") continue; + XmlAttributes node = xml_attributes_read(element, {root}); + XmlTable& table = tables[child == "trinket" ? XML_TRINKET : XML_ITEM]; + if (!is_present(node, "id")) continue; + int id = source.isContent ? table.byRelative[source.sourceId + node["id"]] : text_int(node["id"]); + table.nodes[id]["tags"] = node["tags"]; + table.nodes[id]["quality"] = node["quality"]; + } +} + +// Every mod's metadata.xml (the "name" pass): its elements' text by tag, its tags' ids listed, and its id the folder's +// name when it has none or another mod took it. +static void mods_add() +{ + XmlTable& mods = tables[XML_MOD]; + for (auto& entry : g_manager->modManager.mods) + { + Data data; + data_load(data, platform.modsDirectory + entry->directory + std::string(METADATA_FILE)); + std::optional metadata = data_root_get(data, "metadata"); + if (!metadata) continue; + + XmlAttributes mod; + std::string tags; + for (DataNode child : node_children(*metadata)) + { + std::string tag = text_lower(node_tag(child)); + if (tag != "tag") mod[tag] = node_text(child); + else if (std::optional id = node_attr_find(child, "id")) tags += std::string(*id) + ", "; + } + if (!is_present(mod, "id") || modsById.contains(mod["id"])) mod["id"] = mod["directory"]; + auto known = modsById.find(mod["id"]); + int index = known == modsById.end() ? ++mods.maxId : known->second; + mod["tags"] = tags; + modsById[mod["id"]] = index; + modsByDirectory[mod["directory"]] = index; + mods.byName[mod["name"]] = index; + mods.nodes[index] = std::move(mod); + // REPENTOGON files every mod under order 0 here, which no mod has, so its GetEntryByOrder finds none. + mods.byOrder[(int)mods.nodes.size()] = index; + } +} + +// Adds a document's entries, each of its roots by its tag. +static void document_add(Data& data, const XmlSource& source, bool isMetadata) +{ + if (!data.isLoaded) return; + std::vector roots; + if (node_tag(data.root) == DOCUMENT_TAG) + for (DataNode child : node_children(data.root)) roots.push_back(child); + else roots.push_back(data.root); + for (DataNode root : roots) isMetadata ? metadata_add(root, source) : root_add(root, source); +} + +constexpr std::string_view METADATA_XML = "items_metadata.xml"; +constexpr std::string_view BOSS_COLORS_XML = "bosscolors.xml"; +// The files in the order the game reads its own (Manager::LoadConfigs, then a run's pools, stages and the rest). +constexpr std::string_view XML_FILES[] = {"music.xml", "cutscenes.xml", "achievements.xml", "sounds.xml", + "nightmares.xml", "items.xml", "costumes2.xml", METADATA_XML, + "pocketitems.xml", "playerforms.xml", "bombcostumes.xml", "wisps.xml", + "locusts.xml", "recipes.xml", "challenges.xml", "entities2.xml", + BOSS_COLORS_XML, "players.xml", "babies.xml", "bossportraits.xml", + "itempools.xml", "stages.xml", "curses.xml", "backdrops.xml", + "giantbook.xml", "bossrush.xml", "fxlayers.xml"}; + +static void mods_files_add(std::string_view fileName) +{ + content_files_load(fileName, [&](Data& data, ModEntry& mod) { + document_add(data, {mod_source_id_get(&mod), true}, fileName == METADATA_XML); + }); +} + +// Builds every table: the game's files in its order (the mods' boss colors merged straight after its own), then the +// mods' content files. +static void xml_data_build() +{ + tables = {}; + entities = {}; + modsById.clear(); + modsByDirectory.clear(); + bossColorsByTypeVariant.clear(); + for (auto [type, maxId] : MAX_ID_STARTS) tables[type].maxId = maxId; + + mods_add(); + for (std::string_view file : XML_FILES) + { + Data data; + data_load(data, g_manager->modManager.TryRedirectPath(file)); + document_add(data, {std::string(BASE_GAME), false}, file == METADATA_XML); + if (file == BOSS_COLORS_XML) mods_files_add(file); + } + for (std::string_view file : XML_FILES) + if (file != BOSS_COLORS_XML) mods_files_add(file); + isBuilt = true; +} + +// Drops the tables, which the next query builds again (the mods are loading). +void xml_data_reset() +{ + isBuilt = false; +} + +// Lua_PushXMLNode: an entry's attributes and, under each child tag, the list of its children's attributes. Nil for +// none. +static int node_push(lua_State* state, const XmlAttributes* node, const XmlChildren* children) +{ + if (!node || node->empty()) + { + lua_pushnil(state); + return 1; + } + auto attributes_push = [&](const XmlAttributes& attributes) { + lua_newtable(state); + for (auto& [name, value] : attributes) + { + lua_pushstring(state, value.c_str()); + lua_setfield(state, -2, name.c_str()); + } + }; + attributes_push(*node); + for (auto& [tag, list] : children ? *children : XmlChildren{}) + { + lua_createtable(state, (int)list.size(), 0); + for (size_t i = 0; i < list.size(); i++) + { + attributes_push(list[i]); + lua_rawseti(state, -2, (lua_Integer)i + 1); + } + lua_setfield(state, -2, tag.c_str()); + } + return 1; +} + +static int entity_push(lua_State* state, std::optional key) +{ + if (!key || !entities.nodes.contains(*key)) return node_push(state, nullptr, nullptr); + return node_push(state, &entities.nodes[*key], &entities.children[*key]); +} + +static int table_push(lua_State* state, XmlNodeType type, std::optional id) +{ + XmlTable& table = tables[type]; + if (!id || !table.nodes.contains(*id)) return node_push(state, nullptr, nullptr); + return node_push(state, &table.nodes[*id], &table.children[*id]); +} + +// GetNodesByTypeVarSub: the exact entity, else (unless strict) the variant's with subtype 0, else the type's. +static std::optional entity_find(int type, int variant, int subtype, bool isStrict) +{ + for (EntityKey key : {EntityKey{type, variant, subtype}, EntityKey{type, variant, 0}, EntityKey{type, 0, 0}}) + { + if (entities.nodes.contains(key)) return key; + if (isStrict) break; + } + return std::nullopt; +} + +// The node type argument at index 1, built tables first. Raises REPENTOGON's error for a non-number. +static int node_type_check(lua_State* state) +{ + if (!lua_isnumber(state, 1)) + luaL_error(state, "Expected XMLNode as parameter #1, got %s", lua_typename(state, lua_type(state, 1))); + if (!isBuilt) xml_data_build(); + return (int)lua_tonumber(state, 1); +} + +static bool is_table_type(int type) +{ + return type >= 0 && type < XML_TYPE_COUNT && type != XML_ENTITY; +} + +// XMLData.GetEntryById(type, id): an entity by type, else the entry of that id. +static int entry_by_id_get(lua_State* state) +{ + int type = node_type_check(state); + if (!lua_isnumber(state, 2)) + return luaL_error(state, "Expected number as parameter #2, got %s", lua_typename(state, lua_type(state, 2))); + int id = (int)lua_tonumber(state, 2); + if (type == XML_ENTITY) return entity_push(state, entity_find(id, 0, 0, false)); + return is_table_type(type) ? table_push(state, (XmlNodeType)type, id) : node_push(state, nullptr, nullptr); +} + +// XMLData.GetEntryByName(type, name). +static int entry_by_name_get(lua_State* state) +{ + int type = node_type_check(state); + if (!lua_isstring(state, 2)) + return luaL_error(state, "Expected string as parameter #2, got %s", lua_typename(state, lua_type(state, 2))); + std::string_view name = lua_tostring(state, 2); + if (type == XML_ENTITY) + { + auto found = entities.byName.find(name); + return entity_push(state, found == entities.byName.end() ? std::nullopt : std::optional(found->second)); + } + if (!is_table_type(type)) return node_push(state, nullptr, nullptr); + auto found = tables[type].byName.find(name); + return table_push(state, (XmlNodeType)type, + found == tables[type].byName.end() ? std::nullopt : std::optional(found->second)); +} + +// XMLData.GetEntryByOrder(type, order): the entry added as the order'th, from 1. +static int entry_by_order_get(lua_State* state) +{ + int type = node_type_check(state); + if (!lua_isnumber(state, 2)) + return luaL_error(state, "Expected int as parameter #2, got %s", lua_typename(state, lua_type(state, 2))); + int order = (int)lua_tonumber(state, 2); + if (type == XML_ENTITY) + { + auto found = entities.byOrder.find(order); + return entity_push(state, found == entities.byOrder.end() ? std::nullopt : std::optional(found->second)); + } + if (!is_table_type(type)) return node_push(state, nullptr, nullptr); + auto found = tables[type].byOrder.find(order); + return table_push(state, (XmlNodeType)type, + found == tables[type].byOrder.end() ? std::nullopt : std::optional(found->second)); +} + +// XMLData.GetNumEntries(type). +static int entries_count_get(lua_State* state) +{ + int type = node_type_check(state); + size_t count = type == XML_ENTITY ? entities.nodes.size() : is_table_type(type) ? tables[type].nodes.size() : 0; + lua_pushinteger(state, (lua_Integer)count); + return 1; +} + +// The type, variant and subtype arguments of the lookups by them. +static EntityKey entity_key_read(lua_State* state) +{ + if (!lua_isnumber(state, 1)) + luaL_error(state, "Expected EntityType as parameter #1, got %s", lua_typename(state, lua_type(state, 1))); + if (!isBuilt) xml_data_build(); + return {(int)luaL_checknumber(state, 1), (int)luaL_optnumber(state, 2, 0), (int)luaL_optnumber(state, 3, 0)}; +} + +// XMLData.GetEntityByTypeVarSub(type, variant, subtype, strict). +static int entity_by_type_get(lua_State* state) +{ + auto [type, variant, subtype] = entity_key_read(state); + return entity_push(state, entity_find(type, variant, subtype, LuaOptionalBool::lua_read(state, 4).value)); +} + +// XMLData.GetBossColorByTypeVarSub(type, variant, subtype): the boss's color entry of that subtype, from 1. +static int boss_color_get(lua_State* state) +{ + auto [type, variant, subtype] = entity_key_read(state); + auto color = bossColorsByTypeVariant.find({type, variant}); + if (color == bossColorsByTypeVariant.end()) return node_push(state, nullptr, nullptr); + std::vector& colors = tables[XML_BOSSCOLOR].children[color->second]["color"]; + return node_push(state, subtype > 0 && (size_t)subtype <= colors.size() ? &colors[subtype - 1] : nullptr, nullptr); +} + +// XMLData.GetEntryFromEntity(entity, pick the XML by type, strict): a player's, a pedestal's, card's or trinket's +// entry, else the entity's. +static int entity_entry_get(lua_State* state) +{ + Entity& entity = lua_get(state, 1); + if (!isBuilt) xml_data_build(); + bool isAutomatic = LuaOptionalBool::lua_read(state, 2).value; + bool isStrict = LuaOptionalBool::lua_read(state, 3).value; + int type = entity.type; + int variant = entity.variant; + int subtype = (int)entity.subtype; + if (isAutomatic && type == ENTITY_PLAYER) return table_push(state, XML_PLAYER, subtype); + if (isAutomatic && type == ENTITY_PICKUP && subtype > 0) + { + if (variant == PICKUP_COLLECTIBLE) return table_push(state, XML_ITEM, subtype); + if (variant == PICKUP_CARD) return table_push(state, XML_CARD, subtype); + if (variant == PICKUP_TRINKET) return table_push(state, XML_TRINKET, subtype); + } + return entity_push(state, entity_find(type, variant, subtype, isStrict)); +} + +// XMLData.GetModById(id): a mod's metadata by its id. +static int mod_by_id_get(lua_State* state) +{ + std::string_view id = luaL_checkstring(state, 1); + if (!isBuilt) xml_data_build(); + auto found = modsById.find(id); + return table_push(state, XML_MOD, found == modsById.end() ? std::nullopt : std::optional(found->second)); +} + +// XMLData.GetCurrentMod(): the metadata of the mod whose folder the calling script is in. +static int current_mod_get(lua_State* state) +{ + lua_Debug info; + if (!isBuilt) xml_data_build(); + if (!lua_getstack(state, 1, &info) || !lua_getinfo(state, "S", &info)) return node_push(state, nullptr, nullptr); + + std::filesystem::path source = std::string_view(info.source).substr(info.source[0] == '@' ? 1 : 0); + std::filesystem::path mods = platform.modsDirectory; + std::filesystem::path relative = source.lexically_relative(mods); + std::string directory = !relative.empty() && *relative.begin() != ".." ? relative.begin()->string() : ""; + for (auto part = source.begin(); directory.empty() && part != source.end(); ++part) + if (*part == MODS_FOLDER && std::next(part) != source.end()) directory = std::next(part)->string(); + auto found = modsByDirectory.find(directory); + return table_push(state, XML_MOD, found == modsByDirectory.end() ? std::nullopt : std::optional(found->second)); +} + +// Registers the XMLData global table. +void xml_data_api_register(lua_State* state) +{ + lua_namespace_begin(state, "XMLData"); + lua_functions_add(state, {{"GetEntryByName", entry_by_name_get}, + {"GetEntryById", entry_by_id_get}, + {"GetEntryByOrder", entry_by_order_get}, + {"GetNumEntries", entries_count_get}, + {"GetEntityByTypeVarSub", entity_by_type_get}, + {"GetBossColorByTypeVarSub", boss_color_get}, + {"GetEntryFromEntity", entity_entry_get}, + {"GetModById", mod_by_id_get}, + {"GetCurrentMod", current_mod_get}}); + lua_namespace_plain_end(state); +} diff --git a/src/repentogon/xml_data.h b/src/repentogon/xml_data.h new file mode 100644 index 0000000..b3f7ea0 --- /dev/null +++ b/src/repentogon/xml_data.h @@ -0,0 +1,6 @@ +#pragma once + +struct lua_State; + +void xml_data_reset(); +void xml_data_api_register(lua_State* state); diff --git a/src/ui/console.cpp b/src/ui/console.cpp index d0f3175..d5b7d9b 100644 --- a/src/ui/console.cpp +++ b/src/ui/console.cpp @@ -17,6 +17,7 @@ #include "level/room_config.h" #ifdef ISAAC_REPENTOGON #include "repentogon/console.h" +#include "repentogon/options.h" #endif #ifdef ISAAC_OVERLAY #include "ui/overlay/overlay.h" @@ -295,6 +296,9 @@ void Console::history_push(std::string line) line_begin(); print_format(CONSOLE_ECHO, ">%s\n", input.c_str()); +#ifdef ISAAC_REPENTOGON + if (!repentogonOptions.isVanillaParity) history_save(); // Patches/ConsoleHooks.cpp: kept through a crash +#endif } // Starts a new output line unless the newest one is still empty. @@ -959,6 +963,12 @@ void Console::Close() state = CONSOLE_CLOSING; animationFrame = 0; g_manager->isHotkeysEnabled = true; + history_save(); +} + +// Saves the command history when the options keep it, removing the file when there is none. +void Console::history_save() +{ if (!is_history_saved()) return; std::string path = history_path_get(); diff --git a/src/ui/console.h b/src/ui/console.h index ad73f21..87ee9de 100644 --- a/src/ui/console.h +++ b/src/ui/console.h @@ -138,6 +138,7 @@ struct Console void history_clear(); void LoadCommandHistory(); void history_push(std::string line); + void history_save(); void Print(std::string_view text, uint32_t color = CONSOLE_WHITE, int fadeFrames = CONSOLE_FADE_FRAMES); void PrintError(std::string_view error); diff --git a/src/ui/console_commands.cpp b/src/ui/console_commands.cpp index 63d8f96..2bc9301 100644 --- a/src/ui/console_commands.cpp +++ b/src/ui/console_commands.cpp @@ -32,6 +32,7 @@ #ifdef ISAAC_REPENTOGON #include "repentogon/api_game.h" #include "repentogon/console.h" +#include "repentogon/options.h" #include "repentogon/vanilla_fixes.h" #endif #include @@ -1098,7 +1099,12 @@ void Console::RunCommand(std::string_view text, std::string* output, Entity_Play // An empty command does nothing. The original reads its first word past an empty list. if (command.words.empty()) return; - if (!command.player) command.player = g_game->playerManager.GetPlayer(0); + bool isPlayerFound = true; +#ifdef ISAAC_REPENTOGON + if (is_console_command_refused(*this, command.words[0])) return; + isPlayerFound = repentogonOptions.isVanillaParity || is_console_in_run(); +#endif + if (!command.player && isPlayerFound) command.player = g_game->playerManager.GetPlayer(0); if (output) capture = output; #ifdef ISAAC_REPENTOGON if (is_console_hook_run(*this, command.words, command.player)) diff --git a/src/ui/hud.cpp b/src/ui/hud.cpp index ae8a3c9..dfbe0a1 100644 --- a/src/ui/hud.cpp +++ b/src/ui/hud.cpp @@ -1816,7 +1816,7 @@ void HUD::render_modded_coop_portrait(int playerType, Vector at, Vector portrait ANM2* portrait = config ? config->moddedSprites[PLAYER_SPRITE_COOP_MENU] : nullptr; if (!portrait) return; - portrait->Play(config->GetDisplayName()); + portrait->Play(config->animation_name_get(*portrait)); portrait->scale = portraitScale; portrait->color = color; portrait->Render({.position = at}); diff --git a/src/ui/menu/character.cpp b/src/ui/menu/character.cpp index 7282509..d61fd2e 100644 --- a/src/ui/menu/character.cpp +++ b/src/ui/menu/character.cpp @@ -15,6 +15,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/progress.h" #include "repentogon/render.h" #endif @@ -334,8 +335,20 @@ void CompletionWidget::Update() if ((g_manager->framecount & 1) == 0) anm2.Update(); markCount = 0; +#ifdef ISAAC_REPENTOGON + std::optional modded = modded_marks_shown_get(characterId); +#endif for (const CompletionMarkLayer& mark : COMPLETION_MARK_LAYERS) { +#ifdef ISAAC_REPENTOGON + if (modded) + { + int frame = modded->marks[mark.completionType]; + markCount += frame != 0; + anm2.SetLayerFrame(mark.layer, frame + (mark.layer == 0 && modded->isTainted ? COMPLETION_TAINTED_FRAMES : 0)); + continue; + } +#endif if ((uint32_t)characterId > COMPLETION_PLAYER_TYPE_MAX) { anm2.SetLayerFrame(mark.layer, 0); @@ -671,6 +684,11 @@ void Menu_Character::UpdateRotations() isInputPossible = false; for (int i = 0; i < numCharacters; i++) wheel_rotate(i); +#ifdef ISAAC_REPENTOGON + if (selectedCharacterID >= CHARACTER_ENTRY_COUNT) + completionWidget.characterId = GetPlayerTypeFromMenuID(selectedCharacterID, characterMenuShown); + if (selectedCharacterID >= CHARACTER_ENTRY_COUNT) return completionWidget.Update(); +#endif if (selectedCharacterID >= CHARACTER_ENTRY_COUNT) return; completionWidget.characterId = @@ -1123,7 +1141,13 @@ void Menu_Character::Render() if (!is_action_glyph_rendered(ACTION_MENU_RB, glyphPosition)) pageSwapWidgetSprite.RenderLayer(SWAP_LAYER_GLYPH, {swap}); } - if (selectedCharacterID < CHARACTER_ENTRY_COUNT && selectedCharacterID != MENU_ID_RANDOM) + bool isWidgetShown = selectedCharacterID < CHARACTER_ENTRY_COUNT && selectedCharacterID != MENU_ID_RANDOM; +#ifdef ISAAC_REPENTOGON + // (Patches/CompletionTracker.cpp) A modded character's marks, parity off. + isWidgetShown = isWidgetShown || (selectedCharacterID >= CHARACTER_ENTRY_COUNT && + modded_marks_shown_get(completionWidget.characterId).has_value()); +#endif + if (isWidgetShown) completionWidget.Render(offset_add(origin, COMPLETION_OFFSET), vector_make(1, 1)); difficultyPageSprite.Render({offset_add(origin, DIFFICULTY_OFFSET)}); seedPageSprite.Render({offset_add(origin, SEED_WIDGET_OFFSET)}); diff --git a/src/ui/menu/custom_challenge.cpp b/src/ui/menu/custom_challenge.cpp index 2f09c26..7886e19 100644 --- a/src/ui/menu/custom_challenge.cpp +++ b/src/ui/menu/custom_challenge.cpp @@ -4,15 +4,50 @@ #include "ui/menu/challenge.h" #include "ui/menu/manager.h" #include "ui/menu/mods.h" +#ifdef ISAAC_REPENTOGON +#include "repentogon/progress.h" +#endif constexpr const char* CUSTOM_CHALLENGE_ANM2 = "gfx/ui/main menu/ChallengeMenuCustom.anm2"; constexpr int FIRST_MOD_CHALLENGE = CHALLENGE_COUNT; +// The alpha of a locked challenge's row (Patches/ChallengesStuff.cpp). +constexpr float LOCKED_ALPHA = 0.5f; static int challenge_count() { return (int)g_manager->challengeParams.size(); } +// (Patches/ChallengesStuff.cpp) Whether the menu lists a mod's challenge, and whether it can be picked: REPENTOGON +// hides some and locks others. +static bool is_listed(int id) +{ +#ifdef ISAAC_REPENTOGON + return !is_challenge_hidden(id); +#endif + return true; +} + +static bool is_selectable(int id) +{ +#ifdef ISAAC_REPENTOGON + return is_listed(id) && !is_challenge_locked(id); +#endif + return true; +} + +// Moves the cursor a step at a time, wrapping, until it is on a challenge that can be picked. +static void selection_move(int& selected, int step) +{ + for (int tries = FIRST_MOD_CHALLENGE; tries < challenge_count(); tries++) + { + selected += step; + if (selected < FIRST_MOD_CHALLENGE) selected = challenge_count() - 1; + if (selected >= challenge_count()) selected = FIRST_MOD_CHALLENGE; + if (is_selectable(selected)) return; + } +} + // Loads the menu at its place on the menu sheet, then resets it (inlined in MenuManager::Init). void Menu_CustomChallenge::Init(Vector menuPosition) { @@ -50,20 +85,21 @@ void Menu_CustomChallenge::Update() return; } + if (selectedChallengeId < challenge_count() && !is_selectable(selectedChallengeId)) + selection_move(selectedChallengeId, 1); if (is_action(ACTION_MENU_CONFIRM, ACTION_TRIGGERED)) { - if (challenge_count() == FIRST_MOD_CHALLENGE) menu_sound_play(SOUND_ERROR_BUZZ, SOUND_DELAY); + bool isPickable = challenge_count() > FIRST_MOD_CHALLENGE && is_selectable(selectedChallengeId); + if (!isPickable) menu_sound_play(SOUND_ERROR_BUZZ, SOUND_DELAY); else menus.start_game(kcolor_argb(BLACK_ARGB)); } else if (is_action(ACTION_MENU_UP, ACTION_PRESSED)) { - if (is_key_repeat(holdInputTimer) && --selectedChallengeId < FIRST_MOD_CHALLENGE) - selectedChallengeId = challenge_count() - 1; + if (is_key_repeat(holdInputTimer)) selection_move(selectedChallengeId, -1); } else if (is_action(ACTION_MENU_DOWN, ACTION_PRESSED)) { - if (is_key_repeat(holdInputTimer) && ++selectedChallengeId >= challenge_count()) - selectedChallengeId = FIRST_MOD_CHALLENGE; + if (is_key_repeat(holdInputTimer)) selection_move(selectedChallengeId, 1); } else if (is_action(ACTION_MENU_BACK, ACTION_TRIGGERED)) menus.pop_menu(); @@ -78,15 +114,26 @@ void Menu_CustomChallenge::Render() MenuManager& menus = *g_menuManager; std::vector& params = g_manager->challengeParams; Vector origin = paper_origin_get(position); - int rowCount = challenge_count() - FIRST_MOD_CHALLENGE; - int selectedRow = selectedChallengeId - FIRST_MOD_CHALLENGE; + int rowCount = 0; + int selectedRow = 0; + for (int id = FIRST_MOD_CHALLENGE; id < challenge_count(); id++) rowCount += is_listed(id); paper_top_render(customChallengeSprite, origin); paper_render(customChallengeSprite, origin, rowCount); - for (int row = 0; row < rowCount; row++) + for (int id = FIRST_MOD_CHALLENGE, row = 0; id < challenge_count(); id++) { - paper_row_render(paper_row_text(row, params[row + FIRST_MOD_CHALLENGE].name), origin, row, BLACK); - if (row == selectedRow) paper_cursor_render(customChallengeSprite, origin, row); + if (!is_listed(id)) continue; + std::string name = params[id].name; + KColor color = BLACK; +#ifdef ISAAC_REPENTOGON + name = challenge_row_name_get(id); + if (is_challenge_locked(id)) color._alpha = LOCKED_ALPHA; + if (is_challenge_shown_completed(id)) challenge_streak_render(id, row, name, paper_row_position(origin, row)); +#endif + paper_row_render(paper_row_text(row, name), origin, row, color); + if (id == selectedChallengeId) paper_cursor_render(customChallengeSprite, origin, row); + if (id == selectedChallengeId) selectedRow = row; + row++; } menus.viewPositionSet[MENU_CUSTOM_CHALLENGE].y = paper_view_y_get(selectedRow, rowCount); diff --git a/src/ui/menu/manager.cpp b/src/ui/menu/manager.cpp index f8a4e99..a7b762b 100644 --- a/src/ui/menu/manager.cpp +++ b/src/ui/menu/manager.cpp @@ -100,7 +100,7 @@ bool is_action(ButtonAction action, ActionTest test, int* deviceId) { KAGE::Input::Manager& input = KAGE::Input::manager; #ifdef ISAAC_REPENTOGON - if (is_action_masked(action)) return false; + if (is_action_masked(action) || (test == ACTION_TRIGGERED && is_mods_search_active())) return false; #endif for (int i = 0; i < input.get_device_count(); i++) diff --git a/src/ui/menu/mods.cpp b/src/ui/menu/mods.cpp index 603ee2f..07200f4 100644 --- a/src/ui/menu/mods.cpp +++ b/src/ui/menu/mods.cpp @@ -4,6 +4,9 @@ #include "ui/menu/manager.h" #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/ui_patches.h" +#endif constexpr const char* MODS_MENU_ANM2 = "gfx/ui/main menu/ModsMenu.anm2"; constexpr const char* WIDGET_BUTTON_NULL = "WidgetButton"; @@ -90,10 +93,16 @@ std::string paper_row_text(int row, std::string_view name, std::string_view suff return (text + std::string(suffix)).substr(0, ENTRY_TEXT_LIMIT); } +// Where a row's text starts on the paper. +Vector paper_row_position(Vector origin, int row) +{ + return vector_make(origin.x + ENTRY_OFFSET_X, origin.y + (float)row * ENTRY_HEIGHT); +} + // Draws a row's text, scaled down, at its line of the paper. void paper_row_render(std::string_view text, Vector origin, int row, KColor color) { - Vector position = vector_make(origin.x + ENTRY_OFFSET_X, origin.y + (float)row * ENTRY_HEIGHT); + Vector position = paper_row_position(origin, row); FontSettings settings; g_manager->font2_TeamMeatEx12.DrawString(text, position, vector_make(ENTRY_TEXT_SCALE_X, 1), color, settings); @@ -149,10 +158,15 @@ void Menu_Mods::Update() std::vector>& mods = g_manager->modManager.mods; bool& isModsEnabled = g_manager->optionsConfig.isModsEnabled; int modCount = (int)mods.size(); + int previousSelected = selectedMod; + bool isConfirmTaken = false; +#ifdef ISAAC_REPENTOGON + isConfirmTaken = mods_menu_update_pre(*this); +#endif if (is_action(ACTION_MENU_CONFIRM, ACTION_TRIGGERED)) { - if (isModsEnabled && selectedMod < modCount) + if (isModsEnabled && selectedMod < modCount && !isConfirmTaken) { ModEntry& mod = *mods[selectedMod]; mod.isEnabled = !mod.isEnabled; @@ -181,6 +195,9 @@ void Menu_Mods::Update() bool isHeld = is_action(ACTION_MENU_DOWN, ACTION_PRESSED) || is_action(ACTION_MENU_UP, ACTION_PRESSED); holdInputTimer = isHeld ? holdInputTimer + 1 : 0; +#ifdef ISAAC_REPENTOGON + mods_menu_update_post(*this, previousSelected); +#endif } // 008e3db0 Draws the paper, the controller's tab glyph, and each mod's number and name: black when on, grey when off, @@ -194,6 +211,11 @@ void Menu_Mods::Render() bool isModsEnabled = g_manager->optionsConfig.isModsEnabled; Vector origin = paper_origin_get(position); int modCount = (int)mods.size(); + bool isReworked = false; +#ifdef ISAAC_REPENTOGON + isReworked = is_mods_menu_reworked(); + if (isReworked) mods_menu_widget_hide(*this); +#endif paper_top_render(modsMenuSprite, origin); const NullFrame* button = modsMenuSprite.GetNullFrame(WIDGET_BUTTON_NULL); @@ -208,9 +230,13 @@ void Menu_Mods::Render() KColor color = isModsEnabled && mod.isEnabled ? BLACK : kcolor_argb(DISABLED_ARGB); if (mod.isOutdated) color = isModsEnabled ? OUTDATED_COLOR : OUTDATED_OFF_COLOR; - paper_row_render(paper_row_text(row, mod.name, mod.isOutdated ? OUTDATED_SUFFIX : ""), origin, row, color); + if (!isReworked) + paper_row_render(paper_row_text(row, mod.name, mod.isOutdated ? OUTDATED_SUFFIX : ""), origin, row, color); if (isModsEnabled && row == selectedMod) paper_cursor_render(modsMenuSprite, origin, row); } +#ifdef ISAAC_REPENTOGON + if (isReworked) mods_menu_render(*this, origin); +#endif menus.viewPositionSet[MENU_MODS].y = paper_view_y_get(selectedMod, modCount); menus.isViewMoving = true; diff --git a/src/ui/menu/mods.h b/src/ui/menu/mods.h index 2712dd5..bb98d63 100644 --- a/src/ui/menu/mods.h +++ b/src/ui/menu/mods.h @@ -30,6 +30,7 @@ void paper_reset(ANM2& sprite); void paper_top_render(ANM2& sprite, Vector origin); void paper_render(ANM2& sprite, Vector origin, int rowCount); std::string paper_row_text(int row, std::string_view name, std::string_view suffix = {}); +Vector paper_row_position(Vector origin, int row); void paper_row_render(std::string_view text, Vector origin, int row, KColor color); void paper_cursor_render(ANM2& sprite, Vector origin, int row); float paper_view_y_get(int selectedRow, int rowCount); diff --git a/src/ui/menu/options.cpp b/src/ui/menu/options.cpp index 32b84be..beea893 100644 --- a/src/ui/menu/options.cpp +++ b/src/ui/menu/options.cpp @@ -12,6 +12,9 @@ #include "engine/render_passes.h" #include "engine/texture_cache.h" #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/vanilla_fixes.h" +#endif #include #include @@ -507,6 +510,9 @@ void Menu_Options::language_reload() g_game->genericPrompt.isOnlineVote = false; g_game->completionWidgetSprite.Reset(); } +#ifdef ISAAC_REPENTOGON + if (is_game_restarted()) return; // Patches/ASMPatches/ASMMenu.cpp +#endif log_printf(LOG_INFO, "Lua is resetting!\n"); lua.destroy(); lua.Init(lua.mode); diff --git a/src/ui/menu/stats.cpp b/src/ui/menu/stats.cpp index 8e01587..b1f3e04 100644 --- a/src/ui/menu/stats.cpp +++ b/src/ui/menu/stats.cpp @@ -6,6 +6,10 @@ #include #include #include +#ifdef ISAAC_REPENTOGON +#include "repentogon/achievements.h" +#include "repentogon/options.h" +#endif constexpr const char* STATS_ANM2 = "gfx/ui/main menu/StatsMenu.anm2"; constexpr const char* ACHIEVEMENTS_ANM2 = "gfx/ui/achievement/achievements.anm2"; @@ -45,6 +49,18 @@ constexpr float NUMBERS_Y = 5; constexpr float NUMBER_LINE_HEIGHT = 22; constexpr float DIGIT_STEP_X = 11; constexpr float DIGIT_STEP_Y = 1.5f; +// (Patches/AchievementsStuff.cpp) A mod's achievements pick their icon looks offset from the game's, and the source's +// title sits over the strip with half size cursors turned up and down beside it. +constexpr int MOD_ICON_OFFSET = 100; +constexpr float SOURCE_TITLE_X = 199; +constexpr float SOURCE_TITLE_Y = -3; +constexpr float SOURCE_LEFT_X = 192; +constexpr float SOURCE_LEFT_Y = 8; +constexpr float SOURCE_RIGHT_X = 205; +constexpr float SOURCE_RIGHT_Y = 4; +constexpr float SOURCE_CURSOR_SCALE = 0.5f; +constexpr float SOURCE_CURSOR_TURN = 90; +constexpr float SOURCE_TITLE_ALPHA = 0.8f; // A sprite color that only sets the alpha. static ColorMod alpha_color(float alpha) @@ -153,6 +169,9 @@ void Menu_Stats::Update() if (isAchievementScreenVisible) UpdateSecrets(); else stats_update(); +#ifdef ISAAC_REPENTOGON + secret_source_update(); +#endif statsMenuSprite.SetLayerFrame(CURSOR_LAYER, statsMenuCurrentSelection); } @@ -196,10 +215,10 @@ void Menu_Stats::stats_update() void Menu_Stats::secrets_open() { PersistentGameData& data = g_manager->persistentGameData; - int count = (int)achievementIds.size(); + int count = (int)secret_ids_get().size(); selectedAchievement = 0; - while (selectedAchievement < count && !data.Unlocked(achievementIds[selectedAchievement])) selectedAchievement++; + while (selectedAchievement < count && !data.Unlocked(secret_ids_get()[selectedAchievement])) selectedAchievement++; if (selectedAchievement >= count) return; for (int id = 1; id < ACHIEVEMENT_COUNT; id++) @@ -217,7 +236,10 @@ void Menu_Stats::secrets_open() // Shows the picture of a listed achievement, or the locked picture while it is locked. void Menu_Stats::secret_picture_set(int listIndex) { - int id = achievementIds[listIndex]; + int id = secret_ids_get()[listIndex]; +#ifdef ISAAC_REPENTOGON + if (achievement_picture_replace(achievementsSprite, id)) return; +#endif achievementsSprite.ReplaceSpritesheet(PICTURE_LAYER, g_manager->persistentGameData.Unlocked(id) ? achievementGfx[id] : LOCKED_SHEET); achievementsSprite.LoadGraphics(); @@ -273,7 +295,7 @@ void Menu_Stats::UpdateSecrets() void Menu_Stats::secret_animation_end() { std::string animation = achievementsSprite.GetAnimation(); - int count = (int)achievementIds.size(); + int count = (int)secret_ids_get().size(); if (animation == ANIMATION_DISAPPEAR || animation == ANIMATION_DISAPPEAR_NEXT) { @@ -333,7 +355,7 @@ void Menu_Stats::secret_scroll_update() // unlocked or locked, the middle one selected while the strip rests. void Menu_Stats::secret_icons_update() { - int count = (int)achievementIds.size(); + int count = (int)secret_ids_get().size(); for (int slot = 0; slot < SECRET_ICON_COUNT; slot++) { @@ -341,10 +363,10 @@ void Menu_Stats::secret_icons_update() if (index < 0) index += count; if (index >= count) index -= count; - int id = achievementIds[index]; + int id = secret_ids_get()[index]; bool isSelected = achievementScrollThruListPosition == 0 && slot == SELECTED_ICON; std::string animation = - std::format("Icon{}{}{}", iconIds[id], g_manager->persistentGameData.Unlocked(id) ? "Unlocked" : "Locked", + std::format("Icon{}{}{}", iconIds[id < ACHIEVEMENT_COUNT ? id : (id + MOD_ICON_OFFSET) % ACHIEVEMENT_COUNT], g_manager->persistentGameData.Unlocked(id) ? "Unlocked" : "Locked", isSelected ? "Selected" : ""); achievementMiniSprites[slot].Play(animation, isSelected ? PLAY_UNFORCED : PLAY_FORCED); } @@ -389,7 +411,7 @@ void Menu_Stats::Render() Font& font = g_manager->font1_TeamMeatEx10; FontSettings settings; - std::string place = std::format("{}/{}", selectedAchievement + 1, achievementIds.size()); + std::string place = std::format("{}/{}", selectedAchievement + 1, secret_ids_get().size()); float placeX = origin.x + PICTURE_X - (float)font.GetStringWidth(place) * 0.5f; font.DrawString(place, vector_make(placeX, origin.y + COUNT_Y), vector_make(1, 1), kcolor_make(0.8f, 0.8f, 0.8f, 1), settings); @@ -400,4 +422,77 @@ void Menu_Stats::Render() {vector_make((float)i * ICON_SPACING + achievementScrollThruListPosition + ICONS_X + origin.x, stripY)}); cursorLeftSprite.Render({vector_make(origin.x + CURSOR_LEFT_X, stripY)}); cursorRightSprite.Render({vector_make(origin.x + CURSOR_RIGHT_X, stripY)}); +#ifdef ISAAC_REPENTOGON + secret_source_render(origin); +#endif +} + +// The achievements the secrets page turns through: the game's, or a mod's. +std::vector& Menu_Stats::secret_ids_get() +{ +#ifdef ISAAC_REPENTOGON + if (secretSource > 0) return sourceAchievementIds; +#endif + return achievementIds; +} + +// (AchievementsStuff.cpp's Menu_Stats::Update, parity off) Up and down turn the open secrets page to the next or +// previous source while it rests, wrapping, from its first achievement. Closed, it is back on the game's. +void Menu_Stats::secret_source_update() +{ +#ifdef ISAAC_REPENTOGON + if (!isAchievementScreenVisible || repentogonOptions.isVanillaParity || !g_manager->optionsConfig.isModsEnabled) + { + if (secretSource > 0) achievement_picture_replace(achievementsSprite, 0); + secretSource = 0; + secretSources.clear(); + return; + } + if (secretSources.empty()) secretSources = achievement_sources_get(); + + bool isScrolling = achievementsSprite.IsPlaying(ANIMATION_APPEAR) || achievementsSprite.IsPlaying(ANIMATION_APPEAR_NEXT) || + achievementsSprite.IsPlaying(ANIMATION_DISAPPEAR) || + achievementsSprite.IsPlaying(ANIMATION_DISAPPEAR_NEXT); + int step = is_action(ACTION_MENU_UP, ACTION_TRIGGERED) ? 1 : is_action(ACTION_MENU_DOWN, ACTION_TRIGGERED) ? -1 : 0; + int count = (int)secretSources.size(); + if (isScrolling || step == 0 || count < 2) return; + + secretSource = (secretSource + step + count) % count; + sourceAchievementIds = achievement_source_ids_get(secretSources[secretSource]); + selectedAchievement = 0; + if (secretSource == 0) + { + PersistentGameData& data = g_manager->persistentGameData; + while (selectedAchievement < (int)achievementIds.size() && !data.Unlocked(achievementIds[selectedAchievement])) + selectedAchievement++; + selectedAchievement %= std::max((int)achievementIds.size(), 1); + } + secret_picture_set(selectedAchievement); +#endif +} + +// (AchievementsStuff.cpp's Menu_Stats::Render) The open secrets page's source title between two small cursors, when +// mods add sources. +void Menu_Stats::secret_source_render(Vector origin) +{ +#ifdef ISAAC_REPENTOGON + if (!isAchievementScreenVisible || secretSources.size() < 2) return; + + Font& font = g_manager->font1_TeamMeatEx10; + FontSettings settings; + settings.alignment = ALIGN_TOP_CENTER; + std::string title = achievement_source_name_get(secretSources[secretSource]); + float halfWidth = (float)font.GetStringWidth(title) / 2; + font.DrawString(title, vector_make(origin.x + SOURCE_TITLE_X, origin.y + SOURCE_TITLE_Y), vector_make(1, 1), + kcolor_make(1, 1, 1, SOURCE_TITLE_ALPHA), settings); + + ANM2& cursor = cursorLeftSprite; + cursor.scale = vector_make(SOURCE_CURSOR_SCALE, SOURCE_CURSOR_SCALE); + cursor.rotation = SOURCE_CURSOR_TURN; + cursor.Render({vector_make(origin.x + SOURCE_LEFT_X - halfWidth, origin.y + SOURCE_LEFT_Y)}); + cursor.rotation = -SOURCE_CURSOR_TURN; + cursor.Render({vector_make(origin.x + SOURCE_RIGHT_X + halfWidth, origin.y + SOURCE_RIGHT_Y)}); + cursor.rotation = 0; + cursor.scale = vector_make(1, 1); +#endif } diff --git a/src/ui/menu/stats.h b/src/ui/menu/stats.h index c5e6ba2..a0b31df 100644 --- a/src/ui/menu/stats.h +++ b/src/ui/menu/stats.h @@ -36,6 +36,13 @@ public: std::array iconIds{}; std::array isAchievementListed{}; std::vector achievementIds; +#ifdef ISAAC_REPENTOGON + // (Patches/AchievementsStuff.cpp, parity off) The secrets page's sources, the game's first then each mod's, the one + // shown and the mod's achievements it lists. + std::vector secretSources; + std::vector sourceAchievementIds; + int secretSource = 0; +#endif Vector position{}; float achievementScrollInPosition = 0; float achievementScrollThruListPosition = 0; @@ -66,4 +73,7 @@ private: void secret_scroll_update(); void secret_icons_update(); void number_render(uint32_t value, Vector at); + std::vector& secret_ids_get(); + void secret_source_update(); + void secret_source_render(Vector origin); }; diff --git a/src/ui/nightmare_scene.cpp b/src/ui/nightmare_scene.cpp index 4d0db10..dfd86a9 100644 --- a/src/ui/nightmare_scene.cpp +++ b/src/ui/nightmare_scene.cpp @@ -25,6 +25,7 @@ #include #ifdef ISAAC_REPENTOGON #include "repentogon/callbacks.h" +#include "repentogon/player_config.h" #endif constexpr std::string_view BACKGROUND_DEFAULT = "nightmare_bg.anm2"; @@ -312,17 +313,25 @@ void NightmareScene::Show(bool isSameStageShown) } EntityConfig_Player* config = g_manager->entityConfig.GetPlayer(player->playerType); + std::string portraitPath = config ? config->portraitPath : std::string(); + std::string extraPortraitPath = config ? config->extraPortraitPath : std::string(); +#ifdef ISAAC_REPENTOGON + if (std::string stage = player_stage_portrait_get(player->playerType, "stageportrait"); !stage.empty()) + portraitPath = stage; // Patches/PlayerTags.cpp + if (std::string extra = player_stage_portrait_get(player->playerType, "extrastageportrait"); !extra.empty()) + extraPortraitPath = extra; +#endif if (config) { - backgroundSprite.ReplaceSpritesheet(PORTRAIT_LAYER, config->portraitPath); - backgroundSprite.ReplaceSpritesheet(PORTRAIT_ALT_LAYER, config->portraitPath); + backgroundSprite.ReplaceSpritesheet(PORTRAIT_LAYER, portraitPath); + backgroundSprite.ReplaceSpritesheet(PORTRAIT_ALT_LAYER, portraitPath); } else log_printf(LOG_INFO, "[warn] could not load player config for type %d.\n", player->playerType); playerExtraPortraitSprite.Reset(); // The original read a missing character's animated portrait through a null pointer. This shows none. - if (config && !config->extraPortraitPath.empty()) + if (config && !extraPortraitPath.empty()) { - playerExtraPortraitSprite.Load(config->extraPortraitPath, GRAPHICS_LOAD); + playerExtraPortraitSprite.Load(extraPortraitPath, GRAPHICS_LOAD); playerExtraPortraitSprite.Play(playerExtraPortraitSprite.GetDefaultAnimationName()); } backgroundSprite.ReplaceSpritesheet(BOSS_SPOT_LAYER, game.roomConfig.stages[game.GetStageID()].bossSpot); diff --git a/src/ui/overlay/console.cpp b/src/ui/overlay/console.cpp index 252e20a..e569a9d 100644 --- a/src/ui/overlay/console.cpp +++ b/src/ui/overlay/console.cpp @@ -6,6 +6,7 @@ #include "game/sfx_manager.h" #ifdef ISAAC_REPENTOGON #include "repentogon/api_game.h" +#include "repentogon/options.h" #endif #include "ui/console.h" #include @@ -14,6 +15,7 @@ #include #include #include +#include constexpr int MAX_SUGGESTIONS = 8; constexpr int NO_MATCH = INT_MAX; @@ -35,9 +37,13 @@ static std::string text_lower(std::string_view text) return lower; } -// Whether commands can run: in a run, where the console lives. +// Whether commands can run: in a run, where the console lives, or anywhere with REPENTOGON's console hooks +// (Patches/ConsoleHooks.cpp) without vanilla parity. static bool is_run_live() { +#ifdef ISAAC_REPENTOGON + if (g_game && !repentogonOptions.isVanillaParity) return true; +#endif return g_game && g_manager->state == MANAGER_STATE_GAME; } @@ -188,6 +194,50 @@ void Overlay::log_render() ImGui::EndChild(); } +constexpr size_t LOG_VIEWER_MAX_SIZE = 4 * 1024 * 1024; +constexpr size_t LOG_VIEWER_REDUCE_SIZE = LOG_VIEWER_MAX_SIZE / 4; + +static std::mutex logViewerMutex; +static std::string logViewerText; +static ImGuiTextFilter logViewerFilter; +static bool isLogViewerScrolled = true; + +// (ASMPatches.cpp's LogMessage patch, ImGuiFeatures/LogViewer.h) Keeps what the game logs for the Log window, its +// oldest lines dropped once it outgrows its size. +void log_viewer_append(const std::string& text) +{ + std::lock_guard lock(logViewerMutex); + logViewerText += text; + if (logViewerText.size() <= LOG_VIEWER_MAX_SIZE) return; + size_t end = logViewerText.find('\n', LOG_VIEWER_REDUCE_SIZE); + logViewerText.erase(0, end == std::string::npos ? logViewerText.size() : end + 1); +} + +// REPENTOGON's Log Viewer: everything logged since the overlay started, the lines a filter passes, kept at its end +// while autoscroll is on. +void Overlay::log_viewer_render() +{ + std::lock_guard lock(logViewerMutex); + if (ImGui::Button("Clear")) logViewerText.clear(); + ImGui::SameLine(); + ImGui::Checkbox("Autoscroll", &isLogViewerScrolled); + ImGui::SameLine(); + logViewerFilter.Draw("Filter", -FLT_MIN); + + ImGui::BeginChild("lines", {0, 0}, ImGuiChildFlags_Borders, ImGuiWindowFlags_HorizontalScrollbar); + const char* text = logViewerText.data(); + const char* textEnd = text + logViewerText.size(); + if (!logViewerFilter.IsActive()) ImGui::TextUnformatted(text, textEnd); + for (const char* line = text; logViewerFilter.IsActive() && line < textEnd;) + { + const char* lineEnd = std::find(line, textEnd, '\n'); + if (logViewerFilter.PassFilter(line, lineEnd)) ImGui::TextUnformatted(line, lineEnd); + line = lineEnd + 1; + } + if (isLogViewerScrolled && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) ImGui::SetScrollHereY(1); + ImGui::EndChild(); +} + // The log above the input. Enter runs the line through the console as its own Enter does: recorded in its command // history, echoed, then run. Commands wait for a run, as the console does. void Overlay::console_render() diff --git a/src/ui/overlay/overlay.cpp b/src/ui/overlay/overlay.cpp index 325fa54..cd5b98e 100644 --- a/src/ui/overlay/overlay.cpp +++ b/src/ui/overlay/overlay.cpp @@ -36,14 +36,16 @@ constexpr ImWchar ICON_TERMINAL = 0xF120; constexpr ImWchar ICON_GEARS = 0xF085; constexpr ImWchar ICON_SPARKLES = 0xE2CA; // wand-magic-sparkles constexpr ImWchar ICON_BUG = 0xF188; +constexpr ImWchar ICON_LOG = 0xF15C; // file-lines // Font Awesome's whole private use range, as mods' menus name any of its icons. constexpr ImWchar ICON_FIRST = 0xE000; constexpr ImWchar ICON_LAST = 0xF8FF; constexpr ImWchar ICON_RANGES[] = {ICON_FIRST, ICON_LAST, 0}; // Each window's name and icon, in OverlayWindow order. -constexpr const char* WINDOW_NAMES[OVERLAY_WINDOW_COUNT] = {"Console", "Game Options", "Mods", "Debug"}; -constexpr ImWchar WINDOW_ICONS[OVERLAY_WINDOW_COUNT] = {ICON_TERMINAL, ICON_GEARS, ICON_SPARKLES, ICON_BUG}; +constexpr const char* WINDOW_NAMES[OVERLAY_WINDOW_COUNT] = {"Console", "Game Options", "Mods", "Debug", "Log"}; +constexpr ImWchar WINDOW_ICONS[OVERLAY_WINDOW_COUNT] = {ICON_TERMINAL, ICON_GEARS, ICON_SPARKLES, ICON_BUG, + ICON_LOG}; Overlay overlay; @@ -108,6 +110,7 @@ void Overlay::load() layoutPath = platform.userDataDirectory + LAYOUT_FILE; io.IniFilename = layoutPath.c_str(); io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; + logListener = log_viewer_append; fonts_load(); ImGui_ImplSDL3_InitForOpenGL(platform.window, platform.context); @@ -127,6 +130,7 @@ void Overlay::load() void Overlay::unload() { if (!std::exchange(isReady, false)) return; + logListener = nullptr; for (auto& [path, texture] : thumbnails) gl.DeleteTextures(1, &texture); thumbnails.clear(); @@ -207,7 +211,8 @@ static bool* close_get(const char* name, bool& isOpen) void Overlay::render() { constexpr void (Overlay::*WINDOW_RENDERS[OVERLAY_WINDOW_COUNT])() = { - &Overlay::console_render, &Overlay::options_render, &Overlay::mods_render, &Overlay::debug_render}; + &Overlay::console_render, &Overlay::options_render, &Overlay::mods_render, &Overlay::debug_render, + &Overlay::log_viewer_render}; if (!isReady) return; #ifdef ISAAC_REPENTOGON diff --git a/src/ui/overlay/overlay.h b/src/ui/overlay/overlay.h index bef87d4..445142d 100644 --- a/src/ui/overlay/overlay.h +++ b/src/ui/overlay/overlay.h @@ -15,6 +15,7 @@ enum OverlayWindow OVERLAY_OPTIONS, OVERLAY_MODS, OVERLAY_DEBUG, + OVERLAY_LOG, OVERLAY_WINDOW_COUNT }; @@ -33,9 +34,9 @@ struct OverlaySuggestion }; // The developer overlay (Dear ImGui) in place of the drop-down console, toggled with ` or a mod's console input: the -// Console, Game Options, Mods and Debug windows. It is never made under the test harness. +// Console, Game Options, Mods, Debug and Log windows. It is never made under the test harness. // While it shows it takes the keyboard, mouse, gamepads and text from the game, and a run pauses as for the console. -// Its windows are drawn in console.cpp, game_options.cpp, mods.cpp and debug.cpp. +// Its windows are drawn in console.cpp (with the log), game_options.cpp, mods.cpp and debug.cpp. class Overlay { public: @@ -60,7 +61,7 @@ private: int bindingSlot = 0; int selected = -1; unsigned int listId = 0; - bool isOpen[OVERLAY_WINDOW_COUNT] = {true, true, true, true}; + bool isOpen[OVERLAY_WINDOW_COUNT] = {true, true, true, true, false}; bool isConsoleFrontPending = false; bool isCursorEndPending = false; bool isDismissed = false; @@ -79,6 +80,7 @@ private: void menu_bar_render(); void console_render(); void log_render(); + void log_viewer_render(); void suggestions_load(); void suggestions_render(); static int input_respond(ImGuiInputTextCallbackData* data); @@ -96,3 +98,5 @@ private: }; extern Overlay overlay; + +void log_viewer_append(const std::string& text);