From d6b47d1122f751dea01680d3598041e374a21590 Mon Sep 17 00:00:00 2001 From: Buginator Date: Fri, 17 Sep 2010 02:49:20 +0000 Subject: [PATCH] Don't allow a player to acquire more construction vehicles than the max amount allowed. Fixes ticket:2175 git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/branches/2.3@11674 4a71c877-e1ca-e34f-864e-861f7616d084 (cherry picked from commit e6cd09968b23f0d7941cc6f15569fbe8c8ef8457) --- src/droid.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/droid.c b/src/droid.c index 9f6efd320..eadec8dfa 100644 --- a/src/droid.c +++ b/src/droid.c @@ -4298,6 +4298,14 @@ DROID * giftSingleDroid(DROID *psD, UDWORD to) if (droidRemove(psD, apsDroidLists)) // remove droid from one list { + if (psD->droidType == DROID_CYBORG_CONSTRUCT || psD->droidType == DROID_CONSTRUCT) + { + if (getNumConstructorDroids(selectedPlayer) > MAX_CONSTRUCTOR_DROIDS) + { + CONPRINTF(ConsoleString, (ConsoleString, _("%s wanted to give you a %s but you have too many!"), getPlayerName(psD->player), psD->aName)); + return NULL; + } + } if (!isHumanPlayer(psD->player)) { droidSetName(psD, "Enemy Unit"); @@ -4332,6 +4340,11 @@ DROID * giftSingleDroid(DROID *psD, UDWORD to) } } } + else + { + // if we couldn't remove it, then get rid of it. + return NULL; + } // add back into cluster system clustNewDroid(psD);