diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 5 | ||||
-rw-r--r-- | src/map/clan.c | 3 | ||||
-rw-r--r-- | src/map/clif.c | 271 | ||||
-rw-r--r-- | src/map/clif.h | 2 | ||||
-rw-r--r-- | src/map/intif.c | 14 | ||||
-rw-r--r-- | src/map/packets.h | 23 | ||||
-rw-r--r-- | src/map/packets_keys_main.h | 23 | ||||
-rw-r--r-- | src/map/packets_keys_zero.h | 17 | ||||
-rw-r--r-- | src/map/packets_shuffle_main.h | 107 | ||||
-rw-r--r-- | src/map/packets_shuffle_zero.h | 101 | ||||
-rw-r--r-- | src/map/rodex.c | 32 | ||||
-rw-r--r-- | src/map/unit.c | 16 |
12 files changed, 513 insertions, 101 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index e529f8839..9deed0098 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -10055,6 +10055,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa { char params[100], command[100]; char output[CHAT_SIZE_MAX]; + bool logCommand; // Reconstructed message char atcmd_msg[CHAT_SIZE_MAX]; @@ -10198,6 +10199,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa } } + logCommand = info->log; //Attempt to use the command if ((info->func(fd, ssd, command, params,info) != true)) { #ifdef AUTOTRADE_PERSISTENCY @@ -10209,7 +10211,8 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa return true; } - if (info->log) /* log only if this command should be logged [Ind/Hercules] */ + // info->log cant be used here, because info can be freed [4144] + if (logCommand) /* log only if this command should be logged [Ind/Hercules] */ logs->atcommand(sd, is_atcommand ? atcmd_msg : message); return true; diff --git a/src/map/clan.c b/src/map/clan.c index 865f5a4cd..7aa9be5d4 100644 --- a/src/map/clan.c +++ b/src/map/clan.c @@ -997,10 +997,11 @@ void clan_reload(void) */ void do_init_clan(bool minimal) { + clan->db = idb_alloc(DB_OPT_RELEASE_DATA); + if (minimal) { return; } - clan->db = idb_alloc(DB_OPT_RELEASE_DATA); clan->config_read(false); timer->add_func_list(clan->inactivity_kick, "clan_inactivity_kick"); } diff --git a/src/map/clif.c b/src/map/clif.c index 64e44dfff..cf5edd0e0 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6088,14 +6088,29 @@ void clif_wis_end(int fd, int flag) { /// Returns character name requested by char_id (ZC_ACK_REQNAME_BYGID). /// 0194 <char id>.L <name>.24B +/// 0af7 <flag>.W <char id>.L <name>.24B void clif_solved_charname(int fd, int charid, const char* name) { nullpo_retv(name); - WFIFOHEAD(fd,packet_len(0x194)); - WFIFOW(fd,0)=0x194; - WFIFOL(fd,2)=charid; - safestrncpy(WFIFOP(fd,6), name, NAME_LENGTH); - WFIFOSET(fd,packet_len(0x194)); +#if !defined(PACKETVER_ZERO) && (PACKETVER >= 20180307 || (defined(PACKETVER_RE) && PACKETVER >= 20180221)) + WFIFOHEAD(fd, packet_len(0x0af7)); + WFIFOW(fd, 0) = 0xaf7; + if (*name == 0) { + WFIFOW(fd, 2) = 2; + memset(WFIFOP(fd, 8), 0, NAME_LENGTH); + } else { + WFIFOW(fd, 2) = 3; + safestrncpy(WFIFOP(fd, 8), name, NAME_LENGTH); + } + WFIFOL(fd, 4) = charid; + WFIFOSET(fd, packet_len(0x0af7)); +#else + WFIFOHEAD(fd, packet_len(0x194)); + WFIFOW(fd, 0) = 0x194; + WFIFOL(fd, 2) = charid; + safestrncpy(WFIFOP(fd, 6), name, NAME_LENGTH); + WFIFOSET(fd, packet_len(0x194)); +#endif } /// Presents a list of items that can be carded/composed (ZC_ITEMCOMPOSITION_LIST). @@ -10999,13 +11014,21 @@ void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd) __attribute_ void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd) { int len = RFIFOW(fd,2)-15; - int limit = RFIFOW(fd,4); - bool pub = (RFIFOB(fd,6) != 0); - const char *password = RFIFOP(fd,7); //not zero-terminated - const char *title = RFIFOP(fd,15); // not zero-terminated + int limit; + bool pub; + const char *password; //not zero-terminated + const char *title; // not zero-terminated char s_password[CHATROOM_PASS_SIZE]; char s_title[CHATROOM_TITLE_SIZE]; + if (len < 1) + return; + + limit = RFIFOW(fd, 4); + pub = (RFIFOB(fd, 6) != 0); + password = RFIFOP(fd, 7); //not zero-terminated + title = RFIFOP(fd, 15); // not zero-terminated + if (pc_ismuted(&sd->sc, MANNER_NOROOM)) return; if(battle_config.basic_skill_check && !pc->check_basicskill(sd, 4)) { @@ -11021,9 +11044,6 @@ void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd) return; } - if( len <= 0 ) - return; // invalid input - safestrncpy(s_password, password, CHATROOM_PASS_SIZE); safestrncpy(s_title, title, min(len+1,CHATROOM_TITLE_SIZE)); //NOTE: assumes that safestrncpy will not access the len+1'th byte @@ -11050,15 +11070,20 @@ void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data* sd) __attr void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data* sd) { int len = RFIFOW(fd,2)-15; - int limit = RFIFOW(fd,4); - bool pub = (RFIFOB(fd,6) != 0); - const char *password = RFIFOP(fd,7); // not zero-terminated - const char *title = RFIFOP(fd,15); // not zero-terminated + int limit; + bool pub; + const char *password; // not zero-terminated + const char *title; // not zero-terminated char s_password[CHATROOM_PASS_SIZE]; char s_title[CHATROOM_TITLE_SIZE]; - if( len <= 0 ) - return; // invalid input + if (len < 1) + return; + + limit = RFIFOW(fd, 4); + pub = (RFIFOB(fd, 6) != 0); + password = RFIFOP(fd, 7); // not zero-terminated + title = RFIFOP(fd, 15); // not zero-terminated safestrncpy(s_password, password, CHATROOM_PASS_SIZE); safestrncpy(s_title, title, min(len+1,CHATROOM_TITLE_SIZE)); //NOTE: assumes that safestrncpy will not access the len+1'th byte @@ -11074,7 +11099,7 @@ void clif_parse_ChangeChatOwner(int fd, struct map_session_data* sd) __attribute /// 1 = normal void clif_parse_ChangeChatOwner(int fd, struct map_session_data* sd) { - chat->change_owner(sd, RFIFOP(fd,6)); + chat->change_owner(sd, RFIFOP(fd,6)); // non null terminated } void clif_parse_KickFromChat(int fd,struct map_session_data *sd) __attribute__((nonnull (2))); @@ -11082,7 +11107,7 @@ void clif_parse_KickFromChat(int fd,struct map_session_data *sd) __attribute__(( /// 00e2 <name>.24B void clif_parse_KickFromChat(int fd,struct map_session_data *sd) { - chat->kick(sd, RFIFOP(fd,2)); + chat->kick(sd, RFIFOP(fd,2)); // non null terminated } void clif_parse_ChatLeave(int fd, struct map_session_data* sd) __attribute__((nonnull (2))); @@ -11841,17 +11866,21 @@ void clif_parse_NpcStringInput(int fd, struct map_session_data* sd) __attribute_ /// 01d5 <packet len>.W <npc id>.L <string>.?B void clif_parse_NpcStringInput(int fd, struct map_session_data* sd) { + int len = RFIFOW(fd, 2); // [4144] can't confirm exact client version. At least >= correct for 20150513 #if PACKETVER >= 20151029 - int message_len = RFIFOW(fd, 2) - 7; + int message_len = len - 7; #else - int message_len = RFIFOW(fd, 2) - 8; + int message_len = len - 8; #endif - int npcid = RFIFOL(fd,4); - const char *message = RFIFOP(fd,8); + int npcid; + const char *message; - if( message_len <= 0 ) - return; // invalid input + if (len < 9) + return; + + npcid = RFIFOL(fd, 4); + message = RFIFOP(fd, 8); safestrncpy(sd->npc_str, message, min(message_len,CHATBOX_SIZE)); npc->scriptcont(sd, npcid, false); @@ -13005,9 +13034,15 @@ void clif_parse_PurchaseReq(int fd, struct map_session_data* sd) __attribute__(( /// 0134 <packet len>.W <account id>.L { <amount>.W <index>.W }* void clif_parse_PurchaseReq(int fd, struct map_session_data* sd) { - int len = (int)RFIFOW(fd,2) - 8; - int id = RFIFOL(fd,4); - const uint8 *data = RFIFOP(fd,8); + int len = (int)RFIFOW(fd, 2) - 8; + int id; + const uint8 *data; + + if (len < 1) + return; + + id = RFIFOL(fd, 4); + data = RFIFOP(fd, 8); vending->purchase(sd, id, sd->vended_id, data, len/4); @@ -13020,10 +13055,16 @@ void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd) __attribute__( /// 0801 <packet len>.W <account id>.L <unique id>.L { <amount>.W <index>.W }* void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd) { - int len = (int)RFIFOW(fd,2) - 12; - int aid = RFIFOL(fd,4); - int uid = RFIFOL(fd,8); - const uint8 *data = RFIFOP(fd,12); + int len = (int)RFIFOW(fd, 2) - 12; + int aid; + int uid; + const uint8 *data; + + if (len < 1) + return; + aid = RFIFOL(fd, 4); + uid = RFIFOL(fd, 8); + data = RFIFOP(fd, 12); vending->purchase(sd, aid, uid, data, len/4); @@ -13040,9 +13081,16 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd) __attribute__(( /// 1 = open void clif_parse_OpenVending(int fd, struct map_session_data* sd) { short len = (short)RFIFOW(fd,2) - 85; - const char *message = RFIFOP(fd,4); - bool flag = (RFIFOB(fd,84) != 0) ? true : false; - const uint8 *data = RFIFOP(fd,85); + const char *message; + bool flag; + const uint8 *data; + + if (len < 1) + return; + + message = RFIFOP(fd,4); + flag = (RFIFOB(fd,84) != 0) ? true : false; + data = RFIFOP(fd,85); if( !flag ) sd->state.prevend = sd->state.workinprogress = 0; @@ -13135,12 +13183,14 @@ void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) __a void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) { int i; + int count = (RFIFOW(fd, 2) - 4) / 40; - if(!sd->state.gmaster_flag) + if (!sd->state.gmaster_flag) return; - for(i = 4; i < RFIFOW(fd,2); i += 40 ){ - guild->change_position(sd->status.guild_id, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), RFIFOP(fd,i+16)); + for (i = 0; i < count; i ++ ) { + int idx = i * 40 + 4; + guild->change_position(sd->status.guild_id, RFIFOL(fd, idx), RFIFOL(fd, idx + 4), RFIFOL(fd, idx + 12), RFIFOP(fd, idx + 16)); } } @@ -13151,6 +13201,7 @@ void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd) { int i; int len = RFIFOW(fd, 2); + int count = (len - 4) / 12; if(!sd->state.gmaster_flag) return; @@ -13161,10 +13212,11 @@ void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd) return; } - for(i=4;i<RFIFOW(fd,2);i+=12){ - int position = RFIFOL(fd, i + 8); - if (position > 0) { - guild->change_memberposition(sd->status.guild_id, RFIFOL(fd, i), RFIFOL(fd, i + 4), position); + for (i = 0; i < count; i++) { + int idx = i * 12 + 4; + int position = RFIFOL(fd, idx + 8); + if (position > 0 && position < MAX_GUILDPOSITION) { + guild->change_memberposition(sd->status.guild_id, RFIFOL(fd, idx), RFIFOL(fd, idx + 4), position); } } } @@ -13548,12 +13600,15 @@ void clif_parse_GuildBreak(int fd, struct map_session_data *sd) __attribute__((n /// key: /// now guild name; might have been (intended) email, since the /// field name and size is same as the one in CH_DELETE_CHAR. -void clif_parse_GuildBreak(int fd, struct map_session_data *sd) { +void clif_parse_GuildBreak(int fd, struct map_session_data *sd) +{ + char key[40]; if( map->list[sd->bl.m].flag.guildlock ) { clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. return; } - guild->dobreak(sd, RFIFOP(fd,2)); + safestrncpy(key, RFIFOP(fd, 2), 40); + guild->dobreak(sd, key); } /// Pet @@ -14142,6 +14197,7 @@ void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd) /// Toggles a single friend online/offline [Skotlex] (ZC_FRIENDS_STATE). /// 0206 <account id>.L <char id>.L <state>.B +/// 0206 <account id>.L <char id>.L <state>.B <name>.24B /// state: /// 0 = online /// 1 = offline @@ -14161,7 +14217,13 @@ void clif_friendslist_toggle(struct map_session_data *sd,int account_id, int cha WFIFOW(fd, 0) = 0x206; WFIFOL(fd, 2) = sd->status.friends[i].account_id; WFIFOL(fd, 6) = sd->status.friends[i].char_id; - WFIFOB(fd,10) = !online; //Yeah, a 1 here means "logged off", go figure... + WFIFOB(fd, 10) = !online; //Yeah, a 1 here means "logged off", go figure... +#ifndef PACKETVER_ZERO +#if PACKETVER >= 20180307 || (defined(PACKETVER_RE) && PACKETVER >= 20180221) + memcpy(WFIFOP(fd, 11), sd->status.friends[i].name, NAME_LENGTH); +#endif +#endif // PACKETVER_ZERO + WFIFOSET(fd, packet_len(0x206)); } @@ -14178,22 +14240,30 @@ int clif_friendslist_toggle_sub(struct map_session_data *sd,va_list ap) /// Sends the whole friends list (ZC_FRIENDS_LIST). /// 0201 <packet len>.W { <account id>.L <char id>.L <name>.24B }* +/// 0201 <packet len>.W { <account id>.L <char id>.L }* void clif_friendslist_send(struct map_session_data *sd) { int i = 0, n, fd = sd->fd; +#if !defined(PACKETVER_ZERO) && (PACKETVER >= 20180307 || (defined(PACKETVER_RE) && PACKETVER >= 20180221)) + const int offset = 8; +#else + const int offset = 32; +#endif nullpo_retv(sd); // Send friends list - WFIFOHEAD(fd, MAX_FRIENDS * 32 + 4); + WFIFOHEAD(fd, MAX_FRIENDS * offset + 4); WFIFOW(fd, 0) = 0x201; for(i = 0; i < MAX_FRIENDS && sd->status.friends[i].char_id; i++) { - WFIFOL(fd, 4 + 32 * i + 0) = sd->status.friends[i].account_id; - WFIFOL(fd, 4 + 32 * i + 4) = sd->status.friends[i].char_id; - memcpy(WFIFOP(fd, 4 + 32 * i + 8), &sd->status.friends[i].name, NAME_LENGTH); + WFIFOL(fd, 4 + offset * i + 0) = sd->status.friends[i].account_id; + WFIFOL(fd, 4 + offset * i + 4) = sd->status.friends[i].char_id; +#if !(!defined(PACKETVER_ZERO) && (PACKETVER >= 20180307 || (defined(PACKETVER_RE) && PACKETVER >= 20180221))) + memcpy(WFIFOP(fd, 4 + offset * i + 8), &sd->status.friends[i].name, NAME_LENGTH); +#endif } if (i) { - WFIFOW(fd,2) = 4 + 32 * i; + WFIFOW(fd,2) = 4 + offset * i; WFIFOSET(fd, WFIFOW(fd,2)); } @@ -15302,17 +15372,19 @@ void clif_parse_Mail_winopen(int fd, struct map_session_data *sd) void clif_parse_Mail_send(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); /// Request to send mail (CZ_MAIL_SEND). /// 0248 <packet len>.W <recipient>.24B <title>.40B <body len>.B <body>.?B + void clif_parse_Mail_send(int fd, struct map_session_data *sd) { struct mail_message msg; int body_len; + int len = RFIFOW(fd, 2); if( !chrif->isconnected() ) return; if( sd->state.trading ) return; - if( RFIFOW(fd,2) < 69 ) { + if (len < 69) { ShowWarning("Invalid Msg Len from account %d.\n", sd->status.account_id); return; } @@ -15328,6 +15400,11 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) if (body_len > MAIL_BODY_LENGTH) body_len = MAIL_BODY_LENGTH; + if (body_len + 69 > len) { + ShowWarning("Invalid Msg Len from account %d.\n", sd->status.account_id); + return; + } + memset(&msg, 0, sizeof(msg)); if (!mail->setattachment(sd, &msg)) { // Invalid Append condition clif->mail_send(sd->fd, true); // fail @@ -15833,15 +15910,24 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) fail = npc->cashshop_buy(sd, nameid, amount, points); #else int len = RFIFOW(fd,2); - int points = RFIFOL(fd,4); - int count = RFIFOW(fd,8); + int points; + int count; struct itemlist item_list = { 0 }; int i; - if( len < 10 || len != 10 + count * 4) { + if (len < 10) { + ShowWarning("Player %d sent incorrect cash shop buy packet (len %d)!\n", sd->status.char_id, len); + return; + } + + points = RFIFOL(fd, 4); + count = RFIFOW(fd, 8); + + if (len != 10 + count * 4) { ShowWarning("Player %d sent incorrect cash shop buy packet (len %d:%d)!\n", sd->status.char_id, len, 10 + count * 4); return; } + VECTOR_INIT(item_list); VECTOR_ENSURE(item_list, count, 1); for (i = 0; i < count; i++) { @@ -16879,7 +16965,7 @@ void clif_parse_ItemListWindowSelected(int fd, struct map_session_data *sd) __at /// S 07e4 <length>.w <option>.l <val>.l {<index>.w <amount>.w).4b* void clif_parse_ItemListWindowSelected(int fd, struct map_session_data *sd) { - int n = ((int)RFIFOW(fd,2) - 12) / 4; + int n = ((int)RFIFOW(fd, 2) - 12) / 4; int type = RFIFOL(fd,4); int flag = RFIFOL(fd,8); // Button clicked: 0 = Cancel, 1 = OK struct itemlist item_list = { 0 }; @@ -17010,7 +17096,7 @@ void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data* sd) { char storename[MESSAGE_SIZE]; unsigned char result; int zenylimit; - unsigned int count, packet_len; + int count, packet_len; struct s_packet_db* info = &packet_db[RFIFOW(fd,0)]; packet_len = RFIFOW(fd,info->pos[0]); @@ -17018,7 +17104,7 @@ void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data* sd) { // TODO: Make this check global for all variable length packets. if( packet_len < 89 ) {// minimum packet length - ShowError("clif_parse_ReqOpenBuyingStore: Malformed packet (expected length=%u, length=%u, account_id=%d).\n", 89U, packet_len, sd->bl.id); + ShowError("clif_parse_ReqOpenBuyingStore: Malformed packet (expected length=%u, length=%d, account_id=%d).\n", 89U, packet_len, sd->bl.id); return; } @@ -17030,9 +17116,12 @@ void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data* sd) { // so that buyingstore_create knows, how many elements it has access to packet_len-= info->pos[4]; + if (packet_len < 0) + return; + if( packet_len%blocksize ) { - ShowError("clif_parse_ReqOpenBuyingStore: Unexpected item list size %u (account_id=%d, block size=%u)\n", packet_len, sd->bl.id, blocksize); + ShowError("clif_parse_ReqOpenBuyingStore: Unexpected item list size %d (account_id=%d, block size=%u)\n", packet_len, sd->bl.id, blocksize); return; } count = packet_len/blocksize; @@ -17201,14 +17290,15 @@ void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data* sd) { const unsigned int blocksize = 6; const uint8 *itemlist; int account_id; - unsigned int count, packet_len, buyer_id; + unsigned int buyer_id; + int count, packet_len; struct s_packet_db* info = &packet_db[RFIFOW(fd,0)]; packet_len = RFIFOW(fd,info->pos[0]); if( packet_len < 12 ) {// minimum packet length - ShowError("clif_parse_ReqTradeBuyingStore: Malformed packet (expected length=%u, length=%u, account_id=%d).\n", 12U, packet_len, sd->bl.id); + ShowError("clif_parse_ReqTradeBuyingStore: Malformed packet (expected length=%u, length=%d, account_id=%d).\n", 12U, packet_len, sd->bl.id); return; } @@ -17218,10 +17308,12 @@ void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data* sd) { // so that buyingstore_trade knows, how many elements it has access to packet_len-= info->pos[3]; + if (packet_len < 0) + return; if( packet_len%blocksize ) { - ShowError("clif_parse_ReqTradeBuyingStore: Unexpected item list size %u (account_id=%d, buyer_id=%d, block size=%u)\n", packet_len, sd->bl.id, account_id, blocksize); + ShowError("clif_parse_ReqTradeBuyingStore: Unexpected item list size %d (account_id=%d, buyer_id=%d, block size=%u)\n", packet_len, sd->bl.id, account_id, blocksize); return; } count = packet_len/blocksize; @@ -17340,14 +17432,15 @@ void clif_parse_SearchStoreInfo(int fd, struct map_session_data* sd) { const uint8* itemlist; const uint8* cardlist; unsigned char type; - unsigned int min_price, max_price, packet_len, count, item_count, card_count; + unsigned int min_price, max_price; + int packet_len, count, item_count, card_count; struct s_packet_db* info = &packet_db[RFIFOW(fd,0)]; packet_len = RFIFOW(fd,info->pos[0]); if( packet_len < 15 ) {// minimum packet length - ShowError("clif_parse_SearchStoreInfo: Malformed packet (expected length=%u, length=%u, account_id=%d).\n", 15U, packet_len, sd->bl.id); + ShowError("clif_parse_SearchStoreInfo: Malformed packet (expected length=%u, length=%d, account_id=%d).\n", 15U, packet_len, sd->bl.id); return; } @@ -17357,24 +17450,28 @@ void clif_parse_SearchStoreInfo(int fd, struct map_session_data* sd) { item_count = RFIFOB(fd,info->pos[4]); card_count = RFIFOB(fd,info->pos[5]); itemlist = RFIFOP(fd,info->pos[6]); - cardlist = RFIFOP(fd,info->pos[6]+blocksize*item_count); // check, if there is enough data for the claimed count of items packet_len-= info->pos[6]; + if (packet_len < 0) + return; + if( packet_len%blocksize ) { - ShowError("clif_parse_SearchStoreInfo: Unexpected item list size %u (account_id=%d, block size=%u)\n", packet_len, sd->bl.id, blocksize); + ShowError("clif_parse_SearchStoreInfo: Unexpected item list size %d (account_id=%d, block size=%u)\n", packet_len, sd->bl.id, blocksize); return; } count = packet_len/blocksize; if( count < item_count+card_count ) { - ShowError("clif_parse_SearchStoreInfo: Malformed packet (expected count=%u, count=%u, account_id=%d).\n", item_count+card_count, count, sd->bl.id); + ShowError("clif_parse_SearchStoreInfo: Malformed packet (expected count=%d, count=%d, account_id=%d).\n", item_count+card_count, count, sd->bl.id); return; } + cardlist = RFIFOP(fd, info->pos[6] + blocksize * item_count); + searchstore->query(sd, type, min_price, max_price, (const unsigned short*)itemlist, item_count, (const unsigned short*)cardlist, card_count); } @@ -17994,16 +18091,30 @@ void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) #endif } +/// R 0848 <len>.W <limit>.W <kafra pay>.L (<item id>.L <amount>.L <tab>.W)* void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) { - unsigned short limit = RFIFOW(fd, 4), i, j; - unsigned int kafra_pay = RFIFOL(fd, 6);// [Ryuuzaki] - These are free cash points (strangely #CASH = main cash currently for us, confusing) + int len = RFIFOW(fd, 2); + unsigned short limit, i, j; + unsigned int kafra_pay; + int count; if (map->list[sd->bl.m].flag.nocashshop) { clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1489)); //Cash Shop is disabled in this map return; } + if (len < 10) + return; + + limit = RFIFOW(fd, 4); + kafra_pay = RFIFOL(fd, 6); // [Ryuuzaki] - These are free cash points (strangely #CASH = main cash currently for us, confusing) + count = (len - 10) / 10; + if (count != limit) { + ShowError("Wrong cash shop limit: %d\n", limit); + return; + } + for(i = 0; i < limit; i++) { int qty = RFIFOL(fd, 14 + ( i * 10 )); int id = RFIFOL(fd, 10 + ( i * 10 )); @@ -19516,7 +19627,7 @@ void clif_parse_rodex_open_write_mail(int fd, struct map_session_data *sd) __att void clif_parse_rodex_open_write_mail(int fd, struct map_session_data *sd) { const struct PACKET_CZ_REQ_OPEN_WRITE_MAIL *rPacket = RFIFOP(fd, 0); - int8 result = (rodex->isenabled() == true) ? 1 : 0; + int8 result = (rodex->isenabled() == true && sd->npc_id == 0) ? 1 : 0; clif->rodex_open_write_mail(fd, rPacket->receiveName, result); } @@ -19726,7 +19837,7 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ continue; inner->MailID = msg->id; - inner->Isread = msg->is_read == true ? 1 : 0; + inner->Isread = (msg->is_read == true || msg->sender_read == true) ? 1 : 0; inner->type = msg->type; #if PACKETVER >= 20170419 inner->openType = msg->opentype; @@ -19758,7 +19869,7 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ #endif } -void clif_rodex_send_mails_all(int fd, struct map_session_data *sd) +void clif_rodex_send_mails_all(int fd, struct map_session_data *sd, int64 mail_id) { #if PACKETVER >= 20170419 struct PACKET_ZC_MAIL_LIST *packet; @@ -19766,18 +19877,24 @@ void clif_rodex_send_mails_all(int fd, struct map_session_data *sd) int16 size = sizeof(*packet); int packetMailCount = 0; int mailListCount = 0; - int mailsSize = VECTOR_LENGTH(sd->rodex.messages); - int i; + int mailsSize, i; + int j = -1; nullpo_retv(sd); + mailsSize = VECTOR_LENGTH(sd->rodex.messages); + + if (mail_id > 0) + ARR_FIND(0, VECTOR_LENGTH(sd->rodex.messages), j, (VECTOR_INDEX(sd->rodex.messages, j)).id == mail_id); + WFIFOHEAD(fd, sizeof(*packet) + (sizeof(*inner) + RODEX_TITLE_LENGTH) * RODEX_MAIL_PER_PAGE); packet = WFIFOP(fd, 0); packet->PacketType = rodexmailList; inner = WFIFOP(fd, size); i = mailsSize - 1; - while (i >= 0) { + mailsSize -= (j + 1); + while (i > j) { struct rodex_message *msg = &VECTOR_INDEX(sd->rodex.messages, i); --i; @@ -19785,7 +19902,7 @@ void clif_rodex_send_mails_all(int fd, struct map_session_data *sd) continue; inner->MailID = msg->id; - inner->Isread = msg->is_read == true ? 1 : 0; + inner->Isread = (msg->is_read == true || msg->sender_read == true) ? 1 : 0; inner->type = msg->type; inner->openType = msg->opentype; inner->expireDateTime = msg->expire_date - (int)time(NULL); @@ -19852,7 +19969,7 @@ void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 open_type continue; inner->MailID = msg->id; - inner->Isread = msg->is_read == true ? 1 : 0; + inner->Isread = (msg->is_read == true || msg->sender_read == true) ? 1 : 0; inner->type = msg->type; #if PACKETVER >= 20170419 inner->openType = msg->opentype; diff --git a/src/map/clif.h b/src/map/clif.h index 0711546df..acf79c373 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1389,7 +1389,7 @@ struct clif_interface { void (*rodex_send_mail_result) (int fd, struct map_session_data *sd, int8 result); void (*rodex_send_maillist) (int fd, struct map_session_data *sd, int8 open_type, int64 page_start); void (*rodex_send_refresh) (int fd, struct map_session_data *sd, int8 open_type, int count); - void (*rodex_send_mails_all) (int fd, struct map_session_data *sd); + void (*rodex_send_mails_all) (int fd, struct map_session_data *sd, int64 mail_id); void (*pRodexReadMail) (int fd, struct map_session_data *sd); void (*rodex_read_mail) (struct map_session_data *sd, int8 opentype, struct rodex_message *msg); void (*pRodexNextMaillist) (int fd, struct map_session_data *sd); diff --git a/src/map/intif.c b/src/map/intif.c index 0e5cd3db2..f656a0df9 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -2516,6 +2516,9 @@ void intif_parse_RequestRodexOpenInbox(int fd) int8 is_end = RFIFOB(fd, 10); int is_first = RFIFOB(fd, 11); int count = RFIFOL(fd, 12); +#if PACKETVER >= 20170419 + int64 mail_id = RFIFOQ(fd, 16); +#endif int i, j; sd = map->charid2sd(RFIFOL(fd, 4)); @@ -2533,15 +2536,15 @@ void intif_parse_RequestRodexOpenInbox(int fd) else sd->rodex.total += count; - if (RFIFOW(fd, 2) - 16 != count * sizeof(struct rodex_message)) { - ShowError("intif_parse_RodexInboxOpenReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd, 2) - 16, count * sizeof(struct rodex_message)); + if (RFIFOW(fd, 2) - 24 != count * sizeof(struct rodex_message)) { + ShowError("intif_parse_RodexInboxOpenReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd, 2) - 24, count * sizeof(struct rodex_message)); return; } if (flag == 0 && is_first) VECTOR_CLEAR(sd->rodex.messages); - for (i = 0, j = 16; i < count; ++i, j += sizeof(struct rodex_message)) { + for (i = 0, j = 24; i < count; ++i, j += sizeof(struct rodex_message)) { struct rodex_message msg = { 0 }; VECTOR_ENSURE(sd->rodex.messages, 1, 1); memcpy(&msg, RFIFOP(fd, j), sizeof(struct rodex_message)); @@ -2550,7 +2553,7 @@ void intif_parse_RequestRodexOpenInbox(int fd) if (is_end == true) { #if PACKETVER >= 20170419 - clif->rodex_send_mails_all(sd->fd, sd); + clif->rodex_send_mails_all(sd->fd, sd, mail_id); #else if (flag == 0) clif->rodex_send_maillist(sd->fd, sd, opentype, VECTOR_LENGTH(sd->rodex.messages) - 1); @@ -2599,10 +2602,11 @@ void intif_parse_RodexNotifications(int fd) /// Updates a mail /// flag: -/// 0 - user Read +/// 0 - receiver Read /// 1 - user got Zeny /// 2 - user got Items /// 3 - delete +/// 4 - sender Read (returned mail) int intif_rodex_updatemail(int64 mail_id, int8 flag) { if (intif->CheckForCharServer()) diff --git a/src/map/packets.h b/src/map/packets.h index 4c41a7e8f..462efd31b 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -3995,11 +3995,15 @@ packet(0x96e,-1,clif->ackmergeitems); packet(0x0af3,-1,clif->pDull/*,XXX*/); packet(0x0af4,11,clif->pDull/*,XXX*/); // changed packet sizes - packet(0x0821,102); // AC_OTP_USER packet(0x0ae6,10,clif->pDull/*,XXX*/); #endif #endif // PACKETVER_ZERO +#if PACKETVER >= 20180131 +// changed packet sizes + packet(0x0821,102); // AC_OTP_USER +#endif + #ifdef PACKETVER_ZERO // 2018-02-07bRagexe_zero #if PACKETVER >= 20180207 @@ -4022,5 +4026,22 @@ packet(0x96e,-1,clif->ackmergeitems); #endif #endif // PACKETVER_ZERO +#ifdef PACKETVER_RE +// 2018-02-21aRagexeRE +#if PACKETVER >= 20180221 +// new packets +// changed packet sizes + packet(0x0206,35); // ZC_FRIENDS_STATE +#endif +#endif // PACKETVER_RE + +#ifndef PACKETVER_ZERO +// 2018-03-07bRagexe +#if PACKETVER >= 20180307 +// new packets +// changed packet sizes + packet(0x0206,35); // ZC_FRIENDS_STATE +#endif +#endif // PACKETVER_ZERO #endif /* MAP_PACKETS_H */ diff --git a/src/map/packets_keys_main.h b/src/map/packets_keys_main.h index 9aa39fad5..066e7d2c3 100644 --- a/src/map/packets_keys_main.h +++ b/src/map/packets_keys_main.h @@ -1949,15 +1949,32 @@ packetKeys(0x21F477F4,0x37F437F4,0x37F437F4); #endif -// 2018-01-24bRagexe, 2018-01-24bRagexeRE -#if PACKETVER == 20180124 +// 2018-01-24bRagexe, 2018-01-24bRagexeRE, 2018-01-31Ragexe +#if PACKETVER == 20180124 || \ + PACKETVER == 20180131 packetKeys(0x7EAA1CE0,0x415D1CFD,0x4C8F19FA); #endif -// 2018-02-07bRagexe, 2018-02-07bRagexeRE +// 2018-02-07bRagexe, 2018-02-07bRagexeRE, 2018-02-07cRagexe #if PACKETVER == 20180207 packetKeys(0x45AA1B44,0x20E716B7,0x5388105C); #endif +// 2018-02-13aRagexe, 2018-02-13aRagexeRE, 2018-02-13bRagexe +#if PACKETVER == 20180213 + packetKeys(0x189D69B2,0x43B85EAD,0x2B7A687E); +#endif + +// 2018-02-21aRagexeRE, 2018-02-21bRagexe, 2018-02-21bRagexeRE +#if PACKETVER == 20180221 + packetKeys(0x6E2F6233,0x193B0A66,0x0D1D2CA5); +#endif + +// 2018-03-07bRagexe, 2018-03-07bRagexeRE, 2018-03-09aRagexe +#if PACKETVER == 20180307 || \ + PACKETVER == 20180309 + packetKeys(0x47DA10EB,0x4B922CCF,0x765C5055); +#endif + #endif /* MAP_PACKETS_MAIN_KEYS_H */ diff --git a/src/map/packets_keys_zero.h b/src/map/packets_keys_zero.h index 101d0b973..75196e6b4 100644 --- a/src/map/packets_keys_zero.h +++ b/src/map/packets_keys_zero.h @@ -124,5 +124,22 @@ packetKeys(0x07CB29CB,0x69CB69CB,0x69CB69CB); #endif +// 2018-02-13aRagexe_zero +#if PACKETVER == 20180213 + packetKeys(0x0513075E,0x347075AF,0x67C56C6F); +#endif + +// 2018-02-21aRagexe_zero +#if PACKETVER == 20180221 + packetKeys(0x28ED7635,0x76591F21,0x59383498); +#endif + +// 2018-02-28bRagexe_zero, 2018-03-07aRagexe_zero, 2018-03-09aRagexe_zero +#if PACKETVER == 20180228 || \ + PACKETVER == 20180307 || \ + PACKETVER == 20180309 + packetKeys(0x56C82ABE,0x61AE2B2E,0x472E272E); +#endif + #endif /* MAP_PACKETS_ZERO_KEYS_H */ diff --git a/src/map/packets_shuffle_main.h b/src/map/packets_shuffle_main.h index 13861dd46..aabf9c3f3 100644 --- a/src/map/packets_shuffle_main.h +++ b/src/map/packets_shuffle_main.h @@ -9500,8 +9500,9 @@ packet(0x096a,6,clif->pGetCharNameRequest,2); // CZ_REQNAME #endif -// 2018-01-24bRagexe, 2018-01-24bRagexeRE -#if PACKETVER == 20180124 +// 2018-01-24bRagexe, 2018-01-24bRagexeRE, 2018-01-31Ragexe +#if PACKETVER == 20180124 || \ + PACKETVER == 20180131 packet(0x035f,6,clif->pTickSend,2); // CZ_REQUEST_TIME packet(0x0360,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX @@ -9533,7 +9534,7 @@ packet(0x096a,6,clif->pGetCharNameRequest,2); // CZ_REQNAME #endif -// 2018-02-07bRagexe, 2018-02-07bRagexeRE +// 2018-02-07bRagexe, 2018-02-07bRagexeRE, 2018-02-07cRagexe #if PACKETVER == 20180207 packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES packet(0x035f,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE @@ -9566,5 +9567,105 @@ packet(0x096a,6,clif->pGetCharNameRequest,2); // CZ_REQNAME #endif +// 2018-02-13aRagexe, 2018-02-13aRagexeRE, 2018-02-13bRagexe +#if PACKETVER == 20180213 + packet(0x0369,36,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD + packet(0x0802,6,clif->pDropItem,2,4); // CZ_ITEM_THROW + packet(0x0817,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX + packet(0x085a,12,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK + packet(0x086f,26,clif->pPartyInvite2,2); // CZ_PARTY_JOIN_REQ + packet(0x0874,6,clif->pTickSend,2); // CZ_REQUEST_TIME + packet(0x0875,8,clif->pMoveFromKafra,2,4); // CZ_MOVE_ITEM_FROM_STORE_TO_BODY + packet(0x0878,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION + packet(0x087b,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE + packet(0x0882,10,clif->pUseSkillToId,2,4,6); // CZ_USE_SKILL + packet(0x088c,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); // CZ_SEARCH_STORE_INFO + packet(0x0892,6,clif->pTakeItem,2); // CZ_ITEM_PICKUP + packet(0x0898,-1,clif->pReqTradeBuyingStore,2,4,8,12); // CZ_REQ_TRADE_BUYING_STORE + packet(0x089c,4,clif->pDull/*,XXX*/); // CZ_GANGSI_RANK + packet(0x08a3,19,clif->pWantToConnection,2,6,10,14,18); // CZ_ENTER + packet(0x08a5,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); // CZ_REQ_OPEN_BUYING_STORE + packet(0x08a9,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE + packet(0x08ad,6,clif->pSolveCharName,2); // CZ_REQNAME_BYGID + packet(0x0917,26,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS + packet(0x0922,5,clif->pWalkToXY,2); // CZ_REQUEST_MOVE + packet(0x0924,10,clif->pUseSkillToPos,2,4,6,8); // CZ_USE_SKILL_TOGROUND + packet(0x0926,8,clif->pDull/*,XXX*/); // CZ_JOIN_BATTLE_FIELD + packet(0x0933,7,clif->pActionRequest,2,6); // CZ_REQUEST_ACT + packet(0x0936,2,clif->pSearchStoreInfoNextPage,0); // CZ_SEARCH_STORE_INFO_NEXT_PAGE + packet(0x093c,6,clif->pGetCharNameRequest,2); // CZ_REQNAME + packet(0x0943,18,clif->pPartyBookingRegisterReq,2,4); // CZ_PARTY_BOOKING_REQ_REGISTER + packet(0x0955,8,clif->pMoveToKafra,2,4); // CZ_MOVE_ITEM_FROM_BODY_TO_STORE + packet(0x095a,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES + packet(0x0962,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER +#endif + +// 2018-02-21aRagexeRE, 2018-02-21bRagexe, 2018-02-21bRagexeRE +#if PACKETVER == 20180221 + packet(0x0202,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX + packet(0x0366,8,clif->pDull/*,XXX*/); // CZ_JOIN_BATTLE_FIELD + packet(0x0436,26,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS + packet(0x0838,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION + packet(0x0867,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); // CZ_SEARCH_STORE_INFO + packet(0x086c,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE + packet(0x086f,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); // CZ_REQ_OPEN_BUYING_STORE + packet(0x0871,6,clif->pDropItem,2,4); // CZ_ITEM_THROW + packet(0x0876,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER + packet(0x0879,8,clif->pMoveToKafra,2,4); // CZ_MOVE_ITEM_FROM_BODY_TO_STORE + packet(0x087d,5,clif->pWalkToXY,2); // CZ_REQUEST_MOVE + packet(0x0880,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES + packet(0x0881,18,clif->pPartyBookingRegisterReq,2,4); // CZ_PARTY_BOOKING_REQ_REGISTER + packet(0x0883,-1,clif->pReqTradeBuyingStore,2,4,8,12); // CZ_REQ_TRADE_BUYING_STORE + packet(0x088f,6,clif->pSolveCharName,2); // CZ_REQNAME_BYGID + packet(0x0891,4,clif->pDull/*,XXX*/); // CZ_GANGSI_RANK + packet(0x0897,19,clif->pWantToConnection,2,6,10,14,18); // CZ_ENTER + packet(0x0899,2,clif->pSearchStoreInfoNextPage,0); // CZ_SEARCH_STORE_INFO_NEXT_PAGE + packet(0x089d,6,clif->pTickSend,2); // CZ_REQUEST_TIME + packet(0x0917,36,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD + packet(0x091e,8,clif->pMoveFromKafra,2,4); // CZ_MOVE_ITEM_FROM_STORE_TO_BODY + packet(0x0929,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE + packet(0x093d,26,clif->pPartyInvite2,2); // CZ_PARTY_JOIN_REQ + packet(0x094b,10,clif->pUseSkillToId,2,4,6); // CZ_USE_SKILL + packet(0x094d,10,clif->pUseSkillToPos,2,4,6,8); // CZ_USE_SKILL_TOGROUND + packet(0x094e,6,clif->pTakeItem,2); // CZ_ITEM_PICKUP + packet(0x0957,6,clif->pGetCharNameRequest,2); // CZ_REQNAME + packet(0x0964,12,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK + packet(0x096a,7,clif->pActionRequest,2,6); // CZ_REQUEST_ACT +#endif + +// 2018-03-07bRagexe, 2018-03-07bRagexeRE, 2018-03-09aRagexe +#if PACKETVER == 20180307 || \ + PACKETVER == 20180309 + packet(0x0281,4,clif->pDull/*,XXX*/); // CZ_GANGSI_RANK + packet(0x035f,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); // CZ_REQ_OPEN_BUYING_STORE + packet(0x0437,6,clif->pDropItem,2,4); // CZ_ITEM_THROW + packet(0x07e4,19,clif->pWantToConnection,2,6,10,14,18); // CZ_ENTER + packet(0x0861,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX + packet(0x0862,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE + packet(0x0864,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); // CZ_SEARCH_STORE_INFO + packet(0x086c,6,clif->pTickSend,2); // CZ_REQUEST_TIME + packet(0x0870,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES + packet(0x0872,18,clif->pPartyBookingRegisterReq,2,4); // CZ_PARTY_BOOKING_REQ_REGISTER + packet(0x0877,5,clif->pWalkToXY,2); // CZ_REQUEST_MOVE + packet(0x088d,8,clif->pMoveFromKafra,2,4); // CZ_MOVE_ITEM_FROM_STORE_TO_BODY + packet(0x0893,10,clif->pUseSkillToId,2,4,6); // CZ_USE_SKILL + packet(0x089b,12,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK + packet(0x08a6,2,clif->pSearchStoreInfoNextPage,0); // CZ_SEARCH_STORE_INFO_NEXT_PAGE + packet(0x08aa,26,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS + packet(0x08ab,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION + packet(0x0917,10,clif->pUseSkillToPos,2,4,6,8); // CZ_USE_SKILL_TOGROUND + packet(0x0920,8,clif->pMoveToKafra,2,4); // CZ_MOVE_ITEM_FROM_BODY_TO_STORE + packet(0x0937,-1,clif->pReqTradeBuyingStore,2,4,8,12); // CZ_REQ_TRADE_BUYING_STORE + packet(0x0939,36,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD + packet(0x093d,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE + packet(0x0941,6,clif->pGetCharNameRequest,2); // CZ_REQNAME + packet(0x0944,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER + packet(0x0948,26,clif->pPartyInvite2,2); // CZ_PARTY_JOIN_REQ + packet(0x0951,8,clif->pDull/*,XXX*/); // CZ_JOIN_BATTLE_FIELD + packet(0x0954,6,clif->pTakeItem,2); // CZ_ITEM_PICKUP + packet(0x0957,6,clif->pSolveCharName,2); // CZ_REQNAME_BYGID + packet(0x0969,7,clif->pActionRequest,2,6); // CZ_REQUEST_ACT +#endif + #endif /* MAP_PACKETS_SHUFFLE_MAIN_H */ diff --git a/src/map/packets_shuffle_zero.h b/src/map/packets_shuffle_zero.h index 38c34b18e..463ab1679 100644 --- a/src/map/packets_shuffle_zero.h +++ b/src/map/packets_shuffle_zero.h @@ -551,5 +551,106 @@ packet(0x096a,6,clif->pGetCharNameRequest,2); // CZ_REQNAME #endif +// 2018-02-13aRagexe_zero +#if PACKETVER == 20180213 + packet(0x022d,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION + packet(0x02c4,8,clif->pMoveToKafra,2,4); // CZ_MOVE_ITEM_FROM_BODY_TO_STORE + packet(0x035f,6,clif->pDropItem,2,4); // CZ_ITEM_THROW + packet(0x0361,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX + packet(0x0802,6,clif->pTickSend,2); // CZ_REQUEST_TIME + packet(0x0815,10,clif->pUseSkillToId,2,4,6); // CZ_USE_SKILL + packet(0x0838,2,clif->pSearchStoreInfoNextPage,0); // CZ_SEARCH_STORE_INFO_NEXT_PAGE + packet(0x085a,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); // CZ_SEARCH_STORE_INFO + packet(0x085d,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER + packet(0x0868,18,clif->pPartyBookingRegisterReq,2,4); // CZ_PARTY_BOOKING_REQ_REGISTER + packet(0x087b,6,clif->pGetCharNameRequest,2); // CZ_REQNAME + packet(0x0882,12,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK + packet(0x0887,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES + packet(0x0888,6,clif->pSolveCharName,2); // CZ_REQNAME_BYGID + packet(0x088a,4,clif->pDull/*,XXX*/); // CZ_GANGSI_RANK + packet(0x088e,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE + packet(0x0899,26,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS + packet(0x0917,7,clif->pActionRequest,2,6); // CZ_REQUEST_ACT + packet(0x091d,5,clif->pWalkToXY,2); // CZ_REQUEST_MOVE + packet(0x0922,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); // CZ_REQ_OPEN_BUYING_STORE + packet(0x0930,8,clif->pDull/*,XXX*/); // CZ_JOIN_BATTLE_FIELD + packet(0x0941,19,clif->pWantToConnection,2,6,10,14,18); // CZ_ENTER + packet(0x0942,8,clif->pMoveFromKafra,2,4); // CZ_MOVE_ITEM_FROM_STORE_TO_BODY + packet(0x0947,6,clif->pTakeItem,2); // CZ_ITEM_PICKUP + packet(0x094d,10,clif->pUseSkillToPos,2,4,6,8); // CZ_USE_SKILL_TOGROUND + packet(0x0958,26,clif->pPartyInvite2,2); // CZ_PARTY_JOIN_REQ + packet(0x095b,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE + packet(0x095c,-1,clif->pReqTradeBuyingStore,2,4,8,12); // CZ_REQ_TRADE_BUYING_STORE + packet(0x0967,36,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD +#endif + +// 2018-02-21aRagexe_zero +#if PACKETVER == 20180221 + packet(0x02c4,6,clif->pTickSend,2); // CZ_REQUEST_TIME + packet(0x0362,6,clif->pGetCharNameRequest,2); // CZ_REQNAME + packet(0x0364,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION + packet(0x0438,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES + packet(0x0817,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); // CZ_SEARCH_STORE_INFO + packet(0x085b,10,clif->pUseSkillToPos,2,4,6,8); // CZ_USE_SKILL_TOGROUND + packet(0x086a,8,clif->pDull/*,XXX*/); // CZ_JOIN_BATTLE_FIELD + packet(0x0878,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE + packet(0x0880,19,clif->pWantToConnection,2,6,10,14,18); // CZ_ENTER + packet(0x0884,2,clif->pSearchStoreInfoNextPage,0); // CZ_SEARCH_STORE_INFO_NEXT_PAGE + packet(0x088d,6,clif->pSolveCharName,2); // CZ_REQNAME_BYGID + packet(0x0892,6,clif->pDropItem,2,4); // CZ_ITEM_THROW + packet(0x0895,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE + packet(0x08a1,5,clif->pWalkToXY,2); // CZ_REQUEST_MOVE + packet(0x08a3,10,clif->pUseSkillToId,2,4,6); // CZ_USE_SKILL + packet(0x091b,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX + packet(0x0921,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); // CZ_REQ_OPEN_BUYING_STORE + packet(0x0923,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER + packet(0x092d,26,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS + packet(0x0932,-1,clif->pReqTradeBuyingStore,2,4,8,12); // CZ_REQ_TRADE_BUYING_STORE + packet(0x093b,12,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK + packet(0x093d,26,clif->pPartyInvite2,2); // CZ_PARTY_JOIN_REQ + packet(0x093e,8,clif->pMoveFromKafra,2,4); // CZ_MOVE_ITEM_FROM_STORE_TO_BODY + packet(0x0942,36,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD + packet(0x0951,18,clif->pPartyBookingRegisterReq,2,4); // CZ_PARTY_BOOKING_REQ_REGISTER + packet(0x0952,4,clif->pDull/*,XXX*/); // CZ_GANGSI_RANK + packet(0x0958,7,clif->pActionRequest,2,6); // CZ_REQUEST_ACT + packet(0x0959,8,clif->pMoveToKafra,2,4); // CZ_MOVE_ITEM_FROM_BODY_TO_STORE + packet(0x095d,6,clif->pTakeItem,2); // CZ_ITEM_PICKUP +#endif + +// 2018-02-28bRagexe_zero, 2018-03-07aRagexe_zero, 2018-03-09aRagexe_zero +#if PACKETVER == 20180228 || \ + PACKETVER == 20180307 || \ + PACKETVER == 20180309 + packet(0x0202,5,clif->pChangeDir,2,4); // CZ_CHANGE_DIRECTION + packet(0x022d,19,clif->pWantToConnection,2,6,10,14,18); // CZ_ENTER + packet(0x023b,26,clif->pFriendsListAdd,2); // CZ_ADD_FRIENDS + packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8); // CZ_ITEMLISTWIN_RES + packet(0x035f,6,clif->pTickSend,2); // CZ_REQUEST_TIME + packet(0x0360,6,clif->pReqClickBuyingStore,2); // CZ_REQ_CLICK_TO_BUYING_STORE + packet(0x0361,5,clif->pHomMenu,2,4); // CZ_COMMAND_MER + packet(0x0362,6,clif->pDropItem,2,4); // CZ_ITEM_THROW + packet(0x0363,8,clif->pDull/*,XXX*/); // CZ_JOIN_BATTLE_FIELD + packet(0x0364,8,clif->pMoveFromKafra,2,4); // CZ_MOVE_ITEM_FROM_STORE_TO_BODY + packet(0x0365,18,clif->pPartyBookingRegisterReq,2,4); // CZ_PARTY_BOOKING_REQ_REGISTER + packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); // CZ_USE_SKILL_TOGROUND_WITHTALKBOX + packet(0x0368,6,clif->pSolveCharName,2); // CZ_REQNAME_BYGID + packet(0x0369,7,clif->pActionRequest,2,6); // CZ_REQUEST_ACT + packet(0x0436,4,clif->pDull/*,XXX*/); // CZ_GANGSI_RANK + packet(0x0437,5,clif->pWalkToXY,2); // CZ_REQUEST_MOVE + packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8); // CZ_USE_SKILL_TOGROUND + packet(0x07e4,6,clif->pTakeItem,2); // CZ_ITEM_PICKUP + packet(0x07ec,8,clif->pMoveToKafra,2,4); // CZ_MOVE_ITEM_FROM_BODY_TO_STORE + packet(0x0802,26,clif->pPartyInvite2,2); // CZ_PARTY_JOIN_REQ + packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12); // CZ_REQ_TRADE_BUYING_STORE + packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); // CZ_REQ_OPEN_BUYING_STORE + packet(0x0817,2,clif->pReqCloseBuyingStore,0); // CZ_REQ_CLOSE_BUYING_STORE + packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); // CZ_SEARCH_STORE_INFO + packet(0x0835,2,clif->pSearchStoreInfoNextPage,0); // CZ_SEARCH_STORE_INFO_NEXT_PAGE + packet(0x0838,12,clif->pSearchStoreInfoListItemClick,2,6,10); // CZ_SSILIST_ITEM_CLICK + packet(0x083c,10,clif->pUseSkillToId,2,4,6); // CZ_USE_SKILL + packet(0x0930,36,clif->pStoragePassword,0); // CZ_ACK_STORE_PASSWORD + packet(0x096a,6,clif->pGetCharNameRequest,2); // CZ_REQNAME +#endif + #endif /* MAP_PACKETS_SHUFFLE_ZERO_H */ diff --git a/src/map/rodex.c b/src/map/rodex.c index d5a6064cf..0e9e4ee2a 100644 --- a/src/map/rodex.c +++ b/src/map/rodex.c @@ -231,6 +231,11 @@ int rodex_send_mail(struct map_session_data *sd, const char *receiver_name, cons nullpo_retr(RODEX_SEND_MAIL_FATAL_ERROR, body); nullpo_retr(RODEX_SEND_MAIL_FATAL_ERROR, title); + if (!rodex->isenabled() || sd->npc_id > 0) { + rodex->clean(sd, 1); + return RODEX_SEND_MAIL_FATAL_ERROR; + } + if (zeny < 0) { rodex->clean(sd, 1); return RODEX_SEND_MAIL_FATAL_ERROR; @@ -364,15 +369,24 @@ struct rodex_message *rodex_get_mail(struct map_session_data *sd, int64 mail_id) { int i; struct rodex_message *msg; + int char_id; nullpo_retr(NULL, sd); - ARR_FIND(0, VECTOR_LENGTH(sd->rodex.messages), i, VECTOR_INDEX(sd->rodex.messages, i).id == mail_id && VECTOR_INDEX(sd->rodex.messages, i).is_deleted != true); + ARR_FIND(0, VECTOR_LENGTH(sd->rodex.messages), i, VECTOR_INDEX(sd->rodex.messages, i).id == mail_id); if (i == VECTOR_LENGTH(sd->rodex.messages)) return NULL; msg = &VECTOR_INDEX(sd->rodex.messages, i); + char_id = sd->status.char_id; + + if ((msg->is_deleted == true) + || (msg->expire_date < time(NULL) && ((msg->receiver_accountid > 0) || (msg->receiver_id == char_id && msg->sender_id != char_id))) + || ((msg->send_date + 2 * RODEX_EXPIRE) < time(NULL)) + ) + return NULL; + return msg; } @@ -388,9 +402,16 @@ void rodex_read_mail(struct map_session_data *sd, int64 mail_id) msg = rodex->get_mail(sd, mail_id); nullpo_retv(msg); - if (msg->is_read == false) { - intif->rodex_updatemail(msg->id, 0); - msg->is_read = true; + if (msg->opentype == RODEX_OPENTYPE_RETURN) { + if (msg->sender_read == false) { + intif->rodex_updatemail(msg->id, 4); + msg->sender_read = true; + } + } else { + if (msg->is_read == false) { + intif->rodex_updatemail(msg->id, 0); + msg->is_read = true; + } } clif->rodex_read_mail(sd, msg->opentype, msg); @@ -440,6 +461,7 @@ void rodex_get_zeny(struct map_session_data *sd, int8 opentype, int64 mail_id) return; } + msg->type &= ~MAIL_TYPE_ZENY; msg->zeny = 0; intif->rodex_updatemail(mail_id, 1); @@ -523,6 +545,8 @@ void rodex_get_items(struct map_session_data *sd, int8 opentype, int64 mail_id) } } + msg->type &= ~MAIL_TYPE_ITEM; + msg->items_count = 0; intif->rodex_updatemail(mail_id, 2); clif->rodex_request_items(sd, opentype, mail_id, RODEX_GET_ITEMS_SUCCESS); diff --git a/src/map/unit.c b/src/map/unit.c index 938b587f3..c40aa7000 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2210,6 +2210,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) //Non-players use the sync packet on the walk timer. [Skotlex] if (tid == INVALID_TIMER && sd) clif->fixpos(src); + map->freeblock_lock(); if( DIFF_TICK(ud->attackabletime,tick) <= 0 ) { if (battle_config.attack_direction_change && (src->type&battle_config.attack_direction_change)) { ud->dir = map->calc_dir(src, target->x,target->y ); @@ -2219,8 +2220,10 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) if(md) { //First attack is always a normal attack if(md->state.skillstate == MSS_ANGRY || md->state.skillstate == MSS_BERSERK) { - if (mob->skill_use(md,tick,-1)) + if (mob->skill_use(md,tick,-1)) { + map->freeblock_unlock(); return 1; + } } else { // Set mob's ANGRY/BERSERK states. md->state.skillstate = md->state.aggressive?MSS_ANGRY:MSS_BERSERK; @@ -2232,21 +2235,23 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) map->foreachinrange(mob->linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick); } } - if (src->type == BL_PET && pet->attackskill(BL_UCAST(BL_PET, src), target->id)) + if (src->type == BL_PET && pet->attackskill(BL_UCAST(BL_PET, src), target->id)) { + map->freeblock_unlock(); return 1; + } - map->freeblock_lock(); ud->attacktarget_lv = battle->weapon_attack(src,target,tick,0); if(sd && sd->status.pet_id > 0 && sd->pd && battle_config.pet_attack_support) pet->target_check(sd,target,0); - map->freeblock_unlock(); /** * Applied when you're unable to attack (e.g. out of ammo) * We should stop here otherwise timer keeps on and this happens endlessly **/ - if( ud->attacktarget_lv == ATK_NONE ) + if (ud->attacktarget_lv == ATK_NONE) { + map->freeblock_unlock(); return 1; + } ud->attackabletime = tick + sstatus->adelay; // You can't move if you can't attack neither. @@ -2260,6 +2265,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) pc->update_idle_time(sd, BCIDLE_ATTACK); ud->attacktimer = timer->add(ud->attackabletime,unit->attack_timer,src->id,0); } + map->freeblock_unlock(); if (sd != NULL && battle_config.prevent_logout_trigger & PLT_ATTACK) sd->canlog_tick = timer->gettick(); |