refactor: correct tabs

This commit is contained in:
pavanvo 2022-09-05 04:27:22 +04:00
parent 35f755841d
commit c9c1adf8d0
No known key found for this signature in database
GPG Key ID: 34C1C36681B4AD84
1 changed files with 248 additions and 282 deletions

View File

@ -720,9 +720,7 @@ void UnitUpdater::updateAttack(Unit *unit, int frameIndex) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
//if found
//if(frameIndex < 0) {
{
if(attackableOnRange(unit, &target, act->getAttackSkillType(),(frameIndex >= 0))) {
if(frameIndex < 0) {
if(unit->getEp() >= act->getAttackSkillType()->getEpCost()) {
@ -732,7 +730,6 @@ void UnitUpdater::updateAttack(Unit *unit, int frameIndex) {
else {
unit->setCurrSkill(scStop);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"[updateAttack]");
@ -753,15 +750,12 @@ void UnitUpdater::updateAttack(Unit *unit, int frameIndex) {
else {
pos= command->getPos();
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"[updateAttack] pos [%s] unit->getPos() [%s]",pos.getString().c_str(),unit->getPos().getString().c_str());
unit->logSynchData(__FILE__,__LINE__,szBuf);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
TravelState tsValue = tsImpossible;
//if(frameIndex < 0) {
{
@ -777,14 +771,11 @@ void UnitUpdater::updateAttack(Unit *unit, int frameIndex) {
//printf("In [%s::%s Line: %d] END pathfind for attacker [%d - %s]\n",__FILE__,__FUNCTION__,__LINE__,unit->getId(), unit->getType()->getName().c_str());
//fflush(stdout);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
if(frameIndex < 0) {
if(command->getUnit() != NULL && !command->getUnit()->isAlive() && unit->getCommandSize() > 1) {
// don't run over to dead body if there is still something to do in the queue
unit->finishCommand();
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0) {
char szBuf[8096]="";
snprintf(szBuf,8096,"[updateAttack]");
@ -799,7 +790,6 @@ void UnitUpdater::updateAttack(Unit *unit, int frameIndex) {
snprintf(szBuf,8096,"#1 [updateAttack] tsValue = %d",tsValue);
unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
}
switch (tsValue) {
case tsMoving:
unit->setCurrSkill(act->getMoveSkillType());
@ -816,7 +806,6 @@ void UnitUpdater::updateAttack(Unit *unit, int frameIndex) {
/*
case tsMoving:
unit->setCurrSkill(act->getMoveSkillType());
{
std::pair<bool,Unit *> beingAttacked = unitBeingAttacked(unit);
if(beingAttacked.first == true) {
@ -841,9 +830,7 @@ void UnitUpdater::updateAttack(Unit *unit, int frameIndex) {
}
}
}
break;
case tsBlocked:
if(unit->getPath()->isBlocked()){
unit->finishCommand();
@ -853,20 +840,17 @@ void UnitUpdater::updateAttack(Unit *unit, int frameIndex) {
unit->finishCommand();
}
*/
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled == true && frameIndex < 0 &&
SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynchMax).enabled == true) {
char szBuf[8096]="";
snprintf(szBuf,8096,"#2 [updateAttack] tsValue = %d",tsValue);
unit->logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__,szBuf);
}
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -2935,10 +2919,11 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
for(int j = center.y - range; j < center.y + range + size; ++j) {
//cells inside map and in range
#ifdef USE_STREFLOP
if(map->isInside(i, j) && streflop::floor(static_cast<streflop::Simple>(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range+1)){
if(map->isInside(i, j) && streflop::floor(static_cast<streflop::Simple>(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range+1))
#else
if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){
if(map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1))
#endif
{
Cell *cell = map->getCell(i,j);
findEnemiesForCell(ast,cell,unit,commandTarget,enemies);
@ -2962,39 +2947,27 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
std::vector<Unit*> fightingEnemiesInRange;
std::vector<Unit*> damagedFightingEnemiesInRange;
Unit* myFightingEnemyInRange= NULL;
float distToStandingUnit= -1;
Unit* attackingEnemySeen= NULL;
ControlType controlType= unit->getFaction()->getControlType();
bool isUltra= controlType == ctCpuUltra || controlType == ctNetworkCpuUltra;
bool isMega= controlType == ctCpuMega || controlType == ctNetworkCpuMega;
string randomInfoData = "enemies.size() = " + intToStr(enemies.size());
//printf("unit %d has control:%d\n",unit->getId(),controlType);
for(int i = 0; i< (int)enemies.size(); ++i) {
Unit *enemy = enemies[i];
if(enemy != NULL && enemy->isAlive() == true) {
// Here we default to first enemy if no attackers found
if(enemySeen == NULL) {
*rangedPtr = enemy;
enemySeen = enemy;
result = true;
}
//randomInfoData += " i = " + intToStr(i) + " alive = true result = " + intToStr(result);
// Attackers get first priority
if(enemy->getType()->hasSkillClass(scAttack) == true) {
float currentDist = unit->getCenteredPos().dist(enemy->getCenteredPos());
//randomInfoData += " currentDist = " + floatToStr(currentDist);
// Select closest attacking unit
if (distToUnit < 0 || currentDist < distToUnit) {
distToUnit = currentDist;
@ -3027,7 +3000,6 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
}
}
}
}
}
}
@ -3048,7 +3020,6 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
unitList = &damagedFightingEnemiesInRange;
else
unitList = &fightingEnemiesInRange;
//printf("Choosing new one\n");
int myChoice = unit->getRandom()->randRange(1, unitList->size(), extractFileFromDirectoryPath(__FILE__) + intToStr(__LINE__));
//printf("myChoice=%d\n", myChoice);
@ -3124,9 +3095,7 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
}
}
}
if(nearest != NULL) {
// does it fit?
if(nearestDistance < attackWarnRange) {
// update entry with current values
@ -3146,19 +3115,16 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
awd->lastFrameCount=world->getFrameCount();
awd->attackPosition.x=enemyFloatCenter.x;
awd->attackPosition.y=enemyFloatCenter.y;
MutexSafeWrapper safeMutex(mutexAttackWarnings,string(__FILE__) + "_" + intToStr(__LINE__));
attackWarnings.push_back(awd);
if(world->getAttackWarningsEnabled() == true) {
SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound(),true);
world->addAttackEffects(enemyUnit);
}
}
}
}
}
catch(const exception &ex) {
//setRunningStatus(false);