Archived

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

fireking

DirectPlay 8.1

Recommended Posts

fireking    122
ok, so microsoft finally does a good job and makes direct play some what effecient (at least thats what microsoft tells me, which could easily be false information)... but anyways, i''ve looked through the net and all i find is OLD directplay tutorials. The new rendition of directplay in 8.1 has a significant difference over its older versions, and I would love to find a simple tutorial on setting up a server/client topology, sending messages, and using the groups. Also, if anyone has experience with the New DirectPlay, is the following situation bad? I''ve read about the new group thing, and it sounds very promising, would it be bad to subclass my multiplayer world entirely out of groups? For instance, the entire world is loaded into a group, then people on the screen that you can see, are in your group. This would allow for faster transmission of messages, when something happens. Lets say you cast a fire spell or something, everyone in your group(on your screen), will recieve that message of a fire spell flying across the screen. As the fire ball moves, it looks around its view (in theory) to find other players, and sends the message that says "Hey im coming this way!" to all the people in HIS group, until it fizzles out. I was wondering if this would be effecient or not, and a reason explaining why or why not. To me, it sounds like it could get confusing very quickly, but it will be effecient and help reduce sending messages to players who dont need the messages (and cut down on cpu usages when looping through lists of people, finding out who is in view, directplay group will do it for us). Maybe it would be ineffecient, in the fact that you wuold always be adding or removing players from groups. I am not exactley sure on how much time it takes to construct/deconstruct groups of players. And i am not sure how much memory it will take to have a group for each player. --Fireking Owner/Leader Genetics 3rd Dimension Development

Share this post


Link to post
Share on other sites
Fidelio_    122
quote:
Original post by fireking
ok, so microsoft finally does a good job and makes direct play some what effecient (at least thats what microsoft tells me, which could easily be false information)...

but anyways, i''ve looked through the net and all i find is OLD directplay tutorials. The new rendition of directplay in 8.1 has a significant difference over its older versions, and I would love to find a simple tutorial on setting up a server/client topology, sending messages, and using the groups.



That might be a problem, yes. Especially since DirectPlay8 has to be properly initialized (with cocreateinstance etc.).

Here''s a piece of code from a game i''m writing (it''s in Delphi but you can get the general idea). hrtest() is a simple function that prints a debug message when hr <> S_OK


  
function dpinitserver (port: integer) : HRESULT;
var
hr: HResult;
PlayerInfo: TDPN_Player_Info;
AsyncHandle : TDPNHandle;
begin
Result := 1;

// Create the server object

hr := CoCreateInstance( CLSID_DirectPlay8Server, nil, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Server, Server8 );
hrtest(hr,''CoCreateInstance failed'');
hr := Server8.Initialize( nil, MessageHandler , 0 );
hrtest(hr,''Init failed'');
ServerStarted := true;

// Create the local address object

hr := CoCreateInstance( CLSID_DirectPlay8Address, nil, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, LocalAddr );
hrtest(hr,''CoCreateInstance failed'');
hr := LocalAddr.BuildFromURLA( PChar( DPNA_HEADER + DPNA_KEY_PORT + DPNA_SEPARATOR_KEYVALUE + IntToStr(Port) ) );
hrtest(hr,''BuildFromUrla failed'');
hr := LocalAddr.SetSP( @CLSID_DP8SP_TCPIP );
hrtest(hr,''SetSP failed'');

// SetServerinfo is for setting up a broadcast server on the local network


// Local info for setserverinfo

FillChar( PlayerInfo, SizeOf(TDPN_Player_Info), #00 );
PlayerInfo.dwSize := SizeOf( TDPN_Player_Info );
PlayerInfo.dwInfoFlags := DPNINFO_NAME;
PlayerInfo.pwszName := StrToWChar(''Server'');
PlayerInfo.dwPlayerFlags := DPNPLAYER_HOST + DPNPLAYER_LOCAL;

// setserverinfo

hr := Server8.SetServerInfo( PlayerInfo, nil, @asynchandle, 0);
hrtest(hr,''SetServerInfo'');

// appdesc for host

FillChar( ServerAppDesc, SizeOf(TDPN_APPLICATION_DESC), #00 );
ServerAppDesc.dwSize := SizeOf( TDPN_APPLICATION_DESC );
ServerAppDesc.guidApplication := AppGUID;
ServerAppDesc.pwszSessionName := StrToWChar( ''RPG Test'' );
ServerAppDesc.dwFlags := DPNSESSION_CLIENT_SERVER + DPNSESSION_NODPNSVR;
ServerAppDesc.dwMaxPlayers := 10;
ServerAppDesc.dwCurrentPlayers := 0;

// Host

hr := Server8.Host( ServerAppDesc, @LocalAddr, 1, nil, nil, nil, DPNHOST_OKTOQUERYFORADDRESSING );
if hr <> S_OK then
begin
debugstatus(''Host failed'');
end;

Result := hr;
end;


Share this post


Link to post
Share on other sites