blackdtools / Blackd-Proxy-CLASSIC

Blackd Proxy CLASSIC
MIT License
9 stars 7 forks source link

SckClientGame_DataArrival doesn't handle TCP_NODELAY / Nagle's algorithm #9

Closed divinity76 closed 9 years ago

divinity76 commented 9 years ago

Sometimes, it happens rarely, but sometimes, in SckClientGame_DataArrival , when GetTheLong(packet(0), packet(1)) + 2 is NOT EQUAL to bytesTotal , the client used http://en.wikipedia.org/wiki/Nagle%27s_algorithm to try to send several packets at once. the result? the bot may completely ignore certain orders, and not learn correctly from packets, for instance, sometimes during pvp, sometimes i say "exiva 0" so everybody see it, instead of shooting an SD. makes it bloody obvious that im cheating. i only play tibia 7.6 these days, i don't know if it's an issue with newer client versions,hopefully Cipsoft disabled Nagle's Algorithm sometime after 7.6 (as it shouldn't be on for games where low latency is important), but i don't know.

divinity76 commented 9 years ago

interestingly, even when disabling Nagle's by default (like this http://www.pcadvisor.co.uk/how-to/internet/3427572/how-reduce-your-latency-in-windows-7/ ), tibia 7.6 still use it... almost as if it's manually enabling it, which would be weird (most program leave it at default)...

blackdtools commented 9 years ago

Well... in that case this would require to implement a buffer in Blackd Proxy to guarantee 100% sucess when reading commands from client. That would require a lot of time and a lot of tests, specially with critical cases... Sorry, I don't have time for that. But feel free to try doing it if you want. You will find that blackd proxy already manages a buffer for packet bytes received from game server. You could copy the functions and rework them to work in same way with game client. You might also have to do some other minor changes in several points. And of course you would have to do a lot of tests!

divinity76 commented 9 years ago

i have made a fix. all i have confirmed is that it completely fixes the issue in Tibia 7.6, which is good enough for my personal use. ill give you the code shortly, the logic isn't that hard, and i don't think it'd cause any problems for the newer versions, but i haven't tested. i hope you can do some testing. (the whole DataArrival code feels like a mess though, i think it could be rewritten and optimized a lot.. but that's beyond me for the time being)

divinity76 commented 9 years ago

please let met know if you reviewed it, and if you tested it, and if you found any issues with it