Skip to content

Commit 0a9b3b4

Browse files
committed
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 e6cd099. Changelog: Really fix truck limit when giving trucks.
1 parent 68670b2 commit 0a9b3b4

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

src/droid.c

+30-8
Original file line numberDiff line numberDiff line change
@@ -4621,19 +4621,41 @@ DROID * giftSingleDroid(DROID *psD, UDWORD to)
46214621

46224622
if (bMultiPlayer)
46234623
{
4624+
bool tooMany = false;
4625+
4626+
incNumDroids(to);
4627+
tooMany = tooMany || getNumDroids(to) > getMaxDroids(to);
4628+
if (psD->droidType == DROID_CYBORG_CONSTRUCT || psD->droidType == DROID_CONSTRUCT)
4629+
{
4630+
incNumConstructorDroids(to);
4631+
tooMany = tooMany || getNumConstructorDroids(to) > MAX_CONSTRUCTOR_DROIDS;
4632+
}
4633+
else if (psD->droidType == DROID_COMMAND)
4634+
{
4635+
incNumCommandDroids(to);
4636+
tooMany = tooMany || getNumCommandDroids(to) > MAX_COMMAND_DROIDS;
4637+
}
4638+
4639+
if (tooMany)
4640+
{
4641+
if (to == selectedPlayer)
4642+
{
4643+
CONPRINTF(ConsoleString, (ConsoleString, _("%s wanted to give you a %s but you have too many!"), getPlayerName(psD->player), psD->aName));
4644+
}
4645+
else if(psD->player == selectedPlayer)
4646+
{
4647+
CONPRINTF(ConsoleString, (ConsoleString, _("You wanted to give %s a %s but they have too many!"), getPlayerName(to), psD->aName));
4648+
}
4649+
return NULL;
4650+
}
4651+
46244652
// reset order
46254653
orderDroid(psD, DORDER_STOP);
46264654

4655+
visRemoveVisibility((BASE_OBJECT *)psD);
4656+
46274657
if (droidRemove(psD, apsDroidLists)) // remove droid from one list
46284658
{
4629-
if (psD->droidType == DROID_CYBORG_CONSTRUCT || psD->droidType == DROID_CONSTRUCT)
4630-
{
4631-
if (getNumConstructorDroids(selectedPlayer) > MAX_CONSTRUCTOR_DROIDS)
4632-
{
4633-
CONPRINTF(ConsoleString, (ConsoleString, _("%s wanted to give you a %s but you have too many!"), getPlayerName(psD->player), psD->aName));
4634-
return NULL;
4635-
}
4636-
}
46374659
if (!isHumanPlayer(psD->player))
46384660
{
46394661
droidSetName(psD, "Enemy Unit");

0 commit comments

Comments
 (0)