1.1 --- a/core/MenuStyle_Radio.cpp Mon Jan 07 09:09:14 2013 -0500
1.2 +++ b/core/MenuStyle_Radio.cpp Tue Jan 22 21:43:12 2013 -0500
1.3 @@ -39,6 +39,14 @@
1.4 #endif
1.5 #include "logic_bridge.h"
1.6
1.7 +#ifdef USE_PROTOBUF_USERMESSAGES
1.8 +#include <google/protobuf/descriptor.h>
1.9 +#endif
1.10 +
1.11 +#if SOURCE_ENGINE == SE_CSGO
1.12 +#include <game/shared/csgo/protobuf/cstrike15_usermessages.pb.h>
1.13 +#endif
1.14 +
1.15 extern const char *g_RadioNumTable[];
1.16 CRadioStyle g_RadioMenuStyle;
1.17 int g_ShowMenuId = -1;
1.18 @@ -155,13 +163,22 @@
1.19 static unsigned int g_last_client_count = 0;
1.20 static int g_last_clients[256];
1.21
1.22 +#ifdef USE_PROTOBUF_USERMESSAGES
1.23 +void CRadioStyle::OnUserMessage(int msg_id, protobuf::Message &msg, IRecipientFilter *pFilter)
1.24 +#else
1.25 void CRadioStyle::OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter)
1.26 +#endif
1.27 {
1.28 int count = pFilter->GetRecipientCount();
1.29 +
1.30 +#ifdef USE_PROTOBUF_USERMESSAGES
1.31 + int c = ((CCSUsrMsg_ShowMenu &)msg).display_time();
1.32 +#else
1.33 bf_read br(bf->GetBasePointer(), 3);
1.34
1.35 br.ReadWord();
1.36 int c = br.ReadChar();
1.37 +#endif
1.38
1.39 g_last_holdtime = (c == -1) ? 0 : (unsigned)c;
1.40
1.41 @@ -472,6 +489,15 @@
1.42 time = menuHoldTime - (unsigned int)(gpGlobals->curtime - menuStartTime);
1.43 }
1.44
1.45 +#ifdef USE_PROTOBUF_USERMESSAGES
1.46 + // If or when we need to support multiple games per engine with this, we can switch to reflection
1.47 + // TODO: find what happens past 240 on CS:GO
1.48 + CCSUsrMsg_ShowMenu *msg = (CCSUsrMsg_ShowMenu *)g_UserMsgs.StartProtobufMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS);
1.49 + msg->set_bits_valid_slots(display_keys);
1.50 + msg->set_display_time(time);
1.51 + msg->set_menu_string(ptr);
1.52 + g_UserMsgs.EndMessage();
1.53 +#else
1.54 while (true)
1.55 {
1.56 if (len > 240)
1.57 @@ -479,7 +505,8 @@
1.58 save = ptr[240];
1.59 ptr[240] = '\0';
1.60 }
1.61 - bf_write *buffer = g_UserMsgs.StartMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS);
1.62 +
1.63 + bf_write *buffer = g_UserMsgs.StartBitBufMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS);
1.64 buffer->WriteWord(display_keys);
1.65 buffer->WriteChar(time ? time : -1);
1.66 buffer->WriteByte( (len > 240) ? 1 : 0 );
1.67 @@ -496,6 +523,7 @@
1.68 break;
1.69 }
1.70 }
1.71 +#endif
1.72
1.73 display_last_refresh = gpGlobals->curtime;
1.74 }