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.

97 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef DATATABLE_RECV_ENG_H
  8. #define DATATABLE_RECV_ENG_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "dt_recv.h"
  13. #include "bitbuf.h"
  14. #include "dt.h"
  15. class CStandardSendProxies;
  16. // ------------------------------------------------------------------------------------------ //
  17. // RecvTable functions.
  18. // ------------------------------------------------------------------------------------------ //
  19. // These are the module startup and shutdown routines.
  20. bool RecvTable_Init( RecvTable **pTables, int nTables );
  21. void RecvTable_Term( bool clearall = true );
  22. // After calling RecvTable_Init to provide the list of RecvTables, call this
  23. // as the server sends its SendTables over. When bNeedsDecoder is specified,
  24. // it will precalculate the necessary data to actually decode this type of
  25. // SendTable from the server. nDemoProtocol = 0 means current version.
  26. bool RecvTable_RecvClassInfos( bf_read *pBuf, bool bNeedsDecoder, int nDemoProtocol = 0);
  27. // After ALL the SendTables have been received, call this and it will create CRecvDecoders
  28. // for all the SendTable->RecvTable matches it finds.
  29. // Returns false if there is an unrecoverable error.
  30. //
  31. // bAllowMismatches is true when playing demos back so we can change datatables without breaking demos.
  32. // If pAnyMisMatches is non-null, it will be set to true if the client's recv tables mismatched the server's ones.
  33. bool RecvTable_CreateDecoders( const CStandardSendProxies *pSendProxies, bool bAllowMismatches, bool *pAnyMismatches=NULL );
  34. // objectID gets passed into proxies and can be used to track data on particular objects.
  35. // NOTE: this function can ONLY decode a buffer outputted from RecvTable_MergeDeltas
  36. // or RecvTable_CopyEncoding because if the way it follows the exclude prop bits.
  37. bool RecvTable_Decode(
  38. RecvTable *pTable,
  39. void *pStruct,
  40. bf_read *pIn,
  41. int objectID,
  42. bool updateDTI = true
  43. );
  44. // This acts like a RecvTable_Decode() call where all properties are written and all their values are zero.
  45. void RecvTable_DecodeZeros( RecvTable *pTable, void *pStruct, int objectID );
  46. // This writes all pNewState properties into pOut.
  47. //
  48. // If pOldState is non-null and contains any properties that aren't in pNewState, then
  49. // those properties are written to the output as well. Returns # of changed props
  50. int RecvTable_MergeDeltas(
  51. RecvTable *pTable,
  52. bf_read *pOldState, // this can be null
  53. bf_read *pNewState,
  54. bf_write *pOut,
  55. int objectID = - 1,
  56. int *pChangedProps = NULL,
  57. bool updateDTI = false // enclude merge from newState in the DTI reports
  58. );
  59. // Just copies the bits from the bf_read into the bf_write (this function is used
  60. // when you don't know the length of the encoded data).
  61. void RecvTable_CopyEncoding(
  62. RecvTable *pRecvTable,
  63. bf_read *pIn,
  64. bf_write *pOut,
  65. int objectID
  66. );
  67. // ------------------------------------------------------------------------------------------ //
  68. // Globals
  69. // ------------------------------------------------------------------------------------------ //
  70. // This is incremented each time a property is decoded.
  71. extern int g_nPropsDecoded;
  72. #endif // DATATABLE_RECV_ENG_H