mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
- removed lib headers from PCH
- fixed #1062 - correct terrain penalty check
This commit is contained in:
parent
ea4841045f
commit
a138db7c9e
@ -1,7 +1,10 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "Fuzzy.h"
|
#include "Fuzzy.h"
|
||||||
#include <limits>
|
#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
|
* Fuzzy.cpp, part of VCMI engine
|
||||||
|
@ -5,27 +5,10 @@
|
|||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <boost/range/algorithm.hpp>
|
#include <boost/range/algorithm.hpp>
|
||||||
#include <boost/type_traits.hpp>
|
#include <boost/type_traits.hpp>
|
||||||
#include "../../lib/AI_Base.h"
|
|
||||||
#include "../../CCallback.h"
|
|
||||||
#include "../../lib/CObjectHandler.h"
|
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include "../../lib/CThreadHelper.h"
|
|
||||||
#include <boost/thread/tss.hpp>
|
#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 "Fuzzy.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -34,7 +17,6 @@
|
|||||||
using boost::format;
|
using boost::format;
|
||||||
using boost::str;
|
using boost::str;
|
||||||
|
|
||||||
|
|
||||||
extern CLogger &aiLogger;
|
extern CLogger &aiLogger;
|
||||||
|
|
||||||
#define INDENT AILogger::Tab ___dummy_ind
|
#define INDENT AILogger::Tab ___dummy_ind
|
||||||
|
@ -1233,6 +1233,9 @@ void VCAI::recruitCreatures(const CGDwelling * d)
|
|||||||
|
|
||||||
bool VCAI::tryBuildStructure(const CGTownInstance * t, int building, unsigned int maxDays)
|
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
|
if (t->hasBuilt(building)) //Already built? Shouldn't happen in general
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -1,4 +1,26 @@
|
|||||||
#pragma once
|
#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 int3& crint3;
|
||||||
typedef const std::string& crstring;
|
typedef const std::string& crstring;
|
||||||
|
|
||||||
|
@ -527,7 +527,6 @@ void CHighlightableButtonsGroup::addButton(const std::map<int,std::string> &tool
|
|||||||
CHighlightableButton *bt = new CHighlightableButton(OnSelect, 0, tooltip, HelpBox, false, defName, 0, x, y, key);
|
CHighlightableButton *bt = new CHighlightableButton(OnSelect, 0, tooltip, HelpBox, false, defName, 0, x, y, key);
|
||||||
if(musicLike)
|
if(musicLike)
|
||||||
{
|
{
|
||||||
if (buttons.size() > 3)
|
|
||||||
bt->setOffset(buttons.size()-3);
|
bt->setOffset(buttons.size()-3);
|
||||||
}
|
}
|
||||||
bt->ID = uid;
|
bt->ID = uid;
|
||||||
|
@ -526,8 +526,6 @@ static int lowestSpeed(const CGHeroInstance * chi)
|
|||||||
|
|
||||||
ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &from) const
|
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
|
//base move cost
|
||||||
unsigned ret = 100;
|
unsigned ret = 100;
|
||||||
|
|
||||||
@ -553,30 +551,30 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &fro
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(vstd::contains(VLC->townh->factions, type->heroType / 2));
|
//FIXME: in H3 presence of Nomad in army will remove terrain penalty for sand. Bonus not implemented in VCMI
|
||||||
if (VLC->townh->factions[type->heroType / 2].nativeTerrain != from.tertype) //non-native terrain
|
|
||||||
ret = VLC->heroh->terrCosts[from.tertype];
|
|
||||||
|
|
||||||
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;
|
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
|
int3 CGHeroInstance::convertPosition(int3 src, bool toh3m) //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
|
||||||
{
|
{
|
||||||
if (toh3m)
|
if (toh3m)
|
||||||
@ -646,14 +644,17 @@ void CGHeroInstance::setSecSkillLevel(SecondarySkill which, int val, bool abs)
|
|||||||
|
|
||||||
int CGHeroInstance::maxMovePoints(bool onLand) const
|
int CGHeroInstance::maxMovePoints(bool onLand) const
|
||||||
{
|
{
|
||||||
int base = -1;
|
int base;
|
||||||
|
|
||||||
if(onLand)
|
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
|
// used function is f(x) = 66.6x + 1300, rounded to second digit, where x is lowest speed in army
|
||||||
int index = lowestSpeed(this) - 3;
|
static const int baseSpeed = 1300; // base speed from creature with 0 speed
|
||||||
vstd::amin(index, ARRAY_COUNT(moveForSpeed)-1);
|
|
||||||
vstd::amax(index, 0);
|
int armySpeed = lowestSpeed(this) * 20 / 3;
|
||||||
base = moveForSpeed[index];
|
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -674,32 +675,6 @@ int CGHeroInstance::maxMovePoints(bool onLand) const
|
|||||||
return int(base + base*modifier) + bonus;
|
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()
|
CGHeroInstance::CGHeroInstance()
|
||||||
: IBoatGenerator(this)
|
: IBoatGenerator(this)
|
||||||
{
|
{
|
||||||
|
@ -180,14 +180,12 @@ bool CGameInfoCallback::isAllowed( int type, int id )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CPrivilagedInfoCallback::pickAllowedArtsSet(std::vector<const CArtifact*> &out)
|
void CPrivilagedInfoCallback::pickAllowedArtsSet(std::vector<const CArtifact*> &out)
|
||||||
{
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 3 ; j++)
|
for (int j = 0; j < 3 ; j++)
|
||||||
{
|
out.push_back(VLC->arth->artifacts[getRandomArt(CArtifact::ART_TREASURE)]);
|
||||||
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_MINOR)]);
|
||||||
}
|
|
||||||
out.push_back(VLC->arth->artifacts[getRandomArt(CArtifact::ART_MAJOR)]);
|
out.push_back(VLC->arth->artifacts[getRandomArt(CArtifact::ART_MAJOR)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user