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
➜ Running the server
➜ Freading floats instead of numbers
Freading floats instead of numbers
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Marowi
(65 posts) Bio
|
Date
| Fri 19 Mar 2004 04:38 PM (UTC) |
Message
| I am saving pop_support of a province as a (%.1f) float. If I set the pop_support to 66.574, it gets saved as 66.6.
("PopSupport 66.6") This is fine. When I reboot the mud, I get a message during startup saying "BUG: Fread_province: no match: .6". I've traced this to a part of the code that says:
case 'P':
KEY( "PopSupport", province->pop_support, fread_number( fp ) );
break;
It then displays the pop_support as being 66.0, because it doesn't load the additional '.6' and reports it as a bug.
I tried changing 'fread_number' to 'fread_float' and then got a compile report saying 'implicit declaration of function 'fread_float'.
I'm all out of ideas, so please help! | Top |
|
Posted by
| Greven
Canada (835 posts) Bio
|
Date
| Reply #1 on Fri 19 Mar 2004 04:43 PM (UTC) |
Message
| The problem is that fread_float does not exist in the code. However, very recently myself and Samson had this exact same discussion, and we both developed a fread_float. You can simple copy one of them, paste it in db.c with the other freads, add the prototype to mud.h, and you should be good to go. The link to those functions is here:
http://forums.alsherok.net/index.php?showtopic=597 |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | Top |
|
Posted by
| Marowi
(65 posts) Bio
|
Date
| Reply #2 on Sat 20 Mar 2004 03:09 AM (UTC) |
Message
| Ok, new problem. I tried the "atof(fread_string_noalloc(fp))" and it reads the float in correctly, but not the "GovernedBy" on the next line. | Top |
|
Posted by
| Greven
Canada (835 posts) Bio
|
Date
| Reply #3 on Sat 20 Mar 2004 03:34 AM (UTC) |
Message
| Yeah, that method == BAD, unless you rewrite all your files to save ~ after each line. Did fread_string_noalloc actually work? I didn't think that was stock. It would be better to copy either of the functions and use one of them. |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | Top |
|
Posted by
| Samson
USA (683 posts) Bio
|
Date
| Reply #4 on Sat 20 Mar 2004 04:56 AM (UTC) |
Message
| fread_string_noalloc is not a stock function and should have complained unless you've had someone modify your code to contain it. | Top |
|
Posted by
| Marowi
(65 posts) Bio
|
Date
| Reply #5 on Sat 20 Mar 2004 12:48 PM (UTC) |
Message
| Ok, so.. where do I implement that snippet on Samson's forums? Randomly sticking it in doesn't work (I tried >.<) | Top |
|
Posted by
| Greven
Canada (835 posts) Bio
|
Date
| Reply #6 on Sat 20 Mar 2004 05:38 PM (UTC) |
Message
| How it it not working? Either function can just be dropped in anywhere(most appropriate place would be db.c with the other fread_* functions). Copy and paste, and add the prototype to mud.h with the other fread_* prototypes, and you should be all good. |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | Top |
|
Posted by
| Marowi
(65 posts) Bio
|
Date
| Reply #7 on Sat 20 Mar 2004 05:49 PM (UTC) |
Message
| Forgive the stupidity... I forgot to add it to mud.h
Works like a charm now, thanks. | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #8 on Sat 20 Mar 2004 06:27 PM (UTC) |
Message
| Hey, I'd just like to say thanks to Gavin, Greven, and Samson for the fread_float. I long ago fixed the reading of PopSupport in a different way but I quickly changed to these. It seemed like a better solution, plus now I have the fread_float function for when I save other floats. Thanks. |
~Nick Cash
http://www.nick-cash.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.
19,434 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top