Archived

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

shadowarts

DirectPlay SetSP error?

Recommended Posts

I''m confused whats happening with my app that is causing an error that doesn''t seem to be an error. if(FAILED(hResult = pDPAddress->SetSP(&CLSID_DP8SP_TCPIP))) { DISPLAYERRORCODE(hResult, "An error has occured"); } This always returns an error, but the error code is 0x0000000: The operation completed succsessfully. What would cause that?

Share this post


Link to post
Share on other sites
Are you running the debug runtime of DirectPlay? And if so, is its debug output maxed out? And if so, does DirectPlay post any messages to the debug output relating to the problem?

Share this post


Link to post
Share on other sites
the only thing im running in debug is direct3d, im not sure how to run directplay in debug, but i ran the msdn tutorial 2 which does up to what im trying to do with the same version of direct x, but there doesnt seem to be a problem running theirs, i dont see any difference in the order things are initialized for direct play. Heres the only info i got out of my debugger (same messagebox i have displayed for the error, yes i created the messsagebox error checks myself and they are not from an internal directplay error):

c:\gecko\engine\cdplay.cpp (60): Could not set DirectPlay address!
Error code 0x00000000: The operation completed successfully.

the part saying Could not set DirectPlay address! is just something I use to know what the error was, the strange thing is the error code, i dont know why its returning success, heres the actual code causing the problem:

if(FAILED(hResult = dpaAddress->SetSP(&CLSID_DP8SP_TCPIP)));
{
DISPLAYERRORCODE(hResult, "Could not set DirectPlay
address!");
return false;
}

I am writing this for a game engine and the FAILED has seemed to work well for directdraw, play, input, and show, i dont know why but it seems the FAILED() is making the mistake.

Ill do some more in depth debugging.

Share this post


Link to post
Share on other sites
You can select to use the debug runtime of DirectPlay in the DirectX Control Panel applet. Be sure to set its debug output to level 9 (maximum) to get maximum verbage.

Share this post


Link to post
Share on other sites
I may be wrong, but isn''t:

if(FAILED(result=function()))

always going to return false?

Same as doing if( some_int_var = 1 ) right?

you should either do it:

HRESULT hr = pDPAddress->SetSP(&CLSID_DP8SP_TCPIP);
if( FAILED(hr) ) {}

//or
if( FAILED( pDPAddress->SetSP(&CLSID_DP8SP_TCPIP) ) ) {}

Share this post


Link to post
Share on other sites
Have you called the "CoInitialize()" function to init DirectX.
If im not way off here i do recall something about having to call
that function if you are working with DirectX. Especially if you
create your objects with the Com functions. For Direct3D that is
usually no problem since they have helper classes that take care
of that, but if i recall correctly, DirectPlay dont have those
helper functions.

So test by placing a CoInitialize() somwhere in the beginning and
a CoUninitialize() somewhere in the end. Just a guess.

Share this post


Link to post
Share on other sites
im not getting any errors from DirectX Control Panel applet and it seems it could be my code, maybe its just something small I missed, but this is for a whole game engine and with all this code sometimes I just can''t see the problem clearly, goto http://shadowarts.ath.cx/downloads/engine_help.zip

There are a lot of files in there but the main ones of interest to you guys are probally CDPlay.cpp, CDPlay.h, and main.cpp those are the only files that are associcated with DirectPlay. Its just weird that hResult is returning S_OK (0x0...)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yes I call CoInitialize(NULL) as the second thing in the WinMain function, the only thing before that is making the variable msg. There doesnt actually seem to be a problem with it working, but FAILED() seems to be trapping an error thats not an error...

Share this post


Link to post
Share on other sites
We''ll I figured it out, and boy was it stupid, there was semicolon at the end of my if statement, lol, I must be blind, anyway thats for your help and showing me how to do more in depth debugging with DirectX! Wow I can''t believe I kept missing the fact there was a semicolon at the end, im not worthy of coding c++ lol! ty for your help;

Share this post


Link to post
Share on other sites