--- deliantra/server/ext/login.ext 2007/01/07 02:39:14 1.11 +++ deliantra/server/ext/login.ext 2007/01/08 12:39:16 1.16 @@ -160,6 +160,7 @@ my $pl = cf::player::find $user or next; $pl->connect ($ns); check_clean_save $pl; + $pl->{clean_save} = 1; last; } elsif (can_cleanup $buf, $mtime) { Coro::Timer::sleep 1; @@ -257,9 +258,34 @@ }); } -# "Quitting will delete your character PERMANENTLY. If you are sure you want to do this, then use the quit_character command instead of quit." -# "Quitting will delete your character.\nAre you sure you want to quit (y/n):" -# quit, quit_character, save +cf::register_command quit => sub { + my ($ob, $arg) = @_; + + $ob->reply (undef, + "Quitting will delete your character PERMANENTLY: It will be gone forever and any progress will be lost. " + . "If you are sure you want to do this, then use the quit_character command instead of quit.", + cf::NDI_UNIQUE | cf::NDI_RED); +}; + +cf::register_command quit_character => sub { + my ($ob, $arg) = @_; + + my $pl = $ob->contr; + + $pl->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to PERMANENTLY delete your character and all associated data (y/n)?", sub { + if ($_[0] !~ /^[yY]/) { + $ob->reply (undef, + "Ok, not not quitting then.", + cf::NDI_UNIQUE | cf::NDI_RED); + } else { + $ob->reply (undef, + "Ok, quitting, hope to see you again.", + cf::NDI_UNIQUE | cf::NDI_RED); + $pl->ns->flush; + $pl->quit_character; + } + }); +}; cf::object->attach ( type => cf::SAVEBED, @@ -268,7 +294,7 @@ return cf::override 0 unless $ob->type == cf::PLAYER; - my $pl = $ob->pl; + my $pl = $ob->contr; # update respawn position $pl->savebed ($bed->map->path, $bed->x, $bed->y); @@ -284,10 +310,7 @@ $pl->deactivate; $pl->ns->destroy; } else { - cf::async { - $pl->{clean_save} = 1; - $pl->save; - }; + cf::async { $pl->save }; } }); }, @@ -308,6 +331,7 @@ $_->ob->message ("$name left the game.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; } else { $_->ob->message ("$name uncerimoniously disconnected.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; + delete $pl->{clean_save}; } }, ); @@ -342,6 +366,14 @@ $pl->save; Coro::Timer::sleep $SAVE_INTERVAL; } + my $ob = $pl->ob; + Scalar::Util::weaken $pl; # 2 == from object + from perl + Scalar::Util::weaken $ob; # 2 == one from being an object + ??? + my $a_ = $pl->refcnt; + my $b_ = $ob->refcnt; + my $a = $pl->refcnt_cnt; + my $b = $ob->refcnt_cnt; + warn "rc $a,$a_ $b,$b_\n";#d# }; warn $@ if $@; Coro::cede;