Skip to content

Commit

Permalink
QOL + More params
Browse files Browse the repository at this point in the history
- Added the ability to delete maps
- QOL features such as showing map status and CIM status in map view + additional checks and prompts
- Added 2 new params for maps
  • Loading branch information
RealIndica committed Sep 19, 2023
1 parent 71feed3 commit fb166b6
Show file tree
Hide file tree
Showing 16 changed files with 321 additions and 66 deletions.
36 changes: 36 additions & 0 deletions ES-CLIENT/CustomIgnitionModule.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include <iostream>
#include <cmath>
#include <algorithm>
#include <random>
#include <numeric>
#include <set>

#include "CustomIgnitionModule.h"
#include "MinHook.h"
Expand Down Expand Up @@ -84,12 +87,42 @@ __int64 CustomIgnitionModule::ignitionProcess(__int64 instance, double dt) {
if (engineEdit->useCylinderTable) {
postCount = std::clamp(engineEdit->activeCylinderCount, 0, engineUpdate->cylinderCount);
}
else if (engineEdit->useCylinderTableRandom) {
double cycleAngleR = std::round(cycleAngle * 1.0) / 1.0;
double cyclePeriodR = std::round(cyclePeriod * 1.0) / 1.0;

m_cycleTop = std::clamp(engineEdit->activeCylindersRandomUpdateTime, 1, INT32_MAX);

if (cycleAngleR == cyclePeriodR && m_cycleCounter % m_cycleTop == 0) {
int cutCount = m_postCount - engineEdit->activeCylinderCount;
m_cutPosts.clear();
std::set<int> uniqueCuts;
std::random_device rd;
std::default_random_engine generator(rd());
std::uniform_int_distribution<int> distribution(0, m_postCount - 1);
while (uniqueCuts.size() < cutCount) {
uniqueCuts.insert(distribution(generator));
}
m_cutPosts.assign(uniqueCuts.begin(), uniqueCuts.end());
}

if (cycleAngleR == cyclePeriodR) {
m_cycleCounter++;
if (m_cycleCounter >= m_cycleTop) {
m_cycleCounter = 0;
}
}
}

if (_g->quickShift && engineEdit->quickShiftMode == 1 && engineEdit->dsgFarts) {
postCount = 1;
}

for (int i = 0; i < postCount; ++i) {
if (std::find(m_cutPosts.begin(), m_cutPosts.end(), i) != m_cutPosts.end()) {
continue;
};

double adjustedAngle = positiveMod(m_posts[i].angle - advance, cyclePeriod);

if (crank_v_theta < 0) {
Expand Down Expand Up @@ -287,6 +320,9 @@ CustomIgnitionModule::CustomIgnitionModule(EngineUpdate* update, EngineEdit* edi
m_twoStepLimiterDuration = 0;
m_speedLimiterDuration = 0.00001;
m_hiLoNextRPM = 0;
m_cutPosts = {};
m_cycleCounter = 0;
m_cycleTop = 1;
m_posts = nullptr;
m_ignitionEvents = nullptr;
m_revLimitTimer = 0;
Expand Down
3 changes: 3 additions & 0 deletions ES-CLIENT/CustomIgnitionModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class CustomIgnitionModule {
double m_twoStepLimiterDuration;
double m_speedLimiterDuration;
double m_hiLoNextRPM;
std::vector<int> m_cutPosts;
int m_cycleCounter;
int m_cycleTop;
Post* m_posts;
bool* m_ignitionEvents;
double m_revLimitTimer;
Expand Down
2 changes: 2 additions & 0 deletions ES-CLIENT/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ void HandleUpdate(const char* input) {
engineEdit->useRpmTable = data["useRpmTable"];
engineEdit->customRevLimit = data["customRevLimit"];
engineEdit->useCylinderTable = data["useCylinderTable"];
engineEdit->useCylinderTableRandom = data["useCylinderTableRandom"];
engineEdit->activeCylinderCount = data["activeCylinderCount"];
engineEdit->activeCylindersRandomUpdateTime = data["activeCylindersRandomUpdateTime"];
engineEdit->quickShiftEnabled = data["quickShiftEnabled"];
engineEdit->quickShiftTime = data["quickShiftTime"];
engineEdit->quickShiftRetardTime = data["quickShiftRetardTime"];
Expand Down
2 changes: 2 additions & 0 deletions ES-CLIENT/engineEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ EngineEdit::EngineEdit() {
useRpmTable = false;
customRevLimit = 0;
useCylinderTable = false;
useCylinderTableRandom = false;
activeCylinderCount = 0;
activeCylindersRandomUpdateTime = 0;
quickShiftEnabled = false;
quickShiftTime = 0;
quickShiftRetardTime = 0;
Expand Down
2 changes: 2 additions & 0 deletions ES-CLIENT/engineEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class EngineEdit {
bool useRpmTable;
double customRevLimit;
bool useCylinderTable;
bool useCylinderTableRandom;
int activeCylinderCount;
int activeCylindersRandomUpdateTime;
bool quickShiftEnabled;
double quickShiftTime;
double quickShiftRetardTime;
Expand Down
9 changes: 9 additions & 0 deletions ES-GUI/CreateMapForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ private void createMapButton_Click(object sender, EventArgs e)
MessageBox.Show("The map \"" + m.name + "\" is already using this name");
return;
}

if (thisControlParam == MapControlParam.ActiveCylinders || thisControlParam == MapControlParam.ActiveCylindersRandom)
{
if (m.controlParam == MapControlParam.ActiveCylinders || m.controlParam == MapControlParam.ActiveCylindersRandom)
{
MessageBox.Show("The map \"" + m.name + "\" is already using output control \"" + MapControlParam.ActiveCylinders + "\" or \"" + MapControlParam.ActiveCylindersRandom + "\"");
return;
}
}
}

newMap.Configure((MapParam)xAxis.SelectedIndex, (MapParam)yAxis.SelectedIndex, (MapControlParam)outputControl.SelectedIndex, nameTextBox.Text);
Expand Down
4 changes: 4 additions & 0 deletions ES-GUI/ES-GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,9 @@
<ItemGroup>
<None Include="assets\powerbuilder\REV2 KNOB.png" />
</ItemGroup>
<ItemGroup>
<Content Include="assets\icons\check.png" />
<Content Include="assets\icons\cross.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
2 changes: 1 addition & 1 deletion ES-GUI/ESClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void onUpdate()
foreach (Map m in customMaps)
{
m.Update();
}
}

inputPipe = new NamedPipeServerStream("est-input-pipe");
inputPipe.WaitForConnection();
Expand Down
Loading

0 comments on commit fb166b6

Please sign in to comment.