diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/chrif.cpp | 89 | ||||
-rw-r--r-- | src/map/clif.cpp | 33 | ||||
-rw-r--r-- | src/map/npc-parse.cpp | 122 | ||||
-rw-r--r-- | src/map/npc.cpp | 2 | ||||
-rw-r--r-- | src/map/pc.cpp | 29 | ||||
-rw-r--r-- | src/map/pc.hpp | 1 | ||||
-rw-r--r-- | src/map/script-call.cpp | 8 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 91 | ||||
-rw-r--r-- | src/map/script-parse.cpp | 14 |
9 files changed, 142 insertions, 247 deletions
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index 3ffeaf2..2606911 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -218,7 +218,7 @@ int chrif_changemapserverack(Session *, const Packet_Fixed<0x2b06>& fixed) if (fixed.error == 1) { if (battle_config.error_log) - PRINTF("map server change failed.\n"_fmt); + PRINTF("Changing the map server failed.\n"_fmt); pc_authfail(sd->status_key.account_id); return 0; } @@ -241,7 +241,7 @@ int chrif_connectack(Session *s, const Packet_Fixed<0x2af9>& fixed) { if (fixed.code) { - PRINTF("Connected to char-server failed %d.\n"_fmt, fixed.code); + PRINTF("Connecting to char-server failed %d.\n"_fmt, fixed.code); exit(1); } PRINTF("Connected to char-server (connection #%d).\n"_fmt, s); @@ -249,11 +249,6 @@ int chrif_connectack(Session *s, const Packet_Fixed<0x2af9>& fixed) chrif_sendmap(s); - PRINTF("chrif: OnCharIfInit event done. (%d events)\n"_fmt, - npc_event_doall(stringish<ScriptLabel>("OnCharIfInit"_s))); - PRINTF("chrif: OnInterIfInit event done. (%d events)\n"_fmt, - npc_event_doall(stringish<ScriptLabel>("OnInterIfInit"_s))); - return 0; } @@ -266,7 +261,7 @@ int chrif_sendmapack(Session *, Packet_Fixed<0x2afb> fixed) { if (fixed.unknown) //impossible { - PRINTF("chrif : send map list to char server failed %d\n"_fmt, + PRINTF("chrif: sending the map list to char-server failed %d\n"_fmt, fixed.unknown); exit(1); } @@ -388,7 +383,7 @@ void chrif_char_ask_name(AccountId id, CharName character_name, short operation_ fixed_0e.operation = operation_type; // type of operation if (operation_type == 2) fixed_0e.ban_add = modif; - PRINTF("chrif : sended 0x2b0e\n"_fmt); + PRINTF("chrif: sent 0x2b0e\n"_fmt); send_fpacket<0x2b0e, 44>(char_session, fixed_0e); } @@ -402,7 +397,7 @@ void chrif_char_ask_name(AccountId id, CharName character_name, short operation_ * 4: unban * 5: changesex * type of answer: - * 0: login-server resquest done + * 0: login-server request done * 1: player not found * 2: gm level too low * 3: login-server offline @@ -419,7 +414,7 @@ int chrif_char_ask_name_answer(Session *, const Packet_Fixed<0x2b0f>& fixed) { AString output; if (fixed.error == 1) // player not found - output = STRPRINTF("The player '%s' doesn't exist."_fmt, + output = STRPRINTF("The player, '%s,' doesn't exist."_fmt, player_name); else { @@ -428,20 +423,20 @@ int chrif_char_ask_name_answer(Session *, const Packet_Fixed<0x2b0f>& fixed) case 1: // block switch (fixed.error) { - case 0: // login-server resquest done + case 0: // login-server request done output = STRPRINTF( - "Login-server has been asked to block the player '%s'."_fmt, + "Login-server has been asked to block '%s'."_fmt, player_name); break; //case 1: // player not found case 2: // gm level too low output = STRPRINTF( - "Your GM level don't authorise you to block the player '%s'."_fmt, + "Your GM level doesn't authorize you to block the player '%s'."_fmt, player_name); break; case 3: // login-server offline output = STRPRINTF( - "Login-server is offline. Impossible to block the the player '%s'."_fmt, + "Login-server is offline, so it's impossible to block '%s'."_fmt, player_name); break; } @@ -449,20 +444,20 @@ int chrif_char_ask_name_answer(Session *, const Packet_Fixed<0x2b0f>& fixed) case 2: // ban switch (fixed.error) { - case 0: // login-server resquest done + case 0: // login-server request done output = STRPRINTF( - "Login-server has been asked to ban the player '%s'."_fmt, + "Login-server has been asked to ban '%s'."_fmt, player_name); break; //case 1: // player not found case 2: // gm level too low output = STRPRINTF( - "Your GM level don't authorise you to ban the player '%s'."_fmt, + "Your GM level doesn't authorize you to ban '%s'."_fmt, player_name); break; case 3: // login-server offline output = STRPRINTF( - "Login-server is offline. Impossible to ban the the player '%s'."_fmt, + "Login-server is offline, so it's impossible to ban '%s'."_fmt, player_name); break; } @@ -470,20 +465,20 @@ int chrif_char_ask_name_answer(Session *, const Packet_Fixed<0x2b0f>& fixed) case 3: // unblock switch (fixed.error) { - case 0: // login-server resquest done + case 0: // login-server request done output = STRPRINTF( - "Login-server has been asked to unblock the player '%s'."_fmt, + "Login-server has been asked to unblock '%s'."_fmt, player_name); break; //case 1: // player not found case 2: // gm level too low output = STRPRINTF( - "Your GM level don't authorise you to unblock the player '%s'."_fmt, + "Your GM level doesn't authorize you to unblock '%s'."_fmt, player_name); break; case 3: // login-server offline output = STRPRINTF( - "Login-server is offline. Impossible to unblock the the player '%s'."_fmt, + "Login-server is offline, so it's impossible to unblock '%s'."_fmt, player_name); break; } @@ -491,20 +486,20 @@ int chrif_char_ask_name_answer(Session *, const Packet_Fixed<0x2b0f>& fixed) case 4: // unban switch (fixed.error) { - case 0: // login-server resquest done + case 0: // login-server request done output = STRPRINTF( - "Login-server has been asked to unban the player '%s'."_fmt, + "Login-server has been asked to unban '%s'."_fmt, player_name); break; //case 1: // player not found case 2: // gm level too low output = STRPRINTF( - "Your GM level don't authorise you to unban the player '%s'."_fmt, + "Your GM level doesn't authorize you to unban '%s'."_fmt, player_name); break; case 3: // login-server offline output = STRPRINTF( - "Login-server is offline. Impossible to unban the the player '%s'."_fmt, + "Login-server is offline, so it's impossible to unban '%s'."_fmt, player_name); break; } @@ -512,20 +507,20 @@ int chrif_char_ask_name_answer(Session *, const Packet_Fixed<0x2b0f>& fixed) case 5: // changesex switch (fixed.error) { - case 0: // login-server resquest done + case 0: // login-server request done output = STRPRINTF( - "Login-server has been asked to change the sex of the player '%s'."_fmt, + "Login-server has been asked to change the sex of '%s'."_fmt, player_name); break; //case 1: // player not found case 2: // gm level too low output = STRPRINTF( - "Your GM level don't authorise you to change the sex of the player '%s'."_fmt, + "Your GM level doesn't authorize you to change the sex of '%s'."_fmt, player_name); break; case 3: // login-server offline output = STRPRINTF( - "Login-server is offline. Impossible to change the sex of the the player '%s'."_fmt, + "Login-server is offline, so it's impossible to change the sex of '%s'."_fmt, player_name); break; } @@ -536,7 +531,7 @@ int chrif_char_ask_name_answer(Session *, const Packet_Fixed<0x2b0f>& fixed) clif_displaymessage(sd->sess, output); } else - PRINTF("chrif_char_ask_name_answer failed - player not online.\n"_fmt); + PRINTF("chrif_char_ask_name_answer failed because the player is not online.\n"_fmt); return 0; } @@ -704,14 +699,14 @@ int chrif_accountdeletion(Session *, const Packet_Fixed<0x2b13>& fixed) { sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters clif_displaymessage(sd->sess, - "Your account has been deleted (disconnection)..."_s); + "Your account has been deleted. You will now be disconnected..."_s); clif_setwaitclose(sd->sess); // forced to disconnect for the change } } else { if (sd != nullptr) - PRINTF("chrif_accountdeletion failed - player not online.\n"_fmt); + PRINTF("chrif_accountdeletion failed because the player is not online.\n"_fmt); } return 0; @@ -741,11 +736,11 @@ int chrif_accountban(Session *, const Packet_Fixed<0x2b14>& fixed) { // status or final date of a banishment case 1: // 0 = Unregistered ID clif_displaymessage(sd->sess, - "Your account has 'Unregistered'."_s); + "Your account has an unregistered ID."_s); break; case 2: // 1 = Incorrect Password clif_displaymessage(sd->sess, - "Your account has an 'Incorrect Password'..."_s); + "Your password is incorrect."_s); break; case 3: // 2 = This ID is expired clif_displaymessage(sd->sess, @@ -753,7 +748,7 @@ int chrif_accountban(Session *, const Packet_Fixed<0x2b14>& fixed) break; case 4: // 3 = Rejected from Server clif_displaymessage(sd->sess, - "Your account has been rejected from server."_s); + "Your account has been rejected by the server."_s); break; case 5: // 4 = You have been blocked by the GM Team clif_displaymessage(sd->sess, @@ -761,19 +756,19 @@ int chrif_accountban(Session *, const Packet_Fixed<0x2b14>& fixed) break; case 6: // 5 = Your Game's EXE file is not the latest version clif_displaymessage(sd->sess, - "Your Game's EXE file is not the latest version."_s); + "You need to update your client."_s); break; case 7: // 6 = Your are Prohibited to log in until %s clif_displaymessage(sd->sess, - "Your account has been prohibited to log in."_s); + "Your account has been prohibited from logging in."_s); break; case 8: // 7 = Server is jammed due to over populated clif_displaymessage(sd->sess, - "Server is jammed due to over populated."_s); + "The server is overpopulated."_s); break; case 9: // 8 = No MSG (actually, all states after 9 except 99 are No MSG, use only this) clif_displaymessage(sd->sess, - "Your account has not more authorised."_s); + "Your account must be authorized."_s); break; case 100: // 99 = This ID has been totally erased clif_displaymessage(sd->sess, @@ -781,7 +776,7 @@ int chrif_accountban(Session *, const Packet_Fixed<0x2b14>& fixed) break; default: clif_displaymessage(sd->sess, - "Your account has not more authorised."_s); + "Your account must be authorized."_s); break; } } @@ -800,7 +795,7 @@ int chrif_accountban(Session *, const Packet_Fixed<0x2b14>& fixed) else { if (sd != nullptr) - PRINTF("chrif_accountban failed - player not online.\n"_fmt); + PRINTF("chrif_accountban failed because the player is not online.\n"_fmt); } return 0; @@ -813,7 +808,7 @@ int chrif_accountban(Session *, const Packet_Fixed<0x2b14>& fixed) static int chrif_recvgmaccounts(Session *s, const std::vector<Packet_Repeat<0x2b15>>& repeat) { - PRINTF("From login-server: receiving of %d GM accounts information.\n"_fmt, + PRINTF("Receiving information on %d GM accounts from login-server.\n"_fmt, pc_read_gm_account(s, repeat)); return 0; @@ -823,7 +818,7 @@ static void chrif_delete(Session *s) { assert (s == char_session); - PRINTF("Map-server can't connect to char-server (connection #%d).\n"_fmt, + PRINTF("map-server can't connect to char-server (connection #%d).\n"_fmt, s); char_session = nullptr; } @@ -1012,7 +1007,7 @@ void chrif_parse(Session *s) return; if (battle_config.error_log) - PRINTF("chrif_parse : unknown packet %d %d\n"_fmt, s, + PRINTF("chrif_parse: unknown packet %d %d\n"_fmt, s, packet_id); s->set_eof(); return; @@ -1066,7 +1061,7 @@ void check_connect_char_server(TimerData *, tick_t) { if (!char_session) { - PRINTF("Attempt to connect to char-server...\n"_fmt); + PRINTF("Attempting to connect to char-server...\n"_fmt); chrif_state = 0; char_session = make_connection(map_conf.char_ip, map_conf.char_port, SessionParsers{.func_parse= chrif_parse, .func_delete= chrif_delete}); diff --git a/src/map/clif.cpp b/src/map/clif.cpp index e3cd55f..d327286 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -807,6 +807,8 @@ void clif_mob007b(dumb_ptr<mob_data> md, Buffer& buf) fixed_7b.mob_class = md->mob_class; // snip: stuff for monsters disguised as PCs fixed_7b.tick_and_maybe_part_of_guild_emblem = gettick(); + fixed_7b.max_hp = md->stats[mob_stat::MAX_HP]; + fixed_7b.hp = md->hp; fixed_7b.pos2.x0 = md->bl_x; fixed_7b.pos2.y0 = md->bl_y; @@ -819,7 +821,33 @@ void clif_mob007b(dumb_ptr<mob_data> md, Buffer& buf) buf = create_fpacket<0x007b, 60>(fixed_7b); } +/*========================================== + * Packet to send server's mob walkpath data + *------------------------------------------ + */ +static +int clif_0225_being_move3(dumb_ptr<mob_data> md) +{ + Packet_Head<0x0225> head_225; + std::vector<Packet_Repeat<0x0225>> repeat_225; + + head_225.magic_packet_length = md->walkpath.path_len + 14; + head_225.id = md->bl_id; + head_225.speed = battle_get_speed(md); + head_225.x_position = md->bl_x; + head_225.y_position = md->bl_y; + for (int i = 0; i < md->walkpath.path_len; i++) + { + Packet_Repeat<0x0225> move_225; + move_225.move = md->walkpath.path[i]; + repeat_225.push_back(move_225); + } + + Buffer buf = create_vpacket<0x0225, 14, 1>(head_225, repeat_225); + clif_send(buf, md, SendWho::AREA); + return 0; +} /*========================================== * *------------------------------------------ @@ -901,7 +929,7 @@ int clif_spawnnpc(dumb_ptr<npc_data> nd) { nullpo_retz(nd); - if (nd->npc_class == NEGATIVE_SPECIES || nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS) + if (nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS) return 0; Packet_Fixed<0x007c> fixed_7c; @@ -2320,7 +2348,7 @@ void clif_getareachar_npc(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data> nd) nullpo_retv(sd); nullpo_retv(nd); - if (nd->npc_class == NEGATIVE_SPECIES || nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS) + if (nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS) return; Buffer buf; @@ -2339,6 +2367,7 @@ int clif_movemob(dumb_ptr<mob_data> md) Buffer buf; clif_mob007b(md, buf); clif_send(buf, md, SendWho::AREA); + clif_0225_being_move3(md); return 0; } diff --git a/src/map/npc-parse.cpp b/src/map/npc-parse.cpp index 9c9a22c..4d9fcbd 100644 --- a/src/map/npc-parse.cpp +++ b/src/map/npc-parse.cpp @@ -446,7 +446,7 @@ bool npc_load_script_none(ast::script::ScriptBody& body, ast::npc::ScriptNone& s nd->bl_id = npc_get_new_npc_id(); nd->dir = DIR::S; nd->flag = 0; - nd->npc_class = NEGATIVE_SPECIES; + nd->npc_class = INVISIBLE_CLASS; nd->speed = 200_ms; nd->scr.script = std::move(script); nd->option = Opt0::ZERO; @@ -514,115 +514,6 @@ bool npc_load_script_none(ast::script::ScriptBody& body, ast::npc::ScriptNone& s } static -bool npc_load_script_map_none(ast::script::ScriptBody& body, ast::npc::ScriptMapNone& script_map_none) -{ - MapName mapname = script_map_none.m.data; - int x = script_map_none.x.data, y = script_map_none.y.data; - DIR dir = script_map_none.d.data; - P<map_local> m = TRY_UNWRAP(map_mapname2mapid(mapname), - { - script_map_none.m.span.error("No such map"_s); - return false; - }); - - std::unique_ptr<const ScriptBuffer> script = compile_script(STRPRINTF("script npc \"%s\""_fmt, script_map_none.name.data), body, false); - if (script == nullptr) - return false; - - dumb_ptr<npc_data_script> nd; - nd.new_(); - nd->scr.event_needs_map = false; - - nd->name = script_map_none.name.data; - - nd->bl_prev = nd->bl_next = nullptr; - nd->bl_m = m; - nd->bl_x = x; - nd->bl_y = y; - nd->bl_id = npc_get_new_npc_id(); - nd->dir = dir; - nd->flag = 0; - nd->npc_class = NEGATIVE_SPECIES; - nd->speed = 200_ms; - nd->scr.script = std::move(script); - nd->option = Opt0::ZERO; - nd->opt1 = Opt1::ZERO; - nd->opt2 = Opt2::ZERO; - nd->opt3 = Opt3::ZERO; - - npc_script++; - nd->bl_type = BL::NPC; - nd->npc_subtype = NpcSubtype::SCRIPT; - - nd->n = map_addnpc(m, nd); - map_addblock(nd); - - { - struct event_data ev {}; - ev.nd = nd; - ev.pos = 0; - NpcEvent npcev; - npcev.npc = nd->name; - npcev.label = ScriptLabel(); - ev_db.insert(npcev, ev); - } - - register_npc_name(nd); - - for (auto& pair : scriptlabel_db) - npc_convertlabel_db(pair.first, pair.second, nd); - - for (npc_label_list& el : nd->scr.label_listv) - { - ScriptLabel lname = el.name; - int pos = el.pos; - - if (lname.startswith("On"_s)) - { - struct event_data ev {}; - ev.nd = nd; - ev.pos = pos; - NpcEvent buf; - buf.npc = nd->name; - buf.label = lname; - ev_db.insert(buf, ev); - } - } - - for (npc_label_list& el : nd->scr.label_listv) - { - int t_ = 0; - ScriptLabel lname = el.name; - int pos = el.pos; - if (lname.startswith("OnTimer"_s) && extract(lname.xslice_t(7), &t_) && t_ > 0) - { - interval_t t = static_cast<interval_t>(t_); - - npc_timerevent_list tel {}; - tel.timer = t; - tel.pos = pos; - - auto it = std::lower_bound(nd->scr.timer_eventv.begin(), nd->scr.timer_eventv.end(), tel, - [](const npc_timerevent_list& l, const npc_timerevent_list& r) - { - return l.timer < r.timer; - } - ); - assert (it == nd->scr.timer_eventv.end() || it->timer != tel.timer); - - nd->scr.timer_eventv.insert(it, std::move(tel)); - } - } - // The counter starts stopped with 0 ticks, which is the first event, - // unless there is none, in which case begin == end. - nd->scr.timer = interval_t::zero(); - nd->scr.next_event = nd->scr.timer_eventv.begin(); - // nd->scr.timerid = nullptr; - - return true; -} - -static bool npc_load_script_map(ast::script::ScriptBody& body, ast::npc::ScriptMap& script_map) { MapName mapname = script_map.m.data; @@ -761,17 +652,6 @@ bool npc_load_script_any(ast::npc::Script *script) { return npc_load_script_none(script->body, script_none); } - MATCH_CASE (ast::npc::ScriptMapNone&, script_map_none) - { - auto& mapname = script_map_none.m; - Option<P<map_local>> m = map_mapname2mapid(mapname.data); - if (m.is_none()) - { - mapname.span.error(STRPRINTF("Map not found: %s"_fmt, mapname.data)); - return false; - } - return npc_load_script_map_none(script->body, script_map_none); - } MATCH_CASE (ast::npc::ScriptMap&, script_map) { auto& mapname = script_map.m; diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 56c33cc..4296432 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -583,7 +583,7 @@ int npc_checknear(dumb_ptr<map_session_data> sd, BlockId id) if (nd->bl_type != BL::NPC) return 1; - if (nd->npc_class == NEGATIVE_SPECIES) + if (nd->npc_class == INVISIBLE_CLASS) return 0; // エリア判定 diff --git a/src/map/pc.cpp b/src/map/pc.cpp index e8e526a..6fa35b0 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -2289,35 +2289,6 @@ int pc_setpos(dumb_ptr<map_session_data> sd, } /*========================================== - * PCのランダムワープ - *------------------------------------------ - */ -int pc_randomwarp(dumb_ptr<map_session_data> sd, BeingRemoveWhy type) -{ - int x, y, i = 0; - - nullpo_retz(sd); - - P<map_local> m = sd->bl_m; - - if (sd->bl_m->flag.get(MapFlag::NOTELEPORT)) // テレポート禁止 - return 0; - - do - { - x = random_::in(1, m->xs - 2); - y = random_::in(1, m->ys - 2); - } - while (bool(read_gatp(m, x, y) & MapCell::UNWALKABLE) - && (i++) < 1000); - - if (i < 1000) - pc_setpos(sd, m->name_, x, y, type); - - return 0; -} - -/*========================================== * *------------------------------------------ */ diff --git a/src/map/pc.hpp b/src/map/pc.hpp index 6c0803f..d100938 100644 --- a/src/map/pc.hpp +++ b/src/map/pc.hpp @@ -92,7 +92,6 @@ int pc_walktoxy(dumb_ptr<map_session_data>, int, int); int pc_stop_walking(dumb_ptr<map_session_data>, int); int pc_setpos(dumb_ptr<map_session_data>, MapName, int, int, BeingRemoveWhy); void pc_setsavepoint(dumb_ptr<map_session_data>, MapName, int, int); -int pc_randomwarp(dumb_ptr<map_session_data> sd, BeingRemoveWhy type); ADDITEM pc_checkadditem(dumb_ptr<map_session_data>, ItemNameId, int); int pc_inventoryblank(dumb_ptr<map_session_data>); diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp index c3c6aa1..7092dbc 100644 --- a/src/map/script-call.cpp +++ b/src/map/script-call.cpp @@ -28,6 +28,8 @@ #include "../mmo/cxxstdio_enums.hpp" +#include "../high/core.hpp" + #include "battle.hpp" #include "battle_conf.hpp" #include "globals.hpp" @@ -584,6 +586,7 @@ void run_func(ScriptState *st) if (battle_config.error_log) PRINTF("function not found\n"_fmt); st->state = ScriptEndState::END; + runflag = 0; return; } } @@ -596,6 +599,7 @@ void run_func(ScriptState *st) { PRINTF("run_func: not function and command! \n"_fmt); st->state = ScriptEndState::END; + runflag = 0; return; } size_t func = st->stack->stack_datav[st->start].get_if<ScriptDataFuncRef>()->numi; @@ -665,6 +669,7 @@ void run_func(ScriptState *st) { PRINTF("script:run_func (return) return without callfunc or callsub!\n"_fmt); st->state = ScriptEndState::END; + runflag = 0; return; } assert (olddefsp == st->defsp); // pretty sure it hasn't changed yet @@ -761,6 +766,7 @@ void run_script_main(ScriptState *st, Borrowed<const ScriptBuffer> rootscript) { PRINTF("run_script: infinity loop !\n"_fmt); st->state = ScriptEndState::END; + runflag = 0; } } break; @@ -804,12 +810,14 @@ void run_script_main(ScriptState *st, Borrowed<const ScriptBuffer> rootscript) PRINTF("unknown command : %d @ %zu\n"_fmt, c, st->scriptp.pos); st->state = ScriptEndState::END; + runflag = 0; break; } if (st->freeloop != 1 && cmdcount > 0 && (--cmdcount) <= 0) { PRINTF("run_script: infinity loop !\n"_fmt); st->state = ScriptEndState::END; + runflag = 0; } } switch (st->state) 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'), diff --git a/src/map/script-parse.cpp b/src/map/script-parse.cpp index fb306c5..2c7305b 100644 --- a/src/map/script-parse.cpp +++ b/src/map/script-parse.cpp @@ -451,7 +451,7 @@ ZString::iterator ScriptBuffer::parse_subexpr(ZString::iterator p, int limit) ZString::iterator tmpp = skip_space(p + 1); if (*tmpp == ';' || *tmpp == ',') { - --script_errors; disp_error_message("deprecated: implicit 'next statement' label"_s, p); + disp_error_message("error: implicit 'next statement' label"_s, p); add_scriptl(borrow(LABEL_NEXTLINE_)); p++; return p; @@ -752,7 +752,7 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) { if (can_step) { - --script_errors; disp_error_message("deprecated: implicit fallthrough"_s, p); + disp_error_message("error: implicit fallthrough"_s, p); } can_step = true; @@ -777,7 +777,7 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) if (!can_step) { - --script_errors; disp_error_message("deprecated: unreachable statement"_s, p); + disp_error_message("error: unreachable statement"_s, p); } // 他は全部一緒くた p = parse_line(p, &can_step); @@ -792,7 +792,7 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) if (can_step && !implicit_end) { - --script_errors; disp_error_message("deprecated: implicit end"_s, p); + disp_error_message("error: implicit end"_s, p); } add_scriptc(ByteCode::NOP); @@ -824,14 +824,14 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) if (key.startswith("On"_s)) continue; if (!(key.startswith("L_"_s) || key.startswith("S_"_s))) - PRINTF("Warning: ugly label: %s\n"_fmt, key); + disp_error_message(STRPRINTF("error: ugly label: %s\n"_fmt, key),p); else if (!probable_labels.count(key)) - PRINTF("Warning: unused label: %s\n"_fmt, key); + disp_error_message(STRPRINTF("error: unused label: %s\n"_fmt, key),p); } for (ScriptLabel used : probable_labels) { if (scriptlabel_db.search(used).is_none()) - PRINTF("Warning: no such label: %s\n"_fmt, used); + disp_error_message(STRPRINTF("error: no such label: %s\n"_fmt, used),p); } probable_labels.clear(); |