Cleaned up whisper code between map-servers (#2763)

Fixes #2760
Fixes #2762

Thanks to @LunarSHINING
This commit is contained in:
Lemongrass3110
2018-01-24 18:33:09 +01:00
committed by GitHub
parent c4a57c571c
commit 3a8c8a9da4
5 changed files with 77 additions and 67 deletions

View File

@@ -6445,8 +6445,13 @@ void clif_upgrademessage(int fd, int result, unsigned short item_id)
/// Whisper is transmitted to the destination player (ZC_WHISPER).
/// 0097 <packet len>.W <nick>.24B <message>.?B
/// 0097 <packet len>.W <nick>.24B <isAdmin>.L <message>.?B (PACKETVER >= 20091104)
void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len)
{
void clif_wis_message(struct map_session_data* sd, const char* nick, const char* mes, int mes_len, int gmlvl){
int fd;
nullpo_retv(sd);
fd = sd->fd;
#if PACKETVER < 20091104
WFIFOHEAD(fd, mes_len + NAME_LENGTH + 4);
WFIFOW(fd,0) = 0x97;
@@ -6461,7 +6466,11 @@ void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len)
WFIFOW(fd,0) = 0x97;
WFIFOW(fd,2) = mes_len + NAME_LENGTH + 8;
safestrncpy(WFIFOCP(fd,4), nick, NAME_LENGTH);
WFIFOL(fd,28) = (ssd && pc_get_group_level(ssd) == 99) ? 1 : 0; // isAdmin; if nonzero, also displays text above char
// If it is not a message from the server or a player from another map-server
if( ssd ){
gmlvl = pc_get_group_level(ssd);
}
WFIFOL(fd, 28) = (gmlvl == 99) ? 1 : 0; // isAdmin; if nonzero, also displays text above char
safestrncpy(WFIFOCP(fd,32), mes, mes_len);
WFIFOSET(fd,WFIFOW(fd,2));
#endif
@@ -11222,7 +11231,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
// if there are 'Test' player on an other map-server and 'test' player on this map-server,
// and if we ask for 'Test', we must not contact 'test' player
// so, we send information to inter-server, which is the only one which decide (and copy correct name).
intif_wis_message(sd, target, message, strlen(message));
intif_wis_message(sd, target, message, strlen(message) + 1);
return;
}
@@ -11238,7 +11247,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
// if player is autotrading
if (dstsd->state.autotrade == 1){
safesnprintf(output,sizeof(output),"%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name);
clif_wis_message(fd, wisp_server_name, output, strlen(output) + 1);
clif_wis_message(sd, wisp_server_name, output, strlen(output) + 1, 0);
return;
}
@@ -11255,7 +11264,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
clif_wis_end(fd, 0); // 0: success to send wisper
// Normal message
clif_wis_message(dstsd->fd, sd->status.name, message, strlen(message)+1 );
clif_wis_message(dstsd, sd->status.name, message, strlen(message)+1, 0);
}