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.198 by root, Sun Jan 28 01:58:37 2007 UTC vs.
Revision 1.202 by root, Mon Jan 29 20:16:28 2007 UTC

82mkdir cf::localdir . "/" . cf::tmpdir; 82mkdir cf::localdir . "/" . cf::tmpdir;
83mkdir cf::localdir . "/" . cf::uniquedir; 83mkdir cf::localdir . "/" . cf::uniquedir;
84mkdir $RANDOM_MAPS; 84mkdir $RANDOM_MAPS;
85 85
86our $EMERGENCY_POSITION; 86our $EMERGENCY_POSITION;
87
88sub cf::map::normalise;
87 89
88############################################################################# 90#############################################################################
89 91
90=head2 GLOBAL VARIABLES 92=head2 GLOBAL VARIABLES
91 93
774 } 776 }
775 } else { 777 } else {
776 aio_unlink $filename; 778 aio_unlink $filename;
777 aio_unlink "$filename.pst"; 779 aio_unlink "$filename.pst";
778 } 780 }
781
782 #d##TODO# nuke non .map-files if exist
783 if ($filename =~ s/\.map$//) {
784 aio_unlink $filename;
785 aio_unlink "$filename.pst";
786 }
779 } 787 }
780} 788}
781 789
782sub object_freezer_as_string { 790sub object_freezer_as_string {
783 my ($rdata, $objs) = @_; 791 my ($rdata, $objs) = @_;
789 797
790sub object_thawer_load { 798sub object_thawer_load {
791 my ($filename) = @_; 799 my ($filename) = @_;
792 800
793 my ($data, $av); 801 my ($data, $av);
802
803 #d#TODO remove .map if file does not exist
804 aio_stat $filename and $filename =~ s/\.map$//;
794 805
795 (aio_load $filename, $data) >= 0 806 (aio_load $filename, $data) >= 0
796 or return; 807 or return;
797 808
798 unless (aio_stat "$filename.pst") { 809 unless (aio_stat "$filename.pst") {
1068=cut 1079=cut
1069 1080
1070sub maps($) { 1081sub maps($) {
1071 my ($pl) = @_; 1082 my ($pl) = @_;
1072 1083
1084 $pl = ref $pl ? $pl->ob->name : $pl;
1085
1073 my $files = aio_readdir playerdir $pl 1086 my $files = aio_readdir playerdir $pl
1074 or return; 1087 or return;
1075 1088
1076 my @paths; 1089 my @paths;
1077 1090
1078 for (@$files) { 1091 for (@$files) {
1079 utf8::decode $_; 1092 utf8::decode $_;
1080 next if /\.(?:pl|pst)$/; 1093 next if /\.(?:pl|pst)$/;
1081 next unless /^$PATH_SEP/o; 1094 next unless /^$PATH_SEP/o;
1082 1095
1083 s/\.map$//; 1096 push @paths, cf::map::normalise "~$pl/$_";
1084 push @paths, "~" . $pl->ob->name . "/" . $_;
1085 } 1097 }
1086 1098
1087 \@paths 1099 \@paths
1088} 1100}
1089 1101
1178sub normalise { 1190sub normalise {
1179 my ($path, $base) = @_; 1191 my ($path, $base) = @_;
1180 1192
1181 $path = "$path"; # make sure its a string 1193 $path = "$path"; # make sure its a string
1182 1194
1195 $path =~ s/\.map$//;
1196
1183 # map plan: 1197 # map plan:
1184 # 1198 #
1185 # /! non-realised random map exit (special hack!) 1199 # /! non-realised random map exit (special hack!)
1186 # {... are special paths that are not being touched 1200 # {... are special paths that are not being touched
1187 # ?xxx/... are special absolute paths 1201 # ?xxx/... are special absolute paths
1248 1262
1249# the original (read-only) location 1263# the original (read-only) location
1250sub load_path { 1264sub load_path {
1251 my ($self) = @_; 1265 my ($self) = @_;
1252 1266
1253 sprintf "%s/%s/%s", cf::datadir, cf::mapdir, $self->{path} 1267 sprintf "%s/%s/%s.map", cf::datadir, cf::mapdir, $self->{path}
1254} 1268}
1255 1269
1256# the temporary/swap location 1270# the temporary/swap location
1257sub save_path { 1271sub save_path {
1258 my ($self) = @_; 1272 my ($self) = @_;
1259 1273
1260 (my $path = $_[0]{path}) =~ s/\//$PATH_SEP/g; 1274 (my $path = $_[0]{path}) =~ s/\//$PATH_SEP/g;
1261 sprintf "%s/%s/%s", cf::localdir, cf::tmpdir, $path 1275 sprintf "%s/%s/%s.map", cf::localdir, cf::tmpdir, $path
1262} 1276}
1263 1277
1264# the unique path, undef == no special unique path 1278# the unique path, undef == no special unique path
1265sub uniq_path { 1279sub uniq_path {
1266 my ($self) = @_; 1280 my ($self) = @_;
1282 my ($self) = @_; 1296 my ($self) = @_;
1283 1297
1284 utf8::encode (my $save = $self->save_path); 1298 utf8::encode (my $save = $self->save_path);
1285 IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink $save; 1299 IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink $save;
1286 IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink "$save.pst"; 1300 IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink "$save.pst";
1301
1302 #d#TODO remove .map and also nuke
1303 $save =~ s/\.map// or return;#d#
1304 IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink $save;#d#
1305 IO::AIO::aioreq_pri 4; Coro::AIO::aio_unlink "$save.pst";#d#
1287} 1306}
1288 1307
1289sub load_header_from($) { 1308sub load_header_from($) {
1290 my ($self, $path) = @_; 1309 my ($self, $path) = @_;
1291 1310
1292 utf8::encode $path; 1311 utf8::encode $path;
1293 aio_open $path, O_RDONLY, 0 1312 #aio_open $path, O_RDONLY, 0
1294 or return; 1313 # or return;
1295 1314
1296 $self->_load_header ($path) 1315 $self->_load_header ($path)
1297 or return; 1316 or return;
1298 1317
1299 $self->{load_path} = $path; 1318 $self->{load_path} = $path;
1628 for (@$files) { 1647 for (@$files) {
1629 utf8::decode $_; 1648 utf8::decode $_;
1630 next if /\.pst$/; 1649 next if /\.pst$/;
1631 next unless /^$PATH_SEP/o; 1650 next unless /^$PATH_SEP/o;
1632 1651
1633 s/\.map$//; 1652 push @paths, cf::map::normalise $_;
1634 push @paths, $_;
1635 } 1653 }
1636 1654
1637 \@paths 1655 \@paths
1638} 1656}
1639 1657
1985 # get handled first 2003 # get handled first
1986 my $queue = delete $ns->{query_queue} 2004 my $queue = delete $ns->{query_queue}
1987 or return; # be conservative, not sure how that can happen, but we saw a crash here 2005 or return; # be conservative, not sure how that can happen, but we saw a crash here
1988 2006
1989 (shift @$queue)->[1]->($msg); 2007 (shift @$queue)->[1]->($msg);
2008 return unless $ns->valid; # temporary(?) workaround for callback destroying socket
1990 2009
1991 push @{ $ns->{query_queue} }, @$queue; 2010 push @{ $ns->{query_queue} }, @$queue;
1992 2011
1993 if (@{ $ns->{query_queue} } == @$queue) { 2012 if (@{ $ns->{query_queue} } == @$queue) {
1994 if (@$queue) { 2013 if (@$queue) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines