Unity-Technologies / qstat

New official qstat repository
Artistic License 2.0
121 stars 33 forks source link

fix gamespy master server query for small list, handle binary response #32

Closed illwieckz closed 7 years ago

illwieckz commented 9 years ago

Hi, the current gamespy master server query have many issues.

For example, currently the following query works (text format, many servers, so more than 2 packets):

qstat -gsm,bfield1942 gsm.qtracker.com

Currently the following query does not work (text format but not enough servers so only 2 packets, only one server list packer):

qstat -gsm,rune gsm.qtracker.com

Currently the following query does not work (binary format):

qstat -gsm,mohaa gsm.qtracker.com

So, this PR fixes these two issues and rewrite some part to get a cleaner and safer code:

This code was successfully tested against these use cases:

qstat -gsm,bfield1942 gsm.qtracker.com
qstat -gsm,rune gsm.qtracker.com
qstat -gsm,mohaa gsm.qtracker.com
qstat -gsm,rune master.333networks.com:28900
qstat -gsm,ut master.errorist.tk:28900
qstat -gsm,ut master.noccer.de:28900 

And some other combinations.

illwieckz commented 9 years ago

Note: this PR can be merged before others.

stevenh commented 9 years ago

Overall for new code blocks please use trailing brace style e.g.

if (condition1 || condition2) {
...
} else {
...
}
illwieckz commented 9 years ago

Is it really needed since all that will be revamped? I don't like to mix different style in the same block (like a function block), and all this stuff will be rewritten.

However, even if all these feedbacks are annoying, thank you very much for your meticulous review, for sure you read my code considerately. :wink:

stevenh commented 9 years ago

If it was all consistent with the existing style I would agree but atm its quite a mixed bag, so at the very least it should be self consistent :)

illwieckz commented 9 years ago

yeah, that part is one of the worst part (not only style) I ever read in qstat :scream: (one of the other very ugly qstat part is the template code :no_mouth: ), the kind of stuff you'll never accept these days, hopefully. :laughing:

stevenh commented 7 years ago

Any intention to address the outstanding comments?

illwieckz commented 7 years ago

code rebased, revamped and uncrustified

illwieckz commented 7 years ago

Things done in this PR (see first comment for details):

Things not done in this PR:

Only unsecure gamespy protocol is supported by qstat, qstat was never able to grok it (that's why XQF used gslist in the past for that task for example) so this part was left untouched, adding support for the secure protocol must be another PR (see gsmsalg.h for a reference implementation).