|
楼主 |
发表于 2012-2-3 13:56:32
|
显示全部楼层
[jass]
function LoadFile takes string fn,gamecache gc returns nothing
local string mk
local string ky
local string tc
local integer px
local integer di
local integer ix
local integer sl
local integer tl
local integer od
local string array pn
local string array ld
set px = 0
loop
exitwhen(px>=16)
set pn[px] = GetPlayerName(Player(px))
call SetPlayerName(Player(px)," ")
set px = px + 1
endloop
call Preloader(fn)
set px = 0
loop
exitwhen(px>=16)
set ld[px] = GetPlayerName(Player(px))
call SetPlayerName(Player(px),pn[px])
set px = px + 1
endloop
set mk = I2S(GetPlayerId(GetLocalPlayer())+1)
set ky = I2S(0)
set od = GetStoredInteger(gc,mk,ky)
call StoreInteger(gc,mk,ky,-1)
call SyncStoredInteger(gc,mk,ky)
call StoreInteger(gc,mk,ky,od)
set di = 0
set px = 0
loop
exitwhen(px>=16)
set tc = ld[px]
exitwhen(tc==" ")
set sl = StringLength(tc)
set ix = 0
loop
exitwhen(ix>=sl)
set tl = ix
loop
exitwhen(ix>=sl)
exitwhen(SubString(tc,ix,ix+1)==",")
set ix = ix + 1
endloop
set di = di + 1
set ky = I2S(di)
set tl = S2I(SubString(tc,tl,ix))
set od = GetStoredInteger(gc,mk,ky)
call StoreInteger(gc,mk,ky,tl)
call SyncStoredInteger(gc,mk,ky)
call StoreInteger(gc,mk,ky,od)
set ix = ix + 1
endloop
set px = px + 1
endloop
set ky = I2S(0)
set od = GetStoredInteger(gc,mk,ky)
call StoreInteger(gc,mk,ky,di)
call SyncStoredInteger(gc,mk,ky)
call StoreInteger(gc,mk,ky,od)
endfunction
function SaveFile takes string fn,gamecache gc returns nothing
local string mk
local string ky
local string sd
local integer px
local integer dc
local integer di
set mk = I2S(GetPlayerId(GetLocalPlayer())+1)
set ky = I2S(0)
set dc = GetStoredInteger(gc,mk,ky)
call PreloadGenClear()
call PreloadGenStart()
set px = 0
loop
exitwhen(px>=16)
exitwhen(px*16>=dc)
set sd = ""
set di = 0
loop
exitwhen(di>=16)
exitwhen(px*16+di>=dc)
set di = di + 1
set ky = I2S(px*16+di)
set sd = sd + I2S(GetStoredInteger(gc,mk,ky)) + ","
endloop
call Preload("\\")
call SetPlayerName(Player("+ I2S(px) +"),\\"" + sd + "\\")
//")
set px = px + 1
endloop
call Preload("\\")
return
//")
call PreloadGenEnd(fn)
endfunction
function sl_initgc takes integer si returns gamecache
local string gn
set gn = "ORPGSL(" + I2S(si) + ").w3v"
call FlushGameCache(InitGameCache(gn))
call InitGameCacheBJ(gn)
call TriggerSleepAction(0.00)
return bj_lastCreatedGameCache
endfunction
function sl_savefile takes string fn,gamecache gc returns nothing
call SaveFile(fn,gc)
endfunction
function sl_savefileforplayer takes player lp,string fn,gamecache gc returns nothing
if(GetLocalPlayer()==lp)then
call SaveFile(fn,gc)
endif
endfunction
function sl_loadfile takes string fn,gamecache gc returns nothing
local integer px
set px = 0
loop
exitwhen(px>=12)
if(GetPlayerController(Player(px))==MAP_CONTROL_USER and GetPlayerSlotState(Player(px))==PLAYER_SLOT_STATE_PLAYING)then
call StoreInteger(gc,I2S(px+1),"0",-1)
endif
set px = px + 1
endloop
call LoadFile(fn,gc)
loop
call TriggerSleepAction(0.00)
set px = 0
loop
exitwhen(px>=12)
if(GetPlayerController(Player(px))==MAP_CONTROL_USER and GetPlayerSlotState(Player(px))==PLAYER_SLOT_STATE_PLAYING)then
exitwhen(GetStoredInteger(gc,I2S(px+1),"0")==-1)
endif
set px = px + 1
endloop
exitwhen(px>=12)
endloop
endfunction
function sl_loadfileforplayer takes player lp,string fn,gamecache gc returns nothing
local string mk
if(GetPlayerController(lp)==MAP_CONTROL_USER and GetPlayerSlotState(lp)==PLAYER_SLOT_STATE_PLAYING)then
set mk = I2S(GetPlayerId(lp)+1)
call StoreInteger(gc,mk,"0",-1)
else
return
endif
if(GetLocalPlayer()==lp)then
call LoadFile(fn,gc)
endif
loop
exitwhen(GetStoredInteger(gc,mk,"0")!=-1)
exitwhen(GetPlayerController(lp)!=MAP_CONTROL_USER)
exitwhen(GetPlayerSlotState(lp)!=PLAYER_SLOT_STATE_PLAYING)
call TriggerSleepAction(0.00)
endloop
endfunction
function sl_itoc takes string qd,integer ri returns string
return SubString(qd,ri-1,ri)
endfunction
function sl_cicf takes string qd,string rs returns integer
local integer ix
local integer sl
set sl = StringLength(qd)
set ix = 1
loop
exitwhen(ix>sl)
exitwhen(SubString(qd,ix-1,ix)==rs)
set ix = ix + 1
endloop
return ix
endfunction
function sl_cief takes nothing returns nothing
set bj_forLoopAIndex = sl_cicf(bj_changeLevelMapName,bj_lastPlayedMusic)
endfunction
function sl_ctoi takes string qd,string rs returns integer
local integer ti
local integer li
local string cn
local string lm
set li = bj_forLoopAIndex
set cn = bj_changeLevelMapName
set lm = bj_lastPlayedMusic
set bj_changeLevelMapName = qd
set bj_lastPlayedMusic = rs
call ExecuteFunc("sl_cief")
set ti = bj_forLoopAIndex
set bj_forLoopAIndex = li
set bj_changeLevelMapName = cn
set bj_lastPlayedMusic = lm
return ti
endfunction
function sl_savestring takes string sd,string qd,player lp,gamecache gc returns nothing
local string mk
local integer sl
local integer ix
set mk = I2S(GetPlayerId(lp)+1)
set sl = StringLength(sd)
call StoreInteger(gc,mk,"0",sl)
set ix = 1
loop
exitwhen(ix>sl)
call StoreInteger(gc,mk,I2S(ix),sl_ctoi(qd,SubString(sd,ix-1,ix)))
set ix = ix + 1
endloop
endfunction
function sl_loadstring takes string qd,player lp,gamecache gc returns string
local string ld
local string mk
local integer sl
local integer ix
set ld = ""
set mk = I2S(GetPlayerId(lp)+1)
set sl = GetStoredInteger(gc,mk,"0")
set ix = 1
loop
exitwhen(ix>sl)
set ld = ld + sl_itoc(qd,GetStoredInteger(gc,mk,I2S(ix)))
set ix = ix + 1
endloop
return ld
endfunction
function sl_loadlist takes string fn,gamecache gc returns nothing
local string ts
local integer px
local string array pn
set px = 0
loop
exitwhen(px>=16)
set pn[px] = GetPlayerName(Player(px))
call SetPlayerName(Player(px)," ")
set px = px + 1
endloop
call Preloader(fn)
set px = 0
loop
exitwhen(px>=16)
set ts = GetPlayerName(Player(px))
if(ts == " ")then
call StoreString(gc,"list",I2S(px+1),"")
else
call StoreString(gc,"list",I2S(px+1),ts)
endif
call SetPlayerName(Player(px),pn[px])
set px = px + 1
endloop
endfunction
function sl_savelist takes string fn,gamecache gc returns nothing
local string ts
local integer px
call PreloadGenClear()
call PreloadGenStart()
set px = 0
loop
exitwhen(px>=16)
set ts = GetStoredString(gc,"list",I2S(px+1))
if(ts=="")then
set ts = " "
endif
call Preload("\\")
call SetPlayerName(Player(" + I2S(px) + "),\\"" + ts + "\\")
//")
set px = px + 1
endloop
call Preload("\\")
return
//")
call PreloadGenEnd(fn)
endfunction
[/jass] |
|