… | |
… | |
42 | use List::Util (); |
42 | use List::Util (); |
43 | use IO::AIO (); |
43 | use IO::AIO (); |
44 | use Coro::AIO (); |
44 | use Coro::AIO (); |
45 | use AnyEvent::AIO (); |
45 | use AnyEvent::AIO (); |
46 | |
46 | |
|
|
47 | use Deliantra::Util (); |
47 | use Deliantra::Protocol::Constants (); |
48 | use Deliantra::Protocol::Constants (); |
48 | |
49 | |
49 | =item shorten $string[, $maxlength] |
50 | =item shorten $string[, $maxlength] |
50 | |
51 | |
51 | =cut |
52 | =cut |
… | |
… | |
60 | local $_ = $_[0]; |
61 | local $_ = $_[0]; |
61 | |
62 | |
62 | s/&/&/g; |
63 | s/&/&/g; |
63 | s/>/>/g; |
64 | s/>/>/g; |
64 | s/</</g; |
65 | s/</</g; |
|
|
66 | |
|
|
67 | $_ |
|
|
68 | } |
|
|
69 | |
|
|
70 | sub sanitise_cfxml($) { |
|
|
71 | local $_ = shift; |
|
|
72 | |
|
|
73 | # we now weed out all tags we do not support |
|
|
74 | s{ <(?! /?i> | /?u> | /?b> | /?big | /?small | /?s | /?tt | fg\ | /fg>) |
|
|
75 | }{ |
|
|
76 | "<" |
|
|
77 | }gex; |
|
|
78 | |
|
|
79 | # now all entities |
|
|
80 | s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&/g; |
|
|
81 | |
|
|
82 | # handle some elements |
|
|
83 | s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; |
|
|
84 | s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; |
|
|
85 | |
|
|
86 | s/\s+$//; |
65 | |
87 | |
66 | $_ |
88 | $_ |
67 | } |
89 | } |
68 | |
90 | |
69 | sub background(&;&) { |
91 | sub background(&;&) { |
… | |
… | |
212 | |
234 | |
213 | sub load_cfg() { |
235 | sub load_cfg() { |
214 | if (-e "$Deliantra::VARDIR/client.cf") { |
236 | if (-e "$Deliantra::VARDIR/client.cf") { |
215 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
237 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
216 | } else { |
238 | } else { |
217 | $::CFG = {}; |
239 | $::CFG = { cfg_schema => 1, db_schema => 1 }; |
218 | } |
240 | } |
219 | } |
241 | } |
220 | |
242 | |
221 | sub save_cfg() { |
243 | sub save_cfg() { |
222 | write_cfg "$Deliantra::VARDIR/client.cf"; |
244 | write_cfg "$Deliantra::VARDIR/client.cf"; |
… | |
… | |
263 | logview_max_par => 1000, |
285 | logview_max_par => 1000, |
264 | shift_fire_stop => 0, |
286 | shift_fire_stop => 0, |
265 | uitheme => "wood", |
287 | uitheme => "wood", |
266 | map_shift_x => -24, # arbitrary |
288 | map_shift_x => -24, # arbitrary |
267 | map_shift_y => +24, # arbitrary |
289 | map_shift_y => +24, # arbitrary |
268 | #db_schema => 0, |
|
|
269 | ); |
290 | ); |
270 | |
291 | |
271 | while (my ($k, $v) = each %DEF_CFG) { |
292 | while (my ($k, $v) = each %DEF_CFG) { |
272 | $::CFG->{$k} = $v unless exists $::CFG->{$k}; |
293 | $::CFG->{$k} = $v unless exists $::CFG->{$k}; |
|
|
294 | } |
|
|
295 | |
|
|
296 | if ($::CFG->{cfg_schema} < 1) { |
|
|
297 | for my $profile (values %{ $::CFG->{profile} }) { |
|
|
298 | $profile->{password} = unpack "H*", Deliantra::Util::hash_pw $profile->{password}; |
|
|
299 | } |
|
|
300 | $::CFG->{cfg_schema} = 1; |
273 | } |
301 | } |
274 | } |
302 | } |
275 | |
303 | |
276 | sub http_proxy { |
304 | sub http_proxy { |
277 | my @proxy = win32_proxy_info; |
305 | my @proxy = win32_proxy_info; |