… | |
… | |
2 | |
2 | |
3 | # login handling |
3 | # login handling |
4 | |
4 | |
5 | use Fcntl; |
5 | use Fcntl; |
6 | use Coro::AIO; |
6 | use Coro::AIO; |
|
|
7 | |
|
|
8 | our $MAX_DISCONNECT_TIME = $cf::CFG{max_disconnect_time} || 3600; |
7 | |
9 | |
8 | # paranoia function to overwrite a string-in-place |
10 | # paranoia function to overwrite a string-in-place |
9 | sub nuke_str { |
11 | sub nuke_str { |
10 | substr $_[0], 0, (length $_[0]), "x" x length $_[0] |
12 | substr $_[0], 0, (length $_[0]), "x" x length $_[0] |
11 | } |
13 | } |
… | |
… | |
64 | |
66 | |
65 | $ob->enter_link; |
67 | $ob->enter_link; |
66 | |
68 | |
67 | if (my $time = delete $pl->{unclean_save}) { |
69 | if (my $time = delete $pl->{unclean_save}) { |
68 | if (my $m = cf::map::find $map) { |
70 | if (my $m = cf::map::find $map) { |
69 | if ($time < $m->{instantiate_time} || 1) {#d# |
71 | if ($time < $m->{instantiate_time}) { |
70 | # the map was reset in the meantime |
72 | # the map was reset in the meantime |
71 | my $age = $cf::RUNTIME - $time; |
73 | my $age = $cf::RUNTIME - $time; |
|
|
74 | |
72 | warn $ob->name, " map reset after logout, logout age $age\n";#d# |
75 | warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# |
73 | |
76 | |
74 | # for now, just go back to savebed |
77 | # for now, just go back to savebed |
75 | ($map, $x, $y) = $pl->savebed; |
78 | ($map, $x, $y) = $pl->savebed; |
76 | |
79 | |
77 | $pl->ns->send_drawinfo ( |
80 | if ($age >= $MAX_DISCONNECT_TIME) { |
|
|
81 | $ob->message ( |
78 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
82 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
|
|
83 | . "Unfortunately, nobody was near to help you when the monsters arrived to eat you. " |
|
|
84 | . "Maybe you can find comfort in the thought that your body was quite satisfying in taste... " |
|
|
85 | . "H<You disconnected too long without having used a savebed.>", |
|
|
86 | cf::NDI_RED |
|
|
87 | ); |
|
|
88 | # kill them. |
|
|
89 | # reminds me of the famous badness 10000 syndrome... |
|
|
90 | $ob->stats->hp (-10000); #] if they survive this they deserved to live |
|
|
91 | } else { |
|
|
92 | $ob->message ( |
|
|
93 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
79 | . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " |
94 | . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " |
80 | . "Better use a savebed next time, much worse things could have happened...", |
95 | . "Better use a savebed next time, much worse things could have happened... " |
|
|
96 | . "H<You disconnected without having used a savebed. When you do that for too long, you might die.>", |
81 | cf::NDI_RED |
97 | cf::NDI_RED |
82 | ); |
98 | ); |
|
|
99 | } |
83 | } else { |
100 | } else { |
84 | $pl->ns->send_drawinfo ( |
101 | $ob->message ( |
85 | "You didn't use a bed to reality to leave this realm. This is very dangerous, " |
102 | "You didn't use a bed to reality to leave this realm. This is very dangerous, " |
86 | . "as lots of things could happen when you leave by other means, such as cave-ins, " |
103 | . "as lots of things could happen when you leave by other means, such as cave-ins, " |
87 | . "or monsters suddenly snapping your body. Better use a savebed next time.", |
104 | . "or monsters suddenly snapping your body. Better use a savebed next time. " |
|
|
105 | . "H<Always apply a bed of reality to disconnect from the server.>", |
88 | cf::NDI_RED |
106 | cf::NDI_RED |
89 | ); |
107 | ); |
90 | } |
108 | } |
91 | } |
109 | } |
92 | } |
110 | } |