… | |
… | |
86 | cf::NDI_RED |
86 | cf::NDI_RED |
87 | ); |
87 | ); |
88 | # kill them. |
88 | # kill them. |
89 | # reminds me of the famous badness 10000 syndrome... |
89 | # reminds me of the famous badness 10000 syndrome... |
90 | $ob->stats->hp (-10000); #] if they survive this they deserved to live |
90 | $ob->stats->hp (-10000); #] if they survive this they deserved to live |
|
|
91 | $pl->killer ("a cave-in"); |
91 | } else { |
92 | } else { |
92 | $ob->message ( |
93 | $ob->message ( |
93 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
94 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
94 | . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " |
95 | . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " |
95 | . "Better use a savebed next time, much worse things could have happened... " |
96 | . "Better use a savebed next time, much worse things could have happened... " |
… | |
… | |
115 | # delete a player directory, be non-blocking AND synchronous... |
116 | # delete a player directory, be non-blocking AND synchronous... |
116 | # (thats hard, so we crap out and fork). |
117 | # (thats hard, so we crap out and fork). |
117 | sub nuke_playerdir { |
118 | sub nuke_playerdir { |
118 | my ($user) = @_; |
119 | my ($user) = @_; |
119 | |
120 | |
120 | aio_stat "$PLAYERDIR/$user"; |
121 | my $temp = "$PLAYERDIR/~$Coro::current~deleting~"; |
121 | system "cd \Q$PLAYERDIR\E " |
122 | |
122 | . "&& mv \Q$user\E ~\Q$Coro::current\E~deleting~ 2>/dev/null " |
123 | cf::fork_call { |
123 | . "&& (rm -rf ~\Q$Coro::current\E~deleting~ &)"; |
124 | rename "$PLAYERDIR/$user", $temp; |
|
|
125 | system "rm", "-rf", $temp; |
|
|
126 | }; |
124 | } |
127 | } |
125 | |
128 | |
126 | cf::client->attach (on_addme => sub { |
129 | cf::client->attach (on_addme => sub { |
127 | my ($ns) = @_; |
130 | my ($ns) = @_; |
128 | |
131 | |
… | |
… | |
141 | *** |
144 | *** |
142 | *** CFPlus: all known versions automatically enable the facecache. |
145 | *** CFPlus: all known versions automatically enable the facecache. |
143 | *** cfclient: use the -cache commandline option. |
146 | *** cfclient: use the -cache commandline option. |
144 | *** cfclient: map will not redraw automatically (bug). |
147 | *** cfclient: map will not redraw automatically (bug). |
145 | *** gcfclient: use -cache commandline option, or enable |
148 | *** gcfclient: use -cache commandline option, or enable |
146 | *** gcfclient: Client=>Configure=>Map & Image=>Cache Images. |
149 | *** gcfclient: Client => Configure => Map & Image => Cache Images. |
147 | *** jcrossclient: your client is broken, use CFPlus or gcfclient. |
150 | *** jcrossclient: your client is broken, use CFPlus or gcfclient. |
148 | *** |
151 | *** |
149 | *** |
152 | *** |
150 | EOF |
153 | EOF |
151 | if ($ns->version =~ /jcrossclient/) { |
154 | if ($ns->version =~ /jcrossclient/) { |
… | |
… | |
356 | |
359 | |
357 | $ob->set_animation (2); |
360 | $ob->set_animation (2); |
358 | $ob->add_statbonus; |
361 | $ob->add_statbonus; |
359 | |
362 | |
360 | while () { |
363 | while () { |
361 | $ns->send_msg (-1, "chargen-race-title", ucfirst $pl->title); |
364 | $ns->send_msg ("chargen-race-title", ucfirst $pl->title, -1); |
362 | my $msg = $ob->msg; |
365 | my $msg = $ob->msg; |
363 | $msg =~ s/(?<=\S)\n(?=\S)/ /g; |
366 | $msg =~ s/(?<=\S)\n(?=\S)/ /g; |
364 | $ns->send_msg (cf::NDI_BLUE, "chargen-race-description", $msg); |
367 | $ns->send_msg ("chargen-race-description", $msg, cf::NDI_BLUE); |
365 | |
368 | |
366 | my $res = query $ns, cf::CS_QUERY_SINGLECHAR, |
369 | my $res = query $ns, cf::CS_QUERY_SINGLECHAR, |
367 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"; |
370 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"; |
368 | |
371 | |
369 | last if $res =~ /[dD]/; |
372 | last if $res =~ /[dD]/; |
… | |
… | |
476 | }, |
479 | }, |
477 | ); |
480 | ); |
478 | |
481 | |
479 | ############################################################################# |
482 | ############################################################################# |
480 | |
483 | |
481 | our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs |
484 | our $SCHEDULE_INTERVAL = $cf::CFG{player_schedule_interval} || 10; # time the player scheduler sleeps between runs |
482 | our $SAVE_TIMEOUT = 20; # save players every n seconds |
485 | our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds |
483 | |
486 | |
484 | our $SCHEDULER = cf::async_ext { |
487 | our $SCHEDULER = cf::async_ext { |
485 | my $schedule_interval = Coro::Event->timer (after => 1, interval => $SCHEDULE_INTERVAL); |
488 | my $schedule_interval = Coro::Event->timer (after => 1); |
486 | while () { |
489 | while () { |
|
|
490 | $schedule_interval->interval ($SCHEDULE_INTERVAL); |
487 | $schedule_interval->next; |
491 | $schedule_interval->next; |
488 | |
492 | |
489 | # this weird form of iteration over values is used because |
493 | # this weird form of iteration over values is used because |
490 | # the hash changes underneath us frequently, and for |
494 | # the hash changes underneath us frequently, and for |
491 | # keeps a direct reference to the value without (in 5.8 perls) |
495 | # keeps a direct reference to the value without (in 5.8 perls) |
… | |
… | |
496 | or next; |
500 | or next; |
497 | $pl->valid or next; |
501 | $pl->valid or next; |
498 | |
502 | |
499 | eval { |
503 | eval { |
500 | if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
504 | if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
501 | cf::wait_for_tick_begin; |
|
|
502 | $pl->save; |
505 | $pl->save; |
503 | |
506 | |
504 | unless ($pl->active || $pl->ns) { |
507 | unless ($pl->active || $pl->ns) { |
505 | # check refcounts, this is tricky and needs to be adjusted to fit server internals |
508 | # check refcounts, this is tricky and needs to be adjusted to fit server internals |
506 | my $ob = $pl->ob; |
509 | my $ob = $pl->ob; |