ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Protocol.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.12 by elmex, Tue May 30 14:59:26 2006 UTC vs.
Revision 1.20 by root, Mon Jun 5 05:31:13 2006 UTC

3use utf8; 3use utf8;
4use strict; 4use strict;
5 5
6use Crossfire::Protocol::Constants; 6use Crossfire::Protocol::Constants;
7 7
8use CFClient;
8use CFClient::UI; 9use CFClient::UI;
9 10
10use base 'Crossfire::Protocol::Base'; 11use base 'Crossfire::Protocol::Base';
11 12
12sub new { 13sub new {
14 15
15 my $self = $class->SUPER::new (@_); 16 my $self = $class->SUPER::new (@_);
16 17
17 $self->{map_widget}->clr_commands; 18 $self->{map_widget}->clr_commands;
18 19
19 my $parser = new Pod::POM;
20 my $pod = $parser->parse_file (CFClient::find_rcfile "pod/command_help.pod"); 20 my $pod = CFClient::load_pod CFClient::find_rcfile "pod/command_help.pod";
21 21
22 for my $head2 ($pod->head1->[-2]->head2) { 22 for my $head2 ($pod->head1->[-2]->head2) {
23 $head2->title =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x 23 $head2->title =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
24 or next; 24 or next;
25 25
268 unless ($id) { 268 unless ($id) {
269 # create new id for face 269 # create new id for face
270 # I love transactions 270 # I love transactions
271 for (1..100) { 271 for (1..100) {
272 my $txn = $CFClient::DB_ENV->txn_begin; 272 my $txn = $CFClient::DB_ENV->txn_begin;
273 my $status = $self->{facemap}->db_get (id => $id, BerkeleyDB::DB_RMW); 273 my $status = $self->{facemap}->db_get (id => $id);
274 if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { 274 if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) {
275 $id = ($id || 16) + 1; 275 $id = ($id || 16) + 1;
276 if ($self->{facemap}->put (id => $id) == 0 276 if ($self->{facemap}->put (id => $id) == 0
277 && $self->{facemap}->put ($hash => $id) == 0) { 277 && $self->{facemap}->put ($hash => $id) == 0) {
278 $txn->txn_commit; 278 $txn->txn_commit;
279 279
280 goto gotid; 280 goto gotid;
281 } 281 }
282 } 282 }
283 $txn->abort; 283 $txn->txn_abort;
284 } 284 }
285 285
286 CFClient::fatal "maximum number of transaction retries reached - database problems?"; 286 CFClient::fatal "maximum number of transaction retries reached - database problems?";
287 } 287 }
288 288
429 join "\n", map "$time $_", split /\n/, $text); 429 join "\n", map "$time $_", split /\n/, $text);
430 430
431 $self->{statusbox}->add ($text, 431 $self->{statusbox}->add ($text,
432 group => $text, 432 group => $text,
433 fg => $color[$color], 433 fg => $color[$color],
434 timeout => 10, 434 timeout => $color >= 2 ? 60 : 10,
435 tooltip_font => $::FONT_FIXED, 435 tooltip_font => $::FONT_FIXED,
436 ); 436 );
437} 437}
438 438
439sub drawextinfo { 439sub drawextinfo {
445sub spell_add { 445sub spell_add {
446 my ($self, $spell) = @_; 446 my ($self, $spell) = @_;
447 447
448 # TODO 448 # TODO
449 # create a widget dynamically, using spell face (CF::Protocol downloads them) 449 # create a widget dynamically, using spell face (CF::Protocol downloads them)
450 $::SETUP_SPELLS->add_spell ($spell);
451
450 $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message}); 452 $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message});
451 $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message}); 453 $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message});
452} 454}
453 455
454sub spell_delete { 456sub spell_delete {
455 my ($self, $spell) = @_; 457 my ($self, $spell) = @_;
458 $::SETUP_SPELLS->remove_spell ($spell);
456} 459}
457 460
458sub addme_success { 461sub addme_success {
459 my ($self) = @_; 462 my ($self) = @_;
460 463
461 $self->send ("command output-sync $::CFG->{output_sync}"); 464 my $pod = CFClient::load_pod CFClient::find_rcfile "pod/skill_help.pod";
462 $self->send ("command output-count $::CFG->{output_count}");
463
464 my $parser = new Pod::POM;
465 my $pod = $parser->parse_file (CFClient::find_rcfile "pod/skill_help.pod");
466 465
467 my %skill_tooltip; 466 my %skill_tooltip;
468 467
469 for my $head2 ($pod->head1->[-2]->head2) { 468 for my $head2 ($pod->head1->[-2]->head2) {
470 $skill_tooltip{$head2->title} = CFClient::pod_to_pango $head2->content; 469 $skill_tooltip{$head2->title} = CFClient::pod_to_pango $head2->content;
509 my ($face) = splice @{ $self->{face_prefetch} }, + rand @{ $self->{face_prefetch} }, 1, (); 508 my ($face) = splice @{ $self->{face_prefetch} }, + rand @{ $self->{face_prefetch} }, 1, ();
510 509
511 $self->send ("requestinfo image_sums $face $face"); 510 $self->send ("requestinfo image_sums $face $face");
512 511
513 $self->{statusbox}->add (CFClient::UI::Label::escape "prefetching $todo", 512 $self->{statusbox}->add (CFClient::UI::Label::escape "prefetching $todo",
514 group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); 513 group => "prefetch", timeout => 3, fg => [1, 1, 0, 0.5]);
515 } elsif (!exists $self->{num_faces}) { 514 } elsif (!exists $self->{num_faces}) {
516 $self->send ("requestinfo image_info"); 515 $self->send ("requestinfo image_info");
517 516
518 $self->{num_faces} = 0; 517 $self->{num_faces} = 0;
519 518
520 $self->{statusbox}->add (CFClient::UI::Label::escape "starting to prefetch", 519 $self->{statusbox}->add (CFClient::UI::Label::escape "starting to prefetch",
521 group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); 520 group => "prefetch", timeout => 3, fg => [1, 1, 0, 0.5]);
522 } 521 }
523} 522}
524 523
525sub update_floorbox { 524sub update_floorbox {
526 $CFClient::UI::ROOT->on_refresh ($::FLOORBOX => sub { 525 $CFClient::UI::ROOT->on_refresh ($::FLOORBOX => sub {
658} 657}
659 658
660sub player_update { 659sub player_update {
661 my ($self, $player) = @_; 660 my ($self, $player) = @_;
662 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); 661 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000);
662
663 # do it here because it is ignored earlier, and there is no "login" event
664 $self->send_command ("output-sync $::CFG->{output_sync}");
665 $self->send_command ("output-count $::CFG->{output_count}");
663} 666}
664 667
6651; 6681;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines