--- deliantra/server/ext/rent.ext 2007/01/21 21:28:27 1.6 +++ deliantra/server/ext/rent.ext 2007/02/15 03:19:02 1.7 @@ -18,12 +18,10 @@ sub reject_entry { my ($pl) = @_; - cf::override; + my $prev_pos = $pl->ob->{_prev_pos}; + $pl->ob->goto ($prev_pos ? @$prev_pos : "/world/world_105_115", 2, 34); - $pl->goto ("/world/world_105_115", 2, 34) - unless - $pl->ob->map - && !$pl->ob->map->{path}{user_rel}; + cf::override; } sub update_balance { @@ -160,33 +158,28 @@ on_enter => sub { my ($map, $pl, $x, $y) = @_; - # can freely enter homes of other people - { - my $path = sprintf "%s/%s/%s/", - cf::localdir, cf::playerdir, $pl->ob->name; + my $pfx = sprintf "~%s/", $pl->ob->name; - return if $path ne substr $map->path, 0, length $path; - } + # only do something if entering ones own apartment + if ($pfx eq substr $map->path, 0, length $pfx) { + for my $path (keys %{ $pl->{rent}{apartment} }) { + $path = sprintf "~%s%s", $pl->ob->name, $path; + + if ($map->path eq $path) { + if (check_balance $pl) { + $pl->ob->reply (undef, "Welcome to your apartment, sir!"); + } else { + $pl->ob->reply (undef, "We are sorry, sir, you have to pay your rent first."); + reject_entry $pl; + } - for my $path (keys %{ $pl->{rent}{apartment} }) { - $path =~ y/\//_/; - $path = sprintf "%s/%s/%s/%s", - cf::localdir, cf::playerdir, $pl->ob->name, $path; - - if ($map->path eq $path) { - if (check_balance $pl) { - $pl->ob->reply (undef, "Welcome to your apartment, sir!"); - } else { - $pl->ob->reply (undef, "We are sorry, sir, you have to pay your rent first."); - reject_entry $pl; + return; } - - return; } - } - $pl->ob->reply (undef, "Sir, you have to rent this apartment in The Apartment Shop in Scorn first!"); - reject_entry $pl; + $pl->ob->reply (undef, "Sir, you have to rent this apartment in The Apartment Shop in Scorn first!"); + reject_entry $pl; + } }, ;