Issue information

Issue ID
#2295
Status
Fixed
Severity
None
Started
Hercules Elf Bot
Sep 30, 2008 22:01
Last Post
Hercules Elf Bot
Sep 30, 2008 22:01
Confirmation
N/A

Hercules Elf Bot - Sep 30, 2008 22:01

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

Hello, there's an error in offline character divorce. It works only if both partners are online, but when one isn't, it's kinda buggy. It divorces both characters in SQL through char server only. So the offline partner is really divorced. But the online one has only different records in SQL table, which is overwritten by actual map data when character saving. Those map session data isn't 'divorced'. Blame goes to chrif_divorceack function (src/map/chrif.c):

CODE
    if (!char_id || !partner_id || (sd = map_charid2sd(partner_id)) == NULL || sd->status.partner_id != char_id)
        return 0;

    // Update Partner info
    sd->status.partner_id = 0;

    // Remove Wedding Rings from inventory
    for(i = 0; i < MAX_INVENTORY; i++)
        if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
            pc_delitem(sd, i, 1, 0);

Actually, that (sd = map_charid2sd(partner_id)) == NULL condition is true, because map_charid2sd function returns map session data of online character. Partner isn't online, so it returns null, condition is true and function ends. So there's no update to sd->status.partner_id and no pc_delitem. To fix this, change that first condition to:
CODE
    if (!char_id || !partner_id || (sd = map_charid2sd(char_id)) == NULL )

Now it properly gets the map session data of online partner - that one invoking divorce; npc function or @divorce <char> <- that one (IMG:style_emoticons/default/smile.gif)

Thanks for fixing guys (IMG:style_emoticons/default/ani_meow.gif)