… | |
… | |
104 | use List::Util qw(max min); |
104 | use List::Util qw(max min); |
105 | |
105 | |
106 | use Deliantra; |
106 | use Deliantra; |
107 | use Deliantra::Protocol::Constants; |
107 | use Deliantra::Protocol::Constants; |
108 | |
108 | |
|
|
109 | use AnyEvent::Util (); |
109 | use AnyEvent::DNS; |
110 | use AnyEvent::DNS; |
110 | use AnyEvent::Socket (); |
111 | use AnyEvent::Socket (); |
111 | |
112 | |
112 | use Compress::LZF; |
113 | use Compress::LZF; |
|
|
114 | use JSON::XS; |
113 | |
115 | |
114 | use DC; |
116 | use DC; |
115 | BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$_[0]" unless $^S } } |
117 | |
|
|
118 | ############################################################################# |
|
|
119 | |
|
|
120 | our $CONN; |
|
|
121 | |
|
|
122 | # write a crash message blockingly to the socket, if possible |
|
|
123 | # this is a bit too complicated for my tastes, but it was easy. |
|
|
124 | sub crash($;$) { |
|
|
125 | my ($msg, $backtrace) = @_; |
|
|
126 | |
|
|
127 | return unless $CONN; |
|
|
128 | |
|
|
129 | my $fh = $CONN->{fh} |
|
|
130 | or return; |
|
|
131 | |
|
|
132 | my $buf = delete $CONN->{wbuf}; |
|
|
133 | |
|
|
134 | $buf .= pack "n/a*", "exti " . JSON::XS::encode_json [clientlog => undef, substr $msg, 0, 8000]; |
|
|
135 | |
|
|
136 | AnyEvent::Util::fh_nonblocking $fh, 0; |
|
|
137 | |
|
|
138 | syswrite $fh, $buf; |
|
|
139 | AnyEvent::Util::fh_nonblocking $fh, 1; |
|
|
140 | |
|
|
141 | $msg =~ s/\s+$//; |
|
|
142 | |
|
|
143 | # backtrace as second step, in case it crashes, too |
|
|
144 | crash (Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated") |
|
|
145 | if $backtrace; |
|
|
146 | } |
|
|
147 | |
|
|
148 | ############################################################################# |
|
|
149 | |
|
|
150 | BEGIN { |
|
|
151 | $SIG{__DIE__} = sub { |
|
|
152 | return if $^S; |
|
|
153 | crash ("CRASH/DIE: $_[0]" => 1); |
|
|
154 | DC::fatal Carp::longmess "$_[0]"; |
|
|
155 | } |
|
|
156 | } |
|
|
157 | |
116 | use DC::OpenGL (); |
158 | use DC::OpenGL (); |
117 | use DC::Protocol; |
159 | use DC::Protocol; |
118 | use DC::DB; |
160 | use DC::DB; |
119 | use DC::UI; |
161 | use DC::UI; |
120 | use DC::UI::Canvas; |
162 | use DC::UI::Canvas; |
121 | use DC::UI::Inventory; |
163 | use DC::UI::Inventory; |
122 | use DC::UI::SpellList; |
164 | use DC::UI::SpellList; |
123 | use DC::UI::Dockable; |
165 | use DC::UI::Dockable; |
124 | use DC::UI::Dockbar; |
166 | use DC::UI::Dockbar; |
125 | use DC::UI::MessageWindow; |
|
|
126 | use DC::UI::ChatView; |
167 | use DC::UI::ChatView; |
127 | use DC::MessageDistributor; |
168 | use DC::MessageDistributor; |
128 | use DC::Pod; |
169 | use DC::Pod; |
129 | use DC::MapWidget; |
170 | use DC::MapWidget; |
130 | use DC::Macro; |
171 | use DC::Macro; |
131 | |
172 | |
132 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
173 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
133 | $SIG{PIPE} = 'IGNORE'; |
174 | $SIG{PIPE} = 'IGNORE'; |
134 | |
175 | |
135 | $EV::DIED = sub { |
176 | $EV::DIED = sub { |
|
|
177 | crash ("CRASH/EV::DIED: $@" => 1); |
136 | DC::fatal Carp::longmess $@; |
178 | DC::fatal Carp::longmess $@; |
137 | }; |
179 | }; |
138 | |
180 | |
139 | my $MAX_FPS = 60; |
181 | my $MAX_FPS = 60; |
140 | |
182 | |
… | |
… | |
142 | |
184 | |
143 | our $LAST_REFRESH; |
185 | our $LAST_REFRESH; |
144 | our $NOW; |
186 | our $NOW; |
145 | |
187 | |
146 | our $CFG; |
188 | our $CFG; |
147 | our $CONN; |
|
|
148 | our $PROFILE; # current profile |
189 | our $PROFILE; # current profile |
149 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
190 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
150 | |
191 | |
151 | our $WANT_REFRESH; |
192 | our $WANT_REFRESH; |
152 | |
193 | |
… | |
… | |
807 | dc_connect $host, $port; |
848 | dc_connect $host, $port; |
808 | } |
849 | } |
809 | } |
850 | } |
810 | |
851 | |
811 | sub stop_game { |
852 | sub stop_game { |
|
|
853 | crash "stop_game"; |
|
|
854 | |
812 | $LOGIN_BUTTON->set_text ("Login / Register"); |
855 | $LOGIN_BUTTON->set_text ("Login / Register"); |
813 | $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); |
856 | $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); |
814 | $SETUP_DIALOG->show; |
857 | $SETUP_DIALOG->show; |
815 | $PL_WINDOW->hide; |
858 | $PL_WINDOW->hide; |
816 | $SPELL_LIST->clear_spells; |
859 | $SPELL_LIST->clear_spells; |
… | |
… | |
836 | |
879 | |
837 | my $row = 0; |
880 | my $row = 0; |
838 | |
881 | |
839 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "OpenGL Info"); |
882 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "OpenGL Info"); |
840 | $table->add_at (1, $row++, new DC::UI::Label fontsize => 0.8, text => DC::OpenGL::gl_vendor . ", " . DC::OpenGL::gl_version, |
883 | $table->add_at (1, $row++, new DC::UI::Label fontsize => 0.8, text => DC::OpenGL::gl_vendor . ", " . DC::OpenGL::gl_version, |
841 | can_events => 1, |
884 | can_events => 1, |
842 | tooltip => "<tt><span size='8192'>" . (DC::OpenGL::gl_extensions) . "</span></tt>"); |
885 | tooltip => "<tt><span size='8192'>" . (DC::OpenGL::gl_extensions) . "</span></tt>"); |
843 | |
886 | |
844 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Caveats"); |
887 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Caveats"); |
845 | $table->add_at (1, $row++, $CAVEAT_LABEL = new DC::UI::Label fontsize => 0.8, |
888 | $table->add_at (1, $row++, $CAVEAT_LABEL = new DC::UI::Label fontsize => 0.8, |
846 | can_events => 1, |
889 | can_events => 1, |
847 | tooltip => "This field shows any known issues with your config or driver, such as " |
890 | tooltip => "This field shows any known issues with your config or driver, such as " |
… | |
… | |
910 | |
953 | |
911 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
954 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
912 | $table->add_at (1, $row++, new DC::UI::CheckBox |
955 | $table->add_at (1, $row++, new DC::UI::CheckBox |
913 | state => $CFG->{texture_compression}, |
956 | state => $CFG->{texture_compression}, |
914 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
957 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
915 | . "will save a lot of memory and increase performance. The compression algorithm " |
958 | . "will save a lot of memory and increase performance (and also fall prey to the ever-buggy Mac OS X software renderer). " |
916 | . "can differ form card to card, so your mileage may vary. This setting is ignored in " |
959 | . "The compression algorithm can differ form card to card, so your mileage may vary. This setting is ignored in " |
917 | . "forced OpenGL 1.1 mode.", |
960 | . "forced OpenGL 1.1 mode and when using the Apple renderer.", |
918 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
961 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
919 | ); |
962 | ); |
920 | |
963 | |
921 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly"); |
964 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly"); |
922 | $table->add_at (1, $row++, new DC::UI::CheckBox |
965 | $table->add_at (1, $row++, new DC::UI::CheckBox |
… | |
… | |
1597 | }, |
1640 | }, |
1598 | ); |
1641 | ); |
1599 | |
1642 | |
1600 | $vbox->add (new DC::UI::FancyFrame |
1643 | $vbox->add (new DC::UI::FancyFrame |
1601 | label => "How to Play", |
1644 | label => "How to Play", |
1602 | min_h => 200, |
1645 | min_h => 240, |
1603 | child => (new DC::UI::Label valign => 0, ellipsise => 0, |
1646 | child => (new DC::UI::Label valign => 0, ellipsise => 0, |
1604 | markup => |
1647 | markup => |
1605 | "First select a suitable video resolution in the Graphics tab, above.\n\n" |
1648 | "First select a suitable video resolution in the <b>Graphics</b> tab, above.\n\n" |
1606 | . "Then register a new account (or use an existibg one if you have one). " |
1649 | . "Then register a new account (or use an existing one if you have one). " |
1607 | . "To register an account, choose a username that hasn't been taken yet and " |
1650 | . "To register an account, choose a username that hasn't been taken yet (just guess) and " |
1608 | . "try to log-in. Follow the instructions in the Log tab in the message window.", |
1651 | . "try to log-in. Follow the instructions in the Log tab in the message window.", |
1609 | ), |
1652 | ), |
1610 | ); |
1653 | ); |
1611 | |
1654 | |
1612 | $vbox |
1655 | $vbox |
… | |
… | |
2133 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
2176 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
2134 | ); |
2177 | ); |
2135 | $hb->add (new DC::UI::Button |
2178 | $hb->add (new DC::UI::Button |
2136 | text => "Quit anyway", |
2179 | text => "Quit anyway", |
2137 | expand => 1, |
2180 | expand => 1, |
2138 | on_activate => sub { EV::unloop EV::UNLOOP_ALL }, |
2181 | on_activate => sub { |
|
|
2182 | crash "Quit anyway"; |
|
|
2183 | EV::unloop EV::UNLOOP_ALL; |
|
|
2184 | }, |
2139 | ); |
2185 | ); |
2140 | } |
2186 | } |
2141 | |
2187 | |
2142 | $QUIT_DIALOG->show; |
2188 | $QUIT_DIALOG->show; |
2143 | $QUIT_DIALOG->grab_focus; |
2189 | $QUIT_DIALOG->grab_focus; |
… | |
… | |
2481 | delete $animate_object{$widget}; |
2527 | delete $animate_object{$widget}; |
2482 | } |
2528 | } |
2483 | |
2529 | |
2484 | %SDL_CB = ( |
2530 | %SDL_CB = ( |
2485 | DC::SDL_QUIT => sub { |
2531 | DC::SDL_QUIT => sub { |
|
|
2532 | crash "SDL_QUIT"; |
2486 | EV::unloop EV::UNLOOP_ALL; |
2533 | EV::unloop EV::UNLOOP_ALL; |
2487 | }, |
2534 | }, |
2488 | DC::SDL_VIDEORESIZE => sub { |
2535 | DC::SDL_VIDEORESIZE => sub { |
2489 | }, |
2536 | }, |
2490 | DC::SDL_VIDEOEXPOSE => sub { |
2537 | DC::SDL_VIDEOEXPOSE => sub { |