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 e6cd099.

Changelog: Really fix truck limit when giving trucks.
  • Loading branch information
Cyp committed Nov 19, 2010
1 parent 68670b2 commit 0a9b3b4
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions src/droid.c
Expand Up @@ -4621,19 +4621,41 @@ DROID * giftSingleDroid(DROID *psD, UDWORD to)

if (bMultiPlayer)
{
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);

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 0a9b3b4

Please sign in to comment.