diff --git a/src/droid.c b/src/droid.c index deb18b593..0af6ac898 100644 --- a/src/droid.c +++ b/src/droid.c @@ -119,6 +119,7 @@ void droidUpdateRecoil( DROID *psDroid ); static void cancelBuild(DROID *psDroid) { + objTrace(psDroid->id, "Droid build order cancelled"); psDroid->action = DACTION_NONE; psDroid->order = DORDER_NONE; setDroidTarget(psDroid, NULL); @@ -1089,8 +1090,17 @@ BOOL droidUpdateBuild(DROID *psDroid) { // Update the interface intBuildFinished(psDroid); - - cancelBuild(psDroid); + if ((map_coord(psDroid->orderX) == map_coord(psDroid->orderX2) && map_coord(psDroid->orderY) == map_coord(psDroid->orderY2)) + || psDroid->order != DORDER_LINEBUILD) + { + cancelBuild(psDroid); + } + else + { + psDroid->action = DACTION_NONE; // make us continue line build + setDroidTarget(psDroid, NULL); + setDroidActionTarget(psDroid, NULL, 0); + } return false; } diff --git a/src/order.c b/src/order.c index 09d9837c8..fe339cf16 100644 --- a/src/order.c +++ b/src/order.c @@ -1709,6 +1709,7 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder) psDroid->psTarStats = psOrder->psStats; ASSERT((!psDroid->psTarStats || ((STRUCTURE_STATS *)psDroid->psTarStats)->type != REF_DEMOLISH), "Cannot build demolition"); actionDroidLoc(psDroid, DACTION_BUILD, psOrder->x,psOrder->y); + objTrace(psDroid->id, "Starting new construction effort of %s", psOrder->psStats->pName); break; case DORDER_BUILDMODULE: //build a module onto the structure @@ -1724,6 +1725,7 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder) ASSERT(psDroid->psTarStats != NULL, "orderUnitBase: should have found a module stats"); ASSERT((!psDroid->psTarStats || ((STRUCTURE_STATS *)psDroid->psTarStats)->type != REF_DEMOLISH), "Cannot build demolition"); actionDroidLoc(psDroid, DACTION_BUILD, psOrder->psObj->pos.x,psOrder->psObj->pos.y); + objTrace(psDroid->id, "Starting new upgrade of %s", psOrder->psStats->pName); break; case DORDER_LINEBUILD: // build a line of structures @@ -1742,6 +1744,7 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder) psDroid->psTarStats = psOrder->psStats; ASSERT((!psDroid->psTarStats || ((STRUCTURE_STATS *)psDroid->psTarStats)->type != REF_DEMOLISH), "Cannot build demolition"); actionDroidLoc(psDroid, DACTION_BUILD, psOrder->x,psOrder->y); + objTrace(psDroid->id, "Starting new line construction of %s", psOrder->psStats->pName); break; case DORDER_HELPBUILD: // help to build a structure that is starting to be built @@ -1756,6 +1759,7 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder) psDroid->psTarStats = (BASE_STATS *)((STRUCTURE *)psOrder->psObj)->pStructureType; ASSERT((!psDroid->psTarStats || ((STRUCTURE_STATS *)psDroid->psTarStats)->type != REF_DEMOLISH), "Cannot build demolition"); actionDroidLoc(psDroid, DACTION_BUILD, psDroid->orderX, psDroid->orderY); + objTrace(psDroid->id, "Helping construction of %s", psOrder->psStats->pName); break; case DORDER_DEMOLISH: if (!(psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT)) diff --git a/src/scriptai.c b/src/scriptai.c index 270ab1e1e..596670e7f 100644 --- a/src/scriptai.c +++ b/src/scriptai.c @@ -240,14 +240,11 @@ BOOL scrIdleGroup(void) { return false; } - - ASSERT( psGroup != NULL, - "scrIdleGroup: invalid group pointer" ); + ASSERT_OR_RETURN(false, psGroup, "Invalid group pointer"); for(psDroid = psGroup->psList;psDroid; psDroid = psDroid->psGrpNext) { - if( psDroid->order == DORDER_NONE - || (psDroid->order == DORDER_GUARD && psDroid->psTarget == NULL)) + if (psDroid->order == DORDER_NONE || (psDroid->order == DORDER_GUARD && psDroid->psTarget == NULL)) { count++; } diff --git a/src/structure.c b/src/structure.c index e661e83e4..38b453718 100644 --- a/src/structure.c +++ b/src/structure.c @@ -1206,9 +1206,12 @@ void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints) for (psIter = apsDroidLists[psDroid->player]; psIter; psIter = psIter->psNext) { if ((psIter->order == DORDER_BUILD || psIter->order == DORDER_HELPBUILD || psIter->order == DORDER_LINEBUILD) - && psIter->psTarget == (BASE_OBJECT *)psStruct) + && psIter->psTarget == (BASE_OBJECT *)psStruct + && (psIter->order != DORDER_LINEBUILD || (map_coord(psIter->orderX) == map_coord(psIter->orderX2) + && map_coord(psIter->orderY) == map_coord(psIter->orderY2)))) { - objTrace(psIter->id, "Construction complete"); + objTrace(psIter->id, "Construction order %s complete (%d, %d -> %d, %d)", getDroidOrderName(psDroid->order), + (int)psIter->orderX, (int)psIter->orderY, (int)psIter->orderX2, (int)psIter->orderY2); psIter->action = DACTION_NONE; psIter->order = DORDER_NONE; setDroidTarget(psIter, NULL);