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, Yandex, Yahoo!, Bing

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

[Bug] fix_char causes problems when reequipping the same item in different
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 5, 2005, 4:04 pm   Last edited Feb 4, 2006, 3:31 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.
Danger: Medium - Data corruption
Found by: Greven
Fixed by: Greven

handler.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;

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

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

    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....subject_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 >>