Fixed crash in AI controller again - third time or so (thanks to acme_pjz).

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7534 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2011-01-25 02:23:53 +00:00
parent e4b86ffc5d
commit 235fd83cdc

View File

@ -53,11 +53,9 @@ AIBaseController::AIBaseController(Kart *kart,
// race. Long term statistics might be gathered to determine the // race. Long term statistics might be gathered to determine the
// best way, potentially depending on race position etc. // best way, potentially depending on race position etc.
int r = rand(); int r = rand();
int indx = (int)( int indx = (int)( r / ((float)(RAND_MAX)+1.0f) * next.size() );
r / ((float)(RAND_MAX)+1.0f) * next.size() // In case of rounding errors0
); if(indx>=(int)next.size()) indx--;
// In case of rounding errors
if(indx>(int)next.size()) indx--;
m_successor_index.push_back(indx); m_successor_index.push_back(indx);
assert(indx <(int)next.size() && indx>=0); assert(indx <(int)next.size() && indx>=0);
m_next_node_index.push_back(next[indx]); m_next_node_index.push_back(next[indx]);