Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
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, Yandex

Members: 0
Guests: 4
Stats
Files
Topics
Posts
Members
Newest Member
481
3,734
19,366
618
Micheal64X
Today's Birthdays
Vintar (28)
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,643
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 >>