… | |
… | |
52 | ); |
52 | ); |
53 | |
53 | |
54 | 1 |
54 | 1 |
55 | } |
55 | } |
56 | |
56 | |
57 | sub safe_spot($$$) { |
57 | sub safe_spot($) { |
58 | my ($m, $x, $y) = @_; |
58 | my ($pl) = @_; |
|
|
59 | |
|
|
60 | my $ob = $pl->ob; |
|
|
61 | |
|
|
62 | my $m = $ob->map |
|
|
63 | or return; |
|
|
64 | my $x = $ob->x; |
|
|
65 | my $y = $ob->y; |
|
|
66 | |
|
|
67 | # return 0;#d# |
|
|
68 | # warn join ":", $m->at ($x, $y);#d# |
|
|
69 | # warn "FOO$m { ".scalar ($m->at ($x, $y))." }\n"; |
|
|
70 | # return 0; |
59 | |
71 | |
60 | scalar grep $_->type == cf::SAVEBED, $m->at ($x, $y) |
72 | scalar grep $_->type == cf::SAVEBED, $m->at ($x, $y) |
61 | } |
73 | } |
62 | |
74 | |
63 | sub enter_map { |
75 | sub enter_map { |
64 | my ($pl) = @_; |
76 | my ($pl) = @_; |
65 | |
77 | |
|
|
78 | warn $pl->ob->name, ": enter map 1\n";#d# |
66 | my $ob = $pl->ob; |
79 | my $ob = $pl->ob; |
67 | |
80 | |
68 | my ($map, $x, $y) |
81 | my ($map, $x, $y) |
69 | = $ob->{_link_pos} |
82 | = $ob->{_link_pos} |
70 | ? @{delete $ob->{_link_pos}} |
83 | ? @{delete $ob->{_link_pos}} |
71 | : ($pl->maplevel, $ob->x, $ob->y); |
84 | : ($pl->maplevel, $ob->x, $ob->y); |
72 | |
85 | |
|
|
86 | warn $pl->ob->name, ": enter map 2\n";#d# |
73 | $ob->enter_link; |
87 | $ob->enter_link; |
|
|
88 | warn $pl->ob->name, ": enter map 3\n";#d# |
74 | |
89 | |
75 | my $m = cf::map::find $map; |
90 | my $m = cf::map::find $map; |
76 | my $time = delete $pl->{unclean_save}; |
91 | my $time = delete $pl->{unclean_save}; |
|
|
92 | warn $pl->ob->name, ": enter map 4\n";#d# |
77 | |
93 | |
78 | if ($time && $m && !safe_spot $m, $x, $y) { |
94 | if ($time && $m) { |
79 | if ($time < $m->{instantiate_time}) { |
95 | if ($time < $m->{instantiate_time}) { |
80 | # the map was reset in the meantime |
96 | # the map was reset in the meantime |
81 | my $age = $cf::RUNTIME - $time; |
97 | my $age = $cf::RUNTIME - $time; |
82 | |
98 | |
83 | warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# |
99 | warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# |
84 | |
|
|
85 | ($map, $x, $y) = $pl->savebed; |
|
|
86 | |
100 | |
87 | if ($age >= $MAX_DISCONNECT_TIME) { |
101 | if ($age >= $MAX_DISCONNECT_TIME) { |
88 | $ob->message ( |
102 | $ob->message ( |
89 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
103 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
90 | . "Unfortunately, nobody was near to help you when the monsters arrived to eat you. " |
104 | . "Unfortunately, nobody was near to help you when the monsters arrived to eat you. " |
… | |
… | |
93 | cf::NDI_RED |
107 | cf::NDI_RED |
94 | ); |
108 | ); |
95 | # kill them. |
109 | # kill them. |
96 | # reminds me of the famous badness 10000 syndrome... |
110 | # reminds me of the famous badness 10000 syndrome... |
97 | $ob->stats->hp (-10000); #] if they survive this they deserved to live |
111 | $ob->stats->hp (-10000); #] if they survive this they deserved to live |
98 | $pl->killer ("a cave-in"); |
112 | my $killer = cf::arch::get "killer_login"; $pl->killer ($killer); $killer->destroy; |
99 | } else { |
113 | } else { |
|
|
114 | ($map, $x, $y) = $pl->savebed; |
|
|
115 | |
100 | $ob->message ( |
116 | $ob->message ( |
101 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
117 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
102 | . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " |
118 | . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " |
103 | . "Better use a savebed next time, much worse things could have happened... " |
119 | . "Better use a savebed next time, much worse things could have happened... " |
104 | . "H<You disconnected without having used a savebed. When you do that for too long, you might die.>", |
120 | . "H<You disconnected without having used a savebed. When you do that for too long, you might die.>", |
… | |
… | |
114 | cf::NDI_RED |
130 | cf::NDI_RED |
115 | ); |
131 | ); |
116 | } |
132 | } |
117 | } |
133 | } |
118 | |
134 | |
|
|
135 | warn $pl->ob->name, ": enter map 5\n";#d# |
119 | $ob->goto ($map, $x, $y); |
136 | #$ob->goto ($map, $x, $y); |
|
|
137 | $ob->goto ($map, $x, $y, sub { |
|
|
138 | warn $pl->ob->name, ": enter map check\n";#d# |
|
|
139 | $_[0] |
|
|
140 | }, sub { |
|
|
141 | warn $pl->ob->name, ": enter map done\n";#d# |
|
|
142 | }); |
|
|
143 | warn $pl->ob->name, ": enter map 6\n";#d# |
|
|
144 | |
120 | } |
145 | } |
121 | |
146 | |
122 | # delete a player directory, be non-blocking AND synchronous... |
147 | # delete a player directory, be non-blocking AND synchronous... |
123 | # (thats hard, so we crap out and fork). |
148 | # (thats hard, so we crap out and fork). |
124 | sub nuke_playerdir { |
149 | sub nuke_playerdir { |
… | |
… | |
146 | *** or it has been disabled. Face caching is mandatory |
171 | *** or it has been disabled. Face caching is mandatory |
147 | *** so please enable it or use a newer client. |
172 | *** so please enable it or use a newer client. |
148 | *** |
173 | *** |
149 | *** Look at your client preferences: |
174 | *** Look at your client preferences: |
150 | *** |
175 | *** |
151 | *** CFPlus: all known versions automatically enable the facecache. |
176 | *** deliantra: all known versions automatically enable the facecache. |
152 | *** cfclient: use the -cache commandline option. |
177 | *** cfclient: use the -cache commandline option. |
153 | *** cfclient: map will not redraw automatically (bug). |
178 | *** cfclient: map will not redraw automatically (bug). |
154 | *** gcfclient: use -cache commandline option, or enable |
179 | *** gcfclient: use -cache commandline option, or enable |
155 | *** gcfclient: Client => Configure => Map & Image => Cache Images. |
180 | *** gcfclient: Client => Configure => Map & Image => Cache Images. |
156 | *** jcrossclient: your client is broken, use CFPlus or gcfclient. |
181 | *** jcrossclient: your client is broken, use deliantra or gcfclient. |
157 | *** |
182 | *** |
158 | *** |
183 | *** |
159 | EOF |
184 | EOF |
160 | if ($ns->version =~ /jcrossclient/) { |
185 | if ($ns->version =~ /jcrossclient/) { |
161 | # let them, for now |
186 | # let them, for now |
… | |
… | |
197 | cf::NDI_BLUE |
222 | cf::NDI_BLUE |
198 | ); |
223 | ); |
199 | |
224 | |
200 | # read username |
225 | # read username |
201 | while () { |
226 | while () { |
202 | $user = query $ns, 0, "What is your name?\n:"; |
227 | $user = query $ns, 0, "What is your name? (login names are case-sensitive)\n:"; |
203 | |
228 | |
204 | if ($cf::LOGIN_LOCK{$user}) { |
229 | if ($cf::LOGIN_LOCK{$user}) { |
205 | $ns->send_drawinfo ( |
230 | $ns->send_drawinfo ( |
206 | "That username is currently used in another login session. " |
231 | "That username is currently used in another login session. " |
207 | . "Chose another, or wait till the other session has ended.", |
232 | . "Chose another, or wait till the other session has ended.", |
… | |
… | |
365 | } |
390 | } |
366 | } else { |
391 | } else { |
367 | $ob->roll_stats; |
392 | $ob->roll_stats; |
368 | } |
393 | } |
369 | |
394 | |
370 | Coro::Timer::sleep 0.2; |
395 | Coro::Timer::sleep 0.05; |
371 | } |
396 | } |
372 | |
397 | |
373 | $ob->set_animation (2); |
398 | $ob->set_animation (2); |
374 | $ob->add_statbonus; |
399 | $ob->add_statbonus; |
375 | |
400 | |
… | |
… | |
386 | |
411 | |
387 | $pl->chargen_race_next; |
412 | $pl->chargen_race_next; |
388 | Coro::Timer::sleep 0.2; |
413 | Coro::Timer::sleep 0.2; |
389 | } |
414 | } |
390 | |
415 | |
|
|
416 | # create the playerdir, if necessary, as chargen_race_done did it before |
|
|
417 | # presumably because of unique maps |
|
|
418 | aio_mkdir playerdir $pl, 0770; |
391 | $pl->chargen_race_done; |
419 | $pl->chargen_race_done; |
392 | |
420 | |
393 | while () { |
421 | while () { |
394 | my $res = query $ns, cf::CS_QUERY_SINGLECHAR, |
422 | my $res = query $ns, cf::CS_QUERY_SINGLECHAR, |
395 | "Now choose a gender.\nPress 'f' to become female, and 'm' to become male.\n"; |
423 | "Now choose a gender.\nPress 'f' to become female, and 'm' to become male.\n"; |
… | |
… | |
453 | |
481 | |
454 | # update respawn position |
482 | # update respawn position |
455 | $pl->savebed ($bed->map->path, $bed->x, $bed->y); |
483 | $pl->savebed ($bed->map->path, $bed->x, $bed->y); |
456 | cf::async { $pl->save }; |
484 | cf::async { $pl->save }; |
457 | |
485 | |
458 | $pl->killer ("left"); |
486 | my $killer = cf::arch::get "killer_logout"; $pl->killer ($killer); $killer->destroy; |
459 | $ob->check_score; |
487 | $ob->check_score; |
460 | |
488 | |
461 | $ob->reply (undef, "In the future, you will wake up here when you die."); |
489 | $ob->reply (undef, "In the future, you will wake up here when you die."); |
462 | |
490 | |
463 | $pl->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to continue playing (y/n)?", sub { |
491 | $pl->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to continue playing (y/n)?", sub { |
… | |
… | |
485 | |
513 | |
486 | if ($cleanly) { |
514 | if ($cleanly) { |
487 | $_->ob->message ("$name left the game.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; |
515 | $_->ob->message ("$name left the game.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; |
488 | } else { |
516 | } else { |
489 | $_->ob->message ("$name uncerimoniously disconnected.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; |
517 | $_->ob->message ("$name uncerimoniously disconnected.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; |
490 | $pl->{unclean_save} = $cf::RUNTIME; |
518 | $pl->{unclean_save} = $cf::RUNTIME |
|
|
519 | unless safe_spot $pl; |
491 | } |
520 | } |
492 | }, |
521 | }, |
493 | ); |
522 | ); |
494 | |
523 | |
495 | ############################################################################# |
524 | ############################################################################# |
… | |
… | |
536 | $pl->destroy; # destroys $ob |
565 | $pl->destroy; # destroys $ob |
537 | } else { |
566 | } else { |
538 | my $a_ = $pl->refcnt;#d# |
567 | my $a_ = $pl->refcnt;#d# |
539 | my $b_ = $ob->refcnt;#d# |
568 | my $b_ = $ob->refcnt;#d# |
540 | |
569 | |
541 | warn "player-scheduler refcnt ", $ob->name, " pl $pl_ref ob $ob_ref (C pl $a_ ob $b_)\n";#d# |
570 | warn "player-scheduler refcnt ", $ob->name, " pl $pl_ref/3 ob $ob_ref/3 (C pl $a_/1 ob $b_/2)\n";#d# |
542 | } |
571 | } |
543 | } |
572 | } |
544 | } |
573 | } |
545 | }; |
574 | }; |
546 | warn $@ if $@; |
575 | warn $@ if $@; |
547 | Coro::cede; |
576 | cf::cede_to_tick; |
548 | }; |
577 | }; |
549 | } |
578 | } |
550 | }; |
579 | }; |
551 | |
580 | |
552 | $SCHEDULER->prio (1); |
581 | $SCHEDULER->prio (1); |