//----------------------------------------------------------------------------- // Name: // Desc: //----------------------------------------------------------------------------- BOOL Network_CloseSession() { HRESULT hRet; hRet = g_pDPlay->Close(); if (FAILED(hRet)) return FALSE; return TRUE; }
//----------------------------------------------------------------------------- // Name: // Desc: //----------------------------------------------------------------------------- void Network_Free() { if (g_pDPlay) { g_pDPlay->Close(); SAFE_RELEASE(g_pDPlay); } if (g_hEvent != 0) { CloseHandle(g_hEvent); g_hEvent = 0; } }
HRESULT bld_create_player( LPDIRECTPLAY4A dp_interface, const char *game_name, const char *player_name, PLAYER_INFO *player_info ) { DPID dpid;/* the dpid of the player created given by directplay */ DPNAME name; HRESULT hr; DPSESSIONDESC2 session_desc; if (dp_interface == NULL) return DPERR_INVALIDOBJECT; ZeroMemory(&session_desc, sizeof(DPSESSIONDESC2)); session_desc.dwSize = sizeof(DPSESSIONDESC2); session_desc.dwFlags = (DPSESSION_KEEPALIVE | DPSESSION_MIGRATEHOST); session_desc.guidApplication = AppGUID; session_desc.dwMaxPlayers = gbl_max_players; session_desc.lpszSessionNameA = (char *)game_name; hr = dp_interface->Open(&session_desc, DPOPEN_CREATE); if (FAILED(hr)) goto close; ZeroMemory(&name,sizeof(DPNAME)); name.dwSize = sizeof(DPNAME); name.lpszShortNameA = (char *)player_name; name.lpszLongNameA = NULL; dp_interface->CreatePlayer( &dpid, &name, player_info->event, NULL, 0, DPPLAYER_SERVERPLAYER ); if (FAILED(hr)) goto close; player_info->dp_interface = dp_interface; player_info->dpid = dpid; player_info->is_server = 1; return DP_OK; close: dp_interface->Close(); return hr; }
HRESULT bld_create_client_player( LPDIRECTPLAY4A dp_interface, LPGUID sessionGuid, const char *player_name, PLAYER_INFO *player_info) { DPID dpid;/* the dpid of the player created given by directplay */ DPNAME name; HRESULT hr; DPSESSIONDESC2 session_desc; if (dp_interface == NULL) return DPERR_INVALIDOBJECT; ZeroMemory(&session_desc, sizeof(DPSESSIONDESC2)); session_desc.dwSize = sizeof(DPSESSIONDESC2); session_desc.guidInstance = *sessionGuid; player_info->dp_interface = dp_interface; hr = dp_interface->Open(&session_desc, DPOPEN_JOIN); if (FAILED(hr)) goto close; ZeroMemory(&name,sizeof(DPNAME)); name.dwSize = sizeof(DPNAME); name.lpszShortNameA = (char *)player_name; name.lpszLongNameA = NULL; dp_interface->CreatePlayer( &dpid, &name, player_info->event, NULL, 0, 0 ); if (FAILED(hr)) goto close; player_info->dpid = dpid; player_info->is_server = 0; return DP_OK; close: dp_interface->Close(); return hr; }