- Joined
- Apr 24, 2012
- Messages
- 5,113
So I was coding a Simple Scrambler :
But it seems that Warcraft 3 can't load the map fully when tried to test or play the game. Anyone can solve this?
JASS:
function Scramble takes string s returns string
local string ts
local string s2 = ""
local string s3 = ""
local integer i = 0
local integer sl= StringLength(s)
local integer i2 = 0
local boolean flag = true
loop
exitwhen i == 4
loop
exitwhen i2 == sl
set ts = SubString(s, i2, i2 + 1)
if flag then
set s2 = s2 + ts
else
set s3 = s3 + ts
endif
set flag = not flag
set i2 = i2 + 1
endloop
set s = s2 + s3
set s2 = ""
set s3 = ""
set i2 = 0
set i = i + 1
endloop
return s
endfunction
function Descramble takes string s returns string
local string ts
local string s2
local string s3
local integer sl = StringLength(s)
local integer i = 0
local integer i2 = 0
local boolean flag = true
local boolean isOdd = ModuloInteger(sl, 2) == 1
local string final = s
loop
exitwhen i == 4
if isOdd then
set s2 = SubString(final, 0, sl - 1 / 2 + 1)
set s3 = SubString(final, sl - 1 / 2 + 1, sl)
else
set s2 = SubString(final, 0, sl / 2)
set s3 = SubString(final, sl / 2, sl)
endif
loop
exitwhen i2 == sl
if flag then
set ts = SubString(s2, i2, i2 + 1)
else
set ts = SubString(s3, i2, i2 + 1)
endif
set s = s + ts
set flag = not flag
endloop
set final = s
set s = ""
set i = i + 1
endloop
return final
endfunction
But it seems that Warcraft 3 can't load the map fully when tried to test or play the game. Anyone can solve this?