diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-11-04 22:28:16 -0800 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-11-04 22:28:16 -0800 |
commit | 0bc322efc087ab0c7b53709e5e20ac76aee761de (patch) | |
tree | c656fb93447bc7268920f020c8459c7392abce6d | |
parent | ad98bbcff7d6385dbcc4b2c7d393c7f16420ebdd (diff) | |
download | tmwa-0bc322efc087ab0c7b53709e5e20ac76aee761de.tar.gz tmwa-0bc322efc087ab0c7b53709e5e20ac76aee761de.tar.bz2 tmwa-0bc322efc087ab0c7b53709e5e20ac76aee761de.tar.xz tmwa-0bc322efc087ab0c7b53709e5e20ac76aee761de.zip |
Perform divorces asynchronously to avoid crashes
-rw-r--r-- | src/map/chrif.cpp | 11 | ||||
-rw-r--r-- | src/map/map.hpp | 1 | ||||
-rw-r--r-- | src/map/pc.cpp | 9 | ||||
-rw-r--r-- | 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<map_session_data> 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<map_session_data> 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<ScriptDataInt>(st->stack, 0); |