Stupid stinky FileWriteString
Displaying 1-20 of 22 total.
12 next
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Ness

So I'm trying to write the save/load feature for my HoV and I've hit a problem. I'm trying to save the name of the map the player is on, which I stored in a string var called sMap. Then I wrote it to a file like this

FileWriteString(handle, sMap);


Then when they go to load the file I do this

sMap = FileReadString(handle);


Problem is once I read the string back in it has a few garbage characters tacked on to the end. Am I doing something wrong?

Posted on 2004-06-21 04:49:18

geronimo

it is a problem with verge3.

poor grue, his heart is in it. i expect the problem will be fixed soon..

Posted on 2004-06-21 06:14:21 (last edited on 2004-06-21 06:15:12)

el_desconocido

Are you sure you have the 2004.04.21 build? This:
string sMap = "testing.map";

int f = fileopen("testing.txt",2);
FileWriteString(f, sMap);
FileWriteString(f, sMap);
FileClose(f);

f = fileopen("testing.txt",1);
sMap = FileReadString(f);
log(sMap + "eos");
sMap = FileReadString(f);
log(sMap + "eos");
FileClose(f);

logs
testing.mapeos

testing.mapeos


for me.

El

Posted on 2004-06-21 06:53:09

Ness

I've got the latest build, but when I put the code you posted in I got
testing.map1"eos

testing.map1"eos


it seems that if the string your writing is less then 13 chars, you get garbage at the end if you read it back

Posted on 2004-06-21 14:39:44

Buckermann

I've run into this problem with my battlesystem too. To work around this, I just also write the lenght of my string to the file. Not very elegant, but it works.
Like this:

Writing:
FileWriteString(myFile, myString);
FileWriteByte(Myfile, len(myString);

Loading:
TestString = FileReadString(File);
MyString = left(TestString, FileReadByte(MyFile));

This should also work for loading, but I didn't tested it:
MyString = left(FileReadString(File), FileReadByte(MyFile));

Posted on 2004-06-21 15:24:43 (last edited on 2004-06-21 15:25:23)

Ness

It works now, thanks

Posted on 2004-06-21 16:05:54

Interference22

I encountered this bug a while back (I was probably the first, in fact) and it's a bastard. The easiest, cleanest workaround is to NOT use WriteString but to use FileWriteln (sorry if that might not be quite how it's spelt, look it up in the docs). Instead of writing strings to a file as a continuous block, it outputs each string as a seperate line. Use this for INTs too and it works like a treat. I'm using it in my HOV entry, Parallel Seven.

Mind you, it makes save files easier to hack, although that can be a bonus when bug-hunting.

Posted on 2004-06-21 23:17:28

vecna

try this exe

Posted on 2004-06-22 05:10:36

Ness

Behold the power of the VERGE developer

All is wounderful in the relm of FileWriteString

Posted on 2004-06-22 13:08:34

Interference22

Woot! The mystical Coding Hand of Vecna strikes again, smiting bugs in it's wake. Cheers, Vecna.

Posted on 2004-06-22 23:47:44

Interference22

Er, Vecna: the FileWriteString bugfix is nice, but now VERGE isn't giving me any sound output. What did you DO?!

Posted on 2004-06-23 23:01:42

Kildorf

I'm having the same problem as Interference... where is our sound? ;_:

Also does Verge now/will Verge in the future support .ogg as a music format?

Posted on 2004-06-24 01:17:33

Kildorf

-agh double post... sorry-

Posted on 2004-06-24 01:18:09 (last edited on 2004-06-24 01:18:26)

Zip

I know fmod.dll supports .ogg - and was rather relying on verge supporting it too to keep my music file size down. But have yet to test. If it doesn't work, bugging the dev will most likely get it added.

Zip

Posted on 2004-06-24 01:22:50

Kildorf

Quote:Originally posted by Kildorf

I'm having the same problem as Interference... where is our sound? ;_:

Also does Verge now/will Verge in the future support .ogg as a music format?

Actually, I just tested, and .ogg works beautifully. :)

Posted on 2004-06-24 01:31:29

Ness

In your verge.cfg file add the line

nosound 0
turns ON sound


nosound 1
turns OFF sound

apperently Vecna likes to change the values of true and false :p

Posted on 2004-06-24 03:43:32

mcgrue

Ness:

The parameter is 'nosound'. When nosound is 1/true, there will be no sound.

I think his boolean paradigm is the same as the rest of the world's ;)

Posted on 2004-06-24 05:15:07

Ness

Oops.....chalk it up to my inability to read....and count....

Posted on 2004-06-24 13:27:17

Interference22

Er, actually, my CFG says "nosound 0" and there's no sound. That's not right, right?

By my reasoning, Ness is almost right: nosound 1 should turn sound OFF but it isn't. Vecna has the boolean argument for sound inverted: 1 is now false and 0 is now true. The result? A perfectly normal VERGE.CFG is now turning the sound off.

Vecna, could we have it back as it was, please? The new way is either a mistake or an attempt to confuse everyone.

Posted on 2004-06-25 00:45:40

vecna

I leant my g_startup.cpp to zeromus. he fixed automax 0, and apparently broke this in the process. He will be flogged.

Posted on 2004-06-26 01:46:09


Displaying 1-20 of 22 total.
12 next
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.