Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions [gameplay]/mapfixes/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<setting name="*atrium_lobby_interior" value="[true]" friendlyname="Atrium Lobby Interior" desc="Enable Commerce Atrium lobby open-world interior" accept="true,false"/>
<setting name="*doherty_garage_interior" value="[true]" friendlyname="Doherty Garage Interior" desc="Enable Doherty Safehouse Garage open-world interior" accept="true,false"/>
<setting name="*undamaged_crackfactory_with_interior" friendlyname="Undamaged SF Crack Factory" value="[true]" desc="Enable restored Undamaged SF Crack Factory with open-world interior" accept="true,false"/>
<setting name="*model_transparency_fixes" friendlyname="Model Transparency Fixes" value="[true]" desc="Apply some fixes to certain models which have bugged transparency in GTA" accept="true,false"/>
</settings>
</meta>
32 changes: 29 additions & 3 deletions [gameplay]/mapfixes/scripts/client/main.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
addEvent("mapfixes:client:loadAllComponents", true)
addEvent("mapfixes:client:togOneComponent", true)

local function loadOneMapFixComponent(name, data)
local function loadOneMapFixComponent(name, data, wasToggled)
-- Clear the previous elements if any
local createdElements = data.createdElements
if createdElements then
Expand Down Expand Up @@ -34,9 +34,22 @@ local function loadOneMapFixComponent(name, data)
setGarageOpen(garageID, false)
end
end
-- Revert previously set model flags
local modelFlagsToSet = data.modelFlagsToSet
if modelFlagsToSet then
for _, v in pairs(modelFlagsToSet) do
engineSetModelFlag(v[1], v[2], not v[3])
end
end

-- Don't proceed if the component is disabled
if not data.enabled then

-- Force restream world after unloading this component
-- only if it was the only one toggled
if wasToggled then
engineRestreamWorld()
end
return
end

Expand All @@ -60,7 +73,6 @@ local function loadOneMapFixComponent(name, data)
if allocatedID then
if not data.allocatedIDs then data.allocatedIDs = {} end
data.allocatedIDs[#data.allocatedIDs + 1] = allocatedID

object = createObject(allocatedID, v.x, v.y, v.z, v.rx, v.ry, v.rz)
if object then
engineSetModelPhysicalPropertiesGroup(allocatedID, v.physicalPropertiesGroup)
Expand Down Expand Up @@ -94,6 +106,18 @@ local function loadOneMapFixComponent(name, data)
setGarageOpen(garageID, true)
end
end
-- Set model flags if any
if modelFlagsToSet then
for _, v in pairs(modelFlagsToSet) do
engineSetModelFlag(v[1], v[2], v[3])
end
end

-- Force restream world after loading this component
-- only if it was the only one toggled
if wasToggled then
engineRestreamWorld()
end
end

local function loadMapFixComponents(mapFixComponentStatuses)
Expand All @@ -105,6 +129,7 @@ local function loadMapFixComponents(mapFixComponentStatuses)
loadOneMapFixComponent(name, data)
end
end
engineRestreamWorld()
end
addEventHandler("mapfixes:client:loadAllComponents", localPlayer, loadMapFixComponents, false)

Expand All @@ -116,7 +141,7 @@ local function toggleOneMapFixComponent(name, enable)
return
end
data.enabled = (enable == true)
loadOneMapFixComponent(name, data)
loadOneMapFixComponent(name, data, true)
if eventName ~= "onClientResourceStop" then
outputDebugString("Map fix component '" .. name .. "' is now " .. (data.enabled and "enabled" or "disabled"))
end
Expand All @@ -127,5 +152,6 @@ local function unloadAllMapFixComponents()
for name, _ in pairs(mapFixComponents) do
toggleOneMapFixComponent(name, false)
end
engineRestreamWorld()
end
addEventHandler("onClientResourceStop", resourceRoot, unloadAllMapFixComponents, false)
5 changes: 5 additions & 0 deletions [gameplay]/mapfixes/scripts/shared/data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@ mapFixComponents = {
{ 11236, 25, -2164.4531, -255.39062, 38.125, 0 }, -- crackfactwalke
},
},
["model_transparency_fixes"] = {
modelFlagsToSet = {
{ 3089, 'draw_last', true }, -- ab_casdorLok (brown door with glass window)
}
},
}
Loading