(New message)
Subject review (reverse sequence)
Posted by
Nick Gammon
Australia (18,800 posts) bio
Forum Administrator
Date
Mon 06 Oct 2008 07:22 AM (UTC) [ quote
]
Message
You would be 100% correct about that.
- Nick Gammon
www.gammon.com.au, www.mushclient.com top
Posted by
Nick Cash
USA (626 posts) bio
Date
Mon 06 Oct 2008 05:58 AM (UTC) [ quote
] Amended on Mon 06 Oct 2008 06:01 AM (UTC) by Nick Cash
Message
Although you figured it out, I'd like to point out it is the use of a static variable that causes this. It avoids memory allocation management, but at the expense of situations like this. As you have discovered, it works if you break up the code calling the functions.
If I had to guess, the value retained in the buffer is from the last call completed since the return value each time points to the same static character array. Because you put two calls in one line, the second call was stacked on the first call, thus executing the second call first, causing it's value in 'buf' to be wiped out by the next call.
~Nick Cash
http://www.nick-cash.com top
Posted by
Typhon
USA (112 posts) bio
Date
Sun 05 Oct 2008 06:06 PM (UTC) [ quote
]
Message
haha breaking up the code works. thanks :) top
Posted by
Zeno
USA (2,868 posts) bio
Moderator
Date
Sun 05 Oct 2008 05:33 PM (UTC) [ quote
]
Message
This may be related, but in Smaug if you use num_punct (which does the same thing) on the same line, it won't work.
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org top
Posted by
Typhon
USA (112 posts) bio
Date
Sun 05 Oct 2008 04:23 PM (UTC) [ quote
]
Message
seems like i'm missing something real small here but nonetheless i cant find it.
added :
char *short_num(int num)
{
static char buf[12];
buf[0] = '\0';
if (num <= 9999)
{
sprintf(buf, "%d", num);
return buf;
}
sprintf(buf, "%5.1f%c", (float)num / 1000, num>1000000 ? 'm' : 'k' );
return buf;
}
when calling that function in
ch_printf(ch, "%-4s/%-4s ", short_num(ch->hit), short_num(ch->max_hit) );
it returns the exact same figure for both :(
11.4k/11.4k when ch has 30,000 max_hit.
thanks
-typ 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.
2,464 views.
Reply to this subject
Start a new subject
  Refresh page
Go to topic:
(Choose topic)
Area Editor: Bug reports
Area Editor: General
Area Editor: News and updates
Area Editor: Suggestions
Area Editor: Tips and tricks
Dawn of Time: Administration
Dawn of Time: Configuration
Dawn of Time: Installing/compiling the server
Dawn of Time: New Dawn Muds Announcements
Dawn of Time: Playing
Dawn of Time: What is Dawn of Time (Dawn)?
Electronics: Microprocessors
Electronics: Operational Amplifiers
Forum: About
Forum: Announcements
Forum: Mailing other users
Forum: Problems
Forum: Registering
Forum: Searching
Forum: Subscribing
Forum: Suggestions
Forum: Test
Forum: Time zones / time display
Forum software: Administration
Forum software: Installation
MUDs: Announcements
MUDs: General
MUDs: MUD Design Concepts
MUSHclient: Announcements
MUSHclient: Beta testing
MUSHclient: Bug reports
MUSHclient: Development
MUSHclient: General
MUSHclient: Getting Started
MUSHclient: International
MUSHclient: Jscript
MUSHclient: Lua
MUSHclient: Miniwindows
MUSHclient: MXP and Pueblo
MUSHclient: Perlscript
MUSHclient: Plugins
MUSHclient: Python
MUSHclient: Suggestions
MUSHclient: Tips and tricks
MUSHclient: VBscript
MUSHclient: Wine
PennMUSH: Compiling the server
PennMUSH: Running the server
Programming: General
Programming: STL
Quilting: General
ROM: Compiling the server
ROM: Running the server
SMAUG: Commands
SMAUG: Compiling the server
SMAUG: Lua
SMAUG: Running the server
SMAUG: SMAUG coding
Search the forum
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )