(svn r14038) -Fix [FS#2211] (r13731): company limit was not properly enforced for CMD_PLAYER_CTRL.
--- a/src/player_base.h Sun Aug 10 15:02:21 2008 +0000
+++ b/src/player_base.h Sun Aug 10 19:00:33 2008 +0000
@@ -24,7 +24,11 @@
Money company_value;
};
-DECLARE_OLD_POOL(Player, Player, 1, MAX_PLAYERS)
+/* The third parameter and the number after >> MUST be the same,
+ * otherwise more (or less) players will be allowed to be
+ * created than what MAX_PLAYER specifies!
+ */
+DECLARE_OLD_POOL(Player, Player, 1, MAX_PLAYERS >> 1)
struct Player : PoolItem<Player, PlayerByte, &_Player_pool> {
Player(uint16 name_1 = 0, bool is_ai = false);
--- a/src/players.cpp Sun Aug 10 15:02:21 2008 +0000
+++ b/src/players.cpp Sun Aug 10 19:00:33 2008 +0000
@@ -516,10 +516,10 @@
*/
Player *DoStartupNewPlayer(bool is_ai)
{
+ if (!Player::CanAllocateItem()) return NULL;
+
Player *p = new Player(STR_SV_UNNAMED, is_ai);
- if (p == NULL) return NULL;
-
memset(&_players_ai[p->index], 0, sizeof(PlayerAI));
memset(&_players_ainew[p->index], 0, sizeof(PlayerAiNew));