ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/doc/doc2messages.xsl
(Generate patch)

Comparing kgsueme/doc/doc2messages.xsl (file contents):
Revision 1.3 by pcg, Thu Jun 5 10:40:17 2003 UTC vs.
Revision 1.7 by pcg, Fri Jun 13 22:11:50 2003 UTC

12 12
13# See doc/protocol.xml and doc/doc2messages.xsl 13# See doc/protocol.xml and doc/doc2messages.xsl
14 14
15package KGS::Messages; 15package KGS::Messages;
16 16
17use KGS::Constants; # REPLACE by parsed file, too
18
17use strict; 19use strict;
18 20
19our %type; 21our %type;
20our %send; 22our %send;
21our %recv; 23our %recv;
99sub enc_U64 { 101sub enc_U64 {
100 enc_U32 $_[0] & 0xffffffff; 102 enc_U32 $_[0] & 0xffffffff;
101 enc_U32 +($_[0] >> 32) & 0xffffffff; 103 enc_U32 +($_[0] >> 32) & 0xffffffff;
102} 104}
103 105
106sub enc_I16 {
107 enc_U16 unpack "S", pack "s", $_[0];
108}
109
104sub enc_I32 { 110sub enc_I32 {
105 enc_U32 unpack "I", pack "i", $_[0]; 111 enc_U32 unpack "I", pack "i", $_[0];
106} 112}
107 113
108sub enc_DATA { 114sub enc_DATA {
112 118
113sub enc_STRING { 119sub enc_STRING {
114 # should use encode for speed and clarity ;) 120 # should use encode for speed and clarity ;)
115 $data .= pack "v*", map ord, split //, $_[0]; 121 $data .= pack "v*", map ord, split //, $_[0];
116} 122}
123
124sub enc_password {
125 require Math::BigInt; # I insist on 32-bit-perl.. should use C
126 # $hash must be 64 bit
127 my $hash = new Math::BigInt;
128 $hash = $hash * 1055 + ord for split //, $_[0];
129 enc_U64 $hash;
130}
131
117]]> 132]]>
118 133
119############################################################################# 134#############################################################################
120# types 135# types
121<xsl:apply-templates select="descendant::type"/> 136<xsl:apply-templates select="descendant::type"/>
182 197
183 } elsif ($type == 15 || $type == 16) { 198 } elsif ($type == 15 || $type == 16) {
184 push @r, [set_timer => $type - 15, dec_time, dec_U16]; 199 push @r, [set_timer => $type - 15, dec_time, dec_U16];
185 200
186 } elsif ($type == 17 || $type == 18) { 201 } elsif ($type == 17 || $type == 18) {
187 push @r, [score => $type - 17, dec_score]; 202 push @r, [score => $type - 17, dec_score16];
188 203
189 } elsif ($type == 19) { 204 } elsif ($type == 19) {
190 push @r, [result => dec_result]; 205 push @r, [result => dec_result]; # not certain
191 206
192 } elsif ($type == 30) { 207 } elsif ($type == 30) {
193 push @r, [active_player => dec_U8]; 208 push @r, [active_player => dec_U8];
194 209
195 } elsif ($type == 0) { # label(?) 210 } elsif ($type == 0) { # label(?)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines