Assume the following code. Testing shows that "Passed1" gets printed to screen while "Passed2" doesn't. It does not fail to find the needle and it properly returns the index that it found the delimiter at. Why does it seem to end at StringSub()?
void ChangeMap(string &in map)
{
string[] split = StringSplit(map, ":");
if (split.length() > 1)
{
AddDebugMessage(split[0], false);
AddDebugMessage(split[1], false);
// ChangeMap(split[0], split[1], "", "");
}
else AddDebugMessage("String array length less than 1", false);
}
void OnEnter()
{
AddTimer("creed_of_amnesia.map:StartMenu", 3, "ChangeMap");
}
int StringFindFirst(string &in heystack, string &in needle, int start)
{
if (StringContains(heystack, needle))
{
if (start < 0)
start = 0;
for (int i = start; i < heystack.length(); ++i)
{
if (StringSub(heystack, i, 1) == needle)
{
AddDebugMessage("Found needle: "+needle, false);
return i;
}
}
}
else AddDebugMessage("No needle in heystack", false);
AddDebugMessage("Couldn't find needle in heystack", false);
return -1;
}
string[] StringSplit(string &in str, string &in delimiter)
{
string[] ret;
int start = 0;
int i = StringFindFirst(str, delimiter, start);
string str_i = i;
str_i += " "+str.length();
AddDebugMessage(str_i, false);
while (i != -1)
{
if (str.length() < start
|| str.length() < i)
break;
AddDebugMessage("Passed1", false);
ret[ret.length()] = StringSub(str, start, i); // Seems to be haulting
AddDebugMessage("Passed2", false);
start = i+1;
i = StringFindFirst(str, delimiter, start);
}
return ret;
}
int StringToInt(string &in str)
{
if (str.length() > 0)
{
int i = 0;
string chk_str = i;
while (str != chk_str)
{
++i;
chk_str = i;
}
return i;
}
return 0;
}