|
| 1 | +#include "misc_patches.h" |
1 | 2 | #include <api/SWA.h> |
2 | 3 | #include <ui/game_window.h> |
3 | 4 | #include <user/achievement_manager.h> |
@@ -204,3 +205,43 @@ bool StageCollisionDebugViewMidAsmHook(PPCRegister& r27) |
204 | 205 |
|
205 | 206 | return false; |
206 | 207 | } |
| 208 | + |
| 209 | +// The game is set up so that after parsing the Stage.set.xml it checks if TerrainInfoFile is found or not. |
| 210 | +// Based on the result of that it will either draw terrain or debug collision (if enabled). |
| 211 | +// |
| 212 | +// The XMLs in the game are populated like this generally speaking: |
| 213 | +// <Terrain> |
| 214 | +// <TerrainInfoFile>terrain</TerrainInfoFile> |
| 215 | +// <GIAtlas>1</GIAtlas> |
| 216 | +// </Terrain> |
| 217 | +// <Terrain> |
| 218 | +// <RigidBodyContainer>collision</RigidBodyContainer> |
| 219 | +// <IsCollisionRender>false</IsCollisionRender> |
| 220 | +// </Terrain> |
| 221 | +// |
| 222 | +// In some cases however, the information in these two Terrain blocks however combined into one block, |
| 223 | +// which makes the logic checking TerrainInfoFile's contents only fire once, and with success only, as such |
| 224 | +// the logic for drawing collision will never execute. |
| 225 | +// |
| 226 | +// To combat this we check if both types returned with some value from the XML file, which indicates that its |
| 227 | +// a single Terrain block, and if so we store that information so we can later on re-use to manually fire the |
| 228 | +// logic controlling the drawing of the debug collision view. |
| 229 | +void StageCollisionDebugViewStoreXmlTypeMidAsmHook(PPCRegister& r1) |
| 230 | +{ |
| 231 | + uint8_t* base = g_memory.base; |
| 232 | + |
| 233 | + const char* rigidBodyContainer = (const char*)(base + PPC_LOAD_U32(r1.u32 + 108)); |
| 234 | + const char* terrainInfoFile = (const char*)(base + PPC_LOAD_U32(r1.u32 + 132)); |
| 235 | + if (*rigidBodyContainer != '\0' && *terrainInfoFile != '\0') |
| 236 | + { |
| 237 | + g_singleTerrainBlockXml = true; |
| 238 | + } |
| 239 | +} |
| 240 | + |
| 241 | +bool StageCollisionDebugViewSingleTerrainBlockXmlMidAsmHook() |
| 242 | +{ |
| 243 | + bool runCollisionViewDrawLogic = g_singleTerrainBlockXml; |
| 244 | + g_singleTerrainBlockXml = false; |
| 245 | + |
| 246 | + return runCollisionViewDrawLogic; |
| 247 | +} |
0 commit comments