Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored September 18, 2012
12  src/order.cpp
@@ -1570,6 +1570,12 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder)
1570 1570
 		actionDroid(psDroid, DACTION_OBSERVE, psOrder->psObj);
1571 1571
 		break;
1572 1572
 	case DORDER_FIRESUPPORT:
  1573
+		if (psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER)
  1574
+		{
  1575
+			debug(LOG_ERROR, "Sorry, transports cannot be assigned to commanders.");
  1576
+			psDroid->order = DroidOrder(DORDER_NONE);
  1577
+			break;
  1578
+		}
1573 1579
 		if (psDroid->asWeaps[0].nStat == 0)
1574 1580
 		{
1575 1581
 			break;
@@ -1587,6 +1593,12 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder)
1587 1593
 		}
1588 1594
 		break;
1589 1595
 	case DORDER_COMMANDERSUPPORT:
  1596
+		if (psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER)
  1597
+		{
  1598
+			debug(LOG_ERROR, "Sorry, transports cannot be assigned to commanders.");
  1599
+			psDroid->order = DroidOrder(DORDER_NONE);
  1600
+			break;
  1601
+		}
1590 1602
 		cmdDroidAddDroid((DROID *)psOrder->psObj, psDroid);
1591 1603
 		break;
1592 1604
 	case DORDER_RETREAT:
30  src/structure.cpp
@@ -2109,7 +2109,8 @@ void assignFactoryCommandDroid(STRUCTURE *psStruct, DROID *psCommander)
2109 2109
 		}
2110 2110
 
2111 2111
 		psFact->psCommander = NULL;
2112  
-		syncDebug("Removed commander from factory %d", psStruct->id);
  2112
+		// TODO: Synchronise .psCommander.
  2113
+		//syncDebug("Removed commander from factory %d", psStruct->id);
2113 2114
 		if (!missionIsOffworld())
2114 2115
 		{
2115 2116
 			addFlagPosition(psFact->psAssemblyPoint);	// add the assembly point back into the list
@@ -2441,18 +2442,29 @@ static bool structPlaceDroid(STRUCTURE *psStructure, DROID_TEMPLATE *psTempl,
2441 2442
 			assignCommander = true;
2442 2443
 		}
2443 2444
 
2444  
-		if ( psFact->psCommander != NULL )
  2445
+		bool isTransporter = psNewDroid->droidType == DROID_TRANSPORTER || psNewDroid->droidType == DROID_SUPERTRANSPORTER;
  2446
+		if (isVtolDroid(psNewDroid) && !isTransporter)
2445 2447
 		{
2446  
-			syncDebug("Has commander.");
2447  
-			if (idfDroid(psNewDroid) ||
  2448
+			moveToRearm(psNewDroid);
  2449
+		}
  2450
+		if (psFact->psCommander != NULL && myResponsibility(psStructure->player))
  2451
+		{
  2452
+			// TODO: Should synchronise .psCommander in all cases.
  2453
+			//syncDebug("Has commander.");
  2454
+			if (isTransporter)
  2455
+			{
  2456
+				// 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.
  2457
+				orderDroidLoc(psNewDroid, DORDER_MOVE, psFact->psCommander->pos.x, psFact->psCommander->pos.y, ModeQueue);
  2458
+			}
  2459
+			else if (idfDroid(psNewDroid) ||
2448 2460
 				isVtolDroid(psNewDroid))
2449 2461
 			{
2450  
-				orderDroidObj(psNewDroid, DORDER_FIRESUPPORT, psFact->psCommander, ModeImmediate);
2451  
-				moveToRearm(psNewDroid);
  2462
+				orderDroidObj(psNewDroid, DORDER_FIRESUPPORT, psFact->psCommander, ModeQueue);
  2463
+				//moveToRearm(psNewDroid);
2452 2464
 			}
2453 2465
 			else
2454 2466
 			{
2455  
-				orderDroidObj(psNewDroid, DORDER_COMMANDERSUPPORT, psFact->psCommander, ModeImmediate);
  2467
+				orderDroidObj(psNewDroid, DORDER_COMMANDERSUPPORT, psFact->psCommander, ModeQueue);
2456 2468
 			}
2457 2469
 		}
2458 2470
 		else
@@ -2469,10 +2481,6 @@ static bool structPlaceDroid(STRUCTURE *psStructure, DROID_TEMPLATE *psTempl,
2469 2481
 			}
2470 2482
 			//if vtol droid - send it to ReArm Pad if one exists
2471 2483
 			placed = false;
2472  
-			if (isVtolDroid(psNewDroid) && (psNewDroid->droidType != DROID_TRANSPORTER && psNewDroid->droidType != DROID_SUPERTRANSPORTER))
2473  
-			{
2474  
-				moveToRearm(psNewDroid);
2475  
-			}
2476 2484
 			if (!placed)
2477 2485
 			{
2478 2486
 				//find flag in question.

0 notes on commit e1178b5

Please sign in to comment.
Something went wrong with that request. Please try again.