Skip to content

Commit

Permalink
Fixed: Ghost elevation not calculated correctly
Browse files Browse the repository at this point in the history
Fixed: Processing DSV generating table indexing  errors
Added: Use library unpack method for normal angle
Added: Extra log on timer navigation fail
  • Loading branch information
dvdvideo1234 committed Jul 11, 2024
1 parent ae16f13 commit a1e7727
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
------------ CONFIGURE ASMLIB ------------

asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","8.800")
asmlib.SetOpVar("TOOL_VERSION","8.801")

------------ CONFIGURE GLOBAL INIT OPVARS ------------

Expand Down
49 changes: 33 additions & 16 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2061,9 +2061,9 @@ function GetPointElevation(oEnt,ivPoID)
LogInstance("POA missing "..GetReport(ivPoID, sModel)); return nil end
if(not (hdPnt.O and hdPnt.A)) then
LogInstance("Transform missing "..GetReport(ivPoID, sModel)); return nil end
local aOBB, vOBB = Angle(), oEnt:OBBMins()
aOBB:SetUnpacked(hdPnt.A:Get()); aOBB:RotateAroundAxis(aOBB:Up(), 180)
vOBB:SetUnpacked(hdPnt.O:Get()); BasisVector(vOBB,aOBB)
local aA, vV, vOBB = Angle(), Vector(), oEnt:OBBMins()
aA:SetUnpacked(hdPnt.A:Get()); aA:RotateAroundAxis(aA:Up(), 180)
vV:SetUnpacked(hdPnt.O:Get()); vOBB:Sub(vV); BasisVector(vOBB, aA)
return mathAbs(vOBB.z)
end

Expand Down Expand Up @@ -2651,19 +2651,31 @@ function CreateTable(sTable,defTab,bDelete,bReload)
if(smTM == "CQT") then
if(iCnt > 1) then -- Record in the placeholder must be cleared
for key, rec in pairs(oSpot) do -- Check other items that qualify
if(not rec.Used) then -- Used time is updated correctly. Report it
LogInstance("Navigation error "..GetReport(iCnt, unpack(tKey)),tabDef.Nick)
LogInstance("Navigation key "..GetReport(kKey, key),tabDef.Nick)
LogTable(rec, "Navigation", tabDef.Nick)
else -- Used time is updated correctly. Try to do some work
local vDif = (nNow - rec.Used) -- Calculate time difference
if(IsHere(rec.Used) and (vDif > tmLif)) then -- Check the deletion
LogInstance("Qualify "..GetReport(vDif, tmLif), tabDef.Nick)
if(tmDie) then oSpot[key] = nil; LogInstance("Clear "..GetReport(key),tabDef.Nick) end
end -- Clear one item that qualifies for deletion and time frame is present
end
end -- Clear all the items that qualified for deletion
else -- The whole cache placeholder must be deleted. Identifier is at base pointer
local key, rec = kKey, oSpot[kKey] -- Index placeholder
if(not rec.Used) then -- Used time is updated correctly. Report it
LogInstance("Navigation error "..GetReport(iCnt, unpack(tKey)),tabDef.Nick)
LogInstance("Navigation key "..GetReport(kKey, key),tabDef.Nick)
LogTable(rec, "Navigation", tabDef.Nick)
else -- Used time is updated correctly. Try to do some work
local vDif = (nNow - rec.Used) -- Calculate time difference
if(IsHere(rec.Used) and (vDif > tmLif)) then -- Check the deletion
LogInstance("Qualify "..GetReport(vDif, tmLif), tabDef.Nick)
if(tmDie) then oSpot[key] = nil; LogInstance("Clear "..GetReport(key),tabDef.Nick) end
end -- Clear one item that qualifies for deletion and time frame is present
end -- Clear all the items that qualified for deletion
else -- The whole cache placeholder must be deleted. Identifier is at base pointer
local key, rec = kKey, oSpot[kKey] -- Index placeholder
local vDif = (nNow - rec.Used) -- Calculate time difference
if(IsHere(rec.Used) and (vDif > tmLif)) then -- Check the deletion
LogInstance("Qualify "..GetReport(vDif, tmLif), tabDef.Nick)
if(tmDie) then oSpot[key] = nil; LogInstance("Clear "..GetReport(key),tabDef.Nick) end
end -- Clear the placeholder that qualifies for deletion and time frame is present
end -- Clear the placeholder that qualifies for deletion and time frame is present
end
end
if(tmCol) then collectgarbage(); LogInstance("Garbage collected",tabDef.Nick) end
LogInstance("Finish "..GetReport(kKey, nNow), tabDef.Nick); return oSpot[kKey]
Expand Down Expand Up @@ -3737,15 +3749,16 @@ function ProcessDSV(sDelim)
LogInstance("Failed "..GetReport(prf, "CATEGORY")) end
else LogInstance("Missing "..GetReport(prf, "CATEGORY")) end
else LogInstance("Generic "..GetReport(prf, "CATEGORY")) end
end local iD, makTab = 1, GetBuilderID(1)
while(makTab) do local defTab = makTab:GetDefinition()
end
for iD = 1, #libQTable do
local makTab = GetBuilderID(iD)
local defTab = makTab:GetDefinition()
if(not fileExists(sDv..fForm:format(irf, sNt..defTab.Nick), "DATA")) then
if(fileExists(sDv..fForm:format(prf, sNt..defTab.Nick), "DATA")) then
if(not ImportDSV(defTab.Nick, true, prf)) then
LogInstance("Failed "..GetReport(prf, defTab.Nick)) end
else LogInstance("Missing "..GetReport(prf, defTab.Nick)) end
else LogInstance("Generic "..GetReport(prf, defTab.Nick)) end
iD = (iD + 1); makTab = GetBuilderID(iD)
end
end
end; LogInstance("Success"); return true
Expand Down Expand Up @@ -4007,7 +4020,11 @@ function GetNormalAngle(oPly, soTr, bSnp, nSnp)
if(not (stTr and stTr.Hit)) then stTr = GetCacheTrace(oPly)
if(not (stTr and stTr.Hit)) then return aAng end
end; aAng:Set(GetSurfaceAngle(oPly, stTr.HitNormal))
else aAng.y = oPly:GetAimVector():Angle().y end
else -- Modify only the roll of the base angle
local aP, aY, aR = aAng:Unpack() -- Base angle
local pP, pY, pR = oPly:GetAimVector():Angle():Unpack()
aAng:SetUnpacked(aP, pY, aR) -- Apply the player yaw
end
SnapAngle(aAng, nAsn); GridAngle(aAng, nAsn); return aAng
end

Expand Down
15 changes: 7 additions & 8 deletions lua/weapons/gmod_tool/stools/trackassembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1770,14 +1770,13 @@ end
function TOOL:ElevateGhost(oEnt, oPly)
if(not (oPly and oPly:IsValid() and oPly:IsPlayer())) then
asmlib.LogInstance("Player invalid <"..tostring(oPly)..">",gtLogs); return end
if(oEnt and oEnt:IsValid()) then
local pointid, pnextid = self:GetPointID()
local spawncn, elevpnt = self:GetSpawnCenter(), 0
if(not spawncn) then -- Distance for the piece spawned on the ground
elevpnt = (asmlib.GetPointElevation(oEnt, pointid) or 0); end
asmlib.LogInstance("("..tostring(spawncn)..") <"..tostring(elevpnt)..">",gtLogs)
asmlib.SetAsmConvar(oPly, "elevpnt", elevpnt)
end
if(not (oEnt and oEnt:IsValid())) then return end
local pointid, pnextid = self:GetPointID()
local spawncn, elevpnt = self:GetSpawnCenter(), 0
if(not spawncn) then -- Distance for the piece spawned on the ground
elevpnt = (asmlib.GetPointElevation(oEnt, pointid) or 0); end
asmlib.LogInstance("("..tostring(spawncn)..") <"..tostring(elevpnt)..">",gtLogs)
asmlib.SetAsmConvar(oPly, "elevpnt", elevpnt)
end

function TOOL:Think()
Expand Down

0 comments on commit a1e7727

Please sign in to comment.