DirectPlay - Bad data transmition

Started by
-1 comments, last by Sagito 17 years, 9 months ago
Hi all... I've been trying to establish a peer-2-peer connection using DirectPlay for a simple console sample game. So, I need to send a message to the other computer, everytime a player made its move. This message is an array of 4 chars. I'm sending it w/ DirectPlay's SendTo function, which looks like this:

if( FAILED( hr = pDP->SendTo( DPNID_ALL_PLAYERS_GROUP,
                                    &dpnBuffer,           
                                    1,                    
                                    0,                    
                                    NULL,                 
                                    phAsync, DPNSEND_PRIORITY_HIGH | DPNSEND_GUARANTEED | DPNSEND_NOLOOPBACK)))


But when I receive it in the other computer, the msg is filled with zeros. I'm receiving the message through the DirectPlayMessageHandler, which is the following:

        case DPN_MSGID_RECEIVE:
        {
            PDPNMSG_RECEIVE     pMsg;
            TCHAR       strBuffer[4];

            pMsg = (PDPNMSG_RECEIVE) pMsgBuffer;
            DXUtil_ConvertWideStringToGenericCch( strBuffer, (WCHAR*) pMsg->pReceiveData, 4);

			for (int i = 0; i < 4; i++)
			{
				//Avoid garbage
				if (strBuffer >= 0)
				{
					msg = strBuffer;
				}
			}
 
                        //Check it up
			cout << msg[0] << msg[1] << msg[2] << msg[3] << endl;
            break;
        }


Can someone tell me why this happens? What am I doing wrong here? =S Thanks everyone...
http://sagito.wordpress.com

This topic is closed to new replies.

Advertisement