… | |
… | |
175 | } |
175 | } |
176 | |
176 | |
177 | $ns->pl and return $ns->destroy; |
177 | $ns->pl and return $ns->destroy; |
178 | |
178 | |
179 | $ns->async (sub { |
179 | $ns->async (sub { |
|
|
180 | $Coro::current->{desc} = "addme init"; |
|
|
181 | |
180 | my ($user, $pass); |
182 | my ($user, $pass); |
181 | |
183 | |
182 | $ns->send_packet ("addme_success"); |
184 | $ns->send_packet ("addme_success"); |
183 | |
185 | |
184 | for (;;) { |
186 | for (;;) { |
… | |
… | |
211 | } |
213 | } |
212 | Coro::Timer::sleep 0.4; |
214 | Coro::Timer::sleep 0.4; |
213 | } |
215 | } |
214 | |
216 | |
215 | check_playing $ns, $user and next; |
217 | check_playing $ns, $user and next; |
|
|
218 | |
|
|
219 | $Coro::current->{desc} = "addme($user) pass"; |
216 | |
220 | |
217 | $ns->send_drawinfo ( |
221 | $ns->send_drawinfo ( |
218 | "Welcome $user, please enter your password now. " |
222 | "Welcome $user, please enter your password now. " |
219 | . "New users should now choose a password. " |
223 | . "New users should now choose a password. " |
220 | . "Anything your client lets you enter is fine.", |
224 | . "Anything your client lets you enter is fine.", |
… | |
… | |
244 | } |
248 | } |
245 | local $cf::LOGIN_LOCK{$user} = 1; |
249 | local $cf::LOGIN_LOCK{$user} = 1; |
246 | |
250 | |
247 | check_playing $ns, $user and next; |
251 | check_playing $ns, $user and next; |
248 | |
252 | |
|
|
253 | $Coro::current->{desc} = "addme($user) check"; |
|
|
254 | |
249 | # try to read the user file and check the password |
255 | # try to read the user file and check the password |
250 | if (my $pl = cf::player::find $user) { |
256 | if (my $pl = cf::player::find $user) { |
251 | aio_stat $pl->path and next; |
257 | aio_stat $pl->path and next; |
252 | my $mtime = (stat _)[9]; |
258 | my $mtime = (stat _)[9]; |
253 | my $hash = $pl->password; |
259 | my $hash = $pl->password; |
… | |
… | |
306 | next; |
312 | next; |
307 | } |
313 | } |
308 | } |
314 | } |
309 | |
315 | |
310 | # the rest of this function is character creation |
316 | # the rest of this function is character creation |
|
|
317 | $Coro::current->{desc} = "addme($user) chargen"; |
311 | |
318 | |
312 | # just to make sure nothing is left over |
319 | # just to make sure nothing is left over |
313 | nuke_playerdir $user; |
320 | nuke_playerdir $user; |
314 | |
321 | |
315 | my $pass2 = query $ns, cf::CS_QUERY_HIDEINPUT, "Please type your password again."; |
322 | my $pass2 = query $ns, cf::CS_QUERY_HIDEINPUT, "Please type your password again."; |
… | |
… | |
483 | |
490 | |
484 | our $SCHEDULE_INTERVAL = $cf::CFG{player_schedule_interval} || 10; # time the player scheduler sleeps between runs |
491 | our $SCHEDULE_INTERVAL = $cf::CFG{player_schedule_interval} || 10; # time the player scheduler sleeps between runs |
485 | our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds |
492 | our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds |
486 | |
493 | |
487 | our $SCHEDULER = cf::async_ext { |
494 | our $SCHEDULER = cf::async_ext { |
|
|
495 | $Coro::current->{desc} = "player scheduler"; |
|
|
496 | |
488 | my $schedule_interval = Coro::Event->timer (after => 1); |
497 | my $schedule_interval = Coro::Event->timer (after => 1); |
489 | while () { |
498 | while () { |
490 | $schedule_interval->interval ($SCHEDULE_INTERVAL); |
499 | $schedule_interval->interval ($SCHEDULE_INTERVAL); |
491 | $schedule_interval->next; |
500 | $schedule_interval->next; |
492 | |
501 | |