From 1d6dc898128912105b40766e446a0408f32e2e6e Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 21 Feb 2020 03:36:52 +0100 Subject: Adjust clif_pcname_ack() function to always use PACKET_ZC_ACK_REQNAMEALL This fixes the issue, where not even the fake name shows up, when using @fakename in RE clients. --- src/map/clif.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 660c516d7..fd5bdc699 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9391,17 +9391,10 @@ static void clif_pcname_ack(int fd, struct block_list *bl) struct PACKET_ZC_ACK_REQNAMEALL packet = { 0 }; int len = sizeof(struct PACKET_ZC_ACK_REQNAMEALL); packet.gid = bl->id; + packet.packet_id = HEADER_ZC_ACK_REQNAMEALL; 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) { packet.gid = -bl->id; -- cgit v1.2.3-70-g09d2 From d65ebbe6b29af6223e588303bc4898a673c1c545 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 21 Feb 2020 05:24:15 +0100 Subject: Add enumeration for @fakename display option flags --- src/map/atcommand.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 66827b3b2..f3a5155ab 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -54,6 +54,16 @@ typedef enum { COMMAND_CHARCOMMAND = 2, } AtCommandType; +/** @fakename display option flags **/ +enum fakename_option_flag { + FAKENAME_OPTION_NONE = 0x00, + FAKENAME_OPTION_SHOW_PARTYNAME = 0x01, + FAKENAME_OPTION_SHOW_GUILDNAME = 0x02, + FAKENAME_OPTION_SHOW_GUILDPOSITION = 0x04, + FAKENAME_OPTION_SHOW_CLANPOSITION = 0x08, + FAKENAME_OPTION_SHOW_TITLE = 0x10 +}; + /** * Typedef **/ -- cgit v1.2.3-70-g09d2 From f86c32c9d61ca46135dd536635a3750681d1b6e5 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 21 Feb 2020 05:26:50 +0100 Subject: Implement display options in ACMD(fakename) function --- src/map/atcommand.c | 20 ++++++++++++++++++-- src/map/pc.h | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 707522423..cafe3e39f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -7856,6 +7856,7 @@ ACMD(fakename) if (sd->fakename[0]) { sd->fakename[0] = '\0'; + sd->fakename_options = FAKENAME_OPTION_NONE; clif->blname_ack(0, &sd->bl); if( sd->disguise ) clif->blname_ack(sd->fd, &sd->bl); @@ -7867,13 +7868,28 @@ ACMD(fakename) return false; } - if (strlen(message) < 2) + int options = FAKENAME_OPTION_NONE; + char buf[NAME_LENGTH] = {'\0'}; + const char *fake_name = NULL; + + if (sscanf(message, "%d %23[^\n]", &options, buf) == 2) { + fake_name = buf; + } else { + options = FAKENAME_OPTION_NONE; + fake_name = message; + } + + if (strlen(fake_name) < 2) { clif->message(sd->fd, msg_fd(fd,1309)); // Fake name must be at least two characters. return false; } - safestrncpy(sd->fakename, message, sizeof(sd->fakename)); + if (options < FAKENAME_OPTION_NONE) + options = FAKENAME_OPTION_NONE; + + safestrncpy(sd->fakename, fake_name, sizeof(sd->fakename)); + sd->fakename_options = options; clif->blname_ack(0, &sd->bl); if (sd->disguise) // Another packet should be sent so the client updates the name for sd clif->blname_ack(sd->fd, &sd->bl); diff --git a/src/map/pc.h b/src/map/pc.h index e940c3310..007c08f20 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -492,6 +492,7 @@ END_ZEROED_BLOCK; int change_level_3rd; // job level when changing from 2nd to 3rd class [jobchange_level_3rd in global_reg_value] char fakename[NAME_LENGTH]; // fake names [Valaris] + int fakename_options; // Fake name display options. int duel_group; // duel vars [LuzZza] int duel_invite; -- cgit v1.2.3-70-g09d2 From 77934e484d42ef95e5b744670fddbebae0d40265 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 21 Feb 2020 05:28:01 +0100 Subject: Implement display options in clif_pcname_ack() function --- src/map/clif.c | 70 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index fd5bdc699..7b711a52f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9400,48 +9400,64 @@ static void clif_pcname_ack(int fd, struct block_list *bl) packet.gid = -bl->id; } - if (ssd->fakename[0] != '\0') { + if (ssd->fakename[0] != '\0') memcpy(packet.name, ssd->fakename, NAME_LENGTH); - } else { + else + memcpy(packet.name, ssd->status.name, NAME_LENGTH); + #if PACKETVER_MAIN_NUM >= 20150225 || PACKETVER_RE_NUM >= 20141126 || defined(PACKETVER_ZERO) - // Title System [Dastgir/Hercules] - if (ssd->status.title_id > 0) { + // Title System [Dastgir/Hercules] + 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 - 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; + 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; } + } - if (!battle_config.display_party_name && g == NULL) { - // do not display party unless the player is also in a guild - 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 (p != NULL) { + 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 && ps >= 0 && ps < 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[ps].name, NAME_LENGTH); } - else if (ssd->status.clan_id != 0) { - struct clan *c = clan->search(ssd->status.clan_id); - if (c != 0) { + } + 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); } } -- cgit v1.2.3-70-g09d2 From c2807092020b94ef01694d3e3f770edb9d1da812 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 21 Feb 2020 05:28:32 +0100 Subject: Implement display options in clif_charnameupdate() function --- src/map/clif.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 7b711a52f..600bf6bd7 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9764,13 +9764,13 @@ static void clif_charnameupdate(struct map_session_data *ssd) nullpo_retv(ssd); - if (ssd->fakename[0]) - return; //No need to update as the party/guild was not displayed anyway. - 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) @@ -9786,18 +9786,41 @@ static void clif_charnameupdate(struct map_session_data *ssd) if( i < g->max_member ) ps = g->member[i].position; } - if (p != NULL) - memcpy(packet.party_name, p->party.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 (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 ((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[ps].name, NAME_LENGTH); + } + } else if (ssd->status.clan_id != 0) { + struct clan *c = clan->search(ssd->status.clan_id); + + if (c != NULL) { + 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) // Achievement System [Dastgir/Hercules] 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 -- cgit v1.2.3-70-g09d2 From 2d357188c0ff56234ad54d619ece7450ed8b247e Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 21 Feb 2020 05:41:57 +0100 Subject: Update doc/atcommands.txt --- doc/atcommands.txt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/atcommands.txt b/doc/atcommands.txt index 0cddc1680..65c3bb091 100644 --- a/doc/atcommands.txt +++ b/doc/atcommands.txt @@ -968,10 +968,19 @@ If no position is given, the command defaults to headgear. --------------------------------------- -@fakename {} - -Temporarily changes name to the specified string. -If no string is given, the character's real name will be re-applied. +@fakename {} {} + +Temporarily changes the character's name to . +If no parameter is passed, the character's real name will be re-applied. +The parameter is used, to modify which names will be displayed. +The fake name will always be displayed, regardless of . +Valid flags (combinable): + 0 - Only the fake name is displayed. (Default value.) + 1 - Display party name. + 2 - Display guild name. + 4 - Display guild position. + 8 - Display clan position. + 16 - Display title. --------------------------------------- -- cgit v1.2.3-70-g09d2 From 8a7dbf58b05fab38e45f8c538fd104a3b172b82a Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sat, 22 Feb 2020 00:08:06 +0100 Subject: Apply code style to ACMD(fakename) function --- src/map/atcommand.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index cafe3e39f..df851bbcc 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -7845,26 +7845,31 @@ ACMD(monsterignore) return true; } -/*========================================== - * @fakename - * => Gives your character a fake name. [Valaris] - *------------------------------------------*/ + +/** + * Temporarily changes the character's name to the specified string. + * + * @code{.herc} + * @fakename {} {} + * @endcode + * + **/ ACMD(fakename) { - if (!*message) - { - if (sd->fakename[0]) - { + if (*message == '\0') { + if (sd->fakename[0] != '\0') { sd->fakename[0] = '\0'; sd->fakename_options = FAKENAME_OPTION_NONE; clif->blname_ack(0, &sd->bl); - if( sd->disguise ) + + if (sd->disguise != 0) // Another packet should be sent so the client updates the name for sd. clif->blname_ack(sd->fd, &sd->bl); - clif->message(sd->fd, msg_fd(fd,1307)); // Returned to real name. + + clif->message(sd->fd, msg_fd(fd, 1307)); // Returned to real name. return true; } - clif->message(sd->fd, msg_fd(fd,1308)); // You must enter a name. + clif->message(sd->fd, msg_fd(fd, 1308)); // You must enter a name. return false; } @@ -7879,9 +7884,8 @@ ACMD(fakename) fake_name = message; } - if (strlen(fake_name) < 2) - { - clif->message(sd->fd, msg_fd(fd,1309)); // Fake name must be at least two characters. + if (strlen(fake_name) < 2) { + clif->message(sd->fd, msg_fd(fd, 1309)); // Fake name must be at least two characters. return false; } @@ -7891,9 +7895,11 @@ ACMD(fakename) safestrncpy(sd->fakename, fake_name, sizeof(sd->fakename)); sd->fakename_options = options; clif->blname_ack(0, &sd->bl); - if (sd->disguise) // Another packet should be sent so the client updates the name for sd + + if (sd->disguise != 0) // Another packet should be sent so the client updates the name for sd. clif->blname_ack(sd->fd, &sd->bl); - clif->message(sd->fd, msg_fd(fd,1310)); // Fake name enabled. + + clif->message(sd->fd, msg_fd(fd, 1310)); // Fake name enabled. return true; } -- cgit v1.2.3-70-g09d2 From b63dd3e64720e6a87264be6a6cbdef59a5eaa842 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sat, 22 Feb 2020 00:35:44 +0100 Subject: Apply code style to clif_pcname_ack() function --- src/map/clif.c | 85 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 600bf6bd7..cf7c31dcd 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9379,62 +9379,60 @@ static void clif_send_selforarea(int fd, struct block_list *bl, const void *buf, } } -/// Updates the object's (bl) name on client. -/// 0095 .L .24B (ZC_ACK_REQNAME) -/// 0195 .L .24B .24B .24B .24B (ZC_ACK_REQNAMEALL) -/// 0A30 .L .24B .24B .24B .24B .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); - packet.gid = bl->id; + 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); - //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') memcpy(packet.name, ssd->fakename, NAME_LENGTH); else memcpy(packet.name, ssd->status.name, NAME_LENGTH); -#if PACKETVER_MAIN_NUM >= 20150225 || PACKETVER_RE_NUM >= 20141126 || defined(PACKETVER_ZERO) - // Title System [Dastgir/Hercules] - 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 - const struct party_data *p = NULL; - int ps = -1; - if (ssd->status.party_id != 0) { + + 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; - } - } + int pos_idx = INDEX_NOT_FOUND; - 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.guild_id != 0 && (g = ssd->guild) != NULL) { + int i; + 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 (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') { @@ -9442,7 +9440,7 @@ static void clif_pcname_ack(int fd, struct block_list *bl) } } - 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); @@ -9450,11 +9448,11 @@ static void clif_pcname_ack(int fd, struct block_list *bl) if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_GUILDPOSITION) != 0) || ssd->fakename[0] == '\0') { - memcpy(packet.position_name, g->position[ps].name, NAME_LENGTH); + memcpy(packet.position_name, g->position[pos_idx].name, NAME_LENGTH); } - } - else if (ssd->status.clan_id != 0) { + } 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') { @@ -9463,7 +9461,16 @@ static void clif_pcname_ack(int fd, struct block_list *bl) } } - 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. -- cgit v1.2.3-70-g09d2 From 548a03ec3dafb0521dedd979e01027f0e8cf4177 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer <Kenpachi.Developer@gmx.de> Date: Sat, 22 Feb 2020 01:05:40 +0100 Subject: Apply code style to clif_charnameupdate() function --- src/map/clif.c | 59 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index cf7c31dcd..ddd364a75 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9760,17 +9760,22 @@ 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); + struct PACKET_ZC_ACK_REQNAMEALL packet = {0}; packet.packet_id = HEADER_ZC_ACK_REQNAMEALL; packet.gid = ssd->bl.id; @@ -9779,20 +9784,28 @@ static void clif_charnameupdate(struct map_session_data *ssd) 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); - if (ssd->status.guild_id > 0 && (g = ssd->guild) != NULL) { + struct guild *g = NULL; + int pos_idx = INDEX_NOT_FOUND; + + 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 (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') { @@ -9800,7 +9813,7 @@ static void clif_charnameupdate(struct map_session_data *ssd) } } - 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); @@ -9808,12 +9821,12 @@ static void clif_charnameupdate(struct map_session_data *ssd) if ((ssd->fakename[0] != '\0' && (ssd->fakename_options & FAKENAME_OPTION_SHOW_GUILDPOSITION) != 0) || ssd->fakename[0] == '\0') { - memcpy(packet.position_name, g->position[ps].name, NAME_LENGTH); + 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 != NULL) { + 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); @@ -9821,8 +9834,7 @@ static void clif_charnameupdate(struct map_session_data *ssd) } } -#if PACKETVER_MAIN_NUM >= 20150225 || PACKETVER_RE_NUM >= 20141126 || defined(PACKETVER_ZERO) - // Achievement System [Dastgir/Hercules] +#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') { @@ -9831,8 +9843,7 @@ static void clif_charnameupdate(struct map_session_data *ssd) } #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). -- cgit v1.2.3-70-g09d2