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.

128 lines
3.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef DATATABLE_SEND_ENG_H
  8. #define DATATABLE_SEND_ENG_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "dt_send.h"
  13. #include "bitbuf.h"
  14. #include "utlmemory.h"
  15. typedef unsigned int CRC32_t;
  16. class CStandardSendProxies;
  17. #define MAX_DELTABITS_SIZE 2048
  18. // ------------------------------------------------------------------------ //
  19. // SendTable functions.
  20. // ------------------------------------------------------------------------ //
  21. // Precalculate data that enables the SendTable to be used to encode data.
  22. bool SendTable_Init( SendTable **pTables, int nTables );
  23. void SendTable_Term();
  24. CRC32_t SendTable_GetCRC();
  25. int SendTable_GetNum();
  26. SendTable *SendTabe_GetTable(int index);
  27. // Return the number of unique properties in the table.
  28. int SendTable_GetNumFlatProps( SendTable *pTable );
  29. // compares properties and writes delta properties
  30. int SendTable_WriteAllDeltaProps(
  31. const SendTable *pTable,
  32. const void *pFromData,
  33. const int nFromDataBits,
  34. const void *pToData,
  35. const int nToDataBits,
  36. const int nObjectID,
  37. bf_write *pBufOut );
  38. // Write the properties listed in pCheckProps and nCheckProps.
  39. void SendTable_WritePropList(
  40. const SendTable *pTable,
  41. const void *pState,
  42. const int nBits,
  43. bf_write *pOut,
  44. const int objectID,
  45. const int *pCheckProps,
  46. const int nCheckProps
  47. );
  48. //
  49. // Writes the property indices that must be written to move from pFromState to pToState into pDeltaProps.
  50. // Returns the number of indices written to pDeltaProps.
  51. //
  52. int SendTable_CalcDelta(
  53. const SendTable *pTable,
  54. const void *pFromState,
  55. const int nFromBits,
  56. const void *pToState,
  57. const int nToBits,
  58. int *pDeltaProps,
  59. int nMaxDeltaProps,
  60. const int objectID );
  61. // This function takes the list of property indices in startProps and the values from
  62. // SendProxies in pProxyResults, and fills in a new array in outProps with the properties
  63. // that the proxies want to allow for iClient's client.
  64. //
  65. // If pOldStateProxies is non-null, this function adds new properties into the output list
  66. // if a proxy has turned on from the previous state.
  67. int SendTable_CullPropsFromProxies(
  68. const SendTable *pTable,
  69. const int *pStartProps,
  70. int nStartProps,
  71. const int iClient,
  72. const CSendProxyRecipients *pOldStateProxies,
  73. const int nOldStateProxies,
  74. const CSendProxyRecipients *pNewStateProxies,
  75. const int nNewStateProxies,
  76. int *pOutProps,
  77. int nMaxOutProps
  78. );
  79. // Encode the properties that are referenced in the delta bits.
  80. // If pDeltaBits is NULL, then all the properties are encoded.
  81. bool SendTable_Encode(
  82. const SendTable *pTable,
  83. const void *pStruct,
  84. bf_write *pOut,
  85. int objectID = -1,
  86. CUtlMemory<CSendProxyRecipients> *pRecipients = NULL, // If non-null, this is an array of CSendProxyRecipients.
  87. // The array must have room for pTable->GetNumDataTableProxies().
  88. bool bNonZeroOnly = false // If this is true, then it will write all properties that have
  89. // nonzero values.
  90. );
  91. // In order to receive a table, you must send it from the server and receive its info
  92. // on the client so the client knows how to unpack it.
  93. bool SendTable_WriteInfos( SendTable *pTable, bf_write *pBuf );
  94. // do all kinds of checks on a packed entity bitbuffer
  95. bool SendTable_CheckIntegrity( SendTable *pTable, const void *pData, const int nDataBits );
  96. #endif // DATATABLE_SEND_ENG_H