CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

DPLAY.H (11450B)


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