… | |
… | |
3522 | # the server's init and main functions |
3522 | # the server's init and main functions |
3523 | |
3523 | |
3524 | our %FACEHASH; # hash => idx, #d# HACK for http server |
3524 | our %FACEHASH; # hash => idx, #d# HACK for http server |
3525 | |
3525 | |
3526 | # internal api, not fianlised |
3526 | # internal api, not fianlised |
3527 | sub add_face { |
3527 | sub set_face { |
3528 | my ($name, $type, $data) = @_; |
3528 | my ($name, $type, $data) = @_; |
3529 | |
3529 | |
3530 | my $idx = cf::face::find $name; |
3530 | my $idx = cf::face::find $name; |
3531 | |
3531 | |
3532 | if ($idx) { |
3532 | if ($idx) { |
… | |
… | |
3562 | or cf::cleanup "$path: version mismatch, cannot proceed."; |
3562 | or cf::cleanup "$path: version mismatch, cannot proceed."; |
3563 | |
3563 | |
3564 | cf::cede_to_tick; |
3564 | cf::cede_to_tick; |
3565 | |
3565 | |
3566 | { |
3566 | { |
3567 | my $faces = $facedata->{faceinfo}; |
3567 | my $faces = delete $facedata->{faceinfo}; |
3568 | |
3568 | |
3569 | for my $face (sort keys %$faces) { |
3569 | for my $face (sort keys %$faces) { |
3570 | my $info = $faces->{$face}; |
3570 | my $info = $faces->{$face}; |
3571 | my $idx = (cf::face::find $face) || cf::face::alloc $face; |
3571 | my $idx = (cf::face::find $face) || cf::face::alloc $face; |
3572 | |
3572 | |
… | |
… | |
3574 | cf::face::set_magicmap $idx, $info->{magicmap}; |
3574 | cf::face::set_magicmap $idx, $info->{magicmap}; |
3575 | cf::face::set_data $idx, 0, $info->{data32}, $info->{hash32}; |
3575 | cf::face::set_data $idx, 0, $info->{data32}, $info->{hash32}; |
3576 | cf::face::set_data $idx, 1, $info->{data64}, $info->{hash64}; |
3576 | cf::face::set_data $idx, 1, $info->{data64}, $info->{hash64}; |
3577 | cf::face::set_data $idx, 2, $info->{glyph} , $info->{glyph} ; |
3577 | cf::face::set_data $idx, 2, $info->{glyph} , $info->{glyph} ; |
3578 | $FACEHASH{$info->{hash64}} = $idx;#d# |
3578 | $FACEHASH{$info->{hash64}} = $idx;#d# |
3579 | |
3579 | |
3580 | cf::cede_to_tick; |
3580 | cf::cede_to_tick; |
3581 | } |
3581 | } |
3582 | |
3582 | |
3583 | while (my ($face, $info) = each %$faces) { |
3583 | while (my ($face, $info) = each %$faces) { |
3584 | next unless $info->{smooth}; |
3584 | next unless $info->{smooth}; |
… | |
… | |
3596 | cf::cede_to_tick; |
3596 | cf::cede_to_tick; |
3597 | } |
3597 | } |
3598 | } |
3598 | } |
3599 | |
3599 | |
3600 | { |
3600 | { |
3601 | my $anims = $facedata->{animinfo}; |
3601 | my $anims = delete $facedata->{animinfo}; |
3602 | |
3602 | |
3603 | while (my ($anim, $info) = each %$anims) { |
3603 | while (my ($anim, $info) = each %$anims) { |
3604 | cf::anim::set $anim, $info->{frames}, $info->{facings}; |
3604 | cf::anim::set $anim, $info->{frames}, $info->{facings}; |
3605 | cf::cede_to_tick; |
3605 | cf::cede_to_tick; |
3606 | } |
3606 | } |
3607 | |
3607 | |
3608 | cf::anim::invalidate_all; # d'oh |
3608 | cf::anim::invalidate_all; # d'oh |
3609 | } |
3609 | } |
3610 | |
3610 | |
3611 | { |
3611 | { |
3612 | my $res = $facedata->{resource}; |
3612 | my $res = delete $facedata->{resource}; |
3613 | |
3613 | |
3614 | while (my ($name, $info) = each %$res) { |
3614 | while (my ($name, $info) = each %$res) { |
3615 | if (defined (my $type = $info->{type})) { |
3615 | if (defined (my $type = $info->{type})) { |
3616 | # TODO: different hash - must free and use new index, or cache ixface data queue |
3616 | # TODO: different hash - must free and use new index, or cache ixface data queue |
3617 | my $idx = (cf::face::find $name) || cf::face::alloc $name; |
3617 | my $idx = (cf::face::find $name) || cf::face::alloc $name; |
… | |
… | |
3652 | } |
3652 | } |
3653 | |
3653 | |
3654 | sub reload_exp_table { |
3654 | sub reload_exp_table { |
3655 | _reload_exp_table; |
3655 | _reload_exp_table; |
3656 | |
3656 | |
3657 | add_face "res/exp_table" => FT_RSRC, |
3657 | set_face "res/exp_table" => FT_RSRC, |
3658 | JSON::XS->new->utf8->canonical->encode ( |
3658 | JSON::XS->new->utf8->canonical->encode ( |
3659 | [map cf::level_to_min_exp $_, 1 .. cf::settings->max_level] |
3659 | [map cf::level_to_min_exp $_, 1 .. cf::settings->max_level] |
3660 | ); |
3660 | ); |
3661 | } |
3661 | } |
3662 | |
3662 | |
… | |
… | |
3685 | |
3685 | |
3686 | sub reload_archetypes { |
3686 | sub reload_archetypes { |
3687 | load_resource_file "$DATADIR/archetypes" |
3687 | load_resource_file "$DATADIR/archetypes" |
3688 | or die "unable to load archetypes\n"; |
3688 | or die "unable to load archetypes\n"; |
3689 | |
3689 | |
3690 | add_face "res/skill_info" => FT_RSRC, |
3690 | set_face "res/skill_info" => FT_RSRC, |
3691 | JSON::XS->new->utf8->canonical->encode ( |
3691 | JSON::XS->new->utf8->canonical->encode ( |
3692 | [map [cf::arch::skillvec ($_)->name], 0 .. cf::arch::skillvec_size - 1] |
3692 | [map [cf::arch::skillvec ($_)->name], 0 .. cf::arch::skillvec_size - 1] |
3693 | ); |
3693 | ); |
3694 | add_face "res/spell_paths" => FT_RSRC, |
3694 | set_face "res/spell_paths" => FT_RSRC, |
3695 | JSON::XS->new->utf8->canonical->encode ( |
3695 | JSON::XS->new->utf8->canonical->encode ( |
3696 | [map [cf::spellpathnames ($_)], 0 .. NRSPELLPATHS - 1] |
3696 | [map [cf::spellpathnames ($_)], 0 .. NRSPELLPATHS - 1] |
3697 | ); |
3697 | ); |
3698 | } |
3698 | } |
3699 | |
3699 | |