5 changes: 2 additions & 3 deletions src/edit3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ void init3DBuilding(BASE_STATS *psStats,BUILDCALLBACK CallBack,void *UserData)

void kill3DBuilding ( void )
{
CancelDeliveryRepos();
//cancel the drag boxes
dragBox3D.status = DRAG_INACTIVE;
wallDrag.status = DRAG_INACTIVE;
Expand Down Expand Up @@ -267,7 +266,7 @@ bool found3DBuilding(UDWORD *x, UDWORD *y)
if (ctrlShiftDown())
{
quickQueueMode = true;
init3DBuilding(sBuildDetails.psStats, NULL, NULL);
init3DBuilding(sBuildDetails.psStats, sBuildDetails.CallBack, sBuildDetails.UserData);
}
else
{
Expand Down Expand Up @@ -304,7 +303,7 @@ bool found3DBuildLocTwo(UDWORD *px1, UDWORD *py1, UDWORD *px2, UDWORD *py2)
if (ctrlShiftDown())
{
quickQueueMode = true;
init3DBuilding(sBuildDetails.psStats, NULL, NULL);
init3DBuilding(sBuildDetails.psStats, sBuildDetails.CallBack, sBuildDetails.UserData);
}

return true;
Expand Down
27 changes: 18 additions & 9 deletions src/hci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ bool SecondaryWindowUp = false;

static UDWORD newMapWidth, newMapHeight;

static FLAG_POSITION debugMenuDroidDeliveryPoint;

#define RETXOFFSET (0)// Reticule button offset
#define RETYOFFSET (0)
#define NUMRETBUTS 7 // Number of reticule buttons.
Expand Down Expand Up @@ -822,7 +820,7 @@ static void intDoScreenRefresh(void)
if (psFlag != NULL)
{
// need to restart the delivery point position
StartDeliveryPosition(psFlag);
startDeliveryPosition(psFlag);
}

// make sure the commander order screen is in the right state
Expand Down Expand Up @@ -1355,12 +1353,17 @@ static void intProcessEditStats(UDWORD id)
if (psPositionStats->ref >= REF_TEMPLATE_START &&
psPositionStats->ref < REF_TEMPLATE_START + REF_RANGE)
{
FLAG_POSITION debugMenuDroidDeliveryPoint;
// Placing a droid from the debug menu, set up the flag. (This would probably be safe to do, even if we're placing something else.)
debugMenuDroidDeliveryPoint.factoryType = REPAIR_FLAG;
debugMenuDroidDeliveryPoint.factoryInc = 0;
deliveryPointToMove = &debugMenuDroidDeliveryPoint;
debugMenuDroidDeliveryPoint.player = selectedPlayer;
startDeliveryPosition(&debugMenuDroidDeliveryPoint);
}
else
{
intStartStructPosition(psPositionStats);
}
intStartStructPosition(psPositionStats);
editPosMode = IED_POS;
}
else if (id == IDSTAT_CLOSE)
Expand Down Expand Up @@ -1905,9 +1908,10 @@ INT_RETVAL intRunWidgets(void)
/* Directly positioning some type of object */
unsigned structX1 = INT32_MAX;
unsigned structY1 = INT32_MAX;
FLAG_POSITION flag;
structX2 = INT32_MAX - 1;
structY2 = INT32_MAX - 1;
if (found3DBuildLocTwo(&structX1, &structY1, &structX2, &structY2) || found3DBuilding(&structX1, &structY1))
if (sBuildDetails.psStats && (found3DBuilding(&structX1, &structY1) || found3DBuildLocTwo(&structX1, &structY1, &structX2, &structY2)))
{
if (structX2 == INT32_MAX - 1)
{
Expand All @@ -1923,6 +1927,12 @@ INT_RETVAL intRunWidgets(void)
std::swap(structY1, structY2);
}
}
else if (deliveryReposFinished(&flag))
{
structX2 = structX1 = map_coord(flag.coords.x);
structY2 = structY1 = map_coord(flag.coords.y);
}

for (unsigned j = structY1; j <= structY2; ++j)
for (unsigned i = structX1; i <= structX2; ++i)
{
Expand Down Expand Up @@ -2001,6 +2011,7 @@ INT_RETVAL intRunWidgets(void)
psDroid = buildDroid((DROID_TEMPLATE *)psPositionStats,
world_coord(structX) + TILE_UNITS / 2, world_coord(structY) + TILE_UNITS / 2,
selectedPlayer, false, NULL);
cancelDeliveryRepos();
if (psDroid)
{
addDroid(psDroid, apsDroidLists);
Expand Down Expand Up @@ -2751,7 +2762,7 @@ static void intProcessStats(UDWORD id)
psFlag = FindFactoryDelivery(psStruct);
if (psFlag)
{
StartDeliveryPosition(psFlag);
startDeliveryPosition(psFlag);
}
}
}
Expand Down Expand Up @@ -2897,8 +2908,6 @@ void intCommanderSelected(DROID *psDroid)
widgHide(psWScreen, IDOBJ_FORM);
}

extern void FinishStructurePosition(UDWORD xPos,UDWORD yPos,void *UserData);

/* Start looking for a structure location */
static void intStartStructPosition(BASE_STATS *psStats)
{
Expand Down
1 change: 0 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,6 @@ bool stageThreeInitialise(void)
// Re-inititialise some static variables.

driveInitVars(false);
displayInitVars();
resizeRadar();

setAllPauseStates(false);
Expand Down
1 change: 1 addition & 0 deletions src/loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ static GAMECODE renderLoop()

//handles callbacks for positioning of DP's
process3DBuilding();
processDeliveryRepos();

//ajl. get the incoming netgame messages and process them.
// FIXME Previous comment is deprecated. multiPlayerLoop does some other weird stuff, but not that anymore.
Expand Down
3 changes: 2 additions & 1 deletion src/scriptfuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5640,7 +5640,8 @@ bool scrGetGameStatus(void)

break;
case STATUS_DeliveryReposInProgress:
if (DeliveryReposValid()==true) bResult=true;
if (deliveryReposValid())
bResult=true;
break;

default:
Expand Down
30 changes: 2 additions & 28 deletions src/structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4621,13 +4621,9 @@ bool removeStruct(STRUCTURE *psDel, bool bDestroy)
if (psDel->player == selectedPlayer)
{
//if currently trying to place a DP
if (tryingToGetLocation())
if (psFactory->psAssemblyPoint && psFactory->psAssemblyPoint->selected)
{
//need to check if this factory's DP is trying to be re-positioned
if (psAssemblyPoint == sBuildDetails.UserData)
{
kill3DBuilding();
}
cancelDeliveryRepos();
}
}
}
Expand Down Expand Up @@ -5055,28 +5051,6 @@ void setFlagPositionInc(FUNCTIONALITY* pFunctionality, UDWORD player, UBYTE fact
ASSERT( false, "Can't set flag!");
}


/* called from order.c.. delivery/assembly point handler*/
/*now called from display.c */
void processDeliveryPoint(UDWORD player, UDWORD x, UDWORD y)
{
FLAG_POSITION *psCurrFlag;//,*psFlag;//,*psNewFlag

for (psCurrFlag = apsFlagPosLists[player]; psCurrFlag; psCurrFlag = psCurrFlag->psNext)
{
// must be selected and have a valid pos.
if (psCurrFlag->selected)
{
setAssemblyPoint(psCurrFlag, x, y, player, true);

//deselect once moved
psCurrFlag->selected = false;
return; //will want to break if more than one can be selected?
}
}
}


/*called when a structure has been built - checks through the list of callbacks
for the scripts*/
void structureCompletedCallback(STRUCTURE_STATS *psStructType)
Expand Down
3 changes: 0 additions & 3 deletions src/structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ extern bool checkStructureStatus( STRUCTURE_STATS *psStats, UDWORD player, UDWOR
extern void setAssemblyPoint(FLAG_POSITION *psAssemblyPoint, UDWORD x, UDWORD y,
UDWORD player, bool bCheck);

/* consider delivery points when selected by player*/
extern void processDeliveryPoint(UDWORD player, UDWORD x, UDWORD y);

/*called when a structure has been built - checks through the list of callbacks
for the scripts*/
extern void structureCompletedCallback(STRUCTURE_STATS *psStructType);
Expand Down