ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.474 by root, Thu Jul 16 21:42:56 2009 UTC vs.
Revision 1.479 by root, Thu Oct 8 05:04:27 2009 UTC

88our %EXT_CORO = (); # coroutines bound to extensions 88our %EXT_CORO = (); # coroutines bound to extensions
89our %EXT_MAP = (); # pluggable maps 89our %EXT_MAP = (); # pluggable maps
90 90
91our $RELOAD; # number of reloads so far, non-zero while in reload 91our $RELOAD; # number of reloads so far, non-zero while in reload
92our @EVENT; 92our @EVENT;
93our @REFLECT; # set by XS
94our %REFLECT; # set by us
93 95
94our $CONFDIR = confdir; 96our $CONFDIR = confdir;
95our $DATADIR = datadir; 97our $DATADIR = datadir;
96our $LIBDIR = "$DATADIR/ext"; 98our $LIBDIR = "$DATADIR/ext";
97our $PODDIR = "$DATADIR/pod"; 99our $PODDIR = "$DATADIR/pod";
161 163
162sub cf::map::normalise; 164sub cf::map::normalise;
163 165
164############################################################################# 166#############################################################################
165 167
168%REFLECT = ();
169for (@REFLECT) {
170 my $reflect = JSON::XS::decode_json $_;
171 $REFLECT{$reflect->{class}} = $reflect;
172}
173
174#############################################################################
175
166=head2 GLOBAL VARIABLES 176=head2 GLOBAL VARIABLES
167 177
168=over 4 178=over 4
169 179
170=item $cf::UPTIME 180=item $cf::UPTIME
218 228
219This array contains the results of the last C<invoke ()> call. When 229This array contains the results of the last C<invoke ()> call. When
220C<cf::override> is called C<@cf::INVOKE_RESULTS> is set to the parameters of 230C<cf::override> is called C<@cf::INVOKE_RESULTS> is set to the parameters of
221that call. 231that call.
222 232
233=item %cf::REFLECT
234
235Contains, for each (C++) class name, a hash reference with information
236about object members (methods, scalars and arrays) and other metadata,
237which is useful for introspection.
238
223=back 239=back
224 240
225=cut 241=cut
226 242
227BEGIN { 243$Coro::State::WARNHOOK = sub {
228 *CORE::GLOBAL::warn = sub {
229 my $msg = join "", @_; 244 my $msg = join "", @_;
230 245
231 $msg .= "\n" 246 $msg .= "\n"
232 unless $msg =~ /\n$/; 247 unless $msg =~ /\n$/;
233 248
234 $msg =~ s/([\x00-\x08\x0b-\x1f])/sprintf "\\x%02x", ord $1/ge; 249 $msg =~ s/([\x00-\x08\x0b-\x1f])/sprintf "\\x%02x", ord $1/ge;
235 250
236 LOG llevError, $msg; 251 LOG llevError, $msg;
237 }; 252};
238}
239 253
240$Coro::State::DIEHOOK = sub { 254$Coro::State::DIEHOOK = sub {
241 return unless $^S eq 0; # "eq", not "==" 255 return unless $^S eq 0; # "eq", not "=="
256
257 warn Carp::longmess $_[0];
242 258
243 if ($Coro::current == $Coro::main) {#d# 259 if ($Coro::current == $Coro::main) {#d#
244 warn "DIEHOOK called in main context, Coro bug?\n";#d# 260 warn "DIEHOOK called in main context, Coro bug?\n";#d#
245 return;#d# 261 return;#d#
246 }#d# 262 }#d#
247 263
248 # kill coroutine otherwise 264 # kill coroutine otherwise
249 warn Carp::longmess $_[0];
250 Coro::terminate 265 Coro::terminate
251}; 266};
252
253$SIG{__DIE__} = sub { }; #d#?
254 267
255@safe::cf::global::ISA = @cf::global::ISA = 'cf::attachable'; 268@safe::cf::global::ISA = @cf::global::ISA = 'cf::attachable';
256@safe::cf::object::ISA = @cf::object::ISA = 'cf::attachable'; 269@safe::cf::object::ISA = @cf::object::ISA = 'cf::attachable';
257@safe::cf::player::ISA = @cf::player::ISA = 'cf::attachable'; 270@safe::cf::player::ISA = @cf::player::ISA = 'cf::attachable';
258@safe::cf::client::ISA = @cf::client::ISA = 'cf::attachable'; 271@safe::cf::client::ISA = @cf::client::ISA = 'cf::attachable';
2223 2236
2224 my $lock = cf::lock_acquire "map_data:$self->{path}"; 2237 my $lock = cf::lock_acquire "map_data:$self->{path}";
2225 2238
2226 return if $self->players; 2239 return if $self->players;
2227 2240
2228 warn "resetting map ", $self->path; 2241 warn "resetting map ", $self->path, "\n";
2229 2242
2230 $self->in_memory (cf::MAP_SWAPPED); 2243 $self->in_memory (cf::MAP_SWAPPED);
2231 2244
2232 # need to save uniques path 2245 # need to save uniques path
2233 unless ($self->{deny_save}) { 2246 unless ($self->{deny_save}) {
2534 2547
2535 $map->load; 2548 $map->load;
2536 $map->load_neighbours; 2549 $map->load_neighbours;
2537 2550
2538 return unless $self->contr->active; 2551 return unless $self->contr->active;
2539 $self->flag (cf::FLAG_DEBUG, 0);#d# temp
2540 $self->activate_recursive;
2541 2552
2542 local $self->{_prev_pos} = $link_pos; # ugly hack for rent.ext 2553 local $self->{_prev_pos} = $link_pos; # ugly hack for rent.ext
2543 $self->enter_map ($map, $x, $y); 2554 $self->enter_map ($map, $x, $y);
2555
2556 # only activate afterwards, to support waiting in hooks
2557 $self->activate_recursive;
2544} 2558}
2545 2559
2546=item $player_object->goto ($path, $x, $y[, $check->($map)[, $done->()]]) 2560=item $player_object->goto ($path, $x, $y[, $check->($map)[, $done->()]])
2547 2561
2548Moves the player to the given map-path and coordinates by first freezing 2562Moves the player to the given map-path and coordinates by first freezing
3460 load_extensions; 3474 load_extensions;
3461 3475
3462 utime time, time, $RUNTIMEFILE; 3476 utime time, time, $RUNTIMEFILE;
3463 3477
3464 # no (long-running) fork's whatsoever before this point(!) 3478 # no (long-running) fork's whatsoever before this point(!)
3479 use POSIX ();
3465 POSIX::close delete $ENV{LOCKUTIL_LOCK_FD} if exists $ENV{LOCKUTIL_LOCK_FD}; 3480 POSIX::close delete $ENV{LOCKUTIL_LOCK_FD} if exists $ENV{LOCKUTIL_LOCK_FD};
3466 3481
3467 (pop @POST_INIT)->(0) while @POST_INIT; 3482 (pop @POST_INIT)->(0) while @POST_INIT;
3468 }; 3483 };
3469 3484

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines