--- deliantra/Deliantra-Client/bin/deliantra 2010/03/20 01:01:16 1.103
+++ deliantra/Deliantra-Client/bin/deliantra 2011/12/26 03:58:12 1.118
@@ -7,6 +7,7 @@
use Coro::Debug;
our $debug = new_unix_server Coro::Debug "/tmp/dc";
';
+ die if $@;
}
# do splash-screen thingy on win32
@@ -19,23 +20,22 @@
require Win32::GUI::SplashScreen;
- # initialise the resolver now, as vista forces us back to the desktop
- # when doing this.
- use AnyEvent::DNS ();
- AnyEvent::DNS::resolver;
-
Win32::GUI::SplashScreen::Show (
-file => "$ENV{PAR_TEMP}/SPLASH.bmp",
);
+ # initialise the resolver now, as vista forces us back to the desktop
+ # when doing this later.
+ require AnyEvent::DNS;
+ AnyEvent::DNS::resolver ();
+
$startup_done = sub {
Win32::GUI::SplashScreen::Done (1);
};
}
}
-use strict;
-use utf8;
+use common::sense;
use Carp 'verbose';
@@ -146,6 +146,7 @@
our $CFG;
our $PROFILE; # current profile
our $FAST; # fast, low-quality mode, possibly useful for software-rendering
+our $DELIANTRA_DEBUG = $ENV{DELIANTRA_DEBUG} * 1;
our $WANT_REFRESH;
@@ -520,6 +521,15 @@
sub audio_init {
if ($CFG->{audio_enable}) {
+ if (length $CFG->{audio_driver}) {
+ local $ENV{SDL_AUDIODRIVER} = $CFG->{audio_driver};
+ DC::SDL_Init DC::SDL_INIT_AUDIO
+ and die "SDL::Init failed!\n";
+ } else {
+ DC::SDL_Init DC::SDL_INIT_AUDIO
+ and die "SDL::Init failed!\n";
+ }
+
$ENV{MIX_EFFECTSMAXSPEED} = 1;
$SDL_MIXER = !DC::Mix_OpenAudio
$CFG->{audio_hw_frequency},
@@ -559,6 +569,8 @@
DC::Mix_CloseAudio if $SDL_MIXER;
undef $SDL_MIXER;
+
+ DC::SDL_QuitSubSystem DC::SDL_INIT_AUDIO;
}
#############################################################################
@@ -809,7 +821,12 @@
mapw => $mapw,
maph => $maph,
- client => "$DC::VERSION $] $^O",
+ c_version => {
+ client => "deliantra",
+ clientver => $DC::VERSION,
+ gl_vendor => DC::OpenGL::gl_vendor,
+ gl_version => DC::OpenGL::gl_version,
+ },
map_widget => $MAPWIDGET,
statusbox => $STATUSBOX,
@@ -851,12 +868,12 @@
# can be removed once AnyEvent::DNS is proven stable.
if ($host eq "gameserver.deliantra.net") {
AnyEvent::DNS::a "dnstest.deliantra.net", sub {
- if ($_[0] ne "80.101.114.108") { # Perl
+ if ($_[0] ne "80.101.114.108") { # P-e-r-l
status "dns failure, trying differently";
$host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" };
unless (defined $host) {
status "dns failure, using hardcoded address";
- $host = "129.13.162.95";
+ $host = "194.126.175.154";
}
}
@@ -1142,10 +1159,11 @@
my $text = !$freq
? "audio is off"
: "audio is enabled\n"
- . "frequency (Hz): $freq\n"
- . "channels: $chans\n"
- . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n"
- . "music decoders available: " . (join ", ", DC::MixMusic::decoders);
+ . "driver: " . DC::SDL_AudioDriverName . "\n"
+ . "frequency (Hz): $freq\n"
+ . "channels: $chans\n"
+ . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n"
+ . "music decoders available: " . (join ", ", DC::MixMusic::decoders);
$AUDIO_INFO->set_text ($text);
}
@@ -1158,11 +1176,24 @@
my $row = 0;
$table->add_at (0, $row, new DC::UI::Label align => 1, text => "Audio Enable");
- $table->add_at (1, $row++, new DC::UI::CheckBox
+ $table->add_at (1, $row, new DC::UI::CheckBox
state => $CFG->{audio_enable},
tooltip => "Master Audio Enable. If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.",
on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 }
);
+ $table->add_at (2, $row++, my $driver = new DC::UI::HBox expand => 1);
+
+ $driver->add (new DC::UI::Label align => 1, text => " Audio driver override");
+ $driver->add (new DC::UI::Entry
+ text => $CFG->{audio_driver},
+ template => "dsound1234",
+ tooltip => "You can override the audio driver to use here. Leaving it empty will result "
+ . "in Deliantra picking one automatically. GNU/Linux users often prefer specific "
+ . "drivers though, and can experiment with alsa, dsp, esd, pulse, arts, nas "
+ . "or other system-specific drivers. Selecting the wrong driver here will simply result"
+ . "in no sound.",
+ on_changed => sub { my ($self, $value) = @_; $CFG->{audio_driver} = $value; 1 }
+ );
$table->add_at (0, $row, new DC::UI::Label align => 1, text => "Sound Effects");
$table->add_at (1, $row, new DC::UI::CheckBox
@@ -1184,7 +1215,7 @@
$table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music");
$table->add_at (1, $row, new DC::UI::CheckBox
expand => 1, state => $CFG->{bgm_enable},
- tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.",
+ tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played. Needs server reconnect to take effect.",
on_changed => sub {
$CFG->{bgm_enable} = $_[1];
$CONN->update_fx_want if $CONN;
@@ -1205,9 +1236,9 @@
options => [
[ 0, "default" , "Use System Default"],
[11025, "11 kHz" , "11kHz (low quality)"],
- [22050, "22 kHz" , "22kHz (reduced quality)"],
+ [22050, "22 kHz" , "22kHz (reduced quality, recommended)"],
[44100, "44.1 kHz", "44.1kHz (cd quality)"],
- [48000, "48 kHz" , "48kHz (studio quality)"],
+ [48000, "48 kHz" , "48kHz (studio quality, not recommended)"],
],
tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.",
on_changed => sub {
@@ -1241,7 +1272,7 @@
c_colspan => 2, expand => 1,
value => $CFG->{audio_hw_chunksize},
tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback "
- . "is stuttering, increase this value. Values of 50-100ms are optimal.",
+ . "is stuttering, increase this value. Values of 50-150ms are optimal.",
on_changed => sub {
$CFG->{audio_hw_chunksize} = $_[1];
audio_tab_update;
@@ -1331,20 +1362,39 @@
$win
}
+our $BW_WATCHER;
+
+sub debug_toggle($) {
+ $DELIANTRA_DEBUG ^= $_[0];
+
+ if ($DELIANTRA_DEBUG & 16) {
+ $BW_WATCHER = EV::periodic 0, 1, 0, sub {
+ return unless $CONN;
+ debug sprintf "%8.2gKB/s", $CONN->{octets_in} / 1e3;
+ $CONN->{octets_in} = 0;
+ };
+ } else {
+ undef $BW_WATCHER;
+ }
+
+}
+
sub debug_setup {
my $table = new DC::UI::Table;
$table->add_at (0, 0, new DC::UI::Label text => "Widget Borders");
- $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 });
+ $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { debug_toggle 1; 0 });
$table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info");
- $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 });
+ $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { debug_toggle 2; 0 });
$table->add_at (0, 2, new DC::UI::Label text => "Show FPS");
- $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 });
+ $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { debug_toggle 4; 0 });
$table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips");
- $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 });
- $table->add_at (0, 4, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } );
+ $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { debug_toggle 8; 0 });
+ $table->add_at (0, 4, new DC::UI::Label text => "Show Bandwidth");
+ $table->add_at (1, 4, new DC::UI::CheckBox on_changed => sub { debug_toggle 16; 0 });
- $table->add_at (0, 5, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d#
+ $table->add_at (0, 6, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } );
+ $table->add_at (0, 7, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d#
$table->add_at (7,7, my $t = new DC::UI::Table expand => 0);
$t->add_at (0,0, new DC::UI::Label text => "a a", c_rowspan => 1, c_colspan => 2);
@@ -1475,7 +1525,7 @@
deat => ["Death",
"Death (resistance against death spells)"],
phys => ["Physical",
- "Physical (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed in the 'Arm' field on the left.)"],
+ "Physical (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed as the 'Arm' secondary stat.)"],
blind => ["Blind",
"Blind (blind resistance affects the chance of a successful blinding attack)"],
fear => ["Fear",
@@ -1944,23 +1994,28 @@
my %SORT_ORDER = (
type => sub {
+ use sort 'stable';
sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_
},
mtime => sub {
- my $NOW = time;
- sort {
- my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6;
- my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6;
-
- ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED)
- or $btime <=> $atime
- or $a->{type} <=> $b->{type}
- } @_
- },
- weight => sub { sort {
- $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1)
- or $a->{type} <=> $b->{type}
- } @_ },
+ use sort 'stable';
+ my $NOW = time;
+ sort {
+ my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6;
+ my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6;
+
+ ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED)
+ or $btime <=> $atime
+ or $a->{type} <=> $b->{type}
+ } @_
+ },
+ weight => sub {
+ use sort 'stable';
+ sort {
+ $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1)
+ or $a->{type} <=> $b->{type}
+ } @_
+ },
);
sub inventory_widget {
@@ -2411,11 +2466,6 @@
};
}
-sub sdl_init {
- DC::SDL_Init DC::SDL_INIT_AUDIO #| DC::SDL_NOPARACHUTE
- and die "SDL::Init failed!\n";
-}
-
sub video_init {
DC::set_theme $CFG->{uitheme};
@@ -2484,7 +2534,7 @@
padding => 0,
z => 100,
force_x => "max",
- force_y => 0;
+ force_y => 20;
$DEBUG_STATUS->show;
$STATUSBOX = new DC::UI::Statusbox;
@@ -2622,7 +2672,7 @@
my $fps = 9;
sub force_refresh {
- if ($ENV{CFPLUS_DEBUG} & 4) {
+ if ($DELIANTRA_DEBUG & 4) {
$fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02;
debug sprintf "%3.2f", $fps;
}
@@ -2785,13 +2835,21 @@
my @args = @ARGV;
+ # OS X passes some process serial number of other shit. they
+ # could have used an env var or any other sane mechanism. but
+ # would it be os x then? no...
+ shift @args if $args[0] =~ /^-psn_/;
+
my $profile = 'default';
for (my $i = 0; $i < @args; $i++) {
- if ($args[$i] eq '-profile') {
+ if ($args[$i] =~ /^--?profile$/) {
$profile = $args[$i + 1];
splice @args, $i, 2, ();
$i = 0;
+ } elsif ($args[$i] =~ /^--?h/) {
+ print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n";
+ exit 0;
}
}
@@ -2815,8 +2873,6 @@
}
}
- sdl_init;
-
$ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf";
$ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts";
@@ -2856,6 +2912,7 @@
# warn $t2-$t1;
# }
+ DC::IMG_Init;
video_init;
audio_init;
}
@@ -2867,6 +2924,8 @@
$startup_done->();
};
+ debug_toggle 0;
+
delete $SIG{__DIE__};
EV::loop;
@@ -2888,22 +2947,23 @@
=head1 SYNOPSIS
-Just run it - no commandline arguments are supported.
+ deliantra [--profile name] [host [user [password]]]
+ deliantra --help
=head1 USAGE
-deliantra utilises OpenGL for all UI elements and the game. It is supposed to
-be used in fullscreen mode and interactively.
+The deliantra client utilises OpenGL for all UI elements and the game. It
+is supposed to be used in fullscreen mode and interactively.
=head1 DEBUGGING
-
-CFPLUS_DEBUG - environment variable
+DELIANTRA_DEBUG - environment variable
1 draw borders around widgets
2 add low-level widget info to tooltips
4 show fps
8 suppress tooltips
+ 16 show bandwidth downstream
=head1 AUTHOR