Sounds okay. I haven't compared the comparison between packets and frames, and I certainly would have no idea how to "hook DDraw". I'm getting closer to understanding the COM API for DirectX than I was when I started poking PT in sore places though. XD
When I reduced the Sleep(), and when I skipped the entire GetForgroundWindow() stuff... I struggled to type in notepad, let alone do anything else, so your method clearly has considerable benefits. However, I don't see any greater speed-up tapping F11, and I do by disabling all the 2D UI (HUD or WHY) and leaving the text in place.
I can certainly kill the PT client frame rate by patching it with
You must be registered to see links
though. XD (Text renders awesomely, but game is not playable)
Back to packet timing. I believe that there is one or more threads allocated to packet send. Each has a Sleep() or similar API associated with it, and a critical section object.
The method
I think is being employed (debugging around thread change and critical objects often leads to a threadlock or other crash) is that the thread goes idle by means of a sleep, leaving the game to get on with what it's doing until it's time for a packet of this type. Then the critical object is signaled, (I'm not sure what the Microsoftees for this is, but they are basically an object-oriented Mutex unlike anything in any other OS, just to be awkward) so any other thread which tries to do anything with the memory the packet dispatching thread is working on becomes suspended. The packet is created in a memory buffer (which I'm not sure if it creates and destroys every time a packet is to be dispatched or just creates and keeps present... I suspect they just use the threads heap or such) encoded and passed to WinSock to send out.
The the thread cleans up, releases the critical section and returns to it's Sleep().
There are a few places which perform this same basic task in a couple of different ways. I don't really understand them, but I can kinda identify them.
Same way as with frame rate, it's simple and safe enough to reduce the Sleep() time.
If all your clients are doing it, you need to allow for that in your server bandwidth though... especially if the server spits out a packet to anyone nearby any player when ever they send it a packet.
Would be nicer if changing a clothing item, or starting / stopping / turning would trigger the packet generation, and the time-out only applied if you are stood still doing nothing... so the connection remains in "keep alive".
Unsurprisingly, I'm pretty sure it doesn't work the "nice" way.
: