Fix off-by-one memory error

(cherry picked from commit 1e6e097e7ab5112b4e603c2996ced41dccf77df9)
Fix AI picking to show at most 8 AIs, because of the limitations of the GUI. closes ticket:3147

(cherry picked from commit 20c7024a9bfff73ce3a9338a17381cfb110a1d40)
Fix a off by one error for AI count.
Merge branch 'bugfixes' into 3.1