I actually wonder what RANDOM_LONG takes for args.
Is it:
RANDOM_LONG(from, TILL) or RANDOM_LONG(from, including)
meaning:
RANDOM_LONG(0,10) can return 0,1,2,3,4,5,6,7,8,9
or it can return: 0,1,2,3,4,5,6,7,8,9,10
i need to know this because my current function does not seem to return all goals i want, or... it could be i have been darn unfortunate:
Code:
// Find a goal, and return the node close to it
int cNodeMachine::node_goal(int iType)
{
if (iType == GOAL_NONE)
return -1;
int goals_list[MAX_GOALS];
for (int c=0; c < MAX_GOALS; c++)
goals_list[c] = -1;
int iId = 0;
for (int g=0; g< MAX_GOALS; g++)
if (Goals[g].iType == iType && Goals[g].iNode > -1)
{
goals_list[iId] = Goals[g].iNode;
iId++;
}
if (iId == 0)
return -1; // nothing found :(
iId--;
// we have an amount of goals (iId has them)
// TODO: Is it TILL iId? or INCLUDING? Assuming including now.
int the_goal = RANDOM_LONG(0, iId);
return goals_list[the_goal];
}