1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-24 03:47:18 +02:00

- removed lib headers from PCH

- fixed #1062
- correct terrain penalty check
This commit is contained in:
Ivan Savenko 2012-09-06 10:39:48 +00:00
parent ea4841045f
commit a138db7c9e
7 changed files with 65 additions and 83 deletions

View File

@ -1,7 +1,10 @@
#include "StdInc.h"
#include "Fuzzy.h"
#include <limits>
//#include "../../lib/CObjectHandler.h"
#include "../../lib/CObjectHandler.h"
#include "../../lib/CCreatureHandler.h"
#include "../../lib/VCMI_Lib.h"
/*
* Fuzzy.cpp, part of VCMI engine

View File

@ -5,27 +5,10 @@
#include <boost/format.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/type_traits.hpp>
#include "../../lib/AI_Base.h"
#include "../../CCallback.h"
#include "../../lib/CObjectHandler.h"
#include <boost/foreach.hpp>
#include "../../lib/CThreadHelper.h"
#include <boost/thread/tss.hpp>
#include "../../lib/VCMI_Lib.h"
#include "../../lib/CBuildingHandler.h"
#include "../../lib/CCreatureHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CSpellHandler.h"
#include "../../lib/CObjectHandler.h"
#include "../../lib/Connection.h"
#include "../../lib/CGameState.h"
#include "../../lib/map.h"
#include "../../lib/NetPacks.h"
#include "../../lib/CondSh.h"
#include "../../lib/CStopWatch.h"
#include "Fuzzy.h"
#include <fstream>
@ -34,7 +17,6 @@
using boost::format;
using boost::str;
extern CLogger &aiLogger;
#define INDENT AILogger::Tab ___dummy_ind

View File

@ -1233,6 +1233,9 @@ void VCAI::recruitCreatures(const CGDwelling * d)
bool VCAI::tryBuildStructure(const CGTownInstance * t, int building, unsigned int maxDays)
{
if (!vstd::contains(t->town->buildings, building))
return false; // no such building in town
if (t->hasBuilt(building)) //Already built? Shouldn't happen in general
return true;

View File

@ -1,4 +1,26 @@
#pragma once
#include "../../lib/AI_Base.h"
#include "../../CCallback.h"
#include "../../lib/CObjectHandler.h"
#include "../../lib/CThreadHelper.h"
#include "../../lib/VCMI_Lib.h"
#include "../../lib/CBuildingHandler.h"
#include "../../lib/CCreatureHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CSpellHandler.h"
#include "../../lib/CObjectHandler.h"
#include "../../lib/Connection.h"
#include "../../lib/CGameState.h"
#include "../../lib/map.h"
#include "../../lib/NetPacks.h"
#include "../../lib/CondSh.h"
#include "../../lib/CStopWatch.h"
struct QuestInfo;
typedef const int3& crint3;
typedef const std::string& crstring;

View File

@ -527,8 +527,7 @@ void CHighlightableButtonsGroup::addButton(const std::map<int,std::string> &tool
CHighlightableButton *bt = new CHighlightableButton(OnSelect, 0, tooltip, HelpBox, false, defName, 0, x, y, key);
if(musicLike)
{
if (buttons.size() > 3)
bt->setOffset(buttons.size()-3);
bt->setOffset(buttons.size()-3);
}
bt->ID = uid;
bt->callback += boost::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID);

View File

@ -526,8 +526,6 @@ static int lowestSpeed(const CGHeroInstance * chi)
ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &from) const
{
//TODO: check if all creatures are on its native terrain and change cost appropriately
//base move cost
unsigned ret = 100;
@ -553,30 +551,30 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &fro
}
else
{
assert(vstd::contains(VLC->townh->factions, type->heroType / 2));
if (VLC->townh->factions[type->heroType / 2].nativeTerrain != from.tertype) //non-native terrain
ret = VLC->heroh->terrCosts[from.tertype];
//FIXME: in H3 presence of Nomad in army will remove terrain penalty for sand. Bonus not implemented in VCMI
ret = std::max(ret - 25*unsigned(getSecSkillLevel(CGHeroInstance::PATHFINDING)), 100u); //reduce 25% of terrain penalty for each pathfinding level
}
// NOTE: in H3 neutral stacks will ignore terrain penalty only if placed as topmost stack(s) in hero army.
// This is clearly bug in H3 however intended behaviour is not clear.
// Current VCMI behaviour will ignore neutrals in calculations so army in VCMI
// will always have best penalty without any influence from player-defined stacks order
bool nativeArmy = true;
BOOST_FOREACH(auto stack, stacks)
{
int nativeTerrain = VLC->townh->factions[stack.second->type->faction].nativeTerrain;
if (nativeTerrain != -1 && nativeTerrain != from.tertype)
{
nativeArmy = false;
break;
}
}
if (!nativeArmy)
ret = VLC->heroh->terrCosts[from.tertype];
}
return ret;
}
#if 0
// Unused and buggy method.
// - for loop is wrong. will not find all creatures. must use iterator instead.
// - -> is the slot number. use second->first for creature index
// Is lowestSpeed() the correct equivalent ?
ui32 CGHeroInstance::getLowestCreatureSpeed() const
{
ui32 sl = 100;
for(size_t h=0; h < stacksCount(); ++h)
{
if(VLC->creh->creatures[Slots().find(h)->first]->speed<sl)
sl = VLC->creh->creatures[Slots().find(h)->first]->speed;
}
return sl;
}
#endif
int3 CGHeroInstance::convertPosition(int3 src, bool toh3m) //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
{
if (toh3m)
@ -646,14 +644,17 @@ void CGHeroInstance::setSecSkillLevel(SecondarySkill which, int val, bool abs)
int CGHeroInstance::maxMovePoints(bool onLand) const
{
int base = -1;
int base;
if(onLand)
{
static const int moveForSpeed[] = { 1500, 1560, 1630, 1700, 1760, 1830, 1900, 1960, 2000 }; //first element for 3 and lower; last for 11 and more
int index = lowestSpeed(this) - 3;
vstd::amin(index, ARRAY_COUNT(moveForSpeed)-1);
vstd::amax(index, 0);
base = moveForSpeed[index];
// used function is f(x) = 66.6x + 1300, rounded to second digit, where x is lowest speed in army
static const int baseSpeed = 1300; // base speed from creature with 0 speed
int armySpeed = lowestSpeed(this) * 20 / 3;
base = armySpeed * 10 + baseSpeed; // separate *10 is intentional to receive same rounding as in h3
vstd::abetween(base, 1500, 2000); // base speed is limited by these values
}
else
{
@ -674,32 +675,6 @@ int CGHeroInstance::maxMovePoints(bool onLand) const
return int(base + base*modifier) + bonus;
}
// int CGHeroInstance::getSpellSecLevel(int spell) const
// {
// int bestslvl = 0;
// if(VLC->spellh->spells[spell].air)
// if(getSecSkillLevel(15) >= bestslvl)
// {
// bestslvl = getSecSkillLevel(15);
// }
// if(VLC->spellh->spells[spell].fire)
// if(getSecSkillLevel(14) >= bestslvl)
// {
// bestslvl = getSecSkillLevel(14);
// }
// if(VLC->spellh->spells[spell].water)
// if(getSecSkillLevel(16) >= bestslvl)
// {
// bestslvl = getSecSkillLevel(16);
// }
// if(VLC->spellh->spells[spell].earth)
// if(getSecSkillLevel(17) >= bestslvl)
// {
// bestslvl = getSecSkillLevel(17);
// }
// return bestslvl;
// }
CGHeroInstance::CGHeroInstance()
: IBoatGenerator(this)
{

View File

@ -181,13 +181,11 @@ bool CGameInfoCallback::isAllowed( int type, int id )
void CPrivilagedInfoCallback::pickAllowedArtsSet(std::vector<const CArtifact*> &out)
{
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 3 ; j++)
{
out.push_back(VLC->arth->artifacts[getRandomArt(CArtifact::ART_TREASURE << i)]);
}
}
for (int j = 0; j < 3 ; j++)
out.push_back(VLC->arth->artifacts[getRandomArt(CArtifact::ART_TREASURE)]);
for (int j = 0; j < 3 ; j++)
out.push_back(VLC->arth->artifacts[getRandomArt(CArtifact::ART_MINOR)]);
out.push_back(VLC->arth->artifacts[getRandomArt(CArtifact::ART_MAJOR)]);
}