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.42 by root, Wed Apr 18 17:32:06 2007 UTC vs.
Revision 1.49 by root, Sun Jun 10 03:11:16 2007 UTC

51 ); 51 );
52 52
53 1 53 1
54} 54}
55 55
56sub check_clean_save { 56sub enter_map {
57 my ($pl) = @_; 57 my ($pl) = @_;
58 58
59 my ($map, $x, $y)
60 = $pl->ob->{_link_pos}
61 ? @{delete $pl->ob->{_link_pos}}
62 : ($pl->maplevel, $pl->ob->x, $pl->ob->y);
63
64 $pl->ob->enter_link;
65
59 if (my $time = delete $pl->{unclean_save}) { 66 if (my $time = delete $pl->{unclean_save}) {
67 if (my $m = cf::map::find $map) {
68 if ($time < $m->{instantiate_time}) {
69 # the map was reset in the meantime
70 my $age = $cf::RUNTIME - $time;
71 warn $pl->ob->name, " map reset after logout, logout age $age\n";#d#
72
73 # for now, just go back to savebed
74 ($map, $x, $y) = $pl->savebed;
75
60 $pl->ns->send_drawinfo ( 76 $pl->ns->send_drawinfo (
77 "You didn't use a bed to reality to leave this realm, leaving your body in great danger. "
78 . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. "
79 . "Better use a savebed next time, much worse things could have happened...",
80 cf::NDI_RED
81 );
82 } else {
83 $pl->ns->send_drawinfo (
61 "You didn't use a savebed to leave this realm. This is very dangerous, " 84 "You didn't use a bed to reality to leave this realm. This is very dangerous, "
62 . "as lots of things could happen when you leave by other means, such as cave-ins, " 85 . "as lots of things could happen when you leave by other means, such as cave-ins, "
63 . "or monsters suddenly snapping your body. Better use a savebed next time.", 86 . "or monsters suddenly snapping your body. Better use a savebed next time.",
64 cf::NDI_RED 87 cf::NDI_RED
88 );
89 }
65 ); 90 }
66 #d#TODO
67 } 91 }
92
93 $pl->ob->goto ($map, $x, $y);
68} 94}
69 95
70# delete a player directory, be non-blocking AND synchronous... 96# delete a player directory, be non-blocking AND synchronous...
71# (thats hard, so we crap out and fork). 97# (thats hard, so we crap out and fork).
72sub nuke_playerdir { 98sub nuke_playerdir {
99 # The client then must sort this out 125 # The client then must sort this out
100 126
101 my %setup = split / +/, $args; 127 my %setup = split / +/, $args;
102 while (my ($k, $v) = each %setup) { 128 while (my ($k, $v) = each %setup) {
103 if ($k eq "sound") { 129 if ($k eq "sound") {
104 $ns->sound ($v); 130 $ns->sound ($v);
105 131
106 } elsif ($k eq "exp64") { 132 } elsif ($k eq "exp64") {
107 $setup{$k} = 1; 133 $setup{$k} = 1;
108 134
109 } elsif ($k eq "spellmon") { 135 } elsif ($k eq "spellmon") {
110 $ns->monitor_spells ($v); 136 $ns->monitor_spells ($v);
111 137
112 } elsif ($k eq "darkness") { 138 } elsif ($k eq "darkness") {
113 $ns->darkness ($v); 139 $ns->darkness ($v);
114 140
115 } elsif ($k eq "map1cmd") { 141 } elsif ($k eq "map1cmd") {
116 $ns->mapmode (cf::Map1Cmd) if $v > 0; 142 $ns->mapmode (cf::Map1Cmd) if $v > 0;
117 143
118 } elsif ($k eq "map1acmd") { 144 } elsif ($k eq "map1acmd") {
119 $ns->mapmode (cf::Map1aCmd) if $v > 0; 145 $ns->mapmode (cf::Map1aCmd) if $v > 0;
120 146
121 } elsif ($k eq "map2cmd") { 147 } elsif ($k eq "map2cmd") {
122 # gcfclient bug, map1acmd is sent too late 148 # gcfclient bug, map1acmd is sent too late
123 $ns->mapmode (cf::Map1aCmd); 149 $ns->mapmode (cf::Map1aCmd);
124 $setup{$k} = "FALSE"; 150 $setup{$k} = "FALSE";
125 151
126 } elsif ($k eq "newmapcmd") { 152 } elsif ($k eq "newmapcmd") {
127 $ns->newmapcmd ($v); 153 $ns->newmapcmd ($v);
128 154
129 } elsif ($k eq "mapinfocmd") { 155 } elsif ($k eq "mapinfocmd") {
130 $ns->mapinfocmd ($v); 156 $ns->mapinfocmd ($v);
131 157
132 } elsif ($k eq "extcmd") { 158 } elsif ($k eq "extcmd") {
133 $ns->extcmd ($v > 0); 159 $ns->extcmd ($v > 0);
134 send_capabilities $ns; 160 send_capabilities $ns;
135 161
136 } elsif ($k eq "extmap") { 162 } elsif ($k eq "extmap") {
137 $ns->extmap ($v); 163 $ns->extmap ($v);
138 164
139 } elsif ($k eq "facecache") { 165 } elsif ($k eq "facecache") {
140 if (!$v) { 166 if (!$v) {
141 $v = 1; 167 $v = 1;
142 $setup{$k} = $v; 168 $setup{$k} = $v;
143 $ns->send_drawinfo ("(trying to forcefully enable facecaching)", cf::NDI_RED); 169 $ns->send_drawinfo ("(trying to forcefully enable facecaching)", cf::NDI_RED);
144 } 170 }
145 171
146 $ns->facecache ($v); 172 $ns->facecache ($v);
147 173
148 } elsif ($k eq "faceset") { 174 } elsif ($k eq "faceset") {
149 $ns->faceset (0); 175 $ns->faceset (0);
150 $setup{$k} = 0; 176 $setup{$k} = 0;
151 # $ns->image2 (1) 177 # $ns->image2 (1)
152 178
153 } elsif ($k eq "tileset") { 179 } elsif ($k eq "tileset") {
154 $setup{$k} = $ns->faceset ($v & 1); 180 $setup{$k} = $ns->faceset ($v & 1);
155 181
156 } elsif ($k eq "itemcmd") { 182 } elsif ($k eq "itemcmd") {
157 # Version of the item protocol command to use. Currently, 183 # Version of the item protocol command to use. Currently,
158 # only supported versions are 1 and 2. Using a numeric 184 # only supported versions are 1 and 2. Using a numeric
159 # value will make it very easy to extend this in the future. 185 # value will make it very easy to extend this in the future.
160 $ns->itemcmd ($v) if $v >= 1 && $v <= 2; 186 $ns->itemcmd ($v) if $v >= 1 && $v <= 2;
161 187
162 $setup{$k} = $ns->itemcmd; 188 $setup{$k} = $ns->itemcmd;
163 189
164 } elsif ($k eq "mapsize") { 190 } elsif ($k eq "mapsize") {
165 my ($x, $y) = split /x/, $v; 191 my ($x, $y) = split /x/, $v;
166 192
167 $ns->mapx ($x = max 9, min cf::MAP_CLIENT_X, ($x - 1) | 1); 193 $ns->mapx ($x = max 9, min cf::MAP_CLIENT_X, ($x - 1) | 1);
168 $ns->mapy ($y = max 9, min cf::MAP_CLIENT_Y, ($y - 1) | 1); 194 $ns->mapy ($y = max 9, min cf::MAP_CLIENT_Y, ($y - 1) | 1);
169 195
170 $setup{$k} = "${x}x${y}"; 196 $setup{$k} = "${x}x${y}";
171 197
172 } elsif ($k eq "extendedMapInfos") { 198 } elsif ($k eq "extendedMapInfos") {
173 $ns->ext_mapinfos ($v); 199 $ns->ext_mapinfos ($v);
174 200
175 } elsif ($k eq "extendedTextInfos") { 201 } elsif ($k eq "extendedTextInfos") {
176 $ns->has_readable_type ($v); 202 $ns->has_readable_type ($v);
177 203
178 } elsif ($k eq "smoothing") { # cfplus-style smoothing 204 } elsif ($k eq "smoothing") { # cfplus-style smoothing
179 $ns->smoothing ($v); 205 $ns->smoothing ($v);
180 206
181 } elsif ($k eq "fxix") { 207 } elsif ($k eq "fxix") {
182 $ns->fxix ($v); 208 $ns->fxix ($v);
209
210 } elsif ($k eq "msg") {
211 $ns->can_msg ($v);
212
213 } elsif ($k eq "excmd") {
214 # we support it
183 215
184 } else { 216 } else {
185 # other commands: 217 # other commands:
186 # sexp: no idea, probably for oudated servers 218 # sexp: no idea, probably for oudated servers
187 # tick: more stupidity, server should sned a tick per tick 219 # tick: more stupidity, server should send a tick per tick
188 220
189 $setup{$k} = "FALSE"; 221 $setup{$k} = "FALSE";
190 } 222 }
191 } 223 }
192 224
193 $ns->send_packet (join " ", setup => %setup); 225 $ns->send_packet (join " ", setup => %setup);
194 226
326 if ($cf::CFG{ext_login_nocheck} or $hash eq crypt $pass, $hash) { 358 if ($cf::CFG{ext_login_nocheck} or $hash eq crypt $pass, $hash) {
327 nuke_str $pass; 359 nuke_str $pass;
328 # password matches, wonderful 360 # password matches, wonderful
329 my $pl = cf::player::find $user or next; 361 my $pl = cf::player::find $user or next;
330 $pl->connect ($ns); 362 $pl->connect ($ns);
331 check_clean_save $pl; 363 enter_map $pl;
332 last; 364 last;
333 } elsif (can_cleanup $pl, $mtime) { 365 } elsif (can_cleanup $pl, $mtime) {
334 Coro::Timer::sleep 1; 366 Coro::Timer::sleep 1;
335 367
336 $ns->send_drawinfo ( 368 $ns->send_drawinfo (
399 431
400 my $pl = cf::player::new $user; 432 my $pl = cf::player::new $user;
401 $pl->password (crypt $pass, join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]); 433 $pl->password (crypt $pass, join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]);
402 nuke_str $pass; 434 nuke_str $pass;
403 $pl->connect ($ns); 435 $pl->connect ($ns);
404
405 my $ob = $pl->ob; 436 my $ob = $pl->ob;
437
438 $ob->goto ($pl->maplevel, $ob->x, $ob->y);
406 439
407 while () { 440 while () {
408 $ob->update_stats; 441 $ob->update_stats;
409 $pl->save_stats; 442 $pl->save_stats;
410 443
425 } 458 }
426 459
427 $ob->set_animation (2); 460 $ob->set_animation (2);
428 $ob->add_statbonus; 461 $ob->add_statbonus;
429 462
430 $ns->send_drawinfo ($ob->msg, cf::NDI_BLUE); 463 while () {
431 $ns->send_packet (sprintf "query %d %s", cf::CS_QUERY_SINGLECHAR, 464 $ns->send_msg (-1, "chargen-race-title", ucfirst $pl->title);
465 my $msg = $ob->msg;
466 $msg =~ s/(?<=\S)\n(?=\S)/ /g;
467 $ns->send_msg (cf::NDI_BLUE, "chargen-race-description", $msg);
468
469 my $res = query $ns, cf::CS_QUERY_SINGLECHAR,
432 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); 470 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n";
433 471
434 $ns->state (cf::ST_CHANGE_CLASS); 472 last if $res =~ /[dD]/;
473
474 $pl->chargen_race_next;
475 }
476
477 $pl->chargen_race_done;
478
435 delete $pl->{deny_save};#d# too early 479 delete $pl->{deny_save};
436 480
437 last; 481 last;
438 } 482 }
439 }); 483 });
440} 484}
546 eval { 590 eval {
547 if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { 591 if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) {
548 cf::wait_for_tick_begin; 592 cf::wait_for_tick_begin;
549 $pl->save; 593 $pl->save;
550 594
551 unless ($pl->active) { 595 unless ($pl->active || $pl->ns) {
552 # check refcounts, this is tricky and needs to be adjusted to fit server internals 596 # check refcounts, this is tricky and needs to be adjusted to fit server internals
553 my $ob = $pl->ob; 597 my $ob = $pl->ob;
554 Scalar::Util::weaken $pl; 598 Scalar::Util::weaken $pl;
555 Scalar::Util::weaken $ob; 599 Scalar::Util::weaken $ob;
556 my $a_ = $pl->refcnt;#d# 600 my $a_ = $pl->refcnt;#d#
557 my $b_ = $ob->refcnt;#d# 601 my $b_ = $ob->refcnt;#d#
558 my $pl_ref = $pl->refcnt_cnt; 602 my $pl_ref = $pl->refcnt_cnt;
559 my $ob_ref = $ob->refcnt_cnt; 603 my $ob_ref = $ob->refcnt_cnt;
560 604
561 ## pl_ref == one from object + one from cf::PLAYER 605 ## pl_ref == one from object + one from cf::PLAYER
562 ## ob_ref == one from simply being an object 606 ## ob_ref == one from simply being an object + one from pl->observe
563 if ($pl_ref == 2 && $ob_ref == 1) { 607 if ($pl_ref == 2 && $ob_ref == 2) {
564 warn "player-scheduler destroy ", $ob->name;#d# 608 warn "player-scheduler destroy ", $ob->name;#d#
565 609
566 # remove from sight and get fresh "copies" 610 # remove from sight and get fresh "copies"
567 $pl = delete $cf::PLAYER{$ob->name}; 611 $pl = delete $cf::PLAYER{$ob->name};
568 $ob = $pl->ob; 612 $ob = $pl->ob;
569 613
570 $ob->destroy; 614 $ob->destroy;
571 $pl->destroy; 615 $pl->destroy;
572 } else { 616 } else {
573 warn "player-scheduler refcnt ", $ob->name, " $pl_ref,$a_ $ob_ref,$b_\n";#d# 617 warn "player-scheduler refcnt ", $ob->name, " pp$pl_ref,pc$a_ op$ob_ref,oc$b_\n";#d#
574 } 618 }
575 } 619 }
576 } 620 }
577 }; 621 };
578 warn $@ if $@; 622 warn $@ if $@;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines