--- deliantra/Deliantra-Client/DC/Protocol.pm 2006/06/12 13:26:14 1.32 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2006/06/15 13:40:02 1.35 @@ -10,6 +10,8 @@ use base 'Crossfire::Protocol::Base'; +our %open_logs; + sub new { my $class = shift; @@ -61,6 +63,30 @@ $self } +sub logprint { + my ($self, @a) = @_; + my $filename = "$Crossfire::VARDIR/log.$self->{host}"; + + my $fh = $open_logs{$filename}; + unless ($fh) { + # FIXME: handle this more gracefully? + open $fh, ">>", $filename + or die "Couldn't open logfile: log.$self->{host}: $!"; + + $open_logs{$filename} = $fh; + } + + my ($sec, $min, $hour, $mday, $mon, $year) = localtime (time); + + my $ts = sprintf "%04d-%02d-%02d %02d:%02d:%02d", + $year + 1900, $mon + 1, $mday, $hour, $min, $sec; + + print $fh "$ts ", @a, "\n"; + $fh->flush; +} + + + sub stats_update { my ($self, $stats) = @_; @@ -81,6 +107,7 @@ push @{$self->{record}}, $command; } + $self->logprint ("send: ", $command); $self->send_command ($command); ::status $command; } @@ -281,7 +308,7 @@ my $txn = $CFClient::DB_ENV->txn_begin; my $status = $self->{facemap}->db_get (id => $id); if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { - $id = ($id || 16) + 1; + $id = ($id || 64) + 1; if ($self->{facemap}->put (id => $id) == 0 && $self->{facemap}->put ($hash => $id) == 0) { $txn->txn_commit; @@ -371,6 +398,8 @@ [0.74, 0.65, 0.41], ); + $self->logprint ("info: ", $text); + my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0]; # try to create single paragraphs of multiple lines sent by the server @@ -781,8 +810,6 @@ my ($msg, @kw) = split /\x00/, $msg; $self->{kw}{$_} = 1 for @kw; - warn "<<<<@kw>>>>\n";#d# - $msg = CFClient::UI::Label::escape $msg; my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; $msg =~ s/($match)/$1<\/span>/gi; # underline when http-ready, huh.