changeset 4377 | 43945842da0c |
parent 4376 | 9654205a9424 |
child 4389 | d1c65b60cd68 |
4376:9654205a9424 | 4377:43945842da0c |
---|---|
26 hiTicks: Word; |
26 hiTicks: Word; |
27 |
27 |
28 procedure initModule; |
28 procedure initModule; |
29 procedure freeModule; |
29 procedure freeModule; |
30 |
30 |
31 procedure OutError(Msg: shortstring; isFatalError: boolean); |
|
32 procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline; |
|
33 procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
34 |
|
31 procedure SendIPC(s: shortstring); |
35 procedure SendIPC(s: shortstring); |
32 procedure SendIPCXY(cmd: char; X, Y: SmallInt); |
36 procedure SendIPCXY(cmd: char; X, Y: SmallInt); |
33 procedure SendIPCRaw(p: pointer; len: Longword); |
37 procedure SendIPCRaw(p: pointer; len: Longword); |
34 procedure SendIPCAndWaitReply(s: shortstring); |
38 procedure SendIPCAndWaitReply(s: shortstring); |
35 procedure SendIPCTimeInc; |
39 procedure SendIPCTimeInc; |
41 procedure InitIPC; |
45 procedure InitIPC; |
42 procedure CloseIPC; |
46 procedure CloseIPC; |
43 procedure NetGetNextCmd; |
47 procedure NetGetNextCmd; |
44 |
48 |
45 implementation |
49 implementation |
46 uses uConsole, uConsts, uMisc, uLand, uChat, uTeams, uVariables, uCommands, uUtils; |
50 uses uConsole, uConsts, uLand, uChat, uTeams, uVariables, uCommands, uUtils; |
47 |
51 |
48 type PCmd = ^TCmd; |
52 type PCmd = ^TCmd; |
49 TCmd = packed record |
53 TCmd = packed record |
50 Next: PCmd; |
54 Next: PCmd; |
51 loTime: Word; |
55 loTime: Word; |
63 headcmd: PCmd; |
67 headcmd: PCmd; |
64 lastcmd: PCmd; |
68 lastcmd: PCmd; |
65 |
69 |
66 SendEmptyPacketTicks: LongWord; |
70 SendEmptyPacketTicks: LongWord; |
67 |
71 |
72 |
|
73 procedure OutError(Msg: shortstring; isFatalError: boolean); |
|
74 begin |
|
75 WriteLnToConsole(Msg); |
|
76 if isFatalError then |
|
77 begin |
|
78 SendIPC('E' + GetLastConsoleLine); |
|
79 SDL_Quit; |
|
80 halt(1) |
|
81 end |
|
82 end; |
|
83 |
|
84 procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); |
|
85 begin |
|
86 if not Assert then OutError(Msg, isFatal) |
|
87 end; |
|
88 |
|
89 procedure SDLTry(Assert: boolean; isFatal: boolean); |
|
90 begin |
|
91 if not Assert then OutError(SDL_GetError, isFatal) |
|
92 end; |
|
68 |
93 |
69 function AddCmd(Time: Word; str: shortstring): PCmd; |
94 function AddCmd(Time: Word; str: shortstring): PCmd; |
70 var command: PCmd; |
95 var command: PCmd; |
71 begin |
96 begin |
72 new(command); |
97 new(command); |
209 var buf: shortstring; |
234 var buf: shortstring; |
210 begin |
235 begin |
211 buf:= 'i' + stc[sit] + s; |
236 buf:= 'i' + stc[sit] + s; |
212 SendIPCRaw(@buf[0], length(buf) + 1) |
237 SendIPCRaw(@buf[0], length(buf) + 1) |
213 end; |
238 end; |
239 |
|
214 |
240 |
215 procedure SendIPC(s: shortstring); |
241 procedure SendIPC(s: shortstring); |
216 begin |
242 begin |
217 if IPCSock <> nil then |
243 if IPCSock <> nil then |
218 begin |
244 begin |