Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Google

Members: 0
Guests: 7
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » [Bug] fix_char causes problem...
Forum Rules | Mark all | Recent Posts

[Bug] fix_char causes problems reequipping same item in different wearlocs
< Newer Topic :: Older Topic > AFKMud 1.63

Pages:<< prev 1 next >>
Post is unread #1 Aug 15, 2004, 4:33 pm   Last edited Nov 13, 2005, 12:14 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Bug: fix_char causes problems when reequipping the same item in different wear locations.
Discovered in: AFKMud 1.63
Danger: Medium - Data corruption
Found by: Greven
Fixed by: Greven

act_wiz.c, fix_char

Locate the function, and replace it as follows:

/*
 * "Fix" a character's stats    	-Thoric
 */
void fix_char( CHAR_DATA *ch )
{
    AFFECT_DATA *aff;
   OBJ_DATA *obj;

    de_equip_char( ch );

   for( aff = ch->first_affect; aff; aff = aff->next )
	affect_modify( ch, aff, FALSE );

   xCLEAR_BITS( ch->affected_by );
   xSET_BITS( ch->affected_by, race_table[ch->race]->affected );
    ch->mental_state	= -10;
    ch->hit  = UMAX( 1, ch->hit  );
    ch->mana  = UMAX( 1, ch->mana );
    ch->move  = UMAX( 1, ch->move );
    ch->armor  = 100;
    ch->mod_str  = 0;
    ch->mod_dex  = 0;
    ch->mod_wis  = 0;
    ch->mod_int  = 0;
    ch->mod_con  = 0;
    ch->mod_cha  = 0;
    ch->mod_lck  = 0;
    ch->damroll  = 0;
    ch->hitroll  = 0;
    ch->alignment	= URANGE( -1000, ch->alignment, 1000 );
    ch->saving_breath	= 0;
    ch->saving_wand	= 0;
    ch->saving_para_petri = 0;
    ch->saving_spell_staff = 0;
    ch->saving_poison_death = 0;

    ch->carry_weight	= 0;
    ch->carry_number	= 0;

   ClassSpecificStuff( ch ); /* Brought over from DOTD code - Samson 4-6-99 */

   for( aff = ch->first_affect; aff; aff = aff->next )
	affect_modify( ch, aff, TRUE );

    for( obj = ch->first_carrying; obj; obj = obj->next_content )
    {
       if( obj->wear_loc == WEAR_NONE )
            ch->carry_number += get_obj_number(obj);
       if( !xIS_SET(obj->extra_flags, ITEM_MAGIC) )
            ch->carry_weight += get_obj_weight(obj);
    }

    re_equip_char( ch );
}


Greven's explanation of the problem can be found here:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4564

In summary, the way in which fix_char was storing objects when removed was forgetting to account for the fact that object data is grouped when like objects are put together, and then not having any way to know they need separating afterward. The result was object cloning, and pointers to objects with invalid counts.
       
Pages:<< prev 1 next >>