| 550 | } |
| 551 | |
| 552 | bool CHalfLife2::TextMsg(int client, int dest, const char *msg) |
| 553 | { |
| 554 | #ifndef USE_PROTOBUF_USERMESSAGES |
| 555 | bf_write *pBitBuf = NULL; |
| 556 | #endif |
| 557 | cell_t players[] = {client}; |
| 558 | |
| 559 | if (dest == HUD_PRINTTALK) |
| 560 | { |
| 561 | const char *chat_saytext = g_pGameConf->GetKeyValue("ChatSayText"); |
| 562 | |
| 563 | /* Use SayText user message instead */ |
| 564 | if (chat_saytext != NULL && strcmp(chat_saytext, "yes") == 0) |
| 565 | { |
| 566 | char buffer[253]; |
| 567 | ke::SafeSprintf(buffer, sizeof(buffer), "%s\1\n", msg); |
| 568 | |
| 569 | #if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV |
| 570 | CCSUsrMsg_SayText *pMsg; |
| 571 | if ((pMsg = (CCSUsrMsg_SayText *)g_UserMsgs.StartProtobufMessage(m_SayTextMsg, players, 1, USERMSG_RELIABLE)) == NULL) |
| 572 | { |
| 573 | return false; |
| 574 | } |
| 575 | |
| 576 | pMsg->set_ent_idx(0); |
| 577 | pMsg->set_text(buffer); |
| 578 | pMsg->set_chat(false); |
| 579 | #else |
| 580 | if ((pBitBuf = g_UserMsgs.StartBitBufMessage(m_SayTextMsg, players, 1, USERMSG_RELIABLE)) == NULL) |
| 581 | { |
| 582 | return false; |
| 583 | } |
| 584 | |
| 585 | pBitBuf->WriteByte(0); |
| 586 | pBitBuf->WriteString(buffer); |
| 587 | pBitBuf->WriteByte(1); |
| 588 | #endif |
| 589 | |
| 590 | g_UserMsgs.EndMessage(); |
| 591 | |
| 592 | return true; |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | #if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV |
| 597 | CCSUsrMsg_TextMsg *pMsg; |
| 598 | if ((pMsg = (CCSUsrMsg_TextMsg *)g_UserMsgs.StartProtobufMessage(m_MsgTextMsg, players, 1, USERMSG_RELIABLE)) == NULL) |
| 599 | { |
| 600 | return false; |
| 601 | } |
| 602 | |
| 603 | // Client tries to read all 5 'params' and will crash if less |
| 604 | pMsg->set_msg_dst(dest); |
| 605 | pMsg->add_params(msg); |
| 606 | pMsg->add_params(""); |
| 607 | pMsg->add_params(""); |
| 608 | pMsg->add_params(""); |
| 609 | pMsg->add_params(""); |
no test coverage detected