patch #1096: Improve speed of fireOnLocation, and use it to fix AI bug
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5883 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
99605c5982
commit
ceb4e23eda
|
@ -261,6 +261,18 @@ static void positionEffect(EFFECT *psEffect)
|
|||
|
||||
static void killEffect(EFFECT *e)
|
||||
{
|
||||
if (e->group == EFFECT_FIRE)
|
||||
{
|
||||
const int posX = map_coord(e->position.x);
|
||||
const int posY = map_coord(e->position.z);
|
||||
MAPTILE *psTile = mapTile(posX, posY);
|
||||
|
||||
ASSERT(psTile, "Fire effect on non-existing tile (%d, %d)", posX, posY);
|
||||
if (psTile)
|
||||
{
|
||||
psTile->tileInfoBits &= ~BITS_ON_FIRE; // clear fire bit
|
||||
}
|
||||
}
|
||||
effectStatus[e-asEffectsList] = ES_INACTIVE;
|
||||
e->control = (UBYTE) 0;
|
||||
}
|
||||
|
@ -2326,6 +2338,15 @@ void effectSetupConstruction(EFFECT *psEffect)
|
|||
// ----------------------------------------------------------------------------------------
|
||||
void effectSetupFire(EFFECT *psEffect)
|
||||
{
|
||||
const int posX = map_coord(psEffect->position.x);
|
||||
const int posY = map_coord(psEffect->position.z);
|
||||
MAPTILE *psTile = mapTile(posX, posY);
|
||||
|
||||
ASSERT(psTile, "Cannot place a fire effect %d, %d - outside map!", posX, posY);
|
||||
if (psTile)
|
||||
{
|
||||
psTile->tileInfoBits |= BITS_ON_FIRE;
|
||||
}
|
||||
psEffect->frameDelay = 300; // needs to be investigated...
|
||||
psEffect->radius = auxVar; // needs to be investigated
|
||||
psEffect->lifeSpan = (UWORD)auxVarSec;
|
||||
|
@ -2709,26 +2730,18 @@ UDWORD i;
|
|||
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
/// Check if tile contained within the given world coordinates is burning.
|
||||
bool fireOnLocation(unsigned int x, unsigned int y)
|
||||
{
|
||||
unsigned int i;
|
||||
const int posX = map_coord(x);
|
||||
const int posY = map_coord(y);
|
||||
MAPTILE *psTile = mapTile(posX, posY);
|
||||
|
||||
for(i = 0; i < MAX_EFFECTS; ++i)
|
||||
ASSERT(psTile, "Checking fire on tile outside the map (%d, %d)", posX, posY);
|
||||
if (psTile)
|
||||
{
|
||||
if (effectStatus[i] == ES_ACTIVE
|
||||
&& asEffectsList[i].group == EFFECT_FIRE)
|
||||
{
|
||||
const unsigned int posX = asEffectsList[i].position.x;
|
||||
const unsigned int posY = asEffectsList[i].position.z;
|
||||
|
||||
if (posX == x
|
||||
&& posY == y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return (psTile->tileInfoBits & BITS_ON_FIRE);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ static inline unsigned short TileNumber_texture(unsigned short tilenumber)
|
|||
|
||||
#define BITS_NOTBLOCKING 0x01 // units can drive on this even if there is a structure or feature on it
|
||||
#define BITS_FPATHBLOCK 0x10 // bit set temporarily by find path to mark a blocking tile
|
||||
#define BITS_ON_FIRE 0x20 // cache whether tile is burning
|
||||
#define BITS_GATEWAY 0x40 // bit set to show a gateway on the tile
|
||||
#define BITS_TALLSTRUCTURE 0x80 // bit set to show a tall structure which camera needs to avoid.
|
||||
|
||||
|
|
|
@ -1777,7 +1777,7 @@ BOOL scrGetFeatureB(void)
|
|||
if( ( psCurrEnumFeature[bucket]->psStats->subType == psFeatureStatToFind[bucket]->subType)
|
||||
&&( psCurrEnumFeature[bucket]->visible[playerToEnum[bucket]] != 0)
|
||||
&&!TileHasStructure(mapTile(map_coord(psCurrEnumFeature[bucket]->pos.x), map_coord(psCurrEnumFeature[bucket]->pos.y)))
|
||||
/*&&!fireOnLocation(psCurrEnumFeature[bucket]->pos.x,psCurrEnumFeature[bucket]->pos.y )*/ // not burning.
|
||||
&&!fireOnLocation(psCurrEnumFeature[bucket]->pos.x,psCurrEnumFeature[bucket]->pos.y ) // not burning.
|
||||
)
|
||||
{
|
||||
scrFunctionResult.v.oval = psCurrEnumFeature[bucket];
|
||||
|
|
Loading…
Reference in New Issue