Sunday, November 20, 2011

MTUDP.cpp NetLib Bug fixes.

WARNING - I should remove this post, but instead will give a warning.  Do not use the MTUDP.cpp library as is.  It has many bugs and makes a fatal mistake.  The user ID is the IP address.  This breaks if there is a fire wall in the way, and there is always a firewall.  I have nearly rewritten the library with very little of the original code left over.


I have been using the MTUDP.cpp library from the book
Advanced 3D game programming with DirectX 10.0 By Peter Walsh

The library has many bugs that I have been fixing over time.

Several are...

The library send all packets twice, which is unnecessary. So in MTUDP.cpp I comment out the three sections where that happens. Look for secondPacket to find the blocks.

In NetLibHost.cpp there is a big problem with the Ack generation loops. They initialize the mask to 0x80 and if there are no additional Acks, then the later count returned is off by one since the mask is not zero. The mask should be initialized to 0x00. (two places in the code. Search for mask = 0x80;) WARNING - WRONG - SEE NEXT POST

The Ack record can be truncated in AddAckMessage it checks to see if the the length is exceeded and if it is it truncates, but the count of additional acks is not adjusted, boom! I don't have a fix for this except make sure no packets approach the max packet size boundary. I put an assert in to check if you run off the end.

I noticed that on creation the Host record does not initialize the ping times and last packet time. Hmmm, haven't worked on that one yet.

Hope this saved some poor soul some time.


No comments: