DirectPlay

Started by
1 comment, last by ziplux 23 years, 8 months ago
Whenever I call Open(...) to create a new session, it gives me the error DPERR_UNINITIALIZED. Does anyone know what that means or how I can fix it? Here is the function and the Init function too. Thanks in advance.
    
int CDPlayServer :: StartServer(char *name)
	{
	DPSESSIONDESC2   dpsd;    // session desc

	HRESULT hr;

	ZeroMemory( &dpsd, sizeof(dpsd) );
	dpsd.dwSize           = sizeof(dpsd);
	dpsd.guidApplication = TicTacToeApp;
	dpsd.dwMaxPlayers     = 2;

	dpsd.dwFlags          = DPSESSION_DIRECTPLAYPROTOCOL;

	if(FAILED(hr = lpdp->Open( &dpsd, DPOPEN_CREATE )))  // fails here

		{
		switch (hr)
			{
			case DPERR_UNINITIALIZED:
				{
				cout << "Err"; // this is printed

				} break;
			default:break;
			}
		return FAIL;
		}
	CPlayer p;
	sprintf("HOST", p.name);
	CreateLocalPlayer(p);
	return SUCCESS;
	}
[/source]
[source]
int CDPlay :: Init()
	{
	LPDIRECTPLAYLOBBYA        old_lpdplobbyA = NULL;    // old lobby pointer

	
	CoInitialize(NULL);    // registering COM

	CO_UsedBy++;

    // creating directplay object

    if  ( CoCreateInstance(CLSID_DirectPlay, NULL, CLSCTX_INPROC_SERVER,
         IID_IDirectPlay4A,(LPVOID*)&lpdp ) != S_OK)
		{
        // return  a messagebox error

        CoUninitialize();   // unregister the comp

        return(0);
		}

    // creating lobby object

    DirectPlayLobbyCreate(NULL, &old_lpdplobbyA, NULL, NULL, 0);

    // get new interface of lobby

    old_lpdplobbyA->QueryInterface(IID_IDirectPlayLobby3A, (LPVOID *)&lpdplobby);
    old_lpdplobbyA->Release();   // release old interface since we have new one

	return SUCCESS;
	}
    
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t X R- tv+ b++ DI+(+++) D- G e* h!" Decode my geekcode! Geekcode.com
Visit our web site: Asylum Entertainment
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t XR- tv+ b++ DI+(+++) D- G e* h!"Decode my geekcode!Geekcode.com
Visit our web site:Asylum Entertainment
Advertisement
You should initialize the connection before openning the session
Eduardo García SacristánProgrammer. UbiSoft Spainegarcia@ubisoft.es
yeah
just reverse the creation of the direct play obj with the open connect
good luck

This topic is closed to new replies.

Advertisement