diff options
author | mekolat <mekolat@users.noreply.github.com> | 2016-04-24 14:15:28 -0400 |
---|---|---|
committer | mekolat <mekolat@users.noreply.github.com> | 2016-04-24 14:15:28 -0400 |
commit | adda881817c349e141a7b3f9c43fb98932a63803 (patch) | |
tree | 95330adc85016873f711265383a2c60cdecfdd7e /src/map/script-fun.cpp | |
parent | b19a8149a4400180427cf9acbd1498151ccb22c7 (diff) | |
parent | 6fac3210f0de07ab1ff483875ac517a3eea7367a (diff) | |
download | tmwa-adda881817c349e141a7b3f9c43fb98932a63803.tar.gz tmwa-adda881817c349e141a7b3f9c43fb98932a63803.tar.bz2 tmwa-adda881817c349e141a7b3f9c43fb98932a63803.tar.xz tmwa-adda881817c349e141a7b3f9c43fb98932a63803.zip |
Merge pull request #213 from mekolat/params
fixes for magic-v3
Diffstat (limited to 'src/map/script-fun.cpp')
-rw-r--r-- | src/map/script-fun.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index beabef3..b73a8fc 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -90,6 +90,8 @@ static void builtin_mes(ScriptState *st) { dumb_ptr<map_session_data> sd = script_rid2sd(st); + if (sd == nullptr) + return; sd->state.npc_dialog_mes = 1; RString mes = HARG(0) ? conv_str(st, &AARG(0)) : ""_s; clif_scriptmes(sd, st->oid, mes); @@ -327,6 +329,8 @@ void builtin_close(ScriptState *st) } st->state = ScriptEndState::END; dumb_ptr<map_session_data> sd = script_rid2sd(st); + if (sd == nullptr) + return; if (sd->state.npc_dialog_mes) clif_scriptclose(sd, st->oid); else @@ -338,6 +342,8 @@ void builtin_close2(ScriptState *st) { st->state = ScriptEndState::STOP; dumb_ptr<map_session_data> sd = script_rid2sd(st); + if (sd == nullptr) + return; if (sd->state.npc_dialog_mes) clif_scriptclose(sd, st->oid); else @@ -1121,6 +1127,13 @@ void builtin_puppet(ScriptState *st) { int x, y; + NpcName npc = stringish<NpcName>(ZString(conv_str(st, &AARG(3)))); + if (npc_name2id(npc) != nullptr) + { + push_int<ScriptDataInt>(st->stack, 0); + return; + } + dumb_ptr<block_list> bl = map_id2bl(st->oid); dumb_ptr<npc_data_script> parent_nd = bl->is_npc()->is_script(); dumb_ptr<npc_data_script> nd; @@ -1137,8 +1150,8 @@ void builtin_puppet(ScriptState *st) nd->scr.event_needs_map = false; // PlayerName::SpellName - NpcName npc = stringish<NpcName>(ZString(conv_str(st, &AARG(3)))); nd->name = npc; + nd->sex = SEX::UNSPECIFIED; // Dynamically set location nd->bl_m = m; @@ -3813,7 +3826,10 @@ void builtin_get(ScriptState *st) } if (bl == nullptr) + { + push_int<ScriptDataInt>(st->stack, -1); return; + } int var = pc_readparam(bl, reg.sp()); push_int<ScriptDataInt>(st->stack, var); return; @@ -3869,9 +3885,8 @@ void builtin_get(ScriptState *st) if (!bl) { - PRINTF("builtin_get: no block list attached %s!\n"_fmt, conv_str(st, &AARG(1))); if (postfix == '$') - push_str<ScriptDataStr>(st->stack, conv_str(st, &AARG(1))); + push_str<ScriptDataStr>(st->stack, ""_s); else push_int<ScriptDataInt>(st->stack, 0); return; |