Skip to content

Commit 271b94b

Browse files
committed
replace resetparam with a less disruptive function that does the same thing
1 parent 0643ea5 commit 271b94b

2 files changed

Lines changed: 32 additions & 42 deletions

File tree

PigPSO2Cam/imgui/settings_form.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ void luaPrint(std::string s) {
2020

2121
runLuaAsync(dist.c_str());
2222
}
23-
23+
/*
2424
void resetParam() {
2525
const char *a1 = "ResetParam()";
2626
runLuaAsync(a1);
27-
}
27+
}*/
2828

2929
bool runLuaAsync(std::string a1) {
3030
if (initLuaHook()) {
@@ -42,21 +42,6 @@ bool runLua(std::string a1) {
4242
return true;
4343
}
4444

45-
46-
//no explanation honestly
47-
bool writeStructValue(int& addy, byte value) {
48-
addy = value;
49-
return true;
50-
}
51-
bool writeStructValue(byte& addy, byte value) {
52-
addy = value;
53-
return true;
54-
}
55-
bool writeStructValue(int& addy, DWORD value) {
56-
addy = value;
57-
return true;
58-
}
59-
6045
bool initLuaHook() {
6146
if (_executeLua)
6247
return true;

PigPSO2Cam/imgui/settings_form.h

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@ typedef HRESULT(__stdcall* pso2hDoLua)(const char* a1);
1515
static pso2hDoLua _executeLua = 0;
1616

1717
bool runLua(std::string a1);
18-
void resetParam();
18+
1919
bool initLuaHook();
2020

2121
bool runLuaAsync(std::string a1);
2222

23-
bool writeStructValue(int& addy, byte value);
24-
bool writeStructValue(byte&, byte);
25-
bool writeStructValue(int& addy, DWORD value);
26-
2723
void menu_init(void*, LPDIRECT3DDEVICE9);
2824

2925
static int currTab = 0;
@@ -35,12 +31,18 @@ static bool freeCamToggle = false;
3531

3632
static DWORD oNearCullBytes = 0x0;
3733

34+
35+
static bool pushCamera()
36+
{
37+
return runLuaAsync("Camera.PushActorTest()");
38+
}
39+
3840
static bool adjustZoom() {
3941
std::stringstream ss;
4042
ss << "Camera.ActorTrackTestNormal.Offset.Dist = \"" << Camera::cameraBase.Offset.Dist << "\"";
4143
std::string dist(ss.str());
4244
runLuaAsync(dist.c_str());
43-
runLuaAsync("ResetParam()");
45+
pushCamera();
4446

4547
return true;
4648
}
@@ -59,7 +61,7 @@ static bool adjustFovy() {
5961
ss << "Camera.ActorTrackTestNormal.Fovy = " << Camera::cameraBase.Fovy;
6062
std::string dist(ss.str());
6163
runLuaAsync(dist.c_str());
62-
runLuaAsync("ResetParam()");
64+
pushCamera();
6365

6466
return true;
6567
}
@@ -114,11 +116,11 @@ static void draw_menu(bool* status)
114116
//Honestly not quite sure what these two are, figured for culling but idk
115117
if (ImGui::Button("Set DistMin", ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
116118
runLuaAsync(adjustDistmin((float)Camera::cameraBase.Offset.DistMin));
117-
resetParam();
119+
pushCamera();
118120
}
119121
if (ImGui::Button("Set DistMax", ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
120122
runLuaAsync(adjustDistmax((float)Camera::cameraBase.Offset.DistMax));
121-
resetParam();
123+
pushCamera();
122124
}
123125
ImGui::EndColumns();
124126

@@ -179,9 +181,9 @@ static void draw_menu(bool* status)
179181
*(DWORD*)(tNearCull) = (DWORD)(oNearCullBytes);
180182
}
181183
}
182-
if (ImGui::Button("ResetParam", ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
184+
/* if (ImGui::Button("ResetParam", ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
183185
resetParam();
184-
}
186+
}*/
185187
ImGui::EndColumns();
186188
ImGui::Separator();
187189

@@ -195,21 +197,24 @@ static void draw_menu(bool* status)
195197
if (ImGui::Checkbox("##freecamcheck", &freeCamToggle))
196198
{
197199
DWORD funcStart = 0x04FD39D0;
198-
if(freeCamToggle)
199-
{
200-
*(BYTE*)(funcStart) = 0x31; //xor eax,eax ret 0008
201-
*(BYTE*)(funcStart + 1) = 0xC0;
202-
*(BYTE*)(funcStart + 2) = 0xC2;
203-
*(BYTE*)(funcStart + 3) = 0x08;
204-
*(BYTE*)(funcStart + 4) = 0x00;
205-
}
206-
else
200+
if (*(BYTE*)(funcStart) != 0x55)
207201
{
208-
*(BYTE*)(funcStart) = 0x55; //restore entrance
209-
*(BYTE*)(funcStart+1) = 0x8B;
210-
*(BYTE*)(funcStart+2) = 0xEC;
211-
*(BYTE*)(funcStart+3) = 0x83;
212-
*(BYTE*)(funcStart+4) = 0xE4;
202+
if (freeCamToggle)
203+
{
204+
*(BYTE*)(funcStart) = 0x31; //xor eax,eax ret 0008
205+
*(BYTE*)(funcStart + 1) = 0xC0;
206+
*(BYTE*)(funcStart + 2) = 0xC2;
207+
*(BYTE*)(funcStart + 3) = 0x08;
208+
*(BYTE*)(funcStart + 4) = 0x00;
209+
}
210+
else
211+
{
212+
*(BYTE*)(funcStart) = 0x55; //restore entrance
213+
*(BYTE*)(funcStart + 1) = 0x8B;
214+
*(BYTE*)(funcStart + 2) = 0xEC;
215+
*(BYTE*)(funcStart + 3) = 0x83;
216+
*(BYTE*)(funcStart + 4) = 0xE4;
217+
}
213218
}
214219
}
215220
}

0 commit comments

Comments
 (0)