Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

Fixes ticket:3683.
  • Loading branch information...
commit f395be71850cf28f7ab03bf235ba221d8eaf6ca1 1 parent 0dde269
@Cyp Cyp authored
Showing with 14 additions and 1 deletion.
  1. +1 −0  src/intorder.cpp
  2. +3 −1 src/keybind.cpp
  3. +10 −0 src/order.cpp
View
1  src/intorder.cpp
@@ -1000,6 +1000,7 @@ void intRunOrder(void)
//
static bool SetSecondaryState(SECONDARY_ORDER sec, unsigned State)
{
+ // This code is similar to kfsf_SetSelectedDroidsState() in keybind.cpp. Unfortunately, it seems hard to un-duplicate the code.
for (unsigned i = 0; i < SelectedDroids.size(); ++i)
{
if (SelectedDroids[i])
View
4 src/keybind.cpp
@@ -2479,9 +2479,11 @@ static void kfsf_SetSelectedDroidsState( SECONDARY_ORDER sec, SECONDARY_STATE st
// This is a function to set unit orders via keyboard shortcuts. It should
// _not_ be disallowed in multiplayer games.
+ // This code is similar to SetSecondaryState() in intorder.cpp. Unfortunately, it seems hard to un-duplicate the code.
for(psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext)
{
- if(psDroid->selected)
+ // Only set the state if it's not a transporter.
+ if (psDroid->selected && psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER)
{
secondarySetState(psDroid,sec,state);
}
View
10 src/order.cpp
@@ -1747,11 +1747,21 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder)
}
break;
case DORDER_EMBARK:
+ {
+ DROID *embarkee = castDroid(psOrder->psObj);
+ if (psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER // Embarker must not be transporter.
+ || embarkee == NULL || !(embarkee->droidType == DROID_TRANSPORTER || embarkee->droidType == DROID_SUPERTRANSPORTER)) // Embarkee must be a transporter.
+ {
+ debug(LOG_ERROR, "Sorry, can only load things that aren't transporters into things that are.");
+ psDroid->order = DroidOrder(DORDER_NONE);
+ break;
+ }
// move the droid to the transporter location
psDroid->order = *psOrder;
psDroid->order.pos = removeZ(psOrder->psObj->pos);
actionDroid(psDroid, DACTION_MOVE, psOrder->psObj->pos.x, psOrder->psObj->pos.y);
break;
+ }
case DORDER_DISEMBARK:
//only valid in multiPlayer mode
if (bMultiPlayer)
Please sign in to comment.
Something went wrong with that request. Please try again.