fix for too often applied boosts
This commit is contained in:
parent
e20d242e2c
commit
d34e58ccb6
|
@ -2421,13 +2421,11 @@ void Unit::updateAttackBoostProgress(const Game* game) {
|
|||
attackBoost->radius);
|
||||
|
||||
if(debugBoost) printf("Line: %d candidates unit size: " MG_SIZE_T_SPECIFIER " attackBoost: %s\n",__LINE__,candidates.size(),attackBoost->getDesc(false).c_str());
|
||||
|
||||
for (unsigned int i = 0; i < candidates.size(); ++i) {
|
||||
Unit *affectedUnit = candidates[i];
|
||||
if (attackBoost->isAffected(this, affectedUnit) == true) {
|
||||
if (affectedUnit->applyAttackBoost(attackBoost, this) == true) {
|
||||
currentAttackBoostOriginatorEffect.currentAttackBoostUnits.push_back(affectedUnit->getId());
|
||||
|
||||
//printf("+ #1 APPLY ATTACK BOOST to unit [%s - %d]\n",affectedUnit->getType()->getName().c_str(),affectedUnit->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3159,7 +3159,7 @@ vector<Unit*> UnitUpdater::enemyUnitsOnRange(const Unit *unit,const AttackSkillT
|
|||
}
|
||||
|
||||
|
||||
void UnitUpdater::findUnitsForCell(Cell *cell, const Unit *unit,vector<Unit*> &units) {
|
||||
void UnitUpdater::findUnitsForCell(Cell *cell, vector<Unit*> &units) {
|
||||
//all fields
|
||||
if(cell != NULL) {
|
||||
for(int k = 0; k < fieldCount; k++) {
|
||||
|
@ -3169,11 +3169,25 @@ void UnitUpdater::findUnitsForCell(Cell *cell, const Unit *unit,vector<Unit*> &u
|
|||
Unit *cellUnit = cell->getUnit(f);
|
||||
|
||||
if(cellUnit != NULL && cellUnit->isAlive()) {
|
||||
// check if unit already is in list
|
||||
bool found = false;
|
||||
//printf("---- search for cellUnit=%d\n",cellUnit->getId());
|
||||
for (unsigned int i = 0; i < units.size(); ++i) {
|
||||
Unit *unitInList = units[i];
|
||||
//printf("compare unitInList=%d cellUnit=%d\n",unitInList->getId(),cellUnit->getId());
|
||||
if (unitInList->getId() == cellUnit->getId()){
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found==false){
|
||||
//printf(">>> adding cellUnit=%d\n",cellUnit->getId());
|
||||
units.push_back(cellUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<Unit*> UnitUpdater::findUnitsInRange(const Unit *unit, int radius) {
|
||||
int range = radius;
|
||||
|
@ -3195,7 +3209,7 @@ vector<Unit*> UnitUpdater::findUnitsInRange(const Unit *unit, int radius) {
|
|||
if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){
|
||||
#endif
|
||||
Cell *cell = map->getCell(i,j);
|
||||
findUnitsForCell(cell,unit,units);
|
||||
findUnitsForCell(cell,units);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,6 @@ public:
|
|||
vector<Unit*> enemyUnitsOnRange(const Unit *unit,const AttackSkillType *ast);
|
||||
void findEnemiesForCell(const Vec2i pos, int size, int sightRange, const Faction *faction, vector<Unit*> &enemies, bool attackersOnly) const;
|
||||
|
||||
void findUnitsForCell(Cell *cell, const Unit *unit,vector<Unit*> &units);
|
||||
vector<Unit*> findUnitsInRange(const Unit *unit, int radius);
|
||||
|
||||
string getUnitRangeCellsLookupItemCacheStats();
|
||||
|
@ -159,6 +158,8 @@ private:
|
|||
void SwapActiveCommandState(Unit *unit, CommandStateType commandStateType,
|
||||
const CommandType *commandType,
|
||||
int originalValue,int newValue);
|
||||
void findUnitsForCell(Cell *cell, vector<Unit*> &units);
|
||||
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
|
|
Loading…
Reference in New Issue