Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Using Multisync in DarkGDK

Author
Message
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 18th Dec 2007 06:46 Edited at: 19th Jan 2008 10:34
I've compiled a version of Multisync specifically for use outside of DBP, and added support for returning string objects. I'd upload an example DarkGDK project if I could, but as I can't I'll just explain how to set the project up for use with Multisync. You can download Multisync directly from here.

From the download, copy all files in the Other Languages folder into your project directory. Include "Multisync.h" in any source files you want to access the functions from. That's it, it's set up.

All function names are the same as their DBP equivalents, with the spaces missing between words (check the header file if you're not sure). There are two versions of each function that returns a string. For one version you pass in your own buffer and supply a buffer size, and for the other version you can return a string*. Example:



* I've temporarily removed support for std::string due to problems with it.

Hope you guys find this useful.

jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 18th Dec 2007 14:49
Benjamin - this is very nice of you. You've been very helpful to a lot of people - YOU ARE COOL!

God of Thunder
16
Years of Service
User Offline
Joined: 17th Dec 2007
Location: Middle of nowhere, Australia
Posted: 19th Dec 2007 03:40
G'day Benjamin,
I douwnloaded multisync and put all the files from the other languages folder into my project. However when i type #include "multisync.h" I get linker errors.

error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)

error LNK2019: unresolved external symbol __free_dbg referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)

also i get this warning

warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

I'm using VS 2008 express and probably have set it up wrong somehow. Any thoughts would be greatly appreciated. Realy looking forward to using multisync.

Only those who have been through Hell can see Heaven.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 10th Jan 2008 21:21
I'm new to C++ and I don't understand how to use:



Specifically the char * ipAddress part. Could you give me a working example of this command please?
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 10th Jan 2008 22:39
Ben,
Would it be possible to use this say, with a Server that is not running a DarkGDK app but with an App written in C++/C#/Java etc...?

No Kittah, this is my potpie!!!
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th Jan 2008 22:54
Ben will probably come on here and set you straight Michael, but I found that the IP is just a "DWORD" however in network protocols you need to swap the low order and high order bytes usually. If in his header he doesn't have a type like:



Then you might need to make one. Also, on cplusplus did you read about unions? I forget exact syntax but they let you have user defined types like that above BUT you can definae the "SAME MEMORY" to be addressed differently.... something like:



And then you can make a pointer for it...this is pixel obviously

uRGBA *MyRGBA = new uRGBA();

Then you can do things like:

MyRGBA->Pixel=12345567;

or

MyRGBA->Blue=200;

Which is like setting individual OCTETS in IP address... by only changing bytes or using whole thing.

Benjamin might have done all the behind the scene byte order changing for you, and you might just need the iPAdress structure - which might just be a unsigned long, DWROD or some other 4 byte variation that will house this value.

SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 11th Jan 2008 01:49
I had followed the same directions and got the same issue.

No Kittah, this is my potpie!!!
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Jan 2008 02:23 Edited at: 11th Jan 2008 02:24
Quote: "I douwnloaded multisync and put all the files from the other languages folder into my project. However when i type #include "multisync.h" I get linker errors."
That might be my fault. I couldn't remember if DarkGDK used the debug version of the CRT or not, so I compiled it to use it. I seem to remember that the DarkGDK libraries use the other version of it, which would explain the errors. Try using the attached files and see if they work for you.

Quote: " Specifically the char * ipAddress part. Could you give me a working example of this command please?"


Here are a few ways it can be done:



Quote: "Would it be possible to use this say, with a Server that is not running a DarkGDK app but with an App written in C++/C#/Java etc..."

Yes, as long as it acts the same.

Quote: "however in network protocols you need to swap the low order and high order bytes usually"

I've read this in various places, although I'm a bit confused about that one. If you run "127.0.0.1" through inet_addr and then check the resulting value, you notice that 127 is actually stored at the lowest address. The port however is always stored in network-byte order.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)

Attachments

Login to view attachments
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 11th Jan 2008 03:34
1: I think it's cool you set up a string conversion for uyour octets for ease of use.

2: the byte swapping is weird. I've read it and seen snippets in various languages... especially when getting down to linux sockets and WinSock places where they use it... Yeah - I don't have it 100
% down either - I just bang at it until I get it and move on usually don't need to touch it again.

I think the 127 being at lowest byte (Byte 0) is correct for the "SWAPPED", otherwise I'd suspect it in MS Byte (Most Significant)

But - if I can connect to a known server outside my firewall and get a response - I know I have it - that's good enough for me until tcpip6 is the only way to get around.

SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 11th Jan 2008 04:16
Actually, it works if you switch it from Debug to Release.

No Kittah, this is my potpie!!!
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Jan 2008 04:47 Edited at: 11th Jan 2008 04:47
Quote: "I think the 127 being at lowest byte (Byte 0) is correct for the "SWAPPED", otherwise I'd suspect it in MS Byte (Most Significant)"

Indeed. After a bit of thinking I realise 127 is actually the most significant byte in this case, hence it being stored at byte 0 when converted to network byte order.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 11th Jan 2008 05:02
Wow, so I got the program to compile. When I am not running the Java Server on port 8000, my program tells me that it can't connect which is expected. However when I run the server, it establishes a connection which I can see by netstat -a, however the DarkGDK App locks up hard.

No Kittah, this is my potpie!!!
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Jan 2008 05:26 Edited at: 11th Jan 2008 05:26
This is because when the client first connects it waits for data from the server. From the manual:

Quote: "
* When the client initially connects, it waits for 3 bytes of data from the server. The first unsigned short integer (2 bytes) is set to 0 if the client is allowed to join the game, else it is set to 1. The third byte is ignored at this time but must be transmitted anyway.

* Each message is prefixed with an unsigned short integer defining the size of the message.

* The ping message sent by the server, and the ping response sent by the client, consists of 2 bytes set to zero. "


Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 11th Jan 2008 17:39
Oh ok, that makes sense now. I will work on getting that portion into the Java Application.
Hey I have a question, how big can messages be?

No Kittah, this is my potpie!!!
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Jan 2008 17:49
Up to 2048 bytes, which excludes the size prefix.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 17th Jan 2008 15:50
What operating systems is this plugin compatible with?
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 18th Jan 2008 18:29
Possible bug:

I've found that when I use NetGetString(); and the string it is trying to get is above 15 characters long I get the following error:



After clicking break:


After clicking show disassembly:
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 18th Jan 2008 18:37 Edited at: 18th Jan 2008 18:43
Without seeing any code I can't say for certain if it is a bug. [edit] After looking at that disassembly I can see that it's executing code it's not supposed to, and it's hitting a breakpoint. I'm not sure why this would happen. Either way, it doesn't seem to indicate whether it's a bug in your code or mine.

Quote: "What operating systems is this plugin compatible with?"

I haven't actually tested this on various systems, so I'm not sure. I think I can safely say that it'll work for all versions of Windows from XP and onwards, and it should work with 98 and 2000 although I haven't tested it.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 18th Jan 2008 20:23 Edited at: 18th Jan 2008 20:53
Okay, I made some really quick code here that demonstrates the problem:

Server:



Client:



[EDIT] There's also this, that comes up after breaking:
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 18th Jan 2008 20:54 Edited at: 18th Jan 2008 21:07
Somehow my post posted itself twice
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 19th Jan 2008 10:47
It appears the crash is coming from the fact that the EXE and the DLL are using their own CRT libraries, which causes corruption due to one heap manager trying to free memory allocated by the other heap manager.

It's possible to solve this problem by dynamically linking with the CRT library (Multi-threaded DLL (/MD)) but to my knowledge DarkGDK won't compile with this. Thus, I suggest you use the alternative functions that write to a user-supplied buffer until I have time to figure out a solution.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 19th Jan 2008 11:03
Quote: "alternative functions that write to a user-supplied buffer "


Newbie Question: Do you mean the other 'net put' commands? So, I could send a series of integers containing the character codes of each character instead of sending a string?
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 19th Jan 2008 11:20
I'm referring to NetGetError, NetGetPlayerIP, and NetGetString. You pass two parameters; a pointer to a buffer to store the resulting string, and the maximum size of the buffer, like this:



Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 24th Jan 2008 17:58
Thanks, the alternative function works great. I have a new question for you, on a new topic regarding multisync.

The following code when used with 1 client demonstrates that the server believes that the client has the ID of 1 whilst the client believes that the server has this same ID (of 1).

Client:


Server:


Should this be the case? I thought that ID's were universally the same between client and server. If this were true then the server would see the client's ID as 2 rather than 1?
Deagle
18
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Finland
Posted: 25th Jan 2008 13:43
Is there any working example applications for GDK and Multisync? I just cant get my programs work, an example program would be nice.

Deagle aka D-Eagle
Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 25th Jan 2008 14:50
Quote: "Should this be the case? I thought that ID's were universally the same between client and server. If this were true then the server would see the client's ID as 2 rather than 1?"


Server = 0
Client1 = 1
Client2 = 2
Client3 = 3
...

I think the IDs goes like that and im glad it goes


Click For Details!
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 25th Jan 2008 14:57
Quote: "The following code when used with 1 client demonstrates that the server believes that the client has the ID of 1 whilst the client believes that the server has this same ID (of 1)."

The server has no ID. NetMessageFrom is only for the server to find out the client that sent it the message.

Quote: "Is there any working example applications for GDK and Multisync? "

As I said in my original post, I can't make an example as I don't have DarkGDK set up. I'd appreciate if someone could convert one of the DBP examples and post it here.

Deagle
18
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Finland
Posted: 25th Jan 2008 15:16
But shouldn't this multisync work with just a console application? But anyways, i'll try to convert an example and post it here.

Deagle aka D-Eagle
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 25th Jan 2008 15:20
Quote: "But shouldn't this multisync work with just a console application?"

Yes, but it won't tell you how to get it working with DarkGDK. You have to write extra code if you just use it from a console application.

Deagle
18
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Finland
Posted: 3rd Feb 2008 09:40
But if i wanted to make the server in a console application, how would that be done?

Deagle aka D-Eagle
Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 3rd Feb 2008 12:12
I am intrested in this aswell


Click For Details!
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 3rd Feb 2008 13:44 Edited at: 3rd Feb 2008 13:47
Ok, first you need to make sure you have multisync.h and MultisyncDLL.lib in the same place as your source file (or just in a place where the compiler can find them), and MultisyncDLL.dll in the directory you run the application from. Regardless of whether you already have the files or not, you'll probably need to re-download them from here as I've just made some changes.

Server:



Client:



Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 3rd Feb 2008 13:54
Awesome Now i can make console servers wich are awesome


Click For Details!
Deagle
18
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Finland
Posted: 3rd Feb 2008 14:23
Thanks man, it works great!

Deagle aka D-Eagle
Deagle
18
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Finland
Posted: 3rd Feb 2008 16:37 Edited at: 3rd Feb 2008 16:38
One thing, could you make it so, that you could use the send commands like this: NetPut<type>(var);
like,
or, you could have a class 'cSheep', and do:

and

It would be cool.

Deagle aka D-Eagle
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 4th Feb 2008 21:26
It's something I'll think about for the future. For now I may just add a function to allow you to copy a block of data into the message.

Elspin
16
Years of Service
User Offline
Joined: 30th Mar 2008
Location:
Posted: 5th Apr 2008 10:15
This doesn't make any sense, SoulMan had the same problem above, his application was locking up as soon as a client tried to connect, which is exactly what happened to mine; but the reason you gave makes no sense because there's examples here (ie Michael P's test) that don't do that, and also don't lock up...
bobba
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 11th Apr 2008 06:54
Greetings,

I am trying to use Multisync in a RTS game I am making. If anyone could post a DarkGDK example that would really help.

I read that Multisync uses the client/server networking model. How will this affect the game if the Host player is killed or leaves the game, can the other players continue?

I think i understand how to set up a server and have client’s connect. But what I am struggling to understand is how it works once the game is running.

Can the clients communicate directly or does all information pass through the host?

Any help would be appreciated.


Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 11th Apr 2008 09:51
With a server/client model, all clients can only communicate with the server. Here is a pretty little picture to explain this:


Normally RTS games use peer to peer because permanent servers for an RTS game would never be needed, since a server only needs to be set up once all players are ready to begin a new RTS game.

You can use server/client however, except one player needs to be the server. If the host leaves then the other player's can't continue. This shouldn't be a problem really since in RTS games, if a player leaves the game normally becomes unfair.

The client communicates only with the server but the server can redirect any messages to any players.
bobba
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 11th Apr 2008 10:54
Nice 1 m8, i get it now, Im a compleate networking noob so the pretty little picture realy helped.

Quote: "This shouldn't be a problem really since in RTS games, if a player leaves the game normally becomes unfair."


Sometimes true, but what about Free For Alls or 2v2v2 etc.

If Multisync can only do server/client then how do I go about implementing peer to peer?

Could anyone give any advice on coding a Master Server? By this I mean one that is permanently connected to the net and holds the games that people are hosing. I assume this would have to be server/client based so Game Hosts can find it via a fixed IP address.

Any help, advise or pretty little pictures would be appreciated.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Apr 2008 16:02
Quote: "SoulMan had the same problem above, his application was locking up as soon as a client tried to connect"

Assuming you're running a different server just like SoulMan was, did you read my replies to him?

Quote: "If Multisync can only do server/client then how do I go about implementing peer to peer?"

You can't in Multisync. I wouldn't advise peer-to-peer anyway, because these days practically everyone has a router and a peer-to-peer game requires that everyone configures port forwarding on their router, rather than just the host.

bobba
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 20th Apr 2008 10:03
I would just like to say thanks to Benjamin for all his helpfull comments not only on this thread but in others.

This page is a good starting point for any network noobs (like me)

http://beej.us/guide/bgnet/output/html/multipage/intro.html

Login to post a reply

Server time is: 2024-05-05 06:12:44
Your offset time is: 2024-05-05 06:12:44