Counter Strike : Global Offensive Source Code
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.

127 lines
4.2 KiB

  1. //========= Copyright � 1996-2005, 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. #include "tier1/utlvector.h"
  16. #include "tier0/platform.h"
  17. typedef uint32 CRC32_t;
  18. class CStandardSendProxies;
  19. struct edict_t;
  20. typedef intp SerializedEntityHandle_t;
  21. #define MAX_DELTABITS_SIZE 2048
  22. // ------------------------------------------------------------------------ //
  23. // SendTable functions.
  24. // ------------------------------------------------------------------------ //
  25. // Precalculate data that enables the SendTable to be used to encode data.
  26. bool SendTable_Init( SendTable **pTables, int nTables );
  27. void SendTable_Term();
  28. CRC32_t SendTable_GetCRC();
  29. int SendTable_GetNum();
  30. SendTable *SendTabe_GetTable(int index);
  31. // Return the number of unique properties in the table.
  32. int SendTable_GetNumFlatProps( const SendTable *pTable );
  33. // compares properties and writes delta properties
  34. int SendTable_WriteAllDeltaProps(
  35. const SendTable *pTable,
  36. SerializedEntityHandle_t fromEntity, // Can be invalid
  37. SerializedEntityHandle_t toEntity,
  38. const int nObjectID,
  39. bf_write *pBufOut );
  40. //the buffer used to hold a list of delta changes between objects
  41. typedef CUtlVectorFixedGrowable< int, 128 > CalcDeltaResultsList_t;
  42. // Write the properties listed in pCheckProps and nCheckProps.
  43. void SendTable_WritePropList(
  44. const SendTable *pTable,
  45. SerializedEntityHandle_t toEntity,
  46. bf_write *pOut,
  47. const int objectID,
  48. CalcDeltaResultsList_t *pCheckProps // NULL == Send ALL!
  49. );
  50. //given an entity that has had a partial change, this will take the previous data block, and splice in the new values, setting new change fields to the specified tick for ones that have actually changed. This will
  51. //return false if a delta table is not applicable and instead a full pack needs to be done
  52. SerializedEntityHandle_t SendTable_BuildDeltaProperties( edict_t *pEdict, int nObjectID, const SendTable* pTable, SerializedEntityHandle_t OldProps,
  53. CalcDeltaResultsList_t &deltaProps, CUtlMemory<CSendProxyRecipients> *pRecipients, bool& bCanReuseOldData );
  54. //
  55. // Writes the property indices that must be written to move from pFromState to pToState into pDeltaProps.
  56. // Returns the number of indices written to pDeltaProps.
  57. //
  58. void SendTable_CalcDelta(
  59. const SendTable *pTable,
  60. SerializedEntityHandle_t fromEntity, // Can be invalid
  61. SerializedEntityHandle_t toEntity,
  62. const int objectID,
  63. CalcDeltaResultsList_t &deltaProps );
  64. // This function takes the list of property indices in startProps and the values from
  65. // SendProxies in pProxyResults, and fills in a new array in outProps with the properties
  66. // that the proxies want to allow for iClient's client.
  67. //
  68. // If pOldStateProxies is non-null, this function adds new properties into the output list
  69. // if a proxy has turned on from the previous state.
  70. int SendTable_CullPropsFromProxies(
  71. const SendTable *pTable,
  72. const CalcDeltaResultsList_t &startProps,
  73. const int iClient,
  74. const CSendProxyRecipients *pOldStateProxies,
  75. const int nOldStateProxies,
  76. const CSendProxyRecipients *pNewStateProxies,
  77. const int nNewStateProxies,
  78. CalcDeltaResultsList_t &outProps
  79. );
  80. // Encode the properties that are referenced in the delta bits.
  81. // If pDeltaBits is NULL, then all the properties are encoded.
  82. bool SendTable_Encode(
  83. const SendTable *pTable,
  84. SerializedEntityHandle_t handle,
  85. const void *pStruct,
  86. int objectID = -1,
  87. CUtlMemory<CSendProxyRecipients> *pRecipients = NULL // If non-null, this is an array of CSendProxyRecipients.
  88. // The array must have room for pTable->GetNumDataTableProxies().
  89. );
  90. // In order to receive a table, you must send it from the server and receive its info
  91. // on the client so the client knows how to unpack it.
  92. bool SendTable_WriteInfos( const SendTable *pTable, bf_write& bfWrite, bool bNeedsDecoder, bool bIsEnd );
  93. // do all kinds of checks on a packed entity bitbuffer
  94. bool SendTable_CheckIntegrity( SendTable *pTable, const void *pData, const int nDataBits );
  95. #endif // DATATABLE_SEND_ENG_H