|
| 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) |
0 commit comments