diff options
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 212 |
1 files changed, 131 insertions, 81 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index e68028d9d..496a8beda 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9382,82 +9382,98 @@ static void clif_send_selforarea(int fd, struct block_list *bl, const void *buf, } } -/// Updates the object's (bl) name on client. -/// 0095 <id>.L <char name>.24B (ZC_ACK_REQNAME) -/// 0195 <id>.L <char name>.24B <party name>.24B <guild name>.24B <position name>.24B (ZC_ACK_REQNAMEALL) -/// 0A30 <id>.L <char name>.24B <party name>.24B <guild name>.24B <position name>.24B <title id>.L (ZC_ACK_REQNAMEALL2) +/** + * Updates a character's name on client. + * + * @code + * 0095 <id>.L <char name>.24B (ZC_ACK_REQNAME) + * 0195 <id>.L <char name>.24B <party name>.24B <guild name>.24B <position name>.24B (ZC_ACK_REQNAMEALL) + * 0A30 <id>.L <char name>.24B <party name>.24B <guild name>.24B <position name>.24B <title id>.L (ZC_ACK_REQNAMEALL2) + * @endcode + * + * @param fd The incoming file descriptor. + * @param bl The related character's block list. + * + **/ static void clif_pcname_ack(int fd, struct block_list *bl) { nullpo_retv(bl); Assert_retv(bl->type == BL_PC); - struct PACKET_ZC_ACK_REQNAMEALL packet = { 0 }; - int len = sizeof(struct PACKET_ZC_ACK_REQNAMEALL); + struct PACKET_ZC_ACK_REQNAMEALL packet = {0}; + packet.packet_id = HEADER_ZC_ACK_REQNAMEALL; packet.gid = bl->id; const struct map_session_data *ssd = BL_UCCAST(BL_PC, bl); - if (ssd->fakename[0] != '\0') { - packet.packet_id = reqName; - len = sizeof(struct packet_reqname_ack); - } else { - packet.packet_id = HEADER_ZC_ACK_REQNAMEALL; - len = sizeof(struct PACKET_ZC_ACK_REQNAMEALL); - } - - //Requesting your own "shadow" name. [Skotlex] - if (ssd->fd == fd && ssd->disguise != -1) { + if (ssd->fd == fd && ssd->disguise != -1) // Requesting your own "shadow" name. packet.gid = -bl->id; - } - if (ssd->fakename[0] != '\0') { + if (ssd->fakename[0] != '\0') memcpy(packet.name, ssd->fakename, NAME_LENGTH); - } else { -#if PACKETVER_MAIN_NUM >= 20150225 || PACKETVER_RE_NUM >= 20141126 || defined(PACKETVER_ZERO) - // Title System [Dastgir/Hercules] - if (ssd->status.title_id > 0) { - packet.title_id = ssd->status.title_id; - } -#endif + else memcpy(packet.name, ssd->status.name, NAME_LENGTH); - const struct party_data *p = NULL; - int ps = -1; - if (ssd->status.party_id != 0) { - p = party->search(ssd->status.party_id); - } - const struct guild *g = NULL; - if (ssd->status.guild_id != 0) { - if ((g = ssd->guild) != NULL) { - int i; - ARR_FIND(0, g->max_member, i, g->member[i].account_id == ssd->status.account_id && g->member[i].char_id == ssd->status.char_id); - if (i < g->max_member) - ps = g->member[i].position; - } - } + const struct party_data *p = NULL; - if (!battle_config.display_party_name && g == NULL) { - // do not display party unless the player is also in a guild - p = NULL; - } + if (ssd->status.party_id != 0) + p = party->search(ssd->status.party_id); + + const struct guild *g = NULL; + int pos_idx = INDEX_NOT_FOUND; + + if (ssd->status.guild_id != 0 && (g = ssd->guild) != NULL) { + int i; + int acc_id = ssd->status.account_id; + int chr_id = ssd->status.char_id; - if (p != NULL) { + ARR_FIND(0, g->max_member, i, g->member[i].account_id == acc_id && g->member[i].char_id == chr_id); + + if (i < g->max_member) + pos_idx = g->member[i].position; + } + + if (battle_config.display_party_name == 0 && g == NULL) + p = NULL; // Do not display party name, unless the character is also in a guild. + + if (p != NULL) { + if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_PARTYNAME) != 0) + || ssd->fakename[0] == '\0') { memcpy(packet.party_name, p->party.name, NAME_LENGTH); } + } - if (g != NULL && ps >= 0 && ps < MAX_GUILDPOSITION) { + if (g != NULL && pos_idx >= 0 && pos_idx < MAX_GUILDPOSITION) { + if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_GUILDNAME) != 0) + || ssd->fakename[0] == '\0') { memcpy(packet.guild_name, g->name,NAME_LENGTH); - memcpy(packet.position_name, g->position[ps].name, NAME_LENGTH); } - else if (ssd->status.clan_id != 0) { - struct clan *c = clan->search(ssd->status.clan_id); - if (c != 0) { + + if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_GUILDPOSITION) != 0) + || ssd->fakename[0] == '\0') { + memcpy(packet.position_name, g->position[pos_idx].name, NAME_LENGTH); + } + } else if (ssd->status.clan_id != 0) { + struct clan *c = clan->search(ssd->status.clan_id); + + if (c != 0) { + if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_CLANPOSITION) != 0) + || ssd->fakename[0] == '\0') { memcpy(packet.position_name, c->name, NAME_LENGTH); } } } - clif->send_selforarea(fd, bl, &packet, len); +#if PACKETVER_MAIN_NUM >= 20150225 || PACKETVER_RE_NUM >= 20141126 || defined(PACKETVER_ZERO) // Title system. + if (ssd->status.title_id > 0) { + if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_TITLE) != 0) + || ssd->fakename[0] == '\0') { + packet.title_id = ssd->status.title_id; + } + } +#endif + + clif->send_selforarea(fd, bl, &packet, sizeof(struct PACKET_ZC_ACK_REQNAMEALL)); } /// Updates the object's (bl) name on client. @@ -9748,56 +9764,90 @@ static void clif_blname_ack(int fd, struct block_list *bl) } } -//Used to update when a char leaves a party/guild. [Skotlex] -//Needed because when you send a 0x95 packet, the client will not remove the cached party/guild info that is not sent. +/** + * Updates a character's name on client when leaving a party/guild. + * + * @code + * 0195 <id>.L <char name>.24B <party name>.24B <guild name>.24B <position name>.24B (ZC_ACK_REQNAMEALL) + * 0A30 <id>.L <char name>.24B <party name>.24B <guild name>.24B <position name>.24B <title id>.L (ZC_ACK_REQNAMEALL2) + * @endcode + * + * @param ssd The related character. + * + **/ static void clif_charnameupdate(struct map_session_data *ssd) { - int ps = -1; - struct party_data *p = NULL; - struct guild *g = NULL; - struct PACKET_ZC_ACK_REQNAMEALL packet = { 0 }; - nullpo_retv(ssd); - if (ssd->fakename[0]) - return; //No need to update as the party/guild was not displayed anyway. - + struct PACKET_ZC_ACK_REQNAMEALL packet = {0}; packet.packet_id = HEADER_ZC_ACK_REQNAMEALL; packet.gid = ssd->bl.id; - memcpy(packet.name, ssd->status.name, NAME_LENGTH); + if (ssd->fakename[0] != '\0') + memcpy(packet.name, ssd->fakename, NAME_LENGTH); + else + memcpy(packet.name, ssd->status.name, NAME_LENGTH); - if (!battle_config.display_party_name) { - if (ssd->status.party_id > 0 && ssd->status.guild_id > 0 && (g = ssd->guild) != NULL) - p = party->search(ssd->status.party_id); - } else { - if (ssd->status.party_id > 0) - p = party->search(ssd->status.party_id); - } + struct party_data *p = NULL; + + if (ssd->status.party_id != 0) + p = party->search(ssd->status.party_id); + + struct guild *g = NULL; + int pos_idx = INDEX_NOT_FOUND; - if (ssd->status.guild_id > 0 && (g = ssd->guild) != NULL) { + if (ssd->status.guild_id != 0 && (g = ssd->guild) != NULL) { int i; - ARR_FIND(0, g->max_member, i, g->member[i].account_id == ssd->status.account_id && g->member[i].char_id == ssd->status.char_id); - if( i < g->max_member ) ps = g->member[i].position; + int acc_id = ssd->status.account_id; + int chr_id = ssd->status.char_id; + + ARR_FIND(0, g->max_member, i, g->member[i].account_id == acc_id && g->member[i].char_id == chr_id); + + if (i < g->max_member) + pos_idx = g->member[i].position; } - if (p != NULL) - memcpy(packet.party_name, p->party.name, NAME_LENGTH); + if (battle_config.display_party_name == 0 && g == NULL) + p = NULL; // Do not display party name, unless the character is also in a guild. - if (g != NULL && ps >= 0 && ps < MAX_GUILDPOSITION) { - memcpy(packet.guild_name, g->name,NAME_LENGTH); - memcpy(packet.position_name, g->position[ps].name, NAME_LENGTH); + if (p != NULL) { + if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_PARTYNAME) != 0) + || ssd->fakename[0] == '\0') { + memcpy(packet.party_name, p->party.name, NAME_LENGTH); + } } -#if PACKETVER_MAIN_NUM >= 20150225 || PACKETVER_RE_NUM >= 20141126 || defined(PACKETVER_ZERO) - // Achievement System [Dastgir/Hercules] + if (g != NULL && pos_idx >= 0 && pos_idx < MAX_GUILDPOSITION) { + if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_GUILDNAME) != 0) + || ssd->fakename[0] == '\0') { + memcpy(packet.guild_name, g->name,NAME_LENGTH); + } + + if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_GUILDPOSITION) != 0) + || ssd->fakename[0] == '\0') { + memcpy(packet.position_name, g->position[pos_idx].name, NAME_LENGTH); + } + } else if (ssd->status.clan_id != 0) { + struct clan *c = clan->search(ssd->status.clan_id); + + if (c != 0) { + if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_CLANPOSITION) != 0) + || ssd->fakename[0] == '\0') { + memcpy(packet.position_name, c->name, NAME_LENGTH); + } + } + } + +#if PACKETVER_MAIN_NUM >= 20150225 || PACKETVER_RE_NUM >= 20141126 || defined(PACKETVER_ZERO) // Title system. if (ssd->status.title_id > 0) { - packet.title_id = ssd->status.title_id; + if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_TITLE) != 0) + || ssd->fakename[0] == '\0') { + packet.title_id = ssd->status.title_id; + } } #endif - // Update nearby clients - clif->send(&packet, sizeof(packet), &ssd->bl, AREA); + clif->send(&packet, sizeof(packet), &ssd->bl, AREA); // Update nearby clients. } /// Taekwon Jump (TK_HIGHJUMP) effect (ZC_HIGHJUMP). |