The Negative Experience BUG for EmberMUD
                      Fix Sheet by Rindar (Ron Cole)
            Fix by Raven (Laurie Zenner) and Rindar (Ron Cole)

The Bug:  This is one of those odd bugs that we weren't able to 
duplicate because we didn't have the patience.  Basicly, a 
character dies a few times, then constantly flees from opponents. 
After a few days of fleeing, the character is suddenly able to 
advance to the maximum attainable mortal level.  Apparently,  
cowardess pays better than bravery.
     
     What we figure the player in question was doing was lowering 
their XP beyond the lowest possible point.  By doing this, they 
were able to "roll over" the experience counter to the highest 
positive number.  Since none of us wanted to spend the days it 
would take to roll-over our experience, we just played our hunch 
and wrote some code that would stop what we suspected the bug was.  
After implementing the fix, the player in question never went to 
level 91 again.  Either the fix worked, or they got tired of us 
always knocking their characters down to level 1 after an incident.

The Check:  I dunno.  If someone can prove or disprove this fix, 
please e-mail me.

The Bugfix:  Unlike most of the other fixes, it is easier to 
replace the 8 lines of code that make up the function gain_exp 
than it is to explain how to install it.  Just pop in the snippet
at the bottom of this sheet and you're done.  Here's how:

        1)  Open update.c
        2)  Find the function "void gain_exp"
        3)  Delete it.
        3)  Replace it with the function at the bottom of the page. 
        4)  Recompile.  You are done.


-= Rindar
clogar@concentric.net


** Note:  This function is provided "as is" and may be used so long as 
1)  The author's name is kept at the top of the function (if requested) and
2)  all other previous licensing aggreements are abided by.  The author 
assumes no responsibility for problems that occur through use or install-
ation, including lost wages, bugs, deletions, downtimes, etc...  Use at 
your own risk.  All new code is copyrighted by its author.


New gain_exp function (update.c):

void gain_exp( CHAR_DATA *ch, int gain )
{
    long testexp = 0;
    long maxexp  = 2147483647;
    
    if ( IS_NPC(ch) || ch->level >= LEVEL_HERO )
        return;

    if ( ch->exp < 0 && gain < 0 )
    {
        testexp = -1*maxexp;
        if ( ch->exp < (testexp - gain) )
        {
           ch->exp = (-1*maxexp);
           if ( ch->perm_stat[STAT_CON] > 1 )
           {
                send_to_char( "You feel drained!\n\r", ch );
                ch->perm_stat[STAT_CON] -= 1;
                return;
           }
           send_to_char( "You die the final death!\n\r", ch );
           ch->position =  POS_STANDING;
           interpret( ch, "rem all" );
           interpret( ch, "drop all" );
           interpret( ch, "delete" );
           interpret( ch, "delete" );              
           return;
        }
                
    }
    if ( ch->exp > 0 && gain > 0 )
    {
        testexp = maxexp;
        if ( ch->exp > (testexp - gain) )
        {
                ch->exp = maxexp;
                return;
        }       
    }

    ch->exp += gain;
    return;
}                


 =============================================================================
/   ______ _______ ____   _____   ___ __    _ ______    ____  ____   _____   /
\  |  ____|__   __|  _ \ / ____\ / _ \| \  / |  ____|  / __ \|  _ \ / ____\  \
/  | |__     | |  | |_| | |     | |_| | |\/| | |___   | |  | | |_| | |       /
/  | ___|    | |  | ___/| |   __|  _  | |  | | ____|  | |  | |  __/| |   ___ \
\  | |       | |  | |   | |___| | | | | |  | | |____  | |__| | |\ \| |___| | /
/  |_|       |_|  |_|  o \_____/|_| |_|_|  |_|______|o \____/|_| \_|\_____/  \
\                                                                            /
 ============================================================================

------------------------------------------------------------------------------
ftp://ftp.game.org/pub/mud      FTP.GAME.ORG      http://www.game.org/ftpsite/
------------------------------------------------------------------------------

 This file came from FTP.GAME.ORG, the ultimate source for MUD resources.

------------------------------------------------------------------------------