|
发表于 2009-11-27 15:22:33
|
显示全部楼层
constant function IMax takes integer i1,integer i2 returns integer
if(i1>i2)then
return i1
else
return i2
endif
endfunction
constant function RMax takes real r1,real r2 returns real
if(r1>r2)then
return r1
else
return r2
endif
endfunction
constant function IMin takes integer i1,integer i2 returns integer
if(i1<i2)then
return i1
else
return i2
endif
endfunction
constant function RMin takes real r1,real r2 returns real
if(r1<r2)then
return r1
else
return r2
endif
endfunction
function Mod takes integer m, integer d returns integer
return m - (m / d) * d
endfunction
function Modi takes integer m, integer d returns integer
if(d==0)then
return m
endif
return m - (m / d) * d
endfunction
function Mod_EX takes integer m, integer d,integer p returns integer
return (m - (m / d) * d)/p
endfunction
function Modi_EX takes integer m, integer d,integer p returns integer
if(d==0 or p==0)then
return m
endif
return (m - (m / d) * d)/p
endfunction
function PowI takes integer c,integer p returns integer
local integer val = 1
local integer i = 0
loop
exitwhen(i>=p)
set val = val * c
set i = i + 1
endloop
return val
endfunction
function Int2RGB takes integer i,integer c returns integer
if(c<0 or c>2)then
return 0
endif
return Mod_EX(i,PowI(256,c+1),PowI(256,c))
endfunction
function RGB2Int takes integer r,integer g,integer b returns integer
return b*PowI(256,2) + g*256 + r
endfunction
function BlizzardId2IntSingle takes integer b returns integer
if(b>=48 and b<=57)then
return b-48
elseif(b>=65 and b<=90)then
return b-55
elseif(b>=97 and b<=122)then
return b-87
endif
return 0
endfunction
function BlizzardId2Int takes integer b returns integer
local integer k = b
local integer n
local integer s = 0
set n = Mod(k,256)
set s = s+BlizzardId2IntSingle(n)
set k = k - n
set n = Mod_EX(k,65536,256)
set s = s+BlizzardId2IntSingle(n)*36
set k = k - n
set n = Mod_EX(k,16777216,65536)
set s = s+BlizzardId2IntSingle(n)*1296
set k = k - n
set n = k/16777216
set s = s+BlizzardId2IntSingle(n)*46656
return s
endfunction
constant function IConfig takes integer i,integer min,integer max returns integer
return IMax(min,IMin(i,max))
endfunction
constant function RConfig takes real r,real min,real max returns real
return RMax(min,RMin(r,max))
endfunction |
|