-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Active Game Camera Detection #2
Open
XertroV
wants to merge
7
commits into
openplanet-nl:main
Choose a base branch
from
XertroV:cam-detection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5bc53b4
cam detection stuff with debug included
XertroV 32fa680
Polish for first review comments
XertroV 66ac200
get class ids each time + better alt cam check
XertroV 83b2a69
condense code
XertroV f8bb3da
text disabled instead of disabled menu item
XertroV dc1f4c9
tidy up some things and add sig_dev around unknown camera type alerts
XertroV 5dfd765
change g_activeCamera to g_activeCameraType
XertroV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.sig | ||
*.sh |
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,125 @@ | ||
#if TMNEXT | ||
|
||
void RenderMenuMain() | ||
{ | ||
if (!Setting_DebugShowActiveCamInMenu) { | ||
return; | ||
} | ||
UI::TextDisabled("Active Cam: " + tostring(g_activeCameraType)); | ||
} | ||
|
||
const Reflection::MwClassInfo@ tmTy = Reflection::GetType("CTrackMania"); | ||
const Reflection::MwMemberInfo@ gameSceneMember = tmTy.GetMember("GameScene"); | ||
const uint GameCameraNodOffset = gameSceneMember.Offset + 0x10; | ||
|
||
void UpdateActiveGameCam() | ||
{ | ||
g_activeCameraType = ActiveCam::None; | ||
|
||
auto gameCameraNod = Dev::GetOffsetNod(GetApp(), GameCameraNodOffset); | ||
|
||
// This is null in the menu and when cameras aren't being used. | ||
if (gameCameraNod is null) { | ||
return; | ||
} | ||
|
||
auto camModelNod = Dev::GetOffsetNod(gameCameraNod, 0x58); | ||
auto camControlNod = Dev::GetOffsetNod(gameCameraNod, 0x68); | ||
// 0x1 for std, 0x2 for alt. | ||
bool cam1Alt = Dev::GetOffsetUint8(gameCameraNod, 0x24) == 0x2; | ||
bool cam2Alt = Dev::GetOffsetUint8(gameCameraNod, 0x25) == 0x2; | ||
bool cam3Alt = Dev::GetOffsetUint8(gameCameraNod, 0x26) == 0x2; | ||
|
||
// Always 4 when backwards, and seemingly always 0 otherwise | ||
bool isBackwards = Dev::GetOffsetUint32(gameCameraNod, 0xB0) == 0x4; | ||
|
||
if (isBackwards) { | ||
g_activeCameraType = ActiveCam::Backwards; | ||
} else if (camModelNod !is null) { | ||
auto ty = Reflection::TypeOf(camModelNod); | ||
if (ty.ID == ClsId_CPlugVehicleCameraRace2Model) { | ||
g_activeCameraType = cam1Alt ? ActiveCam::Cam1Alt : ActiveCam::Cam1; | ||
} else if (ty.ID == ClsId_CPlugVehicleCameraRace3Model) { | ||
g_activeCameraType = cam2Alt ? ActiveCam::Cam2Alt : ActiveCam::Cam2; | ||
} else if (ty.ID == ClsId_CPlugVehicleCameraInternalModel) { | ||
g_activeCameraType = cam3Alt ? ActiveCam::Cam3Alt : ActiveCam::Cam3; | ||
} else if (ty.ID == ClsId_CPlugVehicleCameraHelicoModel) { | ||
// this happens with CharacterPilot maps | ||
g_activeCameraType = ActiveCam::Helico; | ||
} else { | ||
#if SIG_DEVELOPER | ||
trace('1 Got cam of unknown type: ' + ty.ID + ', ' + ty.Name); | ||
UI::ShowNotification('1 Got cam of unknown type: ' + ty.ID + ', ' + ty.Name); | ||
#endif | ||
g_activeCameraType = ActiveCam::Other; | ||
} | ||
} else if (camControlNod !is null) { | ||
auto ty = Reflection::TypeOf(camControlNod); | ||
if (ty.ID == ClsId_CGameControlCameraFree) { | ||
g_activeCameraType = ActiveCam::FreeCam; | ||
} else if (ty.ID == ClsId_CGameControlCameraEditorOrbital) { | ||
g_activeCameraType = ActiveCam::EditorOrbital; | ||
} else if (ty.ID == ClsId_CGameControlCameraOrbital3d) { | ||
g_activeCameraType = ActiveCam::Orbital3d; | ||
} else if (ty.ID == ClsId_CGameControlCameraHelico) { | ||
g_activeCameraType = ActiveCam::Helico; | ||
} else if (ty.ID == ClsId_CGameControlCameraHmdExternal) { | ||
g_activeCameraType = ActiveCam::HmdExternal; | ||
} else if (ty.ID == ClsId_CGameControlCameraThirdPerson) { | ||
g_activeCameraType = ActiveCam::ThirdPerson; | ||
} else if (ty.ID == ClsId_CGameControlCameraFirstPerson) { | ||
g_activeCameraType = ActiveCam::FirstPerson; | ||
} else if (ty.ID == ClsId_CGameControlCameraTarget) { | ||
g_activeCameraType = ActiveCam::Target; | ||
} else if (ty.ID == ClsId_CGameControlCameraTrackManiaRace) { | ||
g_activeCameraType = ActiveCam::Cam0; | ||
} else if (ty.ID == ClsId_CGameControlCameraTrackManiaRace2) { | ||
g_activeCameraType = ActiveCam::Cam1; | ||
} else if (ty.ID == ClsId_CGameControlCameraTrackManiaRace3) { | ||
g_activeCameraType = ActiveCam::Cam2; | ||
} else if (ty.ID == ClsId_CGameControlCameraVehicleInternal) { | ||
g_activeCameraType = ActiveCam::Cam3; | ||
} else if (ty.ID == ClsId_CGameControlCamera) { | ||
// We probably won't ever end up here, but just in case. | ||
g_activeCameraType = ActiveCam::Other; | ||
} else { | ||
// debug so we know that a cam is unknown | ||
#if SIG_DEVELOPER | ||
trace('2 Got cam of unknown type: ' + ty.ID + ', ' + ty.Name); | ||
UI::ShowNotification('2 Got cam of unknown type: ' + ty.ID + ', ' + ty.Name); | ||
#endif | ||
g_activeCameraType = ActiveCam::Other; | ||
} | ||
} else { | ||
// initalizing editor, when in mediatracker | ||
g_activeCameraType = ActiveCam::Loading; | ||
} | ||
} | ||
|
||
const uint ClsId_CPlugVehicleCameraRace2Model = Reflection::GetType("CPlugVehicleCameraRace2Model").ID; | ||
const uint ClsId_CPlugVehicleCameraRace3Model = Reflection::GetType("CPlugVehicleCameraRace3Model").ID; | ||
const uint ClsId_CPlugVehicleCameraInternalModel = Reflection::GetType("CPlugVehicleCameraInternalModel").ID; | ||
const uint ClsId_CPlugVehicleCameraHelicoModel = Reflection::GetType("CPlugVehicleCameraHelicoModel").ID; | ||
|
||
const uint ClsId_CGameControlCameraFree = Reflection::GetType("CGameControlCameraFree").ID; | ||
const uint ClsId_CGameControlCameraEditorOrbital = Reflection::GetType("CGameControlCameraEditorOrbital").ID; | ||
const uint ClsId_CGameControlCameraOrbital3d = Reflection::GetType("CGameControlCameraOrbital3d").ID; | ||
const uint ClsId_CGameControlCameraHelico = Reflection::GetType("CGameControlCameraHelico").ID; | ||
const uint ClsId_CGameControlCameraHmdExternal = Reflection::GetType("CGameControlCameraHmdExternal").ID; | ||
const uint ClsId_CGameControlCameraThirdPerson = Reflection::GetType("CGameControlCameraThirdPerson").ID; | ||
const uint ClsId_CGameControlCameraFirstPerson = Reflection::GetType("CGameControlCameraFirstPerson").ID; | ||
const uint ClsId_CGameControlCameraTarget = Reflection::GetType("CGameControlCameraTarget").ID; | ||
const uint ClsId_CGameControlCameraTrackManiaRace = Reflection::GetType("CGameControlCameraTrackManiaRace").ID; | ||
const uint ClsId_CGameControlCamera = Reflection::GetType("CGameControlCamera").ID; | ||
const uint ClsId_CGameControlCameraTrackManiaRace2 = Reflection::GetType("CGameControlCameraTrackManiaRace2").ID; | ||
const uint ClsId_CGameControlCameraTrackManiaRace3 = Reflection::GetType("CGameControlCameraTrackManiaRace3").ID; | ||
const uint ClsId_CGameControlCameraVehicleInternal = Reflection::GetType("CGameControlCameraVehicleInternal").ID; | ||
|
||
#else | ||
|
||
void UpdateActiveGameCam() | ||
{ | ||
// not supported yet in MP4 / Turbo | ||
} | ||
|
||
#endif |
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,21 @@ | ||
shared enum ActiveCam { | ||
None = 0, | ||
Cam1 = 1, | ||
Cam2 = 2, | ||
Cam3 = 3, | ||
Cam1Alt = 4, | ||
Cam2Alt = 5, | ||
Cam3Alt = 6, | ||
FreeCam = 7, | ||
Backwards = 8, | ||
EditorOrbital, | ||
Orbital3d, | ||
Helico, | ||
HmdExternal, | ||
ThirdPerson, | ||
FirstPerson, | ||
Target, | ||
Cam0, | ||
Other, | ||
Loading | ||
} | ||
XertroV marked this conversation as resolved.
Show resolved
Hide resolved
|
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,2 @@ | ||
[Setting category="Debug" name="Debug: Show Active Cam in the Menu Bar"] | ||
bool Setting_DebugShowActiveCamInMenu = false; |
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 |
---|---|---|
|
@@ -6,4 +6,5 @@ essential = true | |
|
||
[script] | ||
exports = [ "Export.as" ] | ||
shared_exports = [ "ExportShared.as" ] | ||
timeout = 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not a fan of all these offsets tbh. Have you checked these offsets across game updates? How stable are they?
I'm afraid that Nadeo is going to release an update and make these offsets moot, and we will be forced to spend a long time on updating the offsets, or finding different methods of getting this information, or maybe we even need to remove the feature altogether. (And maybe only 1 plugin will ever need to use this functionality.)
This is my general view of using the Dev API btw, nothing specifically against this. I'm just wondering how stable it is, because it will add a lot of maintenance work. (Perhaps we need a checklist that we manually go through every game update.)