Skip to content

Commit dc280a2

Browse files
committed
Fixed floats being rounded to the nearest hundredth instead of the nearest ten-millionth, and other various changes.
1 parent 485ca6d commit dc280a2

File tree

2 files changed

+123
-57
lines changed

2 files changed

+123
-57
lines changed

modularDollyCam/MainForm.Designer.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modularDollyCam/MainForm.cs

Lines changed: 120 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Runtime.InteropServices;
33
using Memory;
44
using Newtonsoft.Json;
5+
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
56

67
namespace modularDollyCam
78
{
@@ -25,7 +26,7 @@ public partial class MainForm : Form
2526
public string playerFov; // Scan for float;
2627

2728
public string theaterTime; // Scan for float; Convert theater time into seconds (ex: 25:07 is 1507)
28-
/* I have ASLR disabled for MCC, 7FF47EFC0018, 7FF47EFAC528, 7FF47EB30018, 7FF47EB1C528 */
29+
/*7FF47EFC0018, 7FF47EFAC528, 7FF47EB30018, 7FF47EB1C528 */
2930

3031
public string locationTargetBase; // Scan for string; 'havok proxies'
3132
public string targetBaseOffset; // Base offset from pointer
@@ -204,55 +205,102 @@ private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
204205
addKey();
205206
break;
206207
case VK_Home:
207-
208-
int selectedIndex = keyframeDataGridView.SelectedRows[0].Index;
209-
float Time = Convert.ToSingle(keyframeDataGridView.Rows[selectedIndex].Cells["Transition Time"].Value);
210-
TimeSpan timeSpan = TimeSpan.FromSeconds(Time);
211-
string formattedTime = timeSpan.ToString(@"hh\:mm\:ss");
212-
213-
string map = memory.ReadString(LoadedMap, "", 50);
214-
string build = memory.ReadString(BuildTag, "", 25);
215-
216-
byte[] framerate = memory.ReadBytes(gameFramerate, 4);
217-
int framerateValue = BitConverter.ToInt32(framerate, 0);
218-
string framerateString = framerateValue.ToString();
219-
220-
if (framerateString == "0")
208+
if (keyframeDataGridView.RowCount > 0)
221209
{
222-
framerateString = "Unlimited";
223-
}
224-
225-
if (isHeaderLoaded == true)
226-
{
227-
if (useTheaterTime.Checked == true)
210+
if (isHeaderLoaded == true)
228211
{
229-
MessageBox.Show($"Game stats:\n" +
230-
$"********************************************************************************\n" +
231-
$"Build: {build}\n" +
232-
$"Current Map: {map}\n" +
233-
$"Game Framerate: {framerateString}\n" +
234-
$"\nKeyframe stats:\n" +
235-
$"********************************************************************************\n" +
236-
$"Selected Keyframe: {selectedIndex + 1}\n" +
237-
$"Time: {formattedTime}\n" +
238-
$"Time (in seconds): {Time}",
239-
"Debug", MessageBoxButtons.OK);
240-
}
241-
else
242-
{
243-
MessageBox.Show($"Game stats:\n" +
244-
$"********************************************************************************\n" +
245-
$"Build: {build}\n" +
246-
$"Current Map: {map}\n" +
247-
$"Game Framerate: {framerateString}\n" +
248-
$"\nKeyframe stats:\n" +
249-
$"********************************************************************************\n" +
250-
$"Selected Keyframe: {selectedIndex + 1}\n" +
251-
$"Time (in seconds): {Time}",
252-
"Debug", MessageBoxButtons.OK);
212+
int selectedIndex = keyframeDataGridView.SelectedRows[0].Index;
213+
float Time = Convert.ToSingle(keyframeDataGridView.Rows[selectedIndex].Cells["Transition Time"].Value);
214+
TimeSpan timeSpan = TimeSpan.FromSeconds(Time);
215+
string formattedTime = timeSpan.ToString(@"hh\:mm\:ss");
216+
217+
string map = memory.ReadString(LoadedMap, "", 50);
218+
string build = memory.ReadString(BuildTag, "", 25);
219+
220+
byte[] framerate = memory.ReadBytes(gameFramerate, 4);
221+
int framerateValue = BitConverter.ToInt32(framerate, 0);
222+
string framerateString = framerateValue.ToString();
223+
224+
if (framerateString == "0")
225+
{
226+
framerateString = "Unlimited";
227+
}
228+
229+
if (useTheaterTime.Checked == true)
230+
{
231+
MessageBox.Show($"Game stats:\n" +
232+
$"********************************************************************************\n" +
233+
$"Build: {build}\n" +
234+
$"Current Map: {map}\n" +
235+
$"Game Framerate: {framerateString}\n" +
236+
$"\nKeyframe stats:\n" +
237+
$"********************************************************************************\n" +
238+
$"Selected Keyframe: {selectedIndex + 1}\n" +
239+
$"Time: {formattedTime}\n" +
240+
$"Time (in seconds): {Time}\n" +
241+
$"\n Plugin details:\n" +
242+
$"********************************************************************************\n" +
243+
$"X: {xPos}\n" +
244+
$"Y: {yPos}\n" +
245+
$"Z: {zPos}\n" +
246+
$"Yaw: {yawAng}\n" +
247+
$"Pitch: {pitchAng}\n" +
248+
$"Roll: {rollAng}\n" +
249+
$"Fov: {playerFov}\n" +
250+
$"Theater time: {theaterTime}\n",
251+
"Debug", MessageBoxButtons.OK);
252+
}
253+
else
254+
{
255+
MessageBox.Show($"Game stats:\n" +
256+
$"********************************************************************************\n" +
257+
$"Build: {build}\n" +
258+
$"Current Map: {map}\n" +
259+
$"Game Framerate: {framerateString}\n" +
260+
$"\nKeyframe stats:\n" +
261+
$"********************************************************************************\n" +
262+
$"Selected Keyframe: {selectedIndex + 1}\n" +
263+
$"Time (in seconds): {Time}\n" +
264+
$"\n Plugin details:\n" +
265+
$"********************************************************************************\n" +
266+
$"X: {xPos}\n" +
267+
$"Y: {yPos}\n" +
268+
$"Z: {zPos}\n" +
269+
$"Yaw: {yawAng}\n" +
270+
$"Pitch: {pitchAng}\n" +
271+
$"Roll: {rollAng}\n" +
272+
$"Fov: {playerFov}\n" +
273+
$"Theater time: {theaterTime}\n",
274+
"Debug", MessageBoxButtons.OK);
275+
}
253276
}
254277
}
255-
278+
else
279+
{
280+
string map = memory.ReadString(LoadedMap, "", 50);
281+
string build = memory.ReadString(BuildTag, "", 25);
282+
283+
byte[] framerate = memory.ReadBytes(gameFramerate, 4);
284+
int framerateValue = BitConverter.ToInt32(framerate, 0);
285+
string framerateString = framerateValue.ToString();
286+
287+
MessageBox.Show($"Game stats:\n" +
288+
$"********************************************************************************\n" +
289+
$"Build: {build}\n" +
290+
$"Current Map: {map}\n" +
291+
$"Game Framerate: {framerateString}\n" +
292+
$"\n Plugin details:\n" +
293+
$"********************************************************************************\n" +
294+
$"X: {xPos}\n" +
295+
$"Y: {yPos}\n" +
296+
$"Z: {zPos}\n" +
297+
$"Yaw: {yawAng}\n" +
298+
$"Pitch: {pitchAng}\n" +
299+
$"Roll: {rollAng}\n" +
300+
$"Fov: {playerFov}\n" +
301+
$"Theater time: {theaterTime}\n",
302+
"Debug", MessageBoxButtons.OK);
303+
}
256304
break;
257305
default:
258306
break;
@@ -689,18 +737,28 @@ private void AddKeyPointRow(float x, float y, float z, float yaw, float pitch, f
689737

690738
void addKey()
691739
{
692-
float x = memory.ReadFloat(xPos);
693-
float y = memory.ReadFloat(yPos);
694-
float z = memory.ReadFloat(zPos);
695-
float yaw = memory.ReadFloat(yawAng);
696-
float pitch = memory.ReadFloat(pitchAng);
697-
float roll = memory.ReadFloat(rollAng);
740+
byte[] CameraXBytes = memory.ReadBytes(xPos, 4);
741+
float x = (float)Math.Round(BitConverter.ToSingle(CameraXBytes, 0), 7);
742+
byte[] CameraYBytes = memory.ReadBytes(yPos, 4);
743+
float y = (float)Math.Round(BitConverter.ToSingle(CameraYBytes, 0), 7);
744+
byte[] CameraZBytes = memory.ReadBytes(zPos, 4);
745+
float z = (float)Math.Round(BitConverter.ToSingle(CameraZBytes, 0), 7);
746+
byte[] CameraYawBytes = memory.ReadBytes(yawAng, 4);
747+
float yaw = (float)Math.Round(BitConverter.ToSingle(CameraYawBytes, 0), 7);
748+
byte[] CameraPitchBytes = memory.ReadBytes(pitchAng, 4);
749+
float pitch = (float)Math.Round(BitConverter.ToSingle(CameraPitchBytes, 0), 7);
750+
byte[] CameraRollBytes = memory.ReadBytes(rollAng, 4);
751+
float roll = (float)Math.Round(BitConverter.ToSingle(CameraRollBytes, 0), 7);
752+
698753
float fov = memory.ReadFloat(playerFov);
754+
699755
float transitionTime;
700756

701757
if (useTheaterTime.Checked == true)
702758
{
703-
transitionTime = memory.ReadFloat(theaterTime);
759+
byte[] timeBytes = memory.ReadBytes(theaterTime, 4);
760+
float time = (float)Math.Round(BitConverter.ToSingle(timeBytes, 0), 6);
761+
transitionTime = time;
704762
}
705763
else
706764
{
@@ -711,6 +769,15 @@ void addKey()
711769
AddKeyPointRow(x, y, z, yaw, pitch, roll, fov, transitionTime);
712770
}
713771

772+
public static byte[] SwapByteOrder(byte[] bytes)
773+
{
774+
if (BitConverter.IsLittleEndian)
775+
{
776+
Array.Reverse(bytes);
777+
}
778+
return bytes;
779+
}
780+
714781
void rotateCameraClockwise()
715782
{
716783
float current = memory.ReadFloat(rollAng);
@@ -757,7 +824,6 @@ void unzoomCamera()
757824

758825
void unlockUI()
759826
{
760-
//groupBox1.Enabled = true;
761827
groupBox8.Enabled = true;
762828
groupBox9.Enabled = true;
763829
saveGroupbox.Enabled = true;

0 commit comments

Comments
 (0)