summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4ecfaa7)
raw | patch | inline | side by side (parent: 4ecfaa7)
author | fgsfds <pvt.fgsfds@gmail.com> | |
Wed, 16 Aug 2017 20:54:05 +0000 (23:54 +0300) | ||
committer | fgsfds <pvt.fgsfds@gmail.com> | |
Wed, 16 Aug 2017 20:54:05 +0000 (23:54 +0300) |
src/engine/e_fixedbuffer.pas | patch | blob | history | |
src/game/g_game.pas | patch | blob | history | |
src/game/g_net.pas | patch | blob | history | |
src/game/g_nethandler.pas | patch | blob | history |
index 3b6dbf801b28d8208d13ce71236afde048b5bd3e..bc355b1c671884e888ed025927592aec10c88387 100644 (file)
begin
if V = nil then Exit;
N := V^.WritePos;
+ Assert(N <> 0, 'don''t write empty buffers you fuck');
+ if N = 0 then Exit;
e_Buffer_Write(B, Word(N));
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index c46f6e49b4f1d1825e7cc4f03e91b8ae019d357c..718cfc27417387b748d4e4a187c97894b19cd819 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
while (State = 0) and (RawPos < NetEvent.packet^.dataLength) do
begin
Len := e_Raw_Read_Word(Ptr);
+ if Len = 0 then break;
+
MID := e_Raw_Read_Byte(Ptr);
- e_WriteLog(Format('conn recv %U %U', [Len, MID]), MSG_NOTIFY);
+ if NetDump then
+ g_Net_DumpRecvBuffer(NetEvent.packet^.data, NetEvent.packet^.dataLength);
if (MID = NET_MSG_INFO) and (State = 0) then
begin
if newResPath = '' then
begin
g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
- newResPath := g_Res_DownloadWAD(WadName);
+ newResPath := ''; //g_Res_DownloadWAD(WadName);
if newResPath = '' then
begin
g_FatalError(_lc[I_NET_ERR_HASH]);
diff --git a/src/game/g_net.pas b/src/game/g_net.pas
index aad2fb1b2c7cbec07b06b76c492f7b11ee714141..38c0597ec337683556deea2d646fdbffd82f93f6 100644 (file)
--- a/src/game/g_net.pas
+++ b/src/game/g_net.pas
procedure g_Net_SaveBanList();
procedure g_Net_DumpStart();
-procedure g_Net_DumpSendBuffer();
+procedure g_Net_DumpSendBuffer(Buf: pTBuffer);
procedure g_Net_DumpRecvBuffer(Buf: penet_uint8; Len: LongWord);
procedure g_Net_DumpEnd();
else
enet_peer_send(Peer, Ch, P);
end;
+ if NetDump then g_Net_DumpSendBuffer(B);
e_Buffer_Clear(B);
end;
end;
ID := Byte(NetEvent.peer^.data^);
if ID > High(NetClients) then Exit;
TC := @NetClients[ID];
+ if NetDump then
+ g_Net_DumpRecvBuffer(NetEvent.packet^.data, NetEvent.packet^.dataLength);
g_Net_HostMsgHandler(TC, NetEvent.packet);
end;
case NetEvent.kind of
ENET_EVENT_TYPE_RECEIVE:
begin
+ if NetDump then
+ g_Net_DumpRecvBuffer(NetEvent.packet^.data, NetEvent.packet^.dataLength);
g_Net_ClientMsgHandler(NetEvent.packet);
end;
case NetEvent.kind of
ENET_EVENT_TYPE_RECEIVE:
begin
+ if NetDump then
+ g_Net_DumpRecvBuffer(NetEvent.packet^.data, NetEvent.packet^.dataLength);
g_Net_ClientLightMsgHandler(NetEvent.packet);
end;
OuterLoop: Boolean;
MID: Byte;
Ptr: Pointer;
+ Len: LongWord;
msgStream: TMemoryStream;
begin
FillChar(downloadEvent, SizeOf(downloadEvent), 0);
begin
if (downloadEvent.kind = ENET_EVENT_TYPE_RECEIVE) and (downloadEvent.packet^.dataLength > 2) then
begin
+ Len := PWord(downloadEvent.packet^.data)^;
+ if Len = 0 then break;
Ptr := downloadEvent.packet^.data + 2; // skip length
MID := Byte(Ptr^);
NetDumpFile := createDiskFile(NETDUMP_FILENAME + '_client');
end;
-procedure g_Net_DumpSendBuffer();
+procedure g_Net_DumpSendBuffer(Buf: pTBuffer);
begin
+ writeInt(NetDumpFile, Byte($BA));
+ writeInt(NetDumpFile, Byte($BE));
+ writeInt(NetDumpFile, Byte($FF));
writeInt(NetDumpFile, gTime);
- writeInt(NetDumpFile, LongWord(NetOut.WritePos));
- writeInt(NetDumpFile, Byte(1));
- NetDumpFile.WriteBuffer(NetOut.Data[0], NetOut.WritePos);
+ writeInt(NetDumpFile, Byte($FF));
+ writeInt(NetDumpFile, LongWord(Buf^.WritePos));
+ writeInt(NetDumpFile, Byte($FF));
+ NetDumpFile.WriteBuffer(Buf^.Data[0], Buf^.WritePos);
end;
procedure g_Net_DumpRecvBuffer(Buf: penet_uint8; Len: LongWord);
begin
if (Buf = nil) or (Len = 0) then Exit;
+ writeInt(NetDumpFile, Byte($B0));
+ writeInt(NetDumpFile, Byte($0B));
+ writeInt(NetDumpFile, Byte($FF));
writeInt(NetDumpFile, gTime);
+ writeInt(NetDumpFile, Byte($FF));
writeInt(NetDumpFile, Len);
- writeInt(NetDumpFile, Byte(0));
+ writeInt(NetDumpFile, Byte($FF));
NetDumpFile.WriteBuffer(Buf^, Len);
end;
index b8d7c8040b1cd58cff7f22eb5f45b7d77b550c08..67b50dd928a87af7ac0e0ac768a39f61e64da93c 100644 (file)
while RawPos < P^.dataLength do
begin
Len := e_Raw_Read_Word(B);
+ if Len = 0 then break;
+
MID := e_Raw_Read_Byte(B);
case MID of
NET_MSG_CHAT: MC_RECV_Chat(B);
while RawPos < P^.dataLength do
begin
Len := e_Raw_Read_Word(B);
+ if Len = 0 then break;
+
MID := e_Raw_Read_Byte(B);
case MID of
NET_MSG_GEVENT: MC_RECV_GameEvent(B);
while RawPos < P^.dataLength do
begin
Len := e_Raw_Read_Word(B);
+ if Len = 0 then break;
+
MID := e_Raw_Read_Byte(B);
case MID of
NET_MSG_INFO: MH_RECV_Info(S, B);