Page 1 of 1

Stats script for your own server?

Posted: Mon 28.07.2008, 19:05
by FlyveHest
Is it possible to get my hands on the stats scripts that are used on http://www.mangband.org/Main/Statistics ?

I am running a private MAngband server, and would very much like to serve stats like the ones available, but can't seem to find any information on how you do this?

Re: Stats script for your own server?

Posted: Mon 28.07.2008, 19:59
by Jug
No, not currently. The MAngband Project hasn't yet released a "stats script". We have a whole load of interrelated hacks for mangband.org itself, databases based on text file parsers based on cron based on wiki plugins based on custom php hacks based on voodoo based on witchcraft. :-)

For a small private site you may not need to worry about backend SQL databases or such an elaborate system. I recommend you look to the character dumps themselves. The first line is machine readable data which can be easily parsed.

It may be that we package up a series of scripts to do this one day, but we haven't as yet.

Re: Stats script for your own server?

Posted: Wed 30.07.2008, 06:53
by FlyveHest
The player files are the ones in lib\user\*.txt ?

Would it be possible to get an explanation for the individual fields? (Some are self explanatory, but others are not), or should I grab the source and try and get the information from there?

The highscore is in lib\data\scores.raw ?

I've looked at it in binary form, and it looks pretty easy to parse also, but, a short explanation about what the various "fields" do would very much be appreciated :)

Re: Stats script for your own server?

Posted: Wed 30.07.2008, 08:15
by Jug
Yes, the character dumps are saved in lib/user/ and are named <charactername>-<server-turn>.txt. The combination of character name and server turn gives you a unique key for any given character.

The machine readable line in the dump is the first line, and always begins with "#". Fields are delimited with "|".

Fields are:
  • score
  • gold
  • date died
  • character name
  • sex (m/f)
  • race index
  • class index
  • current character level
  • dungeon depth
  • max character level
  • max dungeon depth
  • killed by
  • mangband version id (1.1.0)
Race Index is an integer 0 to 10, the races are: 'Human','Half-Elf','Elf','Hobbit','Gnome','Dwarf','Half-Orc','Half-Troll','Dunadan','High-Elf','Kobold'

Class Index is an integer 0 to 5, the clases are: 'Warrior','Mage','Priest','Rogue','Ranger','Paladin'

Personally I wouldn't bother parsing the scores.raw file if you are parsing the dumps. We don't touch scores.raw on mangband.org. It works ok more or less in game, but it's broken in some subtle ways which make it unsuitable for a reliable ladder.

Re: Stats script for your own server?

Posted: Wed 30.07.2008, 08:55
by FlyveHest
Excellent, thanks a lot Jug, really appreciate it, will get into making a stats script later today :)

Re: Stats script for your own server?

Posted: Wed 30.07.2008, 14:54
by FlyveHest
Is it safe to remove the files from the user directory, when I have parsed them?

Or does the server use them for anything (ie, generating highscorelists later on?)

Re: Stats script for your own server?

Posted: Wed 30.07.2008, 16:05
by Jug
It is technically safe to remove the files, yes. The server never attempts to read any of these files.

However, a character who dies above level 20 gets a full character dump attached below this machine readable line, which you may want to keep...

Re: Stats script for your own server?

Posted: Wed 30.07.2008, 16:11
by FlyveHest
I'll just save them in a TEXT field in the DB, so i'll be able to grap needed information from them later.

Thanks a lot for the help. :)

Re: Stats script for your own server?

Posted: Thu 31.07.2008, 16:36
by FlyveHest
Another question has popped up, does MAngband write a "deathfile" when you die and become a ghost, or is it only when you die finally?

If it does, is it possible to distinguish between a death-to-ghost and a death-to-final file?

Re: Stats script for your own server?

Posted: Thu 31.07.2008, 20:15
by Jug
Ghosts don't feature in this process, just pretend they don't exist. :) MAngband writes a character dump when a character dies.

When a ghost is destroyed it has no effect on anything (the character was already dead) and no additional dump is written.