Tremulous Forum

Mods => Modding Center => Topic started by: Syntac on October 13, 2008, 01:02:15 am

Title: Tremulous Snapshots
Post 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?
Title: Re: Tremulous Snapshots
Post by: Bissig on October 13, 2008, 01:10:15 am
You mean something like the thing called "tremstats"?

http://tremstats.dasprids.de/
Title: Re: Tremulous Snapshots
Post by: Syntac on October 13, 2008, 01:17:52 am
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.
Title: Re: Tremulous Snapshots
Post by: Bissig on October 13, 2008, 01:19:01 am
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!
Title: Re: Tremulous Snapshots
Post by: Syntac on October 13, 2008, 01:48:28 am
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.
Title: Re: Tremulous Snapshots
Post by: Undeference on October 13, 2008, 03:44:21 am
Now I just need to know how to query the master server.
send (to master.tremulous.net:30710)
Code: [Select]
\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
Code: [Select]
\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.,
Code: [Select]
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
Title: Re: Tremulous Snapshots
Post by: Syntac on October 13, 2008, 03:50:07 am
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.
Title: Re: Tremulous Snapshots
Post by: David on October 13, 2008, 12:11:40 pm
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.
Title: Re: Tremulous Snapshots
Post by: Syntac on October 13, 2008, 03:46:51 pm
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!