#define DEBUG
world/fps = 100
proc/let( t, pos )
return ascii2text( text2ascii(t,pos) )
#define TEXT 1
#define INTEGER 2
#define SYMBOL 4
proc/randString( length = 5 , flags = TEXT|INTEGER )
var/static/l[] = list(65,90,97,122,48,57,33,47,162,254)
var/g[0]
if(flags & TEXT) g.Add(1,3)
if(flags & INTEGER) g.Add(5)
if(flags & SYMBOL) g.Add(7,9)
for(var/i=1 to length)
var/x = pick(g)
. += ascii2text(rand(l[x],l[x+1]))
string
var
value
length
proc
set_value(v)
value = v
length = length(v)
compare(string/s)
for(var/n=1 to s.length)
.+=let(s.value,n)==let(value,n)
./=s.length
generate(length,flags=1)
set_value(randString(length,flags))
breed(string/s)
for(var/n=1 to length)
var/g = s.value
if(prob(50))
g = value
.+=let(g,n)
var/string/r = new
r.set_value(.)
return r
client/verb/test(t as text)
var
string
s = new
s2 = new
cs
s.set_value(ckey(t))
s2.generate(s.length)
do
var/string/s3 = new
s3.generate(s.length)
s3 = s3.breed(s2)
var/c = s.compare(s3)
if(c>cs)
cs = c
s2=s3
src << output(null,"output1")
src << "([cs]) [s2.value]"
sleep(0)
while(cs<1)
world << "done"
Problem description:
At random iterations in the loop during test(), I'm getting an index out of bound runtime pointing to the line 'var/x = pick(g)' in randString. I have no clue what's causing this error. Any ideas?
Was there a particular string you entered that caused this error to appear?
I recommend logging each critical step and go through it when you encounter the error:
If the error occurs, the file should remain and you can look at the last entry. Obviously you do not need to define #ifdef DEBUG if you do not want to.