… | |
… | |
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 | |
… | |
… | |
445 | sub spell_add { |
445 | sub 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 | $::SPELL_LIST->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 | |
454 | sub spell_delete { |
456 | sub spell_delete { |
455 | my ($self, $spell) = @_; |
457 | my ($self, $spell) = @_; |
|
|
458 | $::SPELL_LIST->remove_spell ($spell); |
456 | } |
459 | } |
457 | |
460 | |
458 | sub addme_success { |
461 | sub addme_success { |
459 | my ($self) = @_; |
462 | my ($self) = @_; |
460 | |
|
|
461 | $self->send ("command output-sync $::CFG->{output_sync}"); |
|
|
462 | $self->send ("command output-count $::CFG->{output_count}"); |
|
|
463 | |
463 | |
464 | my $parser = new Pod::POM; |
464 | my $parser = new Pod::POM; |
465 | my $pod = $parser->parse_file (CFClient::find_rcfile "pod/skill_help.pod"); |
465 | my $pod = $parser->parse_file (CFClient::find_rcfile "pod/skill_help.pod"); |
466 | |
466 | |
467 | my %skill_tooltip; |
467 | my %skill_tooltip; |
… | |
… | |
658 | } |
658 | } |
659 | |
659 | |
660 | sub player_update { |
660 | sub player_update { |
661 | my ($self, $player) = @_; |
661 | my ($self, $player) = @_; |
662 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); |
662 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); |
|
|
663 | |
|
|
664 | # do it here because it is ignored earlier, and there is no "login" event |
|
|
665 | $self->send_command ("output-sync $::CFG->{output_sync}"); |
|
|
666 | $self->send_command ("output-count $::CFG->{output_count}"); |
663 | } |
667 | } |
664 | |
668 | |
665 | 1; |
669 | 1; |