Close bug #6897 reported by Dennis. Fix two asserts with edit window's

demolish command, and also add the feature of allowing this demolish 
command remove map features such as oil resources.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1784 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2007-05-31 18:19:54 +00:00
parent 10cfe3c065
commit b532b1cc60
2 changed files with 27 additions and 25 deletions

View File

@ -2109,25 +2109,32 @@ INT_RETVAL intRunWidgets(void)
if (psPositionStats->ref >= REF_STRUCTURE_START &&
psPositionStats->ref < REF_STRUCTURE_START + REF_RANGE)
{
intCalcStructCenter((STRUCTURE_STATS *)psPositionStats, structX,structY,
&structX,&structY);
psStructure = buildStructure((STRUCTURE_STATS *)psPositionStats,
structX, structY, selectedPlayer,FALSE);
STRUCTURE_STATS *psBuilding = (STRUCTURE_STATS *)psPositionStats;
intCalcStructCenter(psBuilding, structX, structY, &structX, &structY);
if (psBuilding->type == REF_DEMOLISH)
{
MAPTILE *psTile = mapTile(map_coord(structX), map_coord(structY));
FEATURE *psFeature = (FEATURE *)psTile->psObject;
psStructure = (STRUCTURE *)psTile->psObject; /* reuse var */
if (psStructure && psTile->psObject->type == OBJ_STRUCTURE)
{
removeStruct(psStructure, TRUE);
}
else if (psFeature && psTile->psObject->type == OBJ_FEATURE)
{
removeFeature(psFeature);
}
psStructure = NULL;
} else {
psStructure = buildStructure(psBuilding, structX, structY,
selectedPlayer, FALSE);
}
if (psStructure)
{
psStructure->status = SS_BUILT;
buildingComplete(psStructure);
/*if (psStructure->pStructureType->type == REF_POWER_GEN)
{
//initPlayerPower();
capacityUpdate(psStructure);
}
else if (psStructure->pStructureType->type == REF_RESOURCE_EXTRACTOR ||
psStructure->pStructureType->type == REF_HQ)
{
//initPlayerPower();
extractedPowerUpdate(psStructure);
}*/
}
}
else if (psPositionStats->ref >= REF_FEATURE_START &&
@ -6176,15 +6183,6 @@ static BOOL setConstructionStats(BASE_OBJECT *psObj, BASE_STATS *psStats)
if(driveModeActive()) {
driveSelectionChanged();
}
/* Re-written to allow demolish order to be added to the queuing system
//make sure its not on the way to build something
orderDroid(psDroid,DORDER_STOP);
//clear out target (but not if queuing)
psDroid->psTarget = NULL;
psDroid->psTarStats = (BASE_STATS *) structGetDemolishStat();
*/
return TRUE;
}

View File

@ -1701,6 +1701,9 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
int i;
STRUCTURE *psBuilding = NULL;
assert(pStructureType);
ASSERT(pStructureType->type != REF_DEMOLISH, "You cannot build demolition!");
if (IsStatExpansionModule(pStructureType)==FALSE)
{
//some prelim tests...
@ -4461,8 +4464,9 @@ BOOL validLocation(BASE_STATS *psStats, UDWORD x, UDWORD y, UDWORD player,
switch(psBuilding->type)
{
case NUM_DIFF_BUILDINGS:
case REF_DEMOLISH:
break;
case NUM_DIFF_BUILDINGS:
case REF_BRIDGE:
ASSERT(FALSE, "validLocation: Bad structure type %u", psBuilding->type);
break;