Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 20 additions & 4 deletions newmodels_red/scripts/core/client_logic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ local function finishLoadCustomModel(customModel)

local allocatedModel = queuedInfo.allocatedModel
local col, txd, dff = queuedInfo.col, queuedInfo.txd, queuedInfo.dff
local elementToApply = queuedInfo.elementToApply
local waitingElements = queuedInfo.waitingElements or {}

local function cancelLoading()
-- Destroy all non-reused col/txd/dff elements
Expand Down Expand Up @@ -146,8 +146,11 @@ local function finishLoadCustomModel(customModel)
},
disableAutoFree = disableAutoFree or false,
}
if isElement(elementToApply) then
applyElementCustomModel(elementToApply)

for element, _ in pairs(waitingElements) do
if isElement(element) then
applyElementCustomModel(element)
end
end

loadingQueue[customModel] = nil
Expand Down Expand Up @@ -388,6 +391,14 @@ local function beginDownloadModelFiles(customModel)
end

local function beginLoadCustomModel(customModel, elementToApply)
if loadingQueue[customModel] then
-- Model is already loading, add this element to the waiting list
if isElement(elementToApply) then
loadingQueue[customModel].waitingElements[elementToApply] = true
end
return
end

local customInfo = customModels[customModel]
if not customInfo then
outputDebugString("Trying to load custom model " .. customModel .. " that does not exist", 2)
Expand All @@ -406,8 +417,13 @@ local function beginLoadCustomModel(customModel, elementToApply)
if txdPath then filesList[#filesList + 1] = { type = "txd", path = txdPath } end
if dffPath then filesList[#filesList + 1] = { type = "dff", path = dffPath } end

local waitingElements = {}
if isElement(elementToApply) then
waitingElements[elementToApply] = true
end

loadingQueue[customModel] = {
elementToApply = elementToApply,
waitingElements = waitingElements,
filesList = filesList,
-- Start in Phase 1
phase = LOADING_QUEUE_PHASES.DOWNLOAD_FILES,
Expand Down
4 changes: 3 additions & 1 deletion newmodels_red/scripts/optional/debug/c_debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@ end

local function updateDebugViewInfo()
local loadedModelsStr_ = ""
local count = 0
for customModel, v in pairsByKeys(loadedModels) do
local str = ("%d \"%s\" (%d)"):format(customModel, v.name, v.baseModel)
if loadedModelsStr_ == "" then
loadedModelsStr_ = str
else
loadedModelsStr_ = str .. ", " .. loadedModelsStr_
end
count = count + 1
end
if loadedModelsStr_ ~= "" then
loadedModelsStr = "Loaded new models (client-side):\n" .. loadedModelsStr_
loadedModelsStr = ("Loaded new models (client-side: %d):\n"):format(count) .. loadedModelsStr_
else
loadedModelsStr = "No new models loaded (client-side)"
end
Expand Down