Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix assert failure and wrong action type selected when VTOLs finished

attacking something and are sent back to rearm, and there are no
rearm structures in existence.
  • Loading branch information...
commit 9549a685ed16eb33bc18ac9e908fc9dd99de5957 1 parent 997d25b
@perim perim authored
Showing with 5 additions and 14 deletions.
  1. +3 −3 src/droid.cpp
  2. +2 −11 src/structure.cpp
View
6 src/droid.cpp
@@ -3105,9 +3105,9 @@ void updateVtolAttackRun(DROID *psDroid , int weapon_slot)
//assign rearmPad to the VTOL
void assignVTOLPad(DROID *psNewDroid, STRUCTURE *psReArmPad)
{
- ASSERT_OR_RETURN( , isVtolDroid(psNewDroid), "not a vtol droid");
- ASSERT_OR_RETURN( , psReArmPad->type == OBJ_STRUCTURE
- && psReArmPad->pStructureType->type == REF_REARM_PAD, "not a ReArm Pad" );
+ ASSERT_OR_RETURN( , isVtolDroid(psNewDroid), "%s is not a VTOL droid", objInfo(psNewDroid));
+ ASSERT_OR_RETURN( , psReArmPad->type == OBJ_STRUCTURE && psReArmPad->pStructureType->type == REF_REARM_PAD,
+ "%s cannot rearm", objInfo(psReArmPad));
setDroidBase(psNewDroid, psReArmPad);
}
View
13 src/structure.cpp
@@ -6740,13 +6740,13 @@ bool clearRearmPad(STRUCTURE *psStruct)
// if bClear is true it tries to find the nearest clear rearm pad in
// the same cluster as psTarget
// psTarget can be NULL
-STRUCTURE * findNearestReArmPad(DROID *psDroid, STRUCTURE *psTarget, bool bClear)
+STRUCTURE *findNearestReArmPad(DROID *psDroid, STRUCTURE *psTarget, bool bClear)
{
STRUCTURE *psStruct, *psNearest, *psTotallyClear;
SDWORD xdiff,ydiff, mindist, currdist, totallyDist;
SDWORD cx,cy;
- ASSERT_OR_RETURN(NULL, psDroid != NULL, "findNearestReArmPad: No droid was passed.");
+ ASSERT_OR_RETURN(NULL, psDroid != NULL, "No droid was passed.");
if (psTarget != NULL)
{
@@ -6762,18 +6762,12 @@ STRUCTURE * findNearestReArmPad(DROID *psDroid, STRUCTURE *psTarget, bool bClear
cx = (SDWORD)psDroid->pos.x;
cy = (SDWORD)psDroid->pos.y;
}
-
mindist = SDWORD_MAX;
totallyDist = SDWORD_MAX;
psNearest = NULL;
psTotallyClear = NULL;
- STRUCTURE *hq = nullptr;
for(psStruct = apsStructLists[psDroid->player]; psStruct; psStruct=psStruct->psNext)
{
- if (psStruct->pStructureType->type == REF_HQ)
- {
- hq = psStruct;
- }
if ((psStruct->pStructureType->type == REF_REARM_PAD) &&
(psTarget == NULL || psTarget->cluster == psStruct->cluster) &&
(!bClear || clearRearmPad(psStruct)))
@@ -6799,13 +6793,10 @@ STRUCTURE * findNearestReArmPad(DROID *psDroid, STRUCTURE *psTarget, bool bClear
}
}
}
-
if (bClear && (psTotallyClear != NULL))
{
psNearest = psTotallyClear;
}
- psNearest = psNearest != nullptr? psNearest : hq;
-
return psNearest;
}
Please sign in to comment.
Something went wrong with that request. Please try again.