40 end; |
40 end; |
41 |
41 |
42 var Strs: array[0 .. MaxStrIndex] of TChatLine; |
42 var Strs: array[0 .. MaxStrIndex] of TChatLine; |
43 lastStr: Longword = 0; |
43 lastStr: Longword = 0; |
44 visibleCount: Longword = 0; |
44 visibleCount: Longword = 0; |
45 |
45 |
46 InputStr: TChatLine; |
46 InputStr: TChatLine; |
47 InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char |
47 InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char |
48 |
48 |
49 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean); |
49 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean); |
50 var strSurface, resSurface: PSDL_Surface; |
50 var strSurface, resSurface: PSDL_Surface; |
132 procedure AcceptChatString(s: shortstring); |
132 procedure AcceptChatString(s: shortstring); |
133 var i: TWave; |
133 var i: TWave; |
134 |
134 |
135 begin |
135 begin |
136 // "Make hedgehog say something" |
136 // "Make hedgehog say something" |
137 if (s[1] = '"') and (s[Length(s)] = '"') then |
137 if (s[1] = '"') and (s[Length(s)] = '"') then |
138 begin |
138 begin |
139 if CurrentTeam^.ExtDriven then |
139 if CurrentTeam^.ExtDriven then |
140 ParseCommand('/say ' + copy(s, 2, Length(s)-2), true) |
140 ParseCommand('/say ' + copy(s, 2, Length(s)-2), true) |
141 else |
141 else |
142 ParseCommand('/hogsay '#1 + copy(s, 2, Length(s)-2), true); |
142 ParseCommand('/hogsay '#1 + copy(s, 2, Length(s)-2), true); |
143 exit |
143 exit |
144 end; |
144 end; |
145 // 'Make hedgehog think something' |
145 // 'Make hedgehog think something' |
146 if (s[1] = '''') and (s[Length(s)] = '''') then |
146 if (s[1] = '''') and (s[Length(s)] = '''') then |
147 begin |
147 begin |
148 if CurrentTeam^.ExtDriven then |
148 if CurrentTeam^.ExtDriven then |
149 ParseCommand('/say ' + copy(s, 2, Length(s)-2), true) |
149 ParseCommand('/say ' + copy(s, 2, Length(s)-2), true) |
150 else |
150 else |
151 ParseCommand('/hogsay '#2 + copy(s, 2, Length(s)-2), true); |
151 ParseCommand('/hogsay '#2 + copy(s, 2, Length(s)-2), true); |
152 exit |
152 exit |
153 end; |
153 end; |
154 // -Make hedgehog yell something- |
154 // -Make hedgehog yell something- |
155 if (s[1] = '-') and (s[Length(s)] = '-') then |
155 if (s[1] = '-') and (s[Length(s)] = '-') then |
156 begin |
156 begin |
157 if CurrentTeam^.ExtDriven then |
157 if CurrentTeam^.ExtDriven then |
158 ParseCommand('/say ' + copy(s, 2, Length(s)-2), true) |
158 ParseCommand('/say ' + copy(s, 2, Length(s)-2), true) |
159 else |
159 else |
160 ParseCommand('/hogsay '#3 + copy(s, 2, Length(s)-2), true); |
160 ParseCommand('/hogsay '#3 + copy(s, 2, Length(s)-2), true); |
192 exit |
192 exit |
193 end; |
193 end; |
194 if (s[1] = '/') and (copy(s, 1, 4) <> '/me ') then |
194 if (s[1] = '/') and (copy(s, 1, 4) <> '/me ') then |
195 begin |
195 begin |
196 if CurrentTeam^.ExtDriven then exit; |
196 if CurrentTeam^.ExtDriven then exit; |
197 |
197 |
198 for i:= Low(TWave) to High(TWave) do |
198 for i:= Low(TWave) to High(TWave) do |
199 if (s = Wavez[i].cmd) then |
199 if (s = Wavez[i].cmd) then |
200 begin |
200 begin |
201 ParseCommand('/taunt ' + char(i), true); |
201 ParseCommand('/taunt ' + char(i), true); |
202 exit |
202 exit |
249 else |
249 else |
250 if (Key < $80) then btw:= 1 |
250 if (Key < $80) then btw:= 1 |
251 else if (Key < $800) then btw:= 2 |
251 else if (Key < $800) then btw:= 2 |
252 else if (Key < $10000) then btw:= 3 |
252 else if (Key < $10000) then btw:= 3 |
253 else btw:= 4; |
253 else btw:= 4; |
254 |
254 |
255 utf8:= ''; |
255 utf8:= ''; |
256 |
256 |
257 for i:= btw downto 2 do |
257 for i:= btw downto 2 do |
258 begin |
258 begin |
259 utf8:= char((Key or $80) and $BF) + utf8; |
259 utf8:= char((Key or $80) and $BF) + utf8; |
260 Key:= Key shr 6 |
260 Key:= Key shr 6 |
261 end; |
261 end; |
262 |
262 |
263 utf8:= char(Key or firstByteMark[btw]) + utf8; |
263 utf8:= char(Key or firstByteMark[btw]) + utf8; |
264 |
264 |
265 if byte(InputStr.s[0]) + btw > 240 then exit; |
265 if byte(InputStr.s[0]) + btw > 240 then exit; |
266 |
266 |
267 InputStrL[byte(InputStr.s[0]) + btw]:= InputStr.s[0]; |
267 InputStrL[byte(InputStr.s[0]) + btw]:= InputStr.s[0]; |