… | |
… | |
118 | utf8::encode $msg; |
118 | utf8::encode $msg; |
119 | |
119 | |
120 | $msg .= "\n" |
120 | $msg .= "\n" |
121 | unless $msg =~ /\n$/; |
121 | unless $msg =~ /\n$/; |
122 | |
122 | |
123 | LOG llevError, "cfperl: $msg"; |
123 | LOG llevError, $msg; |
124 | }; |
124 | }; |
125 | } |
125 | } |
126 | |
126 | |
127 | @safe::cf::global::ISA = @cf::global::ISA = 'cf::attachable'; |
127 | @safe::cf::global::ISA = @cf::global::ISA = 'cf::attachable'; |
128 | @safe::cf::object::ISA = @cf::object::ISA = 'cf::attachable'; |
128 | @safe::cf::object::ISA = @cf::object::ISA = 'cf::attachable'; |
… | |
… | |
1119 | return $cf::PLAYER{$_[0]} || do { |
1119 | return $cf::PLAYER{$_[0]} || do { |
1120 | my $login = $_[0]; |
1120 | my $login = $_[0]; |
1121 | |
1121 | |
1122 | my $guard = cf::lock_acquire "user_find:$login"; |
1122 | my $guard = cf::lock_acquire "user_find:$login"; |
1123 | |
1123 | |
1124 | $cf::PLAYER{$login} ||= (load_pl path $login or return); |
1124 | $cf::PLAYER{$_[0]} || do { |
|
|
1125 | my $pl = load_pl path $login |
|
|
1126 | or return; |
|
|
1127 | $cf::PLAYER{$login} = $pl |
|
|
1128 | } |
1125 | }; |
1129 | } |
1126 | } |
1130 | } |
1127 | |
1131 | |
1128 | sub save($) { |
1132 | sub save($) { |
1129 | my ($pl) = @_; |
1133 | my ($pl) = @_; |
1130 | |
1134 | |
… | |
… | |
1132 | |
1136 | |
1133 | my $path = path $pl; |
1137 | my $path = path $pl; |
1134 | my $guard = cf::lock_acquire "user_save:$path"; |
1138 | my $guard = cf::lock_acquire "user_save:$path"; |
1135 | |
1139 | |
1136 | return if $pl->{deny_save}; |
1140 | return if $pl->{deny_save}; |
|
|
1141 | |
|
|
1142 | Coro::AIO::aio_mkdir playerdir $pl, 0770; |
1137 | $pl->{last_save} = $cf::RUNTIME; |
1143 | $pl->{last_save} = $cf::RUNTIME; |
1138 | |
1144 | |
1139 | Coro::cede; |
|
|
1140 | $pl->save_pl ($path); |
1145 | $pl->save_pl ($path); |
1141 | Coro::cede; |
1146 | Coro::cede; |
1142 | } |
1147 | } |
1143 | |
1148 | |
1144 | sub new($) { |
1149 | sub new($) { |
… | |
… | |
1165 | $pl->invoke (cf::EVENT_PLAYER_QUIT); |
1170 | $pl->invoke (cf::EVENT_PLAYER_QUIT); |
1166 | $pl->ns->destroy if $pl->ns; |
1171 | $pl->ns->destroy if $pl->ns; |
1167 | |
1172 | |
1168 | my $path = playerdir $pl; |
1173 | my $path = playerdir $pl; |
1169 | my $temp = "$path~$cf::RUNTIME~deleting~"; |
1174 | my $temp = "$path~$cf::RUNTIME~deleting~"; |
1170 | IO::AIO::aio_rename $path, $temp, sub { |
1175 | Coro::AIO::aio_rename $path, $temp; |
1171 | delete $cf::PLAYER{$pl->ob->name}; |
1176 | delete $cf::PLAYER{$pl->ob->name}; |
1172 | $pl->destroy; |
1177 | $pl->destroy; |
1173 | |
|
|
1174 | IO::AIO::aio_rmtree $temp; |
1178 | IO::AIO::aio_rmtree $temp; |
1175 | }; |
|
|
1176 | } |
1179 | } |
1177 | |
1180 | |
1178 | =item $player->ext_reply ($msgid, $msgtype, %msg) |
1181 | =item $player->ext_reply ($msgid, $msgtype, %msg) |
1179 | |
1182 | |
1180 | Sends an ext reply to the player. |
1183 | Sends an ext reply to the player. |
… | |
… | |
1679 | $map = $map->customise_for ($self) if $map; |
1682 | $map = $map->customise_for ($self) if $map; |
1680 | |
1683 | |
1681 | # warn "entering ", $map->path, " at ($x, $y)\n" |
1684 | # warn "entering ", $map->path, " at ($x, $y)\n" |
1682 | # if $map; |
1685 | # if $map; |
1683 | |
1686 | |
|
|
1687 | $map or $map->cluck ("oy");#d# |
1684 | $map or $self->message ("The exit is closed", cf::NDI_UNIQUE | cf::NDI_RED); |
1688 | $map or $self->message ("The exit to '" . ($path->visible_name) . "' is closed", cf::NDI_UNIQUE | cf::NDI_RED); |
1685 | |
1689 | |
1686 | $self->leave_link ($map, $x, $y); |
1690 | $self->leave_link ($map, $x, $y); |
1687 | })->prio (1); |
1691 | })->prio (1); |
1688 | } |
1692 | } |
1689 | |
1693 | |
… | |
… | |
2097 | $cf::map::MAX_RESET = $CFG{map_max_reset} if exists $CFG{map_max_reset}; |
2101 | $cf::map::MAX_RESET = $CFG{map_max_reset} if exists $CFG{map_max_reset}; |
2098 | $cf::map::DEFAULT_RESET = $CFG{map_default_reset} if exists $CFG{map_default_reset}; |
2102 | $cf::map::DEFAULT_RESET = $CFG{map_default_reset} if exists $CFG{map_default_reset}; |
2099 | |
2103 | |
2100 | if (exists $CFG{mlockall}) { |
2104 | if (exists $CFG{mlockall}) { |
2101 | eval { |
2105 | eval { |
2102 | $CFG{mlockall} ? &mlockall : &munlockall |
2106 | $CFG{mlockall} ? eval "mlockall()" : eval "munlockall()" |
2103 | and die "WARNING: m(un)lockall failed: $!\n"; |
2107 | and die "WARNING: m(un)lockall failed: $!\n"; |
2104 | }; |
2108 | }; |
2105 | warn $@ if $@; |
2109 | warn $@ if $@; |
2106 | } |
2110 | } |
2107 | } |
2111 | } |