Skip to content

Commit

Permalink
Fixed: Developer mode console variable description typo
Browse files Browse the repository at this point in the history
Fixed: Phantom records are present due to record time mismatch when mode is SQL
Optimized: Memory manager and CacheQuery%
  • Loading branch information
dvdvideo1234 committed Mar 6, 2016
1 parent 0e16174 commit 0496a92
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 33 deletions.
4 changes: 2 additions & 2 deletions lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ asmlib.SetIndexes("V",1,2,3)
asmlib.SetIndexes("A",1,2,3)
asmlib.SetIndexes("S",4,5,6,7)
asmlib.InitAssembly("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","5.214")
asmlib.SetOpVar("TOOL_VERSION","5.216")
asmlib.SetOpVar("DIRPATH_BAS",asmlib.GetOpVar("TOOLNAME_NL")..asmlib.GetOpVar("OPSYM_DIRECTORY"))
asmlib.SetOpVar("DIRPATH_EXP","exp"..asmlib.GetOpVar("OPSYM_DIRECTORY"))
asmlib.SetOpVar("DIRPATH_DSV","dsv"..asmlib.GetOpVar("OPSYM_DIRECTORY"))
Expand All @@ -41,7 +41,7 @@ asmlib.SetLogControl(0,"")
------ CONFIGURE REPLICATED CVARS ----- Server tells the client what value to use
asmlib.MakeCoVar("maxactrad", "150", {1,500} ,bitBor(FCVAR_ARCHIVE, FCVAR_ARCHIVE_XBOX, FCVAR_NOTIFY, FCVAR_REPLICATED, FCVAR_PRINTABLEONLY), "Maximum active radius to search for a point ID")
asmlib.MakeCoVar("enwiremod", "1" , {0, 1 } ,bitBor(FCVAR_ARCHIVE, FCVAR_ARCHIVE_XBOX, FCVAR_NOTIFY, FCVAR_REPLICATED, FCVAR_PRINTABLEONLY), "Toggle the wire extension on/off server side")
asmlib.MakeCoVar("devmode" , "0" , {0, 1 } ,bitBor(FCVAR_ARCHIVE, FCVAR_ARCHIVE_XBOX, FCVAR_NOTIFY, FCVAR_REPLICATED, FCVAR_PRINTABLEONLY), "Toggle the wire extension on/off server side")
asmlib.MakeCoVar("devmode" , "0" , {0, 1 } ,bitBor(FCVAR_ARCHIVE, FCVAR_ARCHIVE_XBOX, FCVAR_NOTIFY, FCVAR_REPLICATED, FCVAR_PRINTABLEONLY), "Toggle developer mode on/off server side")
asmlib.MakeCoVar("maxstcnt" , "200", {1,200} ,bitBor(FCVAR_ARCHIVE, FCVAR_ARCHIVE_XBOX, FCVAR_NOTIFY, FCVAR_REPLICATED, FCVAR_PRINTABLEONLY), "Maximum pieces to spawn in stack mode")
if(SERVER) then
asmlib.MakeCoVar("bnderrmod", "LOG", nil ,bitBor(FCVAR_ARCHIVE, FCVAR_ARCHIVE_XBOX, FCVAR_NOTIFY, FCVAR_REPLICATED, FCVAR_PRINTABLEONLY), "Unreasonable position error handling mode")
Expand Down
77 changes: 46 additions & 31 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ function InitAssembly(sName,sPurpose)
return StatusPrint(false,"InitAssembly: Name invalid") end
if(IsEmptyString(sPurpose) or tonumber(stringSub(sPurpose,1,1))) then
return StatusPrint(false,"InitAssembly: Purpose invalid") end
SetOpVar("ANG_ZERO",Angle())
SetOpVar("VEC_ZERO",Vector())
SetOpVar("OPSYM_DISABLE","#")
SetOpVar("OPSYM_REVSIGN","@")
SetOpVar("OPSYM_DIVIDER","_")
SetOpVar("OPSYM_DIRECTORY","/")
SetOpVar("OPSYM_SEPARATOR",",")
SetOpVar("TIME_EPOCH",Time())
SetOpVar("NAME_INIT",stringLower(sName))
SetOpVar("NAME_PERP",stringLower(sPurpose))
Expand All @@ -363,13 +370,11 @@ function InitAssembly(sName,sPurpose)
SetOpVar("HASH_PLAYER_KEYDOWN","PLAYER_KEYDOWN")
SetOpVar("HASH_PROPERTY_NAMES","PROPERTY_NAMES")
SetOpVar("HASH_PROPERTY_TYPES","PROPERTY_TYPES")
SetOpVar("ANG_ZERO",Angle())
SetOpVar("VEC_ZERO",Vector())
SetOpVar("OPSYM_DISABLE","#")
SetOpVar("OPSYM_REVSIGN","@")
SetOpVar("OPSYM_DIVIDER","_")
SetOpVar("OPSYM_DIRECTORY","/")
SetOpVar("OPSYM_SEPARATOR",",")
SetOpVar("NAV_PIECE",{})
SetOpVar("NAV_ADDITION",{})
SetOpVar("NAV_PROPERTY_NAMES",{})
SetOpVar("NAV_PROPERTY_TYPES",{})
SetOpVar("NAV_PANEL",{})
SetOpVar("STRUCT_SPAWN",{
F = Vector(),
R = Vector(),
Expand Down Expand Up @@ -2018,7 +2023,7 @@ function InsertRecord(sTable,tData)
end
end

--------------------------- PIECE QUERY -----------------------------
--------------- TIMER MEMORY MANAGMENT ----------------------------

local function NavigateTable(oLocation,tKeys)
if(not IsExistent(oLocation)) then
Expand All @@ -2040,8 +2045,6 @@ local function NavigateTable(oLocation,tKeys)
return Place, Key
end

--------------- TIMER MEMORY MANAGMENT ----------------------------

function TimerSetting(sTimerSet) -- Generates a timer settings table and keeps the defaults
if(not IsExistent(sTimerSet)) then
return StatusLog(nil,"TimerSetting: Timer set missing for setup") end
Expand All @@ -2066,10 +2069,14 @@ local function TimerAttach(oLocation,tKeys,defTable,anyMessage)
local sModeDB = GetOpVar("MODE_DATABASE")
LogInstance("TimerAttach: Called by <"..anyMessage.."> for Place["..tostring(Key).."]")
if(sModeDB == "SQL") then
if(IsExistent(Place[Key].Kept)) then Place[Key].Kept = Place[Key].Kept - 1 end -- Get the proper line count
local tTimer = defTable.Timer -- If we have a timer, and it does speak, we advise you send your regards..
local nNowTM = Time() -- When is "now" ?
-- If we have a timer, and it does speak, we advise you send your regards..
local tTimer = defTable.Timer
if(not IsExistent(tTimer)) then
return StatusLog(Place[Key],"TimerAttach: Missing timer settings") end
Place[Key].Used = nNowTM -- Make the first selected deletable to avoid phantom records
-- Get the proper line count to avoid doing in every caching function"
if(IsExistent(Place[Key].Kept)) then Place[Key].Kept = Place[Key].Kept - 1 end
local nLifeTM = tTimer[2]
if(nLifeTM <= 0) then
return StatusLog(Place[Key],"TimerAttach: Timer attachment ignored") end
Expand All @@ -2078,10 +2085,10 @@ local function TimerAttach(oLocation,tKeys,defTable,anyMessage)
local bCollGB = tTimer[4]
LogInstance("TimerAttach: ["..sModeTM.."] ("..tostring(nLifeTM)..") "..tostring(bKillRC)..", "..tostring(bCollGB))
if(sModeTM == "CQT") then
Place[Key].Load = Time()
Place[Key].Load = nNowTM
for k, v in pairs(Place) do
if(IsExistent(v.Used) and IsExistent(v.Load) and ((v.Used - v.Load) > nLifeTM)) then
LogInstance("TimerAttach: ("..tostring(v.Used - v.Load).." > "..tostring(nLifeTM)..") > Dead")
if(IsExistent(v.Load) and IsExistent(v.Used) and ((nNowTM - v.Used) > nLifeTM)) then
LogInstance("TimerAttach: ("..tostring(RoundValue(nNowTM - v.Used,0.01)).." > "..tostring(nLifeTM)..") > Dead")
if(bKillRC) then
LogInstance("TimerAttach: Killed <"..tostring(k)..">")
Place[k] = nil
Expand All @@ -2092,7 +2099,7 @@ local function TimerAttach(oLocation,tKeys,defTable,anyMessage)
collectgarbage()
LogInstance("TimerAttach: Garbage collected")
end
return StatusLog(Place[Key],"TimerAttach: Place["..tostring(Key).."].Load = "..tostring(Place[Key].Load))
return StatusLog(Place[Key],"TimerAttach: Place["..tostring(Key).."].Load = "..tostring(RoundValue(nNowTM,0.01)))
elseif(sModeTM == "OBJ") then
local TimerID = stringImplode(GetOpVar("OPSYM_DIVIDER"),tKeys)
LogInstance("TimerAttach: TimID <"..TimerID..">")
Expand Down Expand Up @@ -2157,7 +2164,7 @@ function CacheBoxLayout(oEnt,nRot,nCamX,nCamZ)
if(not (oEnt and oEnt:IsValid())) then
return StatusLog(nil,"CacheBoxLayout: Entity invalid <"..tostring(oEnt)..">") end
local sMod = oEnt:GetModel()
local oRec = CacheQueryPiece(sMod)
local oRec = CacheQueryPiece(sMod)
if(not IsExistent(oRec)) then
return StatusLog(nil,"CacheBoxLayout: Piece record invalid <"..sMod..">") end
local Box = oRec.Layout
Expand All @@ -2174,12 +2181,13 @@ function CacheBoxLayout(oEnt,nRot,nCamX,nCamZ)
Box.Len = ((vMax - vMin):Length() / 2) -- Layout border sphere radius
Box.Cam = Vector(); Box.Cam:Set(Box.Eye) -- Layout camera position
AddVectorXYZ(Box.Cam,Box.Len*(tonumber(nCamX) or 0),0,Box.Len*(tonumber(nCamZ) or 0))
LogInstance("CacheBoxLayout: "..tostring(Box.Cen).." #"..tostring(Box.Len))
LogInstance("CacheBoxLayout: "..tostring(Box.Cen).." # "..tostring(Box.Len))
end; Box.Ang[caY] = (tonumber(nRot) or 0) * Time()
return Box
end

-- Cashing the selected Piece Result
--------------------------- PIECE QUERY -----------------------------

function CacheQueryPiece(sModel)
if(not IsExistent(sModel)) then
return StatusLog(nil,"CacheQueryPiece: Model does not exist") end
Expand All @@ -2197,7 +2205,8 @@ function CacheQueryPiece(sModel)
local sModel = MatchType(defTable,sModel,1,false,"",true,true)
if(not IsExistent(Cache)) then
return StatusLog(nil,"CacheQueryPiece: Cache not allocated for <"..namTable..">") end
local caInd = {namTable,sModel}
local caInd = GetOpVar("NAV_PIECE")
if(not IsExistent(caInd[1])) then caInd[1] = namTable end caInd[2] = sModel
local stPiece = Cache[sModel]
if(IsExistent(stPiece) and IsExistent(stPiece.Kept)) then
if(stPiece.Kept > 0) then
Expand Down Expand Up @@ -2258,7 +2267,8 @@ function CacheQueryAdditions(sModel)
local sModel = MatchType(defTable,sModel,1,false,"",true,true)
if(not IsExistent(Cache)) then
return StatusLog(nil,"CacheQueryAdditions: Cache not allocated for <"..namTable..">") end
local caInd = {namTable,sModel}
local caInd = GetOpVar("NAV_ADDITION")
if(not IsExistent(caInd[1])) then caInd[1] = namTable end caInd[2] = sModel
local stAddition = Cache[sModel]
if(IsExistent(stAddition) and IsExistent(stAddition.Kept)) then
if(stAddition.Kept > 0) then
Expand Down Expand Up @@ -2303,11 +2313,12 @@ function CacheQueryPanel()
if(not defTable) then
return StatusLog(false,"CacheQueryPanel: Missing table definition") end
local namTable = defTable.Name
local keyPanel = GetOpVar("HASH_USER_PANEL")
if(not IsExistent(libCache[namTable])) then
return StatusLog(nil,"CacheQueryPanel: Cache not allocated for <"..namTable..">") end
local stPanel = libCache[keyPanel]
local caInd = {keyPanel}
local caInd = GetOpVar("NAV_PANEL")
local keyPanel = GetOpVar("HASH_USER_PANEL")
if(not IsExistent(caInd[1])) then caInd[1] = keyPanel end
local stPanel = libCache[keyPanel]
if(IsExistent(stPanel) and IsExistent(stPanel.Kept)) then
LogInstance("CacheQueryPanel: From Pool")
if(stPanel.Kept > 0) then
Expand Down Expand Up @@ -2363,18 +2374,19 @@ function CacheQueryProperty(sType)
if(not Cache) then
return StatusLog(nil,"CacheQueryProperty["..tostring(sType).."]: Cache not allocated for <"..namTable..">") end
local sModeDB = GetOpVar("MODE_DATABASE")
if(IsString(sType) and not IsEmptyString(sType)) then -- Get names per type
local sType = MatchType(defTable,sType,1,false,"",true,true) -- Match type casing
if(IsString(sType) and not IsEmptyString(sType)) then
local sType = MatchType(defTable,sType,1,false,"",true,true)
local keyName = GetOpVar("HASH_PROPERTY_NAMES")
local arNames = Cache[keyName]
local caInd = {namTable,keyName,sType}
local caInd = GetOpVar("NAV_PROPERTY_NAMES")
if(not IsExistent(caInd[1])) then caInd[1] = namTable; caInd[2] = keyName end caInd[3] = sType
if(not IsExistent(arNames)) then
Cache[keyName] = {}
arNames = Cache[keyName]
end
local stName = arNames[sType]
if(IsExistent(stName) and IsExistent(stName.Kept)) then
LogInstance("CacheQueryProperty["..sType.."]: From Pool")
LogInstance("CacheQueryProperty["..sType.."]: Names << Pool")
if(stName.Kept > 0) then
return TimerRestart(libCache,caInd,defTable,"CacheQueryProperty") end
return nil
Expand All @@ -2397,16 +2409,18 @@ function CacheQueryProperty(sType)
stName[stName.Kept] = qData[stName.Kept][defTable[3][1]]
stName.Kept = stName.Kept + 1
end
LogInstance("CacheQueryProperty["..sType.."]: Names >> Pool")
return TimerAttach(libCache,caInd,defTable,"CacheQueryProperty")
elseif(sModeDB == "LUA") then return StatusLog(nil,"CacheQueryProperty["..sType.."]: Record not located")
else return StatusLog(nil,"CacheQueryProperty["..sType.."]: Wrong database mode <"..sModeDB..">") end
end
else
local keyType = GetOpVar("HASH_PROPERTY_TYPES")
local stType = Cache[keyType]
local caInd = {namTable,keyType}
if(IsExistent(stType) and IsExistent(stType.Kept)) then -- Get All type names
LogInstance("CacheQueryProperty: From Pool")
local caInd = GetOpVar("NAV_PROPERTY_TYPES")
if(not IsExistent(caInd[1])) then caInd[1] = namTable; caInd[2] = keyType end
if(IsExistent(stType) and IsExistent(stType.Kept)) then
LogInstance("CacheQueryProperty: Types << Pool")
if(stType.Kept > 0) then
return TimerRestart(libCache,caInd,defTable,"CacheQueryProperty") end
return nil
Expand All @@ -2428,6 +2442,7 @@ function CacheQueryProperty(sType)
stType[stType.Kept] = qData[stType.Kept][defTable[1][1]]
stType.Kept = stType.Kept + 1
end
LogInstance("CacheQueryProperty: Types >> Pool")
return TimerAttach(libCache,caInd,defTable,"CacheQueryProperty")
elseif(sModeDB == "LUA") then return StatusLog(nil,"CacheQueryProperty: Record not located")
else return StatusLog(nil,"CacheQueryProperty: Wrong database mode <"..sModeDB..">") end
Expand Down

0 comments on commit 0496a92

Please sign in to comment.