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.466 by root, Thu Jan 8 03:03:24 2009 UTC vs.
Revision 1.473 by root, Fri Jun 26 16:32:10 2009 UTC

105our %RESOURCE; 105our %RESOURCE;
106 106
107our $TICK = MAX_TIME * 1e-6; # this is a CONSTANT(!) 107our $TICK = MAX_TIME * 1e-6; # this is a CONSTANT(!)
108our $NEXT_RUNTIME_WRITE; # when should the runtime file be written 108our $NEXT_RUNTIME_WRITE; # when should the runtime file be written
109our $NEXT_TICK; 109our $NEXT_TICK;
110our $USE_FSYNC = 1; # use fsync to write maps - default off 110our $USE_FSYNC = 1; # use fsync to write maps - default on
111 111
112our $BDB_DEADLOCK_WATCHER; 112our $BDB_DEADLOCK_WATCHER;
113our $BDB_CHECKPOINT_WATCHER; 113our $BDB_CHECKPOINT_WATCHER;
114our $BDB_TRICKLE_WATCHER; 114our $BDB_TRICKLE_WATCHER;
115our $DB_ENV; 115our $DB_ENV;
145unless ($RUNTIME || !-e $RUNTIMEFILE) { 145unless ($RUNTIME || !-e $RUNTIMEFILE) {
146 open my $fh, "<", $RUNTIMEFILE 146 open my $fh, "<", $RUNTIMEFILE
147 or die "unable to read $RUNTIMEFILE file: $!"; 147 or die "unable to read $RUNTIMEFILE file: $!";
148 $RUNTIME = <$fh> + 0.; 148 $RUNTIME = <$fh> + 0.;
149} 149}
150
151eval "sub TICK() { $TICK } 1" or die;
150 152
151mkdir $_ 153mkdir $_
152 for $LOCALDIR, $TMPDIR, $UNIQUEDIR, $PLAYERDIR, $RANDOMDIR, $BDBDIR; 154 for $LOCALDIR, $TMPDIR, $UNIQUEDIR, $PLAYERDIR, $RANDOMDIR, $BDBDIR;
153 155
154our $EMERGENCY_POSITION; 156our $EMERGENCY_POSITION;
1149 $decname, length $$rdata, scalar @$objs; 1151 $decname, length $$rdata, scalar @$objs;
1150 1152
1151 if (my $fh = aio_open "$filename~", O_WRONLY | O_CREAT, 0600) { 1153 if (my $fh = aio_open "$filename~", O_WRONLY | O_CREAT, 0600) {
1152 aio_chmod $fh, SAVE_MODE; 1154 aio_chmod $fh, SAVE_MODE;
1153 aio_write $fh, 0, (length $$rdata), $$rdata, 0; 1155 aio_write $fh, 0, (length $$rdata), $$rdata, 0;
1154 aio_fsync $fh if $cf::USE_FSYNC; 1156 if ($cf::USE_FSYNC) {
1157 aio_sync_file_range $fh, 0, 0, IO::AIO::SYNC_FILE_RANGE_WAIT_BEFORE | IO::AIO::SYNC_FILE_RANGE_WRITE | IO::AIO::SYNC_FILE_RANGE_WAIT_AFTER;
1158 aio_fsync $fh;
1159 }
1155 aio_close $fh; 1160 aio_close $fh;
1156 1161
1157 if (@$objs) { 1162 if (@$objs) {
1158 if (my $fh = aio_open "$filename.pst~", O_WRONLY | O_CREAT, 0600) { 1163 if (my $fh = aio_open "$filename.pst~", O_WRONLY | O_CREAT, 0600) {
1159 aio_chmod $fh, SAVE_MODE; 1164 aio_chmod $fh, SAVE_MODE;
1160 my $data = Coro::Storable::nfreeze { version => 1, objs => $objs }; 1165 my $data = Coro::Storable::nfreeze { version => 1, objs => $objs };
1161 aio_write $fh, 0, (length $data), $data, 0; 1166 aio_write $fh, 0, (length $data), $data, 0;
1162 aio_fsync $fh if $cf::USE_FSYNC; 1167 if ($cf::USE_FSYNC) {
1168 aio_sync_file_range $fh, 0, 0, IO::AIO::SYNC_FILE_RANGE_WAIT_BEFORE | IO::AIO::SYNC_FILE_RANGE_WRITE | IO::AIO::SYNC_FILE_RANGE_WAIT_AFTER;
1169 aio_fsync $fh;
1170 }
1163 aio_close $fh; 1171 aio_close $fh;
1164 aio_rename "$filename.pst~", "$filename.pst"; 1172 aio_rename "$filename.pst~", "$filename.pst";
1165 } 1173 }
1166 } else { 1174 } else {
1167 aio_unlink "$filename.pst"; 1175 aio_unlink "$filename.pst";
1318 1326
1319# "readahead" all extensions 1327# "readahead" all extensions
1320sub cache_extensions { 1328sub cache_extensions {
1321 my $grp = IO::AIO::aio_group; 1329 my $grp = IO::AIO::aio_group;
1322 1330
1323 add $grp IO::AIO::aio_readdir $LIBDIR, sub { 1331 add $grp IO::AIO::aio_readdirx $LIBDIR, IO::AIO::READDIR_STAT_ORDER, sub {
1324 for (grep /\.ext$/, @{$_[0]}) { 1332 for (grep /\.ext$/, @{$_[0]}) {
1325 add $grp IO::AIO::aio_load "$LIBDIR/$_", my $data; 1333 add $grp IO::AIO::aio_load "$LIBDIR/$_", my $data;
1326 } 1334 }
1327 }; 1335 };
1328 1336
2386 2394
2387our $SAY_CHANNEL = { 2395our $SAY_CHANNEL = {
2388 id => "say", 2396 id => "say",
2389 title => "Map", 2397 title => "Map",
2390 reply => "say ", 2398 reply => "say ",
2391 tooltip => "Things said to and replied from npcs near you and other players on the same map only.", 2399 tooltip => "Things said to and replied from NPCs near you and other players on the same map only.",
2392}; 2400};
2393 2401
2394our $CHAT_CHANNEL = { 2402our $CHAT_CHANNEL = {
2395 id => "chat", 2403 id => "chat",
2396 title => "Chat", 2404 title => "Chat",
2783 id => "infobox", 2791 id => "infobox",
2784 title => "Skills", 2792 title => "Skills",
2785 reply => undef, 2793 reply => undef,
2786 tooltip => "Shows your experience per skill and item power", 2794 tooltip => "Shows your experience per skill and item power",
2787 }, 2795 },
2796 "c/shopitems" => {
2797 id => "infobox",
2798 title => "Shop Items",
2799 reply => undef,
2800 tooltip => "Shows the items currently for sale in this shop",
2801 },
2788 "c/resistances" => { 2802 "c/resistances" => {
2789 id => "infobox", 2803 id => "infobox",
2790 title => "Resistances", 2804 title => "Resistances",
2791 reply => undef, 2805 reply => undef,
2792 tooltip => "Shows your resistances", 2806 tooltip => "Shows your resistances",
2794 "c/pets" => { 2808 "c/pets" => {
2795 id => "infobox", 2809 id => "infobox",
2796 title => "Pets", 2810 title => "Pets",
2797 reply => undef, 2811 reply => undef,
2798 tooltip => "Shows information abotu your pets/a specific pet", 2812 tooltip => "Shows information abotu your pets/a specific pet",
2813 },
2814 "c/perceiveself" => {
2815 id => "infobox",
2816 title => "Perceive Self",
2817 reply => undef,
2818 tooltip => "You gained detailed knowledge about yourself",
2799 }, 2819 },
2800 "c/uptime" => { 2820 "c/uptime" => {
2801 id => "infobox", 2821 id => "infobox",
2802 title => "Uptime", 2822 title => "Uptime",
2803 reply => undef, 2823 reply => undef,
3925 LOG llevInfo, "[ABT] [suppressed]\n"; 3945 LOG llevInfo, "[ABT] [suppressed]\n";
3926 } 3946 }
3927} 3947}
3928 3948
3929# load additional modules 3949# load additional modules
3930eval "use cf::$_" for @EXTRA_MODULES; 3950require "cf/$_.pm" for @EXTRA_MODULES;
3931 3951
3932END { cf::emergency_save } 3952END { cf::emergency_save }
3933 3953
39341 39541
3935 3955

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines