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

Comparing deliantra/server/ext/rent.ext (file contents):
Revision 1.9 by root, Sun Jun 17 13:56:09 2007 UTC vs.
Revision 1.12 by root, Wed Nov 14 08:09:46 2007 UTC

45} 45}
46 46
47sub pay_balance { 47sub pay_balance {
48 my ($pl) = @_; 48 my ($pl) = @_;
49 49
50 cf::cede_to_tick;
51
50 update_balance $pl; 52 update_balance $pl;
51 53
52 return unless $pl->{rent}{balance} > 0; 54 return unless $pl->{rent}{balance} > 0;
53 55
54 my $deduct = cf::ceil $pl->{rent}{balance}; 56 my $deduct = cf::ceil $pl->{rent}{balance};
57 59
58 if ($deduct <= $pl->ob->{bank_balance}) { 60 if ($deduct <= $pl->ob->{bank_balance}) {
59 cf::db_put rent => balance => $deduct + cf::db_get rent => "balance"; 61 cf::db_put rent => balance => $deduct + cf::db_get rent => "balance";
60 $pl->ob->{bank_balance} -= $deduct; 62 $pl->ob->{bank_balance} -= $deduct;
61 $pl->{rent}{balance} -= $deduct; 63 $pl->{rent}{balance} -= $deduct;
62 $pl->ob->reply (undef, "Something whispers into your ear:\n" 64 $pl->ob->reply (undef, "Something whispers into your ear: "
63 . "Your highness, we deducted your apartment rent ($deduct_string) from your bank account."); 65 . "Your highness, we deducted your apartment rent ($deduct_string) from your bank account.");
64 } else { 66 } else {
65 $pl->ob->reply (undef, "Something whispers into your ear:\n" 67 $pl->ob->reply (undef, "Something whispers into your ear: "
66 . "Your highness, we want to deduct the apartment rent ($deduct_string), but the bank informed us that they cannot perform the transaction. " 68 . "Your highness, we want to deduct the apartment rent ($deduct_string), but the bank informed us that they cannot perform the transaction. "
67 . "Please even out your balance so we can deduct the fees, otherwise we will be forced to shut down your access to the apartment."); 69 . "Please even out your balance so we can deduct the fees, otherwise we will be forced to shut down your access to the apartment.");
68 } 70 }
69} 71}
70 72
90 92
91 while (my ($k, $v) = each %apartment) { 93 while (my ($k, $v) = each %apartment) {
92 my $type = exists $pl->{rent}{apartment}{$k} ? 1 : 2; 94 my $type = exists $pl->{rent}{apartment}{$k} ? 1 : 2;
93 95
94 $pl->ob->reply (undef, "model \"$v->[2]\", situated in $v->[1] (" 96 $pl->ob->reply (undef, "model \"$v->[2]\", situated in $v->[1] ("
95 . (cf::cost_string_from_value $v->[0]) . "/hr)") 97 . (cf::cost_string_from_value $v->[0]) . "/hr)\n")
96 if $type & $types; 98 if $type & $types;
97 } 99 }
98}; 100};
99 101
100cf::register_script_function "rent::status" => sub { 102cf::register_script_function "rent::status" => sub {
181 reject_entry $pl; 183 reject_entry $pl;
182 } 184 }
183 }, 185 },
184; 186;
185 187
186our $RENT_TIMER = Event->timer ( 188our $RENT_TIMER = cf::periodic 3600, Coro::unblock_sub {
187 reentrant => 0,
188 after => 60,
189 interval => 3600,
190 data => cf::WF_AUTOCANCEL,
191 cb => sub {
192 pay_balance $_ for cf::player::list; 189 pay_balance $_ for cf::player::list;
193 }, 190};
194);
195 191

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines