equal
deleted
inserted
replaced
1 unit uFLNet; |
1 unit uFLNet; |
2 interface |
2 interface |
|
3 uses SDLh; |
3 |
4 |
4 procedure connectOfficialServer; |
5 procedure connectOfficialServer; |
5 |
6 |
6 procedure initModule; |
7 procedure initModule; |
7 procedure freeModule; |
8 procedure freeModule; |
8 procedure sendNet(s: shortstring); |
9 procedure sendNet(s: shortstring); |
9 procedure sendNetLn(s: shortstring); |
10 procedure sendNetLn(s: shortstring); |
|
11 procedure passToNet(data: PByteArray; len: Longword); |
10 |
12 |
11 var isConnected: boolean = false; |
13 var isConnected: boolean = false; |
12 |
14 |
13 implementation |
15 implementation |
14 uses SDLh, uFLIPC, uFLTypes, uFLUICallback, uFLNetTypes, uFLUtils; |
16 uses uFLIPC, uFLUICallback, uFLNetTypes, uFLUtils, uFLTypes; |
15 |
17 |
16 const endCmd: shortstring = #10 + #10; |
18 const endCmd: shortstring = #10 + #10; |
17 |
19 |
18 function getNextChar: char; forward; |
20 function getNextChar: char; forward; |
19 function getCurrChar: char; forward; |
21 function getCurrChar: char; forward; |
376 getLongString:= l |
378 getLongString:= l |
377 end; |
379 end; |
378 |
380 |
379 procedure netSendCallback(p: pointer; msg: PChar; len: Longword); |
381 procedure netSendCallback(p: pointer; msg: PChar; len: Longword); |
380 begin |
382 begin |
381 // W A R N I N G: totally thread-unsafe due to use of sock variable |
383 // FIXME W A R N I N G: totally thread-unsafe due to use of sock variable |
382 SDLNet_TCP_Send(sock, msg, len); |
384 SDLNet_TCP_Send(sock, msg, len); |
383 end; |
385 end; |
384 |
386 |
385 procedure connectOfficialServer; |
387 procedure connectOfficialServer; |
386 begin |
388 begin |
395 |
397 |
396 netReaderThread:= SDL_CreateThread(@netReader, 'netReader', nil); |
398 netReaderThread:= SDL_CreateThread(@netReader, 'netReader', nil); |
397 SDL_DetachThread(netReaderThread) |
399 SDL_DetachThread(netReaderThread) |
398 end; |
400 end; |
399 |
401 |
|
402 |
|
403 procedure passToNet(data: PByteArray; len: Longword); |
|
404 var i: Longword; |
|
405 begin |
|
406 i:= 0; |
|
407 |
|
408 while(i < len) do |
|
409 begin |
|
410 if data^[i + 1] = ord('s') then |
|
411 begin |
|
412 sendUI(mtRoomChatLine, @(data^[i + 2]), data^[i]); |
|
413 //sendChatLine() |
|
414 end; |
|
415 |
|
416 inc(i, data^[i] + 1); |
|
417 end; |
|
418 end; |
|
419 |
400 procedure initModule; |
420 procedure initModule; |
401 begin |
421 begin |
402 sock:= nil; |
422 sock:= nil; |
403 isConnected:= false; |
423 isConnected:= false; |
404 |
424 |