Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix commander-related desynch and crash.

Would probably desynch on building anything in a factory assigned to a commander.

Would crash if assigning a VTOL factory to a commander, building a transport, and trying to unload the transport
(which would appear to contain everything assigned to said commander).

The .psCommander and .psAssemblyPoint should probably be syncronised at some point, but for now, are done like
this.

Fixes ticket:1924, ticket:3296 and ticket:3676.
  • Loading branch information...
commit e1178b57e9c53f031139f18d36d8158a27e64f39 1 parent c8b6ac5
@Cyp Cyp authored
Showing with 31 additions and 11 deletions.
  1. +12 −0 src/order.cpp
  2. +19 −11 src/structure.cpp
View
12 src/order.cpp
@@ -1570,6 +1570,12 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder)
actionDroid(psDroid, DACTION_OBSERVE, psOrder->psObj);
break;
case DORDER_FIRESUPPORT:
+ if (psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER)
+ {
+ debug(LOG_ERROR, "Sorry, transports cannot be assigned to commanders.");
+ psDroid->order = DroidOrder(DORDER_NONE);
+ break;
+ }
if (psDroid->asWeaps[0].nStat == 0)
{
break;
@@ -1587,6 +1593,12 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder)
}
break;
case DORDER_COMMANDERSUPPORT:
+ if (psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER)
+ {
+ debug(LOG_ERROR, "Sorry, transports cannot be assigned to commanders.");
+ psDroid->order = DroidOrder(DORDER_NONE);
+ break;
+ }
cmdDroidAddDroid((DROID *)psOrder->psObj, psDroid);
break;
case DORDER_RETREAT:
View
30 src/structure.cpp
@@ -2109,7 +2109,8 @@ void assignFactoryCommandDroid(STRUCTURE *psStruct, DROID *psCommander)
}
psFact->psCommander = NULL;
- syncDebug("Removed commander from factory %d", psStruct->id);
+ // TODO: Synchronise .psCommander.
+ //syncDebug("Removed commander from factory %d", psStruct->id);
if (!missionIsOffworld())
{
addFlagPosition(psFact->psAssemblyPoint); // add the assembly point back into the list
@@ -2441,18 +2442,29 @@ static bool structPlaceDroid(STRUCTURE *psStructure, DROID_TEMPLATE *psTempl,
assignCommander = true;
}
- if ( psFact->psCommander != NULL )
+ bool isTransporter = psNewDroid->droidType == DROID_TRANSPORTER || psNewDroid->droidType == DROID_SUPERTRANSPORTER;
+ if (isVtolDroid(psNewDroid) && !isTransporter)
{
- syncDebug("Has commander.");
- if (idfDroid(psNewDroid) ||
+ moveToRearm(psNewDroid);
+ }
+ if (psFact->psCommander != NULL && myResponsibility(psStructure->player))
+ {
+ // TODO: Should synchronise .psCommander in all cases.
+ //syncDebug("Has commander.");
+ if (isTransporter)
+ {
+ // Transporters can't be assigned to commanders, due to abuse of .psGroup. Try to land on the commander instead. Hopefully the transport is heavy enough to crush the commander.
+ orderDroidLoc(psNewDroid, DORDER_MOVE, psFact->psCommander->pos.x, psFact->psCommander->pos.y, ModeQueue);
+ }
+ else if (idfDroid(psNewDroid) ||
isVtolDroid(psNewDroid))
{
- orderDroidObj(psNewDroid, DORDER_FIRESUPPORT, psFact->psCommander, ModeImmediate);
- moveToRearm(psNewDroid);
+ orderDroidObj(psNewDroid, DORDER_FIRESUPPORT, psFact->psCommander, ModeQueue);
+ //moveToRearm(psNewDroid);
}
else
{
- orderDroidObj(psNewDroid, DORDER_COMMANDERSUPPORT, psFact->psCommander, ModeImmediate);
+ orderDroidObj(psNewDroid, DORDER_COMMANDERSUPPORT, psFact->psCommander, ModeQueue);
}
}
else
@@ -2469,10 +2481,6 @@ static bool structPlaceDroid(STRUCTURE *psStructure, DROID_TEMPLATE *psTempl,
}
//if vtol droid - send it to ReArm Pad if one exists
placed = false;
- if (isVtolDroid(psNewDroid) && (psNewDroid->droidType != DROID_TRANSPORTER && psNewDroid->droidType != DROID_SUPERTRANSPORTER))
- {
- moveToRearm(psNewDroid);
- }
if (!placed)
{
//find flag in question.
Please sign in to comment.
Something went wrong with that request. Please try again.