… | |
… | |
105 | $ns->send_drawinfo ( |
105 | $ns->send_drawinfo ( |
106 | "That username is currently used in another login session. " |
106 | "That username is currently used in another login session. " |
107 | . "Chose another, or wait till the other session has ended.", |
107 | . "Chose another, or wait till the other session has ended.", |
108 | cf::NDI_RED |
108 | cf::NDI_RED |
109 | ); |
109 | ); |
110 | } elsif ($user =~ /^[a-zA-Z0-9][a-zA-Z0-9\-_]{2,17}$/) { |
110 | } elsif ($user =~ /^[a-zA-Z0-9][a-zA-Z0-9\-_]{2,17}\z/) { |
111 | last; |
111 | last; |
112 | } else { |
112 | } else { |
113 | $ns->send_drawinfo ( |
113 | $ns->send_drawinfo ( |
114 | "Your username contains illegal characters " |
114 | "Your username contains illegal characters " |
115 | . "(only a-z, A-Z and 0-9 are allowed), " |
115 | . "(only a-z, A-Z and 0-9 are allowed), " |
… | |
… | |
348 | |
348 | |
349 | our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs |
349 | our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs |
350 | our $SAVE_TIMEOUT = 20; # save players every n seconds |
350 | our $SAVE_TIMEOUT = 20; # save players every n seconds |
351 | |
351 | |
352 | our $SCHEDULER = cf::async_ext { |
352 | our $SCHEDULER = cf::async_ext { |
|
|
353 | my $schedule_interval = Coro::Event->timer (after => 1, interval => $SCHEDULE_INTERVAL); |
353 | while () { |
354 | while () { |
354 | Coro::Timer::sleep $SCHEDULE_INTERVAL; |
355 | $schedule_interval->next; |
355 | |
356 | |
356 | # this weird form of iteration over values is used because |
357 | # this weird form of iteration over values is used because |
357 | # the hash changes underneath us frequently, and for |
358 | # the hash changes underneath us frequently, and for |
358 | # keeps a direct reference to the value without (in 5.8 perls) |
359 | # keeps a direct reference to the value without (in 5.8 perls) |
359 | # keeping a reference, so this is prone to crashes or worse. |
360 | # keeping a reference, so this is prone to crashes or worse. |