Jump to content
  • Advertisement


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


Getting corrupt data from directplay

This topic is 5384 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! I got a problem when sending directplay messages. Everything works great when I send a message of type ''netmsg''. But when I''m about to send a message of type ''netmsg_position'' for example, some of the data in the struct is corrupt. I don''t think there is something wrong with directplay, I''m sure that I screw up somewhere with the pointers or something. Below is some of my source code for you to check out.

// my message structs

struct netmsg
int type;

struct netmsg_position : public netmsg
	int x,y;

// message types

enum messagetype { msgtype_position = 0, msgtype_message = 1 };

// function that send a message

void myengine::net::client::send(netmsg msg,int msgsize)
		DPNHANDLE handle;

		// description

		desc.dwBufferSize = msgsize;
		desc.pBufferData = (BYTE*)&msg;

		// send

		m_dpclient->Send(&desc,1,0,NULL,NULL,DPNSEND_SYNC | 

// send a message

netmsg_position pos;
pos.type = msgtype_position;
pos.x = 23;
pos.y = 19;


// inside message handler for server

	// message received

	netmsg *msg = (netmsg*)data->pReceiveData;
	return S_OK;

// function that handles message

void myengine::net::server::on_client_receive(int msgtype,PBYTE msg)
if(msgtype == msgtype_position)
	netmsg_position *pos = (netmsg_position*)msg;
else if(msgtype == msgtype_message)
	netmsg_message *mess = (netmsg_message*)msg;
Thanks in advance for any help I can get.

Share this post

Link to post
Share on other sites
Oh, your right..
But that doesn''t really solve my problem... (I pasted in wrong code there, it should be "sizeof(netmsg_position)" ).

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!