d_net.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 __D_NET__
  21. #define __D_NET__
  22. #include "d_player.h"
  23. #ifdef __GNUG__
  24. #pragma interface
  25. #endif
  26. //
  27. // Network play related stuff.
  28. // There is a data struct that stores network
  29. // communication related stuff, and another
  30. // one that defines the actual packets to
  31. // be transmitted.
  32. //
  33. #define DOOMCOM_ID 0x12345678l
  34. // Max computers/players in a game.
  35. #define MAXNETNODES 8
  36. // Networking and tick handling related.
  37. #define BACKUPTICS 64
  38. typedef enum
  39. {
  40. CMD_SEND = 1,
  41. CMD_GET = 2
  42. } command_t;
  43. //
  44. // Network packet data.
  45. //
  46. typedef struct
  47. {
  48. // High bit is retransmit request.
  49. unsigned checksum;
  50. // Only valid if NCMD_RETRANSMIT.
  51. byte retransmitfrom;
  52. byte sourceDest;
  53. byte starttic;
  54. byte player;
  55. byte numtics;
  56. ticcmd_t cmds[BACKUPTICS];
  57. } doomdata_t;
  58. struct doomcom_t
  59. {
  60. // Supposed to be DOOMCOM_ID?
  61. long id;
  62. // DOOM executes an int to execute commands.
  63. short intnum;
  64. // Communication between DOOM and the driver.
  65. // Is CMD_SEND or CMD_GET.
  66. short command;
  67. // Is dest for send, set by get (-1 = no packet).
  68. short remotenode;
  69. // Number of bytes in doomdata to be sent
  70. short datalength;
  71. // Info common to all nodes.
  72. // Console is allways node 0.
  73. short numnodes;
  74. // Flag: 1 = no duplication, 2-5 = dup for slow nets.
  75. short ticdup;
  76. // Flag: 1 = send a backup tic in every packet.
  77. short extratics;
  78. // Flag: 1 = deathmatch.
  79. short deathmatch;
  80. // Flag: -1 = new game, 0-5 = load savegame
  81. short savegame;
  82. short episode; // 1-3
  83. short map; // 1-9
  84. short skill; // 1-5
  85. // Info specific to this node.
  86. short consoleplayer;
  87. short numplayers;
  88. // These are related to the 3-display mode,
  89. // in which two drones looking left and right
  90. // were used to render two additional views
  91. // on two additional computers.
  92. // Probably not operational anymore.
  93. // 1 = left, 0 = center, -1 = right
  94. short angleoffset;
  95. // 1 = drone
  96. short drone;
  97. // The packet data to be sent.
  98. doomdata_t data;
  99. } ;
  100. class idUserCmdMgr;
  101. // Create any new ticcmds and broadcast to other players.
  102. void NetUpdate ( idUserCmdMgr * userCmdMgr );
  103. // Broadcasts special packets to other players
  104. // to notify of game exit
  105. void D_QuitNetGame (void);
  106. //? how many ticks to run?
  107. bool TryRunTics (void);
  108. #endif