Skip to content

Commit ef2da9c

Browse files
committed
Review on-death workflow to fix crash.
1 parent 68059d7 commit ef2da9c

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

sim.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ void resolve_skill(Field* fd)
354354
fd->skill_queue.pop_front();
355355
if (status->m_jammed)
356356
{
357+
_DEBUG_MSG(2, "%s failed to %s because it is Jammed.", status_description(status).c_str(), skill_description(fd->cards, ss).c_str());
357358
continue;
358359
}
359360
signed evolved_offset = status->m_evolved_skill_offset[ss.id];
@@ -734,7 +735,7 @@ void turn_end_phase(Field* fd)
734735
fd->inc_counter(QuestType::skill_damage, poison, 0, poison_dmg);
735736
}
736737
_DEBUG_MSG(1, "%s takes poison damage %u\n", status_description(&status).c_str(), poison_dmg);
737-
remove_hp(fd, &status, poison_dmg);
738+
remove_hp(fd, &status, poison_dmg); // simultaneous
738739
}
739740
}
740741
// end of the opponent's next turn for enemy units
@@ -750,7 +751,7 @@ void turn_end_phase(Field* fd)
750751
// Active player's structure cards:
751752
// nothing so far
752753

753-
prepend_on_death(fd);
754+
prepend_on_death(fd); // poison
754755
resolve_skill(fd);
755756
remove_dead(fd->tap->assaults);
756757
remove_dead(fd->tap->structures);
@@ -839,6 +840,8 @@ struct PerformAttack
839840
}
840841
_DEBUG_MSG(1, "%s takes %u counter damage from %s\n", status_description(att_status).c_str(), counter_dmg, status_description(def_status).c_str());
841842
remove_hp(fd, att_status, counter_dmg);
843+
prepend_on_death(fd);
844+
resolve_skill(fd);
842845
if (def_cardtype == CardType::assault && def_status->m_hp > 0 && fd->bg_effects[def_status->m_player].count(counterflux))
843846
{
844847
unsigned flux_denominator = fd->bg_effects[def_status->m_player].at(counterflux) ? fd->bg_effects[def_status->m_player].at(counterflux) : 4;
@@ -881,8 +884,6 @@ struct PerformAttack
881884
_DEBUG_MSG(1, "Heroism: %s gain %u attack\n", status_description(att_status).c_str(), valor_value);
882885
att_status->m_attack += valor_value;
883886
}
884-
prepend_on_death(fd);
885-
resolve_skill(fd);
886887
return att_dmg;
887888
}
888889

@@ -979,6 +980,8 @@ struct PerformAttack
979980
void attack_damage()
980981
{
981982
remove_hp(fd, def_status, att_dmg);
983+
prepend_on_death(fd);
984+
resolve_skill(fd);
982985
}
983986

984987
template<enum CardType::CardType>
@@ -1064,6 +1067,8 @@ bool attack_phase(Field* fd)
10641067
_DEBUG_MSG(1, "%s swipes %s for %u damage\n", status_description(att_status).c_str(), status_description(adj_status).c_str(), swipe_dmg);
10651068
remove_hp(fd, adj_status, swipe_dmg);
10661069
}
1070+
prepend_on_death(fd);
1071+
resolve_skill(fd);
10671072
}
10681073
}
10691074
return false;
@@ -1083,6 +1088,8 @@ bool attack_phase(Field* fd)
10831088
_DEBUG_MSG(1, "%s swipes %s for %u damage\n", status_description(att_status).c_str(), status_description(adj_status).c_str(), swipe_dmg);
10841089
remove_hp(fd, adj_status, swipe_dmg);
10851090
}
1091+
prepend_on_death(fd);
1092+
resolve_skill(fd);
10861093
}
10871094
}
10881095
else
@@ -1621,7 +1628,6 @@ void perform_targetted_hostile_fast(Field* fd, CardStatus* src, const SkillSpec&
16211628
_DEBUG_MSG(1, "TurningTides %u!\n", turningtides_value);
16221629
perform_targetted_allied_fast<rally>(fd, &fd->players[src->m_player]->commander, ss_rally);
16231630
}
1624-
prepend_on_death(fd);
16251631
for (CardStatus * pb_status: paybackers)
16261632
{
16271633
++ pb_status->m_paybacked;
@@ -1636,7 +1642,6 @@ void perform_targetted_hostile_fast(Field* fd, CardStatus* src, const SkillSpec&
16361642
perform_targetted_allied_fast<rally>(fd, &fd->players[pb_status->m_player]->commander, ss_rally);
16371643
}
16381644
}
1639-
prepend_on_death(fd);
16401645
return;
16411646
}
16421647
for (CardStatus * dst: fd->selection_array)
@@ -1651,14 +1656,14 @@ void perform_targetted_hostile_fast(Field* fd, CardStatus* src, const SkillSpec&
16511656
}
16521657
}
16531658
}
1654-
prepend_on_death(fd);
1659+
prepend_on_death(fd); // skills
16551660
for (CardStatus * pb_status: paybackers)
16561661
{
16571662
++ pb_status->m_paybacked;
16581663
_DEBUG_MSG(1, "%s Payback %s on %s\n", status_description(pb_status).c_str(), skill_short_description(s).c_str(), status_description(src).c_str());
16591664
perform_skill<skill_id>(fd, pb_status, src, s);
16601665
}
1661-
prepend_on_death(fd);
1666+
prepend_on_death(fd); // paybacked skills
16621667
}
16631668

16641669
//------------------------------------------------------------------------------

tyrant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef TYRANT_H_INCLUDED
22
#define TYRANT_H_INCLUDED
33

4-
#define TYRANT_OPTIMIZER_VERSION "2.17.1"
4+
#define TYRANT_OPTIMIZER_VERSION "2.17.2"
55

66
#include <string>
77
#include <sstream>

0 commit comments

Comments
 (0)