Skip to content

Commit

Permalink
Fix bug: crash using Structures and BGE Virulence.
Browse files Browse the repository at this point in the history
  • Loading branch information
andor9 committed Feb 8, 2016
1 parent c0b21d3 commit 68059d7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 37 deletions.
74 changes: 38 additions & 36 deletions sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion tyrant.h
Original file line number Diff line number Diff line change
@@ -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 <string>
#include <sstream>
Expand Down

0 comments on commit 68059d7

Please sign in to comment.