mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
MenuChat Added (#25)
* Update CNShardServer.hpp * Update ChatManager.cpp * Update ChatManager.hpp Co-authored-by: CPunch <sethtstubbs@gmail.com>
This commit is contained in:
parent
cd9fb6ec25
commit
4f10ee0505
@ -6,12 +6,12 @@
|
|||||||
void ChatManager::init() {
|
void ChatManager::init() {
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_FREECHAT_MESSAGE, chatHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_FREECHAT_MESSAGE, chatHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT, emoteHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT, emoteHandler);
|
||||||
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_MENUCHAT_MESSAGE, menuChatHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatManager::chatHandler(CNSocket* sock, CNPacketData* data) {
|
void ChatManager::chatHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE))
|
if (data->size != sizeof(sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE*)data->buf;
|
sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE*)data->buf;
|
||||||
PlayerView plr = PlayerManager::players[sock];
|
PlayerView plr = PlayerManager::players[sock];
|
||||||
|
|
||||||
@ -31,7 +31,28 @@ void ChatManager::chatHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
otherSock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC), otherSock->getFEKey()));
|
otherSock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC), otherSock->getFEKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void ChatManager::menuChatHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
|
if (data->size != sizeof(sP_CL2FE_REQ_SEND_MENUCHAT_MESSAGE))
|
||||||
|
return; // malformed packet
|
||||||
|
sP_CL2FE_REQ_SEND_MENUCHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_MENUCHAT_MESSAGE*)data->buf;
|
||||||
|
PlayerView plr = PlayerManager::players[sock];
|
||||||
|
|
||||||
|
// send to client
|
||||||
|
sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC* resp = (sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC));
|
||||||
|
memcpy(resp->szFreeChat, chat->szFreeChat, sizeof(chat->szFreeChat));
|
||||||
|
resp->iPC_ID = PlayerManager::players[sock].plr.iID;
|
||||||
|
resp->iEmoteCode = chat->iEmoteCode;
|
||||||
|
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC), sock->getFEKey()));
|
||||||
|
|
||||||
|
// send to visible players
|
||||||
|
for (CNSocket* otherSock : plr.viewable) {
|
||||||
|
sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC* resp = (sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC));
|
||||||
|
memcpy(resp->szFreeChat, chat->szFreeChat, sizeof(chat->szFreeChat));
|
||||||
|
resp->iPC_ID = PlayerManager::players[sock].plr.iID;
|
||||||
|
resp->iEmoteCode = chat->iEmoteCode;
|
||||||
|
otherSock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC), otherSock->getFEKey()));
|
||||||
|
}
|
||||||
|
}
|
||||||
void ChatManager::emoteHandler(CNSocket* sock, CNPacketData* data) {
|
void ChatManager::emoteHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT))
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT))
|
||||||
return; // ignore the malformed packet
|
return; // ignore the malformed packet
|
||||||
|
@ -8,6 +8,7 @@ namespace ChatManager {
|
|||||||
|
|
||||||
void chatHandler(CNSocket* sock, CNPacketData* data);
|
void chatHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void emoteHandler(CNSocket* sock, CNPacketData* data);
|
void emoteHandler(CNSocket* sock, CNPacketData* data);
|
||||||
|
void menuChatHandler(CNSocket* sock, CNPacketData* data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user