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 ➜ Uptime and reading from files

Uptime and reading from files

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


Pages: 1  2 

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #15 on Mon 10 Jul 2006 09:06 PM (UTC)
Message
Now I'm having an issue with it. =P

With the code using ch_printf, it's fine. But using sprintf, I get these warnings:
update.c:3806: warning: format '%d' expects type 'int', but argument 3 has type 'long int'
update.c:3806: warning: format '%d' expects type 'int', but argument 5 has type 'long int'
update.c:3806: warning: format '%d' expects type 'int', but argument 7 has type 'long int'
update.c:3806: warning: format '%d' expects type 'int', but argument 9 has type 'long int'


Doesn't make much sense, except ch_printf is being used and not sprintf. How would I fix those warnings?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #16 on Mon 10 Jul 2006 09:14 PM (UTC)
Message
I think all you need to do is to use %l instead of %d, to avoid the warning.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Conner   USA  (381 posts)  Bio
Date Reply #17 on Mon 10 Jul 2006 09:19 PM (UTC)
Message
You sure that wouldn't be %ld rather than %l or %d?

-=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 David Haley   USA  (3,881 posts)  Bio
Date Reply #18 on Mon 10 Jul 2006 09:21 PM (UTC)
Message
Oops, I left out the d. Yes, of course, it's %ld, because the l is a length modifier ('long') on the conversion specifier (d, the integer).

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #19 on Mon 10 Jul 2006 10:06 PM (UTC)
Message
Silly me. It's been too long since I did code with long int. Thanks.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #20 on Tue 11 Jul 2006 05:04 AM (UTC)
Message
Try to be to totally off the subject here.. well I kinda am since you mentioned finger, but if you can make finger work in smaugfuss... would you post it or something? I've tried for the life of me, but cant seem to do it.

Everything turns around in the end
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #21 on Tue 11 Jul 2006 01:00 PM (UTC)
Message
Worked fine for me in FUSS. Are you getting compile errors or something? If so, start a new topic. Keeps things organized.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Samson   USA  (683 posts)  Bio
Date Reply #22 on Tue 11 Jul 2006 01:15 PM (UTC)
Message
A point of efficiency, even if it's a slight one. Smaug has the current_time variable declared globally and it is updated every game_loop, which is roughly 0.25sec. So this bit here:

    current = time(0);
    diff = current - boot_time


Could be done as:

diff  = current_time - boot_time;


One less variable to declare and use, and one less function call to make each time the command is issued. It's little things like this to keep in mind for overall resource efficiency :)
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #23 on Tue 11 Jul 2006 01:40 PM (UTC)
Message
It's true that that would be more efficient, technically speaking, but the gain would be negligible. time(0) is a very cheap operation and this function is not called very frequently. In a sense it's not even a blip on the radar in terms of efficiency, even if it is faster. If you think about it in assembly terms, it's clearer why it's not very important. One function call every once in a while is really nothing. If this function were called very often (as in several thousand times per second or even more), this optimization would be more important.

I would argue that it's important to use the global variable to ensure that you're operating on the same time units. If the time were to be changed and counted in, say, nanoseconds, then using time(0) would break things whereas using the global would be somewhat easier to fix. (Your end result would be off, instead of subtracting nanoseconds from milliseconds or something weird like that.)

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.


75,781 views.

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

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.