Page 2 of 2
Re: New stats - complete mod and map play time stats
Posted: 15 Mar 2010, 15:56
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:

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.
actually only just found out you actually
can use .tff fonts
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?
Re: New stats - complete mod and map play time stats
Posted: 15 Mar 2010, 17:16
by TradeMark
first load:
25.930733 seconds
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

)
14 lines of code, hows yours?

(not including the output code)
Re: New stats - complete mod and map play time stats
Posted: 15 Mar 2010, 18:12
by knorke
lol wat
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.
Re: New stats - complete mod and map play time stats
Posted: 15 Mar 2010, 18:17
by Satirik
knorke wrote:lol wat
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
Re: New stats - complete mod and map play time stats
Posted: 15 Mar 2010, 18:27
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

Re: New stats - complete mod and map play time stats
Posted: 15 Mar 2010, 18:28
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,

Re: New stats - complete mod and map play time stats
Posted: 15 Mar 2010, 18:36
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.
Re: New stats - complete mod and map play time stats
Posted: 15 Mar 2010, 19:18
by TradeMark
yep, that easy
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.
Re: New stats - complete mod and map play time stats
Posted: 15 Mar 2010, 19:29
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
