diff --git a/src/map/clif.c b/src/map/clif.c index cb331bcf75..3e7b91c90d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1516,12 +1516,11 @@ int clif_homskillinfoblock(struct map_session_data *sd) nullpo_ret(sd); - WFIFOHEAD(fd, 4+37*MAX_HOMUNSKILL); - hd = sd->hd; if ( !hd ) return 0 ; + WFIFOHEAD(fd, 4+37*MAX_HOMUNSKILL); WFIFOW(fd,0)=0x235; for ( i = 0; i < MAX_HOMUNSKILL; i++){ int id = hd->homunculus.hskill[i].id; @@ -15604,6 +15603,20 @@ void clif_parse_PartyTick(int fd, struct map_session_data* sd) /// Questlog System [Kevin] [Inkfish] /// +/** + * Safe check to init packet len & quest num for player. + * @param def_len + * @param info_len Length of each quest info. + * @param avail_quests Avail quests that player has. + * @param limit_out Limit for quest num, to make sure the quest num is still in allowed value. + * @param len_out Packet length as initial set => def_len + limit_out * info_len. + **/ +static void clif_quest_len(int def_len, int info_len, int avail_quests, int *limit_out, int *len_out) { + (*limit_out) = (0xFFFF - def_len) / info_len; + (*limit_out) = (avail_quests > (*limit_out)) ? (*limit_out) : avail_quests; + (*len_out) = ((*limit_out) * info_len) + def_len; +} + /// Sends list of all quest states (ZC_ALL_QUEST_LIST). /// 02b1 .W .L { .L .B }*num /// 097a .W .L { .L .B .L