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

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.222 by root, Sun Nov 4 02:14:11 2012 UTC vs.
Revision 1.227 by root, Tue Nov 20 14:32:12 2012 UTC

34 }, 34 },
35 ); 35 );
36 36
37 $self->update_fx_want; 37 $self->update_fx_want;
38 38
39 my $guard = $self->addme_guard; 39 my $exp_guard = $self->addme_guard;
40 my $skl_guard = $self->addme_guard;
41 my $spl_guard = $self->addme_guard;
40 $self->send_exti_req (resource => "exp_table", sub { 42 $self->send_exti_req (resource => qw(exp_table skill_info spell_paths), sub {
41 my ($idx) = @_; 43 my ($exp, $skl, $spl) = @_;
42 44
43 $self->register_face_handler ($idx, sub { 45 $self->register_face_handler ($exp, sub {
44 my ($face) = @_; 46 my ($face) = @_;
45 47
46 undef $guard; 48 undef $exp_guard;
47 $self->{exp_table} = $self->{json_coder}->decode (delete $face->{data}); 49 $self->{exp_table} = $self->{json_coder}->decode (delete $face->{data});
48 $_->() for values %{ $self->{on_exp_update} }; 50 $_->() for values %{ $self->{on_exp_update} };
49 }); 51 });
50 52
51 ()
52 });
53
54 my $guard = $self->addme_guard;
55 $self->send_exti_req (resource => "skill_info", sub {
56 my ($idx) = @_;
57
58 $self->register_face_handler ($idx, sub { 53 $self->register_face_handler ($skl, sub {
59 my ($face) = @_; 54 my ($face) = @_;
60 55
61 undef $guard; 56 undef $skl_guard;
62 my $info = $self->{json_coder}->decode (delete $face->{data}); 57 my $info = $self->{json_coder}->decode (delete $face->{data});
63 $self->{skill_info} = { map { CS_STAT_SKILLINFO + $_ => $info->[$_][0] } 0 .. $#$info }; 58 $self->{skill_info} = { map { CS_STAT_SKILLINFO + $_ => $info->[$_][0] } 0 .. $#$info };
64 }); 59 });
65 60
66 ()
67 });
68
69 my $guard = $self->addme_guard;
70 $self->send_exti_req (resource => "spell_paths", sub {
71 my ($idx) = @_;
72
73 $self->register_face_handler ($idx, sub { 61 $self->register_face_handler ($spl, sub {
74 my ($face) = @_; 62 my ($face) = @_;
75 63
76 undef $guard; 64 undef $spl_guard;
77 my $info = $self->{json_coder}->decode (delete $face->{data}); 65 my $info = $self->{json_coder}->decode (delete $face->{data});
78 $self->{spell_paths} = { map { (1 << $_) => $info->[$_][0] } 0 .. $#$info }; 66 $self->{spell_paths} = { map { (1 << $_) => $info->[$_][0] } 0 .. $#$info };
79 }); 67 });
80 68
81 () 69 ()
82 }); 70 });
83 71
84 $self->{map_widget}->clr_commands; 72 $::COMPLETER->reset;
85
86 my @cmd_help = map {
87 $_->[DC::Pod::N_KW][0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
88 or die "unparseable command help: $_->[DC::Pod::N_KW][0]";
89
90 my $cmd = $1;
91 my @args = split /\|/, $2;
92 @args = (".*") unless @args;
93
94 my (undef, @par) = DC::Pod::section_of $_;
95 my $text = DC::Pod::as_label @par;
96
97 $_ = $_ eq ".*" ? "" : " $_"
98 for @args;
99
100 map ["$cmd$_", $text],
101 sort { (length $a) <=> (length $b) }
102 @args
103 } sort { $a->[DC::Pod::N_PAR] <=> $b->[DC::Pod::N_PAR] }
104 DC::Pod::find command => "*";
105 73
106 $self->{json_coder} 74 $self->{json_coder}
107 ->convert_blessed 75 ->convert_blessed
108 ->filter_json_single_key_object ("\fw" => sub { 76 ->filter_json_single_key_object ("\fw" => sub {
109 $self->{widget}{$_[0]} 77 $self->{widget}{$_[0]}
126 $::INV->clear; 94 $::INV->clear;
127 $::INVR->clear; 95 $::INVR->clear;
128 $::INVR_HB->clear; 96 $::INVR_HB->clear;
129 $::FLOORBOX->clear; 97 $::FLOORBOX->clear;
130 }); 98 });
131
132 $self->{map_widget}->add_command (@$_)
133 for @cmd_help;
134 99
135 { 100 {
136 $self->{dialogue} = my $tex = $TEX_DIALOGUE; 101 $self->{dialogue} = my $tex = $TEX_DIALOGUE;
137 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 102 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}});
138 } 103 }
163 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; 128 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}";
164 129
165 $self 130 $self
166} 131}
167 132
133 #$self->send_exti_req (nickmon => 1, sub { use Data::Dump; ddx \@_ });#d#
134#sub ext_nicklist { shift; use Data::Dump; ddx \@_; } #d#
135
168sub update_fx_want { 136sub update_fx_want {
169 my ($self) = @_; 137 my ($self) = @_;
170 138
171 $self->send_exti_msg (fx_want => { 139 $self->send_exti_msg (fx_want => {
172 3 => !!$::CFG->{bgm_enable}, # FT_MUSIC 140 3 => !!$::CFG->{bgm_enable}, # FT_MUSIC
193} 161}
194 162
195sub ext_ambient_music { 163sub ext_ambient_music {
196 my ($self, $songs) = @_; 164 my ($self, $songs) = @_;
197 &::audio_music_set_ambient ($songs); 165 &::audio_music_set_ambient ($songs);
166}
167
168sub ext_command_list {
169 my ($self, @faces) = @_;
170
171 my $handler = $self->{command_facehandler} = {};
172 my $commands = $::COMPLETER->{command_list} = {};
173
174 for my $idx (@faces) {
175 $handler->{$idx} = $self->register_face_handler ($idx, sub {
176 my ($face) = @_;
177
178 $commands->{$idx} =
179 $face->{cache} ||= $self->{json_coder}->decode ($face->{data});
180 });
181 }
198} 182}
199 183
200############################################################################# 184#############################################################################
201 185
202sub widget_associate { 186sub widget_associate {
1115 tan => 12, 1099 tan => 12,
1116); 1100);
1117 1101
1118our @CF_COLOR = ( 1102our @CF_COLOR = (
1119 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], 1103 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
1120 [1.00, 1.00, 1.00], 1104 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
1121 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] 1105 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55],
1122 [1.00, 0.00, 0.00], 1106 [1.00, 0.00, 0.00],
1123 [1.00, 0.54, 0.00], 1107 [1.00, 0.54, 0.00],
1124 [0.11, 0.56, 1.00], 1108 [0.11, 0.56, 1.00],
1125 [0.93, 0.46, 0.00], 1109 [0.93, 0.46, 0.00],
1126 [0.18, 0.54, 0.34], 1110 [0.18, 0.54, 0.34],
1177 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; 1161 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g;
1178 $spell->{message} =~ s/\n+$//; 1162 $spell->{message} =~ s/\n+$//;
1179 $spell->{message} ||= "Server did not provide a description for this spell."; 1163 $spell->{message} ||= "Server did not provide a description for this spell.";
1180 1164
1181 $::SPELL_LIST->add_spell ($spell); 1165 $::SPELL_LIST->add_spell ($spell);
1182 1166 delete $::COMPLETER->{command_list}{spells};
1183 $self->{map_widget}->add_command ("invoke $spell->{name}", DC::asxml $spell->{message});
1184 $self->{map_widget}->add_command ("cast $spell->{name}", DC::asxml $spell->{message});
1185} 1167}
1186 1168
1187sub spell_delete { 1169sub spell_delete {
1188 my ($self, $spell) = @_; 1170 my ($self, $spell) = @_;
1189 1171
1190 $::SPELL_LIST->remove_spell ($spell); 1172 $::SPELL_LIST->remove_spell ($spell);
1173 delete $::COMPLETER->{command_list}{spells};
1191} 1174}
1192 1175
1193sub setup { 1176sub setup {
1194 my ($self, $setup) = @_; 1177 my ($self, $setup) = @_;
1195 1178
1218} 1201}
1219 1202
1220sub eof { 1203sub eof {
1221 my ($self) = @_; 1204 my ($self) = @_;
1222 1205
1223 $self->{map_widget}->clr_commands; 1206 $::COMPLETER->reset;
1224 1207
1225 ::stop_game (); 1208 ::stop_game ();
1226} 1209}
1227 1210
1228sub update_floorbox { 1211sub update_floorbox {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines