|
8 | 8 | #include "Helpers/Dropper.hpp" |
9 | 9 | #include "Helpers/Inventory.hpp" |
10 | 10 | #include "Helpers/GameKeyboard.hpp" |
| 11 | +#include "Helpers/Player.hpp" |
11 | 12 | #include "RuntimeContext.hpp" |
12 | 13 | #include "Color.h" |
13 | 14 |
|
14 | | -extern "C" void MoveFurn(void); |
15 | 15 | extern "C" void PATCH_MoveFurnButton(void); |
16 | 16 | extern "C" void PATCH_ToolAnim(void); |
17 | 17 |
|
18 | | -extern "C" bool __IsIndoors(void) { |
19 | | - return CTRPluginFramework::RuntimeContext::getInstance()->isIndoors(); |
20 | | -} |
21 | | - |
22 | 18 | u8 toolTypeAnimID = 6; |
23 | 19 |
|
24 | | -extern "C" bool __IsAnimID(u8 toolAnimID) { |
25 | | - static const u8 toolAnimIDArr[18] = { 0xB0, 0x49, 0x55, 0x6C, 0xA0, 0x98, 0x8F, 0x91, 0xC3, 0xCE, 0xCF, 0x8D, 0x8E, 0x91, 0xB1, 0xB1, 0x70, 0x9A }; |
26 | | - return std::find(std::begin(toolAnimIDArr), std::end(toolAnimIDArr), toolAnimID) != std::end(toolAnimIDArr); |
27 | | -} |
28 | | - |
29 | 20 | namespace CTRPluginFramework { |
30 | 21 | //Change Tool Animation |
31 | 22 | void tooltype(MenuEntry *entry) { |
@@ -224,32 +215,82 @@ namespace CTRPluginFramework { |
224 | 215 | fovlargeMod.Unpatch(); |
225 | 216 | } |
226 | 217 | } |
| 218 | + |
| 219 | + u32 MoveFurniturePatch(void) { |
| 220 | + const HookContext &curr = HookContext::GetCurrent(); |
| 221 | + static Address func = Address::decodeARMBranch(curr.targetAddress, curr.overwrittenInstr); |
| 222 | + func.Call<u32>(); |
| 223 | + |
| 224 | + return Player::IsIndoors(); |
| 225 | + } |
| 226 | + |
| 227 | + u32 LightSwitchPatch(void) { |
| 228 | + return Player::IsIndoors(); |
| 229 | + } |
| 230 | + |
227 | 231 | //Move Furniture |
228 | 232 | void roomSeeder(MenuEntry *entry) { |
229 | | - static const Address movefurn(0x5B531C); |
230 | | - static const Address lightswitch(0x5B7558); |
231 | | - static const Address MoveFurnPatch(0x326B98); |
232 | | - |
233 | | - static Hook hook1, hook2, hook3; |
| 233 | + static const Address movingFurniture(0x4E1720); |
| 234 | + static const Address pickingUpFurniture(0x678AC0); |
| 235 | + static const Address placingFurniture1(0x76B880); |
| 236 | + static const Address placingFurniture2(0x26FED8); |
| 237 | + static const Address placingFurniture3(0x4E78A8); |
| 238 | + static const Address lightswitchVisible(0x3279CC); |
| 239 | + static const Address lightswitchFunction(0x3277E8); |
| 240 | + static const Address moveFurnButton(0x326B98); |
| 241 | + |
| 242 | + static Hook movingFurnitureHook; |
| 243 | + static Hook pickingUpFurnitureHook; |
| 244 | + static Hook placingFurnitureHook1; |
| 245 | + static Hook placingFurnitureHook2; |
| 246 | + static Hook placingFurnitureHook3; |
| 247 | + static Hook lightSwitchVisibleHook; |
| 248 | + static Hook lightSwitchFunctionHook; |
| 249 | + static Hook moveFurnButtonHook; |
234 | 250 |
|
235 | 251 | if(entry->WasJustActivated()) { |
236 | | - hook1.Initialize(movefurn.addr, (u32)MoveFurn); |
237 | | - hook1.SetFlags(USE_LR_TO_RETURN); |
238 | | - hook1.Enable(); |
| 252 | + movingFurnitureHook.Initialize(movingFurniture.addr, (u32)MoveFurniturePatch); |
| 253 | + movingFurnitureHook.SetFlags(USE_LR_TO_RETURN); |
| 254 | + movingFurnitureHook.Enable(); |
| 255 | + |
| 256 | + pickingUpFurnitureHook.Initialize(pickingUpFurniture.addr, (u32)MoveFurniturePatch); |
| 257 | + pickingUpFurnitureHook.SetFlags(USE_LR_TO_RETURN); |
| 258 | + pickingUpFurnitureHook.Enable(); |
| 259 | + |
| 260 | + placingFurnitureHook1.Initialize(placingFurniture1.addr, (u32)MoveFurniturePatch); |
| 261 | + placingFurnitureHook1.SetFlags(USE_LR_TO_RETURN); |
| 262 | + placingFurnitureHook1.Enable(); |
| 263 | + |
| 264 | + placingFurnitureHook2.Initialize(placingFurniture2.addr, (u32)MoveFurniturePatch); |
| 265 | + placingFurnitureHook2.SetFlags(USE_LR_TO_RETURN); |
| 266 | + placingFurnitureHook2.Enable(); |
| 267 | + |
| 268 | + placingFurnitureHook3.Initialize(placingFurniture3.addr, (u32)MoveFurniturePatch); |
| 269 | + placingFurnitureHook3.SetFlags(USE_LR_TO_RETURN); |
| 270 | + placingFurnitureHook3.Enable(); |
| 271 | + |
| 272 | + lightSwitchVisibleHook.Initialize(lightswitchVisible.addr, (u32)LightSwitchPatch); |
| 273 | + lightSwitchVisibleHook.SetFlags(USE_LR_TO_RETURN); |
| 274 | + lightSwitchVisibleHook.Enable(); |
239 | 275 |
|
240 | | - hook2.Initialize(lightswitch.addr, (u32)MoveFurn); |
241 | | - hook2.SetFlags(USE_LR_TO_RETURN); |
242 | | - hook2.Enable(); |
| 276 | + lightSwitchFunctionHook.Initialize(lightswitchFunction.addr, (u32)LightSwitchPatch); |
| 277 | + lightSwitchFunctionHook.SetFlags(USE_LR_TO_RETURN); |
| 278 | + lightSwitchFunctionHook.Enable(); |
243 | 279 |
|
244 | | - hook3.Initialize(MoveFurnPatch.addr, (u32)PATCH_MoveFurnButton); |
245 | | - hook3.SetFlags(USE_LR_TO_RETURN); |
246 | | - hook3.Enable(); |
| 280 | + moveFurnButtonHook.Initialize(moveFurnButton.addr, (u32)PATCH_MoveFurnButton); |
| 281 | + moveFurnButtonHook.SetFlags(USE_LR_TO_RETURN); |
| 282 | + moveFurnButtonHook.Enable(); |
247 | 283 | } |
248 | 284 |
|
249 | 285 | else if(!entry->IsActivated()) { |
250 | | - hook1.Disable(); |
251 | | - hook2.Disable(); |
252 | | - hook3.Disable(); |
| 286 | + movingFurnitureHook.Disable(); |
| 287 | + pickingUpFurnitureHook.Disable(); |
| 288 | + placingFurnitureHook1.Disable(); |
| 289 | + placingFurnitureHook2.Disable(); |
| 290 | + placingFurnitureHook3.Disable(); |
| 291 | + lightSwitchVisibleHook.Disable(); |
| 292 | + lightSwitchFunctionHook.Disable(); |
| 293 | + moveFurnButtonHook.Disable(); |
253 | 294 | } |
254 | 295 | } |
255 | 296 | //Can Walk When Talk /*Made by Jay*/ |
|
0 commit comments