[AStyle]
This commit is contained in:
parent
785d51953c
commit
c5005efb98
5 changed files with 32 additions and 32 deletions
src
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue