Skip to content

Instantly share code, notes, and snippets.

Created November 9, 2012 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4046378 to your computer and use it in GitHub Desktop.
Save anonymous/4046378 to your computer and use it in GitHub Desktop.
VCMI Den of Thieves Army fix
--- lib/CGameState.cpp (revision 3001)
+++ lib/CGameState.cpp (working copy)
@@ -2225,7 +2225,7 @@
struct statsHLP
{
typedef std::pair< TPlayerColor, si64 > TStat;
- //converts [<player's color, value>] to vec[place] -> platers
+ //converts [<player's color, value>] to vec[place] -> players
static std::vector< std::vector< TPlayerColor > > getRank( std::vector<TStat> stats )
{
std::sort(stats.begin(), stats.end(), statsHLP());
@@ -2352,7 +2352,23 @@
}
if(level >= 6) //army strength
{
- //TODO
+ std::vector< std::pair< TPlayerColor, si64 > > stats;
+ for(auto g = players.cbegin(); g != players.cend(); ++g)
+ {
+ if(g->second.color == 255)
+ continue;
+ ui64 str = 0;
+ BOOST_FOREACH(auto h, g->second.heroes)
+ {
+ if(!h->inTownGarrison) //original h3 behavior
+ str += h->getArmyStrength();
+ }
+ std::pair<ui8, si64> stat;
+ stat.first = g->second.color;
+ stat.second = str;
+ stats.push_back(stat);
+ }
+ tgi.army = statsHLP::getRank(stats);
}
if(level >= 7) //income
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment