void Session::HandlePrivateMessage(ChatClientPrivateMessage* data) { Session* S = SearchForSession(data->receiver); if(S == NULL) { Send(ChatErrorMessage(CHAT_ERROR_RECEIVER_NOT_FOUND)); return; } else if(S->GetCharacter()->GetGuid() == m_char->GetGuid()) { Send(ChatErrorMessage(CHAT_ERROR_INTERIOR_MONOLOGUE)); return; } else if(S->GetBoolValue(BOOL_AWAY) || S->IsEnnemyWith(m_data[FLAG_GUID].intValue) || S->IsIgnoredWith(m_data[FLAG_GUID].intValue) || (S->GetBoolValue(BOOL_INVISIBLE) && !S->IsFriendWith(m_data[FLAG_GUID].intValue))) { std::vector<std::string> args; args.push_back(S->GetCharacter()->GetName()); Send(TextInformationMessage(1, 14, args)); return; } ChatServerMessage* distant = NULL; ChatServerCopyMessage* local = NULL; time_t t = time(NULL); if(data->GetOpcode() == CMSG_CHAT_CLIENT_PRIVATE) { distant = new ChatServerMessage(PSEUDO_CHANNEL_PRIVATE, data->content, static_cast<int>(t), "", m_char->GetGuid(), m_char->GetName(), m_data[FLAG_GUID].intValue); local = new ChatServerCopyMessage(PSEUDO_CHANNEL_PRIVATE, data->content, static_cast<int>(t), "", S->GetCharacter()->GetGuid(), S->GetCharacter()->GetName()); } else if(data->GetOpcode() == CMSG_CHAT_CLIENT_PRIVATE_WITH_OBJECT) { distant = new ChatServerWithObjectMessage(PSEUDO_CHANNEL_PRIVATE, data->content, static_cast<int>(t), "", m_char->GetGuid(), m_char->GetName(), m_data[FLAG_GUID].intValue, ((ChatClientPrivateWithObjectMessage*)data)->objects); local = new ChatServerCopyWithObjectMessage(PSEUDO_CHANNEL_PRIVATE, data->content, static_cast<int>(t), "", S->GetCharacter()->GetGuid(), S->GetCharacter()->GetName(), ((ChatClientPrivateWithObjectMessage*)data)->objects); } else return; S->Send(*distant); Send(*local); delete distant; delete local; }