Skip to content

Commit 205a22e

Browse files
authored
Version 3.1.5W
Complete rework part 2
1 parent 0f07e28 commit 205a22e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+5177
-662
lines changed

MODBUILDER/CheckCONFLICTLOG.lua

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
function LocatePAK(CurrentMBIN)
2+
local TextFileTable = ParseTextFileIntoTable(arg[2].."pak_list.txt")
3+
4+
--because pak_list.txt uses / (and "xxx") and MBIN_PAKS.txt uses \
5+
TempMBIN = string.sub(string.gsub(CurrentMBIN,[[\]],[[/]]),2,#CurrentMBIN - 1)
6+
7+
local NMSPAKname = ""
8+
local found = false
9+
10+
for i=1,#TextFileTable do
11+
local line = TextFileTable[i]
12+
if (line ~= nil) then
13+
if (string.find(line,"Listing ",1,true) ~= nil) then
14+
local start,stop = string.find(line,"Listing ",1,true)
15+
NMSPAKname = string.sub(line, stop+1)
16+
elseif (string.find(line,TempMBIN,1,true) ~= nil) then
17+
found = true
18+
break
19+
end
20+
end
21+
end
22+
if not found then
23+
NMSPAKname = "Only in User paks below"
24+
end
25+
26+
return NMSPAKname
27+
end
28+
29+
-- ****************************************************
30+
-- main
31+
-- ****************************************************
32+
33+
--arg[1] == path to REPORT.txt
34+
--arg[2] == path to MODBUILDER
35+
--arg[3] == a message
36+
--arg[4] == 1 (check NMS MODS for conflict)
37+
38+
if gVerbose == nil then dofile(arg[2]..[[LoadHelpers.lua]]) end --.\MODBUILDER\
39+
pv(">>> In CheckCONFLICTLOG.lua")
40+
gfilePATH = arg[1] --to use by LoadHelpers.Report()
41+
THIS = "In CheckCONFLICTLOG: "
42+
43+
-- -- Report(arg[3])
44+
-- local LogTable = ParseTextFileIntoTable(arg[1]..[[REPORT.txt]])
45+
local CheckMODSconflicts = (arg[4] == "1")
46+
47+
if CheckMODSconflicts then
48+
--merge MODS_pak_list with MBIN_PAKS
49+
local MODSTable = ParseTextFileIntoTable(arg[2]..[[MODS_pak_list.txt]])
50+
local pakName = ""
51+
for i=1,#MODSTable do
52+
local text = MODSTable[i]
53+
if text ~= nil and trim(text) ~= "" then
54+
if string.sub(text,1,7) == "Listing" then
55+
pakName = string.sub(text,9)
56+
elseif string.sub(text,1,5) == "FROM " then
57+
if string.sub(text,6) == "MODS" then
58+
else -- "ModScript"
59+
end
60+
else
61+
local pakFile = string.gsub(StripInfo(text,[[]],[[ (]]),[[/]],[[\]])
62+
-- because some user pak file list may start with / or other non-letters
63+
local start = string.find(pakFile,"%a")
64+
pakFile = string.sub(pakFile,start)
65+
WriteToFileAppend(pakFile..", : "..pakName.."\n",arg[2]..[[MBIN_PAKS.txt]])
66+
end
67+
end
68+
end
69+
end
70+
71+
local ConflictScriptTable = ParseTextFileIntoTable(arg[2]..[[MBIN_PAKS.txt]])
72+
73+
--[[ debug purposes only
74+
-- WriteToFile("", "MBIN_PAKS_scrubbed.txt")
75+
-- for i=1,#ConflictScriptTable do
76+
-- local text = ConflictScriptTable[i]
77+
-- if text ~= nil and trim(text) ~= "" then
78+
-- WriteToFileAppend(text.."\n", "MBIN_PAKS_scrubbed.txt")
79+
-- end
80+
-- end
81+
-- print(os.date())
82+
--]]
83+
84+
if CheckMODSconflicts then
85+
print()
86+
print(">>> Checking Conflicts in Processed Scripts/paks and NMS MODS paks. Please wait...")
87+
Report("")
88+
Report("",">>> Checked Conflicts in Processed Scripts/paks and NMS MODS paks.")
89+
Report("")
90+
else
91+
print()
92+
print("===== Conflicts in NMS MODS where NOT checked at user request =====")
93+
-- print()
94+
Report("")
95+
Report("","===== Conflicts in NMS MODS where NOT checked at user request =====")
96+
-- Report("")
97+
98+
-- print()
99+
print(">>> Checking Conflicts in Processed Scripts/paks only. Please wait...")
100+
-- Report("")
101+
Report("",">>> ONLY Checked Conflicts in Processed Scripts/paks.")
102+
Report("")
103+
end
104+
105+
local ConflictsDetected = false
106+
local modulo = 1
107+
local display = false
108+
if #ConflictScriptTable > 500 then
109+
display = true
110+
modulo = math.ceil(#ConflictScriptTable / 10)
111+
end
112+
if #ConflictScriptTable - 1 > 0 then
113+
if display then
114+
print(" We have "..#ConflictScriptTable.." lines to process, be patient! WORKING...")
115+
else
116+
print(" We have "..#ConflictScriptTable.." lines to process! WORKING...")
117+
end
118+
end
119+
120+
for i=1,#ConflictScriptTable do
121+
if display and i%modulo == 0 then print(string.format("%9u of %u lines processed...",i,#ConflictScriptTable)) end
122+
local text = ConflictScriptTable[i]
123+
if text ~= nil and trim(text) ~= "" then
124+
local ConflictYet = false
125+
local MBINname = [["]]..StripInfo(text,[[]],[[,]])..[["]]
126+
local SCRIPTname = [["]]..StripInfo(text,[[, ]],[[:]])..[["]]
127+
local PAKname = [["]]..StripInfo(text,[[: ]])..[["]]
128+
129+
for j=i+1,#ConflictScriptTable do
130+
local text1 = ConflictScriptTable[j]
131+
if text1 ~= nil and trim(text1) ~= "" then
132+
local MBINname1 = [["]]..StripInfo(text1,[[]],[[,]])..[["]]
133+
local SCRIPTname1 = [["]]..StripInfo(text1,[[, ]],[[:]])..[["]]
134+
local PAKname1 = [["]]..StripInfo(text1,[[: ]])..[["]]
135+
136+
if PAKname ~= PAKname1 then --different PAKname, investigate
137+
if MBINname == MBINname1 then --same MBINname, a conflict
138+
if not ConflictYet then
139+
--this one is modified by another one
140+
pv("Conflict in line "..i)
141+
ConflictYet = true
142+
ConflictsDetected = true
143+
local NMSPAKname = LocatePAK(MBINname)
144+
Report("",MBINname..[[ (]]..NMSPAKname..[[)]],"CONFLICT")
145+
Report("","is MOD-ified by:")
146+
if trim(SCRIPTname) ~= [[""]] then
147+
Report("","\t\t "..SCRIPTname..[[ (==> ModScript folder)]])
148+
else
149+
local PAKname = [["]]..StripInfo(text,[[: ]])..[["]]
150+
local start,stop = string.find(PAKname,[[..\ModScript\]],1,true)
151+
local comingFrom = "==> NMS MODS folder"
152+
if stop ~= nil then
153+
PAKname = [["]]..string.sub(PAKname,stop+1)
154+
comingFrom = "==> ModScript folder"
155+
end
156+
Report("","\t\t "..PAKname.." ("..comingFrom..")")
157+
end
158+
end
159+
if ConflictYet then
160+
if trim(SCRIPTname1) ~= [[""]] then
161+
Report("","\t\t+ "..SCRIPTname1..[[ (==> ModScript folder)]])
162+
else
163+
local start,stop = string.find(PAKname1,[[..\ModScript\]],1,true)
164+
local comingFrom = "==> NMS MODS folder"
165+
if stop ~= nil then
166+
PAKname1 = [["]]..string.sub(PAKname1,stop+1)
167+
comingFrom = "==> ModScript folder"
168+
end
169+
Report("","\t\t+ "..PAKname1.." ("..comingFrom..")")
170+
end
171+
ConflictScriptTable[j] = ""
172+
pv(" With line "..j)
173+
end
174+
end
175+
else --same PAKname
176+
if MBINname == MBINname1 then --same MBINNAME
177+
ConflictScriptTable[j] = ""
178+
pv("Rejected line "..j)
179+
-- elseif trim(SCRIPTname) ~= [[""]] and SCRIPTname == SCRIPTname1 then --same SCRIPTname
180+
-- ConflictScriptTable[j] = ""
181+
end
182+
end
183+
end
184+
end
185+
if Conflict then
186+
Report("")
187+
end
188+
end
189+
end
190+
191+
print()
192+
if ConflictsDetected then
193+
-- print([[XXXXX Some conflicts were detected, see "REPORT.txt" XXXXX]])
194+
-- print(" If you already made COMBINED paks for each, you're OK.")
195+
-- print(" Note, the COMBINED pak should also be listed as a conflicting file")
196+
-- print(" Otherwise, please COMBINE those scripts that MOD-ify the same file")
197+
-- print(" If you want them together in MODS to get the full effect of each script/mod")
198+
-- print()
199+
-- Report("")
200+
-- Report("","XXXXX Some conflicts were detected XXXXX","ABOUT CONFLICTS")
201+
-- Report(""," If you already made COMBINED paks for each, you're OK.","ABOUT CONFLICTS")
202+
-- Report(""," Note, the COMBINED pak should also be listed as a conflicting file","ABOUT CONFLICTS")
203+
-- Report(""," Otherwise, please COMBINE those scripts that MOD-ify the same file","ABOUT CONFLICTS")
204+
-- Report(""," If you want them together in MODS to get the full effect of each script/mod","ABOUT CONFLICTS")
205+
-- Report("")
206+
else
207+
-- print("***** NO CONFLICT DETECTED IN USED SCRIPTS *****")
208+
-- print(" It is safe to use together any of the generated PAK")
209+
-- print()
210+
-- Report("")
211+
-- Report("","***** NO CONFLICT DETECTED IN USED SCRIPTS *****")
212+
-- Report(""," It is safe to use together any of the generated PAK")
213+
-- Report("")
214+
215+
end
216+
217+
LuaEndedOk(THIS)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
-- ****************************************************
2+
-- main
3+
-- ****************************************************
4+
5+
--arg[1] == path to REPORT.txt
6+
--arg[2] == path to MODBUILDER
7+
8+
if gVerbose == nil then dofile(arg[2]..[[LoadHelpers.lua]]) end --.\MODBUILDER\
9+
pv(">>> In CheckGlobalReplacements.lua")
10+
gfilePATH = arg[1] --to use by LoadHelpers.Report()
11+
THIS = "In CheckGlobalReplacements: "
12+
13+
local LogTable = ParseTextFileIntoTable(arg[1]..[[REPORT.txt]])
14+
local ScriptName = ""
15+
local ActionCount = -1
16+
local ScriptCount = -1
17+
18+
local NoProblems = true
19+
Report("")
20+
for i=1,#LogTable do
21+
local line = LogTable[i]
22+
if line ~= nil and string.find(line,"Starting to process script",1,true) ~= nil then
23+
ScriptName = StripInfo(line," [","]")
24+
end
25+
if line ~= nil and string.find(line,"Ended script processing with",1,true) ~= nil then
26+
ActionCount = tonumber(StripInfo(line," ["," action"))
27+
end
28+
if ScriptName ~= "" and ActionCount >= 0 then
29+
local ScriptTable = ParseTextFileIntoTable(arg[1]..[[ModScript\]]..ScriptName)
30+
for j=1,#ScriptTable do
31+
local line = ScriptTable[j]
32+
if line ~= nil and string.find(line,"global replacements",1,true) ~= nil then
33+
ScriptCount = tonumber(StripInfo(line,"--"," global"))
34+
end
35+
end
36+
37+
local state = "ERROR"
38+
if ScriptCount == ActionCount then
39+
state = "INFO"
40+
elseif ScriptCount == -1 then
41+
ScriptCount = "???"
42+
state = "WARNING"
43+
end
44+
45+
if state ~= "INFO" then
46+
NoProblems = false
47+
-- Report("")
48+
Report("",ScriptName..": "..ScriptCount.." global replacements / "..ActionCount.." action(s)",state)
49+
end
50+
51+
--reset for next script
52+
ScriptName = ""
53+
ActionCount = -1
54+
ScriptCount = -1
55+
end
56+
end
57+
58+
if NoProblems then
59+
Report("","ALL scripts are OK!")
60+
end
61+
62+
LuaEndedOk(THIS)
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
--arg[1] == path to REPORT.txt
2+
--arg[2] == path to MODBUILDER
3+
--arg[3] == a message
4+
5+
if gVerbose == nil then dofile(arg[2]..[[LoadHelpers.lua]]) end --in MODBUILDER
6+
pv(">>> In CheckMBINCompilerLOG.lua")
7+
gfilePATH = arg[1] --for Report()
8+
THIS = "In CheckMBINCompilerLOG: "
9+
10+
local LogTable, LineCount = ParseTextFileIntoTable(arg[2]..[[MBINCompiler.log]])
11+
local MASTER_FOLDER_PATH = LoadFileData(arg[2]..[[MASTER_FOLDER_PATH.txt]])
12+
13+
local say = arg[3]
14+
-- because string.gsub pattern does not work with all folder names (ex.: ".")
15+
if string.find(say,MASTER_FOLDER_PATH..[[MODBUILDER\MOD\]],1,true) ~= nil then
16+
local start = string.find(say,MASTER_FOLDER_PATH..[[MODBUILDER\MOD\]],1,true)
17+
say = string.sub(say,1,start - 1)..string.sub(say,string.len(MASTER_FOLDER_PATH..[[MODBUILDER\MOD\]]) + start)
18+
end
19+
20+
local Compiling = true
21+
local MessageStart = 10
22+
if string.sub(say,1,1) == "D" then
23+
--we are Decompiling
24+
Compiling = false
25+
MessageStart = 12
26+
end
27+
28+
local warningCount = 0
29+
local errorCount = 0
30+
for i=1,LineCount do
31+
if string.find(LogTable[i],"[WARN]",1,true) then
32+
warningCount = warningCount + 1
33+
end
34+
if string.find(LogTable[i],"[ERROR]",1,true) then
35+
errorCount = errorCount + 1
36+
end
37+
end
38+
39+
if warningCount > 0 then
40+
if Compiling then
41+
Report("","Trying to compile... "..string.sub(say,MessageStart))
42+
else
43+
Report("","Trying to decompile... "..string.sub(say,MessageStart))
44+
end
45+
local Found = false
46+
for i=1,LineCount do
47+
if not Found and string.find(LogTable[i],"[WARN]",1,true) then
48+
Found = true
49+
-- local info = LogTable[i+3] --print filepath+name
50+
-- print(info)
51+
local info = LogTable[i]
52+
local start,ending = string.find(info,"[WARN]: [",1,true)
53+
if ending ~= nil then
54+
info = string.sub(info,ending+1,#info-2)
55+
end
56+
print(" [WARNING] MBINCompiler = "..info.." OR check your script!")
57+
Report(info.." OR check your script!","MBINCompiler =","WARNING")
58+
elseif Found then
59+
info = LogTable[i]
60+
if info == nil or trim(info) == ""
61+
or string.find(info," converted.",1,true)
62+
or string.find(info," WARNINGS.",1,true)
63+
or string.find(info," TIME:",1,true)
64+
or string.find(info,"[FILE]:",1,true) then
65+
--skip it
66+
else
67+
print(" [WARN] MBINCompiler = "..info)
68+
Report(info," MBINCompiler =","WARN")
69+
end
70+
end
71+
end
72+
end
73+
74+
if errorCount > 0 then
75+
if Compiling then
76+
Report("","Trying to compile "..string.sub(say,MessageStart))
77+
else
78+
Report("","Trying to decompile "..string.sub(say,MessageStart))
79+
end
80+
local Found = false
81+
for i=1,LineCount do
82+
if not Found and string.find(LogTable[i],"[ERROR]",1,true) then
83+
Found = true
84+
-- local info = LogTable[i+3] --print filepath+name
85+
-- print(info)
86+
local info = LogTable[i]
87+
local start,ending = string.find(info,"[ERROR]: [",1,true)
88+
if ending ~= nil then
89+
info = string.sub(info,ending,#info-1)
90+
end
91+
print(" [ERROR] MBINCompiler = "..info.." OR check your script!")
92+
Report(info.." OR check your script!","MBINCompiler =","ERROR")
93+
Report("The PAK will not include this EXML!","","PSARC")
94+
elseif Found then
95+
info = LogTable[i]
96+
if info == nil or trim(info) == ""
97+
or string.find(info," converted.",1,true)
98+
or string.find(info," FAILED.",1,true)
99+
or string.find(info," TIME:",1,true)
100+
or string.find(info,"[ERROR]:",1,true)
101+
or string.find(info,"[FILE]:",1,true) then
102+
--skip it
103+
else
104+
print(" [ERR] MBINCompiler = "..info)
105+
Report(info," MBINCompiler =","ERR")
106+
end
107+
end
108+
end
109+
end
110+
111+
if warningCount == 0 and errorCount == 0 then
112+
Report("SUCCESS "..say)
113+
end
114+
115+
LuaEndedOk(THIS)

0 commit comments

Comments
 (0)