Skip to content

Commit a6b3f0b

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 5098b36 commit a6b3f0b

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

src/droid.c

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4900,19 +4900,41 @@ DROID * giftSingleDroid(DROID *psD, UDWORD to)
49004900

49014901
if (bMultiPlayer)
49024902
{
4903+
bool tooMany = false;
4904+
4905+
incNumDroids(to);
4906+
tooMany = tooMany || getNumDroids(to) > getMaxDroids(to);
4907+
if (psD->droidType == DROID_CYBORG_CONSTRUCT || psD->droidType == DROID_CONSTRUCT)
4908+
{
4909+
incNumConstructorDroids(to);
4910+
tooMany = tooMany || getNumConstructorDroids(to) > MAX_CONSTRUCTOR_DROIDS;
4911+
}
4912+
else if (psD->droidType == DROID_COMMAND)
4913+
{
4914+
incNumCommandDroids(to);
4915+
tooMany = tooMany || getNumCommandDroids(to) > MAX_COMMAND_DROIDS;
4916+
}
4917+
4918+
if (tooMany)
4919+
{
4920+
if (to == selectedPlayer)
4921+
{
4922+
CONPRINTF(ConsoleString, (ConsoleString, _("%s wanted to give you a %s but you have too many!"), getPlayerName(psD->player), psD->aName));
4923+
}
4924+
else if(psD->player == selectedPlayer)
4925+
{
4926+
CONPRINTF(ConsoleString, (ConsoleString, _("You wanted to give %s a %s but they have too many!"), getPlayerName(to), psD->aName));
4927+
}
4928+
return NULL;
4929+
}
4930+
49034931
// reset order
49044932
orderDroid(psD, DORDER_STOP);
49054933

4934+
visRemoveVisibility((BASE_OBJECT *)psD);
4935+
49064936
if (droidRemove(psD, apsDroidLists)) // remove droid from one list
49074937
{
4908-
if (psD->droidType == DROID_CYBORG_CONSTRUCT || psD->droidType == DROID_CONSTRUCT)
4909-
{
4910-
if (getNumConstructorDroids(selectedPlayer) > MAX_CONSTRUCTOR_DROIDS)
4911-
{
4912-
CONPRINTF(ConsoleString, (ConsoleString, _("%s wanted to give you a %s but you have too many!"), getPlayerName(psD->player), psD->aName));
4913-
return NULL;
4914-
}
4915-
}
49164938
if (!isHumanPlayer(psD->player))
49174939
{
49184940
droidSetName(psD, "Enemy Unit");

0 commit comments

Comments
 (0)