Properly fixed previous bugfix (RAND_MAX+1 will wrap around on e.g. linux).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7368 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
9dde70687f
commit
8769fc9492
@ -54,9 +54,10 @@ AIBaseController::AIBaseController(Kart *kart,
|
||||
// best way, potentially depending on race position etc.
|
||||
int r = rand();
|
||||
int indx = (int)(
|
||||
(r / (float)(RAND_MAX+1)) * next.size()
|
||||
(r / (float)(RAND_MAX)+1.0f) * next.size()
|
||||
);
|
||||
|
||||
// In case of rounding errors
|
||||
if(indx>(int)next.size()) indx--;
|
||||
m_successor_index.push_back(indx);
|
||||
m_next_node_index.push_back(next[indx]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user