Tremulous Forum
Mods => Modding Center => Topic started by: Syntac on October 13, 2008, 01:02:15 am
-
I've been thinking of writing a PHP script that takes a snapshot of the entire Tremulous "network" (not sure what you'd call it; every server and every player). It would go something like this:
1] Query the master server.
2] Using the list obtained from that, query each server for information like the current map, number of players, each player's status, etc.
3] Save the resulting massive quantity of data into some sort of database (probably multi-file).
4] Allow visitors to browse the snapshot archive.
Should be pretty easy. However, I don't know how to implement steps 1-2. Does anyone have any ideas?
-
You mean something like the thing called "tremstats"?
http://tremstats.dasprids.de/
-
Not exactly. The idea behind this is to retrieve a list from the master server, then get information for each server on that list (without having access to its log files). Ideally, retrieving information from a server would work the same way the master does it.
-
Too bad this one is not open source:
http://www.qtracker.com/
But this one:
http://www.linuxgames.com/xqf/index.shtml
is based on this:
http://www.qstat.org/
It is open source!
-
Thanks.
Although, all I really need is some sort of PHP code that sends and receives messages (and then parses the response into something recognizable). Do you know how I'd do that? For example, sending something via fsockopen(), to which a server would then respond with data?
I'm afraid you're going to be hearing a lot of questions from me, because I've never even attempted something like this before.
[EDIT] Ah... Found something that may be of use. http://tremulous.net/forum/index.php?topic=8750.0 Now I just need to know how to query the master server.
-
Now I just need to know how to query the master server.
send (to master.tremulous.net:30710)
\xff\xff\xff\xffgetservers <protocol> [keywords]
\xff\xff\xff\xffgetserversExt <gamename> [keywords]
protocol is 69 for old, 70 for new
keywords is optionally "empty" and/or "full" (and/or "ipv6")
receive
\xff\xff\xff\xffgetserversResponse\\addrport...EOT\0\0\0
\xff\xff\xff\xffgetserversExtResponse/addrport...EOT\0\0\0
addr is packed (4 (or 16) bytes), port is packed (2 bytes) -- in php, you should able to use inet_ntop(addr), unpack("n",port)
packet ends with EOT\0\0\0, more packets may follow
(the master doesn't currently support IPv6 and when it does, there's no guarantee that the Ext forms will work as mentioned)
e.g.,
c->s \xff\xff\xff\xffgetservers 70 full empty
s->c \xff\xff\xff\xffgetserversResponse\x5cT\x9dc\x85x\x00\x5cb\xc1\xe5\xc4x\x00\x5cEOT\x00\x00\x00
-
Cool, thanks. I'll give that a try.
[EDIT] I definitely got a response. However, I have no idea how to turn it into something I can use. Does anyone have some code I could take a look at?
[EDIT#2] Working on it...
[EDIT#3] Woot, figured it out. Expect something called TremSnaps in the near future.
-
I already have C++ classes that do all this, including keeping a list in memory up-to-date and concurrent connections etc etc.
If you want I can slap a GPL sticker on it and upload it all someplace.
Also if you have any questions about the connectionless protocols feel free to ask me, I know that shit like the back of my hand.
-
If something weird happens with my code, I'll be sure to ask you. Not sure I'll need the C++ stuff, though. Thanks for offering!