From 7c5a4495acf7ce33393a937e097e8d08c2a0cc81 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 9 May 2020 07:58:14 +0300 Subject: Use correct struct in delayed removing mobs --- src/map/clif.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index 477894805..46391035a 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -943,12 +943,11 @@ static int clif_clearunit_delayed_sub(int tid, int64 tick, int id, intptr_t data static void clif_clearunit_delayed(struct block_list *bl, enum clr_type type, int64 tick) { - struct block_list *tbl; - nullpo_retv(bl); - tbl = ers_alloc(clif->delay_clearunit_ers, struct block_list); - memcpy (tbl, bl, sizeof (struct block_list)); - timer->add(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl); + Assert_retv(bl->type == BL_MOB); + struct mob_data *md = ers_alloc(clif->delay_clearunit_ers, struct mob_data); + memcpy (md, bl, sizeof (struct mob_data)); + timer->add(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)md); } /// Gets weapon view info from sd's inventory_data and points (*rhand,*lhand) @@ -24192,7 +24191,7 @@ static int do_init_clif(bool minimal) timer->add_func_list(clif->clearunit_delayed_sub, "clif_clearunit_delayed_sub"); timer->add_func_list(clif->delayquit, "clif_delayquit"); - clif->delay_clearunit_ers = ers_new(sizeof(struct block_list),"clif.c::delay_clearunit_ers",ERS_OPT_CLEAR); + clif->delay_clearunit_ers = ers_new(sizeof(struct mob_data), "clif.c::delay_clearunit_ers", ERS_OPT_CLEAR); clif->delayed_damage_ers = ers_new(sizeof(struct cdelayed_damage),"clif.c::delayed_damage_ers",ERS_OPT_CLEAR); #if PACKETVER_MAIN_NUM >= 20190403 || PACKETVER_RE_NUM >= 20190320 -- cgit v1.2.3-60-g2f50 From bb21005b13f1a8741e60a65f973b3a115bea1ff1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 11 May 2020 08:03:15 +0300 Subject: Fix possible mail name in packet clif_rodex_checkname_result --- src/map/clif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index 46391035a..12e58f8ec 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -22298,7 +22298,7 @@ static void clif_rodex_checkname_result(struct map_session_data *sd, int char_id sPacket->Class = class_; sPacket->BaseLevel = base_level; #if PACKETVER >= 20160316 - strncpy(sPacket->Name, name, NAME_LENGTH); + safestrncpy(sPacket->Name, name, NAME_LENGTH); #endif WFIFOSET(fd, sizeof(*sPacket)); #endif -- cgit v1.2.3-60-g2f50 From 26f926c8b33bb7b501e2a291364b8c07a9a50ae6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 13 May 2020 01:24:35 +0300 Subject: Add missing vd checks into clif.c --- src/map/clif.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index 12e58f8ec..836259483 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1030,6 +1030,7 @@ static void clif_set_unit_idle2(struct block_list *bl, struct map_session_data * int g_id = status->get_guild_id(bl); nullpo_retv(bl); + nullpo_retv(vd); sd = BL_CAST(BL_PC, bl); p.PacketType = idle_unit2Type; @@ -1086,6 +1087,7 @@ static void clif_set_unit_idle(struct block_list *bl, struct map_session_data *t int g_id = status->get_guild_id(bl); nullpo_retv(bl); + nullpo_retv(vd); #if PACKETVER < 20091103 if (!pc->db_checkid(vd->class)) { @@ -1196,6 +1198,7 @@ static void clif_spawn_unit2(struct block_list *bl, enum send_target target) int g_id = status->get_guild_id(bl); nullpo_retv(bl); + nullpo_retv(vd); sd = BL_CAST(BL_PC, bl); p.PacketType = spawn_unit2Type; @@ -1243,6 +1246,7 @@ static void clif_spawn_unit(struct block_list *bl, enum send_target target) int g_id = status->get_guild_id(bl); nullpo_retv(bl); + nullpo_retv(vd); #if PACKETVER < 20091103 if (!pc->db_checkid(vd->class)) { @@ -1356,6 +1360,7 @@ static void clif_set_unit_walking(struct block_list *bl, struct map_session_data nullpo_retv(bl); nullpo_retv(ud); + nullpo_retv(vd); sd = BL_CAST(BL_PC, bl); -- cgit v1.2.3-60-g2f50 From 495f4b84f775030e189209704387ee97adb20ee0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 18 May 2020 02:09:22 +0300 Subject: Dont call clif->clearunit_area if mob died on missing map --- src/map/clif.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index 836259483..12242e44c 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -936,8 +936,15 @@ static void clif_clearunit_area(struct block_list *bl, enum clr_type type) static int clif_clearunit_delayed_sub(int tid, int64 tick, int id, intptr_t data) { struct block_list *bl = (struct block_list *)data; + nullpo_ret(bl); + Assert_ret(bl->m >= 0 && bl->m < map->count); + if (map->list[bl->m].block == NULL) { + // avoid error report for missing/removed map + ers_free(clif->delay_clearunit_ers, bl); + return 0; + } clif->clearunit_area(bl, (enum clr_type) id); - ers_free(clif->delay_clearunit_ers,bl); + ers_free(clif->delay_clearunit_ers, bl); return 0; } -- cgit v1.2.3-60-g2f50 From b648e49e821760502b5b5ae826b194c98b17d529 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 19 May 2020 12:25:19 +0300 Subject: fix motd on load/unload npc. --- src/map/atcommand.c | 3 +++ src/map/clif.c | 1 + src/map/npc.c | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/map/clif.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 54cc9e2c9..76448b237 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -4499,6 +4499,7 @@ ACMD(loadnpc) // add to list of script sources and run it npc->addsrcfile(message); npc->parsesrcfile(message,true); + npc->motd = npc->name2id("HerculesMOTD"); npc->read_event_script(); clif->message(fd, msg_fd(fd,262)); @@ -4533,6 +4534,7 @@ ACMD(unloadnpc) npc->unload_duplicates(nd, (flag != 0)); npc->unload(nd, true, (flag != 0)); + npc->motd = npc->name2id("HerculesMOTD"); npc->read_event_script(); clif->message(fd, msg_fd(fd, 112)); /// Npc Disabled. return true; @@ -4588,6 +4590,7 @@ ACMD(reloadnpc) clif->message(fd, msg_fd(fd, 1386)); /// File unloaded. Be aware that... npc->addsrcfile(file_path); npc->parsesrcfile(file_path, true); + npc->motd = npc->name2id("HerculesMOTD"); npc->read_event_script(); clif->message(fd, msg_fd(fd, 262)); /// Script loaded. return true; diff --git a/src/map/clif.c b/src/map/clif.c index 12242e44c..8edb47e61 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -15485,6 +15485,7 @@ static void clif_parse_GMKick(int fd, struct map_session_data *sd) } npc->unload_duplicates(nd, true); npc->unload(nd, true, true); + npc->motd = npc->name2id("HerculesMOTD"); npc->read_event_script(); } break; diff --git a/src/map/npc.c b/src/map/npc.c index 2f03623e4..30aeb616a 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -5728,8 +5728,10 @@ static bool npc_unloadfile(const char *filepath, bool unload_mobs) dbi_destroy(iter); - if (found) /// Refresh event cache. + if (found) { /// Refresh event cache. + npc->motd = npc->name2id("HerculesMOTD"); npc->read_event_script(); + } return found; } -- cgit v1.2.3-60-g2f50