Fix broken check for giving too many trucks to a player. Caused desynchs due to players not agreeing who owned what.

The check against selectedPlayer was incorrect, it caused clients with max trucks + 1 to not believe anyone could give trucks to anyone else.

Introduced in d6b47d1122.

Changelog: Really fix truck limit when giving trucks.
master
Cyp 2010-11-19 15:16:37 +01:00
parent a0ea827340
commit 3da5952483
1 changed files with 29 additions and 8 deletions

View File

@ -4306,20 +4306,41 @@ DROID * giftSingleDroid(DROID *psD, UDWORD to)
if (bMultiPlayer)
{
int i;
bool tooMany = false;
incNumDroids(to);
tooMany = tooMany || getNumDroids(to) > getMaxDroids(to);
if (psD->droidType == DROID_CYBORG_CONSTRUCT || psD->droidType == DROID_CONSTRUCT)
{
incNumConstructorDroids(to);
tooMany = tooMany || getNumConstructorDroids(to) > MAX_CONSTRUCTOR_DROIDS;
}
else if (psD->droidType == DROID_COMMAND)
{
incNumCommandDroids(to);
tooMany = tooMany || getNumCommandDroids(to) > MAX_COMMAND_DROIDS;
}
if (tooMany)
{
if (to == selectedPlayer)
{
CONPRINTF(ConsoleString, (ConsoleString, _("%s wanted to give you a %s but you have too many!"), getPlayerName(psD->player), psD->aName));
}
else if(psD->player == selectedPlayer)
{
CONPRINTF(ConsoleString, (ConsoleString, _("You wanted to give %s a %s but they have too many!"), getPlayerName(to), psD->aName));
}
return NULL;
}
// reset order
orderDroid(psD, DORDER_STOP, ModeQueue);
visRemoveVisibility((BASE_OBJECT *)psD);
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");