Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Bug
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Metsuro
USA (389 posts) Bio
|
Date
| Sun 21 May 2006 08:44 AM (UTC) Amended on Sun 21 May 2006 08:30 PM (UTC) by Metsuro
|
Message
| I am using Noplex hometown and nations snippet, and I get this...
Fri May 19 15:03:18 2006 :: Loading Hometowns...
Fri May 19 15:03:18 2006 :: Loading Nations...
Fri May 19 15:03:18 2006 :: [*****] BUG: Fread_string: EOF
Fri May 19 15:03:18 2006 :: Loading changes
I had to change load_nations a bit so it could work with the mud, and that might have caused the problem? so heres the load_nations I use...
void load_nations(void)
{
FILE *list = NULL;
char filename[256];
/* load from nations list */
sprintf(filename, "%snations.lst", NATION_DIR);
if((list = fopen(filename, "r")) == NULL)
{
bug("load_nations(): cannot open %s for reading; aborting load", filename);
return;
}
top_nation = 0;
for( ; ; )
{
char *file = feof(list) ? "$" : fread_string(list);
/* end of the file */
if(file[0] == '$')
break;
/* load each nation indiviually */
{
NATION_DATA *nation = NULL;
nation = fread_nation(file);
if(!nation)
{
bug("load_nations(): error returning back nation from filename %s", file);
return;
}
/* linker */
nation_list[top_nation] = nation;
top_nation++;
continue;
}
}
FCLOSE(list);
checkup( );
return;
}
yea there were two there by my fault had to post it in two sections sorry, now its exactly what I have in the mud right now. |
Everything turns around in the end | Top |
|
Posted by
| Tzaro
USA (41 posts) Bio
|
Date
| Reply #1 on Sun 21 May 2006 12:51 PM (UTC) |
Message
| Was that a direct copy? I dunno much about code but... under:
if(!nation)
you have two {'s, and only one is needed. I couldn't tell you what effect that would have without playing around with it for hours on end :\ but I think that might be an issue... :)
Hope this helps somehow,
Tzaro |
Implementer of Lost Prophecy,
Tzaro | Top |
|
Posted by
| Metsuro
USA (389 posts) Bio
|
Date
| Reply #2 on Mon 22 May 2006 07:45 AM (UTC) |
Message
| Hrm, still cant quiet figure out what is wrong... anyone? |
Everything turns around in the end | Top |
|
Posted by
| Gohan_TheDragonball
USA (183 posts) Bio
|
Date
| Reply #3 on Mon 22 May 2006 07:58 AM (UTC) |
Message
| i would check your fread_nation() function, from the looks of it that is where the problem is, because i see nothing wrong in the loading function. if you dun see a problem post it here or give a link so it can be checked out. | Top |
|
Posted by
| Conner
USA (381 posts) Bio
|
Date
| Reply #4 on Mon 22 May 2006 08:52 AM (UTC) |
Message
| Have you checked your nations file to make sure it's ending with a $ instead of an END? |
-=Conner=-
--
Come test your mettle in the Land of Legends at telnet://tcdbbs.zapto.org:4000
or, for a little family oriented medieval fun, come join us at The Castle's Dungeon BBS at telnet://tcdbbs.zapto.org
or, if you just want information about either, check our web page at http://tcdbbs.zapto.org | Top |
|
Posted by
| Metsuro
USA (389 posts) Bio
|
Date
| Reply #5 on Mon 22 May 2006 07:29 PM (UTC) |
Message
| Yes, it ends with a $ not end.
here is fread_nation, but to me... I think fread_nation is looking for END at the end?
NATION_DATA *fread_nation(char *file)
{
char filename[256];
FILE *fp = NULL;
NATION_DATA *nation = NULL;
sprintf(filename, "../nations/%s", file);
if((fp = fopen(filename, "r")) == NULL)
{
bug("fread_nation(): cannot open %s for reading", filename);
FCLOSE(fp); /* just in case */
return NULL;
}
/* initalize entry */
CREATE(nation, NATION_DATA, 1);
nation->name = STRALLOC("None");
nation->leader = STRALLOC("None");
nation->fname = STRALLOC("None");
nation->description = STRALLOC("None");
nation->hometown = NULL;
nation->htown_vnum = -1;
nation->vnum = -1;
nation->race = -1;
for( ; ; )
{
bool fMatch = FALSE;
char *word = feof(fp) ? "END" : fread_word(fp);
if(word[0] == '*')
{
fread_to_eol(fp);
break;
}
switch(UPPER(word[0]))
{
case '$':
{
FCLOSE(fp);
return nation;
}
break;
case 'D':
KEY("Description", nation->description, fread_string(fp));
break;
case 'F':
KEY("Filename", nation->fname, fread_string(fp));
break;
case 'H':
KEY("Hometown", nation->htown_vnum, fread_number(fp));
break;
case 'L':
KEY("Leader", nation->leader, fread_string(fp));
break;
case 'N':
KEY("Name", nation->name, fread_string(fp));
break;
case 'R':
KEY("Race", nation->race, fread_number(fp));
break;
case 'V':
KEY("Vnum", nation->vnum, fread_number(fp));
break;
}
if(!fMatch)
bug("fread_nation(): no match for %s", word);
}
FCLOSE(fp);
return NULL;
}
|
Everything turns around in the end | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #6 on Mon 22 May 2006 08:54 PM (UTC) |
Message
| It's looking for $, not END. It only does END when it hits end-of-file, which should (apparently) never happen for properly formatted files.
A good idea would be to just run this through the debugger, and see at what point in the file reading it dies. If you don't feel like debugging, you can always print out every word you read, and observe where it stops being able to read more words. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Metsuro
USA (389 posts) Bio
|
Date
| Reply #7 on Mon 22 May 2006 09:31 PM (UTC) |
Message
| Dont know how to use the debugger, and the guide nick has, confuses the mess outta me. And dont know how to do the second part that you are talking about. |
Everything turns around in the end | Top |
|
Posted by
| Metsuro
USA (389 posts) Bio
|
Date
| Reply #8 on Tue 23 May 2006 08:18 AM (UTC) |
Message
| I'm still completly stumped on why it says theres a bug. |
Everything turns around in the end | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #9 on Tue 23 May 2006 09:43 AM (UTC) |
Message
| Unfortunately you'll have to find some way to step through the process of reading the file. None of us can really help you from a distance due to the nature of the problem.
To explain what I suggested, just put log entries at regular intervals during the loading of your nations. Notably, log every time you read a new word. That will help you identify where in the file the reading stops.
Most probably the file is not in the right format. I'd double-check it by hand before going in and messing with the code too much. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Metsuro
USA (389 posts) Bio
|
Date
| Reply #10 on Tue 23 May 2006 10:40 AM (UTC) |
Message
| I'm not really sure about this, but because there is only one nation, could the for, becausing the bug, as it tries to read the file a second time, and gets nothing new? not really sure, I know little about things like this, and dead tired. |
Everything turns around in the end | Top |
|
Posted by
| Metsuro
USA (389 posts) Bio
|
Date
| Reply #11 on Tue 23 May 2006 10:46 AM (UTC) |
Message
| alright no, that wasn't it, but I did find out that this right here...
char *file = feof(list) ? "$" : fread_string(list);
is causing the error in load_nations. but not sure what it does... in the function so... |
Everything turns around in the end | Top |
|
Posted by
| Metsuro
USA (389 posts) Bio
|
Date
| Reply #12 on Tue 23 May 2006 10:53 AM (UTC) |
Message
| Tue May 23 05:50:34 2006 :: Loading Nations...
Tue May 23 05:50:34 2006 :: hope
Tue May 23 05:50:34 2006 :: jas
Tue May 23 05:50:34 2006 :: hope
Tue May 23 05:50:34 2006 :: [*****] BUG: Fread_string: EOF
Tue May 23 05:50:34 2006 :: jas
I placed a log_string before and after
char *file = feof(list) ? "$" : fread_string(list);
So I go back to my earlier statement about it being the for? |
Everything turns around in the end | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #13 on Tue 23 May 2006 11:09 AM (UTC) |
Message
| Looks like it expects there to be absolutely nothing in the file after the last nation is defined, because it uses EOF as a marker for ending the for loop. You could also try putting the string "$~" at the end of the file, so that fread_string returns "$", but that's a fairly ugly fix. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
38,889 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top