DPLAY.H 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /*==========================================================================;
  15. *
  16. * Copyright (C) 1994-1995 Microsoft Corporation. All Rights Reserved.
  17. *
  18. * File: dplay.h
  19. * Content: DirectPlay include file
  20. *
  21. ***************************************************************************/
  22. #ifndef __DPLAY_INCLUDED__
  23. #define __DPLAY_INCLUDED__
  24. #ifdef _WIN32
  25. /* for DECLARE_INTERFACE and HRESULT. */
  26. #include <ole2.h>
  27. #endif
  28. #define _FACDP 0x877
  29. #define MAKE_DPHRESULT( code ) MAKE_HRESULT( 1, _FACDP, code )
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. #pragma pack(push, 1)
  34. /*============================================================================
  35. *
  36. * DirectPlay Structures
  37. *
  38. * Various structures used to invoke DirectPlay.
  39. *
  40. *==========================================================================*/
  41. #ifdef __cplusplus
  42. /* 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined */
  43. struct IDirectPlay;
  44. typedef struct IDirectPlay FAR *LPDIRECTPLAY;
  45. #else
  46. typedef struct IDirectPlay FAR *LPDIRECTPLAY;
  47. #endif
  48. typedef DWORD DPID, FAR *LPDPID;
  49. typedef struct _DPCAPS
  50. {
  51. DWORD dwSize;
  52. DWORD dwFlags;
  53. DWORD dwMaxBufferSize;
  54. DWORD dwMaxQueueSize; // Function of DPlay, not SP.
  55. DWORD dwMaxPlayers;
  56. DWORD dwHundredBaud; // 24 is 2400, 96 is 9600, etc.
  57. DWORD dwLatency;
  58. } DPCAPS;
  59. typedef DPCAPS FAR *LPDPCAPS;
  60. #define DPLONGNAMELEN 52
  61. #define DPSHORTNAMELEN 20
  62. #define DPSESSIONNAMELEN 32
  63. #define DPPASSWORDLEN 16
  64. #define DPUSERRESERVED 16
  65. typedef struct
  66. {
  67. DWORD dwSize;
  68. GUID guidSession; // Id for Game. Null is all games.
  69. DWORD dwSession; // session identifier
  70. DWORD dwMaxPlayers; // Maximum players allowed in game.
  71. DWORD dwCurrentPlayers; // Current players in Game.
  72. DWORD dwFlags; // DPOPEN_* flags
  73. char szSessionName[DPSESSIONNAMELEN];// Human readable name for Game
  74. char szUserField[DPUSERRESERVED];
  75. DWORD dwReserved1; // Reserved for future MS use.
  76. char szPassword[DPPASSWORDLEN]; // Password to be allowed into game.
  77. DWORD dwReserved2; // Reserved for future MS use.
  78. DWORD dwUser1;
  79. DWORD dwUser2;
  80. DWORD dwUser3;
  81. DWORD dwUser4;
  82. } DPSESSIONDESC;
  83. typedef DPSESSIONDESC FAR *LPDPSESSIONDESC;
  84. /*
  85. * Create API
  86. */
  87. typedef BOOL (FAR PASCAL * LPDPENUMDPCALLBACK)(
  88. LPGUID lpSPGuid,
  89. LPSTR lpFriendlyName,
  90. DWORD dwMajorVersion,
  91. DWORD dwMinorVersion,
  92. LPVOID lpContext);
  93. typedef BOOL (FAR PASCAL * LPDPENUMSESSIONSCALLBACK)(
  94. LPDPSESSIONDESC lpDPSGameDesc,
  95. LPVOID lpContext,
  96. LPDWORD lpdwTimeOut,
  97. DWORD dwFlags);
  98. extern HRESULT WINAPI DirectPlayCreate( LPGUID lpGUID, LPDIRECTPLAY FAR *lplpDP, IUnknown FAR *pUnk);
  99. extern HRESULT WINAPI DirectPlayEnumerate( LPDPENUMDPCALLBACK, LPVOID );
  100. /* Player enumeration callback prototype */
  101. typedef BOOL (FAR PASCAL *LPDPENUMPLAYERSCALLBACK)(
  102. DPID dpId,
  103. LPSTR lpFriendlyName,
  104. LPSTR lpFormalName,
  105. DWORD dwFlags,
  106. LPVOID lpContext );
  107. /*
  108. * IDirectPlay
  109. */
  110. #undef INTERFACE
  111. #define INTERFACE IDirectPlay
  112. #ifdef _WIN32
  113. DECLARE_INTERFACE_( IDirectPlay, IUnknown )
  114. {
  115. /*** IUnknown methods ***/
  116. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  117. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  118. STDMETHOD_(ULONG,Release) (THIS) PURE;
  119. /*** IDirectPlay methods ***/
  120. STDMETHOD(AddPlayerToGroup) (THIS_ DPID, DPID) PURE;
  121. STDMETHOD(Close) (THIS) PURE;
  122. STDMETHOD(CreatePlayer) (THIS_ LPDPID,LPSTR,LPSTR,LPHANDLE) PURE;
  123. STDMETHOD(CreateGroup) (THIS_ LPDPID,LPSTR,LPSTR) PURE;
  124. STDMETHOD(DeletePlayerFromGroup)(THIS_ DPID,DPID) PURE;
  125. STDMETHOD(DestroyPlayer) (THIS_ DPID) PURE;
  126. STDMETHOD(DestroyGroup) (THIS_ DPID) PURE;
  127. STDMETHOD(EnableNewPlayers) (THIS_ BOOL) PURE;
  128. STDMETHOD(EnumGroupPlayers) (THIS_ DPID, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE;
  129. STDMETHOD(EnumGroups) (THIS_ DWORD, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE;
  130. STDMETHOD(EnumPlayers) (THIS_ DWORD, LPDPENUMPLAYERSCALLBACK,LPVOID,DWORD) PURE;
  131. STDMETHOD(EnumSessions) (THIS_ LPDPSESSIONDESC,DWORD,LPDPENUMSESSIONSCALLBACK,LPVOID,DWORD) PURE;
  132. STDMETHOD(GetCaps) (THIS_ LPDPCAPS) PURE;
  133. STDMETHOD(GetMessageCount) (THIS_ DPID, LPDWORD) PURE;
  134. STDMETHOD(GetPlayerCaps) (THIS_ DPID, LPDPCAPS) PURE;
  135. STDMETHOD(GetPlayerName) (THIS_ DPID,LPSTR,LPDWORD,LPSTR,LPDWORD) PURE;
  136. STDMETHOD(Initialize) (THIS_ LPGUID) PURE;
  137. STDMETHOD(Open) (THIS_ LPDPSESSIONDESC) PURE;
  138. STDMETHOD(Receive) (THIS_ LPDPID,LPDPID,DWORD,LPVOID,LPDWORD) PURE;
  139. STDMETHOD(SaveSession) (THIS_ LPSTR) PURE;
  140. STDMETHOD(Send) (THIS_ DPID, DPID, DWORD, LPVOID, DWORD) PURE;
  141. STDMETHOD(SetPlayerName) (THIS_ DPID,LPSTR,LPSTR) PURE;
  142. };
  143. #endif
  144. /****************************************************************************
  145. *
  146. * DIRECTPLAY ERRORS
  147. *
  148. * Errors are represented by negative values and cannot be combined.
  149. *
  150. ****************************************************************************/
  151. #define DP_OK 0
  152. #define DPERR_ALREADYINITIALIZED MAKE_DPHRESULT( 5 )
  153. #define DPERR_ACCESSDENIED MAKE_DPHRESULT( 10 )
  154. #define DPERR_ACTIVEPLAYERS MAKE_DPHRESULT( 20 )
  155. #define DPERR_BUFFERTOOSMALL MAKE_DPHRESULT( 30 )
  156. #define DPERR_CANTADDPLAYER MAKE_DPHRESULT( 40 )
  157. #define DPERR_CANTCREATEGROUP MAKE_DPHRESULT( 50 )
  158. #define DPERR_CANTCREATEPLAYER MAKE_DPHRESULT( 60 )
  159. #define DPERR_CANTCREATESESSION MAKE_DPHRESULT( 70 )
  160. #define DPERR_CAPSNOTAVAILABLEYET MAKE_DPHRESULT( 80 )
  161. #define DPERR_EXCEPTION MAKE_DPHRESULT( 90 )
  162. #define DPERR_GENERIC E_FAIL
  163. #define DPERR_INVALIDFLAGS MAKE_DPHRESULT( 120 )
  164. #define DPERR_INVALIDOBJECT MAKE_DPHRESULT( 130 )
  165. #define DPERR_INVALIDPARAM E_INVALIDARG
  166. #define DPERR_INVALIDPARAMS DPERR_INVALIDPARAM
  167. #define DPERR_INVALIDPLAYER MAKE_DPHRESULT( 150 )
  168. #define DPERR_NOCAPS MAKE_DPHRESULT( 160 )
  169. #define DPERR_NOCONNECTION MAKE_DPHRESULT( 170 )
  170. #define DPERR_NOMEMORY E_OUTOFMEMORY
  171. #define DPERR_OUTOFMEMORY DPERR_NOMEMORY
  172. #define DPERR_NOMESSAGES MAKE_DPHRESULT( 190 )
  173. #define DPERR_NONAMESERVERFOUND MAKE_DPHRESULT( 200 )
  174. #define DPERR_NOPLAYERS MAKE_DPHRESULT( 210 )
  175. #define DPERR_NOSESSIONS MAKE_DPHRESULT( 220 )
  176. #define DPERR_SENDTOOBIG MAKE_DPHRESULT( 230 )
  177. #define DPERR_TIMEOUT MAKE_DPHRESULT( 240 )
  178. #define DPERR_UNAVAILABLE MAKE_DPHRESULT( 250 )
  179. #define DPERR_UNSUPPORTED E_NOTIMPL
  180. #define DPERR_BUSY MAKE_DPHRESULT( 270 )
  181. #define DPERR_USERCANCEL MAKE_DPHRESULT( 280 )
  182. #define DPOPEN_OPENSESSION 0x00000001
  183. #define DPOPEN_CREATESESSION 0x00000002
  184. #define DPSEND_GUARANTEE 0x00000001
  185. #define DPSEND_HIGHPRIORITY 0x00000002
  186. #define DPSEND_TRYONCE 0x00000004
  187. #define DPRECEIVE_ALL 0x00000001
  188. #define DPRECEIVE_TOPLAYER 0x00000002
  189. #define DPRECEIVE_FROMPLAYER 0x00000004
  190. #define DPRECEIVE_PEEK 0x00000008
  191. #define DPCAPS_NAMESERVICE 0x00000001 // A name server is supported.
  192. #define DPCAPS_NAMESERVER 0x00000002 // You are the name server.
  193. #define DPCAPS_GUARANTEED 0x00000004 // SP's don't have to implement guarantees.
  194. #define DPENUMSESSIONS_AVAILABLE 0x00000001 // All games that match password (if given)
  195. // and have openings.
  196. #define DPENUMSESSIONS_ALL 0x00000002
  197. #define DPENUMSESSIONS_PREVIOUS 0x00000004
  198. #define DPENUMPLAYERS_ALL 0x00000000
  199. #define DPENUMPLAYERS_PREVIOUS 0x00000004
  200. #define DPENUMPLAYERS_LOCAL 0x00000008
  201. #define DPENUMPLAYERS_REMOTE 0x00000010
  202. #define DPENUMPLAYERS_GROUP 0x00000020
  203. #define DPENUMPLAYERS_SESSION 0x00000080
  204. //
  205. // This flag is set on the enumsessions callback when the time out has occured.
  206. // This means that there is no session data for this callback.
  207. // If lpdwTimeOut is set to a non-zero value and the EnumSessionsCallback returns
  208. // TRUE then EnumSessions will continue until the next timeout occurs.
  209. // Timeouts are in milliseconds.
  210. #define DPESC_TIMEDOUT 0x00000001
  211. //
  212. // System message structures and types.
  213. //
  214. // System messages have a leading 4 byte type code to identify the message.
  215. // an app knows it is a system message because it is addressed 'To' player 0.
  216. //
  217. #define DPSYS_ADDPLAYER 0x0003 // DPMSG_ADDPLAYER
  218. #define DPSYS_DELETEPLAYER 0x0005 // DPMSG_DELETEPLAYER
  219. #define DPSYS_ADDPLAYERTOGROUP 0x0007 // DPMSG_GROUPADD
  220. #define DPSYS_INVITE 0x000e // DPMSG_INVITE, Net only.
  221. #define DPSYS_DELETEGROUP 0x0020 // DPMSG_DELETEPLAYER
  222. #define DPSYS_DELETEPLAYERFROMGRP 0x0021 // DPMSG_GROUPDELETE
  223. #define DPSYS_SESSIONLOST 0x0031
  224. #define DPSYS_CONNECT 0x484b // DPMSG_GENERIC
  225. typedef struct
  226. {
  227. DWORD dwType;
  228. DWORD dwPlayerType;
  229. DPID dpId;
  230. char szLongName[DPLONGNAMELEN];
  231. char szShortName[DPSHORTNAMELEN];
  232. DWORD dwCurrentPlayers;
  233. } DPMSG_ADDPLAYER;
  234. typedef DPMSG_ADDPLAYER DPMSG_ADDGROUP;
  235. typedef struct
  236. {
  237. DWORD dwType;
  238. DPID dpIdGroup;
  239. DPID dpIdPlayer;
  240. } DPMSG_GROUPADD;
  241. typedef DPMSG_GROUPADD DPMSG_GROUPDELETE;
  242. typedef struct
  243. {
  244. DWORD dwType;
  245. DPID dpId;
  246. } DPMSG_DELETEPLAYER;
  247. typedef struct
  248. {
  249. DWORD dwType;
  250. DPSESSIONDESC dpsDesc;
  251. } DPMSG_INVITE;
  252. typedef struct
  253. {
  254. DWORD dwType;
  255. } DPMSG_GENERIC;
  256. #pragma pack(pop)
  257. DEFINE_GUID( IID_IDirectPlay, 0x5454e9a0, 0xdb65, 0x11ce, 0x92, 0x1c, 0x00, 0xaa, 0x00, 0x6c, 0x49, 0x72);
  258. #ifdef __cplusplus
  259. };
  260. #endif
  261. #endif