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.

105 lines
3.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef COMMON_H
  9. #define COMMON_H
  10. #pragma once
  11. #ifndef WORLDSIZE_H
  12. #include "worldsize.h"
  13. #endif
  14. #include "basetypes.h"
  15. #include "filesystem.h"
  16. #include "mathlib/vector.h" // @Note (toml 05-01-02): solely for definition of QAngle
  17. #include "qlimits.h"
  18. #include "SteamCommon.h"
  19. #include "steam/steamclientpublic.h"
  20. class Vector;
  21. struct cache_user_t;
  22. //============================================================================
  23. #define COM_COPY_CHUNK_SIZE 1024 // For copying operations
  24. #ifndef NULL
  25. #define NULL ((void *)0)
  26. #endif
  27. #include "tier1/strtools.h"
  28. //============================================================================
  29. char *COM_StringCopy(const char *text); // allocates memory and copys text
  30. void COM_StringFree(const char *text); // frees memory allocated by COM_StringCopy
  31. void COM_AddNoise( unsigned char *data, int length, int number ); // Changes n random bits in a data block
  32. //============================================================================
  33. extern void COM_WriteFile (const char *filename, void *data, int len);
  34. extern int COM_OpenFile( const char *filename, FileHandle_t* file );
  35. extern void COM_CloseFile( FileHandle_t hFile );
  36. extern void COM_CreatePath (const char *path);
  37. extern int COM_FileSize (const char *filename);
  38. extern int COM_ExpandFilename (char *filename, int maxlength);
  39. extern byte *COM_LoadFile (const char *path, int usehunk, int *pLength);
  40. extern bool COM_IsValidPath( const char *pszFilename );
  41. const char *COM_Parse (const char *data);
  42. const char *COM_ParseLine (const char *data);
  43. int COM_TokenWaiting( const char *buffer );
  44. extern bool com_ignorecolons;
  45. extern char com_token[1024];
  46. void COM_Init (void);
  47. void COM_Shutdown( void );
  48. bool COM_CheckGameDirectory( const char *gamedir );
  49. void COM_ParseDirectoryFromCmd( const char *pCmdName, char *pDirName, int maxlen, const char *pDefault );
  50. #define Bits2Bytes(b) ((b+7)>>3)
  51. // does a varargs printf into a temp buffer
  52. // Returns char* because of bad historical reasons.
  53. char *va(PRINTF_FORMAT_STRING const char *format, ...) FMTFUNCTION( 1, 2 );
  54. // prints a vector into a temp buffer.
  55. const char *vstr(Vector& v);
  56. //============================================================================
  57. extern char com_basedir[MAX_OSPATH];
  58. extern char com_gamedir[MAX_OSPATH];
  59. byte *COM_LoadStackFile (const char *path, void *buffer, int bufsize, int& filesize );
  60. void COM_LoadCacheFile (const char *path, cache_user_t *cu);
  61. byte* COM_LoadFile(const char *path, int usehunk, int *pLength);
  62. void COM_CopyFileChunk( FileHandle_t dst, FileHandle_t src, int nSize );
  63. bool COM_CopyFile( const char *netpath, const char *cachepath );
  64. void COM_SetupLogDir( const char *mapname );
  65. void COM_GetGameDir(char *szGameDir, int maxlen);
  66. int COM_CompareFileTime(const char *filename1, const char *filename2, int *iCompare);
  67. int COM_GetFileTime( const char *pFileName );
  68. const char *COM_ParseFile(const char *data, char *token, int maxtoken);
  69. extern char gszDisconnectReason[256];
  70. extern char gszExtendedDisconnectReason[256];
  71. extern bool gfExtendedError;
  72. extern uint8 g_eSteamLoginFailure;
  73. void COM_ExplainDisconnection( bool bPrint, PRINTF_FORMAT_STRING const char *fmt, ... ) FMTFUNCTION( 2, 3 );
  74. const char *COM_DXLevelToString( int dxlevel ); // convert DX level to string
  75. void COM_Log( const char *pszFile, PRINTF_FORMAT_STRING const char *fmt, ...) FMTFUNCTION( 2, 3 ); // Log a debug message to specified file ( if pszFile == NULL uses c:\\hllog.txt )
  76. void COM_LogString( char const *pchFile, char const *pchString );
  77. const char *COM_FormatSeconds( int seconds ); // returns seconds as hh:mm:ss string
  78. const char *COM_GetModDirectory(); // return the mod dir (rather than the complete -game param, which can be a path)
  79. #endif // COMMON_H