Issue information

Issue ID
#992
Status
Working as Intended
Severity
None
Started
Hercules Elf Bot
Feb 17, 2008 23:23
Last Post
Hercules Elf Bot
Feb 17, 2008 23:23
Confirmation
N/A

Hercules Elf Bot - Feb 17, 2008 23:23

Originally posted by [b]theultramage[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=992

This is a modification of eathena chatroom code. Instead of moving it to a next player, all the players are removed instead.
Original:
CODE
    if( leavechar == 0 && cd->owner->type == BL_PC )
    {    // Set and announce new owner
        cd->owner = (struct block_list*) cd->usersd[0];
        clif_changechatowner(cd, cd->usersd[0]);
        clif_clearchat(cd, 0);

        //Adjust Chat location after owner has been changed.
        map_delblock( &cd->bl );
        cd->bl.x=cd->usersd[0]->bl.x;
        cd->bl.y=cd->usersd[0]->bl.y;
        map_addblock( &cd->bl );

        clif_dispchat(cd,0);
    }

Modified:
CODE
    if( leavechar == 0 && cd->owner->type == BL_PC )
    {    // close the chatroom to prevent people from moving it to a disallowed area
        for( i = 0; i < cd->users; ++i )
            chat_leavechat(cd->usersd[i],0);
    }


This produces random? crashes.
CODE
#0  chat_leavechat (sd=0xdddddddd, kicked=0 '\') at chat.c:234
234             cd = (struct chat_data*)map_id2bl(sd->chatID);
(gdb) bt full
#0  chat_leavechat (sd=0xdddddddd, kicked=0 '\') at chat.c:234
        i = <value optimized out>
        __FUNCTION__ = "chat_leavechat"
#1  0x0809e6a3 in chat_leavechat (sd=0xa721e1d8, kicked=0 '\') at chat.c:268
        i = 0
        __FUNCTION__ = "chat_leavechat"
#2  0x08061a04 in clif_parse (fd=704) at clif.c:11260
        cmd = 227
        packet_ver = 22
        packet_len = 2
        err = 628
        sd = (TBL_PC *) 0xa721e1d8
        pnum = 0
#3  0x081354b0 in do_sockets (next=50) at socket.c:790
        rfd = {__fds_bits = {0 <repeats 22 times>, 1, 0 <repeats 133 times>}}
        timeout = {tv_sec = 0, tv_usec = 48000}
        ret = 0
        i = <value optimized out>
#4  0x08133f26 in main (argc=1, argv=0xbf800d54) at core.c:254
        next = 0

This modification probably has a fault somewhere that might be producing this.