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)
master
Buginator 2010-09-17 02:49:20 +00:00 committed by buginator
parent 58c0ceec95
commit d6b47d1122
1 changed files with 13 additions and 0 deletions

View File

@ -4298,6 +4298,14 @@ DROID * giftSingleDroid(DROID *psD, UDWORD to)
if (droidRemove(psD, apsDroidLists)) // remove droid from one list 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)) if (!isHumanPlayer(psD->player))
{ {
droidSetName(psD, "Enemy Unit"); 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 // add back into cluster system
clustNewDroid(psD); clustNewDroid(psD);