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.161 by root, Thu Jan 11 00:16:58 2007 UTC vs.
Revision 1.164 by root, Thu Jan 11 01:24:25 2007 UTC

472} 472}
473 473
474# escape the /'s in the path 474# escape the /'s in the path
475sub _escaped_path { 475sub _escaped_path {
476 (my $path = $_[0]{path}) =~ s/\//$PATH_SEP/g; 476 (my $path = $_[0]{path}) =~ s/\//$PATH_SEP/g;
477
477 $path 478 $path
478} 479}
479 480
480# the original (read-only) location 481# the original (read-only) location
481sub load_path { 482sub load_path {
486 487
487# the temporary/swap location 488# the temporary/swap location
488sub save_path { 489sub save_path {
489 my ($self) = @_; 490 my ($self) = @_;
490 491
492 $self->{user_rel}
491 $self->{user_rel} ? sprintf "%s/%s/%s/%s", cf::localdir, cf::playerdir, $self->{user}, $self->_escaped_path 493 ? sprintf "%s/%s/%s/%s", cf::localdir, cf::playerdir, $self->{user}, $self->_escaped_path
492 : $self->{random} ? sprintf "%s/%s", $RANDOM_MAPS, $self->{path}
493 : sprintf "%s/%s/%s", cf::localdir, cf::tmpdir, $self->_escaped_path 494 : sprintf "%s/%s/%s", cf::localdir, cf::tmpdir, $self->_escaped_path
494} 495}
495 496
496# the unique path, undef == no special unique path 497# the unique path, undef == no special unique path
497sub uniq_path { 498sub uniq_path {
498 my ($self) = @_; 499 my ($self) = @_;
513 514
514sub load_temp { 515sub load_temp {
515 my ($self) = @_; 516 my ($self) = @_;
516 517
517 &cf::map::load_map_header ($self->save_path) 518 &cf::map::load_map_header ($self->save_path)
519}
520
521sub unlink_save {
522 my ($self) = @_;
523
524 utf8::encode (my $save = $self->save_path);
525 IO::AIO::aioreq_pri 4; IO::AIO::aio_unlink $save;
526 IO::AIO::aioreq_pri 4; IO::AIO::aio_unlink "$save.pst";
518} 527}
519 528
520package cf; 529package cf;
521 530
522############################################################################# 531#############################################################################
1265 1274
1266sub generate_random_map { 1275sub generate_random_map {
1267 my ($path, $rmp) = @_; 1276 my ($path, $rmp) = @_;
1268 1277
1269 # mit "rum" bekleckern, nicht 1278 # mit "rum" bekleckern, nicht
1270 cf::map::_create_random_map 1279 cf::map::_create_random_map (
1271 $path, 1280 $path,
1272 $rmp->{wallstyle}, $rmp->{wall_name}, $rmp->{floorstyle}, $rmp->{monsterstyle}, 1281 $rmp->{wallstyle}, $rmp->{wall_name}, $rmp->{floorstyle}, $rmp->{monsterstyle},
1273 $rmp->{treasurestyle}, $rmp->{layoutstyle}, $rmp->{doorstyle}, $rmp->{decorstyle}, 1282 $rmp->{treasurestyle}, $rmp->{layoutstyle}, $rmp->{doorstyle}, $rmp->{decorstyle},
1274 $rmp->{origin_map}, $rmp->{final_map}, $rmp->{exitstyle}, $rmp->{this_map}, 1283 $rmp->{origin_map}, $rmp->{final_map}, $rmp->{exitstyle}, $rmp->{this_map},
1275 $rmp->{exit_on_final_map}, 1284 $rmp->{exit_on_final_map},
1277 $rmp->{expand2x}, $rmp->{layoutoptions1}, $rmp->{layoutoptions2}, $rmp->{layoutoptions3}, 1286 $rmp->{expand2x}, $rmp->{layoutoptions1}, $rmp->{layoutoptions2}, $rmp->{layoutoptions3},
1278 $rmp->{symmetry}, $rmp->{difficulty}, $rmp->{difficulty_given}, $rmp->{difficulty_increase}, 1287 $rmp->{symmetry}, $rmp->{difficulty}, $rmp->{difficulty_given}, $rmp->{difficulty_increase},
1279 $rmp->{dungeon_level}, $rmp->{dungeon_depth}, $rmp->{decoroptions}, $rmp->{orientation}, 1288 $rmp->{dungeon_level}, $rmp->{dungeon_depth}, $rmp->{decoroptions}, $rmp->{orientation},
1280 $rmp->{origin_y}, $rmp->{origin_x}, $rmp->{random_seed}, $rmp->{total_map_hp}, 1289 $rmp->{origin_y}, $rmp->{origin_x}, $rmp->{random_seed}, $rmp->{total_map_hp},
1281 $rmp->{map_layout_style}, $rmp->{treasureoptions}, $rmp->{symmetry_used}, 1290 $rmp->{map_layout_style}, $rmp->{treasureoptions}, $rmp->{symmetry_used},
1282 (cf::region::find $rmp->{region}) 1291 (cf::region::find $rmp->{region}), $rmp->{custom}
1292 )
1283} 1293}
1284 1294
1285# and all this just because we cannot iterate over 1295# and all this just because we cannot iterate over
1286# all maps in C++... 1296# all maps in C++...
1287sub change_all_map_light { 1297sub change_all_map_light {
1399 1409
1400 if ($self->{path}->is_style_map) { 1410 if ($self->{path}->is_style_map) {
1401 $self->{deny_save} = 1; 1411 $self->{deny_save} = 1;
1402 $self->{deny_reset} = 1; 1412 $self->{deny_reset} = 1;
1403 } else { 1413 } else {
1414 $self->decay_objects;
1404 $self->fix_auto_apply; 1415 $self->fix_auto_apply;
1405 $self->decay_objects;
1406 $self->update_buttons; 1416 $self->update_buttons;
1407 $self->set_darkness_map; 1417 $self->set_darkness_map;
1408 $self->difficulty ($self->estimate_difficulty) 1418 $self->difficulty ($self->estimate_difficulty)
1409 unless $self->difficulty; 1419 unless $self->difficulty;
1410 $self->activate; 1420 $self->activate;
1546 my ($self) = @_; 1556 my ($self) = @_;
1547 1557
1548 $self->reset_at <= $cf::RUNTIME 1558 $self->reset_at <= $cf::RUNTIME
1549} 1559}
1550 1560
1551sub unlink_save {
1552 my ($self) = @_;
1553
1554 utf8::encode (my $save = $self->{path}->save_path);
1555 aioreq_pri 3; IO::AIO::aio_unlink $save;
1556 aioreq_pri 3; IO::AIO::aio_unlink "$save.pst";
1557}
1558
1559sub rename { 1561sub rename {
1560 my ($self, $new_path) = @_; 1562 my ($self, $new_path) = @_;
1561 1563
1562 $self->unlink_save; 1564 $self->{path}->unlink_save;
1563 1565
1564 delete $cf::MAP{$self->path}; 1566 delete $cf::MAP{$self->path};
1565 $self->{path} = new cf::path $new_path; 1567 $self->{path} = new cf::path $new_path;
1566 $self->path ($self->{path}->as_string); 1568 $self->path ($self->{path}->as_string);
1567 $cf::MAP{$self->path} = $self; 1569 $cf::MAP{$self->path} = $self;
1581 1583
1582 delete $cf::MAP{$self->path}; 1584 delete $cf::MAP{$self->path};
1583 1585
1584 $_->clear_links_to ($self) for values %cf::MAP; 1586 $_->clear_links_to ($self) for values %cf::MAP;
1585 1587
1586 $self->unlink_save; 1588 $self->{path}->unlink_save;
1587 $self->destroy; 1589 $self->destroy;
1588} 1590}
1589 1591
1590my $nuke_counter = "aaaa"; 1592my $nuke_counter = "aaaa";
1591 1593
2466 reentrant => 0, 2468 reentrant => 0,
2467 prio => 0, 2469 prio => 0,
2468 at => $NEXT_TICK || $TICK, 2470 at => $NEXT_TICK || $TICK,
2469 data => WF_AUTOCANCEL, 2471 data => WF_AUTOCANCEL,
2470 cb => sub { 2472 cb => sub {
2473 $NOW = Event::time;
2474
2471 cf::server_tick; # one server iteration 2475 cf::server_tick; # one server iteration
2472 $RUNTIME += $TICK; 2476 $RUNTIME += $TICK;
2473 $NEXT_TICK += $TICK; 2477 $NEXT_TICK += $TICK;
2474 2478
2475 $WAIT_FOR_TICK->broadcast; 2479 $WAIT_FOR_TICK->broadcast;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines