From 0bc322efc087ab0c7b53709e5e20ac76aee761de Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 4 Nov 2014 22:28:16 -0800 Subject: Perform divorces asynchronously to avoid crashes --- src/map/chrif.cpp | 11 +++-------- src/map/map.hpp | 1 - src/map/pc.cpp | 9 +++------ src/map/script-fun.cpp | 4 ---- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index 09c238c..dbdd401 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -751,18 +751,13 @@ int chrif_divorce(CharId char_id, CharId partner_id) if (sd && sd->status.partner_id == partner_id) { sd->status.partner_id = CharId(); - - if (sd->npc_flags.divorce) - { - sd->npc_flags.divorce = 0; - map_scriptcont(sd, sd->npc_id); - } } sd = map_nick2sd(map_charid2nick(partner_id)); - nullpo_retz(sd); - if (sd->status.partner_id == char_id) + if (sd && sd->status.partner_id == char_id) + { sd->status.partner_id = CharId(); + } return 0; } diff --git a/src/map/map.hpp b/src/map/map.hpp index 183b74d..f82283d 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -194,7 +194,6 @@ struct map_session_data : block_list, SessionData struct { unsigned storage:1; - unsigned divorce:1; } npc_flags; Timer attacktimer; diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 1e7d295..70c9087 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -4709,15 +4709,12 @@ int pc_divorce(dumb_ptr sd) } p_sd->status.partner_id = CharId(); sd->status.partner_id = CharId(); - - if (sd->npc_flags.divorce) - { - sd->npc_flags.divorce = 0; - map_scriptcont(sd, sd->npc_id); - } } else + { + sd->status.partner_id = CharId(); chrif_send_divorce(sd->status_key.char_id); + } return 0; } diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 69aee10..c38f498 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2209,10 +2209,6 @@ void builtin_divorce(ScriptState *st) { dumb_ptr sd = script_rid2sd(st); - st->state = ScriptEndState::STOP; // rely on pc_divorce to restart - - sd->npc_flags.divorce = 1; - if (sd == nullptr || pc_divorce(sd) < 0) { push_int(st->stack, 0); -- cgit v1.2.3-60-g2f50