core/HalfLife2.cpp
changeset 3855 d8ba5eddf543
parent 3854 8abb0924497b
child 3864 f73dc11e87f5
     1.1 --- a/core/HalfLife2.cpp	Tue Mar 19 11:19:19 2013 -0400
     1.2 +++ b/core/HalfLife2.cpp	Tue Mar 19 11:19:38 2013 -0400
     1.3 @@ -42,7 +42,9 @@
     1.4  #include "logic_bridge.h"
     1.5  #include <tier0/mem.h>
     1.6  
     1.7 -#if SOURCE_ENGINE == SE_CSGO
     1.8 +#if SOURCE_ENGINE == SE_DOTA
     1.9 +#include <game/shared/protobuf/usermessages.pb.h>
    1.10 +#elif SOURCE_ENGINE == SE_CSGO
    1.11  #include <cstrike15_usermessages.pb.h>
    1.12  #endif
    1.13  
    1.14 @@ -512,7 +514,7 @@
    1.15  
    1.16  bool CHalfLife2::TextMsg(int client, int dest, const char *msg)
    1.17  {
    1.18 -#if SOURCE_ENGINE != SE_CSGO
    1.19 +#ifndef USE_PROTOBUF_USERMESSAGES
    1.20  	bf_write *pBitBuf = NULL;
    1.21  #endif
    1.22  	cell_t players[] = {client};
    1.23 @@ -527,7 +529,17 @@
    1.24  			char buffer[192];
    1.25  			UTIL_Format(buffer, sizeof(buffer), "%s\1\n", msg);
    1.26  
    1.27 -#if SOURCE_ENGINE == SE_CSGO
    1.28 +#if SOURCE_ENGINE == SE_DOTA
    1.29 +			CUserMsg_SayText *pMsg;
    1.30 +			if ((pMsg = (CUserMsg_SayText *)g_UserMsgs.StartProtobufMessage(m_SayTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
    1.31 +			{
    1.32 +				return false;
    1.33 +			}
    1.34 +
    1.35 +			pMsg->set_client(0);
    1.36 +			pMsg->set_text(buffer);
    1.37 +			pMsg->set_chat(false);
    1.38 +#elif SOURCE_ENGINE == SE_CSGO
    1.39  			CCSUsrMsg_SayText *pMsg;
    1.40  			if ((pMsg = (CCSUsrMsg_SayText *)g_UserMsgs.StartProtobufMessage(m_SayTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
    1.41  			{
    1.42 @@ -554,7 +566,20 @@
    1.43  		}
    1.44  	}
    1.45  
    1.46 -#if SOURCE_ENGINE == SE_CSGO
    1.47 +#if SOURCE_ENGINE == SE_DOTA
    1.48 +	CUserMsg_TextMsg *pMsg;
    1.49 +	if ((pMsg = (CUserMsg_TextMsg *)g_UserMsgs.StartProtobufMessage(m_MsgTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
    1.50 +	{
    1.51 +		return false;
    1.52 +	}
    1.53 +
    1.54 +	pMsg->set_dest(dest);
    1.55 +	pMsg->add_param(msg);
    1.56 +	pMsg->add_param("");
    1.57 +	pMsg->add_param("");
    1.58 +	pMsg->add_param("");
    1.59 +	pMsg->add_param("");
    1.60 +#elif SOURCE_ENGINE == SE_CSGO
    1.61  	CCSUsrMsg_TextMsg *pMsg;
    1.62  	if ((pMsg = (CCSUsrMsg_TextMsg *)g_UserMsgs.StartProtobufMessage(m_MsgTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
    1.63  	{
    1.64 @@ -587,7 +612,15 @@
    1.65  {
    1.66  	cell_t players[] = {client};
    1.67  
    1.68 -#if SOURCE_ENGINE == SE_CSGO
    1.69 +#if SOURCE_ENGINE == SE_DOTA
    1.70 +	CUserMsg_HintText *pMsg;
    1.71 +	if ((pMsg = (CUserMsg_HintText *)g_UserMsgs.StartProtobufMessage(m_HinTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
    1.72 +	{
    1.73 +		return false;
    1.74 +	}
    1.75 +
    1.76 +	pMsg->set_message(msg);
    1.77 +#elif SOURCE_ENGINE == SE_CSGO
    1.78  	CCSUsrMsg_HintText *pMsg;
    1.79  	if ((pMsg = (CCSUsrMsg_HintText *)g_UserMsgs.StartProtobufMessage(m_HinTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
    1.80  	{
    1.81 @@ -617,7 +650,15 @@
    1.82  
    1.83  bool CHalfLife2::HintTextMsg(cell_t *players, int count, const char *msg)
    1.84  {
    1.85 -#if SOURCE_ENGINE == SE_CSGO
    1.86 +#if SOURCE_ENGINE == SE_DOTA
    1.87 +	CUserMsg_HintText *pMsg;
    1.88 +	if ((pMsg = (CUserMsg_HintText *)g_UserMsgs.StartProtobufMessage(m_HinTextMsg, players, count, USERMSG_RELIABLE)) == NULL)
    1.89 +	{
    1.90 +		return false;
    1.91 +	}
    1.92 +
    1.93 +	pMsg->set_message(msg);
    1.94 +#elif SOURCE_ENGINE == SE_CSGO
    1.95  	CCSUsrMsg_HintText *pMsg;
    1.96  	if ((pMsg = (CCSUsrMsg_HintText *)g_UserMsgs.StartProtobufMessage(m_HinTextMsg, players, count, USERMSG_RELIABLE)) == NULL)
    1.97  	{
    1.98 @@ -652,7 +693,13 @@
    1.99  	int count = 0;
   1.100  	cell_t players[] = {client};
   1.101  
   1.102 -#if SOURCE_ENGINE == SE_CSGO
   1.103 +#if SOURCE_ENGINE == SE_DOTA
   1.104 +	CUserMsg_VGUIMenu *pMsg;
   1.105 +	if ((pMsg = (CUserMsg_VGUIMenu *)g_UserMsgs.StartProtobufMessage(m_VGUIMenu, players, 1, USERMSG_RELIABLE)) == NULL)
   1.106 +	{
   1.107 +		return false;
   1.108 +	}
   1.109 +#elif SOURCE_ENGINE == SE_CSGO
   1.110  	CCSUsrMsg_VGUIMenu *pMsg;
   1.111  	if ((pMsg = (CCSUsrMsg_VGUIMenu *)g_UserMsgs.StartProtobufMessage(m_VGUIMenu, players, 1, USERMSG_RELIABLE)) == NULL)
   1.112  	{
   1.113 @@ -677,7 +724,18 @@
   1.114  		SubKey = data->GetFirstSubKey();
   1.115  	}
   1.116  
   1.117 -#if SOURCE_ENGINE == SE_CSGO
   1.118 +#if SOURCE_ENGINE == SE_DOTA
   1.119 +	pMsg->set_name(name);
   1.120 +	pMsg->set_show(show);
   1.121 +
   1.122 +	while (SubKey)
   1.123 +	{
   1.124 +		CUserMsg_VGUIMenu_Keys *key = pMsg->add_keys();
   1.125 +		key->set_name(SubKey->GetName());
   1.126 +		key->set_value(SubKey->GetString());
   1.127 +		SubKey = SubKey->GetNextKey();
   1.128 +	}
   1.129 +#elif SOURCE_ENGINE == SE_CSGO
   1.130  	pMsg->set_name(name);
   1.131  	pMsg->set_show(show);
   1.132