Register forum user name Search FAQ

Gammon Forum

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 ➜ Silly asteroids...

Silly asteroids...

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2  3 4  

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #30 on Tue 13 Apr 2004 03:17 AM (UTC)

Amended on Tue 13 Apr 2004 03:43 AM (UTC) by Nick Cash

Message
Where exactly are you referring to? What function?

It appears it is having trouble in load_asteroids where it is loading the second asteroid using fread_word. Perhaps its a problem given when writing the asteroid list? If I remove all the asteroids then it goes away. However, if there is one or more asteroids then the above situation is the result, with the fread_word error and that messed up y with the two little dots.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #31 on Tue 13 Apr 2004 07:06 AM (UTC)
Message
I am worried about this error message:

BUG: Cannot load asteroid file: ÿ

This seems to have the wrong file name in it. Why I cannot say. Perhaps use gdb to step through the load asteroids function to see what is going wrong.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #32 on Wed 14 Apr 2004 02:36 AM (UTC)
Message
I think I'm going to go through it with gdb (not really sure how, guess I'll have to go read that tutorial again). If I can't find why then I'll rewrite the functions and see what turns up. I'll keep ya posted. However, if you find anything else please tell me so.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #33 on Thu 15 Apr 2004 12:59 AM (UTC)

Amended on Thu 15 Apr 2004 01:05 AM (UTC) by Nick Cash

Message
Ok, well, I've been stepping through load_asteroids and I'm not sure exactly what I'm looking for. It appears that the filename variable gets messed up when the for loop loops a second time, thus making it ÿ. However, before the loop has gone through once it is this:

$9 = 0xbffffa98 "Èúÿ¿Ì\035\v\b"

Got this another time:
$1 = 0xbfffeb18 "Hëÿ¿Ì\035\v\b"

I see the ÿ in there, but I don't think thats the point. I'm go gdb expert, so I really have no clue what all of this information means, I just know that the second time fread_word is called it doesn't read the next word correctly. Perhaps it isn't reading the next line?

The first thime the loop is called it reads the word using fread_word it does it correctly:

$11 = 0x82178c0 "terra1.ast"

However, when we go through the second time:

$12 = 0x82178c0 "ÿ"

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #34 on Thu 15 Apr 2004 01:16 AM (UTC)
Message
I think I found something. I was stepping through the load_shuttles code and found out that just a tiny bit later on in that loop, before filename gets redefined it reads "END", which is at the end of the file of course. Anyways, in my instance, it read End instead of END. Perhaps the problem is in fact in fread_asteroid.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #35 on Thu 15 Apr 2004 01:44 AM (UTC)

Amended on Thu 15 Apr 2004 01:45 AM (UTC) by Nick Cash

Message
Hmm, perhaps not.

Breakpoint 1, load_asteroids () at 3.0a.c:747
747             filename = feof( fpList ) ? "$" : fread_word( fpList );
(gdb) p filename
$4 = 0x81d8e85 ""
(gdb) next
749             if ( filename[0] == '$' )
(gdb) p filename
$5 = 0x82178c0 "terra1.ast"
(gdb) next
752             log_string( filename );
(gdb) next
Wed Apr 14 17:43:24 2004 :: terra1.ast
754             if ( !load_asteroid_file( (char *)filename ) )
(gdb) p filename
$6 = 0x82178c0 "terra1.ast"
(gdb) next

Breakpoint 1, load_asteroids () at 3.0a.c:747
747             filename = feof( fpList ) ? "$" : fread_word( fpList );
(gdb) p filename
$7 = 0x82178c0 "End"
(gdb) p strcpy ( filename, "END" )
$8 = 136411328
(gdb) p filename
$9 = 0x82178c0 "END"
(gdb) next
Wed Apr 14 17:43:24 2004 :: [*****] BUG: fread_word: EOF encountered on read.

749             if ( filename[0] == '$' )
(gdb) p filename
$10 = 0x82178c0 "ÿ"

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #36 on Thu 15 Apr 2004 05:31 AM (UTC)
Message
Can you paste the entire contents of your asteroids list file?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #37 on Fri 16 Apr 2004 02:52 AM (UTC)
Message

terra1.ast
$


Also, the same error is generated if more than one asteroid is contained within the list.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #38 on Fri 16 Apr 2004 06:02 AM (UTC)
Message
Should I step through EVERY function and find exactly where the variable gets messed up? Or is there some better way to go about this?

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #39 on Fri 16 Apr 2004 10:19 PM (UTC)
Message
Does this file currently contain the exact code that is causing these problems? ...

http://ew.xidus.net/code/3.0a.c


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #40 on Fri 16 Apr 2004 11:03 PM (UTC)
Message
Yes.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #41 on Fri 16 Apr 2004 11:53 PM (UTC)

Amended on Fri 16 Apr 2004 11:54 PM (UTC) by Nick Gammon

Message
I pasted in the code from that link into db.c, and the definition for the asteroid data.

I commented out a few lines which didn't seem to relate to the problem, and which were for code I didn't want to wade through, namely:

(in the structure)
//SPACE_DATA * starsystem;
//AREAD_DATA * area;



         if ( !str_cmp( word, "Area" ) )
         {
                char *aName;
                //AREA_DATA *pArea;

                aName = fread_string(fp);

                // bad way to check how valid the area is...need to change later
//                for( pArea = first_area ; pArea ; pArea = pArea->next )
//                  if (pArea->filename && !str_cmp(pArea->filename , aName ) )
//                     asteroid->area = pArea;

                STRFREE( aName );

                fMatch = TRUE;
            }


and


//              if ( (!asteroid->hp || asteroid->hp < 1) && (!asteroid->maxhp || asteroid->maxhp < 1 ) )
//                      asteroid->hp = generate_hp( asteroid->type, asteroid->stype );
                if ( !asteroid->speed || asteroid->speed < 1 )
                        asteroid->speed = 100;
//              if ( !asteroid->starsystem )
//                      asteroid->starsystem = NULL;
//              if ( !asteroid->area )
//                      asteroid->area = NULL;



and


//              if ( asteroid->exp < 0 || !asteroid->exp )
//                      reset_asteroid( asteroid->name, asteroid->type, asteroid->stype, -1, TRUE );
 


and


//          extract_asteroid( asteroid );
//          asteroid_to_system( asteroid , starsystem_from_name(asteroid->home_system) );


I then set up an asteroids directory, and put into it your asteroid.lst file, and your terr1.ast file, make a copy of that asteroid and put the copy also into the asteroid.lst file (so I would have 2) and ran it. It seemed to work fine ...


Sat Apr 17 08:46:45 2004 :: Loading asteroids
Sat Apr 17 08:46:45 2004 :: Loading asteroids...
Sat Apr 17 08:46:45 2004 ::  Done asteroids


So, unless the commented-out code does something strange to memory (and you could test that by commenting your copy out too) I cannot explain it. :)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #42 on Sat 17 Apr 2004 04:10 AM (UTC)
Message
I'll try commenting that stuff out and seeing what happens. Might be some confilict with other code in my codebase ::shrug::. I have no clue what that would be, but I guess you just never know. Would be kind of silly to have that nice piece of code and my own mud not be able to bennefit from it. We'll see what happens. Thanks.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #43 on Sat 17 Apr 2004 05:01 AM (UTC)
Message
Did you comment out the functions that were related to those as well, such as extract_asteroid and the like?

~Nick Cash
http://www.nick-cash.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #44 on Sat 17 Apr 2004 05:53 AM (UTC)
Message
I probably didn't put them there. The reason I commented them out was to avoid the compile error. They had other structures that I didn't want to bother with. The main thing I was testing was the reading of the asteroid file, not what became of it once it was in memory.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


135,536 views.

This is page 3, subject is 4 pages long:  [Previous page]  1  2  3 4  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.