ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/pclient
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.1 by root, Thu Apr 6 15:30:09 2006 UTC vs.
Revision 1.90 by root, Wed Apr 12 21:35:11 2006 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3use strict;
4use utf8;
5
6use Time::HiRes 'time';
7use Event;
2 8
3use SDL; 9use SDL;
4use SDL::App; 10use SDL::App;
5use SDL::Event; 11use SDL::Event;
6use SDL::Surface; 12use SDL::Surface;
13use SDL::OpenGL;
7 14
8my $conn; 15use Crossfire;
9my $map_surface;
10
11my $app = new SDL::App
12 -flags => SDL_HWSURFACE | SDL_ANYFORMAT | SDL_HWACCEL | SDL_ASYNCBLIT,
13 -title => "Crossfire+ Client",
14 -width => 640,
15 -height => 480,
16 -depth => 24,
17 -double_buffer => 1,
18 -resizeable => 1;
19
20sub redraw {
21 $map_surface or return;
22
23 $map_surface->blit (0, $app, 0);
24 $app->sync;
25}
26
27my $ev = new SDL::Event;
28my %ev_cb;
29
30sub event(&$) {
31 $ev_cb{$_[0]->()} = $_[1];
32}
33
34sub does(&) { shift }
35
36event {SDL_QUIT} does {
37 exit;
38};
39
40event {SDL_VIDEORESIZE} does {
41 print "resize\n";
42};
43
44event {SDL_KEYDOWN} does {
45 print "keypress\n";
46};
47
48event {SDL_KEYUP} does {
49 print "keyup\n";#d#
50};
51
52event {SDL_MOUSEMOTION} does {
53 print "motion\n";
54};
55
56event {SDL_MOUSEBUTTONDOWN} does {
57 print "button\n";
58};
59
60event {SDL_MOUSEBUTTONUP} does {
61 print "buttup\n";
62};
63
64event {SDL_ACTIVEEVENT} does {
65 print "active\n";
66};
67
68package Crossfire::Protocol; 16use Crossfire::Protocol;
69 17
70use AnyEvent; 18use CFClient;
71use IO::Socket::INET; 19use CFClient::UI;
72 20
73sub new { 21our $VERSION = '0.1';
74 my $class = shift;
75 my $self = bless { @_ }, $class;
76 22
77 $self->{fh} = new IO::Socket::INET PeerHost => $self->{host}, PeerPort => $self->{port} 23my $MAX_FPS = 60;
78 or die "$self->{host}:$self->{port}: $!"; 24my $MIN_FPS = 5; # unused as of yet
79 $self->{fh}->blocking (0); # stupid nonblock default
80 25
81 my $buf; 26our $FACECACHE;
82 27
83 $self->{w} = AnyEvent->io (fh => $self->{fh}, poll => 'r', cb => sub { 28our $LAST_REFRESH;
84 if (sysread $self->{fh}, $buf, 16384, length $buf) { 29our $NOW;
85 if (2 <= length $buf) { 30
86 my $len = unpack "n", $buf; 31our $CFG;
87 if ($len + 2 <= length $buf) { 32our $CONN;
88 substr $buf, 0, 2, ""; 33our $FAST; # fast, low-quality mode, possibly useful for software-rendering
89 $self->feed (substr $buf, 0, $len, ""); 34
90 } 35our @SDL_MODES;
91 } 36our $WIDTH;
92 } else { 37our $HEIGHT;
93 delete $self->{w}; 38our $FULLSCREEN;
94 close $self->{fh}; 39
40our $MAPWIDGET;
41our $FONTSIZE;
42
43our $SDL_ACTIVE;
44our $SDL_EV;
45our %SDL_CB;
46
47our $ALT_ENTER_MESSAGE;
48our $STATUS_LINE;
49our $DEBUG_STATUS;
50
51sub status {
52 $STATUS_LINE->set_text ($_[0]);
53 my ($w, $h) = $STATUS_LINE->size_request;
54 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h);
55}
56
57sub debug {
58 $DEBUG_STATUS->set_text ($_[0]);
59 my ($w, $h) = $DEBUG_STATUS->size_request;
60 $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h);
61}
62
63sub start_game {
64 status "logging in...";
65
66 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
67
68 $CONN = new conn
69 host => $CFG->{host},
70 port => $CFG->{port},
71 user => $CFG->{user},
72 pass => $CFG->{password},
73 mapw => $mapsize,
74 maph => $mapsize,
75 ;
76
77 status "login successful";
78
79 CFClient::lowdelay fileno $CONN->{fh};
80}
81
82sub stop_game {
83 undef $CONN;
84}
85
86sub config_dialog {
87 my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100,
88 child => (my $vbox = new CFClient::UI::VBox);
89 $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup");
90 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
91
92 $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode");
93 $table->add (1, 0, my $hbox = new CFClient::UI::HBox);
94
95 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]);
96 $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8);
97
98 $mode_slider->connect (changed => sub {
99 my ($self, $value) = @_;
100
101 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
102 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
103 });
104 $mode_slider->emit (changed => $mode_slider->{range}[0]);
105
106 $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Fullscreen");
107 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub {
108 my ($self, $value) = @_;
109 $CFG->{fullscreen} = $value;
110 });
111
112 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fast &amp; Ugly");
113 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub {
114 my ($self, $value) = @_;
115 $CFG->{fast} = $value;
116 });
117
118 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fog of War");
119 $table->add (1, 2, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub {
120 my ($self, $value) = @_;
121 $CFG->{fow_intensity} = $value;
122 });
123
124 $table->add (1, 4, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
125 destroy_screen ();
126 init_screen ();
127 });
128
129 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup");
130 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
131 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host");
132 $table->add (1, 2, my $host = new CFClient::UI::Entry text => $CFG->{host});
133
134 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Port");
135 $table->add (1, 3, my $port = new CFClient::UI::Entry text => $CFG->{port});
136
137 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username");
138 $table->add (1, 4, my $user = new CFClient::UI::Entry text => $CFG->{user});
139
140 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password");
141 $table->add (1, 5, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1);
142
143 $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Map Size");
144 $table->add (1, 6, new CFClient::UI::Slider
145 req_w => 100,
146 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
147 connect_changed => sub {
148 my ($self, $value) = @_;
149
150 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
95 } 151 },
96 }); 152 );
97 153
98 $self->send ("version 1023 1027 perlclient"); 154 $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub {
99 $self->send ("setup sound 1 exp 1 map1acmd 1 itemcmd 2 darkness 1 mapsize 63x63 newmapcmd 1 facecache 1 extendedMapInfos 1 extendedTextInfos 1"); 155 start_game;
100 $self->send ("addme"); 156 });
101 157
102 $self 158 $vbox->add (my $hbox = new CFClient::UI::HBox);
103}
104 159
105sub feed { 160 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub {
106 my ($self, $data) = @_; 161 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
107 162 status "Configuration Saved";
108 $data =~ s/^(\S+)\s// 163 });
109 or return; 164 $CFClient::UI::TOPLEVEL->add ($dialog);
110
111 my $command = "feed_$1";
112
113 $self->$command ($data);
114} 165}
115 166
116sub feed_version { 167sub sdl_init {
117 my ($self, $version) = @_; 168 SDL::Init SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO
169 and die "SDL::Init failed!\n";
118} 170}
119 171
120sub feed_setup { 172sub init_screen {
121 my ($self, $data) = @_; 173 sdl_init;
122 174
123 $data =~ s/^ +//; 175 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
176 $FULLSCREEN = $CFG->{fullscreen};
177 $FAST = $CFG->{fast};
124 178
125 $self->{setup} = { split / +/, $data }; 179 SDL::GLSetAttribute SDL_GL_RED_SIZE, 5;
180 SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5;
181 SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5;
182 SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 0;
126 183
127 ($self->{mapw}, $self->{maph}) = split /x/, $self->{setup}{mapsize}; 184 SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0;
185 SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0;
186 SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0;
187 SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0;
128 188
129 $self->feed_newmap; 189 SDL::GLSetAttribute SDL_GL_DOUBLEBUFFER, 1;
130} 190 SDL::GLSetAttribute SDL_GL_BUFFER_SIZE, 15;
191 SDL::GLSetAttribute SDL_GL_DEPTH_SIZE, 0;
131 192
132sub feed_query { 193 SDL::SetVideoMode $WIDTH, $HEIGHT, 0,
133 my ($self, $data) = @_; 194 SDL_HWSURFACE | SDL_ANYFORMAT | SDL_OPENGL | SDL_DOUBLEBUF
134 warn "Q<$data>\n"; 195 | ($FULLSCREEN ? SDL_FULLSCREEN : 0)
135} 196 or die "SDL::SetVideoMode failed!\n";
136 197
137sub feed_stats { 198 SDL::WMSetCaption "Crossfire+ Client", "Crossfire+";
138 my ($self, $data) = @_;
139# warn "S<$data>\n";
140}
141 199
142sub feed_face1 { 200 $SDL_EV = new SDL::Event;
143 my ($self, $data) = @_; 201 $SDL_EV->set_unicode (1);
144 202
145 my ($num, $chksum, $name) = unpack "nNa*", $data; 203 $SDL_ACTIVE = 1;
146 204
147 $self->{face}[$num] = { name => $name, chksum => $chksum }; 205 $LAST_REFRESH = time - 0.01;
148}
149 206
150sub feed_drawinfo { 207 CFClient::gl_init;
151 my ($self, $data) = @_;
152# warn "<$data>\n";
153}
154 208
155sub feed_delinv { 209 $FONTSIZE = int $HEIGHT / 40;
156 my ($self, $data) = @_;
157}
158 210
159sub feed_item2 { 211 #############################################################################
160 my ($self, $data) = @_;
161}
162 212
163sub feed_map1a { 213 $DEBUG_STATUS = new CFClient::UI::Label padding => 0;
164 my ($self, $data) = @_; 214 $CFClient::UI::TOPLEVEL->add ($DEBUG_STATUS);
215
216 $STATUS_LINE = new CFClient::UI::Label
217 padding => 0,
218 y => $HEIGHT * 49 / 50 - $FONTSIZE;
219 $CFClient::UI::TOPLEVEL->add ($STATUS_LINE);
165 220
166 my $map = $self->{map} ||= []; 221 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
222 padding => 0,
223 y => $HEIGHT * 49 / 50,
224 height => $HEIGHT / 50,
225 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
226 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE);
167 227
168 my @dirty; 228 $MAPWIDGET = new CFClient::UI::MapWidget;
169 my ($coord, $x, $y, $darkness, $fa, $fb, $fc, $cell); 229 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET);
230 $MAPWIDGET->focus_in;
170 231
171 while (length $data) { 232 config_dialog;
172 $coord = unpack "n", substr $data, 0, 2, ""; 233}
173 234
174 $x = ($coord >> 10) & 63; 235sub destroy_screen {
175 $y = ($coord >> 4) & 63; 236 $CFClient::UI::TOPLEVEL->{children} = [];
237 undef $SDL_ACTIVE;
238 undef $SDL_EV;
239 SDL::Quit;
240}
176 241
177 $cell = $map->[$x][$y] ||= []; 242my %animate_object;
243my $animate_timer;
178 244
179 $cell->[3] = unpack "C", substr $data, 0, 1, "" 245my $want_refresh;
180 if $coord & 8; 246my $can_refresh;
181 $cell->[0] = unpack "n", substr $data, 0, 2, ""
182 if $coord & 4;
183 $cell->[1] = unpack "n", substr $data, 0, 2, ""
184 if $coord & 2;
185 $cell->[2] = unpack "n", substr $data, 0, 2, ""
186 if $coord & 1;
187 247
188 @$cell = () 248my $fps = 9;
189 unless $coord & 15;
190 249
191 push @dirty, [$x, $y]; 250sub force_refresh {
251 $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05;
252 debug sprintf "%3.2f", $fps;
253
254 $want_refresh = 0;
255 $can_refresh = 0;
256
257 glViewport 0, 0, $WIDTH, $HEIGHT;
258
259 glMatrixMode GL_PROJECTION;
260 glLoadIdentity;
261 glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000;
262 glMatrixMode GL_MODELVIEW;
263 glLoadIdentity;
264
265 glClearColor +($CFG->{fow_intensity}) x 3, 1;
266 glClear GL_COLOR_BUFFER_BIT;
267
268 $CFClient::UI::TOPLEVEL->draw;
269
270 SDL::GLSwapBuffers;
271
272 $LAST_REFRESH = $NOW;
273}
274
275my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub {
276 $NOW = time;
277
278 ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->()
279 while $SDL_EV->poll;
280
281 if (%animate_object) {
282 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object;
283 $want_refresh++;
192 } 284 }
193 285
194 $self->map_update (\@dirty); 286 if ($want_refresh) {
195} 287 force_refresh;
196
197sub feed_map_scroll {
198 my ($self, $data) = @_;
199
200 my ($dx, $dy) = split / /, $data;
201
202 my $map = $self->{map} ||= [];
203
204 $self->{mapx} += $dx;
205 $self->{mapy} += $dy;
206
207 if ($dx > 0) {
208 unshift @$_, ([]) x $dx for @$map;
209 } elsif ($dx < 0) {
210 splice @$_, 0, -$dx, () for @$map;
211 }
212
213 if ($dy > 0) {
214 unshift @$map, ([]) x $dy;
215 } elsif ($dy < 0) {
216 splice @$map, 0, -$dy, ();
217 }
218
219 $self->map_scroll ($dx, $dy);
220}
221
222sub feed_newmap {
223 my ($self) = @_;
224
225 $self->{map} = [];
226 $self->{mapx} = 0;
227 $self->{mapy} = 0;
228
229 $self->map_clear;
230}
231
232sub feed_image {
233 my ($self, $data) = @_;
234
235 my ($face, $len, $data) = unpack "NNa*", $data;
236
237 $self->{face}[$face]{image} = $data;
238
239 $self->face_update ($face, $self->{face}[$face]);
240}
241
242sub map_clear { }
243sub map_update { }
244sub map_scroll { }
245
246sub face_update { }
247
248sub send {
249 my ($self, $data) = @_;
250
251 $data = pack "na*", length $data, $data;
252
253 syswrite $self->{fh}, $data;
254}
255
256package conn;
257
258@ISA = Crossfire::Protocol::;
259
260sub map_update {
261 my ($self, $dirty) = @_;
262
263 for (@$dirty) {
264 my ($x, $y) = @$_;
265
266 my $px = $x * 32;
267 my $py = $y * 32;
268
269 my $dst = new SDL::Rect -x => $px, -y => $py, -width => 32, -height => 32;
270
271 my $cell = $self->{map}[$x][$y];
272
273 if ($cell) {
274 $cell->[0] or $map_surface->fill ($dst, new SDL::Color -r => 0, -g => 0, -b => 0); # is_floor is opaque, I hope
275
276 for my $num (grep $_, $cell->[0], $cell->[1], $cell->[2]) {
277 my $surface = $self->{face}[$num]{surface} ||= do {
278 $self->send ("askface $num");
279
280 # TODO: fog of "war"
281 my $surface = new SDL::Surface
282 -flags => SDL::SDL_HWSURFACE | SDL::SDL_ANYFORMAT | SDL::SDL_HWACCEL | SDL::SDL_ASYNCBLIT,
283 -width => 32,
284 -height => 32,
285 -depth => 32;
286
287 $surface->fill (0, new SDL::Color -r => 128, -g => 128, -b => 128);
288
289 $surface
290 };
291
292 $surface->blit (0, $map_surface, $dst);
293 }
294 } else { 288 } else {
295 $map_surface->fill ($dst, new SDL::Color -r => 0, -g => 0, -b => 0); 289 $can_refresh = 1;
296 }
297 }
298
299 ::redraw;
300}
301
302sub map_scroll {
303 my ($self, $dx, $dy) = @_;
304
305 ::redraw;
306}
307
308sub map_clear {
309 my ($self) = @_;
310
311 $map_surface = new SDL::Surface
312 -flags => SDL::HWSURFACE,
313 -width => $self->{mapw} * 32,
314 -height => $self->{maph} * 32,
315 -depth => 32;
316
317 SDL::SetClipRect $$map_surface, 0;
318 $map_surface->fill (0, new SDL::Color -r => 0, -g => 0, -b => 0);
319
320 ::redraw;
321}
322
323sub face_update {
324 my ($self, $num, $face) = @_;
325
326 warn "up face $self,$num,$face\n";#d#
327 #TODO
328 open my $fh, ">:raw", "/tmp/x~";
329 syswrite $fh, $face->{image};
330 close $fh;
331
332 $face->{surface} = (new SDL::Surface -name => "/tmp/x~")->display_format;
333
334 unlink "/tmp/x~";
335
336 my @dirty;
337
338 for my $x (0..$self->{mapw} - 1) {
339 for my $y (0..$self->{maph} - 1) {
340 push @dirty, [$x, $y]
341 if grep $_ == $num, @{$self->{map}[$x][$y] || []};
342 }
343 }
344 $self->map_update (\@dirty);
345}
346
347package main;
348
349#############################################################################
350
351use Event;
352
353$conn = new conn
354 host => "cf.schmorp.de",
355 port => 13327;
356
357Event->timer (after => 0, interval => 1/20, hard => 1, cb => sub {
358 while ($ev->poll) {
359 ($ev_cb{$ev->type} || sub { warn "unhandled event ", $ev->type })->();
360 } 290 }
361}); 291});
362 292
293sub refresh {
294 $want_refresh++;
295}
296
297sub animation_start {
298 my ($widget) = @_;
299 $animate_object{$widget} = $widget;
300}
301
302sub animation_stop {
303 my ($widget) = @_;
304 delete $animate_object{$widget};
305}
306
307@conn::ISA = Crossfire::Protocol::;
308
309sub conn::user_send {
310 my ($self, $command) = @_;
311
312 $self->send ($command);
313 status $command;
314}
315
316sub conn::map_update {
317 my ($self, $dirty) = @_;
318
319 $MAPWIDGET->update;
320}
321
322sub conn::map_scroll {
323 my ($self, $dx, $dy) = @_;
324
325# refresh;
326}
327
328sub conn::map_clear {
329 my ($self) = @_;
330
331# refresh;
332}
333
334sub conn::face_find {
335 my ($self, $face) = @_;
336
337 $FACECACHE->{"$face->{chksum},$face->{name}"}
338}
339
340sub conn::face_update {
341 my ($self, $face) = @_;
342
343 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image};
344
345 $face->{texture} = new_from_image CFClient::Texture delete $face->{image};
346}
347
348sub conn::query {
349 my ($self, $flags, $prompt) = @_;
350
351 warn "<<<<QUERY:$flags:$prompt>>>\n";#d#
352}
353
354%SDL_CB = (
355 SDL_QUIT() => sub {
356 Event::unloop -1;
357 },
358 SDL_VIDEORESIZE() => sub {
359 },
360 SDL_VIDEOEXPOSE() => sub {
361 refresh;
362 },
363 SDL_KEYDOWN() => sub {
364 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) {
365 # alt-enter
366 $FULLSCREEN = !$FULLSCREEN;
367 destroy_screen;
368 init_screen;
369 } else {
370 CFClient::UI::feed_sdl_key_down_event ($SDL_EV);
371 }
372 },
373 SDL_KEYUP() => sub {
374 CFClient::UI::feed_sdl_key_up_event ($SDL_EV);
375 },
376 SDL_MOUSEMOTION() => sub {
377 CFClient::UI::feed_sdl_motion_event ($SDL_EV);
378 },
379 SDL_MOUSEBUTTONDOWN() => sub {
380 CFClient::UI::feed_sdl_button_down_event ($SDL_EV);
381 },
382 SDL_MOUSEBUTTONUP() => sub {
383 CFClient::UI::feed_sdl_button_up_event ($SDL_EV);
384 },
385 SDL_ACTIVEEVENT() => sub {
386# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
387 },
388);
389
390#############################################################################
391
392CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
393
394my %DEF_CFG = (
395 width => 640,
396 height => 480,
397 fast => 0,
398 fow_intensity => 0.45,
399 fullscreen => 0,
400 sdl_mode => 0,
401 mapsize => 100,
402 host => "crossfire.schmorp.de",
403 port => 13327,
404);
405
406while (my ($k, $v) = each %DEF_CFG) {
407 $CFG->{$k} = $v unless exists $CFG->{$k};
408}
409
410sdl_init;
411
412@SDL_MODES = reverse map [SDL::RectW ($_), SDL::RectH ($_)],
413 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL };
414
415@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
416
417$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
418
419init_screen;
420
421{
422 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf);
423
424 CFClient::add_font $_ for @fonts;
425 CFClient::set_font $fonts[0];
426}
427
428$FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {};
429
363Event::loop; 430Event::loop;
364 431
432Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces";
365 433

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines