|
发表于 2009-11-15 12:00:17
|
显示全部楼层
[jass]
globals
    integer  array              SYS_ItemId
integer array SYS_ItemInitIndex_Count
integer array SYS_ItemInitIndex_Mask
    integer  array              SYS_ItemIdData
    integer  array              SYS_ItemIdDataEx
endglobals
//----SideCode----------------------
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
function GetHashIndex takes integer i returns integer
    return Mod(i,8191)+1
endfunction
function GetNextHashIndex takes integer i returns integer
    return Mod(i*33,8191)+1
endfunction
//----Main------------------------------
function GetItemHashIndexById takes integer id returns integer
local integer idEx = BlizzardId2Int(id)
local integer tmp = GetHashIndex(idEx)
local integer mask = tmp
local integer c = 0
local integer ci = SYS_ItemInitIndex_Count[tmp]
loop
exitwhen(c>=ci)
if(SYS_ItemId[tmp]!=null)then
if(SYS_ItemId[tmp]==id)then
return tmp
endif
if(SYS_ItemId_Mask[tmp]==mask)then
set c = c + 1
endif
endif
set tmp = GetNextHashIndex(tmp)
endloop
return 0
endfunction
function RegisterItemHashIndexById takes integer id returns integer
local integer idEx = BlizzardId2Int(id)
local integer tmp = GetHashIndex(idEx)
local integer mask = tmp
local integer c = 0
local integer i = 0
local integer ci = 0
if(SYS_ItemInitIndex_Count[tmp]==null or SYS_ItemInitIndex_Count[tmp]==0)then
set SYS_ItemInitIndex_Count[tmp] = 1
else
set SYS_ItemInitIndex_Count[tmp] = SYS_ItemInitIndex_Count[tmp] + 1
endif
set ci = SYS_ItemInitIndex_Count[tmp]
loop
exitwhen(c>=ci)
if(SYS_ItemInitIndex[tmp]==0 or SYS_ItemInitIndex[tmp]==null)then
set SYS_ItemId[tmp] = id
set SYS_ItemId_Mask[tmp] = mask
set SYS_ItemInitIndex[tmp] = GetItemCommonDataPos()
set SYS_ItemDataEnhancePos = 1
return tmp
elseif(SYS_ItemId[tmp]==id)then
return 0
endif
if(SYS_ItemId_Mask[tmp]==mask)then
set c = c + 1
endif
set tmp = GetNextHashIndex(tmp)
endloop
set SYS_ItemInitIndex_Count[mask] = SYS_ItemInitIndex_Count[mask] - 1
return 0
endfunction
[/jass] |
|