doomlib.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef _DOOM_LIB_H
  21. #define _DOOM_LIB_H
  22. #include "doomtype.h"
  23. #include "doomdef.h"
  24. #include "doominterface.h"
  25. #include "idlib/containers/Array.h"
  26. class idSysMutex;
  27. class idUserCmdMgr;
  28. #define IN_NUM_DIGITAL_BUTTONS 8
  29. #define IN_NUM_ANALOG_BUTTONS 8
  30. // Cutoff where the analog buttons are considered to be "pressed"
  31. // This should be smarter.
  32. #define IN_ANALOG_BUTTON_THRESHOLD 64
  33. extern idCVar s_volume_sound;
  34. extern idCVar s_volume_midi;
  35. extern idCVar m_show_messages;
  36. extern idCVar m_inDemoMode;
  37. struct rumble_t
  38. {
  39. int feedback; // SMF // XINPUT_FEEDBACK feedback;
  40. int endTime;
  41. // The following values are needed, becuase a rumble
  42. // can fail, if it hasn't processed the previous one yet,
  43. // so, it must be stored
  44. bool waiting;
  45. int left;
  46. int right;
  47. };
  48. enum gameSKU_t {
  49. GAME_SKU_DCC = 0, // Doom Classic Complete
  50. GAME_SKU_DOOM1_BFG, // Doom 1 Ran from BFG
  51. GAME_SKU_DOOM2_BFG, // Doom 2 Ran from BFG
  52. };
  53. /*
  54. ================================================================================================
  55. ExpansionData
  56. ================================================================================================
  57. */
  58. struct ExpansionData {
  59. enum { IWAD = 0, PWAD = 1 } type;
  60. GameMode_t gameMode;
  61. GameMission_t pack_type;
  62. const char * expansionName;
  63. const char * iWadFilename;
  64. const char * pWadFilename;
  65. const char * saveImageFile;
  66. const char ** mapNames;
  67. };
  68. namespace DoomLib
  69. {
  70. typedef int ( *RecvFunc)( char* buff, DWORD *numRecv );
  71. typedef int ( *SendFunc)( const char* buff, DWORD size, sockaddr_in *target, int toNode );
  72. typedef int ( *SendRemoteFunc)();
  73. void InitGlobals( void *ptr = NULL );
  74. void InitGame( int argc, char ** argv );
  75. void InitControlRemap();
  76. keyNum_t RemapControl( keyNum_t key );
  77. bool Poll();
  78. bool Tic( idUserCmdMgr * userCmdMgr );
  79. void Wipe();
  80. void Frame( int realoffset = 0, int buffer = 0 );
  81. void Draw();
  82. void Shutdown();
  83. void SetNetworking( RecvFunc rf, SendFunc sf, SendRemoteFunc sendRemote );
  84. void SetPlayer( int id );
  85. int GetPlayer();
  86. byte BuildSourceDest( int toNode );
  87. void GetSourceDest( byte sourceDest, int* source, int* dest );
  88. int RemoteNodeToPlayerIndex( int node );
  89. int PlayerIndexToRemoteNode( int index );
  90. void PollNetwork();
  91. void SendNetwork();
  92. void *GetGlobalData( int player );
  93. void RunSound();
  94. extern RecvFunc Recv;
  95. extern SendFunc Send;
  96. extern SendRemoteFunc SendRemote;
  97. extern void* (*Z_Malloc)( int size, int tag, void* user );
  98. extern void (*Z_FreeTag)(int lowtag );
  99. extern DoomInterface Interface;
  100. extern int idealExpansion;
  101. extern int expansionSelected;
  102. extern bool expansionDirty;
  103. extern bool skipToLoad;
  104. extern char loadGamePath[MAX_PATH];
  105. extern bool skipToNew;
  106. extern int chosenSkill;
  107. extern int chosenEpisode;
  108. extern idMatchParameters matchParms;
  109. const ExpansionData * GetCurrentExpansion();
  110. void SetCurrentExpansion( int expansion );
  111. void SetIdealExpansion( int expansion );
  112. void SetCurrentMapName( idStr name );
  113. const idStr & GetCurrentMapName();
  114. void SetCurrentDifficulty( idStr name );
  115. const idStr & GetCurrentDifficulty();
  116. void ActivateGame();
  117. void ExitGame();
  118. void ShowXToContinue( bool activate );
  119. gameSKU_t GetGameSKU();
  120. void HandleEndMatch();
  121. };
  122. #endif