Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


GetClientInfo() fails on host player?

This topic is 5230 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, For some reason DirectPlay chooses to create a player for the server itself. I wish to catch the host player and prevent it from being created as a player in my system. From my own code, it seems GetClientInfo() always fails when trying to call it on the DPNID representing the host player. Also, as seen from the DirectPlay sample code (simpleserver.cpp)
            // Determine the required size of the buffer

            DWORD dwSize = 0;
            DPN_PLAYER_INFO* pdpPlayerInfo = NULL;
            hr = g_pDPServer->GetClientInfo( pCreatePlayerMsg->dpnidPlayer, 
                                             pdpPlayerInfo, &dwSize, 0 );
            if( FAILED(hr) && hr != DPNERR_BUFFERTOOSMALL )
                // Ignore this message if this is for the host

                if( hr != DPNERR_INVALIDPLAYER )
                    DXTRACE_ERR_MSGBOX( TEXT("GetClientInfo"), hr );

It seems like the host player is expected to fail when trying to determine if a DPNID represents the host itself. But in that case, why is the DPNPLAYER_HOST flag specified as being possible in the DPN_PLAYER_INFO::dwPlayerFlags member? If the host always fails, how can that flag ever be of use? Is there a reliable (i.e. one that does not rely on catching a specific succession of errors and interpreting it as indicative of the host) way to determine if the DPNID being examined represents the host player? TIA Bjorn

Share this post

Link to post
Share on other sites
My way of doing that:

pDirectPlayer8Server->Host(..., 0, ...); // preset the host player context to be 0

switch (dwMessage) {
// create your game player object here, and
// preset the player context value to the pointer
// to the object;

// the connection has been aborted before it
// is accepted, so cleanup the previously created
// player object by the preset player context value

// for the host player, the player context value
// has been preset to zero via Host() method; for
// real connection clients, the player context
// values are pointers to the corresponding player
// object (non zero); so if player context is zero
// at this stage, then it must be host player, you
// can safely ignore it; and if player context is
// nonzero, it must be one of the previous real client
// inside DPN_MSGID_INDICATE_CONNECT, so now you can
// do further work on the player object, etc.

case ...:

hope it helps


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!