- attempt to improve explorecells usage when each unit is signalled to move
This commit is contained in:
parent
3825192e2e
commit
77eadd7710
|
@ -45,6 +45,8 @@ Game::Game(Program *program, const GameSettings *gameSettings):
|
||||||
{
|
{
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
Unit::setGame(this);
|
||||||
|
|
||||||
original_updateFps = GameConstants::updateFps;
|
original_updateFps = GameConstants::updateFps;
|
||||||
original_cameraFps = GameConstants::cameraFps;
|
original_cameraFps = GameConstants::cameraFps;
|
||||||
// GameConstants::updateFps= 20;
|
// GameConstants::updateFps= 20;
|
||||||
|
@ -129,6 +131,10 @@ Game::~Game(){
|
||||||
GameConstants::cameraFps = original_cameraFps;
|
GameConstants::cameraFps = original_cameraFps;
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
Unit::setGame(NULL);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Game::quitTriggered() {
|
bool Game::quitTriggered() {
|
||||||
|
|
|
@ -155,6 +155,8 @@ set<Unit*> Unit::livingUnitsp;
|
||||||
|
|
||||||
// ============================ Constructor & destructor =============================
|
// ============================ Constructor & destructor =============================
|
||||||
|
|
||||||
|
Game *Unit::game = NULL;
|
||||||
|
|
||||||
Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing):id(id) {
|
Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing):id(id) {
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -571,6 +573,9 @@ void Unit::setPos(const Vec2i &pos){
|
||||||
this->pos= pos;
|
this->pos= pos;
|
||||||
this->meetingPos= pos - Vec2i(1);
|
this->meetingPos= pos - Vec2i(1);
|
||||||
|
|
||||||
|
// Attempt to improve performance
|
||||||
|
this->exploreCells();
|
||||||
|
|
||||||
logSynchData(string(__FILE__) + string("::") + string(__FUNCTION__) + string(" Line: ") + intToStr(__LINE__));
|
logSynchData(string(__FILE__) + string("::") + string(__FUNCTION__) + string(" Line: ") + intToStr(__LINE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1598,6 +1603,28 @@ int Unit::getFrameCount() {
|
||||||
return frameCount;
|
return frameCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Unit::exploreCells() {
|
||||||
|
if(this->isOperative()) {
|
||||||
|
const Vec2i &newPos = this->getCenteredPos();
|
||||||
|
int sightRange = this->getType()->getSight();
|
||||||
|
int teamIndex = this->getTeam();
|
||||||
|
|
||||||
|
Chrono chrono;
|
||||||
|
chrono.start();
|
||||||
|
|
||||||
|
if(game == NULL) {
|
||||||
|
throw runtime_error("game == NULL");
|
||||||
|
}
|
||||||
|
else if(game->getWorld() == NULL) {
|
||||||
|
throw runtime_error("game->getWorld() == NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
game->getWorld()->exploreCells(newPos, sightRange, teamIndex);
|
||||||
|
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Unit::logSynchData(string source) {
|
void Unit::logSynchData(string source) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true) {
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ class TotalUpgrade;
|
||||||
class UpgradeType;
|
class UpgradeType;
|
||||||
class Level;
|
class Level;
|
||||||
class MorphCommandType;
|
class MorphCommandType;
|
||||||
|
class Game;
|
||||||
|
|
||||||
enum CommandResult{
|
enum CommandResult{
|
||||||
crSuccess,
|
crSuccess,
|
||||||
|
@ -270,10 +271,14 @@ private:
|
||||||
Vec3f screenPos;
|
Vec3f screenPos;
|
||||||
string currentUnitTitle;
|
string currentUnitTitle;
|
||||||
|
|
||||||
|
static Game *game;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Unit(int id, UnitPathInterface *path, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing);
|
Unit(int id, UnitPathInterface *path, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing);
|
||||||
~Unit();
|
~Unit();
|
||||||
|
|
||||||
|
static void setGame(Game *value) { game=value;}
|
||||||
|
|
||||||
//queries
|
//queries
|
||||||
int getId() const {return id;}
|
int getId() const {return id;}
|
||||||
Field getCurrField() const {return currField;}
|
Field getCurrField() const {return currField;}
|
||||||
|
@ -405,6 +410,8 @@ public:
|
||||||
string getCurrentUnitTitle() const {return currentUnitTitle;}
|
string getCurrentUnitTitle() const {return currentUnitTitle;}
|
||||||
void setCurrentUnitTitle(string value) { currentUnitTitle = value;}
|
void setCurrentUnitTitle(string value) { currentUnitTitle = value;}
|
||||||
|
|
||||||
|
void exploreCells();
|
||||||
|
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Glest{ namespace Game{
|
||||||
|
|
||||||
const float World::airHeight= 5.f;
|
const float World::airHeight= 5.f;
|
||||||
// This limit is to keep RAM use under control while offering better performance.
|
// This limit is to keep RAM use under control while offering better performance.
|
||||||
int MaxExploredCellsLookupItemCache = 7500;
|
int MaxExploredCellsLookupItemCache = 9500;
|
||||||
time_t ExploredCellsLookupItem::lastDebug = 0;
|
time_t ExploredCellsLookupItem::lastDebug = 0;
|
||||||
|
|
||||||
// ===================== PUBLIC ========================
|
// ===================== PUBLIC ========================
|
||||||
|
@ -1139,9 +1139,7 @@ void World::computeFow(int factionIdxToTick) {
|
||||||
Unit *unit= getFaction(i)->getUnit(j);
|
Unit *unit= getFaction(i)->getUnit(j);
|
||||||
|
|
||||||
//exploration
|
//exploration
|
||||||
if(unit->isOperative()) {
|
unit->exploreCells();
|
||||||
exploreCells(unit->getCenteredPos(), unit->getType()->getSight(), unit->getTeam());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,6 +206,8 @@ public:
|
||||||
int getUpdateFps(int factionIndex) const;
|
int getUpdateFps(int factionIndex) const;
|
||||||
bool canTickWorld() const;
|
bool canTickWorld() const;
|
||||||
|
|
||||||
|
void exploreCells(const Vec2i &newPos, int sightRange, int teamIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void initCells(bool fogOfWar);
|
void initCells(bool fogOfWar);
|
||||||
|
@ -221,7 +223,6 @@ private:
|
||||||
bool canTickFaction(int factionIdx);
|
bool canTickFaction(int factionIdx);
|
||||||
int tickFactionIndex();
|
int tickFactionIndex();
|
||||||
void computeFow(int factionIdxToTick=-1);
|
void computeFow(int factionIdxToTick=-1);
|
||||||
void exploreCells(const Vec2i &newPos, int sightRange, int teamIndex);
|
|
||||||
|
|
||||||
void updateAllFactionUnits();
|
void updateAllFactionUnits();
|
||||||
void underTakeDeadFactionUnits();
|
void underTakeDeadFactionUnits();
|
||||||
|
|
Loading…
Reference in New Issue