diff --git a/.gitmodules b/.gitmodules index 4a788068..b35cb266 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "LunadllNewLauncher/SMBXLauncher/PGE_File_Formats"] path = LunadllNewLauncher/SMBXLauncher/PGE_File_Formats - url = https://github.com/Wohlhabend-Networks/PGE-File-Library-STL.git + url = https://github.com/WohlSoft/PGE-File-Library-STL [submodule "LunaDll/libs/PGE_File_Formats"] path = LunaDll/libs/PGE_File_Formats url = https://github.com/WohlSoft/PGE-File-Library-STL diff --git a/LunaDll/Input/LunaGameController.cpp b/LunaDll/Input/LunaGameController.cpp index b7072808..38e9dd77 100644 --- a/LunaDll/Input/LunaGameController.cpp +++ b/LunaDll/Input/LunaGameController.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "LunaGameController.h" #if !defined(BUILDING_SMBXLAUNCHER) # ifdef _WIN32 @@ -486,6 +487,16 @@ std::string LunaGameControllerManager::getSelectedControllerName(int playerNum) return "Keyboard"; } +std::tuple LunaGameControllerManager::getSelectedControllerStickPosition(int playerNum) +{ + LunaGameController* controller = getController(playerNum); + if (controller != nullptr) + { + return controller->getStickPosition(); + } + return {0, 0}; +} + void LunaGameControllerManager::rumbleSelectedController(int playerNum, int ms, float strength) { LunaGameController* controller = getController(playerNum); @@ -660,6 +671,8 @@ LunaGameController::LunaGameController(LunaGameControllerManager* _managerPtr, S axisPadState(0), padState(0), buttonState(0), + xAxis(0), + yAxis(0), activeFlag(false), joyButtonMap() { @@ -773,6 +786,8 @@ LunaGameController::LunaGameController(LunaGameController &&other) axisPadState = other.axisPadState; padState = other.padState; buttonState = other.buttonState; + xAxis = other.xAxis; + yAxis = other.yAxis; activeFlag = other.activeFlag; joyButtonMap = other.joyButtonMap; other.joyPtr = nullptr; @@ -795,6 +810,8 @@ LunaGameController & LunaGameController::operator=(LunaGameController &&other) axisPadState = other.axisPadState; padState = other.padState; buttonState = other.buttonState; + xAxis = other.xAxis; + yAxis = other.yAxis; activeFlag = other.activeFlag; joyButtonMap = other.joyButtonMap; other.joyPtr = nullptr; @@ -986,11 +1003,13 @@ void LunaGameController::controllerAxisEvent(const SDL_ControllerAxisEvent& even axisAsDirectional = true; posPadNumber = CONTROLLER_PAD_RIGHT; negPadNumber = CONTROLLER_PAD_LEFT; + xAxis = (int)event.value; break; case SDL_CONTROLLER_AXIS_LEFTY: axisAsDirectional = true; posPadNumber = CONTROLLER_PAD_DOWN; negPadNumber = CONTROLLER_PAD_UP; + yAxis = (int)event.value; break; default: break; diff --git a/LunaDll/Input/LunaGameController.h b/LunaDll/Input/LunaGameController.h index 191a8cd0..c0a6ffd5 100644 --- a/LunaDll/Input/LunaGameController.h +++ b/LunaDll/Input/LunaGameController.h @@ -3,6 +3,7 @@ #include #include +#include #include struct joyinfoex_tag; @@ -55,6 +56,7 @@ class LunaGameController inline void clearActive() { activeFlag = false; } inline unsigned int getPadState() const { return padState; } inline unsigned int getButtonState() const { return buttonState; } + inline std::tuple getStickPosition() const { return {xAxis, yAxis}; } SDL_JoystickPowerLevel getPowerLevel(); @@ -115,6 +117,8 @@ class LunaGameController unsigned int axisPadState; unsigned int padState; unsigned int buttonState; + int xAxis; + int yAxis; bool activeFlag; std::vector joyButtonMap; }; @@ -156,6 +160,7 @@ class LunaGameControllerManager public: SDL_JoystickPowerLevel getSelectedControllerPowerLevel(int playerNum); std::string getSelectedControllerName(int playerNum); + std::tuple getSelectedControllerStickPosition(int playerNum); void rumbleSelectedController(int playerNum, int ms, float strength); LunaGameController* getController(int playerNum); private: diff --git a/LunaDll/LuaMain/LuaProxyFFI.cpp b/LunaDll/LuaMain/LuaProxyFFI.cpp index bd0e6d94..3adec2b0 100644 --- a/LunaDll/LuaMain/LuaProxyFFI.cpp +++ b/LunaDll/LuaMain/LuaProxyFFI.cpp @@ -408,6 +408,18 @@ extern "C" { return (int)SDL_JOYSTICK_POWER_UNKNOWN; } + struct StickPos + { + int x; + int y; + }; + FFI_EXPORT(StickPos) LunaLuaGetSelectedControllerStickPosition(int playerNum) + { + const auto stickPos = gLunaGameControllerManager.getSelectedControllerStickPosition(playerNum); + + return {std::get<0>(stickPos), std::get<1>(stickPos)}; + } + FFI_EXPORT(const char*) LunaLuaGetSelectedControllerName(int playerNum) { static std::string name; @@ -534,6 +546,18 @@ typedef struct ExtendedPlayerFields_\ } } + FFI_EXPORT(void) LunaLuaSetNPCCeilingBugFix(bool enable) + { + if (enable) + { + gNPCCeilingBugFix.Apply(); + } + else + { + gNPCCeilingBugFix.Unapply(); + } + } + FFI_EXPORT(void) LunaLuaSetNPCSectionFix(bool enable) { if (enable) diff --git a/LunaDll/LuaMain/LunaLuaMain.cpp b/LunaDll/LuaMain/LunaLuaMain.cpp index b09883d1..02096905 100644 --- a/LunaDll/LuaMain/LunaLuaMain.cpp +++ b/LunaDll/LuaMain/LunaLuaMain.cpp @@ -133,6 +133,7 @@ bool CLunaLua::shutdown() gDisablePlayerDownwardClipFix.Apply(); gDisableNPCDownwardClipFix.Apply(); gDisableNPCDownwardClipFixSlope.Apply(); + gNPCCeilingBugFix.Apply(); gNPCSectionFix.Apply(); gFenceFixes.Apply(); gLinkFairyClowncarFixes.Apply(); diff --git a/LunaDll/Misc/RuntimeHook.h b/LunaDll/Misc/RuntimeHook.h index fc43829f..bdabeaa5 100644 --- a/LunaDll/Misc/RuntimeHook.h +++ b/LunaDll/Misc/RuntimeHook.h @@ -39,6 +39,7 @@ void TrySkipPatch(); extern AsmPatch<777> gDisablePlayerDownwardClipFix; extern AsmPatch<8> gDisableNPCDownwardClipFix; extern AsmPatch<6> gDisableNPCDownwardClipFixSlope; +extern AsmPatch<21> gNPCCeilingBugFix; extern Patchable& gNPCSectionFix; extern Patchable& gFenceFixes; extern Patchable& gLinkFairyClowncarFixes; diff --git a/LunaDll/Misc/RuntimeHookComponents/RuntimeHookGeneral.cpp b/LunaDll/Misc/RuntimeHookComponents/RuntimeHookGeneral.cpp index 0b6d0465..688951e3 100644 --- a/LunaDll/Misc/RuntimeHookComponents/RuntimeHookGeneral.cpp +++ b/LunaDll/Misc/RuntimeHookComponents/RuntimeHookGeneral.cpp @@ -1266,6 +1266,8 @@ static unsigned int __stdcall LatePatch(void) AsmPatch<777> gDisablePlayerDownwardClipFix = PATCH(0x9A3FD3).JMP(runtimeHookCompareWalkBlockForPlayerWrapper).NOP_PAD_TO_SIZE<777>(); AsmPatch<8> gDisableNPCDownwardClipFix = PATCH(0xA16B82).JMP(runtimeHookCompareNPCWalkBlock).NOP_PAD_TO_SIZE<8>(); +AsmPatch<21> gNPCCeilingBugFix = PATCH(0xA17155).NOP_PAD_TO_SIZE<21>(); + // NOTE: This patch replaces a section 167 bytes long from 0xA13188 to 0xA1322E, but we don't NOP out the whole thing // since that would conflict with NpcIdExtender, and this patch may be turned on/off at runtime. AsmPatch<6> gDisableNPCDownwardClipFixSlope = PATCH(0xA13188).JMP(runtimeHookNPCWalkFixSlope).NOP_PAD_TO_SIZE<6>(); @@ -2083,6 +2085,9 @@ void TrySkipPatch() // Hook to fix an NPC's section property when it spawn out of bounds gNPCSectionFix.Apply(); + // Hook to fix erroneous Y speed after an NPC hits a ceiling + gNPCCeilingBugFix.Apply(); + // Patch to handle block reorder after p-switch handling PATCH(0x9E441A).JMP(runtimeHookAfterPSwitchBlocksReorderedWrapper).NOP_PAD_TO_SIZE<242>().Apply(); PATCH(0x9E3D30).JMP(runtimeHookPSwitchStartRemoveBlockWrapper).NOP_PAD_TO_SIZE<110>().Apply(); diff --git a/README.md b/README.md index 153a2fc0..a049a986 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ LunaLua ======= [![Build status](https://ci.appveyor.com/api/projects/status/72ttgr33ggar3x21?svg=true)](https://ci.appveyor.com/project/Wohlstand/lunadll) -LunaLua - LunaDLL with Lua is a free extension for SMBX game engine -This version is based on LunaDLL ver. 8 with Lua Support. +LunaLua (a.k.a. LunaDLL with Lua) - is a free extension for SMBX game engine. +This version is based on LunaDLL ver. 8 with Lua Support. After the release of 0.7.3.1, LunaLua is being developed as a core part of the [SMBX2 project](https://codehaus.moe). Quick Overview ------- @@ -14,12 +14,17 @@ Quick Overview * npc-*.txt with decimal numbers will no more crash SMBX with "runtime error 13" * fixes a random crash caused by contacting of the mushrooms with a lava blocks * OpenGL render support -* SMBX's audio engine has been replaced with the better and more flexible SDL2_mixer library which also gives to SMBX the internal support of a [lots of additional music formats](http://wohlsoft.ru/pgewiki/SDL2_mixer#Music_Formats) -* Added PGE's [sounds.ini](http://wohlsoft.ru/pgewiki/Game_Configuration_Pack_References#sounds.ini) and [music.ini](http://wohlsoft.ru/pgewiki/Game_Configuration_Pack_References#music.ini) support which gives ability to have custom musics (include world map musics!) and custom sound effects per episode. +* SMBX's audio engine has been replaced with the better and more flexible `SDL2_mixer` (Later its fork called `SDL2 Mixer X` or just `MixerX`) library which also gives to SMBX the internal support of a [lots of additional music formats](https://wohlsoft.ru/pgewiki/SDL_Mixer_X#Music_Formats) +* Added Moondust's [sounds.ini](https://wohlsoft.ru/pgewiki/Sounds.ini_(Episode)) and [music.ini](https://wohlsoft.ru/pgewiki/Music.ini_(Episode)) support which gives ability to have custom musics (include world map musics!) and custom sound effects per episode. +* And more other stuff... **Download links** -* [Download LunaLua](http://wohlsoft.ru/LunaLua/) -* [LunaLua Documenation](http://wohlsoft.ru/pgewiki/Category:LunaLua_API) +* [Download SMBX2 game](https://codehaus.moe/) - The mainstream game based on the LunaLua. +* [SMBX2 Documentation](https://docs.codehaus.moe/) - The most current documentation for the LunaLua API. + +**Old downloads** +* [Download old releases of LunaLua](https://wohlsoft.ru/projects/LunaLua/) - Legacy standalone LunaLua releases. +* [Legacy LunaLua Documenation](https://wohlsoft.ru/pgewiki/Category:LunaLua_API) - The documentation mostly for old versions of LunaLua. Requirements to build LunaLua yourself ------ @@ -51,7 +56,7 @@ If you wish you edit code via Qt Creator, you still must have Visual Studio beca * Open project and configure it * Go to the "Projects" tab * Disable shadow build for both Debug and Release -* remove ALL items from "Building" and "Cenaring" sections +* remove ALL items from "Building" and "Cleaning" sections * Add into "Building" a special item with: ** Command "build.bat" ** Argument "Debug" for debug build and "Release" argument for release build