Skip to content

Commit

Permalink
Use FixSlashes() on Path to normalise to forward slash
Browse files Browse the repository at this point in the history
  • Loading branch information
EnAppelsin committed Aug 7, 2018
1 parent 4cddaac commit 0506a9e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions Randomiser/Resources/GlobalFunctions.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-- Override GetPath to fix slashes for us
OriginalGetPath = GetPath
GetPath = function ()
return FixSlashes(OriginalGetPath(), false, true)
end

function GetRandomFromTbl(tbl, remove)
local i = math.random(#tbl)
local result = tbl[i]
Expand Down
8 changes: 4 additions & 4 deletions Randomiser/Resources/HandleCharModel.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local Path = GetPath()

if SettingRandomCharacter and OrigChar and (Path:match("art\\chars\\" .. OrigChar .. "_m%.p3d") or Path:match("art\\chars\\" .. OrigChar:sub(1,1) .. ".-_m%.p3d")) then
if SettingRandomCharacter and OrigChar and (Path:match("art/chars/" .. OrigChar .. "_m%.p3d") or Path:match("art/chars/" .. OrigChar:sub(1,1) .. ".-_m%.p3d")) then
local Original = ReadFile("GameData/" .. Path)
local ReplacePath = "/GameData/art/chars/" .. GetRandomFromTbl(RandomCharP3DPool, false) .. ".p3d"
local Replace = ReadFile(ReplacePath)
Expand All @@ -18,7 +18,7 @@ else
if model:len() > 6 then
model = model:sub(1, 6)
end
if Path:match("art\\chars\\" .. model .. "_m%.p3d") then
if Path:match("art/chars/" .. model .. "_m%.p3d") then
local Original = ReadFile("GameData/" .. Path)
local ReplacePath = "/GameData/art/chars/" .. GetRandomFromTbl(RandomCharP3DPool, false) .. ".p3d"
local Replace = ReadFile(ReplacePath)
Expand All @@ -38,7 +38,7 @@ else
if model:len() > 6 then
model = model:sub(1, 6)
end
if Path:match("art\\chars\\" .. model .. "_m%.p3d") then
if Path:match("art/chars/" .. model .. "_m%.p3d") then
local Original = ReadFile("GameData/" .. Path)
local ReplacePath = "/GameData/art/chars/" .. GetRandomFromTbl(RandomCharP3DPool, false) .. ".p3d"
local Replace = ReadFile(ReplacePath)
Expand All @@ -59,7 +59,7 @@ else
if model:len() > 6 then
model = model:sub(1, 6)
end
if Path:match("art\\chars\\" .. model .. "_m%.p3d") then
if Path:match("art/chars/" .. model .. "_m%.p3d") then
local Original = ReadFile("GameData/" .. Path)
local ReplacePath = "/GameData/art/chars/" .. GetRandomFromTbl(RandomCharP3DPool, false) .. ".p3d"
local Replace = ReadFile(ReplacePath)
Expand Down
4 changes: 2 additions & 2 deletions Randomiser/Resources/HandleMission.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ elseif Lidx ~= nil then
DebugPrint("Randomising " .. orig .. " to " .. carName)
end
end
elseif SettingDifferentCellouts and Path:match("level02\\m7l.mfk") then
elseif SettingDifferentCellouts and Path:match("level02/m7l.mfk") then
NewFile = NewFile:gsub("cCellA", "cCellA1")
NewFile = NewFile .. "LoadDisposableCar(\"art\\cars\\cCellA2.p3d\",\"cCellA2\",\"AI\");\r\n"
NewFile = NewFile .. "LoadDisposableCar(\"art\\cars\\cCellA3.p3d\",\"cCellA3\",\"AI\");\r\n"
Expand All @@ -233,7 +233,7 @@ elseif Lidx ~= nil then
else
MissionVehicles = {}
local TmpCarPool = {table.unpack(RandomCarPoolMission)}
if Path:match("level02\\m7l.mfk") then
if Path:match("level02/m7l.mfk") then
NewFile = NewFile:gsub("cCellA", "cCellA1")
NewFile = NewFile .. "LoadDisposableCar(\"art\\cars\\cCellA2.p3d\",\"cCellA2\",\"AI\");\r\n"
NewFile = NewFile .. "LoadDisposableCar(\"art\\cars\\cCellA3.p3d\",\"cCellA3\",\"AI\");\r\n"
Expand Down

0 comments on commit 0506a9e

Please sign in to comment.