summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3bb414d)
raw | patch | inline | side by side (parent: 3bb414d)
author | fgsfds <pvt.fgsfds@gmail.com> | |
Wed, 16 Aug 2017 18:37:28 +0000 (21:37 +0300) | ||
committer | fgsfds <pvt.fgsfds@gmail.com> | |
Wed, 16 Aug 2017 18:37:28 +0000 (21:37 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_nethandler.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 36b1016abb6720dab7e7006448c8ef2ad7e966c5..c46f6e49b4f1d1825e7cc4f03e91b8ae019d357c 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
Ptr := NetEvent.packet^.data;
e_Raw_Seek(0);
- Len := e_Raw_Read_Word(Ptr);
- MID := e_Raw_Read_Byte(Ptr);
-
- if (MID = NET_MSG_INFO) and (State = 0) then
+ while (State = 0) and (RawPos < NetEvent.packet^.dataLength) do
begin
- NetMyID := e_Raw_Read_Byte(Ptr);
- NetPlrUID1 := e_Raw_Read_Word(Ptr);
+ Len := e_Raw_Read_Word(Ptr);
+ MID := e_Raw_Read_Byte(Ptr);
+ e_WriteLog(Format('conn recv %U %U', [Len, MID]), MSG_NOTIFY);
- WadName := e_Raw_Read_String(Ptr);
- Map := e_Raw_Read_String(Ptr);
+ if (MID = NET_MSG_INFO) and (State = 0) then
+ begin
+ NetMyID := e_Raw_Read_Byte(Ptr);
+ NetPlrUID1 := e_Raw_Read_Word(Ptr);
- gWADHash := e_Raw_Read_MD5(Ptr);
+ WadName := e_Raw_Read_String(Ptr);
+ Map := e_Raw_Read_String(Ptr);
- gGameSettings.GameMode := e_Raw_Read_Byte(Ptr);
- gSwitchGameMode := gGameSettings.GameMode;
- gGameSettings.GoalLimit := e_Raw_Read_Word(Ptr);
- gGameSettings.TimeLimit := e_Raw_Read_Word(Ptr);
- gGameSettings.MaxLives := e_Raw_Read_Byte(Ptr);
- gGameSettings.Options := e_Raw_Read_LongWord(Ptr);
- T := e_Raw_Read_LongWord(Ptr);
+ gWADHash := e_Raw_Read_MD5(Ptr);
- newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
- if newResPath = '' then
- begin
- g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
- newResPath := g_Res_DownloadWAD(WadName);
+ gGameSettings.GameMode := e_Raw_Read_Byte(Ptr);
+ gSwitchGameMode := gGameSettings.GameMode;
+ gGameSettings.GoalLimit := e_Raw_Read_Word(Ptr);
+ gGameSettings.TimeLimit := e_Raw_Read_Word(Ptr);
+ gGameSettings.MaxLives := e_Raw_Read_Byte(Ptr);
+ gGameSettings.Options := e_Raw_Read_LongWord(Ptr);
+ T := e_Raw_Read_LongWord(Ptr);
+
+ newResPath := g_Res_SearchSameWAD(MapsDir, WadName, gWADHash);
if newResPath = '' then
begin
- g_FatalError(_lc[I_NET_ERR_HASH]);
+ g_Game_SetLoadingText(_lc[I_LOAD_DL_RES], 0, False);
+ newResPath := g_Res_DownloadWAD(WadName);
+ if newResPath = '' then
+ begin
+ g_FatalError(_lc[I_NET_ERR_HASH]);
+ enet_packet_destroy(NetEvent.packet);
+ NetState := NET_STATE_NONE;
+ Exit;
+ end;
+ end;
+ newResPath := ExtractRelativePath(MapsDir, newResPath);
+
+ gPlayer1 := g_Player_Get(g_Player_Create(gPlayer1Settings.Model,
+ gPlayer1Settings.Color,
+ gPlayer1Settings.Team, False));
+
+ if gPlayer1 = nil then
+ begin
+ g_FatalError(Format(_lc[I_GAME_ERROR_PLAYER_CREATE], [1]));
+
enet_packet_destroy(NetEvent.packet);
NetState := NET_STATE_NONE;
Exit;
end;
- end;
- newResPath := ExtractRelativePath(MapsDir, newResPath);
-
- gPlayer1 := g_Player_Get(g_Player_Create(gPlayer1Settings.Model,
- gPlayer1Settings.Color,
- gPlayer1Settings.Team, False));
- if gPlayer1 = nil then
- begin
- g_FatalError(Format(_lc[I_GAME_ERROR_PLAYER_CREATE], [1]));
+ gPlayer1.Name := gPlayer1Settings.Name;
+ gPlayer1.UID := NetPlrUID1;
+ gPlayer1.Reset(True);
- enet_packet_destroy(NetEvent.packet);
- NetState := NET_STATE_NONE;
- Exit;
- end;
+ if not g_Game_StartMap(newResPath + ':\' + Map, True) then
+ begin
+ g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [WadName + ':\' + Map]));
- gPlayer1.Name := gPlayer1Settings.Name;
- gPlayer1.UID := NetPlrUID1;
- gPlayer1.Reset(True);
+ enet_packet_destroy(NetEvent.packet);
+ NetState := NET_STATE_NONE;
+ Exit;
+ end;
- if not g_Game_StartMap(newResPath + ':\' + Map, True) then
- begin
- g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [WadName + ':\' + Map]));
+ gTime := T;
+ State := 1;
+ OuterLoop := False;
enet_packet_destroy(NetEvent.packet);
- NetState := NET_STATE_NONE;
- Exit;
- end;
-
- gTime := T;
-
- State := 1;
- OuterLoop := False;
- enet_packet_destroy(NetEvent.packet);
- break;
- end
- else
- enet_packet_destroy(NetEvent.packet);
+ break;
+ end
+ else
+ RawPos := RawPos + Len-1;
+ end;
+ if State = 1 then break;
end
else
if (NetEvent.kind = ENET_EVENT_TYPE_DISCONNECT) then
index f505d62ecc848f9d4812fb6fbfcebea405a38149..b8d7c8040b1cd58cff7f22eb5f45b7d77b550c08 100644 (file)
NET_MSG_GEVENT: MC_RECV_GameEvent(B);
NET_MSG_GSET: MC_RECV_GameSettings(B);
- NET_MSG_PLR: if NetState <> NET_STATE_AUTH then MC_RECV_PlayerCreate(B);
- NET_MSG_PLRDEL: if NetState <> NET_STATE_AUTH then MC_RECV_PlayerDelete(B);
-
- else RawPos := RawPos + Len;
+ NET_MSG_PLR:
+ if NetState <> NET_STATE_AUTH then MC_RECV_PlayerCreate(B)
+ else RawPos := RawPos + Len-1;
+ NET_MSG_PLRDEL:
+ if NetState <> NET_STATE_AUTH then MC_RECV_PlayerDelete(B)
+ else RawPos := RawPos + Len-1;
+
+ else RawPos := RawPos + Len-1;
end;
end;