I'll start with the UDP versus TCP...
UDP, unlike TCP, is connectionless, that is, there is no persistent connection between the client and the server. When data is recieved by either end, they can determine which IP the data was sent from, and therefore can incorporate a quasi-session based system. UDP has the advantage of being able to send data faster, because it has no overhead associated with packet sequencing, re-sending, etcetc. FPS games have an advantage over other games, that is, the speed at which the game is being played, missing the odd packet or two is not a worry, as the data lost will soon be masked by the new data arriving almost instantly after. Of course problems arise when large amounts of packets are lost, and this is often usually the case.
To keep the game simple, I would suggest TCP, as it makes the network layer simple, and allows you to concentrate on getting the rest of the system working
. Something that might interest you is that DirectPlay incorporates UDP transmission methods with its own management for packet loss and packet re-sequencing.
IOCP may be a good idea for the server, as they allow Windows to manage the thread pool for active connections over multiple processors(should they exist), instead of you having to do the work yourself. Some information on IOCP can be found here:
http://www.codeproject.com/internet/iocp.asp
As for the client, non-blocking sockets are suffient, as you will probably be only handling one or two TCP connections.
The world array that you've created is definitely not the best way to go about it, as you're having to scan through this every time a player moves, so you can send information to them. A better way to create the map is to pre-segment it, that is, split the map into 6x4 tiles for example(note: the size of the segment should be no smaller than the area of tiles visible on the screen). So when a player steps into another segment, you simply send the object data for this segment. When a creature moves around, check to see which players are currently in the segment the creature resides in, and send the new position of the creature. The client will also need to recieve updates on the surrounding 8 segments, so that transitions between segments are not visible by a hoarde of creatures suddenly appearing.
Bookmarks