Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Development
Nov 28, 2018, 10:10 am
By Keirath
First Immortal
Oct 12, 2018, 12:02 pm
By GatewaySysop
Bug in do_climb( )
Jun 5, 2018, 5:31 pm
By joeyfogas
question on overland code
May 31, 2018, 10:03 am
By joeyfogas
KaVir's Protocol Snip
May 15, 2018, 7:57 pm
By joeyfogas
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl

Members: 0
Guests: 10
Stats
Files
Topics
Posts
Members
Newest Member
481
3,740
19,397
638
IgnacioBol
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SmaugFUSS Bugfix List » [Bug] Utility Macros sometime...
Forum Rules | Mark all | Recent Posts

[Bug] Utility Macros sometimes give bad results
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Jan 6, 2008, 11:02 am   Last edited Jan 6, 2008, 11:13 am by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,644
JoinedJan 1, 2002

Bug: Utility Macros sometimes give bad results
Danger: Medium - When they work, they're good. When they don't, you get unexpected and hard to trace errors.
Found by: Remcon
Fixed by: Remcon

---

mud.h

Locate:
/*
 * Utility macros.
 */
#define UMIN(a, b)		((a) < (b) ? (a) : (b))
#define UMAX(a, b)		((a) > (b) ? (a) : (b))
#define URANGE(a, b, c)		((b) < (a) ? (a) : ((b) > (c) ? (c) : (b)))
#define LOWER(c)		((c) >= 'A' && (c) <= 'Z' ? (c)+'a'-'A' : (c))
#define UPPER(c)		((c) >= 'a' && (c) <= 'z' ? (c)+'A'-'a' : (c))


Change to:
// Utility macros.
int umin( int check, int ncheck );
int umax( int check, int ncheck );
int urange( int mincheck, int check, int maxcheck );

#define UMIN( a, b )      ( umin( (a), (b) ) )
#define UMAX( a, b )      ( umax( (a), (b) ) )
#define URANGE(a, b, c )  ( urange( (a), (b), (c) ) )
#define LOWER( c )        ( (c) >= 'A' && (c) <= 'Z' ? (c) + 'a' - 'A' : (c) )
#define UPPER( c )        ( (c) >= 'a' && (c) <= 'z' ? (c) + 'A' - 'a' : (c) )


handler.c

Locate:
/*
 * Return how much exp a char has
 */
int get_exp( CHAR_DATA * ch )
{
   return ch->exp;
}


Above that, add these new functions:
int umin( int check, int ncheck )
{
   if( check < ncheck )
      return check;
   return ncheck;
}

int umax( int check, int ncheck )
{
   if( check > ncheck )
      return check;
   return ncheck;
}

int urange( int mincheck, int check, int maxcheck )
{
   if( check < mincheck )
      return mincheck;
   if( check > maxcheck )
      return maxcheck;
   return check;
}


update.c, gain_exp

Locate:
   /*
    * xp cap to prevent any one event from giving enuf xp to 
    * gain more than one level - FB 
    */
   modgain = UMIN( modgain, exp_level( ch, ch->level + 2 ) - exp_level( ch, ch->level + 1 ) );


Change to:
   /*
    * xp cap to prevent any one event from giving enuf xp to 
    * gain more than one level - FB 
    */
   modgain = UMIN( (int)modgain, exp_level( ch, ch->level + 2 ) - exp_level( ch, ch->level + 1 ) );


This problem is best explained through this post: http://www.smaugmuds.org/index.php?a=topic&t=808

The fix here is part of the same fix Remcon applied to his LoP codebase.
       
Pages:<< prev 1 next >>