--- deliantra/server/ext/login.ext 2007/04/03 00:21:37 1.34 +++ deliantra/server/ext/login.ext 2007/04/18 17:32:06 1.42 @@ -6,8 +6,6 @@ use Coro::AIO; use List::Util qw(min max); -my $PLAYERDIR = sprintf "%s/%s", cf::localdir, cf::playerdir; - # paranoia function to overwrite a string-in-place sub nuke_str { substr $_[0], 0, (length $_[0]), "x" x length $_[0] @@ -17,7 +15,7 @@ my ($ns, $flags, $text) = @_; my $current = $Coro::current; - $ns->query ($flags, $text, sub { $current->ready; $current = $_[0]; }); + $ns->query ($flags, $text, sub { $current->ready; $current = $_[0] }); Coro::schedule while ref $current; $current @@ -80,6 +78,17 @@ . "&& (rm -rf ~\Q$Coro::current\E~deleting~ &)"; } +sub send_capabilities { + my ($ns) = @_; + + return unless $ns->extcmd; + + $ns->ext_event (capabilities => + # id, name, flags (1 == 2d), edge length + tileset => [[1, "default 64x64 faceset", 1, 64], [0, "default 32x32 faceset", 1, 32]], + ); +} + sub setup { my ($ns, $args) = @_; @@ -91,7 +100,6 @@ my %setup = split / +/, $args; while (my ($k, $v) = each %setup) { - if ($k eq "sound") { $ns->sound ($v); @@ -123,11 +131,18 @@ } elsif ($k eq "extcmd") { $ns->extcmd ($v > 0); + send_capabilities $ns; } elsif ($k eq "extmap") { $ns->extmap ($v); } elsif ($k eq "facecache") { + if (!$v) { + $v = 1; + $setup{$k} = $v; + $ns->send_drawinfo ("(trying to forcefully enable facecaching)", cf::NDI_RED); + } + $ns->facecache ($v); } elsif ($k eq "faceset") { @@ -135,6 +150,9 @@ $setup{$k} = 0; # $ns->image2 (1) + } elsif ($k eq "tileset") { + $setup{$k} = $ns->faceset ($v & 1); + } elsif ($k eq "itemcmd") { # Version of the item protocol command to use. Currently, # only supported versions are 1 and 2. Using a numeric @@ -146,8 +164,8 @@ } elsif ($k eq "mapsize") { my ($x, $y) = split /x/, $v; - $ns->mapx ($x = max 9, min cf::MAP_CLIENT_X, $x); - $ns->mapy ($y = max 9, min cf::MAP_CLIENT_Y, $y); + $ns->mapx ($x = max 9, min cf::MAP_CLIENT_X, ($x - 1) | 1); + $ns->mapy ($y = max 9, min cf::MAP_CLIENT_Y, ($y - 1) | 1); $setup{$k} = "${x}x${y}"; @@ -157,6 +175,9 @@ } elsif ($k eq "extendedTextInfos") { $ns->has_readable_type ($v); + } elsif ($k eq "smoothing") { # cfplus-style smoothing + $ns->smoothing ($v); + } elsif ($k eq "fxix") { $ns->fxix ($v); @@ -342,6 +363,19 @@ ); next; } + } else { + # unable to load the playerfile: + # check wether the player dir exists, which means the file is corrupted or + # something very similar. + if (!aio_stat cf::player::playerdir $user) { + $ns->send_drawinfo ( + "Unable to retrieve this player. It might be a locked or broken account. " + . "If this is your account, ask a dungeon master for assistance. " + . "Otherwise choose a different login name.", + cf::NDI_RED + ); + next; + } } # the rest of this function is character creation @@ -511,7 +545,7 @@ eval { if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { - $cf::WAIT_FOR_TICK_ONE->wait; + cf::wait_for_tick_begin; $pl->save; unless ($pl->active) {