ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Main.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Main.pm (file contents):
Revision 1.6 by root, Sat Dec 31 04:23:42 2011 UTC vs.
Revision 1.31 by root, Mon Nov 19 00:56:08 2018 UTC

18} 18}
19 19
20use common::sense; 20use common::sense;
21use Carp 'verbose'; 21use Carp 'verbose';
22use Cwd (); 22use Cwd ();
23use Digest::MD5 ();
23use EV; 24use EV;
24BEGIN { *time = \&EV::time } 25BEGIN { *time = \&EV::time }
25 26
26use List::Util qw(max min); 27use List::Util qw(max min);
27 28
28use Deliantra; 29use Deliantra;
30use Deliantra::Util;
29use Deliantra::Protocol::Constants; 31use Deliantra::Protocol::Constants;
30 32
31use AnyEvent::Util (); 33use AnyEvent::Util ();
32use AnyEvent::Socket (); 34use AnyEvent::Socket ();
33use AnyEvent::DNS (); 35use AnyEvent::DNS ();
34 36
35use Compress::LZF; 37use Compress::LZF;
36use JSON::XS; 38use JSON::XS;
39use Urlader;
37 40
38use DC; 41use DC;
39 42
40sub crash($;$) { 43sub crash($;$) {
41 # nop at compiletime 44 # nop at compiletime
43 46
44BEGIN { 47BEGIN {
45 $SIG{__DIE__} = sub { 48 $SIG{__DIE__} = sub {
46 return if $^S; # quick reject 49 return if $^S; # quick reject
47 50
48 # return if there are any eval contexts in the csall stack 51 # return if there are any eval contexts in the call stack
49 for my $i (0..999) { 52 for my $i (0..999) {
50 my ($sub, $is_require) = (caller $i)[3, 7] 53 my ($sub, $is_require) = (caller $i)[3, 7]
51 or last; 54 or last;
52 return if $sub eq "(eval)" && !$is_require; 55 return if $sub eq "(eval)" && !$is_require;
53 } 56 }
56 DC::fatal Carp::longmess "$_[0]"; 59 DC::fatal Carp::longmess "$_[0]";
57 } 60 }
58} 61}
59 62
60use DC::OpenGL (); 63use DC::OpenGL ();
64use DC::Audio ();
61use DC::Protocol; 65use DC::Protocol;
62use DC::DB; 66use DC::DB;
63use DC::UI; 67use DC::UI;
64use DC::UI::Canvas; 68use DC::UI::Canvas;
65use DC::UI::Inventory; 69use DC::UI::Inventory;
70use DC::MessageDistributor; 74use DC::MessageDistributor;
71use DC::Pod; 75use DC::Pod;
72use DC::MapWidget; 76use DC::MapWidget;
73use DC::Macro; 77use DC::Macro;
74 78
79# printf "%5d %5d %5d %5d\n", $_, DC::minpot $_, DC::ld32 $_, 2 << ((DC::ld32 $_ - 1));
80
75$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 81$SIG{QUIT} = sub { Carp::cluck "QUIT" };
76$SIG{PIPE} = 'IGNORE'; 82$SIG{PIPE} = 'IGNORE';
77 83
78$EV::DIED = sub { 84$EV::DIED = sub {
79 crash "CRASH/EV::DIED: $@" => 0; 85 crash "CRASH/EV::DIED: $@" => 0;
125our $MENUBAR; # the hbox at the top 131our $MENUBAR; # the hbox at the top
126our $MENUPOPUP; 132our $MENUPOPUP;
127our $BUTTONBAR; # the menu buttons 133our $BUTTONBAR; # the menu buttons
128our $METASERVER; 134our $METASERVER;
129our $LOGIN_BUTTON; 135our $LOGIN_BUTTON;
136our $LOGIN_ERROR;
130our $QUIT_DIALOG; 137our $QUIT_DIALOG;
131our $HOST_ENTRY; 138our $HOST_ENTRY;
132our $FULLSCREEN_ENABLE; 139our $FULLSCREEN_ENABLE;
133our $PICKUP_ENABLE; 140our $PICKUP_ENABLE;
134our $SERVER_INFO; 141our $SERVER_INFO;
195 AnyEvent::Util::fh_nonblocking $fh, 1; 202 AnyEvent::Util::fh_nonblocking $fh, 1;
196 203
197 $msg =~ s/\s+$//; 204 $msg =~ s/\s+$//;
198 205
199 # backtrace as second step, in case it crashes, too 206 # backtrace as second step, in case it crashes, too
200 crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" 207 crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION$Urlader::EXE_VER, generated"
201 if $backtrace; 208 if $backtrace;
202}; 209};
203 210
204sub clienterror($;$) { 211sub clienterror($;$) {
205 my ($msg, $backtrace) = @_; 212 my ($msg, $backtrace) = @_;
207 warn $msg; 214 warn $msg;
208 215
209 return unless $CONN; 216 return unless $CONN;
210 217
211 $CONN->send_exti_msg (clientlog => $msg); 218 $CONN->send_exti_msg (clientlog => $msg);
212 $CONN->send_exti_msg (clientlog => Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated") if $backtrace; 219 $CONN->send_exti_msg (clientlog => Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION$Urlader::EXE_VER, generated") if $backtrace;
213} 220}
214 221
215############################################################################# 222#############################################################################
216 223
217sub status { 224sub status {
248 : "[<span foreground='#888'>num</span>]"; 255 : "[<span foreground='#888'>num</span>]";
249 256
250 # <tt> around next statement works around some bug that keeps the 257 # <tt> around next statement works around some bug that keeps the
251 # "font =>" from being used on windows 258 # "font =>" from being used on windows
252 $MODBOX->set_markup ("<tt>$markup</tt>"); 259 $MODBOX->set_markup ("<tt>$markup</tt>");
260}
261
262sub errorbox {
263 my ($msg) = @_;
264
265 status $msg;
266
267 my $dialog = new DC::UI::Toplevel
268 x => "center",
269 y => "center",
270 z => 200,
271 title => "Error",
272 child => my $vbox = new DC::UI::VBox,
273 has_close_button => 1,
274 on_delete => sub {
275 $_[0]->destroy;
276 },
277 ;
278
279 add $vbox new DC::UI::Label
280 align => 0.5,
281 ellipsise => 0,
282 text => $msg;
283
284 add $vbox new DC::UI::Button
285 expand => 1,
286 text => "OK",
287 on_activate => sub {
288 $dialog->destroy;
289 0
290 }
291 ;
292
293 $dialog->show;
253} 294}
254 295
255############################################################################# 296#############################################################################
256#TODO: maybe move into own audio module... 297#TODO: maybe move into own audio module...
257 298
472 audio_music_push; 513 audio_music_push;
473} 514}
474 515
475sub audio_init { 516sub audio_init {
476 if ($CFG->{audio_enable}) { 517 if ($CFG->{audio_enable}) {
477 if (length $CFG->{audio_driver}) { 518 DC::Audio::init;
478 local $ENV{SDL_AUDIODRIVER} = $CFG->{audio_driver};
479 DC::SDL_Init DC::SDL_INIT_AUDIO
480 and die "SDL::Init failed!\n";
481 } else {
482 DC::SDL_Init DC::SDL_INIT_AUDIO
483 and die "SDL::Init failed!\n";
484 }
485
486 $ENV{MIX_EFFECTSMAXSPEED} = 1;
487 $SDL_MIXER = !DC::Mix_OpenAudio
488 $CFG->{audio_hw_frequency},
489 DC::MIX_DEFAULT_FORMAT,
490 $CFG->{audio_hw_channels},
491 $CFG->{audio_hw_chunksize};
492 519
493 if ($SDL_MIXER) { 520 if ($SDL_MIXER) {
494 DC::Mix_AllocateChannels $CFG->{audio_mix_channels};
495
496 audio_music_finished; 521 audio_music_finished;
497 } else { 522 } else {
498 status "Unable to open sound device: there will be no sound"; 523 status "Unable to open sound device: there will be no sound";
499 } 524 }
500 } else { 525 } else {
522 547
523 DC::Mix_CloseAudio if $SDL_MIXER; 548 DC::Mix_CloseAudio if $SDL_MIXER;
524 undef $SDL_MIXER; 549 undef $SDL_MIXER;
525 550
526 DC::SDL_QuitSubSystem DC::SDL_INIT_AUDIO; 551 DC::SDL_QuitSubSystem DC::SDL_INIT_AUDIO;
552}
553
554#############################################################################
555# Over-the-air updates
556
557sub ota_update {
558 my ($face, $size, $md5) = @_;
559
560 my $coro = Coro::async_pool {
561 my $override = "$Urlader::EXE_DIR/override";
562
563 $MESSAGE_DIST->add_channel ({
564 id => "ota_update",
565 title => "Update",
566 tooltip => "<b>Software Update Log</b>",
567 });
568
569 $MESSAGE_DIST->message ({ type => "ota_update", markup => "preparing override..." });
570
571 my $fh = Coro::AIO::aio_open "$override.tmp", IO::AIO::O_WRONLY | IO::AIO::O_CREAT | IO::AIO::O_TRUNC, 0777;
572
573 unless ($fh) {
574 $MESSAGE_DIST->message ({ type => "ota_update", markup => (DC::asxml "unable to write software update:\n$Urlader::EXE_DIR/override.tmp:\n$!") });
575 return;
576 }
577
578 $MESSAGE_DIST->message ({ type => "ota_update", markup => "downloading $size bytes..." });
579
580 my $cv = AE::cv;
581 my $error;
582
583 $cv->begin (Coro::rouse_cb);
584 $CONN->ask_face (
585 $face,
586 -1000,
587 sub {
588 $STATUSBOX->add (
589 (sprintf "update download: %d/%d", $size - $_[1], $size),
590 pri => -9, group => "ota_update", timeout => 60, fg => [1, 1, 0, 1]
591 );
592
593 $cv->begin;
594 my $len = length $_[2];
595 IO::AIO::aio_write $fh, $_[1], $len, $_[2], undef, sub {
596 $error ||= $_[0] != $len;
597 $cv->end;
598 };
599 },
600 sub {
601 $cv->end;
602 },
603 );
604
605 Coro::rouse_wait;
606
607 $STATUSBOX->clr_group ("ota_update");
608
609 $error ||= Coro::AIO::aio_fsync $fh;
610 $error ||= Coro::AIO::aio_close $fh;
611
612 if ($error) {
613 $MESSAGE_DIST->message ({ type => "ota_update", markup => "file write error, update aborted." });
614 Coro::AIO::aio_unlink "$override.tmp";
615 return;
616 }
617
618 {
619 $MESSAGE_DIST->message ({ type => "ota_update", markup => "verifying update file..." });
620
621 my $fh = Coro::AIO::aio_open "$override.tmp", IO::AIO::O_RDONLY, 0;
622
623 if ($fh) {
624 $error ||= Coro::AIO::aio_stat "$override.tmp";
625 $error ||= -s _ != $size;
626 Coro::AIO::aio_readahead $fh, 0, $size;
627
628 my $f_md5 = new Digest::MD5;
629 binmode $fh; # ugh :(
630 $f_md5->addfile ($fh);
631 $f_md5 = $f_md5->hexdigest;
632 $error ||= $md5 ne $f_md5;
633 }
634 }
635
636 if ($error) {
637 $MESSAGE_DIST->message ({ type => "ota_update", markup => "verification failed, update aborted." });
638 Coro::AIO::aio_unlink "$override.tmp";
639 return;
640 }
641
642 $MESSAGE_DIST->message ({ type => "ota_update", markup => "replacing override file..." });
643
644 if (Coro::AIO::aio_rename "$override.tmp", $override) {
645 $MESSAGE_DIST->message ({ type => "ota_update", markup => "unable to replace override file, update aborted." });
646 Coro::AIO::aio_unlink "$override.tmp";
647 }
648
649 $MESSAGE_DIST->message ({ type => "ota_update", markup => "success - update becomes active after restarting." });
650 };
651
652 $CONN->{ota_update} = Guard::guard {
653 $coro->cancel;
654 };
655}
656
657sub ota_update_ask {
658 my ($ok, $face, $ver, $size, $md5, $changes) = @_;
659
660 $CONN->{w}{ota_dialog} = my $dialog = new DC::UI::Toplevel
661 x => "center",
662 y => "center",
663 z => 55,
664 force_w => $::WIDTH * 0.7,
665 force_h => $::HEIGHT * 0.7,
666 title => "Software update available",
667 child => my $vbox = new DC::UI::VBox,
668 ;
669
670 $vbox->add (new DC::UI::Label
671 ellipsise => 0,
672 text => "The server offers a software update, "
673 . "do you want to start downloading this update in the background?",
674 );
675
676 $vbox->add (new DC::UI::FancyFrame
677 expand => 1,
678 label => "Details",
679 child => (new DC::UI::TextScroller
680 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4,
681 par => [{
682 markup => "<tt>Old revision: $Urlader::EXE_VER\n"
683 . "New revision: $ver\n"
684 . "Download size: $size bytes</tt>\n\n"
685 . "Changes:\n\n"
686 . DC::asxml $changes
687 }],
688 ),
689 );
690
691 $vbox->add (my $hbox = new DC::UI::HBox);
692
693 $hbox->add (new DC::UI::Button
694 expand => 1,
695 text => "Not now",
696 on_activate => sub {
697 $dialog->destroy;
698 0
699 }
700 );
701 $hbox->add (new DC::UI::Button
702 expand => 1,
703 text => "Yes, start downloading",
704 on_activate => sub {
705 $dialog->destroy;
706 ota_update $face, $size, $md5;
707 0
708 },
709 );
710
711 $dialog->show;
712}
713
714sub ota_update_check {
715 return unless defined $Urlader::EXE_ID;
716
717 ::message { markup => "Checking for software update..." };
718
719 $CONN->send_exti_req (ota_update => $Urlader::URLADER_VERSION, $Urlader::EXE_ID, $Urlader::EXE_VER, sub {
720 my ($ok, $face, $ver, $size, $md5, $changes) = @_;
721
722 if ($ok) {
723 if (defined $ver) {
724 ::message { markup => "Server offers version $ver (we are version $Urlader::EXE_VER)." };
725 &ota_update_ask;
726 } else {
727 ::message { markup => "Server has no newer version." };
728 }
729 } else {
730 ::message { markup => "Server does not support software update." };
731 }
732
733 ()
734 });
527} 735}
528 736
529############################################################################# 737#############################################################################
530 738
531sub destroy_query_dialog { 739sub destroy_query_dialog {
758 $vbox->add (@dialog); 966 $vbox->add (@dialog);
759 $dialog->show; 967 $dialog->show;
760} 968}
761 969
762sub dc_connect { 970sub dc_connect {
763 my ($host, $port) = @_; 971 my ($host, $port, $create) = @_;
764 972
765 my $mapw = List::Util::min 48, List::Util::max 11, int 1.5 + $WIDTH * $CFG->{mapsize} * 0.01 / 32; 973 my $mapw = List::Util::min 48, List::Util::max 11, int 1.5 + $WIDTH * $CFG->{mapsize} * 0.01 / 32;
766 my $maph = List::Util::min 48, List::Util::max 11, int 1.5 + $HEIGHT * $CFG->{mapsize} * 0.01 / 32; 974 my $maph = List::Util::min 48, List::Util::max 11, int 1.5 + $HEIGHT * $CFG->{mapsize} * 0.01 / 32;
767 975
768 $CONN = 976 $CONN =
769 new DC::Protocol 977 new DC::Protocol
770 host => $host, 978 host => $host,
771 port => $port, 979 port => $port,
980 create_login => $create,
772 user => $PROFILE->{user}, 981 user => $PROFILE->{user},
773 pass => $PROFILE->{password}, 982 pass => (pack "H*", $PROFILE->{password}),
774 mapw => $mapw, 983 mapw => $mapw,
775 maph => $maph, 984 maph => $maph,
776 985
777 c_version => { 986 c_version => {
778 client => "deliantra", 987 client => "deliantra",
779 clientver => $DC::VERSION, 988 clientver => "$DC::VERSION$Urlader::EXE_VER",
780 gl_vendor => DC::OpenGL::gl_vendor, 989 gl_vendor => DC::OpenGL::gl_vendor,
781 gl_version => DC::OpenGL::gl_version, 990 gl_version => DC::OpenGL::gl_version,
782 }, 991 },
783 992
784 map_widget => $MAPWIDGET, 993 map_widget => $MAPWIDGET,
793 1002
794 on_connect => sub { 1003 on_connect => sub {
795 if ($_[0]) { 1004 if ($_[0]) {
796 DC::lowdelay fileno $CONN->{fh}; 1005 DC::lowdelay fileno $CONN->{fh};
797 1006
1007 ota_update_check;
1008
798 status "successfully connected to the server"; 1009 status "successfully connected to the server";
799 } else { 1010 } else {
800 undef $CONN; 1011 undef $CONN;
801 status "unable to connect: $!"; 1012 $LOGIN_ERROR->{fg} = [1, 0, 0];
1013 $LOGIN_ERROR->set_text ("Unable to connect to server: $!");
802 stop_game(); 1014 stop_game();
803 } 1015 }
804 }, 1016 },
1017
1018 on_addme => sub {
1019 my ($ok, $msg) = @_;
1020
1021 $LOGIN_ERROR->{fg} = $ok ? [0, 1, 0] : [1, 0, 0];
1022 $LOGIN_ERROR->set_text ($msg);
1023 },
805 ; 1024 ;
806} 1025}
807 1026
808sub start_game { 1027sub start_game($) {
1028 my ($create) = @_;
1029
809 status "logging in..."; 1030 status "logging in...";
810 1031
811 my $server = $PROFILE->{host} || $DEFAULT_SERVER; 1032 my $server = $PROFILE->{host} || $DEFAULT_SERVER;
812 my ($host, $port) = AnyEvent::Socket::parse_hostport $server, "deliantra=13327" 1033 my ($host, $port) = AnyEvent::Socket::parse_hostport $server, "deliantra=13327"
813 or return status "$server: unable to parse server address, try an empty field."; 1034 or return status "$server: unable to parse server address, try an empty field.";
828 status "dns failure, using hardcoded address"; 1049 status "dns failure, using hardcoded address";
829 $host = "194.126.175.154"; 1050 $host = "194.126.175.154";
830 } 1051 }
831 } 1052 }
832 1053
833 dc_connect $host, $port; 1054 dc_connect $host, $port, $create;
834 }; 1055 };
835 } else { 1056 } else {
836 dc_connect $host, $port; 1057 dc_connect $host, $port, $create;
837 } 1058 }
838} 1059}
839 1060
840sub stop_game { 1061sub stop_game {
841 crash "stop_game"; 1062 crash "stop_game";
959 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); 1180 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures");
960 $table->add_at (1, $row++, new DC::UI::CheckBox 1181 $table->add_at (1, $row++, new DC::UI::CheckBox
961 state => $CFG->{texture_compression}, 1182 state => $CFG->{texture_compression},
962 tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " 1183 tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but "
963 . "will save a lot of memory and increase performance (and also fall prey to the ever-buggy Mac OS X software renderer). " 1184 . "will save a lot of memory and increase performance (and also fall prey to the ever-buggy Mac OS X software renderer). "
964 . "The compression algorithm can differ form card to card, so your mileage may vary. This setting is ignored in " 1185 . "The compression algorithm can differ from card to card, so your mileage may vary. This setting is ignored in "
965 . "forced OpenGL 1.1 mode and when using the Apple renderer.", 1186 . "forced OpenGL 1.1 mode and when using the Apple renderer.",
966 on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } 1187 on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 }
967 ); 1188 );
968 1189
969 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly"); 1190 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly");
1321 $DELIANTRA_DEBUG ^= $_[0]; 1542 $DELIANTRA_DEBUG ^= $_[0];
1322 1543
1323 if ($DELIANTRA_DEBUG & 16) { 1544 if ($DELIANTRA_DEBUG & 16) {
1324 $BW_WATCHER = EV::periodic 0, 1, 0, sub { 1545 $BW_WATCHER = EV::periodic 0, 1, 0, sub {
1325 return unless $CONN; 1546 return unless $CONN;
1326 debug sprintf "%8.2gKB/s", $CONN->{octets_in} / 1e3; 1547 debug sprintf "%8.2gkB/s", $CONN->{octets_in} / 1e3;
1327 $CONN->{octets_in} = 0; 1548 $CONN->{octets_in} = 0;
1328 }; 1549 };
1329 } else { 1550 } else {
1330 undef $BW_WATCHER; 1551 undef $BW_WATCHER;
1331 } 1552 }
1674 $vbox->add (new DC::UI::FancyFrame 1895 $vbox->add (new DC::UI::FancyFrame
1675 label => "Login Settings", 1896 label => "Login Settings",
1676 child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), 1897 child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]),
1677 ); 1898 );
1678 1899
1900 my $nullpw = "\x00" x 16;
1901
1679 $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); 1902 $table->add_at (0, 0, new DC::UI::Label align => 1, text => "Username");
1680 $table->add_at (1, 4, new DC::UI::Entry 1903 $table->add_at (1, 0, new DC::UI::Entry
1681 text => $PROFILE->{user}, 1904 text => $PROFILE->{user},
1682 tooltip => "The name of your character on the server. The name is case-sensitive!", 1905 tooltip => "The name of your character on the server. The name is case-sensitive!",
1683 on_changed => sub { my ($self, $value) = @_; $PROFILE->{user} = $value; 1 } 1906 on_changed => sub { my ($self, $value) = @_; $PROFILE->{user} = $value; 1 }
1684 ); 1907 );
1685 1908
1686 $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); 1909 $table->add_at (0, 1, new DC::UI::Label align => 1, text => "Password");
1687 $table->add_at (1, 5, new DC::UI::Entry 1910 $table->add_at (1, 1, my $pw1 = new DC::UI::Entry
1688 text => $PROFILE->{password}, 1911 text => $PROFILE->{password} ? $nullpw : "",
1689 hidden => 1, 1912 hidden => 1,
1690 tooltip => "The password for your character.", 1913 tooltip => "The password for your character.",
1691 on_changed => sub { my ($self, $value) = @_; $PROFILE->{password} = $value; 1 } 1914 on_focus_in => sub {
1915 my ($self) = @_;
1916 $self->set_text ("")
1917 if $self->{text} eq $nullpw;
1918 0
1919 },
1920 on_changed => sub {
1921 my ($self, $value) = @_;
1922 $PROFILE->{password} = unpack "H*", Deliantra::Util::hash_pw $value
1923 if length $value && $value ne $nullpw;
1924 1
1925 },
1692 ); 1926 );
1693 1927
1694 $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button 1928 $table->add_at (1, 2, $LOGIN_BUTTON = new DC::UI::Button
1695 expand => 1, 1929 expand => 1,
1696 text => "Login / Register", 1930 text => "Login to Existing Account",
1697 tooltip => "This button will either login to the account configured above or register a new account.", 1931 tooltip => "This button will login to the account given by the <b>Username</b> and <b>Password</b> fields above.",
1698 on_activate => sub { 1932 on_activate => sub {
1699 $CONN ? stop_game 1933 $CONN ? stop_game
1700 : start_game; 1934 : start_game 0;
1701 1 1935 1
1702 }, 1936 },
1703 ); 1937 );
1704 1938
1939 $table->add_at (0, 3, new DC::UI::Label align => 1, text => "Password");
1940 $table->add_at (1, 3, my $pw2 = new DC::UI::Entry
1941 hidden => 1,
1942 tooltip => "The new password for your character",
1943 );
1944
1945 $table->add_at (1, 4, new DC::UI::Button
1946 expand => 1,
1947 text => "Create New Account",
1948 tooltip => "This button will try to create a new account - you need to fill out the <b>Username</b> and the two <b>Password</b> fields above, using the same password for both <b>Password</b> fields.",
1949 on_activate => sub {
1950 if ($pw1->{text} ne $pw2->{text}) {
1951 $LOGIN_ERROR->{fg} = [1, 0, 0];
1952 $LOGIN_ERROR->set_text ("The passwords do not match - try to enter them again.");
1953 } else {
1954 $CONN or start_game 1;
1955 }
1956 1
1957 },
1958 );
1959
1960 $vbox->add (new DC::UI::FancyFrame
1961 label => "Server Message",
1962 tooltip => "The last message, or error, from the server.",
1963 child => ($LOGIN_ERROR = new DC::UI::Label valign => 0, ellipsise => 0),
1964 );
1965
1705 $vbox->add (new DC::UI::FancyFrame 1966 $vbox->add (new DC::UI::FancyFrame
1706 label => "How to Play", 1967 label => "How to Play",
1707 min_h => 240, 1968 min_h => 240,#d# should not be necessary - widget bug
1708 child => (new DC::UI::Label valign => 0, ellipsise => 0, 1969 child => (new DC::UI::Label valign => 0, ellipsise => 0,
1709 markup => 1970 markup =>
1710 "First select a suitable video resolution in the <b>Graphics</b> tab, above.\n\n" 1971 "First select a suitable video resolution in the <b>Graphics</b> tab, above.\n\n"
1711 . "Then register a new account (or use an existing one if you have one). " 1972 . "Then create a new account (or use an existing one if you have one).\n\n"
1712 . "To register an account, choose a username that hasn't been taken yet (just guess) and " 1973 . "To create an account, choose a username that hasn't been taken yet (just guess) and "
1713 . "try to log-in. Follow the instructions in the Log tab in the message window.", 1974 . "fill out the top two <b>Password</b> fields using the same password, then press <b>Create New Account</b>.",
1714 ), 1975 ),
1715 ); 1976 );
1716 1977
1717 $vbox 1978 $vbox
1718} 1979}
1769 $table->add_at (0, ++$row, new DC::UI::Label align => 1, text => "Output-Rate"); 2030 $table->add_at (0, ++$row, new DC::UI::Label align => 1, text => "Output-Rate");
1770 $table->add_at (1, $row, new DC::UI::Entry 2031 $table->add_at (1, $row, new DC::UI::Entry
1771 text => $CFG->{output_rate}, 2032 text => $CFG->{output_rate},
1772 tooltip => "The maximum bandwidth in bytes per second that the server should not exceed " 2033 tooltip => "The maximum bandwidth in bytes per second that the server should not exceed "
1773 . "when sending data. When 0 or unset, the server " 2034 . "when sending data. When 0 or unset, the server "
1774 . "default will be used, which is usually around 100kb/s. Most servers will " 2035 . "default will be used, which is usually around 100kB/s. Most servers will "
1775 . "dynamically find an optimal rate, so adjust this only when necessary.", 2036 . "dynamically find an optimal rate, so adjust this only when necessary.",
1776 on_changed => sub { $CFG->{output_rate} = $_[1]; 1 }, 2037 on_changed => sub { $CFG->{output_rate} = $_[1]; 1 },
1777 ); 2038 );
1778 2039
1779 $vbox->add (new DC::UI::FancyFrame 2040 $vbox->add (new DC::UI::FancyFrame
1836 $table->add_at (2, $row++, new DC::UI::Button 2097 $table->add_at (2, $row++, new DC::UI::Button
1837 text => "Save Now", 2098 text => "Save Now",
1838 tooltip => "Use this to manually save configuration and UI layout when " 2099 tooltip => "Use this to manually save configuration and UI layout when "
1839 . "autosave is disabled.", 2100 . "autosave is disabled.",
1840 on_activate => sub { 2101 on_activate => sub {
1841 DC::write_cfg; 2102 DC::save_cfg;
1842 0 2103 0
1843 } 2104 }
1844 ); 2105 );
1845 } 2106 }
1846 2107
1855 $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $DC::DB::DBDIR, tooltip => ""); 2116 $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $DC::DB::DBDIR, tooltip => "");
1856 $table->add_at (0, $row , new DC::UI::Label align => 1, text => "Urlader (Prebuilt)"); 2117 $table->add_at (0, $row , new DC::UI::Label align => 1, text => "Urlader (Prebuilt)");
1857 $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $ENV{URLADER_VERSION}, tooltip => ""); 2118 $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $ENV{URLADER_VERSION}, tooltip => "");
1858 $table->add_at (0, $row , new DC::UI::Label align => 1, text => "Branch (Prebuilt)"); 2119 $table->add_at (0, $row , new DC::UI::Label align => 1, text => "Branch (Prebuilt)");
1859 $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $ENV{URLADER_EXE_ID}, tooltip => ""); 2120 $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $ENV{URLADER_EXE_ID}, tooltip => "");
1860 $table->add_at (0, $row , new DC::UI::Label align => 1, text => "Version (Prebuilt)"); 2121 $table->add_at (0, $row , new DC::UI::Label align => 1, text => "Revision (Prebuilt)");
1861 $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $ENV{URLADER_EXE_VER}, tooltip => ""); 2122 $table->add_at (1, $row++, new DC::UI::Label align => 0, text => $ENV{URLADER_EXE_VER}, tooltip => "");
1862 } 2123 }
1863 2124
1864 $vbox 2125 $vbox
1865} 2126}
2057 my ($self) = @_; 2318 my ($self) = @_;
2058 2319
2059 delete $self->{updater}; 2320 delete $self->{updater};
2060 return unless $_[1]; 2321 return unless $_[1];
2061 2322
2062 $self->{updater} = AE::timer 0, 1, sub { 2323 $self->{updater} = AE::timer 0, 0.7, sub {
2063 $self->clear; 2324 $self->clear;
2064 2325
2065 return unless $CONN; 2326 return unless $CONN;
2066 2327
2067 my @nums = sort { $b <=> $a } keys %{ $CONN->{ix_recv_buf} }; 2328 my @nums = sort { $b <=> $a } keys %{ $CONN->{ix_recv_buf} };
2329 return unless @nums;
2068 2330
2069 $self->add_at (0, 0, new DC::UI::Label align => 1, text => "Face"); 2331 $self->add_at (0, 0, new DC::UI::Label align => 1, text => "Face");
2070 $self->add_at (1, 0, new DC::UI::Label align => 0, text => "Octets/Total"); 2332 $self->add_at (1, 0, new DC::UI::Label align => 0, text => "Octets/Total");
2071 2333
2072 for my $row (0 .. $#nums) { 2334 for my $row (0 .. $#nums) {
2278sub open_quit_dialog { 2540sub open_quit_dialog {
2279 unless ($QUIT_DIALOG) { 2541 unless ($QUIT_DIALOG) {
2280 $QUIT_DIALOG = new DC::UI::Toplevel 2542 $QUIT_DIALOG = new DC::UI::Toplevel
2281 x => "center", 2543 x => "center",
2282 y => "center", 2544 y => "center",
2283 z => 50, 2545 z => 60,
2284 title => "Really Quit?", 2546 title => "Really Quit?",
2285 on_key_down => sub { 2547 on_key_down => sub {
2286 my ($dialog, $ev) = @_; 2548 my ($dialog, $ev) = @_;
2287 $ev->{sym} == 27 and $dialog->hide; 2549 $ev->{sym} == 27 and $dialog->hide;
2288 } 2550 }
2335 make_playerbook; 2597 make_playerbook;
2336 2598
2337 $MENUPOPUP = DC::UI::Menu->new (items => [ 2599 $MENUPOPUP = DC::UI::Menu->new (items => [
2338 ["Setup…\tF9" , sub { $SETUP_DIALOG->toggle_visibility }], 2600 ["Setup…\tF9" , sub { $SETUP_DIALOG->toggle_visibility }],
2339 ["Playerbook…\tTab" , sub { $PL_WINDOW ->toggle_visibility }], 2601 ["Playerbook…\tTab" , sub { $PL_WINDOW ->toggle_visibility }],
2340 ["…Statistics\tF2" , sub { toggle_player_page ($::STATS_PAGE) }], 2602 ["…Statistics\tF2" , sub { toggle_player_page ($::STATS_PAGE) }],
2341 ["…Skills\tF3" , sub { toggle_player_page ($::SKILL_PAGE) }], 2603 ["…Skills\tF3" , sub { toggle_player_page ($::SKILL_PAGE) }],
2342 ["…Spells\tF4" , sub { toggle_player_page ($::SPELL_PAGE) }], 2604 ["…Spells\tF4" , sub { toggle_player_page ($::SPELL_PAGE) }],
2343 ["…Inventory\tF5" , sub { toggle_player_page ($::INVENTORY_PAGE) }], 2605 ["…Inventory\tF5" , sub { toggle_player_page ($::INVENTORY_PAGE) }],
2344 ["Help Browser…\tF1" , sub { $HELP_WINDOW ->toggle_visibility }], 2606 ["Help Browser…\tF1" , sub { $HELP_WINDOW ->toggle_visibility }],
2345 ["Quit…" , sub { 2607 ["Quit…" , sub {
2346 if ($CONN) { 2608 if ($CONN) {
2347 open_quit_dialog; 2609 open_quit_dialog;
2348 } else { 2610 } else {
2349 EV::unloop EV::UNLOOP_ALL; 2611 EV::break EV::BREAK_ALL;
2350 } 2612 }
2351 }], 2613 }],
2352 ]); 2614 ]);
2353 2615
2354 $BUTTONBAR->add (new DC::UI::Button text => "Menu…", 2616 $BUTTONBAR->add (new DC::UI::Button text => "Menu…",
2481 DC::set_theme $CFG->{uitheme}; 2743 DC::set_theme $CFG->{uitheme};
2482 2744
2483 DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; 2745 DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT;
2484 $SDL_REINIT = 0; 2746 $SDL_REINIT = 0;
2485 2747
2486 @SDL_MODES = DC::SDL_ListModes 8, $CFG->{disable_alpha} ? 0 : 8; 2748 @SDL_MODES = DC::SDL_ListModes 8, $CFG->{disable_alpha} ? 0 : 2;
2487 @SDL_MODES = DC::SDL_ListModes 8, 8 unless @SDL_MODES; 2749 @SDL_MODES = DC::SDL_ListModes 8, 8 unless @SDL_MODES;
2488 @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES; 2750 @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES;
2489 @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 2751 @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
2490 2752
2491 @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; 2753 @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES;
2504 my ($old_w, $old_h) = ($WIDTH, $HEIGHT); 2766 my ($old_w, $old_h) = ($WIDTH, $HEIGHT);
2505 2767
2506 ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 2768 ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
2507 $FULLSCREEN = $CFG->{fullscreen}; 2769 $FULLSCREEN = $CFG->{fullscreen};
2508 $FAST = $CFG->{fast}; 2770 $FAST = $CFG->{fast};
2771
2772 DC::SDL_WM_SetCaption "Deliantra MORPG Client $DC::VERSION$Urlader::EXE_VER", "Deliantra"; # must be after SDL_Init
2509 2773
2510 # due to mac os x braindamage, we simply retry with !fullscreen in case of an error 2774 # due to mac os x braindamage, we simply retry with !fullscreen in case of an error
2511 DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN 2775 DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN
2512 or DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, !$FULLSCREEN 2776 or DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, !$FULLSCREEN
2513 or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n"; 2777 or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n";
2723 delete $animate_object{$widget}; 2987 delete $animate_object{$widget};
2724} 2988}
2725 2989
2726$SDL_CB[DC::SDL_QUIT] = sub { 2990$SDL_CB[DC::SDL_QUIT] = sub {
2727 crash "SDL_QUIT"; 2991 crash "SDL_QUIT";
2728 EV::unloop EV::UNLOOP_ALL; 2992 EV::break EV::BREAK_ALL;
2729}; 2993};
2730$SDL_CB[DC::SDL_VIDEORESIZE] = sub { }; 2994$SDL_CB[DC::SDL_VIDEORESIZE] = sub { };
2731$SDL_CB[DC::SDL_VIDEOEXPOSE] = sub { 2995$SDL_CB[DC::SDL_VIDEOEXPOSE] = sub {
2732 DC::UI::full_refresh; 2996 DC::UI::full_refresh;
2733}; 2997};
2766}; 3030};
2767 3031
2768############################################################################# 3032#############################################################################
2769 3033
2770$SIG{INT} = $SIG{TERM} = sub { 3034$SIG{INT} = $SIG{TERM} = sub {
2771 EV::unloop; 3035 EV::break;
2772 #d# TODO calling exit here hangs the process in some futex 3036 #d# TODO calling exit here hangs the process in some futex
2773}; 3037};
2774 3038
2775# due to mac os x + sdl combined braindamage, we need this contortion 3039# due to mac os x + sdl combined braindamage, we need this contortion
2776sub DC::Main::main { 3040sub DC::Main::run {
2777 { 3041 DC::SDL_main_hack {
3042 {
2778 DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; 3043 DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst";
2779 3044
2780 if (-e "$Deliantra::VARDIR/client.cf") { 3045 DC::load_cfg;
2781 DC::read_cfg "$Deliantra::VARDIR/client.cf"; 3046 DC::upgrade_cfg;
2782 } else {
2783 #TODO: compatibility cruft
2784 DC::read_cfg "$Deliantra::OLDDIR/cfplusrc";
2785 print STDERR "INFO: used old configuration file\n";
2786 }
2787 3047
3048 DC::Audio::probe;
3049
2788 DC::DB::Server::run; 3050 DC::DB::Server::run;
2789 3051
2790 if ($CFG->{db_schema} < 1) { 3052 if ($CFG->{db_schema} < 1) {
2791 warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; 3053 warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n";
2792 DC::DB::nuke_db; 3054 DC::DB::nuke_db;
2793 $CFG->{db_schema} = 1; 3055 $CFG->{db_schema} = 1;
2794 DC::write_cfg; 3056 DC::save_cfg;
2795 }
2796
2797 DC::DB::open_db;
2798
2799 DC::UI::set_layout ($::CFG->{layout});
2800
2801 my %DEF_CFG = (
2802 config_autosave => 1,
2803 sdl_mode => undef,
2804 fullscreen => 1,
2805 fast => 0,
2806 force_opengl11 => undef,
2807 disable_alpha => 0,
2808 smooth_movement => 1,
2809 smooth_transitions => 1,
2810 texture_compression => 1,
2811 map_scale => 1,
2812 fow_enable => 1,
2813 fow_intensity => 0,
2814 fow_texture => 0,
2815 map_smoothing => 1,
2816 gui_fontsize => 1,
2817 log_fontsize => 0.7,
2818 gauge_fontsize => 1,
2819 gauge_size => 0.35,
2820 stat_fontsize => 0.7,
2821 mapsize => 100,
2822 audio_enable => 1,
2823 audio_hw_channels => 0,
2824 audio_hw_frequency => 0,
2825 audio_hw_chunksize => 0,
2826 audio_mix_channels => 8,
2827 effects_enable => 1,
2828 effects_volume => 1,
2829 bgm_enable => 1,
2830 bgm_volume => 0.5,
2831 output_rate => "",
2832 pickup => PICKUP_SPELLBOOK | PICKUP_SKILLSCROLL | PICKUP_VALUABLES,
2833 inv_sort => "mtime",
2834 default => "profile", # default profile
2835 show_tips => 1,
2836 logview_max_par => 1000,
2837 shift_fire_stop => 0,
2838 uitheme => "wood",
2839 map_shift_x => -24, # arbitrary
2840 map_shift_y => +24, # arbitrary
2841 );
2842
2843 while (my ($k, $v) = each %DEF_CFG) {
2844 $CFG->{$k} = $v unless exists $CFG->{$k};
2845 }
2846
2847 my @args = @ARGV;
2848
2849 # OS X passes some process serial number of other shit. they
2850 # could have used an env var or any other sane mechanism. but
2851 # would it be os x then? no...
2852 shift @args if $args[0] =~ /^-psn_/;
2853
2854 my $profile = 'default';
2855
2856 for (my $i = 0; $i < @args; $i++) {
2857 if ($args[$i] =~ /^--?profile$/) {
2858 $profile = $args[$i + 1];
2859 splice @args, $i, 2, ();
2860 $i = 0;
2861 } elsif ($args[$i] =~ /^--?h/) {
2862 print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n";
2863 exit 0;
2864 } 3057 }
2865 }
2866 3058
2867 $CFG->{profile}{$profile} ||= {}; 3059 DC::DB::open_db;
2868 $PROFILE = $CFG->{profile}{$profile};
2869 $PROFILE->{host} ||= "gameserver.deliantra.net";
2870 3060
2871 $PROFILE->{host} = $args[0] if @args > 0; 3061 DC::UI::set_layout ($::CFG->{layout});
2872 $PROFILE->{user} = $args[1] if @args > 1;
2873 $PROFILE->{password} = $args[2] if @args > 2;
2874 3062
2875 # convert old bindings (only default profile matters) 3063 my @args = @ARGV;
2876 if (my $bindings = delete $PROFILE->{bindings}) { 3064
2877 while (my ($mod, $syms) = each %$bindings) { 3065 # OS X passes some process serial number of other shit. they
2878 while (my ($sym, $cmds) = each %$syms) { 3066 # could have used an env var or any other sane mechanism. but
2879 push @{ $PROFILE->{macro} }, { 3067 # would it be os x then? no...
2880 accelkey => [$mod*1, $sym*1], 3068 shift @args if $args[0] =~ /^-psn_/;
2881 action => $cmds, 3069
3070 my $profile = 'default';
3071
3072 for (my $i = 0; $i < @args; $i++) {
3073 if ($args[$i] =~ /^--?profile$/) {
3074 $profile = $args[$i + 1];
3075 splice @args, $i, 2, ();
2882 }; 3076 $i = 0;
3077 } elsif ($args[$i] =~ /^--?h/) {
3078 print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n";
3079 exit 0;
2883 } 3080 }
2884 } 3081 }
3082
3083 $CFG->{profile}{$profile} ||= {};
3084 $PROFILE = $CFG->{profile}{$profile};
3085 $PROFILE->{host} ||= "gameserver.deliantra.net";
3086
3087 $PROFILE->{host} = $args[0] if @args > 0;
3088 $PROFILE->{user} = $args[1] if @args > 1;
3089 $PROFILE->{password} = unpack "H*", Deliantra::Util::hash_pw $args[2] if @args > 2;
3090
3091 # convert old bindings (only default profile matters)
3092 if (my $bindings = delete $PROFILE->{bindings}) {
3093 while (my ($mod, $syms) = each %$bindings) {
3094 while (my ($sym, $cmds) = each %$syms) {
3095 push @{ $PROFILE->{macro} }, {
3096 accelkey => [$mod*1, $sym*1],
3097 action => $cmds,
3098 };
3099 }
3100 }
2885 } 3101 }
2886 3102
2887 # fontconfig doesn't support relative paths anymore, so use abs_path and keep fingers crossed 3103 # fontconfig doesn't support relative paths anymore, so use abs_path and keep fingers crossed
2888 # these are ignored under windows, for some reason, and thus set in the loader 3104 # these are ignored under windows, for some reason, and thus set in the loader
2889 $ENV{FONTCONFIG_FILE} = "fonts.conf"; 3105 $ENV{FONTCONFIG_FILE} = "fonts.conf";
2890 $ENV{FONTCONFIG_PATH} = Cwd::abs_path DC::find_rcfile "fonts"; 3106 $ENV{FONTCONFIG_PATH} = Cwd::abs_path DC::find_rcfile "fonts";
2891 $ENV{FONTCONFIG_DIR} = $ENV{FONTCONFIG_PATH}; # helps with older versions 3107 $ENV{FONTCONFIG_DIR} = $ENV{FONTCONFIG_PATH}; # helps with older versions
2892 3108
2893 { 3109 {
2894 my @fonts = map DC::find_rcfile "fonts/$_", qw( 3110 my @fonts = map DC::find_rcfile "fonts/$_", qw(
2895 DejaVuSans.ttf 3111 DejaVuSans.ttf
2896 DejaVuSansMono.ttf 3112 DejaVuSansMono.ttf
2897 DejaVuSans-Bold.ttf 3113 DejaVuSans-Bold.ttf
2898 DejaVuSansMono-Bold.ttf 3114 DejaVuSansMono-Bold.ttf
2899 DejaVuSans-Oblique.ttf 3115 DejaVuSans-Oblique.ttf
2900 DejaVuSansMono-Oblique.ttf 3116 DejaVuSansMono-Oblique.ttf
2901 DejaVuSans-BoldOblique.ttf 3117 DejaVuSans-BoldOblique.ttf
2902 DejaVuSansMono-BoldOblique.ttf 3118 DejaVuSansMono-BoldOblique.ttf
2903 mona.ttf 3119 mona.ttf
2904 ); 3120 );
2905 3121
2906 DC::add_font $_ for @fonts; 3122 DC::add_font $_ for @fonts;
2907 3123
2908 $FONT_PROP = new_from_file DC::Font $fonts[0]; 3124 $FONT_PROP = new_from_file DC::Font $fonts[0];
2909 $FONT_FIXED = new_from_file DC::Font $fonts[1]; 3125 $FONT_FIXED = new_from_file DC::Font $fonts[1];
2910 3126
2911 $FONT_PROP->make_default; 3127 $FONT_PROP->make_default;
2912 3128
2913 DC::pango_init; 3129 DC::pango_init;
2914 } 3130 }
2915 3131
2916# compare mono (ft) vs. rgba (cairo) 3132# compare mono (ft) vs. rgba (cairo)
2917# ft - 1.8s, cairo 3s, even in alpha-only mode 3133# ft - 1.8s, cairo 3s, even in alpha-only mode
2918# for my $rgba (0..1) { 3134# for my $rgba (0..1) {
2919# my $t1 = Time::HiRes::time; 3135# my $t1 = Time::HiRes::time;
2924# } 3140# }
2925# my $t2 = Time::HiRes::time; 3141# my $t2 = Time::HiRes::time;
2926# warn $t2-$t1; 3142# warn $t2-$t1;
2927# } 3143# }
2928 3144
3145 }
3146
3147 DC::SDL_Init 0;
2929 DC::IMG_Init; video_init; 3148 DC::IMG_Init; video_init;
2930 DC::Mix_Init; audio_init; 3149 DC::Mix_Init; audio_init;
2931 }
2932 3150
2933 show_tip_of_the_day if $CFG->{show_tips}; 3151 show_tip_of_the_day if $CFG->{show_tips};
2934 3152
2935 my $STARTUP_CANCEL; $STARTUP_CANCEL = EV::idle sub { 3153 my $STARTUP_CANCEL; $STARTUP_CANCEL = EV::idle sub {
2936 undef $STARTUP_CANCEL; 3154 undef $STARTUP_CANCEL;
2937 (pop @::STARTUP_DONE)->() 3155 (pop @::STARTUP_DONE)->()
2938 while @::STARTUP_DONE; 3156 while @::STARTUP_DONE;
3157 };
3158
3159 debug_toggle 0;
3160
3161 delete $SIG{__DIE__};
3162 EV::run;
3163
3164 DC::save_cfg if $CFG->{config_autosave};
3165
3166 #video_shutdown;
3167 #audio_shutdown;
3168
3169 DC::OpenGL::quit;
3170 DC::SDL_Quit;
3171 DC::DB::Server::stop;
2939 }; 3172 };
2940
2941 debug_toggle 0;
2942
2943 delete $SIG{__DIE__};
2944 EV::loop;
2945
2946 DC::write_cfg if $CFG->{config_autosave};
2947
2948 #video_shutdown;
2949 #audio_shutdown;
2950
2951 DC::OpenGL::quit;
2952 DC::SDL_Quit;
2953 DC::DB::Server::stop;
2954} 3173}
2955
2956*DC::Main::run = \&DC::SDL_braino; # see sub above
2957 3174
29581 31751

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines