… | |
… | |
17 | $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp"); |
17 | $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp"); |
18 | } |
18 | } |
19 | |
19 | |
20 | require Win32::GUI::SplashScreen; |
20 | require Win32::GUI::SplashScreen; |
21 | |
21 | |
|
|
22 | # initialise the resolver now, as vista forces us back to the desktop |
|
|
23 | # when doing this. |
|
|
24 | use AnyEvent::DNS (); |
|
|
25 | AnyEvent::DNS::resolver; |
|
|
26 | |
22 | Win32::GUI::SplashScreen::Show ( |
27 | Win32::GUI::SplashScreen::Show ( |
23 | -file => "$ENV{PAR_TEMP}/SPLASH.bmp", |
28 | -file => "$ENV{PAR_TEMP}/SPLASH.bmp", |
24 | ); |
29 | ); |
25 | |
30 | |
26 | $startup_done = sub { |
31 | $startup_done = sub { |
… | |
… | |
49 | } |
54 | } |
50 | } |
55 | } |
51 | |
56 | |
52 | if ($^O eq "MSWin32") { |
57 | if ($^O eq "MSWin32") { |
53 | # pango is relocatable on win32 |
58 | # pango is relocatable on win32 |
54 | } elsif (-e "$root/pangoversion") { |
|
|
55 | open my $fh, "<:perlio", "$root/pangoversion" |
|
|
56 | or die "pangoversion: $!"; |
|
|
57 | my $PANGO = <$fh>; |
|
|
58 | # unix, need to patch pango rc file |
|
|
59 | open my $fh, "<:perlio", "$root/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules" |
|
|
60 | or die "$root/usr/lib/$PANGO/module-files.d/libpango1.0-0.modules: $!"; |
|
|
61 | local $/; |
|
|
62 | my $rc = <$fh>; |
|
|
63 | $rc =~ s/^\//$root\//gm; # replace abs paths by relative ones |
|
|
64 | |
|
|
65 | mkdir "$root/pango-modules"; |
|
|
66 | open my $fh, ">:perlio", "$root/pango-modules/pango.modules" |
|
|
67 | or die "$root/pango-modules/pango.modules: $!"; |
|
|
68 | print $fh $rc; |
|
|
69 | |
|
|
70 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
|
|
71 | open my $fh, ">:perlio", $ENV{PANGO_RC_FILE} |
|
|
72 | or die "$ENV{PANGO_RC_FILE}: $!"; |
|
|
73 | print $fh "[Pango]\nModuleFiles = $root/pango-modules\n"; |
|
|
74 | } else { |
59 | } else { |
75 | # OS X |
60 | # OS X |
76 | $ENV{FC_CONFIG_FILE} = "$root/fonts.conf"; # no effect??!?! |
61 | $ENV{FONTCONFIG_FILE} = "$root/fonts.conf"; # no effect??!?! |
77 | $ENV{FC_CONFIG_DIR} = $root; # no effect??!?! |
62 | $ENV{FONTCONFIG_DIR} = $root; # no effect??!?! |
78 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
63 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
79 | $ENV{DYLD_LIBRARY_PATH} = $root; |
64 | $ENV{DYLD_LIBRARY_PATH} = $root; |
80 | chdir $root; # for pango modules, maybe other things |
65 | chdir $root; # for pango modules, maybe other things |
81 | } |
66 | } |
82 | |
67 | |
… | |
… | |
106 | |
91 | |
107 | use Deliantra; |
92 | use Deliantra; |
108 | use Deliantra::Protocol::Constants; |
93 | use Deliantra::Protocol::Constants; |
109 | |
94 | |
110 | use AnyEvent::Util (); |
95 | use AnyEvent::Util (); |
111 | use AnyEvent::DNS; |
|
|
112 | use AnyEvent::Socket (); |
96 | use AnyEvent::Socket (); |
|
|
97 | use AnyEvent::DNS (); |
113 | |
98 | |
114 | use Compress::LZF; |
99 | use Compress::LZF; |
115 | use JSON::XS; |
100 | use JSON::XS; |
116 | |
101 | |
117 | use DC; |
102 | use DC; |
… | |
… | |
145 | |
130 | |
146 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
131 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
147 | $SIG{PIPE} = 'IGNORE'; |
132 | $SIG{PIPE} = 'IGNORE'; |
148 | |
133 | |
149 | $EV::DIED = sub { |
134 | $EV::DIED = sub { |
150 | crash "CRASH/EV::DIED: $@" => 1; |
135 | crash "CRASH/EV::DIED: $@" => 0; |
151 | DC::fatal Carp::longmess $@; |
136 | DC::fatal Carp::longmess $@; |
152 | }; |
137 | }; |
153 | |
138 | |
154 | my $MAX_FPS = 60; |
139 | my $MAX_FPS = 60; |
155 | |
140 | |
… | |
… | |
235 | # write a crash message blockingly to the socket, if possible |
220 | # write a crash message blockingly to the socket, if possible |
236 | # this is a bit too complicated for my tastes, but it was easy. |
221 | # this is a bit too complicated for my tastes, but it was easy. |
237 | *crash = sub($;$) { |
222 | *crash = sub($;$) { |
238 | my ($msg, $backtrace) = @_; |
223 | my ($msg, $backtrace) = @_; |
239 | |
224 | |
|
|
225 | warn $msg; |
|
|
226 | |
240 | return unless $CONN; |
227 | return unless $CONN; |
241 | |
228 | |
242 | my $fh = $CONN->{fh} |
229 | my $fh = $CONN->{fh} |
243 | or return; |
230 | or return; |
244 | |
231 | |
… | |
… | |
254 | |
241 | |
255 | # backtrace as second step, in case it crashes, too |
242 | # backtrace as second step, in case it crashes, too |
256 | crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" |
243 | crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" |
257 | if $backtrace; |
244 | if $backtrace; |
258 | }; |
245 | }; |
|
|
246 | |
|
|
247 | sub clienterror($;$) { |
|
|
248 | my ($msg, $backtrace) = @_; |
|
|
249 | |
|
|
250 | warn $msg; |
|
|
251 | |
|
|
252 | return unless $CONN; |
|
|
253 | |
|
|
254 | $CONN->send_exti_msg (clientlog => $msg); |
|
|
255 | $CONN->send_exti_msg (clientlog => Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated") if $backtrace; |
|
|
256 | } |
259 | |
257 | |
260 | ############################################################################# |
258 | ############################################################################# |
261 | |
259 | |
262 | sub status { |
260 | sub status { |
263 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
261 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
… | |
… | |
418 | my $rwops = $meta->{path} |
416 | my $rwops = $meta->{path} |
419 | ? new_from_file DC::RW $meta->{path} |
417 | ? new_from_file DC::RW $meta->{path} |
420 | : new DC::RW $$MUSIC_PLAYING_DATA; |
418 | : new DC::RW $$MUSIC_PLAYING_DATA; |
421 | |
419 | |
422 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
420 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
423 | or Carp::confess "music face $meta->{face} unloadable: " . DC::Mix_GetError; |
421 | or return clienterror "music face $meta->{face} unloadable: " . DC::Mix_GetError => 1; |
424 | |
422 | |
425 | my $NOW = time; |
423 | my $NOW = time; |
426 | |
424 | |
427 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
425 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
428 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
426 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
… | |
… | |
786 | } |
784 | } |
787 | |
785 | |
788 | sub dc_connect { |
786 | sub dc_connect { |
789 | my ($host, $port) = @_; |
787 | my ($host, $port) = @_; |
790 | |
788 | |
791 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
789 | my $mapw = List::Util::min 48, List::Util::max 11, int 1.5 + $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
|
|
790 | my $maph = List::Util::min 48, List::Util::max 11, int 1.5 + $HEIGHT * $CFG->{mapsize} * 0.01 / 32; |
792 | |
791 | |
793 | $CONN = |
792 | $CONN = |
794 | new DC::Protocol |
793 | new DC::Protocol |
795 | host => $host, |
794 | host => $host, |
796 | port => $port, |
795 | port => $port, |
797 | user => $PROFILE->{user}, |
796 | user => $PROFILE->{user}, |
798 | pass => $PROFILE->{password}, |
797 | pass => $PROFILE->{password}, |
799 | mapw => $mapsize, |
798 | mapw => $mapw, |
800 | maph => $mapsize, |
799 | maph => $maph, |
801 | |
800 | |
802 | client => "$DC::VERSION $] $^O", |
801 | client => "$DC::VERSION $] $^O", |
803 | |
802 | |
804 | map_widget => $MAPWIDGET, |
803 | map_widget => $MAPWIDGET, |
805 | statusbox => $STATUSBOX, |
804 | statusbox => $STATUSBOX, |
… | |
… | |
953 | ); |
952 | ); |
954 | |
953 | |
955 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Forbid Alpha"); |
954 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Forbid Alpha"); |
956 | $table->add_at (1, $row++, new DC::UI::CheckBox |
955 | $table->add_at (1, $row++, new DC::UI::CheckBox |
957 | state => $CFG->{disable_alpha}, |
956 | state => $CFG->{disable_alpha}, |
958 | tooltip => "Forbid off the use of the alpha channel. This makes Deliantra look a lot worse " |
957 | tooltip => "Forbid the use of the alpha channel. This makes Deliantra look a lot worse " |
959 | . "by disabling a number of textures and transparency effects. Normally, these " |
958 | . "by disabling a number of textures and transparency effects. Normally, these " |
960 | . "effects do not cost a lot of resources, but some graphics cards might fall " |
959 | . "effects do not cost a lot of resources, but some graphics cards might fall " |
961 | . "back to extremely slow rendering if this is enabled. If disabling this option " |
960 | . "back to extremely slow rendering if this is enabled. If disabling this option " |
962 | . "noticably improves the framerate of the client please report this! " |
961 | . "noticably improves the framerate of the client please report this! " |
963 | . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>", |
962 | . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>", |
… | |
… | |
2605 | $SIG{INT} = $SIG{TERM} = sub { |
2604 | $SIG{INT} = $SIG{TERM} = sub { |
2606 | EV::unloop; |
2605 | EV::unloop; |
2607 | #d# TODO calling exit here hangs the process in some futex |
2606 | #d# TODO calling exit here hangs the process in some futex |
2608 | }; |
2607 | }; |
2609 | |
2608 | |
2610 | # due to mac os x + sdl combined briandamage, we need this contortion |
2609 | # due to mac os x + sdl combined braindamage, we need this contortion |
2611 | sub main { |
2610 | sub main { |
2612 | { |
2611 | { |
2613 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2612 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2614 | |
2613 | |
2615 | if (-e "$Deliantra::VARDIR/client.cf") { |
2614 | if (-e "$Deliantra::VARDIR/client.cf") { |