bizarre problem involving filereadln or fileeof
Displaying 1-5 of 5 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
IkimashoZ

So, I put out this game called Kambou v0.4, right? And I've got a bit of a problem. People are reporting a bug that I can't reproduce no matter what I do. It's in the Info section of the game, and what's happening is that people are getting a sort of "run on text" on the last line, as though the file point is simply jumping to another file after it's done with the first one.

Screenshots:
http://kambou.ikimashoz.com/kambou1.png
http://kambou.ikimashoz.com/kambou2.png
http://kambou.ikimashoz.com/kambou3.png
http://kambou.ikimashoz.com/kambou4.png

Here's my code:


int file = fileopen(infos[num].content, FILE_READ);
while(!fileeof(file)) { printstring(x_coord, y_coord, screen, 0, filereadln(file)); y_coord += 12; }
fileclose(file);


Help??

Posted on 2007-01-27 17:46:28

Overkill

I'd recommend you don't constantly load the file and print it out, but rather load it once and then use TokenCount() and GetToken() to iterate through the lines.

Not tested, but you'd have something like this that's called when the the game starts up.

void LoadInformationData()
{
int i;
int file;
for (i = 0; i < 264; i++)
{
file = FileOpen(infos[i].content, FILE_READ);
if (file)
{
while (!FileEOF(file))
{
// Some field called text stores the file contents.
infos[i].text = infos[i].text + FileReadLn(file) + "|";
}
FileClose(file);
}
else
{
// Actually, you might want it to exit if you can't find resources
Log("Could not find info file '" + infos[i].content + "'!");
}
}
}

Posted on 2007-01-27 21:02:09

IkimashoZ

Thanks Overkill.
I was unaware of gettoken() and tokencount(). Very handy.

Are these particularly slow functions? I'm getting a lot of lag in the individual info sections now. I'd prefer the lag to the sections not displaying properly any day. Just curious.

Posted on 2007-01-27 22:09:36

Overkill

If you have a newer release of Verge (available through SVN), try replacing the "|" with chr('\n') and you won't need to use TokenCount() and GetToken(), as PrintString parses newlines in the newer versions (for unaligned text... I need to get to work for right justified and centered prints as well).

Posted on 2007-01-28 02:16:37

IkimashoZ

I just got around to working on the info section. I also managed to get a newer verge off of the SVN. I tried what you said, and the game behaves very bizarrely in regards to info sections now.

For short sections, newlines were indeed read, but the spacing was off (the words were overlapping). Maybe there should be a way to set the spacing?

For long sections, the game crashed without an error message.

If you would like access to a newer version of kambou so that you can see, I can get one to you.

Posted on 2007-02-02 22:02:24


Displaying 1-5 of 5 total.
1
 
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.