Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Gregjazz on Tue 22/11/2005 06:52:15

Title: Is the WriteInt function supposed to do this? (SOLVED)
Post by: Gregjazz on Tue 22/11/2005 06:52:15
When I use the WriteInt function it actually writes something extraneous at the beginning of each data portion I write.

So if I do this:


File *output = File.Open("test.txt", eFileWrite);
output.WriteInt(5);
output.Close();


And then load the output file in Hexedit, I see this:


49 05 00 00 00                I . . . .


How can I get rid of it? Why is it there?
Title: Re: Is the WriteInt function supposed to do this?
Post by: Kweepa on Tue 22/11/2005 07:38:55
The 'I' is there to indicate to the ReadInt function that indeed the value written to the file was an Int.
Unfortunately there doesn't seem to be a WriteRawInt function to correspond to ReadRawInt.
You could simulate it with WriteRawChar, like so:

function WriteRawInt(File *output, int intToWrite)
{
Ã,  output.WriteRawChar(intToWrite & 255);
Ã,  output.WriteRawChar((intToWrite>>8) & 255);
Ã,  output.WriteRawChar((intToWrite>>16) & 255);
Ã,  output.WriteRawChar((intToWrite>>24) & 255);
}
Title: Re: Is the WriteInt function supposed to do this?
Post by: Gregjazz on Tue 22/11/2005 08:34:13
Success! I've never been happier. It's 12:33 AM and I finally finished this project I've been struggling with.

Thank you everyone for your emmense help!