-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7947602
commit 60f6db4
Showing
10 changed files
with
343 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "Event.h" | ||
#include "util/Hooking.h" | ||
|
||
void* RELOC_GetProcAddress(void* peData, char* lpszName) | ||
{ | ||
auto addr = GET_ADDRESS(0x464550, 0x4680C0, 0x000000); | ||
|
||
return Hooking::CallReturn<void*>(addr, peData, lpszName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
struct EventVar | ||
{ | ||
char* name; | ||
int variable; | ||
}; | ||
|
||
struct UnsavedVar | ||
{ | ||
char* name; | ||
int* variable; | ||
}; | ||
|
||
struct GlobalData | ||
{ | ||
char pad1[232]; | ||
|
||
int* eventVars; | ||
}; | ||
|
||
void* RELOC_GetProcAddress(void* peData, char* lpszName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#pragma once | ||
|
||
#include "cdc/math/Vector.h" | ||
|
||
struct Intro; | ||
struct StreamUnitPortal; | ||
struct Signal; | ||
struct Instance; | ||
struct KDNode; | ||
|
||
struct IndexedFace | ||
{ | ||
unsigned __int16 i0; | ||
unsigned __int16 i1; | ||
unsigned __int16 i2; | ||
|
||
unsigned __int8 adjacencyFlags; | ||
unsigned __int8 collisionFlags; | ||
unsigned __int8 clientFlags; | ||
unsigned __int8 materialType; | ||
}; | ||
|
||
struct MeshVertex | ||
{ | ||
__int16 x; | ||
__int16 y; | ||
__int16 z; | ||
}; | ||
|
||
struct MeshVertex32 | ||
{ | ||
float x; | ||
float y; | ||
float z; | ||
float w; | ||
}; | ||
|
||
struct BBox | ||
{ | ||
cdc::Vector3 bMin; | ||
cdc::Vector3 bMax; | ||
}; | ||
|
||
struct Mesh | ||
{ | ||
BBox m_box; | ||
cdc::Vector3 m_position; | ||
|
||
void* m_vertices; | ||
IndexedFace* m_faces; | ||
KDNode* m_root; | ||
|
||
void* m_clientData; | ||
|
||
unsigned __int16 m_vertexType; | ||
unsigned __int16 m_numNodes; | ||
unsigned __int16 m_numFaces; | ||
unsigned __int16 m_numVertices; | ||
unsigned __int16 m_height; | ||
unsigned __int16 m_numDegenerateFaces; | ||
unsigned __int16 m_numNonManifoldEdges; | ||
}; | ||
|
||
struct Level; | ||
|
||
struct TerrainGroup | ||
{ | ||
cdc::Vector3 globalOffset; | ||
cdc::Vector3 localOffset; | ||
|
||
int flags; | ||
int ID; | ||
int uniqueID; | ||
int splineID; | ||
Instance* instanceSpline; | ||
Level* level; | ||
Mesh* mesh; | ||
|
||
char pad1[116]; | ||
}; | ||
|
||
struct Terrain | ||
{ | ||
__int16 UnitChangeFlags; | ||
__int16 spad; | ||
|
||
int numIntros; | ||
Intro* introList; | ||
|
||
int numStreamUnitPortals; | ||
StreamUnitPortal* streamUnitPortals; | ||
|
||
int numTerrainGroups; | ||
TerrainGroup* terrainGroups; | ||
|
||
TerrainGroup* signalTerrainGroup; | ||
Signal* signals; | ||
}; | ||
|
||
struct Level | ||
{ | ||
Terrain* terrain; | ||
|
||
char pad1[140]; | ||
|
||
Signal* SignalListStart; | ||
__int16* SignalIDList; | ||
void* splineCameraData; | ||
|
||
void* relocModule; // Pointer to script executable | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
#include <imgui.h> | ||
#include <MinHook.h> | ||
|
||
#include "Level.h" | ||
#include "level/Stream.h" | ||
#include "level/Event.h" | ||
#include "game/Game.h" | ||
#include "util/Hooking.h" | ||
|
||
static bool s_disableScript = false; | ||
static void (*s_STREAM_FinishLoad)(StreamUnit*); | ||
|
||
static void STREAM_FinishLoad(StreamUnit* streamUnit) | ||
{ | ||
if (s_disableScript) | ||
{ | ||
streamUnit->level->relocModule = nullptr; | ||
} | ||
|
||
s_STREAM_FinishLoad(streamUnit); | ||
} | ||
|
||
LevelModule::LevelModule() | ||
{ | ||
// Insert hook | ||
auto addr = GET_ADDRESS(0x5D5640, 0x5DB680, 0x000000); | ||
|
||
MH_CreateHook((void*)addr, STREAM_FinishLoad, (void**)&s_STREAM_FinishLoad); | ||
MH_EnableHook(MH_ALL_HOOKS); | ||
} | ||
|
||
void LevelModule::OnMenu() | ||
{ | ||
if (ImGui::BeginMenu("Level")) | ||
{ | ||
ImGui::MenuItem("Disable script", nullptr, &s_disableScript); | ||
ImGui::MenuItem("Event debug", nullptr, &m_eventDebug); | ||
|
||
ImGui::EndMenu(); | ||
} | ||
} | ||
|
||
void LevelModule::OnDraw() | ||
{ | ||
if (m_eventDebug) | ||
{ | ||
DrawEventDebug(); | ||
} | ||
} | ||
|
||
void LevelModule::DrawEventDebug() | ||
{ | ||
ImGui::Begin("Event debug", &m_eventDebug); | ||
ImGui::Columns(2); | ||
|
||
auto stream = Game::GetStreamTracker(); | ||
|
||
// Level list | ||
ImGui::BeginChild("LevelsTree"); | ||
|
||
for (int i = 0; i < MAX_STREAM_UNITS; i++) | ||
{ | ||
auto unit = &stream->StreamList[i]; | ||
|
||
if (unit->used != 2) | ||
{ | ||
continue; | ||
} | ||
|
||
if (ImGui::TreeNodeEx((void*)unit, ImGuiTreeNodeFlags_Leaf, "%s", unit->baseAreaName)) | ||
{ | ||
if (ImGui::IsItemClicked()) | ||
{ | ||
m_selected = unit; | ||
} | ||
|
||
ImGui::TreePop(); | ||
} | ||
} | ||
|
||
ImGui::EndChild(); | ||
|
||
// Event debug | ||
ImGui::NextColumn(); | ||
|
||
if (m_selected && m_selected->used != 2) | ||
{ | ||
m_selected = nullptr; | ||
} | ||
|
||
if (m_selected) | ||
{ | ||
ImGui::BeginChild("EventDebug"); | ||
|
||
DrawEventDebug(m_selected); | ||
|
||
ImGui::EndChild(); | ||
} | ||
|
||
ImGui::End(); | ||
} | ||
|
||
void LevelModule::DrawEventDebug(StreamUnit* unit) | ||
{ | ||
auto level = unit->level; | ||
|
||
if (!level->relocModule) | ||
{ | ||
return; | ||
} | ||
|
||
// Get the event debug export | ||
auto eventVars = (EventVar*)RELOC_GetProcAddress(level->relocModule, "EventDebug"); | ||
|
||
if (eventVars) | ||
{ | ||
auto globalData = (GlobalData*)GET_ADDRESS(0x1076980, 0x7C8A50, 0x000000); | ||
auto i = 0; | ||
|
||
// Display all event variables | ||
while (true) | ||
{ | ||
auto var = &eventVars[i++]; | ||
|
||
if (var->name == nullptr) | ||
break; | ||
|
||
ImGui::Text("%d %s = %d", var->variable, var->name, globalData->eventVars[var->variable]); | ||
} | ||
|
||
// Display all unsaved variables | ||
auto unsavedVars = (UnsavedVar*)eventVars; | ||
while (true) | ||
{ | ||
auto var = &unsavedVars[i++]; | ||
|
||
if (var->name == nullptr || var->variable == nullptr) | ||
break; | ||
|
||
ImGui::Text("%s %d", var->name, *var->variable); | ||
} | ||
} | ||
else | ||
{ | ||
ImGui::Text("No event debug for this level"); | ||
} | ||
} |
Oops, something went wrong.