tailieunhanh - Advanced 3D Game Programming with DirectX - phần 6

Trước khi nó có thể tạo ra một con đường hợp lý, nó phải được xác định. Ví dụ, nếu điểm đến mong muốn một của sinh vật (giao với nó từ các mã động cơ) là các bên khác của một khe núi dốc đứng, một con đường hợp lý có thể sẽ được để đi bộ cầu gần nhất, qua các khe núi, sau đó đi bộ đến mục tiêu. | if result count turn off the mutex and throw an error - could not send all data. if result SOCKET_ERROR turn off the mutex and throw an error - sendto failed. if defined _DEBUG_DROPTEST endif if pStr pHost- GetOutQueue .AddPacket pStr length cMonitor MutexOff Since I ve covered most of this before there are only four new and interesting things. The first is _DEBUG_DROPTEST. This function will cause a random packet to not be sent which is equivalent to playing on a really bad network. If your game can still play on a LAN with a _DEBUG_DROPTEST as high as four then you have done a really good job because that s more than you would ever see in a real game. The second new thing is sendto . I think any logically minded person can look at the bind code look at the clearly named variables and understand how sendto works. It may surprise you to see that the mutex is held for so long directly contradicting what I said earlier. As you can see pHost is still being used on the next-to-last line of the program so the mutex has to be held in case the other thread calls MTUDP HostDestroy . Of course the only reason it has to be held so long is because of HostDestroyO. The third new thing is MTUDPMSGTYPE_RELIABLE. I ll get to that a little later. The last and most important new item is cHost GetOutQueue . Just like its counterpart GetOutQueue provides access to an instance of cQueueOut which is remarkably similar but not identical to cQueueIn. class cQueueOut public cMonitor protected list cDataPacket d_packets 356 DWORD d currentPacketID d count number of packets added to this queue. public cQueueOut virtual cQueueOut void Clear void AddPacket const char const pData unsigned short len void RemovePacket DWORD packetID bool GetPacketForResend DWORD waitTime cDataPacket pPacket bool GetPreviousPacket DWORD packetID cDataPacket pPacket cDataPacket BorrowPacket DWORD packetID void ReturnPacket DWORD GetLowestID bool IsEmpty inline DWORD GetCurrentID returns d_currentPacketID. inline .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.