Skip to content

Commit

Permalink
Fix broken check for giving too many trucks to a player. Caused desyn…
Browse files Browse the repository at this point in the history
…chs 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 d6b47d1.

Changelog: Really fix truck limit when giving trucks.
  • Loading branch information
Cyp committed Nov 19, 2010
1 parent a0ea827 commit 3da5952
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions src/droid.c
Expand Up @@ -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");
Expand Down

0 comments on commit 3da5952

Please sign in to comment.