ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/login.ext
(Generate patch)

Comparing deliantra/server/ext/login.ext (file contents):
Revision 1.78 by root, Mon Jan 7 01:55:19 2008 UTC vs.
Revision 1.89 by root, Sat Aug 30 05:19:03 2008 UTC

52 ); 52 );
53 53
54 1 54 1
55} 55}
56 56
57sub safe_spot($$$) { 57sub safe_spot($) {
58 my ($m, $x, $y) = @_; 58 my ($pl) = @_;
59
60 my $ob = $pl->ob;
59 61
62 my $m = $ob->map
63 or return;
64 my $x = $ob->x;
65 my $y = $ob->y;
66
60 return 0; 67# return 0;#d#
61 warn join ":", $m->at ($x, $y);#d# 68# warn join ":", $m->at ($x, $y);#d#
62 warn "FOO$m { ".scalar ($m->at ($x, $y))." }\n"; 69# warn "FOO$m { ".scalar ($m->at ($x, $y))." }\n";
63 return 0; 70# return 0;
64 71
65 scalar grep $_->type == cf::SAVEBED, $m->at ($x, $y) 72 scalar grep $_->type == cf::SAVEBED, $m->at ($x, $y)
66} 73}
67 74
68sub enter_map { 75sub enter_map {
69 my ($pl) = @_; 76 my ($pl) = @_;
70 77
78 warn $pl->ob->name, ": enter map 1\n";#d#
71 my $ob = $pl->ob; 79 my $ob = $pl->ob;
72 80
73 my ($map, $x, $y) 81 my ($map, $x, $y)
74 = $ob->{_link_pos} 82 = $ob->{_link_pos}
75 ? @{delete $ob->{_link_pos}} 83 ? @{delete $ob->{_link_pos}}
76 : ($pl->maplevel, $ob->x, $ob->y); 84 : ($pl->maplevel, $ob->x, $ob->y);
77 85
86 warn $pl->ob->name, ": enter map 2\n";#d#
78 $ob->enter_link; 87 $ob->enter_link;
88 warn $pl->ob->name, ": enter map 3\n";#d#
79 89
80 my $m = cf::map::find $map; 90 my $m = cf::map::find $map;
81 my $time = delete $pl->{unclean_save}; 91 my $time = delete $pl->{unclean_save};
92 warn $pl->ob->name, ": enter map 4\n";#d#
82 93
83 if ($time && $m && !safe_spot $m, $x, $y) { 94 if ($time && $m) {
84 if ($time < $m->{instantiate_time}) { 95 if ($time < $m->{instantiate_time}) {
85 # the map was reset in the meantime 96 # the map was reset in the meantime
86 my $age = $cf::RUNTIME - $time; 97 my $age = $cf::RUNTIME - $time;
87 98
88 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#
89
90 ($map, $x, $y) = $pl->savebed;
91 100
92 if ($age >= $MAX_DISCONNECT_TIME) { 101 if ($age >= $MAX_DISCONNECT_TIME) {
93 $ob->message ( 102 $ob->message (
94 "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. "
95 . "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. "
98 cf::NDI_RED 107 cf::NDI_RED
99 ); 108 );
100 # kill them. 109 # kill them.
101 # reminds me of the famous badness 10000 syndrome... 110 # reminds me of the famous badness 10000 syndrome...
102 $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
103 $pl->killer ("a cave-in"); 112 my $killer = cf::arch::get "killer_login"; $pl->killer ($killer); $killer->destroy;
104 } else { 113 } else {
114 ($map, $x, $y) = $pl->savebed;
115
105 $ob->message ( 116 $ob->message (
106 "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. "
107 . "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. "
108 . "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... "
109 . "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.>",
119 cf::NDI_RED 130 cf::NDI_RED
120 ); 131 );
121 } 132 }
122 } 133 }
123 134
135 warn $pl->ob->name, ": enter map 5\n";#d#
124 $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
125} 145}
126 146
127# delete a player directory, be non-blocking AND synchronous... 147# delete a player directory, be non-blocking AND synchronous...
128# (thats hard, so we crap out and fork). 148# (thats hard, so we crap out and fork).
129sub nuke_playerdir { 149sub nuke_playerdir {
151*** or it has been disabled. Face caching is mandatory 171*** or it has been disabled. Face caching is mandatory
152*** so please enable it or use a newer client. 172*** so please enable it or use a newer client.
153*** 173***
154*** Look at your client preferences: 174*** Look at your client preferences:
155*** 175***
156*** CFPlus: all known versions automatically enable the facecache. 176*** deliantra: all known versions automatically enable the facecache.
157*** cfclient: use the -cache commandline option. 177*** cfclient: use the -cache commandline option.
158*** cfclient: map will not redraw automatically (bug). 178*** cfclient: map will not redraw automatically (bug).
159*** gcfclient: use -cache commandline option, or enable 179*** gcfclient: use -cache commandline option, or enable
160*** gcfclient: Client => Configure => Map & Image => Cache Images. 180*** gcfclient: Client => Configure => Map & Image => Cache Images.
161*** jcrossclient: your client is broken, use CFPlus or gcfclient. 181*** jcrossclient: your client is broken, use deliantra or gcfclient.
162*** 182***
163*** 183***
164EOF 184EOF
165 if ($ns->version =~ /jcrossclient/) { 185 if ($ns->version =~ /jcrossclient/) {
166 # let them, for now 186 # let them, for now
202 cf::NDI_BLUE 222 cf::NDI_BLUE
203 ); 223 );
204 224
205 # read username 225 # read username
206 while () { 226 while () {
207 $user = query $ns, 0, "What is your name?\n:"; 227 $user = query $ns, 0, "What is your name? (login names are case-sensitive)\n:";
208 228
209 if ($cf::LOGIN_LOCK{$user}) { 229 if ($cf::LOGIN_LOCK{$user}) {
210 $ns->send_drawinfo ( 230 $ns->send_drawinfo (
211 "That username is currently used in another login session. " 231 "That username is currently used in another login session. "
212 . "Chose another, or wait till the other session has ended.", 232 . "Chose another, or wait till the other session has ended.",
370 } 390 }
371 } else { 391 } else {
372 $ob->roll_stats; 392 $ob->roll_stats;
373 } 393 }
374 394
375 Coro::Timer::sleep 0.2; 395 Coro::Timer::sleep 0.05;
376 } 396 }
377 397
378 $ob->set_animation (2); 398 $ob->set_animation (2);
379 $ob->add_statbonus; 399 $ob->add_statbonus;
380 400
391 411
392 $pl->chargen_race_next; 412 $pl->chargen_race_next;
393 Coro::Timer::sleep 0.2; 413 Coro::Timer::sleep 0.2;
394 } 414 }
395 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;
396 $pl->chargen_race_done; 419 $pl->chargen_race_done;
397 420
398 while () { 421 while () {
399 my $res = query $ns, cf::CS_QUERY_SINGLECHAR, 422 my $res = query $ns, cf::CS_QUERY_SINGLECHAR,
400 "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";
458 481
459 # update respawn position 482 # update respawn position
460 $pl->savebed ($bed->map->path, $bed->x, $bed->y); 483 $pl->savebed ($bed->map->path, $bed->x, $bed->y);
461 cf::async { $pl->save }; 484 cf::async { $pl->save };
462 485
463 $pl->killer ("left"); 486 my $killer = cf::arch::get "killer_logout"; $pl->killer ($killer); $killer->destroy;
464 $ob->check_score; 487 $ob->check_score;
465 488
466 $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.");
467 490
468 $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 {
490 513
491 if ($cleanly) { 514 if ($cleanly) {
492 $_->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;
493 } else { 516 } else {
494 $_->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;
495 $pl->{unclean_save} = $cf::RUNTIME; 518 $pl->{unclean_save} = $cf::RUNTIME
519 unless safe_spot $pl;
496 } 520 }
497 }, 521 },
498); 522);
499 523
500############################################################################# 524#############################################################################
541 $pl->destroy; # destroys $ob 565 $pl->destroy; # destroys $ob
542 } else { 566 } else {
543 my $a_ = $pl->refcnt;#d# 567 my $a_ = $pl->refcnt;#d#
544 my $b_ = $ob->refcnt;#d# 568 my $b_ = $ob->refcnt;#d#
545 569
546 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#
547 } 571 }
548 } 572 }
549 } 573 }
550 }; 574 };
551 warn $@ if $@; 575 warn $@ if $@;
552 Coro::cede; 576 cf::cede_to_tick;
553 }; 577 };
554 } 578 }
555}; 579};
556 580
557$SCHEDULER->prio (1); 581$SCHEDULER->prio (1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines