Fixed a crash in message formatter.
The code would fail if a message is sent to a player not yet added to a world.
This commit is contained in:
parent
dff71823d4
commit
10273f64a2
@ -234,7 +234,8 @@ void cProtocol172::SendChat(const cCompositeChat & a_Message)
|
||||
|
||||
// Compose the complete Json string to send:
|
||||
Json::Value msg;
|
||||
msg["text"] = cClientHandle::FormatMessageType(m_Client->GetPlayer()->GetWorld()->ShouldUseChatPrefixes(), a_Message.GetMessageType(), a_Message.GetAdditionalMessageTypeData()); // The client crashes without this field being present
|
||||
cWorld * World = m_Client->GetPlayer()->GetWorld();
|
||||
msg["text"] = cClientHandle::FormatMessageType((World == NULL) ? false : World->ShouldUseChatPrefixes(), a_Message.GetMessageType(), a_Message.GetAdditionalMessageTypeData()); // The client crashes without this field being present
|
||||
const cCompositeChat::cParts & Parts = a_Message.GetParts();
|
||||
for (cCompositeChat::cParts::const_iterator itr = Parts.begin(), end = Parts.end(); itr != end; ++itr)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user