Simplify checks a bit.
parent
7663966206
commit
7c76ca4be1
|
@ -4091,7 +4091,8 @@ x and y in tile-coords*/
|
||||||
bool validLocation(BASE_STATS *psStats, unsigned x, unsigned y, uint16_t direction, unsigned player, bool bCheckBuildQueue)
|
bool validLocation(BASE_STATS *psStats, unsigned x, unsigned y, uint16_t direction, unsigned player, bool bCheckBuildQueue)
|
||||||
{
|
{
|
||||||
STRUCTURE *psStruct;
|
STRUCTURE *psStruct;
|
||||||
STRUCTURE_STATS *psBuilding;
|
STRUCTURE_STATS * psBuilding = NULL;
|
||||||
|
DROID_TEMPLATE * psTemplate = NULL;
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
SDWORD i, j;
|
SDWORD i, j;
|
||||||
UDWORD min, max;
|
UDWORD min, max;
|
||||||
|
@ -4104,14 +4105,20 @@ bool validLocation(BASE_STATS *psStats, unsigned x, unsigned y, uint16_t directi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
psBuilding = (STRUCTURE_STATS *)psStats;
|
if (psStats->ref >= REF_STRUCTURE_START && psStats->ref < REF_STRUCTURE_START + REF_RANGE)
|
||||||
|
{
|
||||||
|
psBuilding = (STRUCTURE_STATS *)psStats; // Is a structure.
|
||||||
|
}
|
||||||
|
if (psStats->ref >= REF_TEMPLATE_START && psStats->ref < REF_TEMPLATE_START + REF_RANGE)
|
||||||
|
{
|
||||||
|
psTemplate = (DROID_TEMPLATE *)psStats; // Is a template.
|
||||||
|
}
|
||||||
|
|
||||||
// initialise the buildsite structure
|
// initialise the buildsite structure
|
||||||
// gets rid of the nasty bug when the GLOBAL buildSite was
|
// gets rid of the nasty bug when the GLOBAL buildSite was
|
||||||
// used in here
|
// used in here
|
||||||
// Now now...we can quite easily hack this a bit more...
|
// Now now...we can quite easily hack this a bit more...
|
||||||
if (psStats->ref >= REF_STRUCTURE_START &&
|
if (psBuilding != NULL)
|
||||||
psStats->ref < (REF_STRUCTURE_START + REF_RANGE))
|
|
||||||
{
|
{
|
||||||
unsigned sWidth = getStructureStatsWidth(psBuilding, direction);
|
unsigned sWidth = getStructureStatsWidth(psBuilding, direction);
|
||||||
unsigned sBreadth = getStructureStatsBreadth(psBuilding, direction);
|
unsigned sBreadth = getStructureStatsBreadth(psBuilding, direction);
|
||||||
|
@ -4219,8 +4226,7 @@ bool validLocation(BASE_STATS *psStats, unsigned x, unsigned y, uint16_t directi
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
//don't check tile is visible for placement of a delivery point
|
//don't check tile is visible for placement of a delivery point
|
||||||
if (psStats->ref >= REF_STRUCTURE_START &&
|
if (psBuilding != NULL)
|
||||||
psStats->ref < (REF_STRUCTURE_START + REF_RANGE))
|
|
||||||
{
|
{
|
||||||
//allow us to do so in debug mode!
|
//allow us to do so in debug mode!
|
||||||
if (!getDebugMappingStatus() && !bMultiPlayer)
|
if (!getDebugMappingStatus() && !bMultiPlayer)
|
||||||
|
@ -4253,8 +4259,7 @@ bool validLocation(BASE_STATS *psStats, unsigned x, unsigned y, uint16_t directi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (psStats->ref >= REF_STRUCTURE_START &&
|
if (psBuilding != NULL)
|
||||||
psStats->ref < (REF_STRUCTURE_START + REF_RANGE))
|
|
||||||
{
|
{
|
||||||
MAPTILE *psTile;
|
MAPTILE *psTile;
|
||||||
|
|
||||||
|
@ -4509,10 +4514,8 @@ bool validLocation(BASE_STATS *psStats, unsigned x, unsigned y, uint16_t directi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (psStats->ref >= REF_TEMPLATE_START
|
else if (psTemplate != NULL)
|
||||||
&& psStats->ref < REF_TEMPLATE_START + REF_RANGE)
|
|
||||||
{
|
{
|
||||||
DROID_TEMPLATE *psTemplate = (DROID_TEMPLATE *)psStats;
|
|
||||||
PROPULSION_STATS *psPropStats = asPropulsionStats + psTemplate->asParts[COMP_PROPULSION];
|
PROPULSION_STATS *psPropStats = asPropulsionStats + psTemplate->asParts[COMP_PROPULSION];
|
||||||
|
|
||||||
valid = !fpathBlockingTile(x, y, psPropStats->propulsionType);
|
valid = !fpathBlockingTile(x, y, psPropStats->propulsionType);
|
||||||
|
|
Loading…
Reference in New Issue