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.

87 lines
3.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef NETWORKSTRINGTABLEDEFS_H
  8. #define NETWORKSTRINGTABLEDEFS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. typedef int TABLEID;
  13. #define INVALID_STRING_TABLE -1
  14. const unsigned short INVALID_STRING_INDEX = (unsigned short )-1;
  15. // table index is sent in log2(MAX_TABLES) bits
  16. #define MAX_TABLES 32 // Table id is 4 bits
  17. #define INTERFACENAME_NETWORKSTRINGTABLESERVER "VEngineServerStringTable001"
  18. #define INTERFACENAME_NETWORKSTRINGTABLECLIENT "VEngineClientStringTable001"
  19. class INetworkStringTable;
  20. typedef void (*pfnStringChanged)( void *object, INetworkStringTable *stringTable, int stringNumber, char const *newString, void const *newData );
  21. //-----------------------------------------------------------------------------
  22. // Purpose: Game .dll shared string table interfaces
  23. //-----------------------------------------------------------------------------
  24. class INetworkStringTable
  25. {
  26. public:
  27. virtual ~INetworkStringTable( void ) {};
  28. // Table Info
  29. virtual const char *GetTableName( void ) const = 0;
  30. virtual TABLEID GetTableId( void ) const = 0;
  31. virtual int GetNumStrings( void ) const = 0;
  32. virtual int GetMaxStrings( void ) const = 0;
  33. virtual int GetEntryBits( void ) const = 0;
  34. // Networking
  35. virtual void SetTick( int tick ) = 0;
  36. virtual bool ChangedSinceTick( int tick ) const = 0;
  37. // Accessors (length -1 means don't change user data if string already exits)
  38. virtual int AddString( bool bIsServer, const char *value, int length = -1, const void *userdata = 0 ) = 0;
  39. virtual const char *GetString( int stringNumber ) const = 0;
  40. virtual void SetStringUserData( int stringNumber, int length, const void *userdata ) = 0;
  41. virtual const void *GetStringUserData( int stringNumber, int *length ) const = 0;
  42. virtual int FindStringIndex( char const *string ) = 0; // returns INVALID_STRING_INDEX if not found
  43. // Callbacks
  44. virtual void SetStringChangedCallback( void *object, pfnStringChanged changeFunc ) = 0;
  45. };
  46. enum ENetworkStringtableFlags
  47. {
  48. NSF_NONE = 0,
  49. NSF_DICTIONARY_ENABLED = (1<<0), // Uses pre-calculated per map dictionaries to reduce bandwidth
  50. };
  51. class INetworkStringTableContainer
  52. {
  53. public:
  54. virtual ~INetworkStringTableContainer( void ) {};
  55. // table creation/destruction
  56. virtual INetworkStringTable *CreateStringTable( const char *tableName, int maxentries, int userdatafixedsize = 0, int userdatanetworkbits = 0, int flags = NSF_NONE ) = 0;
  57. virtual void RemoveAllTables( void ) = 0;
  58. // table infos
  59. virtual INetworkStringTable *FindTable( const char *tableName ) const = 0;
  60. virtual INetworkStringTable *GetTable( TABLEID stringTable ) const = 0;
  61. virtual int GetNumTables( void ) const = 0;
  62. virtual void SetAllowClientSideAddString( INetworkStringTable *table, bool bAllowClientSideAddString ) = 0;
  63. virtual void CreateDictionary( char const *pchMapName ) = 0;
  64. };
  65. #endif // NETWORKSTRINGTABLEDEFS_H