- a few more performance optimizations and logging changes
This commit is contained in:
parent
77eadd7710
commit
d806e7f9ff
|
@ -235,7 +235,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos){
|
||||||
}
|
}
|
||||||
}//while
|
}//while
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld, openNodes.empty() = %d, pathFound = %d, nodeLimitReached = %d, unit = %s\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),openNodes.empty(),pathFound,nodeLimitReached,unit->getFullName().c_str());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld, openNodes.empty() = %d, pathFound = %d, nodeLimitReached = %d, unit = %s\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),openNodes.empty(),pathFound,nodeLimitReached,unit->getFullName().c_str());
|
||||||
|
|
||||||
Node *lastNode= node;
|
Node *lastNode= node;
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 2) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//clean nodes
|
//clean nodes
|
||||||
openNodes.clear();
|
openNodes.clear();
|
||||||
|
|
|
@ -1621,7 +1621,7 @@ void Unit::exploreCells() {
|
||||||
|
|
||||||
game->getWorld()->exploreCells(newPos, sightRange, teamIndex);
|
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());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,20 +100,20 @@ void UnitUpdater::updateUnit(Unit *unit) {
|
||||||
|
|
||||||
//play skill sound
|
//play skill sound
|
||||||
const SkillType *currSkill= unit->getCurrSkill();
|
const SkillType *currSkill= unit->getCurrSkill();
|
||||||
if(currSkill->getSound()!=NULL){
|
if(currSkill->getSound()!=NULL) {
|
||||||
float soundStartTime= currSkill->getSoundStartTime();
|
float soundStartTime= currSkill->getSoundStartTime();
|
||||||
if(soundStartTime>=unit->getLastAnimProgress() && soundStartTime<unit->getAnimProgress()){
|
if(soundStartTime>=unit->getLastAnimProgress() && soundStartTime<unit->getAnimProgress()) {
|
||||||
if(map->getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(world->getThisTeamIndex())){
|
if(map->getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(world->getThisTeamIndex())) {
|
||||||
soundRenderer.playFx(currSkill->getSound(), unit->getCurrVector(), gameCamera->getPos());
|
soundRenderer.playFx(currSkill->getSound(), unit->getCurrVector(), gameCamera->getPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [play skill sound]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [play skill sound]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
//start attack particle system
|
//start attack particle system
|
||||||
if(unit->getCurrSkill()->getClass()==scAttack){
|
if(unit->getCurrSkill()->getClass() == scAttack) {
|
||||||
const AttackSkillType *ast= static_cast<const AttackSkillType*>(unit->getCurrSkill());
|
const AttackSkillType *ast= static_cast<const AttackSkillType*>(unit->getCurrSkill());
|
||||||
float attackStartTime= ast->getAttackStartTime();
|
float attackStartTime= ast->getAttackStartTime();
|
||||||
if(attackStartTime>=unit->getLastAnimProgress() && attackStartTime<unit->getAnimProgress()){
|
if(attackStartTime>=unit->getLastAnimProgress() && attackStartTime<unit->getAnimProgress()){
|
||||||
|
@ -121,36 +121,36 @@ void UnitUpdater::updateUnit(Unit *unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [start attack particles]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [start attack particles]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
//update unit
|
//update unit
|
||||||
if(unit->update()){
|
if(unit->update()) {
|
||||||
//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__);
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [update unit check]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [update unit check]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
updateUnitCommand(unit);
|
updateUnitCommand(unit);
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [update unit command]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [update unit command]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
//if unit is out of EP, it stops
|
//if unit is out of EP, it stops
|
||||||
if(unit->computeEp()){
|
if(unit->computeEp()) {
|
||||||
unit->setCurrSkill(scStop);
|
unit->setCurrSkill(scStop);
|
||||||
unit->cancelCommand();
|
unit->cancelCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [compute ep]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [compute ep]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
//move unit in cells
|
//move unit in cells
|
||||||
if(unit->getCurrSkill()->getClass()==scMove){
|
if(unit->getCurrSkill()->getClass() == scMove) {
|
||||||
world->moveUnitCells(unit);
|
world->moveUnitCells(unit);
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [move unit cells]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [move unit cells]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
//play water sound
|
//play water sound
|
||||||
if(map->getCell(unit->getPos())->getHeight()<map->getWaterLevel() && unit->getCurrField()==fLand){
|
if(map->getCell(unit->getPos())->getHeight()<map->getWaterLevel() && unit->getCurrField()==fLand){
|
||||||
|
@ -160,17 +160,17 @@ void UnitUpdater::updateUnit(Unit *unit) {
|
||||||
gameCamera->getPos()
|
gameCamera->getPos()
|
||||||
);
|
);
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [play water sound]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [play water sound]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//unit death
|
//unit death
|
||||||
if(unit->isDead() && unit->getCurrSkill()->getClass()!=scDie){
|
if(unit->isDead() && unit->getCurrSkill()->getClass() != scDie) {
|
||||||
unit->kill();
|
unit->kill();
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [kill unit]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [kill unit]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ void UnitUpdater::updateUnit(Unit *unit) {
|
||||||
// ==================== progress commands ====================
|
// ==================== progress commands ====================
|
||||||
|
|
||||||
//VERY IMPORTANT: compute next state depending on the first order of the list
|
//VERY IMPORTANT: compute next state depending on the first order of the list
|
||||||
void UnitUpdater::updateUnitCommand(Unit *unit){
|
void UnitUpdater::updateUnitCommand(Unit *unit) {
|
||||||
Chrono chrono;
|
Chrono chrono;
|
||||||
chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
|
@ -188,22 +188,21 @@ void UnitUpdater::updateUnitCommand(Unit *unit){
|
||||||
}
|
}
|
||||||
|
|
||||||
//if no commands stop and add stop command
|
//if no commands stop and add stop command
|
||||||
if(!unit->anyCommand() && unit->isOperative()){
|
if(unit->anyCommand() == false && unit->isOperative()) {
|
||||||
//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->setCurrSkill(scStop);
|
unit->setCurrSkill(scStop);
|
||||||
if(unit->getType()->hasCommandClass(ccStop)){
|
if(unit->getType()->hasCommandClass(ccStop)) {
|
||||||
//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->giveCommand(new Command(unit->getType()->getFirstCtOfClass(ccStop)));
|
unit->giveCommand(new Command(unit->getType()->getFirstCtOfClass(ccStop)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== updateStop ====================
|
// ==================== updateStop ====================
|
||||||
|
|
||||||
void UnitUpdater::updateStop(Unit *unit){
|
void UnitUpdater::updateStop(Unit *unit) {
|
||||||
Chrono chrono;
|
Chrono chrono;
|
||||||
chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
|
@ -215,21 +214,21 @@ void UnitUpdater::updateStop(Unit *unit){
|
||||||
|
|
||||||
//we can attack any unit => attack it
|
//we can attack any unit => attack it
|
||||||
if(unit->getType()->hasSkillClass(scAttack)){
|
if(unit->getType()->hasSkillClass(scAttack)){
|
||||||
for(int i=0; i<unit->getType()->getCommandTypeCount(); ++i){
|
for(int i=0; i<unit->getType()->getCommandTypeCount(); ++i) {
|
||||||
const CommandType *ct= unit->getType()->getCommandType(i);
|
const CommandType *ct= unit->getType()->getCommandType(i);
|
||||||
|
|
||||||
//look for an attack skill
|
//look for an attack skill
|
||||||
const AttackSkillType *ast= NULL;
|
const AttackSkillType *ast= NULL;
|
||||||
if(ct->getClass()==ccAttack){
|
if(ct->getClass()==ccAttack) {
|
||||||
ast= static_cast<const AttackCommandType*>(ct)->getAttackSkillType();
|
ast= static_cast<const AttackCommandType*>(ct)->getAttackSkillType();
|
||||||
}
|
}
|
||||||
else if(ct->getClass()==ccAttackStopped){
|
else if(ct->getClass()==ccAttackStopped) {
|
||||||
ast= static_cast<const AttackStoppedCommandType*>(ct)->getAttackSkillType();
|
ast= static_cast<const AttackStoppedCommandType*>(ct)->getAttackSkillType();
|
||||||
}
|
}
|
||||||
|
|
||||||
//use it to attack
|
//use it to attack
|
||||||
if(ast!=NULL){
|
if(ast!=NULL){
|
||||||
if(attackableOnSight(unit, &sighted, ast)){
|
if(attackableOnSight(unit, &sighted, ast)) {
|
||||||
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->giveCommand(new Command(ct, sighted->getPos()));
|
unit->giveCommand(new Command(ct, sighted->getPos()));
|
||||||
break;
|
break;
|
||||||
|
@ -237,23 +236,21 @@ void UnitUpdater::updateStop(Unit *unit){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//see any unit and cant attack it => run
|
//see any unit and cant attack it => run
|
||||||
else if(unit->getType()->hasCommandClass(ccMove)){
|
else if(unit->getType()->hasCommandClass(ccMove)) {
|
||||||
if(attackerOnSight(unit, &sighted)){
|
if(attackerOnSight(unit, &sighted)) {
|
||||||
Vec2i escapePos= unit->getPos()*2-sighted->getPos();
|
Vec2i escapePos= unit->getPos()*2-sighted->getPos();
|
||||||
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->giveCommand(new Command(unit->getType()->getFirstCtOfClass(ccMove), escapePos));
|
unit->giveCommand(new Command(unit->getType()->getFirstCtOfClass(ccMove), escapePos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ==================== updateMove ====================
|
// ==================== updateMove ====================
|
||||||
void UnitUpdater::updateMove(Unit *unit){
|
void UnitUpdater::updateMove(Unit *unit) {
|
||||||
Chrono chrono;
|
Chrono chrono;
|
||||||
chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
|
@ -274,6 +271,9 @@ void UnitUpdater::updateMove(Unit *unit){
|
||||||
throw runtime_error("detected unsupported pathfinder type!");
|
throw runtime_error("detected unsupported pathfinder type!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
switch (tsValue) {
|
switch (tsValue) {
|
||||||
case tsMoving:
|
case tsMoving:
|
||||||
unit->setCurrSkill(mct->getMoveSkillType());
|
unit->setCurrSkill(mct->getMoveSkillType());
|
||||||
|
@ -290,8 +290,7 @@ void UnitUpdater::updateMove(Unit *unit){
|
||||||
unit->finishCommand();
|
unit->finishCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -306,28 +305,34 @@ void UnitUpdater::updateAttack(Unit *unit){
|
||||||
Unit *target= NULL;
|
Unit *target= NULL;
|
||||||
|
|
||||||
//if found
|
//if found
|
||||||
if(attackableOnRange(unit, &target, act->getAttackSkillType())){
|
if(attackableOnRange(unit, &target, act->getAttackSkillType())) {
|
||||||
if(unit->getEp()>=act->getAttackSkillType()->getEpCost()){
|
if(unit->getEp()>=act->getAttackSkillType()->getEpCost()) {
|
||||||
unit->setCurrSkill(act->getAttackSkillType());
|
unit->setCurrSkill(act->getAttackSkillType());
|
||||||
unit->setTarget(target);
|
unit->setTarget(target);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
unit->setCurrSkill(scStop);
|
unit->setCurrSkill(scStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
//compute target pos
|
//compute target pos
|
||||||
Vec2i pos;
|
Vec2i pos;
|
||||||
if(command->getUnit()!=NULL){
|
if(command->getUnit()!=NULL) {
|
||||||
pos= command->getUnit()->getCenteredPos();
|
pos= command->getUnit()->getCenteredPos();
|
||||||
}
|
}
|
||||||
else if(attackableOnSight(unit, &target, act->getAttackSkillType())){
|
else if(attackableOnSight(unit, &target, act->getAttackSkillType())) {
|
||||||
pos= target->getPos();
|
pos= target->getPos();
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
pos= command->getPos();
|
pos= command->getPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
TravelState tsValue = tsImpossible;
|
TravelState tsValue = tsImpossible;
|
||||||
switch(this->game->getGameSettings()->getPathFinderType()) {
|
switch(this->game->getGameSettings()->getPathFinderType()) {
|
||||||
case pfBasic:
|
case pfBasic:
|
||||||
|
@ -340,6 +345,9 @@ void UnitUpdater::updateAttack(Unit *unit){
|
||||||
throw runtime_error("detected unsupported pathfinder type!");
|
throw runtime_error("detected unsupported pathfinder type!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
//if unit arrives destPos order has ended
|
//if unit arrives destPos order has ended
|
||||||
switch (tsValue){
|
switch (tsValue){
|
||||||
case tsMoving:
|
case tsMoving:
|
||||||
|
@ -355,8 +363,7 @@ void UnitUpdater::updateAttack(Unit *unit){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1468,30 +1475,32 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [AFTER LOOP]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
//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) {
|
||||||
if(enemies[i]->getType()->hasSkillClass(scAttack)){
|
if(enemies[i]->getType()->hasSkillClass(scAttack)) {
|
||||||
*rangedPtr= enemies[i];
|
*rangedPtr= enemies[i];
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld, unit %s, range = %d, size = %d, foundInCache = %d, enemies.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),unit->getFullName().c_str(),range,size,foundInCache,enemies.size());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld, unit %s, range = %d, size = %d, foundInCache = %d, enemies.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),unit->getFullName().c_str(),range,size,foundInCache,enemies.size());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//any enemy
|
//any enemy
|
||||||
if(enemies.size()>0){
|
if(enemies.size() > 0) {
|
||||||
*rangedPtr= enemies.front();
|
*rangedPtr= enemies.front();
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld, unit %s, range = %d, size = %d, foundInCache = %d, enemies.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),unit->getFullName().c_str(),range,size,foundInCache,enemies.size());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld, unit %s, range = %d, size = %d, foundInCache = %d, enemies.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),unit->getFullName().c_str(),range,size,foundInCache,enemies.size());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 1) chrono.start();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld, unit %s, range = %d, size = %d, foundInCache = %d, enemies.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),unit->getFullName().c_str(),range,size,foundInCache,enemies.size());
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld, unit %s, range = %d, size = %d, foundInCache = %d, enemies.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),unit->getFullName().c_str(),range,size,foundInCache,enemies.size());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -962,6 +962,7 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex){
|
||||||
ExploredCellsLookupItem::lastDebug = time(NULL);
|
ExploredCellsLookupItem::lastDebug = time(NULL);
|
||||||
//printf("In [%s::%s Line: %d] ExploredCellsLookupItemCache.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,ExploredCellsLookupItemCache.size());
|
//printf("In [%s::%s Line: %d] ExploredCellsLookupItemCache.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,ExploredCellsLookupItemCache.size());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ExploredCellsLookupItemCache.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,ExploredCellsLookupItemCache.size());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ExploredCellsLookupItemCache.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,ExploredCellsLookupItemCache.size());
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] ExploredCellsLookupItemCache.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,ExploredCellsLookupItemCache.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok we limit the cache size due to possible RAM constraints when
|
// Ok we limit the cache size due to possible RAM constraints when
|
||||||
|
@ -1019,7 +1020,7 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex){
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld [CACHE lookup found]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld [CACHE lookup found]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1027,7 +1028,7 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex){
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [CACHE lookup not found] cacheLookupPosResult = %d, cacheLookupSightResult = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),cacheLookupPosResult,cacheLookupSightResult);
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [CACHE lookup not found] cacheLookupPosResult = %d, cacheLookupSightResult = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),cacheLookupPosResult,cacheLookupSightResult);
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
Vec2i newSurfPos= Map::toSurfCoords(newPos);
|
Vec2i newSurfPos= Map::toSurfCoords(newPos);
|
||||||
int surfSightRange= sightRange/Map::cellScale+1;
|
int surfSightRange= sightRange/Map::cellScale+1;
|
||||||
|
@ -1035,21 +1036,25 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex){
|
||||||
// Explore, this code is quite expensive when we have lots of units
|
// Explore, this code is quite expensive when we have lots of units
|
||||||
ExploredCellsLookupItem item;
|
ExploredCellsLookupItem item;
|
||||||
|
|
||||||
|
int loopCount = 0;
|
||||||
for(int i = -surfSightRange - indirectSightRange -1; i <= surfSightRange + indirectSightRange +1; ++i) {
|
for(int i = -surfSightRange - indirectSightRange -1; i <= surfSightRange + indirectSightRange +1; ++i) {
|
||||||
for(int j = -surfSightRange - indirectSightRange -1; j <= surfSightRange + indirectSightRange +1; ++j) {
|
for(int j = -surfSightRange - indirectSightRange -1; j <= surfSightRange + indirectSightRange +1; ++j) {
|
||||||
Vec2i currRelPos= Vec2i(i, j);
|
loopCount++;
|
||||||
|
Vec2i currRelPos= Vec2i(i, j);
|
||||||
Vec2i currPos= newSurfPos + currRelPos;
|
Vec2i currPos= newSurfPos + currRelPos;
|
||||||
if(map.isInsideSurface(currPos)){
|
if(map.isInsideSurface(currPos)){
|
||||||
SurfaceCell *sc= map.getSurfaceCell(currPos);
|
SurfaceCell *sc= map.getSurfaceCell(currPos);
|
||||||
|
|
||||||
//explore
|
//explore
|
||||||
if(Vec2i(0).dist(currRelPos) < surfSightRange + indirectSightRange + 1) {
|
//if(Vec2i(0).dist(currRelPos) < surfSightRange + indirectSightRange + 1) {
|
||||||
|
if(currRelPos.length() < surfSightRange + indirectSightRange + 1) {
|
||||||
sc->setExplored(teamIndex, true);
|
sc->setExplored(teamIndex, true);
|
||||||
item.exploredCellList.push_back(sc);
|
item.exploredCellList.push_back(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
//visible
|
//visible
|
||||||
if(Vec2i(0).dist(currRelPos) < surfSightRange) {
|
//if(Vec2i(0).dist(currRelPos) < surfSightRange) {
|
||||||
|
if(currRelPos.length() < surfSightRange) {
|
||||||
sc->setVisible(teamIndex, true);
|
sc->setVisible(teamIndex, true);
|
||||||
item.visibleCellList.push_back(sc);
|
item.visibleCellList.push_back(sc);
|
||||||
}
|
}
|
||||||
|
@ -1057,8 +1062,8 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [RAW explore cells logic] cacheLookupPosResult = %d, cacheLookupSightResult = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),cacheLookupPosResult,cacheLookupSightResult);
|
if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [RAW explore cells logic] cacheLookupPosResult = %d, cacheLookupSightResult = %d, loopCount = %d, MaxExploredCellsLookupItemCache = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),cacheLookupPosResult,cacheLookupSightResult,loopCount,MaxExploredCellsLookupItemCache);
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
// Ok update our caches with the latest info for this position, sight and team
|
// Ok update our caches with the latest info for this position, sight and team
|
||||||
if(MaxExploredCellsLookupItemCache > 0) {
|
if(MaxExploredCellsLookupItemCache > 0) {
|
||||||
|
@ -1074,8 +1079,7 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex){
|
||||||
ExploredCellsLookupItemCacheTimer[item.ExploredCellsLookupItemCacheTimerCountIndex] = lookupKey;
|
ExploredCellsLookupItemCacheTimer[item.ExploredCellsLookupItemCacheTimerCountIndex] = lookupKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld [add explorecells result to CACHE]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld [add explorecells result to CACHE]\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//computes the fog of war texture, contained in the minimap
|
//computes the fog of war texture, contained in the minimap
|
||||||
|
|
Loading…
Reference in New Issue
Block a user