diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-08-13 21:50:33 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-08-13 21:50:33 +0300 |
commit | a38eb2a333972481d99c5fe0c152ba6d59fba839 (patch) | |
tree | 1ef8f9da2d4a6ed5caa6c98a2aa50b42c0b1b67f | |
parent | cfaf7b65b33fb94ba96be48c0c0187116616279a (diff) | |
download | evol-hercules-a38eb2a333972481d99c5fe0c152ba6d59fba839.tar.gz evol-hercules-a38eb2a333972481d99c5fe0c152ba6d59fba839.tar.bz2 evol-hercules-a38eb2a333972481d99c5fe0c152ba6d59fba839.tar.xz evol-hercules-a38eb2a333972481d99c5fe0c152ba6d59fba839.zip |
Add support for sending all equipped items with cards from char server.
-rw-r--r-- | src/echar/char.c | 127 | ||||
-rw-r--r-- | src/echar/char.h | 12 | ||||
-rw-r--r-- | src/echar/init.c | 3 | ||||
-rw-r--r-- | src/emap/pc.c | 26 | ||||
-rw-r--r-- | src/emap/send.c | 3 |
5 files changed, 144 insertions, 27 deletions
diff --git a/src/echar/char.c b/src/echar/char.c index 85c890c..6a01e8f 100644 --- a/src/echar/char.c +++ b/src/echar/char.c @@ -7,11 +7,13 @@ #include "common/HPMi.h" #include "common/malloc.h" +#include "common/mapindex.h" #include "common/mmo.h" #include "common/socket.h" #include "common/strlib.h" #include "common/timer.h" #include "char/char.h" +#include "char/inter.h" #include "echar/char.h" #include "echar/config.h" @@ -172,3 +174,128 @@ void echar_parse_login_password_change_ack(int charFd) WFIFOSET(fd, 3); } } + +void echar_mmo_char_send099d(int *fdPtr, struct char_session_data *sd) +{ + send_additional_slots(*fdPtr, sd); +} + +int echar_mmo_char_send_characters(int retVal, int *fdPtr, struct char_session_data* sd) +{ + send_additional_slots(*fdPtr, sd); + return retVal; +} + +void send_additional_slots(int fd, struct char_session_data* sd) +{ + int char_id; + int name_id; + int slot; + short card0; + short card1; + short card2; + short card3; + + if (sd->version < 9) + return; + + SqlStmt* stmt = SQL->StmtMalloc(inter->sql_handle); + if (stmt == NULL) + { + SqlStmt_ShowDebug(stmt); + return; + } + + if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT " + "inventory.char_id, inventory.nameid, inventory.equip, " + "inventory.card0, inventory.card1, inventory.card2, inventory.card3 " + "FROM `char` " + "LEFT JOIN inventory ON inventory.char_id = `char`.char_id " + "WHERE account_id = '%d' AND equip <> 0 AND amount > 0 ORDER BY inventory.char_id", sd->account_id) + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &char_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &name_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_INT, &slot, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_SHORT, &card0, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_SHORT, &card1, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_SHORT, &card2, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_SHORT, &card3, 0, NULL, NULL)) + { + SqlStmt_ShowDebug(stmt); + SQL->StmtFree(stmt); + return; + } + + while (SQL_SUCCESS == SQL->StmtNextRow(stmt)) + { + int type = 2; + switch (slot) + { + case 0: + type = 0; + break; + case EQP_HEAD_LOW: + type = 3; + break; + case EQP_HAND_R: + type = 2; + break; + case EQP_GARMENT: + type = 12; + break; + case EQP_ACC_L: // not implimented + type = 0; + break; + case EQP_ARMOR: + type = 17; + break; + case EQP_HAND_L: // not implimented + type = 0; + break; + case EQP_SHOES: + type = 9; + break; + case EQP_ACC_R: // not implimented + type = 0; + break; + case EQP_HEAD_TOP: + type = 4; + break; + case EQP_HEAD_MID: + type = 5; + break; + case EQP_COSTUME_HEAD_TOP: + type = 13; + break; + case EQP_COSTUME_HEAD_MID: + type = 14; + break; + case EQP_COSTUME_HEAD_LOW: + type = 15; + break; + case EQP_COSTUME_GARMENT: + type = 16; + break; + dafault: + ShowWarning("unknown equip for char %d, item %d, slot %d, cards %d,%d,%d,%d\n", char_id, name_id, slot, (int)card0, (int)card1, (int)card2, (int)card3); + type = 0; + break; + } + + WFIFOHEAD (fd, 19); + WFIFOW (fd, 0) = 0xb17; + WFIFOL (fd, 2) = char_id; + WFIFOB (fd, 6) = (unsigned char)type; + WFIFOW (fd, 7) = name_id; + WFIFOW (fd, 9) = 0; + WFIFOW (fd, 11) = card0; + WFIFOW (fd, 13) = card1; + WFIFOW (fd, 15) = card2; + WFIFOW (fd, 17) = card3; + WFIFOSET (fd, 19); + + //ShowWarning("char %d, item %d, slot %d->%d, cards %d,%d,%d,%d\n", char_id, name_id, slot, type, (int)card0, (int)card1, (int)card2, (int)card3); + } + + SQL->StmtFree(stmt); +} diff --git a/src/echar/char.h b/src/echar/char.h index 60cf223..27994ba 100644 --- a/src/echar/char.h +++ b/src/echar/char.h @@ -14,4 +14,16 @@ void echar_parse_change_paassword(int fd); void echar_parse_login_password_change_ack(int charFd); +void echar_mmo_char_send099d_post(int *fdPtr, struct char_session_data *sd); + +int echar_mmo_char_send_characters_post(int retVal, int *fdPtr, struct char_session_data *sd); + +int echar_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf); + +void echar_mmo_char_send099d(int *fdPtr, struct char_session_data *sd); + +int echar_mmo_char_send_characters(int retVal, int *fdPtr, struct char_session_data* sd); + +void send_additional_slots(int fd, struct char_session_data* sd); + #endif // EVOL_CHAR_CHAR diff --git a/src/echar/init.c b/src/echar/init.c index 4083d17..0fa8c62 100644 --- a/src/echar/init.c +++ b/src/echar/init.c @@ -65,6 +65,9 @@ HPExport void plugin_init (void) addHookPre("chr->parse_char_create_new_char", echar_parse_char_create_new_char); addHookPre("chr->creation_failed", echar_creation_failed); + + addHookPost("chr->mmo_char_send099d", echar_mmo_char_send099d); + addHookPost("chr->mmo_char_send_characters", echar_mmo_char_send_characters); } HPExport void server_preinit (void) diff --git a/src/emap/pc.c b/src/emap/pc.c index feb1980..96bc074 100644 --- a/src/emap/pc.c +++ b/src/emap/pc.c @@ -93,19 +93,6 @@ void epc_equipitem_pos(TBL_PC *sd, struct item_data *id, int *nPtr, int *posPtr) } pc->calcweapontype(sd); eclif_changelook2(&sd->bl, LOOK_WEAPON, sd->status.weapon, id, n); - if (sd->status.weapon) - { - for (int i = 0; i < id->slot; i++ ) - { - struct item_data *data; - if (!sd->status.inventory[n].card[i]) - continue; - if ((data = itemdb->exists(sd->status.inventory[n].card[i])) != NULL) - { - ShowWarning("equip: for pos %d card %d\n", LOOK_WEAPON, data->nameid); - } - } - } } if (pos & (EQP_HAND_L|EQP_SHADOW_SHIELD)) { @@ -128,19 +115,6 @@ void epc_equipitem_pos(TBL_PC *sd, struct item_data *id, int *nPtr, int *posPtr) } pc->calcweapontype(sd); eclif_changelook2(&sd->bl, LOOK_SHIELD, sd->status.shield, id, n); - if (sd->status.shield) - { - for (int i = 0; i < id->slot; i++ ) - { - struct item_data *data; - if (!sd->status.inventory[n].card[i]) - continue; - if ((data = itemdb->exists(sd->status.inventory[n].card[i])) != NULL) - { - ShowWarning("equip: for pos %d card %d\n", LOOK_SHIELD, data->nameid); - } - } - } } equipPos(EQP_HEAD_LOW, head_bottom, LOOK_HEAD_BOTTOM); diff --git a/src/emap/send.c b/src/emap/send.c index 8c74d3b..a951ad6 100644 --- a/src/emap/send.c +++ b/src/emap/send.c @@ -82,6 +82,7 @@ void send_changelook(struct map_session_data* sd, struct map_session_data* sd2, struct item_data *data, int n) { struct SessionExt *tdata = session_get_bysd(sd2); + //ShowWarning("equip: for type %d = %d\n", type, val); if (!tdata || tdata->clientVersion < 9) { WFIFOHEAD (fd, 11); @@ -102,7 +103,6 @@ void send_changelook(struct map_session_data* sd, struct map_session_data* sd2, WFIFOW (fd, 9) = val2; if (data) { - //ShowWarning("equip: for type %d\n", type); for (int i = 0; i < data->slot; i++ ) { struct item_data *data; @@ -348,6 +348,7 @@ void send_client_command(TBL_PC *sd, const char *const command) void send_changelook2(struct map_session_data* sd, struct block_list *bl, int id, int type, int val, int val2, struct item_data *data, int n, enum send_target target) { + //ShowWarning("equip: for type %d = %d\n", type, val); unsigned char buf[32]; WBUFW(buf, 0) = 0x1d7; WBUFL(buf, 2) = id; |