diff --git a/newmodels_reborn/meta.xml b/newmodels_reborn/meta.xml
index fe2d7cc..b073e51 100644
--- a/newmodels_reborn/meta.xml
+++ b/newmodels_reborn/meta.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/newmodels_reborn/models/vehicle/490/-1.txt b/newmodels_reborn/models/vehicle/490/-1.txt
new file mode 100644
index 0000000..fe0589c
--- /dev/null
+++ b/newmodels_reborn/models/vehicle/490/-1.txt
@@ -0,0 +1,3 @@
+disableAutoFree
+disableTextureFiltering
+enableAlphaTransparency
\ No newline at end of file
diff --git a/newmodels_reborn/scripts/core/client_logic.lua b/newmodels_reborn/scripts/core/client_logic.lua
index 1c04329..79a5306 100644
--- a/newmodels_reborn/scripts/core/client_logic.lua
+++ b/newmodels_reborn/scripts/core/client_logic.lua
@@ -4,7 +4,7 @@ loadedModels = {}
local reusableModelElements = {}
-local currFreeIdDelay = 9500 -- ms
+local currFreeIdDelay = 9500 -- ms
local FREE_ID_DELAY_STEP = 500 -- ms
local function applyElementCustomModel(element)
@@ -61,20 +61,22 @@ local function loadCustomModel(customModel, elementToApply)
local colPath, txdPath, dffPath = customInfo.col, customInfo.txd, customInfo.dff
+ local disableTextureFiltering = customInfo.settings.disableTextureFiltering
+
local col, txd, dff
if colPath then
col = reusableModelElements[colPath] or engineLoadCOL(colPath)
end
if txdPath then
- txd = reusableModelElements[txdPath] or engineLoadTXD(txdPath)
+ txd = reusableModelElements[txdPath] or engineLoadTXD(txdPath, disableTextureFiltering and false or nil)
end
if dffPath then
dff = reusableModelElements[dffPath] or engineLoadDFF(dffPath)
end
if (colPath and not col)
- or (txdPath and not txd)
- or (dffPath and not dff) then
+ or (txdPath and not txd)
+ or (dffPath and not dff) then
if col and isElement(col) then destroyElement(col) end
if txd and isElement(txd) then destroyElement(txd) end
if dff and isElement(dff) then destroyElement(dff) end
@@ -83,9 +85,11 @@ local function loadCustomModel(customModel, elementToApply)
return
end
+ local enableAlphaTransparency = customInfo.settings.enableAlphaTransparency
+
if (col and not engineReplaceCOL(col, allocatedModel))
- or (txd and not engineImportTXD(txd, allocatedModel))
- or (dff and not engineReplaceModel(dff, allocatedModel)) then
+ or (txd and not engineImportTXD(txd, allocatedModel))
+ or (dff and not engineReplaceModel(dff, allocatedModel, enableAlphaTransparency or nil)) then
if col and isElement(col) then destroyElement(col) end
if txd and isElement(txd) then destroyElement(txd) end
if dff and isElement(dff) then destroyElement(dff) end
@@ -113,6 +117,8 @@ local function loadCustomModel(customModel, elementToApply)
reusableModelElements[dffPath] = dff
end
+ local disableAutoFree = customInfo.settings.disableAutoFree
+
-- Set loadedModel info
loadedModels[customModel] = {
id = allocatedModel,
@@ -120,7 +126,8 @@ local function loadCustomModel(customModel, elementToApply)
name = customInfo.name,
elementTypes = elementTypes,
freeAllocatedTimer = nil,
- modelPaths = { txd = txdPath, dff = dffPath, col = colPath }
+ modelPaths = { txd = txdPath, dff = dffPath, col = colPath },
+ disableAutoFree = disableAutoFree or false,
}
if isElement(elementToApply) then
@@ -150,7 +157,7 @@ local function freeAllocatedModelNow(customModel)
engineFreeModel(loadedModel.id)
-- Destroy model elements unless used by another loaded model
- for _, modelType in pairs({"dff", "txd", "col"}) do
+ for _, modelType in pairs({ "dff", "txd", "col" }) do
local modelPath = loadedModel.modelPaths[modelType]
if modelPath and reusableModelElements[modelPath] then
-- Check if another loaded model uses this model element
@@ -175,6 +182,11 @@ local function freeAllocatedModelNow(customModel)
end
local function freeAllocatedModel(customModel, loadedModel)
+ if loadedModel.disableAutoFree then
+ print("Not freeing custom model " .. customModel .. " because it has disableAutoFree set")
+ return
+ end
+
if isTimer(loadedModel.freeAllocatedTimer) then
killTimer(loadedModel.freeAllocatedTimer)
end
diff --git a/newmodels_reborn/scripts/core/server_logic.lua b/newmodels_reborn/scripts/core/server_logic.lua
index 0328fa9..3fd4275 100644
--- a/newmodels_reborn/scripts/core/server_logic.lua
+++ b/newmodels_reborn/scripts/core/server_logic.lua
@@ -1,3 +1,9 @@
+local CUSTOM_MODEL_SETTINGS = {
+ ["disableAutoFree"] = true,
+ ["disableTextureFiltering"] = true,
+ ["enableAlphaTransparency"] = true,
+}
+
local function loadModels()
if not pathIsDirectory("models") then
return false, "models directory not found"
@@ -29,25 +35,47 @@ local function loadModels()
local customModelInfo = {}
local function parseOneFile(thisFileName, thisFullPath, name)
local fileType = string.sub(thisFileName, -3)
- if not (fileType == "dff" or fileType == "txd" or fileType == "col") then
- return false, "invalid " .. modelType .. " file type: " .. fileType
- end
- local customModel = tonumber(string.sub(thisFileName, 1, -5))
- if not customModel then
- return false, "invalid " .. modelType .. " custom model: " .. thisFileName
- end
- if isDefaultID(modelType, customModel) then
- return false, "custom " .. modelType .. " model is a default ID: " .. customModel
- end
- if customModels[customModel] then
- return false, "duplicate " .. modelType .. " custom model: " .. customModel
- end
- if not customModelInfo[customModel] then
- customModelInfo[customModel] = {}
- end
- customModelInfo[customModel][fileType] = thisFullPath
- if name then
- customModelInfo[customModel].name = name
+ if (fileType == "dff" or fileType == "txd" or fileType == "col" or fileType == "txt") then
+ local customModel = tonumber(string.sub(thisFileName, 1, -5))
+ if not customModel then
+ return false, "invalid " .. modelType .. " custom model: " .. thisFileName
+ end
+ if not customModelInfo[customModel] then
+ if isDefaultID(modelType, customModel) then
+ return false, "custom " .. modelType .. " model is a default ID: " .. customModel
+ end
+ if customModels[customModel] then
+ return false, "duplicate " .. modelType .. " custom model: " .. customModel
+ end
+ customModelInfo[customModel] = {}
+ end
+ if fileType == "txt" then
+ local file = fileOpen(thisFullPath, true)
+ if not file then
+ return false, "failed to open file: " .. thisFullPath
+ end
+ local info = fileGetContents(file, false)
+ fileClose(file)
+ if not info then
+ return false, "failed to read file: " .. thisFullPath
+ end
+ local customModelSettings = {}
+ local lines = split(info, "\n")
+ for _, settingName in pairs(lines) do
+ settingName = settingName:gsub("\r", "")
+ local settingType = CUSTOM_MODEL_SETTINGS[settingName]
+ if settingType then
+ customModelSettings[settingName] = true
+ end
+ end
+ customModelInfo[customModel].settings = customModelSettings
+ iprint(customModelSettings)
+ else
+ customModelInfo[customModel][fileType] = thisFullPath
+ if name then
+ customModelInfo[customModel].name = name
+ end
+ end
end
return true
end
@@ -79,7 +107,8 @@ local function loadModels()
dff = info.dff,
txd = info.txd,
col = info.col,
- name = info.name or "Unnamed"
+ name = info.name or "Unnamed",
+ settings = info.settings or {},
}
end
end