Skip to content

Commit

Permalink
不需要兼容Lua5.2了
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed May 25, 2018
1 parent d889867 commit d2f0617
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions scripts/war3/id.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ base.ids1 = {}
base.ids2 = {}

function base._id(a)
local s1 = math.floor(a/256/256/256)%256
local s2 = math.floor(a/256/256)%256
local s3 = math.floor(a/256)%256
local s4 = a%256
local r = string.char(s1, s2, s3, s4)
local r = ('>I4'):pack(a)
base.ids1[a] = r
base.ids2[r] = a
return r
Expand All @@ -18,11 +14,7 @@ function base.id2string(a)
end

function base.__id2(a)
local n1 = string.byte(a, 1) or 0
local n2 = string.byte(a, 2) or 0
local n3 = string.byte(a, 3) or 0
local n4 = string.byte(a, 4) or 0
local r = n1*256*256*256+n2*256*256+n3*256+n4
local r = ('>I4'):unpack(a)
base.ids2[a] = r
base.ids1[r] = a
return r
Expand Down

0 comments on commit d2f0617

Please sign in to comment.