New stats - complete mod and map play time stats - Page 2

New stats - complete mod and map play time stats

Various things about Spring that do not fit in any of the other forums listed below, including forum rules.

Moderator: Moderators

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: New stats - complete mod and map play time stats

Post by knorke »

sadly i have no clue of php. might want to learn it sometime for epic weblolz but too lazy.
but yes, it outputs to textfile (for c&p)
c++ btw.

with the sdl i was just messing around, like adding this sweet ass-console that is also scrollable:
Image
and a nice spinning something to the left that spins so i know the program is not crashed/hang up. the console uses a bitmap font for retro look. :shock:
actually only just found out you actually can use .tff fonts :roll:

just wondering, how fast does your php do this? i think php might actually more usefull for such tasks because it has nice functions for tables and whatnot so very clean code?
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: New stats - complete mod and map play time stats

Post by TradeMark »

first load:
25.930733 seconds :shock:

after second (and any amount of next loads):
6.015762 seconds

(php has some epic caching thing i guess)

Edit 3: optimized a little more (1.9secs off :regret: )

14 lines of code, hows yours? :P (not including the output code)
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: New stats - complete mod and map play time stats

Post by knorke »

lol wat :shock:
mines probally 100-200 lines depending how you count it.
http://pastebin.org/113360
only the relevant functions.
The data structure stuff is so complicated because did not just want to add up totals but maybe expand it later to make graphs. (popularity / time)
maybe.
For some things there might be something in the stl (Standard Template Library) but uhm yea, I don't know.

mind posting yours?
Might convience me to have a look at php, maybe.
Satirik
Lobby Developer
Posts: 1688
Joined: 16 Mar 2007, 18:27

Re: New stats - complete mod and map play time stats

Post by Satirik »

knorke wrote:lol wat :shock:
mines probally 100-200 lines depending how you count it.
http://pastebin.org/113360
only the relevant functions.
The data structure stuff is so complicated because did not just want to add up totals but maybe expand it later to make graphs. (popularity / time)
maybe.
For some things there might be something in the stl (Standard Template Library) but uhm yea, I don't know.

mind posting yours?
Might convience me to have a look at php, maybe.
you should use the stl map
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: New stats - complete mod and map play time stats

Post by knorke »

cool, that looks exactly what i would have needed. thanks.
Also I think that nested loop in calc_percent () isnt really good for performance and maybe could have been done been directly when reading the file...but maybe this way its more organized and took less thinking :roll:
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: New stats - complete mod and map play time stats

Post by TradeMark »

knorke wrote:mind posting yours?
Might convience me to have a look at php, maybe.

Code: Select all

<?php

$kanta = glob("J:/stats/*.maps");
$totalminutes = 0;
$maptimes = array();

foreach($kanta as $tiedosto){
    $filu = file($tiedosto);
    $max = count($filu);
    for($u = 0; $u < $max; $u++){
        $osa = explode("|", $filu[$u]);
        $minutes = (int)$osa[1];
        $maptimes[strtolower($osa[0])] += $minutes;
        $totalminutes += $minutes;
    }
}

arsort($maptimes);

// loop array and output here
foreach($maptimes as $mapname => $minutes){
    $percent = round($minutes/$totalminutes*100, 2);
//...
}

?>
sorry for the finnish in my code, :roll:
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: New stats - complete mod and map play time stats

Post by knorke »

so you can simply do
$kanta = glob("J:/stats/*.maps");
and it gets all the .maps files in a folder?

pretty nice actually, only think i do not like is how its not possible to tell what kind of variable something is.
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: New stats - complete mod and map play time stats

Post by TradeMark »

yep, that easy :regret:

you can even do "recursion":
$kanta = glob("J:/*/*/*/*/*/*/*/*/*/*/*/*/*.maps");
would find probably any .maps files from that drive :-) not really nice looking code but it should work.

Most of the time you dont really need to know which type the variable is. However, you can still use C style (int) and (float) and (string) to convert into different datatypes. is_int() is_float() is_array() is_string() can check which type they are.
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: New stats - complete mod and map play time stats

Post by Tribulex »

lol at mod names :)

someone, I cant remember who (think it was smoth or kdr) used to host battles with mods that had some sort of political statement as a name. they probably dont have any playerminutes though :(
Post Reply

Return to “General Discussion”