Archived

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

jannikks

DirectPlay Message handler as class member?

Recommended Posts

Hello, I tried to develop my first game and put multiplayer functionality in it. I did everything object-oriented put the DirectPlay Message Handler in an object, so I did not make it static. When compiling, I get a mistake like this: error C2664: ''IDirectPlay8Peer::Initialize'' : Converting of Parameter 2 of ''HRESULT (PVOID,DWORD,PVOID)'' in ''const PFNDPNMESSAGEHANDLER'' not possible So the initialize - function does not seem to want a nonstatic function as a parameter. I tried using an approach I found somewhere and made a wrapper like this: HRESULT DPMsgHandlerWrapper (PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer) { return m_pGameClass->DirectPlayMessageHandler (pvUserContext, dwMessageId, pMsgBuffer); } ..and I put that wrapper-handler in my initialize function, but the mistake does not change. How do you all program your DirectPlay Applications? Is there a solution for this problem or is the DirectPlay MessageHandler just supposed to be static? Thanks a lot for your help.

Share this post


Link to post
Share on other sites
I haven''t tried putting it inside an object, BUT that wrapper approch can''t be wrong.

Since it''s a normal msg-handler function it has to work.

Check that you set DPMsgHandlerWrapper to your DPmsgProc and NOT m_pGameClass->DirectPlayMessageHandler!

You should be able to type any kind of c++ code inside your wrapper class

----------------------------------------------
Petter Nordlander

"There are only 10 kinds of people in the world. They who understand binary and those who do not"

Share this post


Link to post
Share on other sites