diff --git a/gamemodes/terrortown/gamemode/client/cl_search.lua b/gamemodes/terrortown/gamemode/client/cl_search.lua index a90dfdebb..1c03ea3a4 100644 --- a/gamemodes/terrortown/gamemode/client/cl_search.lua +++ b/gamemodes/terrortown/gamemode/client/cl_search.lua @@ -205,6 +205,8 @@ function SEARCHSCRN:Show(data) and not bodysearch.IsConfirmed(data.ragOwner) and not clientRD.isPolicingRole and not clientRD.isPublicRole then + local searchMode = bodysearch.GetInspectConfirmMode() + self:MakeInfoItem(contentAreaScroll, "policingrole_confirm_disabled", { text = { title = { @@ -212,12 +214,12 @@ function SEARCHSCRN:Show(data) params = nil }, text = {{ - body = "search_policingrole_confirm_disabled_" .. GetConVar("ttt2_inspect_confirm_mode"):GetString(), + body = "search_policingrole_confirm_disabled_" .. tostring(searchMode), params = nil }} }, colorBox = roles.DETECTIVE.ltcolor - }, 62) + }, (searchMode == 1) and 62 or 78) end -- POPULATE WITH INFORMATION @@ -291,12 +293,14 @@ function SEARCHSCRN:Show(data) end buttonConfirm:SetParams({credits = data.credits}) buttonConfirm:SetIcon(Material("vgui/ttt/icon_credits_transparent")) + buttonConfirm:SetSize(self.sizes.widthButtonCredits, self.sizes.heightButton) + buttonConfirm:SetPos(self.sizes.widthMainArea - self.sizes.widthButtonCredits, self.sizes.padding + 1) else buttonConfirm:SetText("search_confirm_forbidden") buttonConfirm:SetEnabled(false) + buttonConfirm:SetSize(self.sizes.widthButton, self.sizes.heightButton) + buttonConfirm:SetPos(self.sizes.widthMainArea - self.sizes.widthButton, self.sizes.padding + 1) end - buttonConfirm:SetSize(self.sizes.widthButtonCredits, self.sizes.heightButton) - buttonConfirm:SetPos(self.sizes.widthMainArea - self.sizes.widthButtonCredits, self.sizes.padding + 1) elseif data.credits > 0 and playerCanTakeCredits then if data.credits == 1 then buttonConfirm:SetText("search_confirm_credit") diff --git a/gamemodes/terrortown/gamemode/client/vgui/cl_sb_row.lua b/gamemodes/terrortown/gamemode/client/vgui/cl_sb_row.lua index ad98b9f2b..39a10de89 100644 --- a/gamemodes/terrortown/gamemode/client/vgui/cl_sb_row.lua +++ b/gamemodes/terrortown/gamemode/client/vgui/cl_sb_row.lua @@ -432,7 +432,7 @@ function PANEL:UpdatePlayerData() self.tag:SetText(ptag and GetTranslation(ptag.txt) or "") self.tag:SetTextColor(ptag and ptag.color or COLOR_WHITE) - self.sresult:SetVisible(ply.bodySearchResult and ply.bodySearchResult.isPublicPolicingSearch) + self.sresult:SetVisible(ply.bodySearchResult and ply.bodySearchResult.base.isPublicPolicingSearch) -- more blue if a detective searched them if ply.bodySearchResult and (LocalPlayer():GetSubRoleData().isPolicingRole or not ply.bodySearchResult.show) then diff --git a/gamemodes/terrortown/gamemode/server/sv_corpse.lua b/gamemodes/terrortown/gamemode/server/sv_corpse.lua index 2e81ac89f..de13aabe0 100644 --- a/gamemodes/terrortown/gamemode/server/sv_corpse.lua +++ b/gamemodes/terrortown/gamemode/server/sv_corpse.lua @@ -209,7 +209,7 @@ function CORPSE.ShowSearch(ply, rag, isCovert, isLongRange) local sData = bodysearch.AssimilateSceneData(ply, rag, isCovert, isLongRange) -- only in mode 0 everyone can confirm by pressing E - if bodysearch.GetInspectConfirmMode() == 0 or sData.isPublicPolicingSearch then + if bodysearch.GetInspectConfirmMode() == 0 or sData.base.isPublicPolicingSearch then -- only give credits if body is also confirmed if not isCovert then bodysearch.GiveFoundCredits(ply, rag, isLongRange, sData.searchUID) diff --git a/lua/ttt2/libraries/bodysearch.lua b/lua/ttt2/libraries/bodysearch.lua index 5e0982579..ab50299ae 100644 --- a/lua/ttt2/libraries/bodysearch.lua +++ b/lua/ttt2/libraries/bodysearch.lua @@ -130,20 +130,23 @@ if SERVER then function bodysearch.AssimilateSceneData(inspector, rag, isCovert, isLongRange) local sData = {} local inspectorRoleData = inspector:GetSubRoleData() + local isPublicPolicingSearch = inspector:IsActive() and inspectorRoleData.isPolicingRole and inspectorRoleData.isPublicRole -- hot-reloads can break the data, therefore we have to sanitize it rag.scene = rag.scene or {} -- data that is available to everyone - sData.searchUID = mathFloor(rag:EntIndex() + (rag.time or 0)) - sData.inspector = inspector + sData.base = {} + sData.base.inspector = inspector + sData.base.isPublicPolicingSearch = isPublicPolicingSearch and not isCovert + sData.playerModel = rag.scene.plyModel or "" - sData.credits = CORPSE.GetCredits(rag, 0) sData.ragOwner = player.GetBySteamID64(rag.sid64) - sData.isPublicPolicingSearch = inspector:IsActive() and inspectorRoleData.isPolicingRole and inspectorRoleData.isPublicRole and not isCovert + sData.credits = CORPSE.GetCredits(rag, 0) + sData.searchUID = mathFloor(rag:EntIndex() + (rag.time or 0)) -- if a non-public or non-policing role tries to search a body in mode 2, nothing happens - if cvInspectConfirmMode:GetInt() == 2 and not sData.isPublicPolicingSearch and not inspector:IsSpec() then + if cvInspectConfirmMode:GetInt() == 2 and not isPublicPolicingSearch and not inspector:IsSpec() then return sData end @@ -244,7 +247,7 @@ if CLIENT then -- @realm shared hook.Run("TTTBodySearchEquipment", searchStreamData, eq) - searchStreamData.show = LocalPlayer() == searchStreamData.inspector + searchStreamData.show = LocalPlayer() == searchStreamData.base.inspector if searchStreamData.show then -- if there is more elaborate data already available @@ -257,7 +260,7 @@ if CLIENT then end -- add this hack here to keep compatibility to the old scoreboard - searchStreamData.show_sb = searchStreamData.show or searchStreamData.isPublicPolicingSearch + searchStreamData.show_sb = searchStreamData.show or searchStreamData.base.isPublicPolicingSearch -- cache search result in rag.bodySearchResult, e.g. useful for scoreboard bodysearch.StoreSearchResult(searchStreamData) @@ -770,20 +773,35 @@ if CLIENT then local ply = sData.ragOwner local rag = sData.rag + -- do not store if searching player (client) is spectator + if LocalPlayer():IsSpec() then return end + -- if the currently stored search result is by a public policing role, it should be kept -- it can be overwritten by another public policing role though - if ply.bodySearchResult and ply.bodySearchResult.isPublicPolicingSearch - and not sData.isPublicPolicingSearch - then return end + -- data can still be updated, but the original base is kept + local oldBase + if ply.bodySearchResult and ply.bodySearchResult.base and ply.bodySearchResult.base.isPublicPolicingSearch + and not sData.base.isPublicPolicingSearch + then + oldBase = sData.base + end - -- do not store if searching player (client) is spectator - if LocalPlayer():IsSpec() then return end + -- merge new data into old data + -- this is useful if a player had good data on a body from another source + -- and now gets updated info on it as it now only replaces the newly added + -- entries + local newData = ply.bodySearchResult or {} + table.Merge(newData, sData) + + -- keep the original finder info if previously searched by public policing role + newData.base = oldBase or newData.base - ply.bodySearchResult = sData + ply.bodySearchResult = newData -- also store data in the ragdoll for targetID if not IsValid(rag) then return end - rag.bodySearchResult = sData + + rag.bodySearchResult = newData end function bodysearch.PlayerHasDetailedSearchResult(ply) diff --git a/lua/ttt2/libraries/targetid.lua b/lua/ttt2/libraries/targetid.lua index e1ff97bea..32e84e80b 100644 --- a/lua/ttt2/libraries/targetid.lua +++ b/lua/ttt2/libraries/targetid.lua @@ -493,7 +493,7 @@ function targetid.HUDDrawTargetIDRagdolls(tData) tData:SetSubtitle(ParT("corpse_hint_spec", key_params)) elseif bodysearch.GetInspectConfirmMode() == 2 and not roleDataClient.isPolicingRole and not roleDataClient.isPublicRole then -- a detective added search results, this should change the targetID - if ent.bodySearchResult and ent.bodySearchResult.isPublicPolicingSearch then + if ent.bodySearchResult and ent.bodySearchResult.base and ent.bodySearchResult.base.isPublicPolicingSearch then tData:SetSubtitle(ParT("corpse_hint_public_policing_searched", key_params)) else tData:SetSubtitle(ParT("corpse_hint_no_inspect", key_params)) @@ -528,7 +528,7 @@ function targetid.HUDDrawTargetIDRagdolls(tData) end -- add info if searched by detectives - if ent.bodySearchResult and ent.bodySearchResult.isPublicPolicingSearch then + if ent.bodySearchResult and ent.bodySearchResult.base and ent.bodySearchResult.base.isPublicPolicingSearch then tData:AddDescriptionLine( TryT("corpse_searched_by_detective"), roles.DETECTIVE.ltcolor,