summaryrefslogtreecommitdiff
path: root/src/map/script-fun.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script-fun.cpp')
-rw-r--r--src/map/script-fun.cpp91
1 files changed, 52 insertions, 39 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 8aae552..744f2c3 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -108,8 +108,9 @@ void builtin_goto(ScriptState *st)
{
if (!AARG(0).is<ScriptDataPos>())
{
- PRINTF("script: goto: not label !\n"_fmt);
+ PRINTF("fatal: script: goto: not label !\n"_fmt);
st->state = ScriptEndState::END;
+ runflag = 0;
return;
}
@@ -149,8 +150,9 @@ void builtin_callfunc(ScriptState *st)
}
OMATCH_CASE_NONE ()
{
- PRINTF("script:callfunc: function not found! [%s]\n"_fmt, str);
+ PRINTF("fatal: script: callfunc: function not found! [%s]\n"_fmt, str);
st->state = ScriptEndState::END;
+ runflag = 0;
}
}
OMATCH_END ();
@@ -188,6 +190,14 @@ void builtin_callsub(ScriptState *st)
static
void builtin_return(ScriptState *st)
{
+ if (!(st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>()))
+ {
+ dumb_ptr<npc_data> nd = map_id_is_npc(st->oid);
+ if(nd)
+ PRINTF("Deprecated: return outside of callfunc or callsub! @ %s\n"_fmt, nd->name);
+ else
+ PRINTF("Deprecated: return outside of callfunc or callsub! (no npc)\n"_fmt);
+ }
#if 0
if (HARG(0))
{ // 戻り値有り
@@ -215,6 +225,14 @@ void builtin_next(ScriptState *st)
static
void builtin_close(ScriptState *st)
{
+ if (st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>())
+ {
+ dumb_ptr<npc_data> nd = map_id_is_npc(st->oid);
+ if(nd)
+ PRINTF("Deprecated: close in a callfunc or callsub! @ %s\n"_fmt, nd->name);
+ else
+ PRINTF("Deprecated: close in a callfunc or callsub! (no npc)\n"_fmt);
+ }
st->state = ScriptEndState::END;
clif_scriptclose(script_rid2sd(st), st->oid);
}
@@ -276,7 +294,9 @@ void builtin_menu(ScriptState *st)
int arg_index = (sd->npc_menu - 1) * 2 + 1;
if (!AARG(arg_index).is<ScriptDataPos>())
{
+ PRINTF("fatal: script:menu: not a label\n"_fmt);
st->state = ScriptEndState::END;
+ runflag = 0;
return;
}
st->scriptp.pos = AARG(arg_index).get_if<ScriptDataPos>()->numi;
@@ -338,22 +358,10 @@ void builtin_warp(ScriptState *st)
{
int x, y;
dumb_ptr<map_session_data> sd = script_rid2sd(st);
-
MapName str = stringish<MapName>(ZString(conv_str(st, &AARG(0))));
x = conv_num(st, &AARG(1));
y = conv_num(st, &AARG(2));
- if (str == "Random"_s)
- pc_randomwarp(sd, BeingRemoveWhy::WARPED);
- else if (str == "SavePoint"_s or str == "Save"_s)
- {
- if (sd->bl_m->flag.get(MapFlag::NORETURN))
- return;
-
- pc_setpos(sd, sd->status.save_point.map_, sd->status.save_point.x, sd->status.save_point.y,
- BeingRemoveWhy::WARPED);
- }
- else
- pc_setpos(sd, str, x, y, BeingRemoveWhy::GONE);
+ pc_setpos(sd, str, x, y, BeingRemoveWhy::GONE);
}
/*==========================================
@@ -364,10 +372,7 @@ static
void builtin_areawarp_sub(dumb_ptr<block_list> bl, MapName mapname, int x, int y)
{
dumb_ptr<map_session_data> sd = bl->is_player();
- if (mapname == "Random"_s)
- pc_randomwarp(sd, BeingRemoveWhy::WARPED);
- else
- pc_setpos(sd, mapname, x, y, BeingRemoveWhy::GONE);
+ pc_setpos(sd, mapname, x, y, BeingRemoveWhy::GONE);
}
static
@@ -553,7 +558,7 @@ void builtin_setarray(ScriptState *st)
if (prefix != '$' && prefix != '@')
{
- PRINTF("builtin_setarray: illegal scope !\n"_fmt);
+ PRINTF("builtin_setarray: illegal scope!\n"_fmt);
return;
}
if (prefix != '$')
@@ -584,7 +589,7 @@ void builtin_cleararray(ScriptState *st)
if (prefix != '$' && prefix != '@')
{
- PRINTF("builtin_cleararray: illegal scope !\n"_fmt);
+ PRINTF("builtin_cleararray: illegal scope!\n"_fmt);
return;
}
if (prefix != '$')
@@ -641,7 +646,7 @@ void builtin_getarraysize(ScriptState *st)
if (prefix != '$' && prefix != '@')
{
- PRINTF("builtin_copyarray: illegal scope !\n"_fmt);
+ PRINTF("builtin_copyarray: illegal scope!\n"_fmt);
return;
}
@@ -660,7 +665,7 @@ void builtin_getelementofarray(ScriptState *st)
int i = conv_num(st, &AARG(1));
if (i > 255 || i < 0)
{
- PRINTF("script: getelementofarray (operator[]): param2 illegal number %d\n"_fmt,
+ PRINTF("script: getelementofarray (operator[]): param2 illegal number: %d\n"_fmt,
i);
push_int<ScriptDataInt>(st->stack, 0);
}
@@ -672,7 +677,7 @@ void builtin_getelementofarray(ScriptState *st)
}
else
{
- PRINTF("script: getelementofarray (operator[]): param1 not name !\n"_fmt);
+ PRINTF("script: getelementofarray (operator[]): param1 not named!\n"_fmt);
push_int<ScriptDataInt>(st->stack, 0);
}
}
@@ -750,7 +755,7 @@ void builtin_countitem(ScriptState *st)
else
{
if (battle_config.error_log)
- PRINTF("wrong item ID : countitem (%i)\n"_fmt, nameid);
+ PRINTF("wrong item ID: countitem (%i)\n"_fmt, nameid);
}
push_int<ScriptDataInt>(st->stack, count);
@@ -788,7 +793,7 @@ void builtin_checkweight(ScriptState *st)
amount = conv_num(st, &AARG(1));
if (amount <= 0 || !nameid)
{
- //if get wrong item ID or amount<=0, don't count weight of non existing items
+ //If it gets the wrong item ID or the amount<=0, don't count its weight (assume it's a non-existent item)
push_int<ScriptDataInt>(st->stack, 0);
return;
}
@@ -940,7 +945,7 @@ void builtin_delitem(ScriptState *st)
if (!nameid || amount <= 0)
{
- //by Lupus. Don't run FOR if u got wrong item ID or amount<=0
+ //By Lupus. Don't run FOR if you've got the wrong item ID or amount<=0
return;
}
@@ -1215,6 +1220,14 @@ void builtin_getgmlevel(ScriptState *st)
static
void builtin_end(ScriptState *st)
{
+ if (st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>())
+ {
+ dumb_ptr<npc_data> nd = map_id_is_npc(st->oid);
+ if(nd)
+ PRINTF("Deprecated: close in a callfunc or callsub! @ %s\n"_fmt, nd->name);
+ else
+ PRINTF("Deprecated: close in a callfunc or callsub! (no npc)\n"_fmt);
+ }
st->state = ScriptEndState::END;
}
@@ -1910,7 +1923,7 @@ static
void builtin_debugmes(ScriptState *st)
{
RString mes = conv_str(st, &AARG(0));
- PRINTF("script debug : %d %d : %s\n"_fmt,
+ PRINTF("script debug: %d %d: '%s'\n"_fmt,
st->rid, st->oid, mes);
}
@@ -2518,7 +2531,7 @@ void builtin_npcwarp(ScriptState *st)
if (!nd)
{
- PRINTF("builtin_npcwarp: no such npc: %s\n"_fmt, npc);
+ PRINTF("builtin_npcwarp: no such npc: '%s'\n"_fmt, npc);
return;
}
@@ -2561,7 +2574,7 @@ void builtin_npcareawarp(ScriptState *st)
if (!nd)
{
- PRINTF("builtin_npcareawarp: no such npc: %s\n"_fmt, npc);
+ PRINTF("builtin_npcareawarp: no such npc: '%s'\n"_fmt, npc);
return;
}
@@ -2806,7 +2819,7 @@ void builtin_shop(ScriptState *st)
nd = npc_name2id(name);
if (!nd)
{
- PRINTF("builtin_shop: no such npc: %s\n"_fmt, name);
+ PRINTF("builtin_shop: no such npc: '%s'\n"_fmt, name);
return;
}
@@ -2839,7 +2852,7 @@ void builtin_fakenpcname(ScriptState *st)
dumb_ptr<npc_data> nd = npc_name2id(name);
if (!nd)
{
- PRINTF("builtin_fakenpcname: no such npc: %s\n"_fmt, name);
+ PRINTF("builtin_fakenpcname: no such npc: '%s'\n"_fmt, name);
return;
}
nd->name = newname;
@@ -2901,7 +2914,7 @@ void builtin_strnpcinfo(ScriptState *st)
nd = npc_name2id(npc);
if (!nd)
{
- PRINTF("builtin_strnpcinfo: no such npc: %s\n"_fmt, npc);
+ PRINTF("builtin_strnpcinfo: no such npc: '%s'\n"_fmt, npc);
return;
}
} else {
@@ -2941,7 +2954,7 @@ void builtin_getnpcx(ScriptState *st)
nd = npc_name2id(name);
if (!nd)
{
- PRINTF("builtin_getnpcx: no such npc: %s\n"_fmt, name);
+ PRINTF("builtin_getnpcx: no such npc: '%s'\n"_fmt, name);
return;
}
} else {
@@ -2965,7 +2978,7 @@ void builtin_getnpcy(ScriptState *st)
nd = npc_name2id(name);
if (!nd)
{
- PRINTF("builtin_getnpcy: no such npc: %s\n"_fmt, name);
+ PRINTF("builtin_getnpcy: no such npc: '%s'\n"_fmt, name);
return;
}
} else {
@@ -3036,11 +3049,11 @@ BuiltinFunction builtin_functions[] =
BUILTIN(killmonster, "ME"_s, '\0'),
BUILTIN(donpcevent, "E"_s, '\0'),
BUILTIN(addtimer, "tE"_s, '\0'),
- BUILTIN(initnpctimer, ""_s, '\0'),
+ BUILTIN(initnpctimer, "?"_s, '\0'),
BUILTIN(startnpctimer, "?"_s, '\0'),
- BUILTIN(stopnpctimer, ""_s, '\0'),
- BUILTIN(getnpctimer, "i"_s, 'i'),
- BUILTIN(setnpctimer, "i"_s, '\0'),
+ BUILTIN(stopnpctimer, "?"_s, '\0'),
+ BUILTIN(getnpctimer, "i?"_s, 'i'),
+ BUILTIN(setnpctimer, "i?"_s, '\0'),
BUILTIN(announce, "si"_s, '\0'),
BUILTIN(mapannounce, "Msi"_s, '\0'),
BUILTIN(getusers, "i"_s, 'i'),