… | |
… | |
106 | our $RANDOMDIR = "$LOCALDIR/random"; |
106 | our $RANDOMDIR = "$LOCALDIR/random"; |
107 | our $BDBDIR = "$LOCALDIR/db"; |
107 | our $BDBDIR = "$LOCALDIR/db"; |
108 | our $PIDFILE = "$LOCALDIR/pid"; |
108 | our $PIDFILE = "$LOCALDIR/pid"; |
109 | our $RUNTIMEFILE = "$LOCALDIR/runtime"; |
109 | our $RUNTIMEFILE = "$LOCALDIR/runtime"; |
110 | |
110 | |
111 | our %RESOURCE; |
111 | our %RESOURCE; # unused |
112 | |
112 | |
113 | our $OUTPUT_RATE_MIN = 3000; |
113 | our $OUTPUT_RATE_MIN = 3000; |
114 | our $OUTPUT_RATE_MAX = 1000000; |
114 | our $OUTPUT_RATE_MAX = 1000000; |
115 | |
115 | |
116 | our $MAX_LINKS = 32; # how many chained exits to follow |
116 | our $MAX_LINKS = 32; # how many chained exits to follow |
… | |
… | |
3428 | my $idx = (cf::face::find $name) || cf::face::alloc $name; |
3428 | my $idx = (cf::face::find $name) || cf::face::alloc $name; |
3429 | |
3429 | |
3430 | cf::face::set_data $idx, 0, $info->{data}, $info->{hash}; |
3430 | cf::face::set_data $idx, 0, $info->{data}, $info->{hash}; |
3431 | cf::face::set_type $idx, $info->{type}; |
3431 | cf::face::set_type $idx, $info->{type}; |
3432 | } else { |
3432 | } else { |
3433 | $RESOURCE{$name} = $info; |
3433 | $RESOURCE{$name} = $info; # unused |
3434 | } |
3434 | } |
3435 | |
3435 | |
3436 | cf::cede_to_tick; |
3436 | cf::cede_to_tick; |
3437 | } |
3437 | } |
3438 | } |
3438 | } |
3439 | |
3439 | |
3440 | cf::global->invoke (EVENT_GLOBAL_RESOURCE_UPDATE); |
3440 | cf::global->invoke (EVENT_GLOBAL_RESOURCE_UPDATE); |
3441 | |
3441 | |
3442 | 1 |
3442 | 1 |
3443 | } |
3443 | } |
3444 | |
|
|
3445 | cf::global->attach (on_resource_update => sub { |
|
|
3446 | if (my $soundconf = $RESOURCE{"res/sound.conf"}) { |
|
|
3447 | $soundconf = JSON::XS->new->utf8->relaxed->decode ($soundconf->{data}); |
|
|
3448 | |
|
|
3449 | for (0 .. SOUND_CAST_SPELL_0 - 1) { |
|
|
3450 | my $sound = $soundconf->{compat}[$_] |
|
|
3451 | or next; |
|
|
3452 | |
|
|
3453 | my $face = cf::face::find "sound/$sound->[1]"; |
|
|
3454 | cf::sound::set $sound->[0] => $face; |
|
|
3455 | cf::sound::old_sound_index $_, $face; # gcfclient-compat |
|
|
3456 | } |
|
|
3457 | |
|
|
3458 | while (my ($k, $v) = each %{$soundconf->{event}}) { |
|
|
3459 | my $face = cf::face::find "sound/$v"; |
|
|
3460 | cf::sound::set $k => $face; |
|
|
3461 | } |
|
|
3462 | } |
|
|
3463 | }); |
|
|
3464 | |
3444 | |
3465 | register_exticmd fx_want => sub { |
3445 | register_exticmd fx_want => sub { |
3466 | my ($ns, $want) = @_; |
3446 | my ($ns, $want) = @_; |
3467 | |
3447 | |
3468 | while (my ($k, $v) = each %$want) { |
3448 | while (my ($k, $v) = each %$want) { |
… | |
… | |
3507 | sub reload_treasures { |
3487 | sub reload_treasures { |
3508 | load_resource_file "$DATADIR/treasures" |
3488 | load_resource_file "$DATADIR/treasures" |
3509 | or die "unable to load treasurelists\n"; |
3489 | or die "unable to load treasurelists\n"; |
3510 | } |
3490 | } |
3511 | |
3491 | |
|
|
3492 | sub reload_sound { |
|
|
3493 | 0 < Coro::AIO::aio_load "$DATADIR/sound", my $data |
|
|
3494 | or die "$DATADIR/sound $!"; |
|
|
3495 | |
|
|
3496 | my $soundconf = JSON::XS->new->utf8->relaxed->decode ($data); |
|
|
3497 | |
|
|
3498 | for (0 .. SOUND_CAST_SPELL_0 - 1) { |
|
|
3499 | my $sound = $soundconf->{compat}[$_] |
|
|
3500 | or next; |
|
|
3501 | |
|
|
3502 | my $face = cf::face::find "sound/$sound->[1]"; |
|
|
3503 | cf::sound::set $sound->[0] => $face; |
|
|
3504 | cf::sound::old_sound_index $_, $face; # gcfclient-compat |
|
|
3505 | } |
|
|
3506 | |
|
|
3507 | while (my ($k, $v) = each %{$soundconf->{event}}) { |
|
|
3508 | my $face = cf::face::find "sound/$v"; |
|
|
3509 | cf::sound::set $k => $face; |
|
|
3510 | } |
|
|
3511 | } |
|
|
3512 | |
3512 | sub reload_resources { |
3513 | sub reload_resources { |
3513 | warn "reloading resource files...\n"; |
3514 | warn "reloading resource files...\n"; |
3514 | |
3515 | |
3515 | reload_facedata; |
3516 | reload_facedata; |
|
|
3517 | reload_sound; |
3516 | reload_archetypes; |
3518 | reload_archetypes; |
3517 | reload_regions; |
3519 | reload_regions; |
3518 | reload_treasures; |
3520 | reload_treasures; |
3519 | |
3521 | |
3520 | warn "finished reloading resource files\n"; |
3522 | warn "finished reloading resource files\n"; |