Skip to content

Commit

Permalink
Fixed memory-leaking on server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
ERAGON007 committed Jul 3, 2021
1 parent 5a3e7f2 commit 696cd31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 2 additions & 3 deletions c_modelsLoader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ local function loadAllModels()
for _, modelObject in ipairs(_MODELS) do
if (modelObject.dontCache) then
triggerServerEvent("modelLoader:getModelFiles", resourceRoot, localPlayer, _)
return
else
loadOneModel(modelObject.txdFileName, modelObject.dffFileName, modelObject.objectId, modelObject.colFileName)
end

loadOneModel(modelObject.txdFileName, modelObject.dffFileName, modelObject.objectId, modelObject.colFileName)
end
end

Expand Down
13 changes: 11 additions & 2 deletions s_modelsHandler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ function(thePlayer, modelIndex)
if not(txdFile and dffFile) then outputDebugString("couldn't load txd or dff file for " .. _MODELS[modelIndex].txdFileName .. " and " .. _MODELS[modelIndex].dffFileName, 1, 255, 0, 0) return end

local colFile
local col
if (_MODELS[modelIndex].colFileName) then
colFile = fileOpen("Models/" .. _MODELS[modelIndex].colFileName, true)
local col = fileOpen("Models/" .. _MODELS[modelIndex].colFileName, true)
colFile = fileRead(col, fileGetSize(col))
end

triggerClientEvent(thePlayer, "modelLoader:loadOneModel", resourceRoot, txdFile, dffFile, _MODELS[modelIndex].objectId, colFile)
triggerClientEvent(thePlayer, "modelLoader:loadOneModel", resourceRoot, fileRead(txdFile, fileGetSize(txdFile)), fileRead(dffFile, fileGetSize(dffFile)), _MODELS[modelIndex].objectId, colFile)

fileClose(txdFile)
fileClose(dffFile)

if (col) then
fileClose(col)
end
else
outputDebugString("invalid arguments given for 'modelLoader:getModelFiles' Event (server-side)", 1, 255, 0, 0)
end
Expand Down

0 comments on commit 696cd31

Please sign in to comment.