void mapif_parse_rodex_checkhasnew(int fd) { int char_id = RFIFOL(fd, 2); int account_id = RFIFOL(fd, 6); bool has_new; Assert_retv(account_id >= START_ACCOUNT_NUM && account_id <= END_ACCOUNT_NUM); Assert_retv(char_id >= START_CHAR_NUM); has_new = inter_rodex->hasnew(char_id, account_id); mapif->rodex_sendhasnew(fd, char_id, has_new); }
/*========================================== * Send Mail *------------------------------------------*/ void mapif_rodex_send(int fd, int sender_id, int receiver_id, int receiver_accountid, bool result) { Assert_retv(sender_id >= 0); Assert_retv(receiver_id + receiver_accountid > 0); WFIFOHEAD(fd,15); WFIFOW(fd,0) = 0x3897; WFIFOL(fd,2) = sender_id; WFIFOL(fd,6) = receiver_id; WFIFOL(fd,10) = receiver_accountid; WFIFOB(fd,14) = result; WFIFOSET(fd,15); }
/*------------------------------------------ * Check Player *------------------------------------------*/ void mapif_rodex_checkname(int fd, int reqchar_id, int target_char_id, short target_class, int target_level, char *name) { nullpo_retv(name); Assert_retv(reqchar_id > 0); Assert_retv(target_char_id >= 0); WFIFOHEAD(fd, 16 + NAME_LENGTH); WFIFOW(fd, 0) = 0x3898; WFIFOL(fd, 2) = reqchar_id; WFIFOL(fd, 6) = target_char_id; WFIFOW(fd, 10) = target_class; WFIFOL(fd, 12) = target_level; safestrncpy(WFIFOP(fd, 16), name, NAME_LENGTH); WFIFOSET(fd, 16 + NAME_LENGTH); }
/*========================================== * Inbox Request *------------------------------------------*/ void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails) { int per_packet = (UINT16_MAX - 24) / sizeof(struct rodex_message); int sent = 0; bool is_first = true; nullpo_retv(mails); Assert_retv(char_id > 0); Assert_retv(count >= 0); Assert_retv(mail_id >= 0); do { int i = 24, j, size, limit; int to_send = count - sent; bool is_last = true; if (to_send <= per_packet) { size = to_send * sizeof(struct rodex_message) + 24; limit = to_send; is_last = true; } else { limit = min(to_send, per_packet); if (limit != to_send) { is_last = false; } size = limit * sizeof(struct rodex_message) + 24; } WFIFOHEAD(fd, size); WFIFOW(fd, 0) = 0x3895; WFIFOW(fd, 2) = size; WFIFOL(fd, 4) = char_id; WFIFOB(fd, 8) = opentype; WFIFOB(fd, 9) = flag; WFIFOB(fd, 10) = is_last; WFIFOB(fd, 11) = is_first; WFIFOL(fd, 12) = limit; WFIFOQ(fd, 16) = mail_id; for (j = 0; j < limit; ++j, ++sent, i += sizeof(struct rodex_message)) { memcpy(WFIFOP(fd, i), &VECTOR_INDEX(*mails, sent), sizeof(struct rodex_message)); } WFIFOSET(fd, size); is_first = false; } while (sent < count); }
void pincode_notifyLoginPinUpdate(int account_id, char* pin) { nullpo_retv(pin); Assert_retv(chr->login_fd != -1); WFIFOHEAD(chr->login_fd,11); WFIFOW(chr->login_fd,0) = 0x2738; WFIFOL(chr->login_fd,2) = account_id; safestrncpy(WFIFOP(chr->login_fd,6), pin, 5); WFIFOSET(chr->login_fd,11); }
/// @copydoc md5_interface::salt(); void md5_salt(int len, char *output) { int i; Assert_retv(len > 0); for (i = 0; i < len; ++i) output[i] = (char)(1 + rnd() % 255); }
/*========================================== * Checks if there are new mails *------------------------------------------*/ void mapif_rodex_sendhasnew(int fd, int char_id, bool has_new) { Assert_retv(char_id > 0); WFIFOHEAD(fd, 7); WFIFOW(fd, 0) = 0x3896; WFIFOL(fd, 2) = char_id; WFIFOB(fd, 6) = has_new; WFIFOSET(fd, 7); }
/*========================================== * Update/Delete mail *------------------------------------------*/ void mapif_parse_rodex_updatemail(int fd) { int64 mail_id = RFIFOL(fd, 2); int8 flag = RFIFOB(fd, 10); Assert_retv(mail_id > 0); Assert_retv(flag >= 0 && flag <= 4); switch (flag) { case 0: // Read if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `is_read` = 1 WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id)) Sql_ShowDebug(inter->sql_handle); break; case 1: // Get Zeny if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `zeny` = 0, `type` = `type` & (~2) WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id)) Sql_ShowDebug(inter->sql_handle); break; case 2: // Get Items if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `mail_id` = '%"PRId64"'", rodex_item_db, mail_id)) Sql_ShowDebug(inter->sql_handle); if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `zeny` = 0, `type` = `type` & (~4) WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id)) Sql_ShowDebug(inter->sql_handle); break; case 3: // Delete Mail if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id)) Sql_ShowDebug(inter->sql_handle); if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `mail_id` = '%"PRId64"'", rodex_item_db, mail_id)) Sql_ShowDebug(inter->sql_handle); break; case 4: // Sender Read if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `sender_read` = 1 WHERE `mail_id` = '%"PRId64"'", rodex_db, mail_id)) Sql_ShowDebug(inter->sql_handle); break; } }
/// Removes an item attached to a message being writen /// @param sd : The player who's writting the message /// @param idx : The index of the item /// @param amount : How much to remove void rodex_remove_item(struct map_session_data *sd, int16 idx, int16 amount) { int i; struct item *it; struct item_data *itd; nullpo_retv(sd); Assert_retv(idx >= 0 && idx < MAX_INVENTORY); for (i = 0; i < RODEX_MAX_ITEM; ++i) { if (sd->rodex.tmp.items[i].idx == idx) break; } if (i == RODEX_MAX_ITEM) { clif->rodex_remove_item_result(sd, idx, -1); return; } it = &sd->rodex.tmp.items[i].item; if (amount <= 0 || amount > it->amount) { clif->rodex_remove_item_result(sd, idx, -1); return; } itd = itemdb->search(it->nameid); if (amount == it->amount) { sd->rodex.tmp.weight -= itd->weight * amount; sd->rodex.tmp.items_count--; if (sd->rodex.tmp.items_count < 1) { sd->rodex.tmp.type &= ~MAIL_TYPE_ITEM; } memset(&sd->rodex.tmp.items[i], 0x0, sizeof(sd->rodex.tmp.items[0])); clif->rodex_remove_item_result(sd, idx, 0); return; } it->amount -= amount; sd->rodex.tmp.weight -= itd->weight * amount; clif->rodex_remove_item_result(sd, idx, it->amount); }