116 IPCSock:= SDLNet_TCP_Open(ipaddr); |
116 IPCSock:= SDLNet_TCP_Open(ipaddr); |
117 SDLTry(IPCSock <> nil, true); |
117 SDLTry(IPCSock <> nil, true); |
118 WriteLnToConsole(msgOK) |
118 WriteLnToConsole(msgOK) |
119 end; |
119 end; |
120 |
120 |
|
121 procedure ParseChatCommand(command: shortstring; message: shortstring; |
|
122 messageStartIndex: Byte); |
|
123 var |
|
124 text: shortstring; |
|
125 begin |
|
126 text:= copy(message, messageStartIndex, |
|
127 Length(message) - messageStartIndex + 1); |
|
128 ParseCommand(command + text, true); |
|
129 WriteLnToConsole(text) |
|
130 end; |
|
131 |
121 procedure ParseIPCCommand(s: shortstring); |
132 procedure ParseIPCCommand(s: shortstring); |
122 var loTicks: Word; |
133 var loTicks: Word; |
123 begin |
134 isProcessed: boolean; |
|
135 begin |
|
136 isProcessed := true; |
124 |
137 |
125 case s[1] of |
138 case s[1] of |
126 '!': begin AddFileLog('Ping? Pong!'); isPonged:= true; end; |
139 '!': begin AddFileLog('Ping? Pong!'); isPonged:= true; end; |
127 '?': SendIPC(_S'!'); |
140 '?': SendIPC(_S'!'); |
128 'e': ParseCommand(copy(s, 2, Length(s) - 1), true); |
141 'e': ParseCommand(copy(s, 2, Length(s) - 1), true); |
138 'V': GameType:= gmtRecord; |
151 'V': GameType:= gmtRecord; |
139 else OutError(errmsgIncorrectUse + ' IPC "T" :' + s[2], true) end; |
152 else OutError(errmsgIncorrectUse + ' IPC "T" :' + s[2], true) end; |
140 'V': begin |
153 'V': begin |
141 if s[2] = '.' then |
154 if s[2] = '.' then |
142 ParseCommand('campvar ' + copy(s, 3, length(s) - 2), true); |
155 ParseCommand('campvar ' + copy(s, 3, length(s) - 2), true); |
143 end |
156 end; |
|
157 'I': ParseCommand('pause server', true); |
|
158 's': if gameType = gmtNet then |
|
159 ParseChatCommand('chatmsg ', s, 2) |
|
160 else |
|
161 isProcessed:= false; |
|
162 'b': if gameType = gmtNet then |
|
163 ParseChatCommand('chatmsg ' + #4, s, 2) |
|
164 else |
|
165 isProcessed:= false; |
144 else |
166 else |
145 loTicks:= SDLNet_Read16(@s[byte(s[0]) - 1]); |
167 isProcessed:= false; |
146 AddCmd(loTicks, s); |
168 end; |
147 AddFileLog('[IPC in] ' + sanitizeCharForLog(s[1]) + ' ticks ' + IntToStr(lastcmd^.loTime)); |
169 |
148 end |
170 if (not isProcessed) then |
|
171 begin |
|
172 loTicks:= SDLNet_Read16(@s[byte(s[0]) - 1]); |
|
173 AddCmd(loTicks, s); |
|
174 AddFileLog('[IPC in] ' + sanitizeCharForLog(s[1]) + ' ticks ' + IntToStr(lastcmd^.loTime)); |
|
175 end |
149 end; |
176 end; |
150 |
177 |
151 procedure IPCCheckSock; |
178 procedure IPCCheckSock; |
152 var i: LongInt; |
179 var i: LongInt; |
153 s: shortstring; |
180 s: shortstring; |
355 ',': ParseCommand('skip', true); |
382 ',': ParseCommand('skip', true); |
356 'c': begin |
383 'c': begin |
357 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
384 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
358 ParseCommand('gencmd ' + s, true); |
385 ParseCommand('gencmd ' + s, true); |
359 end; |
386 end; |
360 's': begin |
387 's': ParseChatCommand('chatmsg ', headcmd^.str, 2); |
361 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
388 'b': ParseChatCommand('chatmsg ' + #4, headcmd^.str, 2); |
362 ParseCommand('chatmsg ' + s, true); |
|
363 WriteLnToConsole(s) |
|
364 end; |
|
365 'b': begin |
|
366 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
|
367 ParseCommand('chatmsg ' + #4 + s, true); |
|
368 WriteLnToConsole(s) |
|
369 end; |
|
370 'F': ParseCommand('teamgone u' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
389 'F': ParseCommand('teamgone u' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
371 'G': ParseCommand('teamback u' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
390 'G': ParseCommand('teamback u' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
372 'f': ParseCommand('teamgone s' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
391 'f': ParseCommand('teamgone s' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
373 'g': ParseCommand('teamback s' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
392 'g': ParseCommand('teamback s' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
374 'N': begin |
393 'N': begin |