how would i go about finding a total time played value in a save file? i want to change it so that I can unlock some things in the game, but i have to have played it for many hours. If, for example, the total time played is 16 hours 30 minutes and 25 seconds, would i search for these values individually and find the place where they all line up or would they be stored as a different value?
sorry, i'm new to this and i thought that i had a pretty good understanding of hex, but this has me confused.
03-13-2012
pureIso
Re: Editing a time value
Convert the time you have using TimeSpan c# data type.
03-13-2012
sss4
Re: Editing a time value
i read about the TimeSpan c# data type, but i'm not sure I get it. For the example of 16 hours 30 minutes and 25 seconds would it be (0,16,32,25,0)?
And would I search for a string that looks like that in a hex editor (after converting to hex that is)?
This might be of use, though its in VB it should convert easily.
Code:
'Playtime Handlers
Public Sub timelord()
Dim ts As New TimeSpan(0, 0, timeread.Text)
timebox.Text = (ts.ToString)
End Sub
It was for reading total game time and displaying it in the form of HH:MM:SS, i deduced it was stored in seconds via an educated guess, timespan should work for you nicely assuming the values aren't just a string like seph is showing.
i clearly wrote the editor this came from while drunk, its a mess, but this is how i then converted the format back into seconds:
Code:
Public Sub timeshift()
Try
Dim time2sec As TimeSpan = TimeSpan.Parse(timebox.Text)
timeread.Text = time2sec.TotalSeconds
Catch ex As Exception
MsgBox("Time must be in the format HH:MM:SS")
End Try
End Sub
Thank you everyone for the help. I finally figured it out. the problem was that i wasnt sure what the time value was because the game gave me total play time instead of campain play time and online play time seperately. 8Ball's post was on point when he said that the value he was looking for was stored in seconds. my value was too, so i compared 2 different saves and found the difference, stored in seconds.
03-16-2012
kartleyBecil
Re: Editing a time value
i read about the TimeSpan c# data type, but i'm not sure I get it.
03-16-2012
pureIso
Re: Editing a time value
Quote:
Originally Posted by kartleyBecil
i read about the TimeSpan c# data type, but i'm not sure I get it.
Look at 8Balls example.
TimeSpan interval = new TimeSpan(2, 14, 18);
Console.WriteLine(interval.ToString());// Displays "02:14:18".
TimeSpan also have various properties you can call e.g: TimeSpan.Seconds, TimeSpan.Minutes
Another Alternative
/// <summary>Converts an Int64 FileTime to a DateTime</summary>
/// <param name="input">The long value to convert</param>
public static DateTime ToDateTime(long input)
{
try
{
//Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
//This is usually stored in 8 byte in files - hex
return DateTime.FromFileTime(input);//Converts long(FileTime) to local time
}
catch
{
return DateTime.Now;
}
}
/// <summary>Converts a DateTime to an Int64 FileTime</summary>
/// <param name="input">The date time input</param>
/// <returns></returns>
public static long ToInt64(DateTime input)
{
try
{
return input.ToFileTime();
}
catch
{
return DateTime.Now.ToFileTime();
}
}
I hope that helps you. If you still don't understand then copy the code, run it and try step through the codes till you understand.