From: fgsfds Date: Wed, 16 Aug 2017 18:37:28 +0000 (+0300) Subject: fixed some logic errors, but shit's still bugged X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=4ecfaa7da77e39e45d45762f31362082a5616dec;p=d2df-sdl.git fixed some logic errors, but shit's still bugged --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 36b1016..c46f6e4 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -3689,77 +3689,82 @@ begin 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 diff --git a/src/game/g_nethandler.pas b/src/game/g_nethandler.pas index f505d62..b8d7c80 100644 --- a/src/game/g_nethandler.pas +++ b/src/game/g_nethandler.pas @@ -108,10 +108,14 @@ begin 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;