diff --git a/Game Files/GRID.cpp b/Game Files/GRID.cpp index b2d6790..3c34c88 100644 --- a/Game Files/GRID.cpp +++ b/Game Files/GRID.cpp @@ -17,7 +17,7 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. static EffectTriggers* myTriggers; static EffectConstants* myConstants; static Helpers* myHelpers; -static SDL_Event e; + static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); static int SpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, settingsFilename); static int GearChangeStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearChangeStrength"), 20, settingsFilename); @@ -32,97 +32,90 @@ static int GearChangeThread(void* ptr) return 0; } -static int RunningThread(void* ptr) -{ - int cnt; - for (cnt = 0; cnt >= 0; ++cnt) - { - INT_PTR WallBase = myHelpers->ReadIntPtr(0xB1B7F0, true); - INT_PTR WallBase1 = myHelpers->ReadIntPtr(WallBase + 0x730, false); - INT_PTR WallBase2 = myHelpers->ReadIntPtr(WallBase1 + 0x4, false); - INT_PTR WallBase3 = myHelpers->ReadIntPtr(WallBase2 + 0x4, false); - float WallBase4 = myHelpers->ReadFloat32(WallBase3 + 0x118, false); - INT_PTR PanelBase = myHelpers->ReadIntPtr(0xA3FA34, true); - INT_PTR PanelBase1 = myHelpers->ReadIntPtr(PanelBase + 0x678, false); - INT_PTR PanelBase2 = myHelpers->ReadIntPtr(PanelBase1 + 0x14, false); - INT_PTR PanelBase3 = myHelpers->ReadIntPtr(PanelBase2 + 0x30, false); - UINT8 PanelBase4 = myHelpers->ReadByte(PanelBase3 + 0x2C, false); - UINT8 Wheels = myHelpers->ReadByte(PanelBase3 + 0xB4, false); - UINT8 Skids = myHelpers->ReadByte(PanelBase3 + 0x100, false); - UINT8 AI = myHelpers->ReadByte(PanelBase3 + 0x3D4, false); - UINT8 gear = myHelpers->ReadByte(0x346A5C6C, false); - INT_PTR speedoBase = myHelpers->ReadIntPtr(0x28C008, true); - INT_PTR speedoBase1 = myHelpers->ReadIntPtr(speedoBase + 0xD0, false); - INT_PTR speedoBase2 = myHelpers->ReadIntPtr(speedoBase1 + 0x460, false); - INT_PTR speedoBase3 = myHelpers->ReadIntPtr(speedoBase2 + 0x184, false); - float speedo = myHelpers->ReadFloat32(speedoBase3 + 0x4F4, false); - - UINT8 static oldgear = 0; - UINT8 newgear = gear; - - { - myTriggers->Springi(SpringStrength / 100.0); - } - - if ((oldgear != newgear) && (speedo > 0)) - { - SDL_Thread* gearChangeThread = SDL_CreateThread(GearChangeThread, "GearChangeThread", (void*)NULL); - } - - if (Wheels > 0) - { - double percentForce = Wheels / 37.0; - double percentLength = 100; - myTriggers->Rumble(percentForce, percentForce, percentLength); - myTriggers->Sine(80, 80, percentForce); - } - - if ((Skids > 12) && (speedo > 0)) - { - double percentForce = ((Skids - 12) / 8.0); - double percentLength = 100; - myTriggers->Rumble(percentForce, 0, percentLength); - } - - if ((AI > 0) && (PanelBase4 > 0)) - { - double percentForce = (PanelBase4) / 8.0; - double percentLength = 100; - myTriggers->Rumble(percentForce, percentForce, percentLength); - } - - if ((WallBase4 > 0) && (PanelBase4 > 0)) - { - double percentForce = (PanelBase4) / 8.0; - double percentLength = 100; - myTriggers->Rumble(percentForce, 0, percentLength); - myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((WallBase4 < 0) && (PanelBase4 > 0)) - { - double percentForce = (PanelBase4) / 8.0; - double percentLength = 100; - myTriggers->Rumble(0, percentForce, percentLength); - myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); - } - oldgear = newgear; - } - return 0; -} - void GRID::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { + INT_PTR WallBase = helpers->ReadIntPtr(0xB1B7F0, true); + INT_PTR WallBase1 = helpers->ReadIntPtr(WallBase + 0x730, false); + INT_PTR WallBase2 = helpers->ReadIntPtr(WallBase1 + 0x4, false); + INT_PTR WallBase3 = helpers->ReadIntPtr(WallBase2 + 0x4, false); + float WallBase4 = helpers->ReadFloat32(WallBase3 + 0x118, false); + INT_PTR PanelBase = helpers->ReadIntPtr(0xA3FA34, true); + INT_PTR PanelBase1 = helpers->ReadIntPtr(PanelBase + 0x678, false); + INT_PTR PanelBase2 = helpers->ReadIntPtr(PanelBase1 + 0x14, false); + INT_PTR PanelBase3 = helpers->ReadIntPtr(PanelBase2 + 0x30, false); + UINT8 PanelBase4 = helpers->ReadByte(PanelBase3 + 0x2C, false); + UINT8 Wheels = helpers->ReadByte(PanelBase3 + 0xB4, false); + UINT8 Skids = helpers->ReadByte(PanelBase3 + 0x100, false); + UINT8 AI = helpers->ReadByte(PanelBase3 + 0x3D4, false); + UINT8 gear = helpers->ReadByte(0x346A5C6C, false); + INT_PTR speedoBase = helpers->ReadIntPtr(0x28C008, true); + INT_PTR speedoBase1 = helpers->ReadIntPtr(speedoBase + 0xD0, false); + INT_PTR speedoBase2 = helpers->ReadIntPtr(speedoBase1 + 0x460, false); + INT_PTR speedoBase3 = helpers->ReadIntPtr(speedoBase2 + 0x184, false); + float speedo = helpers->ReadFloat32(speedoBase3 + 0x4F4, false); + + UINT8 static oldgear = 0; + UINT8 newgear = gear; + + { + triggers->Springi(SpringStrength / 100.0); + } + + if ((oldgear != newgear) && (speedo > 0)) + { + SDL_Thread* gearChangeThread = SDL_CreateThread(GearChangeThread, "GearChangeThread", (void*)NULL); + } + + if (Wheels > 0) + { + double percentForce = Wheels / 37.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(80, 80, percentForce); + } + +<<<<<<< HEAD myTriggers = triggers; myConstants = constants; myHelpers = helpers; SDL_Thread* thread; thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL); - - while (SDL_WaitEvent(&e) != 0) +======= + if ((Skids > 12) && (speedo > 0)) { - myTriggers = triggers; - myConstants = constants; - myHelpers = helpers; + double percentForce = ((Skids - 12) / 8.0); + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); } +>>>>>>> parent of ede0f04... Fix GRID for Rumble to use duration of New Rumble + + if ((AI > 0) && (PanelBase4 > 0)) + { + double percentForce = (PanelBase4) / 8.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + } +<<<<<<< HEAD +======= + + if ((WallBase4 > 0) && (PanelBase4 > 0)) + { + double percentForce = (PanelBase4) / 8.0; + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + else if ((WallBase4 < 0) && (PanelBase4 > 0)) + { + double percentForce = (PanelBase4) / 8.0; + double percentLength = 100; + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + oldgear = newgear; + myTriggers = triggers; + myConstants = constants; + myHelpers = helpers; +>>>>>>> parent of ede0f04... Fix GRID for Rumble to use duration of New Rumble } \ No newline at end of file