Skip to content

Commit

Permalink
xmlLoadString Compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
thisdp committed Mar 5, 2021
1 parent 7bf9751 commit 068834a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
30 changes: 27 additions & 3 deletions G2DManager_s.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@

xmlLoadStr = _G["xmlLoad".."String"]
if not xmlLoadStr then
tempXmlLogger = {count=0}
xmlLoadStr = function(str)
local tick = tempXmlLogger.count
tempXmlLogger.count = tempXmlLogger.count+1
local xmlFile = fileCreate("g2dCrawlTmp_"..tick..".xml")
fileWrite(xmlFile,str)
fileClose(xmlFile)
local xml = xmlLoadFile("g2dCrawlTmp_"..tick..".xml")
tempXmlLogger[xml] = {path="g2dCrawlTmp_"..tick..".xml"}
return xml
end
xmlReleaseTempFiles = function(xml)
if tempXmlLogger[xml] then
xmlUnloadFile(xml)
fileDelete(tempXmlLogger[xml].path)
tempXmlLogger[xml] = nil
end
end
else
xmlReleaseTempFiles = function() end
end

local function tableCount(tabl)
local cnt = 0
Expand Down Expand Up @@ -498,7 +520,7 @@ function CrawlWikiFromMTA(t)
liEnd_1,liEnd_2 = string.find(data,"%<%/li%>",startPos)
if not liStart_1 or not liEnd_1 then break end
local str = string.sub(data,liStart_2+1,liEnd_1-1)
local xmlNode = xmlLoadString(str)
local xmlNode = xmlLoadStr(str)
local fncName = xmlNodeGetValue(xmlNode)
local nTable = {
href=xmlNodeGetAttribute(xmlNode,"href"),
Expand All @@ -508,6 +530,7 @@ function CrawlWikiFromMTA(t)
}
table.insert(fncList,nTable)
startPos = liEnd_2
xmlReleaseTempFiles(xmlNode)
end
print("[DGS]Function list("..#fncList..") is ready, Crawling...")
local fRProg = {thread=0,index=0,valid=0,progress=0,total=#fncList}
Expand Down Expand Up @@ -537,8 +560,9 @@ function CrawlWikiFromMTA(t)
local startPos = data:find("%<textarea")
local _,endPos = data:find("%<%/textarea>",startPos)
local line = data:sub(startPos,endPos)
local xmlNode = xmlLoadString(line)
local xmlNode = xmlLoadStr(line)
local pageSource = xmlNodeGetValue(xmlNode)
xmlReleaseTempFiles(xmlNode)
local _,rangeStart = pageSource:find("==Syntax==")
local _,syntaxStart = pageSource:find("%<syntaxhighlight lang%=\"lua\"%>",rangeStart+1)
local syntaxEnd = pageSource:find("%<%/syntaxhighlight%>",syntaxStart+1)
Expand Down
2 changes: 1 addition & 1 deletion server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ setElementData(root,"DGS-ResName",getResourceName(getThisResource()))

-----------About DGS
addEventHandler("DGSI_RequestAboutData",resourceRoot,function()
if getVersion().sortable < "1.5.7-9.19626" then return outputChatBox("[DGS]Your server version is outdated upgrade to 1.5.7-9.19626 or higher",player,255,255,0) end
if not checkServerVersion(player) then return end
fetchRemote("https://raw.githubusercontent.com/thisdp/dgs/master/README.md",{},function(data,info,player)
triggerClientEvent(player,"DGSI_SendAboutData",resourceRoot,data)
end,{client})
Expand Down
21 changes: 20 additions & 1 deletion update.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,32 @@ function checkUpdate()
end)
end

function checkServerVersion(player)
if getVersion().sortable < "1.5.9-9.11342" then
if player then
local acc = getPlayerAccount(player)
if acc and getAccountName(acc) == "Console" then
outputDebugString("[DGS]Your server version is outdated upgrade to 1.5.4-9.11342 or higher",2)
else
outputChatBox("[DGS]Your server version is outdated upgrade to 1.5.4-9.11342 or higher",player,255,255,0)
end
return false
else
outputDebugString("[DGS]Your server version is outdated upgrade to 1.5.4-9.11342 or higher",2)
return false
end
end
return true
end

if dgsConfig.updateCheckAuto then
if not checkServerVersion() then return end
checkUpdate()
updatePeriodTimer = setTimer(checkUpdate,dgsConfig.updateCheckInterval*3600000,0)
end

addCommandHandler("updatedgs",function(player)
if getVersion().sortable < "1.5.7-9.19626" then return outputChatBox("[DGS]Your server version is outdated upgrade to 1.5.7-9.19626 or higher",player,255,255,0) end
if not checkServerVersion(player) then return end
local account = getPlayerAccount(player)
local isPermit = hasObjectPermissionTo(player,"command.updatedgs")
if not isPermit then
Expand Down

0 comments on commit 068834a

Please sign in to comment.