Commit 96442947 authored by mercury233's avatar mercury233

update chat handling

parent 738a2bf7
......@@ -916,16 +916,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
const wchar_t* input = mainGame->ebChatInput->getText();
if(input[0]) {
unsigned short msgbuf[256];
if(mainGame->dInfo.isStarted) {
if(mainGame->dInfo.player_type < 7) {
if(mainGame->dInfo.isTag && (mainGame->dInfo.player_type % 2))
mainGame->AddChatMsg((wchar_t*)input, 2);
else
mainGame->AddChatMsg((wchar_t*)input, 0);
} else
mainGame->AddChatMsg((wchar_t*)input, 10);
} else
mainGame->AddChatMsg((wchar_t*)input, 7);
int len = BufferIO::CopyWStr(input, msgbuf, 256);
DuelClient::SendBufferToServer(CTOS_CHAT, msgbuf, (len + 1) * sizeof(short));
mainGame->ebChatInput->setText(L"");
......
......@@ -27,17 +27,10 @@ void SingleDuel::Chat(DuelPlayer* dp, void* pdata, int len) {
scc.player = dp->type;
unsigned short* msg = (unsigned short*)pdata;
int msglen = BufferIO::CopyWStr(msg, scc.msg, 256);
if(dp->type > 1) {
NetServer::SendBufferToPlayer(players[0], STOC_CHAT, &scc, 4 + msglen * 2);
NetServer::ReSendToPlayer(players[1]);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
if((*pit) != dp)
NetServer::ReSendToPlayer(*pit);
} else {
NetServer::SendBufferToPlayer(players[1 - dp->type], STOC_CHAT, &scc, 4 + msglen * 2);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
NetServer::SendBufferToPlayer(players[0], STOC_CHAT, &scc, 4 + msglen * 2);
NetServer::ReSendToPlayer(players[1]);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
void SingleDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
if(!is_creater) {
......
......@@ -24,8 +24,9 @@ void TagDuel::Chat(DuelPlayer* dp, void* pdata, int len) {
unsigned short* msg = (unsigned short*)pdata;
int msglen = BufferIO::CopyWStr(msg, scc.msg, 256);
for(int i = 0; i < 4; ++i)
if(players[i] != dp)
NetServer::SendBufferToPlayer(players[i], STOC_CHAT, &scc, 4 + msglen * 2);
NetServer::SendBufferToPlayer(players[i], STOC_CHAT, &scc, 4 + msglen * 2);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
void TagDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
if(!is_creater) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment