Skip to content

Commit

Permalink
Fixed: Model to name conversion setting not working in some cases
Browse files Browse the repository at this point in the history
Fixed: DSV not working if the /exp/ folder is not created
Fixed: Logging date skipping date-time format
  • Loading branch information
dvdvideo1234 committed Aug 11, 2017
1 parent 8ba2ef3 commit 03c600f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ local asmlib = trackasmlib

------ CONFIGURE ASMLIB ------
asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","5.366")
asmlib.SetOpVar("TOOL_VERSION","5.367")
asmlib.SetIndexes("V",1,2,3)
asmlib.SetIndexes("A",1,2,3)
asmlib.SetIndexes("S",4,5,6,7)
Expand Down
37 changes: 22 additions & 15 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ function IsOther(oEnt)
return false
end

function GetDateLog()
return (osDate(GetOpVar("DATE_FORMAT"))
.." "..osDate(GetOpVar("TIME_FORMAT")))
end

------------------ LOGS ------------------------

local function FormatNumberMax(nNum,nMax)
Expand All @@ -230,7 +235,7 @@ local function Log(anyStuff)
if(GetOpVar("LOG_LOGFILE")) then
local fName = GetOpVar("DIRPATH_BAS").."trackasmlib_log.txt"
if(nCurLogs > nMaxLogs) then nCurLogs = 0; fileDelete(fName) end
fileAppend(fName,FormatNumberMax(nCurLogs,nMaxLogs).." ["..osDate().."] "..logData.."\n")
fileAppend(fName,FormatNumberMax(nCurLogs,nMaxLogs).." ["..GetDateLog().."] "..logData.."\n")
else -- The current has values 1..nMaxLogs(0)
if(nCurLogs > nMaxLogs) then nCurLogs = 0 end
print(FormatNumberMax(nCurLogs,nMaxLogs).." >> "..logData)
Expand All @@ -240,11 +245,11 @@ end
function PrintInstance(anyStuff)
local sModeDB = GetOpVar("MODE_DATABASE")
if(SERVER) then
print("["..osDate().."] SERVER > "..GetOpVar("TOOLNAME_NU").." ["..sModeDB.."] "..tostring(anyStuff))
print("["..GetDateLog().."] SERVER > "..GetOpVar("TOOLNAME_NU").." ["..sModeDB.."] "..tostring(anyStuff))
elseif(CLIENT) then
print("["..osDate().."] CLIENT > "..GetOpVar("TOOLNAME_NU").." ["..sModeDB.."] "..tostring(anyStuff))
print("["..GetDateLog().."] CLIENT > "..GetOpVar("TOOLNAME_NU").." ["..sModeDB.."] "..tostring(anyStuff))
else
print("["..osDate().."] NOINST > "..GetOpVar("TOOLNAME_NU").." ["..sModeDB.."] "..tostring(anyStuff))
print("["..GetDateLog().."] NOINST > "..GetOpVar("TOOLNAME_NU").." ["..sModeDB.."] "..tostring(anyStuff))
end
end

Expand Down Expand Up @@ -1133,8 +1138,8 @@ function ModelToName(sModel,bNoSettings)
local sModel = (sModel:sub(1, 1) ~= sSymDir) and (sSymDir..sModel) or sModel
sModel = stringToFileName(sModel):gsub(GetOpVar("MODELNAM_FILE"),"")
local gModel = sModel:sub(1,-1) -- Create a copy so we can select cut-off parts later on
if(not bNoSettings) then
local tCut, Cnt, tSub, tApp = SettingsModelToName("GET"), 1
if(not bNoSettings) then local Cnt = 1
local tCut, tSub, tApp = SettingsModelToName("GET")
if(tCut and tCut[1]) then
while(tCut[Cnt] and tCut[Cnt+1]) do
local fCh = tonumber(tCut[Cnt])
Expand Down Expand Up @@ -2437,7 +2442,7 @@ function ExportCategory(vEq, tData, sPref)
if(not F) then return StatusLog(false,"ExportCategory("..sPref.."): fileOpen("..fName..") failed from") end
local sEq, nLen, sMod = ("="):rep(nEq), (nEq+2), GetOpVar("MODE_DATABASE")
local tCat = (type(tData) == "table") and tData or GetOpVar("TABLE_CATEGORIES")
F:Write("# ExportCategory( "..tostring(nEq).." )("..sPref.."): "..osDate().." [ "..sMod.." ]".."\n")
F:Write("# ExportCategory( "..tostring(nEq).." )("..sPref.."): "..GetDateLog().." [ "..sMod.." ]".."\n")
for cat, rec in pairs(tCat) do
if(IsString(rec.Txt)) then
local exp = "["..sEq.."["..cat..sEq..rec.Txt:Trim().."]"..sEq.."]"
Expand Down Expand Up @@ -2539,7 +2544,7 @@ function ExportDSV(sTable, sPref, sDelim)
.."): fileOpen("..fName..") failed") end
local sDelim = tostring(sDelim or "\t"):sub(1,1)
local sModeDB, symOff = GetOpVar("MODE_DATABASE"), GetOpVar("OPSYM_DISABLE")
F:Write("# ExportDSV: "..osDate().." [ "..sModeDB.." ]".."\n")
F:Write("# ExportDSV: "..GetDateLog().." [ "..sModeDB.." ]".."\n")
F:Write("# Data settings:\t"..GetColumns(defTable,sDelim).."\n")
if(sModeDB == "SQL") then
local Q = ""
Expand Down Expand Up @@ -2753,7 +2758,7 @@ function SynchronizeDSV(sTable, tData, bRepl, sPref, sDelim)
return StatusLog(false,"SynchronizeDSV("..fPref.."): Sorting failed") end
local O = fileOpen(fName, "wb" ,"DATA")
if(not O) then return StatusLog(false,"SynchronizeDSV("..fPref.."): Write fileOpen("..fName..") failed") end
O:Write("# SynchronizeDSV("..fPref.."): "..osDate().." ["..GetOpVar("MODE_DATABASE").."]\n")
O:Write("# SynchronizeDSV("..fPref.."): "..GetDateLog().." ["..GetOpVar("MODE_DATABASE").."]\n")
O:Write("# Data settings:\t"..GetColumns(defTable,sDelim).."\n")
for rcID = 1, #tSort do
local key = tSort[rcID].Val
Expand Down Expand Up @@ -2781,15 +2786,17 @@ function TranslateDSV(sTable, sPref, sDelim)
local defTable = GetOpVar("DEFTABLE_"..sTable)
if(not defTable) then
return StatusLog(false,"TranslateDSV("..fPref.."): Missing table definition for <"..sTable..">") end
local sNdsv = GetOpVar("DIRPATH_BAS")..GetOpVar("DIRPATH_DSV")
sNdsv = sNdsv..fPref..defTable.Name..".txt"
local sNins = GetOpVar("DIRPATH_BAS")..GetOpVar("DIRPATH_INS")
sNins = sNins..fPref..defTable.Name..".txt"
local sNdsv, sNins = GetOpVar("DIRPATH_BAS"), GetOpVar("DIRPATH_BAS")
if(not fileExists(sNins,"DATA")) then fileCreateDir(sNins) end
sNdsv, sNins = sNdsv..GetOpVar("DIRPATH_DSV"), sNins..GetOpVar("DIRPATH_INS")
if(not fileExists(sNins,"DATA")) then fileCreateDir(sNins) end
sNdsv, sNins = sNdsv..fPref..defTable.Name..".txt", sNins..fPref..defTable.Name..".txt"
local sDelim = tostring(sDelim or "\t"):sub(1,1)
local D, I = fileOpen(sNdsv, "rb", "DATA"), fileOpen(sNins, "wb", "DATA")
local D = fileOpen(sNdsv, "rb", "DATA")
if(not D) then return StatusLog(false,"TranslateDSV("..fPref.."): fileOpen("..sNdsv..") failed") end
local I = fileOpen(sNins, "wb", "DATA")
if(not I) then return StatusLog(false,"TranslateDSV("..fPref.."): fileOpen("..sNins..") failed") end
I:Write("# TranslateDSV("..fPref.."@"..sTable.."): "..osDate().." ["..GetOpVar("MODE_DATABASE").."]\n")
I:Write("# TranslateDSV("..fPref.."@"..sTable.."): "..GetDateLog().." ["..GetOpVar("MODE_DATABASE").."]\n")
I:Write("# Data settings:\t"..GetColumns(defTable, sDelim).."\n")
local sLine, sCh, symOff = "", "X", GetOpVar("OPSYM_DISABLE")
local sFr, sBk, sHs = "asmlib.InsertRecord(\""..sTable.."\", {", "})\n", (fPref.."@"..sTable)
Expand Down

0 comments on commit 03c600f

Please sign in to comment.