From 68059d74307c30b81c01a1bab08b5ab5632b5f3e Mon Sep 17 00:00:00 2001 From: andor9 <9andor@gmail.com> Date: Mon, 8 Feb 2016 12:57:55 -0500 Subject: [PATCH] Fix bug: crash using Structures and BGE Virulence. --- sim.cpp | 74 +++++++++++++++++++++++++++++--------------------------- tyrant.h | 2 +- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/sim.cpp b/sim.cpp index 42d1850a..2384e91c 100644 --- a/sim.cpp +++ b/sim.cpp @@ -275,9 +275,9 @@ void prepend_on_death(Field* fd) CardStatus * left_virulence_victim = nullptr; for (auto status: fd->killed_units) { - // avenge if (status->m_card->m_type == CardType::assault) { + // Avenge for (auto && adj_status: fd->adjacent_assaults(status)) { unsigned avenge_value = adj_status->skill(avenge); @@ -290,51 +290,53 @@ void prepend_on_death(Field* fd) adj_status->m_hp += avenge_value; } } - } - if (fd->bg_effects[status->m_player].count(revenge)) - { - SkillSpec ss_heal{heal, fd->bg_effects[status->m_player].at(revenge), allfactions, 0, 0, no_skill, no_skill, true,}; - SkillSpec ss_rally{rally, fd->bg_effects[status->m_player].at(revenge), allfactions, 0, 0, no_skill, no_skill, true,}; - CardStatus * commander = &fd->players[status->m_player]->commander; - _DEBUG_MSG(2, "Revenge: Preparing skill %s and %s\n", skill_description(fd->cards, ss_heal).c_str(), skill_description(fd->cards, ss_rally).c_str()); - od_skills.emplace_back(commander, ss_heal); - od_skills.emplace_back(commander, ss_rally); - } - if (fd->bg_effects[opponent(status->m_player)].count(virulence)) - { - if (status->m_index != last_index + 1) + // Virulence + if (fd->bg_effects[opponent(status->m_player)].count(virulence)) { - stacked_poison_value = 0; - left_virulence_victim = nullptr; - if (status->m_index > 0) + if (status->m_index != last_index + 1) { - auto left_status = &assaults[status->m_index - 1]; - if (left_status->m_hp > 0) + stacked_poison_value = 0; + left_virulence_victim = nullptr; + if (status->m_index > 0) { - left_virulence_victim = left_status; + auto left_status = &assaults[status->m_index - 1]; + if (left_status->m_hp > 0) + { + left_virulence_victim = left_status; + } } } - } - if (status->m_poisoned > 0) - { - if (left_virulence_victim != nullptr) + if (status->m_poisoned > 0) { - _DEBUG_MSG(1, "Virulence: %s spreads left poison +%u to %s\n", status_description(status).c_str(), status->m_poisoned, status_description(left_virulence_victim).c_str()); - left_virulence_victim->m_poisoned += status->m_poisoned; + if (left_virulence_victim != nullptr) + { + _DEBUG_MSG(1, "Virulence: %s spreads left poison +%u to %s\n", status_description(status).c_str(), status->m_poisoned, status_description(left_virulence_victim).c_str()); + left_virulence_victim->m_poisoned += status->m_poisoned; + } + stacked_poison_value += status->m_poisoned; + _DEBUG_MSG(1, "Virulence: %s spreads right poison +%u = %u\n", status_description(status).c_str(), status->m_poisoned, stacked_poison_value); } - stacked_poison_value += status->m_poisoned; - _DEBUG_MSG(1, "Virulence: %s spreads right poison +%u = %u\n", status_description(status).c_str(), status->m_poisoned, stacked_poison_value); - } - if (status->m_index + 1 < assaults.size()) - { - auto right_status = &assaults[status->m_index + 1]; - if (right_status->m_hp > 0) + if (status->m_index + 1 < assaults.size()) { - _DEBUG_MSG(1, "Virulence: spreads stacked poison +%u to %s\n", stacked_poison_value, status_description(right_status).c_str()); - right_status->m_poisoned += stacked_poison_value; + auto right_status = &assaults[status->m_index + 1]; + if (right_status->m_hp > 0) + { + _DEBUG_MSG(1, "Virulence: spreads stacked poison +%u to %s\n", stacked_poison_value, status_description(right_status).c_str()); + right_status->m_poisoned += stacked_poison_value; + } } + last_index = status->m_index; } - last_index = status->m_index; + } + // Revenge + if (fd->bg_effects[status->m_player].count(revenge)) + { + SkillSpec ss_heal{heal, fd->bg_effects[status->m_player].at(revenge), allfactions, 0, 0, no_skill, no_skill, true,}; + SkillSpec ss_rally{rally, fd->bg_effects[status->m_player].at(revenge), allfactions, 0, 0, no_skill, no_skill, true,}; + CardStatus * commander = &fd->players[status->m_player]->commander; + _DEBUG_MSG(2, "Revenge: Preparing skill %s and %s\n", skill_description(fd->cards, ss_heal).c_str(), skill_description(fd->cards, ss_rally).c_str()); + od_skills.emplace_back(commander, ss_heal); + od_skills.emplace_back(commander, ss_rally); } } fd->skill_queue.insert(fd->skill_queue.begin(), od_skills.begin(), od_skills.end()); diff --git a/tyrant.h b/tyrant.h index 6c11d196..5b076dab 100644 --- a/tyrant.h +++ b/tyrant.h @@ -1,7 +1,7 @@ #ifndef TYRANT_H_INCLUDED #define TYRANT_H_INCLUDED -#define TYRANT_OPTIMIZER_VERSION "2.17.0" +#define TYRANT_OPTIMIZER_VERSION "2.17.1" #include #include