From a31285a651dc635a1f51661f5ddaa5a68a407e13 Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Sat, 14 Jul 2007 18:01:12 +0000 Subject: [PATCH] Fix lassat crash where its target would not be updated. Turn some asserts for AI building defense buildings in the wrong place into log messages. Fix those more properly later! git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2098 4a71c877-e1ca-e34f-864e-861f7616d084 --- src/structure.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/structure.c b/src/structure.c index 3746fe000..d5e088ede 100644 --- a/src/structure.c +++ b/src/structure.c @@ -1725,13 +1725,15 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U if(((x >> TILE_SHIFT) < TOO_NEAR_EDGE) || ((x >> TILE_SHIFT) > ( mapWidth - TOO_NEAR_EDGE))) { - ASSERT(!"attempting to build too closely to map-edge", "buildStructure: x coord (%u) too near edge (req. distance is %u)", x, TOO_NEAR_EDGE); + debug(LOG_ERROR, "buildStructure: attempting to build too closely to map-edge, " + "x coord (%u) too near edge (req. distance is %u)", x, TOO_NEAR_EDGE); return NULL; } if(((y >> TILE_SHIFT) < TOO_NEAR_EDGE) || ((y >> TILE_SHIFT) > ( mapHeight - TOO_NEAR_EDGE))) { - ASSERT(!"attempting to build too closely to map-edge", "buildStructure: y coord (%u) too near edge (req. distance is %u)", y, TOO_NEAR_EDGE); + debug(LOG_ERROR, "buildStructure: attempting to build too closely to map-edge, " + "y coord (%u) too near edge (req. distance is %u)", y, TOO_NEAR_EDGE); return NULL; } @@ -1812,13 +1814,15 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U } } // end of dodgy stuff - else + else if (TILE_HAS_STRUCTURE(psTile)) { - ASSERT(!(TILE_HAS_STRUCTURE(psTile)), + debug(LOG_ERROR, "buildStructure: building %s at (%d, %d) but found %s already at (%d, %d)", pStructureType->pName, mapX, mapY, getTileStructure(mapX + width, mapY + breadth)->pStructureType->pName, mapX + width, mapY + breadth); + free(psBuilding); + return NULL; } psTile->psObject = (BASE_OBJECT*)psBuilding; @@ -2975,21 +2979,11 @@ static void aiUpdateStructure(STRUCTURE *psStructure) CHECK_STRUCTURE(psStructure); - if (psStructure->numWeaps > 0) + for (i = 0; i < DROID_MAXWEAPS; i++) { - for (i = 0;i < psStructure->numWeaps;i++) + if (psStructure->psTarget[i] && psStructure->psTarget[i]->died) { - if (psStructure->psTarget[i] && psStructure->psTarget[i]->died) - { - setStructureTarget(psStructure, NULL, i); - } - } - } - else - { - if (psStructure->psTarget[0] && psStructure->psTarget[0]->died) - { - setStructureTarget(psStructure, NULL, 0); + setStructureTarget(psStructure, NULL, i); } }