- disabled more caching to determine if any of these caches cause out of synch
This commit is contained in:
parent
ab966d7872
commit
ca2408073e
|
@ -102,7 +102,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
unit->setCurrentUnitTitle(szBuf);
|
unit->setCurrentUnitTitle(szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
unit->getFaction()->addCachedPath(finalPos,unit);
|
//unit->getFaction()->addCachedPath(finalPos,unit);
|
||||||
return tsArrived;
|
return tsArrived;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -169,7 +169,7 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
case tsArrived:
|
case tsArrived:
|
||||||
|
|
||||||
if(ts == tsArrived) {
|
if(ts == tsArrived) {
|
||||||
unit->getFaction()->addCachedPath(finalPos,unit);
|
//unit->getFaction()->addCachedPath(finalPos,unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The unit is stuck (not only blocked but unable to go anywhere for a while)
|
// The unit is stuck (not only blocked but unable to go anywhere for a while)
|
||||||
|
|
|
@ -53,7 +53,7 @@ UnitUpdater::UnitUpdater() {
|
||||||
this->scriptManager= NULL;
|
this->scriptManager= NULL;
|
||||||
this->routePlanner = NULL;
|
this->routePlanner = NULL;
|
||||||
this->pathFinder = NULL;
|
this->pathFinder = NULL;
|
||||||
UnitRangeCellsLookupItemCacheTimerCount = 0;
|
//UnitRangeCellsLookupItemCacheTimerCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitUpdater::init(Game *game){
|
void UnitUpdater::init(Game *game){
|
||||||
|
@ -67,7 +67,7 @@ void UnitUpdater::init(Game *game){
|
||||||
this->scriptManager= game->getScriptManager();
|
this->scriptManager= game->getScriptManager();
|
||||||
this->routePlanner = NULL;
|
this->routePlanner = NULL;
|
||||||
this->pathFinder = NULL;
|
this->pathFinder = NULL;
|
||||||
UnitRangeCellsLookupItemCacheTimerCount = 0;
|
//UnitRangeCellsLookupItemCacheTimerCount = 0;
|
||||||
|
|
||||||
switch(this->game->getGameSettings()->getPathFinderType()) {
|
switch(this->game->getGameSettings()->getPathFinderType()) {
|
||||||
case pfBasic:
|
case pfBasic:
|
||||||
|
@ -83,7 +83,7 @@ void UnitUpdater::init(Game *game){
|
||||||
}
|
}
|
||||||
|
|
||||||
UnitUpdater::~UnitUpdater() {
|
UnitUpdater::~UnitUpdater() {
|
||||||
UnitRangeCellsLookupItemCache.clear();
|
//UnitRangeCellsLookupItemCache.clear();
|
||||||
|
|
||||||
delete pathFinder;
|
delete pathFinder;
|
||||||
pathFinder = NULL;
|
pathFinder = NULL;
|
||||||
|
@ -1464,6 +1464,7 @@ bool UnitUpdater::attackableOnRange(const Unit *unit, Unit **rangedPtr, const At
|
||||||
return unitOnRange(unit, range, rangedPtr, ast);
|
return unitOnRange(unit, range, rangedPtr, ast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
bool UnitUpdater::findCachedCellsEnemies(Vec2i center, int range, int size, vector<Unit*> &enemies,
|
bool UnitUpdater::findCachedCellsEnemies(Vec2i center, int range, int size, vector<Unit*> &enemies,
|
||||||
const AttackSkillType *ast, const Unit *unit,
|
const AttackSkillType *ast, const Unit *unit,
|
||||||
const Unit *commandTarget) {
|
const Unit *commandTarget) {
|
||||||
|
@ -1490,6 +1491,7 @@ bool UnitUpdater::findCachedCellsEnemies(Vec2i center, int range, int size, vect
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void UnitUpdater::findEnemiesForCell(const AttackSkillType *ast, Cell *cell, const Unit *unit,
|
void UnitUpdater::findEnemiesForCell(const AttackSkillType *ast, Cell *cell, const Unit *unit,
|
||||||
const Unit *commandTarget,vector<Unit*> &enemies) {
|
const Unit *commandTarget,vector<Unit*> &enemies) {
|
||||||
|
@ -1534,12 +1536,12 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
|
||||||
Vec2f floatCenter = unit->getFloatCenteredPos();
|
Vec2f floatCenter = unit->getFloatCenteredPos();
|
||||||
|
|
||||||
bool foundInCache = true;
|
bool foundInCache = true;
|
||||||
if(findCachedCellsEnemies(center,range,size,enemies,ast,
|
//if(findCachedCellsEnemies(center,range,size,enemies,ast,
|
||||||
unit,commandTarget) == false) {
|
// unit,commandTarget) == false) {
|
||||||
foundInCache = false;
|
foundInCache = false;
|
||||||
|
|
||||||
//nearby cells
|
//nearby cells
|
||||||
UnitRangeCellsLookupItem cacheItem;
|
//UnitRangeCellsLookupItem cacheItem;
|
||||||
for(int i=center.x-range; i<center.x+range+size; ++i){
|
for(int i=center.x-range; i<center.x+range+size; ++i){
|
||||||
for(int j=center.y-range; j<center.y+range+size; ++j){
|
for(int j=center.y-range; j<center.y+range+size; ++j){
|
||||||
|
|
||||||
|
@ -1552,17 +1554,17 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
|
||||||
Cell *cell = map->getCell(i,j);
|
Cell *cell = map->getCell(i,j);
|
||||||
findEnemiesForCell(ast,cell,unit,commandTarget,enemies);
|
findEnemiesForCell(ast,cell,unit,commandTarget,enemies);
|
||||||
|
|
||||||
cacheItem.rangeCellList.push_back(cell);
|
//cacheItem.rangeCellList.push_back(cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok update our caches with the latest info
|
// Ok update our caches with the latest info
|
||||||
if(cacheItem.rangeCellList.size() > 0) {
|
//if(cacheItem.rangeCellList.size() > 0) {
|
||||||
cacheItem.UnitRangeCellsLookupItemCacheTimerCountIndex = UnitRangeCellsLookupItemCacheTimerCount++;
|
// cacheItem.UnitRangeCellsLookupItemCacheTimerCountIndex = UnitRangeCellsLookupItemCacheTimerCount++;
|
||||||
UnitRangeCellsLookupItemCache[center][size][range] = cacheItem;
|
// UnitRangeCellsLookupItemCache[center][size][range] = cacheItem;
|
||||||
}
|
//}
|
||||||
}
|
//}
|
||||||
|
|
||||||
//attack enemies that can attack first
|
//attack enemies that can attack first
|
||||||
for(int i = 0; i< enemies.size(); ++i) {
|
for(int i = 0; i< enemies.size(); ++i) {
|
||||||
|
|
|
@ -71,14 +71,14 @@ private:
|
||||||
Game *game;
|
Game *game;
|
||||||
RandomGen random;
|
RandomGen random;
|
||||||
|
|
||||||
std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > > UnitRangeCellsLookupItemCache;
|
//std::map<Vec2i, std::map<int, std::map<int, UnitRangeCellsLookupItem > > > UnitRangeCellsLookupItemCache;
|
||||||
//std::map<int,ExploredCellsLookupKey> ExploredCellsLookupItemCacheTimer;
|
//std::map<int,ExploredCellsLookupKey> ExploredCellsLookupItemCacheTimer;
|
||||||
int UnitRangeCellsLookupItemCacheTimerCount;
|
//int UnitRangeCellsLookupItemCacheTimerCount;
|
||||||
|
|
||||||
bool findCachedCellsEnemies(Vec2i center, int range,
|
//bool findCachedCellsEnemies(Vec2i center, int range,
|
||||||
int size, vector<Unit*> &enemies,
|
// int size, vector<Unit*> &enemies,
|
||||||
const AttackSkillType *ast, const Unit *unit,
|
// const AttackSkillType *ast, const Unit *unit,
|
||||||
const Unit *commandTarget);
|
// const Unit *commandTarget);
|
||||||
void findEnemiesForCell(const AttackSkillType *ast, Cell *cell, const Unit *unit,
|
void findEnemiesForCell(const AttackSkillType *ast, Cell *cell, const Unit *unit,
|
||||||
const Unit *commandTarget,vector<Unit*> &enemies);
|
const Unit *commandTarget,vector<Unit*> &enemies);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue