diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp index ff0c02390..c31d475ca 100644 --- a/src/ai/ai.cpp +++ b/src/ai/ai.cpp @@ -699,28 +699,28 @@ void AiHelpMe(const CUnit *attacker, CUnit &defender) // FIXME ad support for help from Coward type units if (aiunit.IsAgressive() && CanTarget(aiunit.Type, attacker->Type) && aiunit.CurrentOrder()->GetGoal() != attacker) { - bool shouldAttack = aiunit.IsIdle(); + bool shouldAttack = aiunit.IsIdle(); - if (aiunit.CurrentAction() == UnitActionAttack) { - const COrder_Attack &orderAttack = *static_cast<COrder_Attack *>(aiunit.CurrentOrder()); - const CUnit *oldGoal = orderAttack.GetGoal(); + if (aiunit.CurrentAction() == UnitActionAttack) { + const COrder_Attack &orderAttack = *static_cast<COrder_Attack *>(aiunit.CurrentOrder()); + const CUnit *oldGoal = orderAttack.GetGoal(); - if (oldGoal == NULL || oldGoal->IsAgressive() == false - || (ThreatCalculate(defender, *attacker) < ThreatCalculate(defender, *oldGoal) + if (oldGoal == NULL || oldGoal->IsAgressive() == false + || (ThreatCalculate(defender, *attacker) < ThreatCalculate(defender, *oldGoal) && aiunit.MapDistanceTo(defender) <= aiunit.Stats->Variables[ATTACKRANGE_INDEX].Max)) { - shouldAttack = true; - } + shouldAttack = true; } + } - if (shouldAttack) { - CommandAttack(aiunit, attacker->tilePos, const_cast<CUnit *>(attacker), FlushCommands); - COrder *savedOrder = COrder::NewActionAttack(aiunit, attacker->tilePos); + if (shouldAttack) { + CommandAttack(aiunit, attacker->tilePos, const_cast<CUnit *>(attacker), FlushCommands); + COrder *savedOrder = COrder::NewActionAttack(aiunit, attacker->tilePos); - if (aiunit.StoreOrder(savedOrder) == false) { - delete savedOrder; - savedOrder = NULL; - } + if (aiunit.StoreOrder(savedOrder) == false) { + delete savedOrder; + savedOrder = NULL; } + } } } if (!aiForce.Defending && aiForce.State > 0) { diff --git a/src/ai/ai_force.cpp b/src/ai/ai_force.cpp index 7aeb4056e..16b5c626a 100644 --- a/src/ai/ai_force.cpp +++ b/src/ai/ai_force.cpp @@ -286,7 +286,7 @@ void AiForce::Attack(const Vec2i &pos) // Remember the original force position so we can return there after attack if (this->Role == AiForceRoleDefend || (this->Role == AiForceRoleAttack && this->State == AiForceAttackingState_Waiting)) { - this->HomePos = this->Units[this->Units.size()-1]->tilePos; + this->HomePos = this->Units[this->Units.size() - 1]->tilePos; } this->Attacking = true; } diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp index 7807ea458..857367141 100644 --- a/src/sound/sound.cpp +++ b/src/sound/sound.cpp @@ -106,7 +106,7 @@ static CSample *ChooseSample(CSound *sound, bool selection, Origin &source) CSample *result = NULL; if (!sound || !SoundEnabled()) { - return NULL; + return NULL; } if (sound->Number == TWO_GROUPS) { diff --git a/src/sound/sound_server.cpp b/src/sound/sound_server.cpp index 0cc18d615..b00d1ae06 100644 --- a/src/sound/sound_server.cpp +++ b/src/sound/sound_server.cpp @@ -141,17 +141,16 @@ static void MixMusicToStereo32(int *buffer, int size) if (MusicPlaying) { Assert(MusicChannel.Sample); - short* buf = new short[size]; + short *buf = new short[size]; int len = size * sizeof(short); - char* tmp = new char[len]; + char *tmp = new char[len]; - int div = 176400 / (MusicChannel.Sample->Frequency * (MusicChannel.Sample->SampleSize / 8) - * MusicChannel.Sample->Channels); + int div = 176400 / (MusicChannel.Sample->Frequency * (MusicChannel.Sample->SampleSize / 8) * MusicChannel.Sample->Channels); size = MusicChannel.Sample->Read(tmp, len / div); - int n = ConvertToStereo32((char *)(tmp), (char *)buf, MusicChannel.Sample->Frequency, - MusicChannel.Sample->SampleSize / 8, MusicChannel.Sample->Channels, size); + int n = ConvertToStereo32(tmp, (char *)buf, MusicChannel.Sample->Frequency, + MusicChannel.Sample->SampleSize / 8, MusicChannel.Sample->Channels, size); for (int i = 0; i < n / (int)sizeof(*buf); ++i) { // Add to our samples @@ -244,8 +243,8 @@ static int MixChannelsToStereo32(int *buffer, int size) for (int channel = 0; channel < MaxChannels; ++channel) { if (Channels[channel].Playing && Channels[channel].Sample) { int i = MixSampleToStereo32(Channels[channel].Sample, - Channels[channel].Point, Channels[channel].Volume, - Channels[channel].Stereo, buffer, size); + Channels[channel].Point, Channels[channel].Volume, + Channels[channel].Stereo, buffer, size); Channels[channel].Point += i; Assert(Channels[channel].Point <= Channels[channel].Sample->Len); @@ -346,7 +345,7 @@ bool UnitSoundIsPlaying(Origin *origin) for (int i = 0; i < MaxChannels; ++i) { if (origin && Channels[i].Unit && origin->Id && Channels[i].Unit->Id && origin->Id == Channels[i].Unit->Id && Channels[i].Playing) { - return true; + return true; } } return false; diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp index 5adac60dd..2068a954c 100644 --- a/src/unit/unit.cpp +++ b/src/unit/unit.cpp @@ -3024,13 +3024,14 @@ void HitUnit(CUnit *attacker, CUnit &target, int damage) // Calculate the best target we could attack if (!best || (goal && ((goal->IsAgressive() && best->IsAgressive() == false) - || (ThreatCalculate(target, *goal) < ThreatCalculate(target, *best))))) { - best = goal; + || (ThreatCalculate(target, *goal) < ThreatCalculate(target, *best))))) { + best = goal; } - if (CanTarget(target.Type, attacker->Type) && (!best || (attacker && goal != attacker - && ((attacker->IsAgressive() && best->IsAgressive() == false) - || (ThreatCalculate(target, *attacker) < ThreatCalculate(target, *best)))))) { - best = attacker; + if (CanTarget(target.Type, attacker->Type) + && (!best || (attacker && goal != attacker + && ((attacker->IsAgressive() && best->IsAgressive() == false) + || (ThreatCalculate(target, *attacker) < ThreatCalculate(target, *best)))))) { + best = attacker; } if (best) { if (target.MapDistanceTo(*best) <= target.Stats->Variables[ATTACKRANGE_INDEX].Max) {