( search forums )
ConsoleLog More Friendly for parsing.
Soldat Forums - Soldat Talk - Game Improvements / Suggestions
Dark_Noddy
February 27, 2005, 6:29 pm
Whenever some1 say something in a game, it ends up in the console log.. This log can be used by external applications/scripts BUT
(same goes for the msgs from server if you connect via sockets etc.)
When parsing a string you need to split it.. Doing this can be quite hard unless you have some sort of syntax..
The Soldat one is "[nick] msg" But as you can aslo have ]/[ in the nick itself.. This is not a very good way to do this :/

My suggestion is that the msgs should be foramtted in a better way for parsing.. like I dunno.. spilt up by chrs with ascii value 1 () and restrict nicks from containing it..

making the server send out in the syntax NickMsg wouldnt be to hard I reckon.. and just let the clients parse it..

anyways It would be grate..

/me puts on FlameSuit..

papasurf31
February 28, 2005, 3:04 pm
j00 spelled GREAT RONGG!!!1!111

good idea though. It doesn't really affect much but it would be good.

mar77a
February 28, 2005, 3:19 pm
Mmm, it's kinda useless, check http://dyn.u13.net:6080/saidwhat.php . Our hero FliesLikeABrick could manage to to filter the names that contain [ ]...So it's not thaaaaaat necesary...

Dark_Noddy
February 28, 2005, 10:45 pm
Hmmm.. Thx for pointing that out :) I'ma talk to flies !

FliesLikeABrick
March 1, 2005, 1:44 am
the console log is pretty easy to parse, you just have to think about it for a second :P. If you want to see how i parse it, look in the u13sss update script, although that doesn't parse it looking for lines of chat. the code is short, so i will enlighten you with it here rather than paste it on IRC and get the boot for flood:

$lognumber=1;

$logfolder= 'logs';
$filenumber=$lognumber;
$filename=$logfolder.'ConsoleLog-'.$filenumber.'.txt';

//UPDATE CONSOLELOG STATS

while(file_exists($filename)) {
$content=file($filename);
$lines=count($content);
for ($i=0;$i<$lines;$i++) {
if (strstr($content[$i],"] ") && strstr($content[$i]," [")) {
$linelength=strlen($content[$i]);
$end=$linelength-(strpos($content[$i],"] "));
$start=strpos($content[$i],'] ')+2;
$length=($linelength)-($end)-(18);
$name=substr($content[$i],$start);
$name=str_replace("(1)","", $name);
$name=str_replace("(2)","", $name);
$name=addslashes(str_replace("(3)","", $name));
$name=trim($name);

if($name!='') {

$query="select hits from saywhat where comment='$name' limit 1";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$count=mysql_num_rows($result);
if(!$count)
$query="insert into saywhat (hits,comment) values ('1','$name')";
else
$query="update saywhat set hits=hits+1 where comment='$name' limit 1";

mysql_query($query);
}
flush();
}

}
$lognumber+=1;

$logfolder= 'c:\\soldat\\logs\\';
$filenumber=$lognumber;
$filename=$logfolder.'ConsoleLog-'.$filenumber.'.txt';
echo "file number $filenumber added<br>";
flush();
}


Edit: Also, there is a slightly better way to do this. This way tends to get confused when someone has [ and ] in their name, so it would be best to throw something else in there that has it use the last occurance of ] from the right end of the string (if it finds more than oen occurance of ] in the string)

Dark_Noddy
March 1, 2005, 5:00 pm
hehe, Thats bout what I got now.. Only thing is that I need the nick.. and I need it to be complete.. anyways I'll just use whole [nick] in my matchings.. (with the nick enclosed in []) as its less likely that ppl use a [ or ] in the msg itself then in the nicks :) Thx alot Flies !

FliesLikeABrick
March 1, 2005, 5:09 pm
as for parsing it for flag/join/part/grab/return/other stats, look at the algorithm in U13SSS. I am about to release another U13SSS which has a much more optimized parsing algorithm, since the original one was written when i was something of a php newb a year and a half ago

mar77a
March 1, 2005, 7:48 pm
Smart boy, neat code...

What is the flush() for?



FliesLikeABrick
March 1, 2005, 7:52 pm
flush() flushes the output buffer and sends any residing text to the client without waiting for the buffer to fill