Skip to content

Commit

Permalink
Merge pull request NPLPackages#77 from onedou/fix/2020-03-11
Browse files Browse the repository at this point in the history
fix update check for mac
  • Loading branch information
LiXizhi authored Mar 11, 2020
2 parents 130339b + 614daa2 commit 69ba6e7
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions script/apps/Aries/Creator/Game/Login/ClientUpdater.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,58 @@ function ClientUpdater:Check(callbackFunc)
return
end
-- echo({self.autoUpdater:getCurVersion(), self.autoUpdater:getLatestVersion()});

-- we will not update for mac if software version heighter then remote version
if System.os.GetPlatform() == 'mac' then
local function CompareVersion(a, b)
-- a < b return -1
-- a == b return 0
-- a > b return 1
-- format error return nil
local function GetVersions(versionStr)
local result = {};
for s in string.gfind(versionStr, "%d+") do
table.insert(result, tonumber(s));
end
return result;
end

local aVersionList = GetVersions(a);
local bVersionList = GetVersions(b);

if (#aVersionList < 3 or #bVersionList < 3) then
return nil;
end

if (aVersionList[1] < bVersionList[1])then
return -1;
elseif (aVersionList[1] == bVersionList[1]) then
if (aVersionList[2] < bVersionList[2]) then
return -1;
elseif (aVersionList[2] == bVersionList[2]) then
if (aVersionList[3] < bVersionList[3]) then
return -1;
elseif (aVersionList[3] == bVersionList[3]) then
return 0;
else
return 1;
end
else
return 1;
end
else
return 1;
end
end

local compareResult = CompareVersion(self:GetCurrentVersion(), self.autoUpdater:getLatestVersion())

if (compareResult == 1 or compareResult == 0) then
callbackFunc(false, self:GetCurrentVersion());
return true
end
end

if(bSucceed) then
if(self.autoUpdater:isNeedUpdate())then
callbackFunc(true, self.autoUpdater:getLatestVersion());
Expand Down

0 comments on commit 69ba6e7

Please sign in to comment.