Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

917 lines
21 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef NETMESSAGES_H
  7. #define NETMESSAGES_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #pragma warning(disable : 4100) // unreferenced formal parameter
  11. #endif
  12. #include <inetmessage.h>
  13. #include <checksum_crc.h>
  14. #include <checksum_md5.h>
  15. #include <const.h>
  16. #include <utlvector.h>
  17. #include "qlimits.h"
  18. #include "mathlib/vector.h"
  19. #include <soundflags.h>
  20. #include <bitbuf.h>
  21. #include <inetchannel.h>
  22. #include "protocol.h"
  23. #include <inetmsghandler.h>
  24. #include <igameevents.h>
  25. #include <bitvec.h>
  26. #include <engine/iserverplugin.h>
  27. #include <Color.h>
  28. #include "proto_version.h"
  29. #if !defined( _X360 )
  30. #include "xbox/xboxstubs.h"
  31. #endif
  32. class SendTable;
  33. class KeyValue;
  34. class KeyValues;
  35. class INetMessageHandler;
  36. class IServerMessageHandler;
  37. class IClientMessageHandler;
  38. #define DECLARE_BASE_MESSAGE( msgtype ) \
  39. public: \
  40. bool ReadFromBuffer( bf_read &buffer ); \
  41. bool WriteToBuffer( bf_write &buffer ); \
  42. const char *ToString() const; \
  43. int GetType() const { return msgtype; } \
  44. const char *GetName() const { return #msgtype;}\
  45. #define DECLARE_NET_MESSAGE( name ) \
  46. DECLARE_BASE_MESSAGE( net_##name ); \
  47. INetMessageHandler *m_pMessageHandler; \
  48. bool Process() { return m_pMessageHandler->Process##name( this ); }\
  49. #define DECLARE_SVC_MESSAGE( name ) \
  50. DECLARE_BASE_MESSAGE( svc_##name ); \
  51. IServerMessageHandler *m_pMessageHandler;\
  52. bool Process() { return m_pMessageHandler->Process##name( this ); }\
  53. #define DECLARE_CLC_MESSAGE( name ) \
  54. DECLARE_BASE_MESSAGE( clc_##name ); \
  55. IClientMessageHandler *m_pMessageHandler;\
  56. bool Process() { return m_pMessageHandler->Process##name( this ); }\
  57. #define DECLARE_MM_MESSAGE( name ) \
  58. DECLARE_BASE_MESSAGE( mm_##name ); \
  59. IMatchmakingMessageHandler *m_pMessageHandler;\
  60. bool Process() { return m_pMessageHandler->Process##name( this ); }\
  61. class CNetMessage : public INetMessage
  62. {
  63. public:
  64. CNetMessage() { m_bReliable = true;
  65. m_NetChannel = NULL; }
  66. virtual ~CNetMessage() {};
  67. virtual int GetGroup() const { return INetChannelInfo::GENERIC; }
  68. INetChannel *GetNetChannel() const { return m_NetChannel; }
  69. virtual void SetReliable( bool state) {m_bReliable = state;};
  70. virtual bool IsReliable() const { return m_bReliable; };
  71. virtual void SetNetChannel(INetChannel * netchan) { m_NetChannel = netchan; }
  72. virtual bool Process() { Assert( 0 ); return false; }; // no handler set
  73. protected:
  74. bool m_bReliable; // true if message should be send reliable
  75. INetChannel *m_NetChannel; // netchannel this message is from/for
  76. };
  77. ///////////////////////////////////////////////////////////////////////////////////////
  78. // bidirectional net messages:
  79. ///////////////////////////////////////////////////////////////////////////////////////
  80. class NET_SetConVar : public CNetMessage
  81. {
  82. DECLARE_NET_MESSAGE( SetConVar );
  83. int GetGroup() const { return INetChannelInfo::STRINGCMD; }
  84. NET_SetConVar() {}
  85. NET_SetConVar( const char * name, const char * value)
  86. {
  87. cvar_t localCvar;
  88. Q_strncpy( localCvar.name, name, MAX_OSPATH );
  89. Q_strncpy( localCvar.value, value, MAX_OSPATH );
  90. m_ConVars.AddToTail( localCvar );
  91. }
  92. public:
  93. typedef struct cvar_s
  94. {
  95. char name[MAX_OSPATH];
  96. char value[MAX_OSPATH];
  97. } cvar_t;
  98. CUtlVector<cvar_t> m_ConVars;
  99. };
  100. class NET_StringCmd : public CNetMessage
  101. {
  102. DECLARE_NET_MESSAGE( StringCmd );
  103. int GetGroup() const { return INetChannelInfo::STRINGCMD; }
  104. NET_StringCmd() { m_szCommand = NULL; };
  105. NET_StringCmd(const char *cmd) { m_szCommand = cmd; };
  106. public:
  107. const char *m_szCommand; // execute this command
  108. private:
  109. char m_szCommandBuffer[1024]; // buffer for received messages
  110. };
  111. class NET_Tick : public CNetMessage
  112. {
  113. DECLARE_NET_MESSAGE( Tick );
  114. NET_Tick()
  115. {
  116. m_bReliable = false;
  117. #if PROTOCOL_VERSION > 10
  118. m_flHostFrameTime = 0;
  119. m_flHostFrameTimeStdDeviation = 0;
  120. #endif
  121. };
  122. NET_Tick( int tick, float hostFrametime, float hostFrametime_stddeviation )
  123. {
  124. m_bReliable = false;
  125. m_nTick = tick;
  126. #if PROTOCOL_VERSION > 10
  127. m_flHostFrameTime = hostFrametime;
  128. m_flHostFrameTimeStdDeviation = hostFrametime_stddeviation;
  129. #else
  130. NOTE_UNUSED( hostFrametime );
  131. NOTE_UNUSED( hostFrametime_stddeviation );
  132. #endif
  133. };
  134. public:
  135. int m_nTick;
  136. #if PROTOCOL_VERSION > 10
  137. float m_flHostFrameTime;
  138. float m_flHostFrameTimeStdDeviation;
  139. #endif
  140. };
  141. class NET_SignonState : public CNetMessage
  142. {
  143. DECLARE_NET_MESSAGE( SignonState );
  144. int GetGroup() const { return INetChannelInfo::SIGNON; }
  145. NET_SignonState() {};
  146. NET_SignonState( int state, int spawncount ) { m_nSignonState = state; m_nSpawnCount = spawncount; };
  147. public:
  148. int m_nSignonState; // See SIGNONSTATE_ defines
  149. int m_nSpawnCount; // server spawn count (session number)
  150. };
  151. ///////////////////////////////////////////////////////////////////////////////////////
  152. // Client messages:
  153. ///////////////////////////////////////////////////////////////////////////////////////
  154. class CLC_ClientInfo : public CNetMessage
  155. {
  156. DECLARE_CLC_MESSAGE( ClientInfo );
  157. public:
  158. CRC32_t m_nSendTableCRC;
  159. int m_nServerCount;
  160. bool m_bIsHLTV;
  161. #if defined( REPLAY_ENABLED )
  162. bool m_bIsReplay;
  163. #endif
  164. uint32 m_nFriendsID;
  165. char m_FriendsName[MAX_PLAYER_NAME_LENGTH];
  166. CRC32_t m_nCustomFiles[MAX_CUSTOM_FILES];
  167. };
  168. class CLC_Move : public CNetMessage
  169. {
  170. DECLARE_CLC_MESSAGE( Move );
  171. int GetGroup() const { return INetChannelInfo::MOVE; }
  172. CLC_Move() { m_bReliable = false; }
  173. public:
  174. int m_nBackupCommands;
  175. int m_nNewCommands;
  176. int m_nLength;
  177. bf_read m_DataIn;
  178. bf_write m_DataOut;
  179. };
  180. class CLC_VoiceData : public CNetMessage
  181. {
  182. DECLARE_CLC_MESSAGE( VoiceData );
  183. int GetGroup() const { return INetChannelInfo::VOICE; }
  184. CLC_VoiceData() { m_bReliable = false; };
  185. public:
  186. int m_nLength;
  187. bf_read m_DataIn;
  188. bf_write m_DataOut;
  189. uint64 m_xuid;
  190. };
  191. class CLC_BaselineAck : public CNetMessage
  192. {
  193. DECLARE_CLC_MESSAGE( BaselineAck );
  194. CLC_BaselineAck() {};
  195. CLC_BaselineAck(int tick, int baseline ) { m_nBaselineTick = tick; m_nBaselineNr = baseline; }
  196. int GetGroup() const { return INetChannelInfo::ENTITIES; }
  197. public:
  198. int m_nBaselineTick; // sequence number of baseline
  199. int m_nBaselineNr; // 0 or 1
  200. };
  201. class CLC_ListenEvents : public CNetMessage
  202. {
  203. DECLARE_CLC_MESSAGE( ListenEvents );
  204. int GetGroup() const { return INetChannelInfo::SIGNON; }
  205. public:
  206. CBitVec<MAX_EVENT_NUMBER> m_EventArray;
  207. };
  208. #if defined( REPLAY_ENABLED )
  209. class CLC_SaveReplay : public CNetMessage
  210. {
  211. DECLARE_CLC_MESSAGE( SaveReplay );
  212. CLC_SaveReplay() {}
  213. int m_nStartSendByte;
  214. char m_szFilename[ MAX_OSPATH ];
  215. float m_flPostDeathRecordTime;
  216. };
  217. #endif
  218. class CLC_RespondCvarValue : public CNetMessage
  219. {
  220. public:
  221. DECLARE_CLC_MESSAGE( RespondCvarValue );
  222. QueryCvarCookie_t m_iCookie;
  223. const char *m_szCvarName;
  224. const char *m_szCvarValue; // The sender sets this, and it automatically points it at m_szCvarNameBuffer when receiving.
  225. EQueryCvarValueStatus m_eStatusCode;
  226. private:
  227. char m_szCvarNameBuffer[256];
  228. char m_szCvarValueBuffer[256];
  229. };
  230. class CLC_FileCRCCheck : public CNetMessage
  231. {
  232. public:
  233. DECLARE_CLC_MESSAGE( FileCRCCheck );
  234. char m_szPathID[MAX_PATH];
  235. char m_szFilename[MAX_PATH];
  236. MD5Value_t m_MD5;
  237. CRC32_t m_CRCIOs;
  238. int m_eFileHashType;
  239. int m_cbFileLen;
  240. int m_nPackFileNumber;
  241. int m_PackFileID;
  242. int m_nFileFraction;
  243. };
  244. class CLC_FileMD5Check : public CNetMessage
  245. {
  246. public:
  247. DECLARE_CLC_MESSAGE( FileMD5Check );
  248. char m_szPathID[MAX_PATH];
  249. char m_szFilename[MAX_PATH];
  250. MD5Value_t m_MD5;
  251. };
  252. class Base_CmdKeyValues : public CNetMessage
  253. {
  254. protected:
  255. explicit Base_CmdKeyValues( KeyValues *pKeyValues = NULL ); // takes ownership
  256. ~Base_CmdKeyValues();
  257. public:
  258. KeyValues * GetKeyValues() const { return m_pKeyValues; }
  259. public:
  260. bool ReadFromBuffer( bf_read &buffer );
  261. bool WriteToBuffer( bf_write &buffer );
  262. const char * ToString() const;
  263. protected:
  264. KeyValues *m_pKeyValues;
  265. };
  266. class CLC_CmdKeyValues : public Base_CmdKeyValues
  267. {
  268. public:
  269. DECLARE_CLC_MESSAGE( CmdKeyValues );
  270. public:
  271. explicit CLC_CmdKeyValues( KeyValues *pKeyValues = NULL ); // takes ownership
  272. };
  273. class SVC_CmdKeyValues : public Base_CmdKeyValues
  274. {
  275. public:
  276. DECLARE_SVC_MESSAGE( CmdKeyValues );
  277. public:
  278. explicit SVC_CmdKeyValues( KeyValues *pKeyValues = NULL ); // takes ownership
  279. };
  280. ///////////////////////////////////////////////////////////////////////////////////////
  281. // server messages:
  282. ///////////////////////////////////////////////////////////////////////////////////////
  283. class SVC_Print : public CNetMessage
  284. {
  285. DECLARE_SVC_MESSAGE( Print );
  286. SVC_Print() { m_bReliable = false; m_szText = NULL; };
  287. SVC_Print(const char * text) { m_bReliable = false; m_szText = text; };
  288. public:
  289. const char *m_szText; // show this text
  290. private:
  291. char m_szTextBuffer[2048]; // buffer for received messages
  292. };
  293. class SVC_ServerInfo : public CNetMessage
  294. {
  295. DECLARE_SVC_MESSAGE( ServerInfo );
  296. int GetGroup() const { return INetChannelInfo::SIGNON; }
  297. public: // member vars are public for faster handling
  298. int m_nProtocol; // protocol version
  299. int m_nServerCount; // number of changelevels since server start
  300. bool m_bIsDedicated; // dedicated server ?
  301. bool m_bIsHLTV; // HLTV server ?
  302. #if defined( REPLAY_ENABLED )
  303. bool m_bIsReplay; // Replay server ?
  304. #endif
  305. char m_cOS; // L = linux, W = Win32
  306. CRC32_t m_nMapCRC; // server map CRC (only used by older demos)
  307. MD5Value_t m_nMapMD5; // server map MD5
  308. int m_nMaxClients; // max number of clients on server
  309. int m_nMaxClasses; // max number of server classes
  310. int m_nPlayerSlot; // our client slot number
  311. float m_fTickInterval;// server tick interval
  312. const char *m_szGameDir; // game directory eg "tf2"
  313. const char *m_szMapName; // name of current map
  314. const char *m_szSkyName; // name of current skybox
  315. const char *m_szHostName; // server name
  316. private:
  317. char m_szGameDirBuffer[MAX_OSPATH];// game directory eg "tf2"
  318. char m_szMapNameBuffer[MAX_OSPATH];// name of current map
  319. char m_szSkyNameBuffer[MAX_OSPATH];// name of current skybox
  320. char m_szHostNameBuffer[MAX_OSPATH];// name of current skybox
  321. };
  322. class SVC_SendTable : public CNetMessage
  323. {
  324. DECLARE_SVC_MESSAGE( SendTable );
  325. int GetGroup() const { return INetChannelInfo::SIGNON; }
  326. public:
  327. bool m_bNeedsDecoder;
  328. int m_nLength;
  329. bf_read m_DataIn;
  330. bf_write m_DataOut;
  331. };
  332. class SVC_ClassInfo : public CNetMessage
  333. {
  334. DECLARE_SVC_MESSAGE( ClassInfo );
  335. int GetGroup() const { return INetChannelInfo::SIGNON; }
  336. SVC_ClassInfo() {};
  337. SVC_ClassInfo( bool createFromSendTables, int numClasses )
  338. { m_bCreateOnClient = createFromSendTables;
  339. m_nNumServerClasses = numClasses; };
  340. public:
  341. typedef struct class_s
  342. {
  343. int classID;
  344. char datatablename[256];
  345. char classname[256];
  346. } class_t;
  347. bool m_bCreateOnClient; // if true, client creates own SendTables & classinfos from game.dll
  348. CUtlVector<class_t> m_Classes;
  349. int m_nNumServerClasses;
  350. };
  351. class SVC_SetPause : public CNetMessage
  352. {
  353. DECLARE_SVC_MESSAGE( SetPause );
  354. SVC_SetPause() {}
  355. SVC_SetPause( bool state, float end = -1.f ) { m_bPaused = state; }
  356. public:
  357. bool m_bPaused; // true or false, what else
  358. };
  359. class SVC_SetPauseTimed : public CNetMessage
  360. {
  361. DECLARE_SVC_MESSAGE( SetPauseTimed );
  362. SVC_SetPauseTimed() {}
  363. SVC_SetPauseTimed( bool bState, float flExpireTime = -1.f ) { m_bPaused = bState; m_flExpireTime = flExpireTime; }
  364. public:
  365. bool m_bPaused;
  366. float m_flExpireTime;
  367. };
  368. class CNetworkStringTable;
  369. class SVC_CreateStringTable : public CNetMessage
  370. {
  371. DECLARE_SVC_MESSAGE( CreateStringTable );
  372. int GetGroup() const { return INetChannelInfo::SIGNON; }
  373. public:
  374. SVC_CreateStringTable();
  375. public:
  376. const char *m_szTableName;
  377. int m_nMaxEntries;
  378. int m_nNumEntries;
  379. bool m_bUserDataFixedSize;
  380. int m_nUserDataSize;
  381. int m_nUserDataSizeBits;
  382. bool m_bIsFilenames;
  383. int m_nLength;
  384. bf_read m_DataIn;
  385. bf_write m_DataOut;
  386. bool m_bDataCompressed;
  387. private:
  388. char m_szTableNameBuffer[256];
  389. };
  390. class SVC_UpdateStringTable : public CNetMessage
  391. {
  392. DECLARE_SVC_MESSAGE( UpdateStringTable );
  393. int GetGroup() const { return INetChannelInfo::STRINGTABLE; }
  394. public:
  395. int m_nTableID; // table to be updated
  396. int m_nChangedEntries; // number of how many entries has changed
  397. int m_nLength; // data length in bits
  398. bf_read m_DataIn;
  399. bf_write m_DataOut;
  400. };
  401. // SVC_VoiceInit
  402. // v2 - 2017/02/07
  403. // - Can detect v2 packets by nLegacyQuality == 255 and presence of additional nSampleRate field.
  404. // - Added nSampleRate field. Previously, nSampleRate was hard-coded per codec type. ::ReadFromBuffer does a
  405. // one-time conversion of these old types (which can no longer change)
  406. // - Marked quality field as deprecated. This was already being ignored. v2 clients send 255
  407. // - Prior to this the sv_use_steam_voice convar was used to switch to steam voice. With this, we properly set
  408. // szVoiceCodec to "steam". See ::ReadFromBuffer for shim to fallback to the convar for old streams.
  409. // - We no longer pass "svc_voiceinit NULL" as szVoiceCodec if it is not selected, just the empty string. Nothing
  410. // used this that I could find.
  411. class SVC_VoiceInit : public CNetMessage
  412. {
  413. DECLARE_SVC_MESSAGE( VoiceInit );
  414. int GetGroup() const { return INetChannelInfo::SIGNON; }
  415. SVC_VoiceInit()
  416. : m_nSampleRate( 0 )
  417. {
  418. V_memset( m_szVoiceCodec, 0, sizeof( m_szVoiceCodec ) );
  419. }
  420. SVC_VoiceInit( const char * codec, int nSampleRate )
  421. : m_nSampleRate( nSampleRate )
  422. {
  423. V_strncpy( m_szVoiceCodec, codec ? codec : "", sizeof( m_szVoiceCodec ) );
  424. }
  425. public:
  426. // Used voice codec for voice_init.
  427. //
  428. // This used to be a DLL name, then became a whitelisted list of codecs.
  429. char m_szVoiceCodec[MAX_OSPATH];
  430. // DEPRECATED:
  431. //
  432. // This field used to be a custom quality setting, but it was not honored for a long time: codecs use their own
  433. // pre-configured quality settings. We never sent anything besides 5, which was then ignored for some codecs.
  434. //
  435. // New clients always set 255 here, old clients probably send 5. This could be re-purposed in the future, but beware
  436. // that very old demos may have non-5 values. It would take more archaeology to determine how to properly interpret
  437. // those packets -- they're probably using settings we simply don't support any longer.
  438. //
  439. // int m_nQuality;
  440. // The sample rate we are using
  441. int m_nSampleRate;
  442. };
  443. class SVC_VoiceData : public CNetMessage
  444. {
  445. DECLARE_SVC_MESSAGE( VoiceData );
  446. int GetGroup() const { return INetChannelInfo::VOICE; }
  447. SVC_VoiceData() { m_bReliable = false; }
  448. public:
  449. int m_nFromClient; // client who has spoken
  450. bool m_bProximity;
  451. int m_nLength; // data length in bits
  452. uint64 m_xuid; // X360 player ID
  453. bf_read m_DataIn;
  454. void *m_DataOut;
  455. };
  456. class SVC_Sounds : public CNetMessage
  457. {
  458. DECLARE_SVC_MESSAGE( Sounds );
  459. int GetGroup() const { return INetChannelInfo::SOUNDS; }
  460. public:
  461. bool m_bReliableSound;
  462. int m_nNumSounds;
  463. int m_nLength;
  464. bf_read m_DataIn;
  465. bf_write m_DataOut;
  466. };
  467. class SVC_Prefetch : public CNetMessage
  468. {
  469. DECLARE_SVC_MESSAGE( Prefetch );
  470. int GetGroup() const { return INetChannelInfo::SOUNDS; }
  471. enum
  472. {
  473. SOUND = 0,
  474. };
  475. public:
  476. unsigned short m_fType;
  477. unsigned short m_nSoundIndex;
  478. };
  479. class SVC_SetView : public CNetMessage
  480. {
  481. DECLARE_SVC_MESSAGE( SetView );
  482. SVC_SetView() {}
  483. SVC_SetView( int entity ) { m_nEntityIndex = entity; }
  484. public:
  485. int m_nEntityIndex;
  486. };
  487. class SVC_FixAngle: public CNetMessage
  488. {
  489. DECLARE_SVC_MESSAGE( FixAngle );
  490. SVC_FixAngle() { m_bReliable = false; };
  491. SVC_FixAngle( bool bRelative, QAngle angle )
  492. { m_bReliable = false; m_bRelative = bRelative; m_Angle = angle; }
  493. public:
  494. bool m_bRelative;
  495. QAngle m_Angle;
  496. };
  497. class SVC_CrosshairAngle : public CNetMessage
  498. {
  499. DECLARE_SVC_MESSAGE( CrosshairAngle );
  500. SVC_CrosshairAngle() {}
  501. SVC_CrosshairAngle( QAngle angle ) { m_Angle = angle; }
  502. public:
  503. QAngle m_Angle;
  504. };
  505. class SVC_BSPDecal : public CNetMessage
  506. {
  507. DECLARE_SVC_MESSAGE( BSPDecal );
  508. public:
  509. Vector m_Pos;
  510. int m_nDecalTextureIndex;
  511. int m_nEntityIndex;
  512. int m_nModelIndex;
  513. bool m_bLowPriority;
  514. };
  515. class SVC_GameEvent : public CNetMessage
  516. {
  517. DECLARE_SVC_MESSAGE( GameEvent );
  518. int GetGroup() const { return INetChannelInfo::EVENTS; }
  519. public:
  520. int m_nLength; // data length in bits
  521. bf_read m_DataIn;
  522. bf_write m_DataOut;
  523. };
  524. class SVC_UserMessage: public CNetMessage
  525. {
  526. DECLARE_SVC_MESSAGE( UserMessage );
  527. SVC_UserMessage() { m_bReliable = false; }
  528. int GetGroup() const { return INetChannelInfo::USERMESSAGES; }
  529. public:
  530. int m_nMsgType;
  531. int m_nLength; // data length in bits
  532. bf_read m_DataIn;
  533. bf_write m_DataOut;
  534. };
  535. class SVC_EntityMessage : public CNetMessage
  536. {
  537. DECLARE_SVC_MESSAGE( EntityMessage );
  538. SVC_EntityMessage() { m_bReliable = false; }
  539. int GetGroup() const { return INetChannelInfo::ENTMESSAGES ; }
  540. public:
  541. int m_nEntityIndex;
  542. int m_nClassID;
  543. int m_nLength; // data length in bits
  544. bf_read m_DataIn;
  545. bf_write m_DataOut;
  546. };
  547. /* class SVC_SpawnBaseline: public CNetMessage
  548. {
  549. DECLARE_SVC_MESSAGE( SpawnBaseline );
  550. int GetGroup() const { return INetChannelInfo::SIGNON; }
  551. public:
  552. int m_nEntityIndex;
  553. int m_nClassID;
  554. int m_nLength;
  555. bf_read m_DataIn;
  556. bf_write m_DataOut;
  557. }; */
  558. class SVC_PacketEntities: public CNetMessage
  559. {
  560. DECLARE_SVC_MESSAGE( PacketEntities );
  561. int GetGroup() const { return INetChannelInfo::ENTITIES ; }
  562. public:
  563. int m_nMaxEntries;
  564. int m_nUpdatedEntries;
  565. bool m_bIsDelta;
  566. bool m_bUpdateBaseline;
  567. int m_nBaseline;
  568. int m_nDeltaFrom;
  569. int m_nLength;
  570. bf_read m_DataIn;
  571. bf_write m_DataOut;
  572. };
  573. class SVC_TempEntities: public CNetMessage
  574. {
  575. DECLARE_SVC_MESSAGE( TempEntities );
  576. SVC_TempEntities() { m_bReliable = false; }
  577. int GetGroup() const { return INetChannelInfo::EVENTS; }
  578. int m_nNumEntries;
  579. int m_nLength;
  580. bf_read m_DataIn;
  581. bf_write m_DataOut;
  582. };
  583. class SVC_Menu : public CNetMessage
  584. {
  585. public:
  586. DECLARE_SVC_MESSAGE( Menu );
  587. SVC_Menu() { m_bReliable = true; m_Type = DIALOG_MENU; m_MenuKeyValues = NULL; };
  588. SVC_Menu( DIALOG_TYPE type, KeyValues *data );
  589. ~SVC_Menu();
  590. KeyValues *m_MenuKeyValues;
  591. DIALOG_TYPE m_Type;
  592. int m_iLength;
  593. };
  594. class SVC_GameEventList : public CNetMessage
  595. {
  596. public:
  597. DECLARE_SVC_MESSAGE( GameEventList );
  598. int m_nNumEvents;
  599. int m_nLength;
  600. bf_read m_DataIn;
  601. bf_write m_DataOut;
  602. };
  603. ///////////////////////////////////////////////////////////////////////////////////////
  604. // Matchmaking messages:
  605. ///////////////////////////////////////////////////////////////////////////////////////
  606. class MM_Heartbeat : public CNetMessage
  607. {
  608. public:
  609. DECLARE_MM_MESSAGE( Heartbeat );
  610. };
  611. class MM_ClientInfo : public CNetMessage
  612. {
  613. public:
  614. DECLARE_MM_MESSAGE( ClientInfo );
  615. XNADDR m_xnaddr; // xbox net address
  616. uint64 m_id; // machine ID
  617. uint64 m_xuids[MAX_PLAYERS_PER_CLIENT];
  618. byte m_cVoiceState[MAX_PLAYERS_PER_CLIENT];
  619. bool m_bInvited;
  620. char m_cPlayers;
  621. char m_iControllers[MAX_PLAYERS_PER_CLIENT];
  622. char m_iTeam[MAX_PLAYERS_PER_CLIENT];
  623. char m_szGamertags[MAX_PLAYERS_PER_CLIENT][MAX_PLAYER_NAME_LENGTH];
  624. };
  625. class MM_RegisterResponse : public CNetMessage
  626. {
  627. public:
  628. DECLARE_MM_MESSAGE( RegisterResponse );
  629. };
  630. class MM_Mutelist : public CNetMessage
  631. {
  632. public:
  633. DECLARE_MM_MESSAGE( Mutelist );
  634. uint64 m_id;
  635. byte m_cPlayers;
  636. byte m_cRemoteTalkers[MAX_PLAYERS_PER_CLIENT];
  637. XUID m_xuid[MAX_PLAYERS_PER_CLIENT];
  638. byte m_cMuted[MAX_PLAYERS_PER_CLIENT];
  639. CUtlVector< XUID > m_Muted[MAX_PLAYERS_PER_CLIENT];
  640. };
  641. class MM_Checkpoint : public CNetMessage
  642. {
  643. public:
  644. DECLARE_MM_MESSAGE( Checkpoint );
  645. enum eCheckpoint
  646. {
  647. CHECKPOINT_CHANGETEAM,
  648. CHECKPOINT_GAME_LOBBY,
  649. CHECKPOINT_PREGAME,
  650. CHECKPOINT_LOADING_COMPLETE,
  651. CHECKPOINT_CONNECT,
  652. CHECKPOINT_SESSION_DISCONNECT,
  653. CHECKPOINT_REPORT_STATS,
  654. CHECKPOINT_REPORTING_COMPLETE,
  655. CHECKPOINT_POSTGAME,
  656. };
  657. byte m_Checkpoint;
  658. };
  659. // NOTE: The following messages are not network-endian compliant, due to the
  660. // transmission of structures instead of their component parts
  661. class MM_JoinResponse : public CNetMessage
  662. {
  663. public:
  664. DECLARE_MM_MESSAGE( JoinResponse );
  665. MM_JoinResponse()
  666. {
  667. m_ContextCount = 0;
  668. m_PropertyCount = 0;
  669. }
  670. enum
  671. {
  672. JOINRESPONSE_APPROVED,
  673. JOINRESPONSE_APPROVED_JOINGAME,
  674. JOINRESPONSE_SESSIONFULL,
  675. JOINRESPONSE_NOTHOSTING,
  676. JOINRESPONSE_MODIFY_SESSION,
  677. };
  678. uint m_ResponseType;
  679. // host info
  680. uint64 m_id; // Host's machine ID
  681. uint64 m_Nonce; // Session nonce
  682. uint m_SessionFlags;
  683. uint m_nOwnerId;
  684. int m_iTeam;
  685. int m_nTotalTeams;
  686. int m_PropertyCount;
  687. int m_ContextCount;
  688. CUtlVector< XUSER_PROPERTY >m_SessionProperties;
  689. CUtlVector< XUSER_CONTEXT >m_SessionContexts;
  690. };
  691. class MM_Migrate : public CNetMessage
  692. {
  693. public:
  694. DECLARE_MM_MESSAGE( Migrate );
  695. enum eMsgType
  696. {
  697. MESSAGE_HOSTING,
  698. MESSAGE_MIGRATED,
  699. MESSAGE_STANDBY,
  700. };
  701. byte m_MsgType;
  702. uint64 m_Id;
  703. XNKID m_sessionId;
  704. XNADDR m_xnaddr;
  705. XNKEY m_key;
  706. };
  707. class SVC_GetCvarValue : public CNetMessage
  708. {
  709. public:
  710. DECLARE_SVC_MESSAGE( GetCvarValue );
  711. QueryCvarCookie_t m_iCookie;
  712. const char *m_szCvarName; // The sender sets this, and it automatically points it at m_szCvarNameBuffer when receiving.
  713. private:
  714. char m_szCvarNameBuffer[256];
  715. };
  716. #endif // NETMESSAGES_H