Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Do not crash on pressing 'T' with a transporter selected.

Fixes ticket:3683.
  • Loading branch information...
commit f395be71850cf28f7ab03bf235ba221d8eaf6ca1 1 parent 0dde269
Cyp authored September 17, 2012
1  src/intorder.cpp
@@ -1000,6 +1000,7 @@ void intRunOrder(void)
1000 1000
 //
1001 1001
 static bool SetSecondaryState(SECONDARY_ORDER sec, unsigned State)
1002 1002
 {
  1003
+	// This code is similar to kfsf_SetSelectedDroidsState() in keybind.cpp. Unfortunately, it seems hard to un-duplicate the code.
1003 1004
 	for (unsigned i = 0; i < SelectedDroids.size(); ++i)
1004 1005
 	{
1005 1006
 		if (SelectedDroids[i])
4  src/keybind.cpp
@@ -2479,9 +2479,11 @@ static void kfsf_SetSelectedDroidsState( SECONDARY_ORDER sec, SECONDARY_STATE st
2479 2479
 	// This is a function to set unit orders via keyboard shortcuts. It should
2480 2480
 	// _not_ be disallowed in multiplayer games.
2481 2481
 
  2482
+	// This code is similar to SetSecondaryState() in intorder.cpp. Unfortunately, it seems hard to un-duplicate the code.
2482 2483
 	for(psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext)
2483 2484
 	{
2484  
-		if(psDroid->selected)
  2485
+		// Only set the state if it's not a transporter.
  2486
+		if (psDroid->selected && psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER)
2485 2487
 		{
2486 2488
 			secondarySetState(psDroid,sec,state);
2487 2489
 		}
10  src/order.cpp
@@ -1747,11 +1747,21 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder)
1747 1747
 		}
1748 1748
 		break;
1749 1749
 	case DORDER_EMBARK:
  1750
+	{
  1751
+		DROID *embarkee = castDroid(psOrder->psObj);
  1752
+		if (psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER  // Embarker must not be transporter.
  1753
+		    || embarkee == NULL || !(embarkee->droidType == DROID_TRANSPORTER || embarkee->droidType == DROID_SUPERTRANSPORTER))  // Embarkee must be a transporter.
  1754
+		{
  1755
+			debug(LOG_ERROR, "Sorry, can only load things that aren't transporters into things that are.");
  1756
+			psDroid->order = DroidOrder(DORDER_NONE);
  1757
+			break;
  1758
+		}
1750 1759
 		// move the droid to the transporter location
1751 1760
 		psDroid->order = *psOrder;
1752 1761
 		psDroid->order.pos = removeZ(psOrder->psObj->pos);
1753 1762
 		actionDroid(psDroid, DACTION_MOVE, psOrder->psObj->pos.x, psOrder->psObj->pos.y);
1754 1763
 		break;
  1764
+	}
1755 1765
 	case DORDER_DISEMBARK:
1756 1766
 		//only valid in multiPlayer mode
1757 1767
 		if (bMultiPlayer)

0 notes on commit f395be7

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