@@ -44,7 +44,7 @@ public partial class MainForm : Form
4444 private Thread checkTheaterTime ;
4545 private Thread headerCheck ;
4646
47- bool isHeaderLoaded = false ; // Shouldn't be true (on startup) unless it's actually loaded, but I can not be fucked to fix this right now.
47+ bool isHeaderLoaded = false ;
4848 bool lockHotkeys = true ;
4949 bool startup = false ;
5050
@@ -87,6 +87,8 @@ public MainForm()
8787 GetData ( ) ;
8888 SetupDataGridView ( ) ;
8989
90+
91+
9092 _proc = HookCallback ;
9193 _hookID = SetHook ( _proc ) ;
9294
@@ -142,6 +144,25 @@ protected override void OnFormClosing(FormClosingEventArgs e)
142144 UnhookWindowsHookEx ( _hookID ) ;
143145 }
144146
147+ public async Task CheckForMapHeader ( )
148+ {
149+ while ( true )
150+ {
151+ string daeh = memory . ReadString ( Header , "" , 0x04 ) ;
152+
153+ if ( daeh == "daeh" )
154+ {
155+ isHeaderLoaded = true ;
156+ }
157+ else
158+ {
159+ isHeaderLoaded = false ;
160+ }
161+
162+ await Task . Delay ( 1 ) ;
163+ }
164+ }
165+
145166 #region Hotkeys
146167
147168 private IntPtr SetHook ( LowLevelKeyboardProc proc )
@@ -246,6 +267,7 @@ public async Task GetModules()
246267 Console . WriteLine ( "Found: " + selectedProcessName . ToString ( ) + " (" + p . Id + ")" ) ;
247268
248269 updateModules . Text = $ "Load .plugin/.json";
270+
249271 startup = true ;
250272 }
251273 }
@@ -420,24 +442,55 @@ public async Task MoveCamera()
420442
421443 while ( true )
422444 {
423- float currentTheaterTime = memory . ReadFloat ( theaterTime ) ;
424-
425- if ( currentTheaterTime >= endTime )
445+ if ( isHeaderLoaded == false )
446+ {
426447 break ;
427-
428- float tNormalized = ( currentTheaterTime - startTime ) / segmentDuration ;
429- var interpolatedPosition = CatmullRomPositionInterpolation ( p0 , p1 , p2 , p3 , tNormalized ) ;
430-
431- memory . WriteMemory ( xPos , "float" , $ "{ interpolatedPosition . Item1 } ") ;
432- memory . WriteMemory ( yPos , "float" , $ "{ interpolatedPosition . Item2 } ") ;
433- memory . WriteMemory ( zPos , "float" , $ "{ interpolatedPosition . Item3 } ") ;
434-
435- memory . WriteMemory ( yawAng , "float" , $ "{ interpolatedPosition . Item4 } ") ;
436- memory . WriteMemory ( pitchAng , "float" , $ "{ interpolatedPosition . Item5 } ") ;
437- memory . WriteMemory ( rollAng , "float" , $ "{ interpolatedPosition . Item6 } ") ;
438- memory . WriteMemory ( playerFov , "float" , $ "{ interpolatedPosition . Item7 } ") ;
439-
440- await Task . Delay ( 10 ) ;
448+ }
449+ else
450+ {
451+ float currentTheaterTime = memory . ReadFloat ( theaterTime ) ;
452+
453+ if ( currentTheaterTime >= endTime )
454+ {
455+ pathStart_checkbox . Checked = false ;
456+ break ;
457+ }
458+
459+ if ( currentTheaterTime < startTime )
460+ {
461+ float x = Convert . ToSingle ( keyframeDataGridView . Rows [ 0 ] . Cells [ "X" ] . Value ) ;
462+ float y = Convert . ToSingle ( keyframeDataGridView . Rows [ 0 ] . Cells [ "Y" ] . Value ) ;
463+ float z = Convert . ToSingle ( keyframeDataGridView . Rows [ 0 ] . Cells [ "Z" ] . Value ) ;
464+ float yaw = Convert . ToSingle ( keyframeDataGridView . Rows [ 0 ] . Cells [ "Yaw" ] . Value ) ;
465+ float pitch = Convert . ToSingle ( keyframeDataGridView . Rows [ 0 ] . Cells [ "Pitch" ] . Value ) ;
466+ float roll = Convert . ToSingle ( keyframeDataGridView . Rows [ 0 ] . Cells [ "Roll" ] . Value ) ;
467+ float fov = Convert . ToSingle ( keyframeDataGridView . Rows [ 0 ] . Cells [ "FOV" ] . Value ) ;
468+
469+ memory . WriteMemory ( xPos , "float" , $ "{ x } ") ;
470+ memory . WriteMemory ( yPos , "float" , $ "{ y } ") ;
471+ memory . WriteMemory ( zPos , "float" , $ "{ z } ") ;
472+ memory . WriteMemory ( yawAng , "float" , $ "{ yaw } ") ;
473+ memory . WriteMemory ( pitchAng , "float" , $ "{ pitch } ") ;
474+ memory . WriteMemory ( rollAng , "float" , $ "{ roll } ") ;
475+ memory . WriteMemory ( playerFov , "float" , $ "{ fov } ") ;
476+ }
477+ else
478+ {
479+ float tNormalized = ( currentTheaterTime - startTime ) / segmentDuration ;
480+ var interpolatedPosition = CatmullRomPositionInterpolation ( p0 , p1 , p2 , p3 , tNormalized ) ;
481+
482+ memory . WriteMemory ( xPos , "float" , $ "{ interpolatedPosition . Item1 } ") ;
483+ memory . WriteMemory ( yPos , "float" , $ "{ interpolatedPosition . Item2 } ") ;
484+ memory . WriteMemory ( zPos , "float" , $ "{ interpolatedPosition . Item3 } ") ;
485+
486+ memory . WriteMemory ( yawAng , "float" , $ "{ interpolatedPosition . Item4 } ") ;
487+ memory . WriteMemory ( pitchAng , "float" , $ "{ interpolatedPosition . Item5 } ") ;
488+ memory . WriteMemory ( rollAng , "float" , $ "{ interpolatedPosition . Item6 } ") ;
489+ memory . WriteMemory ( playerFov , "float" , $ "{ interpolatedPosition . Item7 } ") ;
490+ }
491+
492+ await Task . Delay ( 1 ) ;
493+ }
441494 }
442495 }
443496 }
@@ -678,6 +731,9 @@ private void ProcessSelected(string selectedProcessName)
678731 isHeaderLoaded = true ;
679732
680733 unlockUI ( ) ;
734+
735+ headerCheck = new Thread ( async ( ) => { await CheckForMapHeader ( ) ; } ) ;
736+ headerCheck . Start ( ) ;
681737 }
682738 else
683739 {
@@ -973,14 +1029,23 @@ private void sortDown_button_Click(object sender, EventArgs e)
9731029
9741030 private void pathStart_checkbox_CheckedChanged ( object sender , EventArgs e )
9751031 {
976- if ( pathStart_checkbox . Checked == true )
1032+
1033+ if ( isHeaderLoaded == true )
9771034 {
978- MoveCamera ( ) ;
1035+ if ( pathStart_checkbox . Checked == true )
1036+ {
1037+ MoveCamera ( ) ;
1038+ }
1039+ else if ( pathStart_checkbox . Checked == false )
1040+ {
1041+ pathStart_checkbox . Checked = false ;
1042+ return ;
1043+ }
9791044 }
980- else if ( pathStart_checkbox . Checked == false )
1045+ else
9811046 {
1047+ MessageBox . Show ( "You might want to load a map first!" , "Warning" , MessageBoxButtons . OK ) ;
9821048 pathStart_checkbox . Checked = false ;
983- return ;
9841049 }
9851050 }
9861051
0 commit comments