mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Merge pull request #3469 from Alexander-Wilms/define-each-identifier-in-a-dedicated-statement
Define each identifier in a dedicated statement
This commit is contained in:
commit
fb027d1a57
@ -33,7 +33,8 @@ void DamageCache::buildDamageCache(std::shared_ptr<HypotheticBattle> hb, int sid
|
||||
return u->isValidTarget();
|
||||
});
|
||||
|
||||
std::vector<const battle::Unit *> ourUnits, enemyUnits;
|
||||
std::vector<const battle::Unit *> ourUnits;
|
||||
std::vector<const battle::Unit *> enemyUnits;
|
||||
|
||||
for(auto stack : stacks)
|
||||
{
|
||||
@ -295,8 +296,10 @@ AttackPossibility AttackPossibility::evaluate(
|
||||
|
||||
for(int i = 0; i < totalAttacks; i++)
|
||||
{
|
||||
int64_t damageDealt, damageReceived;
|
||||
float defenderDamageReduce, attackerDamageReduce;
|
||||
int64_t damageDealt;
|
||||
int64_t damageReceived;
|
||||
float defenderDamageReduce;
|
||||
float attackerDamageReduce;
|
||||
|
||||
DamageEstimation retaliation;
|
||||
auto attackDmg = state->battleEstimateDamage(ap.attack, &retaliation);
|
||||
|
@ -90,7 +90,8 @@ void CBattleAI::yourTacticPhase(const BattleID & battleID, int distance)
|
||||
static float getStrengthRatio(std::shared_ptr<CBattleInfoCallback> cb, int side)
|
||||
{
|
||||
auto stacks = cb->battleGetAllStacks();
|
||||
auto our = 0, enemy = 0;
|
||||
auto our = 0;
|
||||
auto enemy = 0;
|
||||
|
||||
for(auto stack : stacks)
|
||||
{
|
||||
|
@ -1413,7 +1413,8 @@ void AIGateway::tryRealize(Goals::Trade & g) //trade
|
||||
if(res.getNum() == g.resID) //sell any other resource
|
||||
continue;
|
||||
|
||||
int toGive, toGet;
|
||||
int toGive;
|
||||
int toGet;
|
||||
m->getOffer(res, g.resID, toGive, toGet, EMarketMode::RESOURCE_RESOURCE);
|
||||
toGive = static_cast<int>(toGive * (it->resVal / toGive)); //round down
|
||||
//TODO trade only as much as needed
|
||||
|
@ -60,7 +60,9 @@ struct creInfo;
|
||||
class AIGateway;
|
||||
class Nullkiller;
|
||||
|
||||
const int GOLD_MINE_PRODUCTION = 1000, WOOD_ORE_MINE_PRODUCTION = 2, RESOURCE_MINE_PRODUCTION = 1;
|
||||
const int GOLD_MINE_PRODUCTION = 1000;
|
||||
const int WOOD_ORE_MINE_PRODUCTION = 2;
|
||||
const int RESOURCE_MINE_PRODUCTION = 1;
|
||||
const int ACTUAL_RESOURCE_COUNT = 7;
|
||||
const int ALLOWED_ROAMING_HEROES = 8;
|
||||
|
||||
|
@ -39,7 +39,9 @@ void engineBase::addRule(const std::string & txt)
|
||||
|
||||
struct armyStructure
|
||||
{
|
||||
float walkers, shooters, flyers;
|
||||
float walkers;
|
||||
float shooters;
|
||||
float flyers;
|
||||
ui32 maxSpeed;
|
||||
};
|
||||
|
||||
|
@ -41,8 +41,14 @@ public:
|
||||
TacticalAdvantageEngine();
|
||||
float getTacticalAdvantage(const CArmedInstance * we, const CArmedInstance * enemy); //returns factor how many times enemy is stronger than us
|
||||
private:
|
||||
fl::InputVariable * ourWalkers, *ourShooters, *ourFlyers, *enemyWalkers, *enemyShooters, *enemyFlyers;
|
||||
fl::InputVariable * ourSpeed, *enemySpeed;
|
||||
fl::InputVariable * ourWalkers;
|
||||
fl::InputVariable * ourShooters;
|
||||
fl::InputVariable * ourFlyers;
|
||||
fl::InputVariable * enemyWalkers;
|
||||
fl::InputVariable * enemyShooters;
|
||||
fl::InputVariable * enemyFlyers;
|
||||
fl::InputVariable * ourSpeed;
|
||||
fl::InputVariable * enemySpeed;
|
||||
fl::InputVariable * bankPresent;
|
||||
fl::InputVariable * castleWalls;
|
||||
fl::OutputVariable * threat;
|
||||
|
@ -68,7 +68,8 @@ class EnemyInfo
|
||||
{
|
||||
public:
|
||||
const CStack * s;
|
||||
int adi, adr;
|
||||
int adi;
|
||||
int adr;
|
||||
std::vector<BattleHex> attackFrom; //for melee fight
|
||||
EnemyInfo(const CStack * _s) : s(_s), adi(0), adr(0)
|
||||
{}
|
||||
@ -117,7 +118,9 @@ void CStupidAI::activeStack(const BattleID & battleID, const CStack * stack)
|
||||
//boost::this_thread::sleep_for(boost::chrono::seconds(2));
|
||||
print("activeStack called for " + stack->nodeName());
|
||||
ReachabilityInfo dists = cb->getBattle(battleID)->getReachability(stack);
|
||||
std::vector<EnemyInfo> enemiesShootable, enemiesReachable, enemiesUnreachable;
|
||||
std::vector<EnemyInfo> enemiesShootable;
|
||||
std::vector<EnemyInfo> enemiesReachable;
|
||||
std::vector<EnemyInfo> enemiesUnreachable;
|
||||
|
||||
if(stack->creatureId() == CreatureID::CATAPULT)
|
||||
{
|
||||
|
@ -37,7 +37,9 @@ void engineBase::addRule(const std::string & txt)
|
||||
|
||||
struct armyStructure
|
||||
{
|
||||
float walkers, shooters, flyers;
|
||||
float walkers;
|
||||
float shooters;
|
||||
float flyers;
|
||||
ui32 maxSpeed;
|
||||
};
|
||||
|
||||
|
@ -38,8 +38,14 @@ public:
|
||||
TacticalAdvantageEngine();
|
||||
float getTacticalAdvantage(const CArmedInstance * we, const CArmedInstance * enemy); //returns factor how many times enemy is stronger than us
|
||||
private:
|
||||
fl::InputVariable * ourWalkers, *ourShooters, *ourFlyers, *enemyWalkers, *enemyShooters, *enemyFlyers;
|
||||
fl::InputVariable * ourSpeed, *enemySpeed;
|
||||
fl::InputVariable * ourWalkers;
|
||||
fl::InputVariable * ourShooters;
|
||||
fl::InputVariable * ourFlyers;
|
||||
fl::InputVariable * enemyWalkers;
|
||||
fl::InputVariable * enemyShooters;
|
||||
fl::InputVariable * enemyFlyers;
|
||||
fl::InputVariable * ourSpeed;
|
||||
fl::InputVariable * enemySpeed;
|
||||
fl::InputVariable * bankPresent;
|
||||
fl::InputVariable * castleWalls;
|
||||
fl::OutputVariable * threat;
|
||||
|
@ -169,7 +169,8 @@ TSubgoal CollectRes::whatToDoToTrade()
|
||||
{
|
||||
if (i.getNum() == resID)
|
||||
continue;
|
||||
int toGive = -1, toReceive = -1;
|
||||
int toGive = -1;
|
||||
int toReceive = -1;
|
||||
m->getOffer(i, resID, toGive, toReceive, EMarketMode::RESOURCE_RESOURCE);
|
||||
assert(toGive > 0 && toReceive > 0);
|
||||
howManyCanWeBuy += toReceive * (ai->ah->freeResources()[i] / toGive);
|
||||
|
@ -312,7 +312,8 @@ void VCAI::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, Q
|
||||
|
||||
requestActionASAP([=]()
|
||||
{
|
||||
float goalpriority1 = 0, goalpriority2 = 0;
|
||||
float goalpriority1 = 0;
|
||||
float goalpriority2 = 0;
|
||||
|
||||
auto firstGoal = getGoal(firstHero);
|
||||
if(firstGoal->goalType == Goals::GATHER_ARMY)
|
||||
@ -1415,8 +1416,8 @@ void VCAI::wander(HeroPtr h)
|
||||
auto compareReinforcements = [&](const CGTownInstance * lhs, const CGTownInstance * rhs) -> bool
|
||||
{
|
||||
const CGHeroInstance * hptr = h.get();
|
||||
auto r1 = ah->howManyReinforcementsCanGet(hptr, lhs),
|
||||
r2 = ah->howManyReinforcementsCanGet(hptr, rhs);
|
||||
auto r1 = ah->howManyReinforcementsCanGet(hptr, lhs);
|
||||
auto r2 = ah->howManyReinforcementsCanGet(hptr, rhs);
|
||||
if (r1 != r2)
|
||||
return r1 < r2;
|
||||
else
|
||||
@ -2154,7 +2155,8 @@ void VCAI::tryRealize(Goals::Trade & g) //trade
|
||||
if(res.getNum() == g.resID) //sell any other resource
|
||||
continue;
|
||||
|
||||
int toGive, toGet;
|
||||
int toGive;
|
||||
int toGet;
|
||||
m->getOffer(res, g.resID, toGive, toGet, EMarketMode::RESOURCE_RESOURCE);
|
||||
toGive = static_cast<int>(toGive * (it->resVal / toGive)); //round down
|
||||
//TODO trade only as much as needed
|
||||
@ -2221,8 +2223,8 @@ void VCAI::tryRealize(Goals::BuyArmy & g)
|
||||
*boost::max_element(creaturesInDwellings, [](const creInfo & lhs, const creInfo & rhs)
|
||||
{
|
||||
//max value of creatures we can buy with our res
|
||||
int value1 = lhs.cre->getAIValue() * lhs.count,
|
||||
value2 = rhs.cre->getAIValue() * rhs.count;
|
||||
int value1 = lhs.cre->getAIValue() * lhs.count;
|
||||
int value2 = rhs.cre->getAIValue() * rhs.count;
|
||||
|
||||
return value1 < value2;
|
||||
});
|
||||
|
@ -182,7 +182,8 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
|
||||
// Init old logging system and new (temporary) logging system
|
||||
CStopWatch total, pomtime;
|
||||
CStopWatch total;
|
||||
CStopWatch pomtime;
|
||||
std::cout.flags(std::ios::unitbuf);
|
||||
#ifndef VCMI_IOS
|
||||
console = new CConsoleHandler();
|
||||
|
@ -533,7 +533,8 @@ void CServerHandler::sendMessage(const std::string & txt) const
|
||||
}
|
||||
else if(command == "!forcep")
|
||||
{
|
||||
std::string connectedId, playerColorId;
|
||||
std::string connectedId;
|
||||
std::string playerColorId;
|
||||
readed >> connectedId;
|
||||
readed >> playerColorId;
|
||||
if(connectedId.length() && playerColorId.length())
|
||||
|
@ -569,8 +569,10 @@ void CClient::battleStarted(const BattleInfo * info)
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<CPlayerInterface> att, def;
|
||||
auto & leftSide = info->sides[0], & rightSide = info->sides[1];
|
||||
std::shared_ptr<CPlayerInterface> att;
|
||||
std::shared_ptr<CPlayerInterface> def;
|
||||
auto & leftSide = info->sides[0];
|
||||
auto & rightSide = info->sides[1];
|
||||
|
||||
//If quick combat is not, do not prepare interfaces for battleint
|
||||
auto callBattleStart = [&](PlayerColor color, ui8 side)
|
||||
|
@ -379,7 +379,8 @@ void ClientCommandManager::handleBonusesCommand(std::istringstream & singleWordB
|
||||
void ClientCommandManager::handleTellCommand(std::istringstream& singleWordBuffer)
|
||||
{
|
||||
std::string what;
|
||||
int id1, id2;
|
||||
int id1;
|
||||
int id2;
|
||||
singleWordBuffer >> what >> id1 >> id2;
|
||||
|
||||
if(what == "hs")
|
||||
@ -399,7 +400,8 @@ void ClientCommandManager::handleMpCommand()
|
||||
|
||||
void ClientCommandManager::handleSetCommand(std::istringstream& singleWordBuffer)
|
||||
{
|
||||
std::string what, value;
|
||||
std::string what;
|
||||
std::string value;
|
||||
singleWordBuffer >> what;
|
||||
|
||||
Settings config = settings.write["session"][what];
|
||||
|
@ -134,7 +134,8 @@ CInfoBar::VisibleGameStatusInfo::VisibleGameStatusInfo()
|
||||
halls.at(hallLevel)++;
|
||||
}
|
||||
|
||||
std::vector<PlayerColor> allies, enemies;
|
||||
std::vector<PlayerColor> allies;
|
||||
std::vector<PlayerColor> enemies;
|
||||
|
||||
//generate list of allies and enemies
|
||||
for(int i = 0; i < PlayerColor::PLAYER_LIMIT_I; i++)
|
||||
|
@ -48,7 +48,10 @@ private:
|
||||
std::shared_ptr<CMapInfo> mapInfo;
|
||||
|
||||
//options allowed - need to store as impact each other
|
||||
std::set<int> playerCountAllowed, playerTeamsAllowed, compCountAllowed, compTeamsAllowed;
|
||||
std::set<int> playerCountAllowed;
|
||||
std::set<int> playerTeamsAllowed;
|
||||
std::set<int> compCountAllowed;
|
||||
std::set<int> compTeamsAllowed;
|
||||
};
|
||||
|
||||
class TeamAlignmentsWidget: public InterfaceObjectConfigurable
|
||||
@ -61,7 +64,8 @@ private:
|
||||
|
||||
std::shared_ptr<CFilledTexture> background;
|
||||
std::shared_ptr<CLabelGroup> labels;
|
||||
std::shared_ptr<CButton> buttonOk, buttonCancel;
|
||||
std::shared_ptr<CButton> buttonOk;
|
||||
std::shared_ptr<CButton> buttonCancel;
|
||||
std::vector<std::shared_ptr<CToggleGroup>> players;
|
||||
std::vector<std::shared_ptr<CIntObject>> placeholders;
|
||||
};
|
||||
|
@ -72,7 +72,10 @@ bool mapSorter::operator()(const std::shared_ptr<ElementInfo> aaa, const std::sh
|
||||
return (a->defeatIconIndex < b->defeatIconIndex);
|
||||
break;
|
||||
case _playerAm: //by player amount
|
||||
int playerAmntB, humenPlayersB, playerAmntA, humenPlayersA;
|
||||
int playerAmntB;
|
||||
int humenPlayersB;
|
||||
int playerAmntA;
|
||||
int humenPlayersA;
|
||||
playerAmntB = humenPlayersB = playerAmntA = humenPlayersA = 0;
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
|
@ -41,7 +41,8 @@ auto HighScoreCalculation::calculate()
|
||||
bool cheater = false;
|
||||
};
|
||||
|
||||
Result firstResult, summary;
|
||||
Result firstResult;
|
||||
Result summary;
|
||||
const std::array<double, 5> difficultyMultipliers{0.8, 1.0, 1.3, 1.6, 2.0};
|
||||
for(auto & param : parameters)
|
||||
{
|
||||
|
@ -645,7 +645,8 @@ CLoadingScreen::CLoadingScreen()
|
||||
const auto & conf = CMainMenuConfig::get().getConfig()["loading"];
|
||||
if(conf.isStruct())
|
||||
{
|
||||
const int posx = conf["x"].Integer(), posy = conf["y"].Integer();
|
||||
const int posx = conf["x"].Integer();
|
||||
const int posy = conf["y"].Integer();
|
||||
const int blockSize = conf["size"].Integer();
|
||||
const int blocksAmount = conf["amount"].Integer();
|
||||
|
||||
|
@ -246,7 +246,10 @@ int CSDL_Ext::blit8bppAlphaTo24bppT(const SDL_Surface * src, const Rect & srcRec
|
||||
if (src->format->BytesPerPixel==1 && (bpp==3 || bpp==4 || bpp==2)) //everything's ok
|
||||
{
|
||||
SDL_Rect fulldst;
|
||||
int srcx, srcy, w, h;
|
||||
int srcx;
|
||||
int srcy;
|
||||
int w;
|
||||
int h;
|
||||
|
||||
/* If the destination rectangle is nullptr, use the entire dest surface */
|
||||
if ( dstRect == nullptr )
|
||||
@ -258,7 +261,8 @@ int CSDL_Ext::blit8bppAlphaTo24bppT(const SDL_Surface * src, const Rect & srcRec
|
||||
/* clip the source rectangle to the source surface */
|
||||
if(srcRect)
|
||||
{
|
||||
int maxw, maxh;
|
||||
int maxw;
|
||||
int maxh;
|
||||
|
||||
srcx = srcRect->x;
|
||||
w = srcRect->w;
|
||||
@ -295,7 +299,8 @@ int CSDL_Ext::blit8bppAlphaTo24bppT(const SDL_Surface * src, const Rect & srcRec
|
||||
/* clip the destination rectangle against the clip rectangle */
|
||||
{
|
||||
SDL_Rect *clip = &dst->clip_rect;
|
||||
int dx, dy;
|
||||
int dx;
|
||||
int dy;
|
||||
|
||||
dx = clip->x - dstRect->x;
|
||||
if(dx > 0)
|
||||
@ -659,16 +664,16 @@ void CSDL_Ext::convertToGrayscale( SDL_Surface * surf, const Rect & rect )
|
||||
template<int bpp>
|
||||
void scaleSurfaceFastInternal(SDL_Surface *surf, SDL_Surface *ret)
|
||||
{
|
||||
const float factorX = float(surf->w) / float(ret->w),
|
||||
factorY = float(surf->h) / float(ret->h);
|
||||
const float factorX = static_cast<float>(surf->w) / static_cast<float>(ret->w);
|
||||
const float factorY = static_cast<float>(surf->h) / static_cast<float>(ret->h);
|
||||
|
||||
for(int y = 0; y < ret->h; y++)
|
||||
{
|
||||
for(int x = 0; x < ret->w; x++)
|
||||
{
|
||||
//coordinates we want to calculate
|
||||
int origX = static_cast<int>(floor(factorX * x)),
|
||||
origY = static_cast<int>(floor(factorY * y));
|
||||
auto origX = static_cast<int>(floor(factorX * x));
|
||||
auto origY = static_cast<int>(floor(factorY * y));
|
||||
|
||||
// Get pointers to source pixels
|
||||
uint8_t *srcPtr = (uint8_t*)surf->pixels + origY * surf->pitch + origX * bpp;
|
||||
|
@ -35,7 +35,8 @@ void CExchangeController::swapArmy()
|
||||
auto leftSlots = getStacks(left);
|
||||
auto rightSlots = getStacks(right);
|
||||
|
||||
auto i = leftSlots.begin(), j = rightSlots.begin();
|
||||
auto i = leftSlots.begin();
|
||||
auto j = rightSlots.begin();
|
||||
|
||||
for(; i != leftSlots.end() && j != rightSlots.end(); i++, j++)
|
||||
{
|
||||
|
@ -234,7 +234,8 @@ bool CGarrisonSlot::split()
|
||||
const CGarrisonSlot * selection = owner->getSelection();
|
||||
owner->setSplittingMode(false);
|
||||
|
||||
int minLeft=0, minRight=0;
|
||||
int minLeft=0;
|
||||
int minRight=0;
|
||||
|
||||
if(upg != selection->upg) // not splitting within same army
|
||||
{
|
||||
|
@ -1506,8 +1506,8 @@ CHallInterface::CHallInterface(const CGTownInstance * Town):
|
||||
}
|
||||
}
|
||||
}
|
||||
int posX = pos.w/2 - (int)boxList[row].size()*154/2 - ((int)boxList[row].size()-1)*20 + 194*(int)col,
|
||||
posY = 35 + 104*(int)row;
|
||||
int posX = pos.w/2 - (int)boxList[row].size()*154/2 - ((int)boxList[row].size()-1)*20 + 194*(int)col;
|
||||
int posY = 35 + 104*(int)row;
|
||||
|
||||
if(building)
|
||||
boxes[row].push_back(std::make_shared<CBuildingBox>(posX, posY, town, building));
|
||||
|
@ -763,7 +763,8 @@ void CStackWindow::init()
|
||||
|
||||
void CStackWindow::initBonusesList()
|
||||
{
|
||||
BonusList output, input;
|
||||
BonusList output;
|
||||
BonusList input;
|
||||
input = *(info->stackNode->getBonuses(CSelector(Bonus::Permanent), Selector::all));
|
||||
|
||||
while(!input.empty())
|
||||
|
@ -180,7 +180,8 @@ CSpellWindow::CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _m
|
||||
interactiveAreas.push_back(std::make_shared<InteractiveArea>( Rect( 487 + offR + pos.x, 72 + offT + pos.y, rightCorner->pos.h, rightCorner->pos.w ), std::bind(&CSpellWindow::fRcornerb, this), 451, this));
|
||||
|
||||
//areas for spells
|
||||
int xpos = 117 + offL + pos.x, ypos = 90 + offT + pos.y;
|
||||
int xpos = 117 + offL + pos.x;
|
||||
int ypos = 90 + offT + pos.y;
|
||||
|
||||
for(int v=0; v<spellsPerPage; ++v)
|
||||
{
|
||||
|
@ -58,8 +58,11 @@ private:
|
||||
static constexpr int CREATURE_HEIGHT = 132;
|
||||
};
|
||||
|
||||
std::shared_ptr<CButton> maxButton, minButton, creatureSwitcher;
|
||||
std::shared_ptr<CLabel> availableAmount, purchaseAmount;
|
||||
std::shared_ptr<CButton> maxButton;
|
||||
std::shared_ptr<CButton> minButton;
|
||||
std::shared_ptr<CButton> creatureSwitcher;
|
||||
std::shared_ptr<CLabel> availableAmount;
|
||||
std::shared_ptr<CLabel> purchaseAmount;
|
||||
std::shared_ptr<CCreaturePic> picture;
|
||||
std::shared_ptr<CreatureCostBox> cost;
|
||||
std::vector<CreatureID> upgradesID;
|
||||
|
@ -42,7 +42,9 @@ private:
|
||||
void purchaseUnits();
|
||||
|
||||
const CGTownInstance * town;
|
||||
std::shared_ptr<CButton> maxButton, buyButton, cancelButton;
|
||||
std::shared_ptr<CButton> maxButton;
|
||||
std::shared_ptr<CButton> buyButton;
|
||||
std::shared_ptr<CButton> cancelButton;
|
||||
std::shared_ptr<CreatureCostBox> totalCost;
|
||||
std::vector<std::shared_ptr<CreaturePurchaseCard>> cards;
|
||||
std::shared_ptr<CFilledTexture> backgroundTexture;
|
||||
|
@ -27,7 +27,8 @@ class Chat : public QWidget
|
||||
};
|
||||
|
||||
QCompleter namesCompleter;
|
||||
QString username, session;
|
||||
QString username;
|
||||
QString session;
|
||||
ChatId chatId = GLOBAL;
|
||||
|
||||
QVector<QTextDocument*> chatDocuments;
|
||||
|
@ -106,7 +106,8 @@ void Lobby::serverCommand(const ServerCommand & command) try
|
||||
//initialize variables outside of switch block
|
||||
const QString statusPlaceholder("%1 %2\n");
|
||||
const auto & args = command.arguments;
|
||||
int amount, tagPoint;
|
||||
int amount;
|
||||
int tagPoint;
|
||||
QString joinStr;
|
||||
switch(command.command)
|
||||
{
|
||||
@ -521,7 +522,8 @@ void Lobby::on_kickButton_clicked()
|
||||
|
||||
void Lobby::on_buttonResolve_clicked()
|
||||
{
|
||||
QStringList toEnableList, toDisableList;
|
||||
QStringList toEnableList;
|
||||
QStringList toDisableList;
|
||||
auto items = ui->modsList->selectedItems();
|
||||
if(items.empty())
|
||||
{
|
||||
|
@ -52,7 +52,8 @@ class DLL_LINKAGE CCreature : public Creature, public CBonusSystemNode
|
||||
TResources cost; //cost[res_id] - amount of that resource required to buy creature from dwelling
|
||||
|
||||
public:
|
||||
ui32 ammMin, ammMax; // initial size of stack of these creatures on adventure map (if not set in editor)
|
||||
ui32 ammMin; // initial size of stack of these creatures on adventure map (if not set in editor)
|
||||
ui32 ammMax;
|
||||
|
||||
bool special = true; // Creature is not available normally (war machines, commanders, several unused creatures, etc
|
||||
|
||||
|
@ -194,7 +194,8 @@ CSkill * CSkillHandler::loadFromJson(const std::string & scope, const JsonNode &
|
||||
{
|
||||
assert(identifier.find(':') == std::string::npos);
|
||||
assert(!scope.empty());
|
||||
bool major, minor;
|
||||
bool major;
|
||||
bool minor;
|
||||
|
||||
major = json["obligatoryMajor"].Bool();
|
||||
minor = json["obligatoryMinor"].Bool();
|
||||
|
@ -23,7 +23,9 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class CStopWatch
|
||||
{
|
||||
si64 start, last, mem;
|
||||
si64 start;
|
||||
si64 last;
|
||||
si64 mem;
|
||||
|
||||
public:
|
||||
CStopWatch()
|
||||
|
@ -22,7 +22,9 @@ public:
|
||||
void run();
|
||||
private:
|
||||
boost::mutex rtinm;
|
||||
int currentTask, amount, threads;
|
||||
int currentTask;
|
||||
int amount;
|
||||
int threads;
|
||||
std::vector<Task> *tasks;
|
||||
|
||||
|
||||
@ -60,7 +62,9 @@ public:
|
||||
}
|
||||
private:
|
||||
boost::mutex rtinm;
|
||||
size_t currentTask, amount, threads;
|
||||
size_t currentTask;
|
||||
size_t amount;
|
||||
size_t threads;
|
||||
Tasks * tasks;
|
||||
std::vector<std::shared_ptr<Payload>> context;
|
||||
|
||||
|
@ -68,8 +68,10 @@ public:
|
||||
void step(int count = 1);
|
||||
|
||||
private:
|
||||
std::atomic<Type> _progress, _target;
|
||||
std::atomic<int> _step, _maxSteps;
|
||||
std::atomic<Type> _progress;
|
||||
std::atomic<Type> _target;
|
||||
std::atomic<int> _step;
|
||||
std::atomic<int> _maxSteps;
|
||||
|
||||
friend class ProgressAccumulator;
|
||||
};
|
||||
@ -87,7 +89,8 @@ public:
|
||||
|
||||
private:
|
||||
mutable boost::mutex _mx;
|
||||
long long _accumulated = 0, _steps = 0;
|
||||
long long _accumulated = 0;
|
||||
long long _steps = 0;
|
||||
std::vector<std::reference_wrapper<const Progress>> _progress;
|
||||
};
|
||||
|
||||
|
@ -40,7 +40,8 @@ public:
|
||||
|
||||
bool isAbsoluteObstacle; //there may only one such obstacle in battle and its position is always the same
|
||||
bool isForegroundObstacle;
|
||||
si32 width, height; //how much space to the right and up is needed to place obstacle (affects only placement algorithm)
|
||||
si32 width; //how much space to the right and up is needed to place obstacle (affects only placement algorithm)
|
||||
si32 height;
|
||||
std::vector<si16> blockedTiles; //offsets relative to obstacle position (that is its left bottom corner)
|
||||
|
||||
int32_t getIndex() const override;
|
||||
|
@ -154,7 +154,8 @@ struct RangeGenerator
|
||||
return ret;
|
||||
}
|
||||
|
||||
int min, remainingCount;
|
||||
int min;
|
||||
int remainingCount;
|
||||
std::vector<bool> remaining;
|
||||
std::function<int()> myRand;
|
||||
};
|
||||
|
@ -34,7 +34,8 @@ public:
|
||||
DEFENDER
|
||||
};
|
||||
std::array<SideInBattle, 2> sides; //sides[0] - attacker, sides[1] - defender
|
||||
si32 round, activeStack;
|
||||
si32 round;
|
||||
si32 activeStack;
|
||||
const CGTownInstance * town; //used during town siege, nullptr if this is not a siege (note that fortless town IS also a siege)
|
||||
int3 tile; //for background and bonuses
|
||||
bool creatureBank; //auxilary field, do not serialize
|
||||
|
@ -235,7 +235,8 @@ public:
|
||||
class DLL_LINKAGE RankRangeLimiter : public ILimiter //applies to creatures with min <= Rank <= max
|
||||
{
|
||||
public:
|
||||
ui8 minRank, maxRank;
|
||||
ui8 minRank;
|
||||
ui8 maxRank;
|
||||
|
||||
RankRangeLimiter();
|
||||
RankRangeLimiter(ui8 Min, ui8 Max = 255);
|
||||
|
@ -35,7 +35,8 @@ class DLL_LINKAGE CampaignRegions
|
||||
struct DLL_LINKAGE RegionDescription
|
||||
{
|
||||
std::string infix;
|
||||
int xpos, ypos;
|
||||
int xpos;
|
||||
int ypos;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int formatVersion)
|
||||
{
|
||||
|
@ -105,7 +105,8 @@ public:
|
||||
void init(const IMapService * mapService, StartInfo * si, Load::ProgressAccumulator &, bool allowSavingRandomMap = true);
|
||||
void updateOnLoad(StartInfo * si);
|
||||
|
||||
ConstTransitivePtr<StartInfo> scenarioOps, initialOpts; //second one is a copy of settings received from pregame (not randomized)
|
||||
ConstTransitivePtr<StartInfo> scenarioOps;
|
||||
ConstTransitivePtr<StartInfo> initialOpts; //copy of settings received from pregame (not randomized)
|
||||
ui32 day; //total number of days in game
|
||||
ConstTransitivePtr<CMap> map;
|
||||
std::map<PlayerColor, PlayerState> players;
|
||||
|
@ -15,7 +15,9 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
class int3
|
||||
{
|
||||
public:
|
||||
si32 x, y, z;
|
||||
si32 x;
|
||||
si32 y;
|
||||
si32 z;
|
||||
|
||||
//c-tor: x, y, z initialized to 0
|
||||
constexpr int3() : x(0), y(0), z(0) {} // I think that x, y, z should be left uninitialized.
|
||||
|
@ -117,7 +117,8 @@ protected:
|
||||
JsonNode predefinedOffer;
|
||||
int marketEfficiency;
|
||||
|
||||
std::string title, speech;
|
||||
std::string title;
|
||||
std::string speech;
|
||||
|
||||
public:
|
||||
CGMarket * createObject() const override;
|
||||
|
@ -28,8 +28,10 @@ protected:
|
||||
struct LinePattern
|
||||
{
|
||||
std::string data[9];
|
||||
std::pair<int, int> roadMapping, riverMapping;
|
||||
bool hasHFlip, hasVFlip;
|
||||
std::pair<int, int> roadMapping;
|
||||
std::pair<int, int> riverMapping;
|
||||
bool hasHFlip;
|
||||
bool hasVFlip;
|
||||
};
|
||||
|
||||
struct ValidationResult
|
||||
|
@ -141,7 +141,8 @@ void CMapHeader::registerMapStrings()
|
||||
VLC->generaltexth->addSubContainer(*this);
|
||||
|
||||
//get supported languages. Assuming that translation containing most strings is the base language
|
||||
std::set<std::string> mapLanguages, mapBaseLanguages;
|
||||
std::set<std::string, std::less<>> mapLanguages;
|
||||
std::set<std::string, std::less<>> mapBaseLanguages;
|
||||
int maxStrings = 0;
|
||||
for(auto & translation : translations.Struct())
|
||||
{
|
||||
@ -166,7 +167,8 @@ void CMapHeader::registerMapStrings()
|
||||
mapBaseLanguages.insert(translation.first);
|
||||
}
|
||||
|
||||
std::string baseLanguage, language;
|
||||
std::string baseLanguage;
|
||||
std::string language;
|
||||
//english is preferrable as base language
|
||||
if(mapBaseLanguages.count(Languages::getLanguageOptions(Languages::ELanguages::ENGLISH).identifier))
|
||||
baseLanguage = Languages::getLanguageOptions(Languages::ELanguages::ENGLISH).identifier;
|
||||
|
@ -83,7 +83,8 @@ private:
|
||||
|
||||
struct InvalidTiles
|
||||
{
|
||||
std::set<int3> foreignTiles, nativeTiles;
|
||||
std::set<int3> foreignTiles;
|
||||
std::set<int3> nativeTiles;
|
||||
bool centerPosValid;
|
||||
|
||||
InvalidTiles() : centerPosValid(false) { }
|
||||
|
@ -94,7 +94,8 @@ ModCompatibilityInfo CMapService::verifyMapHeaderMods(const CMapHeader & map)
|
||||
{
|
||||
const auto & activeMods = VLC->modh->getActiveMods();
|
||||
|
||||
ModCompatibilityInfo missingMods, missingModsFiltered;
|
||||
ModCompatibilityInfo missingMods;
|
||||
ModCompatibilityInfo missingModsFiltered;
|
||||
for(const auto & mapMod : map.mods)
|
||||
{
|
||||
if(vstd::contains(activeMods, mapMod.first))
|
||||
|
@ -23,8 +23,11 @@ struct DLL_LINKAGE MapRect
|
||||
{
|
||||
MapRect();
|
||||
MapRect(const int3 & pos, si32 width, si32 height);
|
||||
si32 x, y, z;
|
||||
si32 width, height;
|
||||
si32 x;
|
||||
si32 y;
|
||||
si32 z;
|
||||
si32 width;
|
||||
si32 height;
|
||||
|
||||
si32 left() const;
|
||||
si32 right() const;
|
||||
@ -206,7 +209,8 @@ struct DLL_LINKAGE TerrainViewPattern
|
||||
int rotationTypesCount;
|
||||
|
||||
/// The minimum and maximum points to reach to validate the pattern successfully.
|
||||
int minPoints, maxPoints;
|
||||
int minPoints;
|
||||
int maxPoints;
|
||||
};
|
||||
|
||||
/// The terrain view pattern config loads pattern data from the filesystem.
|
||||
|
@ -51,7 +51,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::string messageMissingMods, messageExcessiveMods;
|
||||
std::string messageMissingMods;
|
||||
std::string messageExcessiveMods;
|
||||
};
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
@ -250,7 +250,8 @@ struct DLL_LINKAGE HeroVisitCastle : public CPackForClient
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
ui8 flags = 0; //1 - start
|
||||
ObjectInstanceID tid, hid;
|
||||
ObjectInstanceID tid;
|
||||
ObjectInstanceID hid;
|
||||
|
||||
bool start() const //if hero is entering castle (if false - leaving)
|
||||
{
|
||||
@ -629,7 +630,8 @@ struct DLL_LINKAGE TryMoveHero : public CPackForClient
|
||||
ObjectInstanceID id;
|
||||
ui32 movePoints = 0;
|
||||
EResult result = FAILED; //uses EResult
|
||||
int3 start, end; //h3m format
|
||||
int3 start; //h3m format
|
||||
int3 end;
|
||||
std::unordered_set<int3> fowRevealed; //revealed tiles
|
||||
std::optional<int3> attackedFrom; // Set when stepping into endangered tile.
|
||||
|
||||
@ -708,7 +710,9 @@ struct DLL_LINKAGE SetHeroesInTown : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs) const;
|
||||
|
||||
ObjectInstanceID tid, visiting, garrison; //id of town, visiting hero, hero in garrison
|
||||
ObjectInstanceID tid; //id of town
|
||||
ObjectInstanceID visiting; //id of visiting hero
|
||||
ObjectInstanceID garrison; //id of hero in garrison
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -1028,7 +1032,8 @@ struct DLL_LINKAGE MoveArtifact : CArtifactOperationPack
|
||||
: src(*src), dst(*dst), askAssemble(askAssemble)
|
||||
{
|
||||
}
|
||||
ArtifactLocation src, dst;
|
||||
ArtifactLocation src;
|
||||
ArtifactLocation dst;
|
||||
bool askAssemble = true;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
@ -1169,8 +1174,9 @@ struct DLL_LINKAGE NewTurn : public CPackForClient
|
||||
|
||||
struct Hero
|
||||
{
|
||||
ObjectInstanceID id;
|
||||
ui32 move, mana; //id is a general serial id
|
||||
ObjectInstanceID id; //id is a general serial id
|
||||
ui32 move;
|
||||
ui32 mana;
|
||||
template <typename Handler> void serialize(Handler & h, const int version)
|
||||
{
|
||||
h & id;
|
||||
@ -1361,7 +1367,8 @@ struct DLL_LINKAGE BlockingDialog : public Query
|
||||
|
||||
struct DLL_LINKAGE GarrisonDialog : public Query
|
||||
{
|
||||
ObjectInstanceID objid, hid;
|
||||
ObjectInstanceID objid;
|
||||
ObjectInstanceID hid;
|
||||
bool removableUnits = false;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
@ -72,7 +72,8 @@ struct DLL_LINKAGE LobbyClientDisconnected : public CLobbyPackToPropagate
|
||||
|
||||
struct DLL_LINKAGE LobbyChatMessage : public CLobbyPackToPropagate
|
||||
{
|
||||
std::string playerName, message;
|
||||
std::string playerName;
|
||||
std::string message;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
@ -112,7 +113,8 @@ struct DLL_LINKAGE LobbyLoadProgress : public CLobbyPackToPropagate
|
||||
|
||||
struct DLL_LINKAGE LobbyEndGame : public CLobbyPackToPropagate
|
||||
{
|
||||
bool closeConnection = false, restart = false;
|
||||
bool closeConnection = false;
|
||||
bool restart = false;
|
||||
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
|
@ -157,9 +157,13 @@ private:
|
||||
void updatePlayers();
|
||||
const CRmgTemplate * getPossibleTemplate(CRandomGenerator & rand) const;
|
||||
|
||||
si32 width, height;
|
||||
si32 width;
|
||||
si32 height;
|
||||
bool hasTwoLevels;
|
||||
si8 humanOrCpuPlayerCount, teamCount, compOnlyPlayerCount, compOnlyTeamCount;
|
||||
si8 humanOrCpuPlayerCount;
|
||||
si8 teamCount;
|
||||
si8 compOnlyPlayerCount;
|
||||
si8 compOnlyTeamCount;
|
||||
EWaterContent::EWaterContent waterContent;
|
||||
EMonsterStrength::EMonsterStrength monsterStrength;
|
||||
std::map<PlayerColor, CPlayerSettings> players;
|
||||
|
@ -42,11 +42,17 @@ public:
|
||||
std::string defaultRoadType;
|
||||
std::string secondaryRoadType;
|
||||
int treasureValueLimit;
|
||||
std::vector<int> prisonExperience, prisonValues;
|
||||
std::vector<int> prisonExperience;
|
||||
std::vector<int> prisonValues;
|
||||
std::vector<int> scrollValues;
|
||||
int pandoraMultiplierGold, pandoraMultiplierExperience, pandoraMultiplierSpells, pandoraSpellSchool, pandoraSpell60;
|
||||
int pandoraMultiplierGold;
|
||||
int pandoraMultiplierExperience;
|
||||
int pandoraMultiplierSpells;
|
||||
int pandoraSpellSchool;
|
||||
int pandoraSpell60;
|
||||
std::vector<int> pandoraCreatureValues;
|
||||
std::vector<int> questValues, questRewardValues;
|
||||
std::vector<int> questValues;
|
||||
std::vector<int> questRewardValues;
|
||||
bool singleThread;
|
||||
};
|
||||
|
||||
|
@ -263,8 +263,10 @@ public:
|
||||
private:
|
||||
std::string id;
|
||||
std::string name;
|
||||
int3 minSize, maxSize;
|
||||
CPlayerCountRange players, humanPlayers;
|
||||
int3 minSize;
|
||||
int3 maxSize;
|
||||
CPlayerCountRange players;
|
||||
CPlayerCountRange humanPlayers;
|
||||
Zones zones;
|
||||
std::vector<rmg::ZoneConnection> connectedZoneIds;
|
||||
std::set<EWaterContent::EWaterContent> allowedWaterContent;
|
||||
|
@ -108,7 +108,8 @@ void CZonePlacer::placeOnGrid(CRandomGenerator* rand)
|
||||
//Place first zone
|
||||
|
||||
auto firstZone = zonesVector[0].second;
|
||||
size_t x = 0, y = 0;
|
||||
size_t x = 0;
|
||||
size_t y = 0;
|
||||
|
||||
auto getRandomEdge = [rand, gridSize](size_t& x, size_t& y)
|
||||
{
|
||||
|
@ -95,7 +95,8 @@ public:
|
||||
private:
|
||||
std::list<Instance> dInstances;
|
||||
mutable Area dFullAreaCache;
|
||||
mutable Area dAccessibleAreaCache, dAccessibleAreaFullCache;
|
||||
mutable Area dAccessibleAreaCache;
|
||||
mutable Area dAccessibleAreaFullCache;
|
||||
mutable Area dBlockVisitableCache;
|
||||
mutable Area dVisitableCache;
|
||||
mutable Area dRemovableAreaCache;
|
||||
|
@ -16,7 +16,8 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
class float3
|
||||
{
|
||||
public:
|
||||
float x, y;
|
||||
float x;
|
||||
float y;
|
||||
si32 z;
|
||||
|
||||
float3() : x(0), y(0), z(0) {}
|
||||
|
@ -35,7 +35,8 @@ protected:
|
||||
void collectNeighbourZones();
|
||||
|
||||
protected:
|
||||
std::vector<rmg::ZoneConnection> dConnections, dCompleted;
|
||||
std::vector<rmg::ZoneConnection> dConnections;
|
||||
std::vector<rmg::ZoneConnection> dCompleted;
|
||||
std::map<TRmgTemplateZoneId, rmg::Tileset> dNeighbourZones;
|
||||
};
|
||||
|
||||
|
@ -36,7 +36,8 @@ protected:
|
||||
protected:
|
||||
rmg::Tileset roadNodes; //tiles to be connected with roads
|
||||
rmg::Area roads; //all tiles with roads
|
||||
rmg::Area areaRoads, isolated;
|
||||
rmg::Area areaRoads;
|
||||
rmg::Area isolated;
|
||||
};
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
@ -28,7 +28,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
rmg::Area rockArea, accessibleArea;
|
||||
rmg::Area rockArea;
|
||||
rmg::Area accessibleArea;
|
||||
TerrainId rockTerrain;
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,8 @@ protected:
|
||||
void createWater(EWaterContent::EWaterContent waterContent);
|
||||
|
||||
protected:
|
||||
rmg::Area noWaterArea, waterArea;
|
||||
rmg::Area noWaterArea;
|
||||
rmg::Area waterArea;
|
||||
TRmgTemplateZoneId waterZoneId;
|
||||
std::map<int3, int> distanceMap;
|
||||
std::map<int, rmg::Tileset> reverseDistanceMap;
|
||||
|
@ -482,7 +482,9 @@ public:
|
||||
void load(boost::multi_array<T, 3> & data)
|
||||
{
|
||||
ui32 length = readAndCheckLength();
|
||||
ui32 x, y, z;
|
||||
ui32 x;
|
||||
ui32 y;
|
||||
ui32 z;
|
||||
load(x);
|
||||
load(y);
|
||||
load(z);
|
||||
|
@ -365,7 +365,9 @@ public:
|
||||
ui32 length = data.num_elements();
|
||||
*this & length;
|
||||
auto shape = data.shape();
|
||||
ui32 x = shape[0], y = shape[1], z = shape[2];
|
||||
ui32 x = shape[0];
|
||||
ui32 y = shape[1];
|
||||
ui32 z = shape[2];
|
||||
*this & x & y & z;
|
||||
for(ui32 i = 0; i < length; i++)
|
||||
save(data.data()[i]);
|
||||
|
@ -144,7 +144,9 @@ public:
|
||||
const std::set<si32> & standard;
|
||||
const TDecoder decoder;
|
||||
const TEncoder encoder;
|
||||
std::set<si32> all, any, none;
|
||||
std::set<si32> all;
|
||||
std::set<si32> any;
|
||||
std::set<si32> none;
|
||||
};
|
||||
|
||||
const bool saving;
|
||||
|
@ -62,7 +62,9 @@ class ImageLoader
|
||||
QImage * image;
|
||||
ui8 * lineStart;
|
||||
ui8 * position;
|
||||
QPoint spriteSize, margins, fullSize;
|
||||
QPoint spriteSize;
|
||||
QPoint margins;
|
||||
QPoint fullSize;
|
||||
public:
|
||||
//load size raw pixels from data
|
||||
inline void Load(size_t size, const ui8 * data);
|
||||
|
@ -538,7 +538,8 @@ void MainWindow::addGroupIntoCatalog(const std::string & groupName, bool useCust
|
||||
auto picture = animation.getImage(0);
|
||||
if(picture && picture->width() && picture->height())
|
||||
{
|
||||
qreal xscale = qreal(128) / qreal(picture->width()), yscale = qreal(128) / qreal(picture->height());
|
||||
qreal xscale = static_cast<qreal>(128) / static_cast<qreal>(picture->width());
|
||||
qreal yscale = static_cast<qreal>(128) / static_cast<qreal>(picture->height());
|
||||
qreal scale = std::min(xscale, yscale);
|
||||
painter.scale(scale, scale);
|
||||
painter.drawImage(QPoint(0, 0), *picture);
|
||||
|
@ -174,7 +174,8 @@ private:
|
||||
ObjectBrowserProxyModel * objectBrowser = nullptr;
|
||||
QGraphicsScene * scenePreview;
|
||||
|
||||
QString filename, lastSavingDir;
|
||||
QString filename;
|
||||
QString lastSavingDir;
|
||||
bool unsaved = false;
|
||||
|
||||
QStandardItemModel objectsModel;
|
||||
|
@ -100,7 +100,8 @@ void MapHandler::drawTerrainTile(QPainter & painter, int x, int y, int z)
|
||||
if(terrainImages.at(terrainName).size() <= tinfo.terView)
|
||||
return;
|
||||
|
||||
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
||||
bool hflip = (rotation == 1 || rotation == 3);
|
||||
bool vflip = (rotation == 2 || rotation == 3);
|
||||
painter.drawImage(x * tileSize, y * tileSize, terrainImages.at(terrainName)[tinfo.terView]->mirrored(hflip, vflip));
|
||||
}
|
||||
|
||||
@ -114,7 +115,8 @@ void MapHandler::drawRoad(QPainter & painter, int x, int y, int z)
|
||||
auto roadName = tinfoUpper->roadType->getJsonKey();
|
||||
QRect source(0, tileSize / 2, tileSize, tileSize / 2);
|
||||
ui8 rotation = (tinfoUpper->extTileFlags >> 4) % 4;
|
||||
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
||||
bool hflip = (rotation == 1 || rotation == 3);
|
||||
bool vflip = (rotation == 2 || rotation == 3);
|
||||
if(roadImages.at(roadName).size() > tinfoUpper->roadDir)
|
||||
{
|
||||
painter.drawImage(QPoint(x * tileSize, y * tileSize), roadImages.at(roadName)[tinfoUpper->roadDir]->mirrored(hflip, vflip), source);
|
||||
@ -126,7 +128,8 @@ void MapHandler::drawRoad(QPainter & painter, int x, int y, int z)
|
||||
auto roadName = tinfo.roadType->getJsonKey();;
|
||||
QRect source(0, 0, tileSize, tileSize / 2);
|
||||
ui8 rotation = (tinfo.extTileFlags >> 4) % 4;
|
||||
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
||||
bool hflip = (rotation == 1 || rotation == 3);
|
||||
bool vflip = (rotation == 2 || rotation == 3);
|
||||
if(roadImages.at(roadName).size() > tinfo.roadDir)
|
||||
{
|
||||
painter.drawImage(QPoint(x * tileSize, y * tileSize + tileSize / 2), roadImages.at(roadName)[tinfo.roadDir]->mirrored(hflip, vflip), source);
|
||||
@ -148,7 +151,8 @@ void MapHandler::drawRiver(QPainter & painter, int x, int y, int z)
|
||||
return;
|
||||
|
||||
ui8 rotation = (tinfo.extTileFlags >> 2) % 4;
|
||||
bool hflip = (rotation == 1 || rotation == 3), vflip = (rotation == 2 || rotation == 3);
|
||||
bool hflip = (rotation == 1 || rotation == 3);
|
||||
bool vflip = (rotation == 2 || rotation == 3);
|
||||
|
||||
painter.drawImage(x * tileSize, y * tileSize, riverImages.at(riverName)[tinfo.riverDir]->mirrored(hflip, vflip));
|
||||
}
|
||||
|
@ -494,7 +494,8 @@ void MapView::mouseReleaseEvent(QMouseEvent *event)
|
||||
//key: y position of tile
|
||||
//value.first: x position of left tile
|
||||
//value.second: x postiion of right tile
|
||||
std::map<int, std::pair<int, int>> selectionRangeMapX, selectionRangeMapY;
|
||||
std::map<int, std::pair<int, int>> selectionRangeMapX;
|
||||
std::map<int, std::pair<int, int>> selectionRangeMapY;
|
||||
for(auto & t : sc->selectionTerrainView.selection())
|
||||
{
|
||||
auto pairIter = selectionRangeMapX.find(t.y);
|
||||
@ -516,7 +517,8 @@ void MapView::mouseReleaseEvent(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
std::set<int3> selectionByX, selectionByY;
|
||||
std::set<int3> selectionByX;
|
||||
std::set<int3> selectionByY;
|
||||
std::vector<int3> finalSelection;
|
||||
for(auto & selectionRange : selectionRangeMapX)
|
||||
{
|
||||
|
@ -312,7 +312,8 @@ void TerrainLayer::draw(bool onlyDirty)
|
||||
|
||||
if(onlyDirty)
|
||||
{
|
||||
std::set<int3> forRedrawing(dirty), neighbours;
|
||||
std::set<int3> forRedrawing(dirty);
|
||||
std::set<int3> neighbours;
|
||||
for(auto & t : dirty)
|
||||
{
|
||||
for(auto & tt : int3::getDirs())
|
||||
|
@ -86,7 +86,9 @@ signals:
|
||||
void selectionMade(bool anythingSlected);
|
||||
|
||||
private:
|
||||
std::set<int3> area, areaAdd, areaErase;
|
||||
std::set<int3> area;
|
||||
std::set<int3> areaAdd;
|
||||
std::set<int3> areaErase;
|
||||
|
||||
void onSelection();
|
||||
};
|
||||
@ -227,6 +229,9 @@ public:
|
||||
int viewportHeight() const {return h;}
|
||||
|
||||
private:
|
||||
int x = 0, y = 0, w = 1, h = 1;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int w = 1;
|
||||
int h = 1;
|
||||
|
||||
};
|
||||
|
@ -94,7 +94,8 @@ namespace ERM
|
||||
|
||||
struct TArithmeticOp
|
||||
{
|
||||
TIexp lhs, rhs;
|
||||
TIexp lhs;
|
||||
TIexp rhs;
|
||||
char opcode;
|
||||
};
|
||||
|
||||
@ -145,7 +146,8 @@ namespace ERM
|
||||
struct TComparison
|
||||
{
|
||||
std::string compSign;
|
||||
TIexp lhs, rhs;
|
||||
TIexp lhs;
|
||||
TIexp rhs;
|
||||
};
|
||||
|
||||
struct Tcondition;
|
||||
|
@ -1550,8 +1550,8 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
if (!ScholarSpellLevel || !h1->hasSpellbook() || !h2->hasSpellbook())
|
||||
return;//no scholar skill or no spellbook
|
||||
|
||||
int h1Lvl = std::min(ScholarSpellLevel, h1->maxSpellLevel()),
|
||||
h2Lvl = std::min(ScholarSpellLevel, h2->maxSpellLevel());//heroes can receive this levels
|
||||
int h1Lvl = std::min(ScholarSpellLevel, h1->maxSpellLevel());//heroes can receive these levels
|
||||
int h2Lvl = std::min(ScholarSpellLevel, h2->maxSpellLevel());
|
||||
|
||||
ChangeSpells cs1;
|
||||
cs1.learn = true;
|
||||
@ -1636,7 +1636,8 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
|
||||
|
||||
void CGameHandler::heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)
|
||||
{
|
||||
auto h1 = getHero(hero1), h2 = getHero(hero2);
|
||||
auto h1 = getHero(hero1);
|
||||
auto h2 = getHero(hero2);
|
||||
|
||||
if (getPlayerRelations(h1->getOwner(), h2->getOwner()) != PlayerRelations::ENEMIES)
|
||||
{
|
||||
@ -2083,7 +2084,8 @@ bool CGameHandler::arrangeStacks(ObjectInstanceID id1, ObjectInstanceID id2, ui8
|
||||
const CArmedInstance * s2 = static_cast<const CArmedInstance *>(getObjInstance(id2));
|
||||
const CCreatureSet & S1 = *s1;
|
||||
const CCreatureSet & S2 = *s2;
|
||||
StackLocation sl1(s1, p1), sl2(s2, p2);
|
||||
StackLocation sl1(s1, p1);
|
||||
StackLocation sl2(s2, p2);
|
||||
|
||||
if (s1 == nullptr || s2 == nullptr)
|
||||
{
|
||||
@ -2965,7 +2967,8 @@ bool CGameHandler::buyArtifact(const IMarket *m, const CGHeroInstance *h, GameRe
|
||||
if (!vstd::contains(m->availableItemsIds(EMarketMode::RESOURCE_ARTIFACT), aid))
|
||||
COMPLAIN_RET("That artifact is unavailable!");
|
||||
|
||||
int b1, b2;
|
||||
int b1;
|
||||
int b2;
|
||||
m->getOffer(rid, aid, b1, b2, EMarketMode::RESOURCE_ARTIFACT);
|
||||
|
||||
if (getResource(h->tempOwner, rid) < b1)
|
||||
@ -3013,7 +3016,8 @@ bool CGameHandler::sellArtifact(const IMarket *m, const CGHeroInstance *h, Artif
|
||||
COMPLAIN_RET_FALSE_IF((!art), "There is no artifact to sell!");
|
||||
COMPLAIN_RET_FALSE_IF((!art->artType->isTradable()), "Cannot sell a war machine or spellbook!");
|
||||
|
||||
int resVal = 0, dump = 1;
|
||||
int resVal = 0;
|
||||
int dump = 1;
|
||||
m->getOffer(art->artType->getId(), rid, dump, resVal, EMarketMode::ARTIFACT_RESOURCE);
|
||||
|
||||
removeArtifact(ArtifactLocation(h->id, h->getArtPos(art)));
|
||||
@ -3053,7 +3057,8 @@ bool CGameHandler::tradeResources(const IMarket *market, ui32 amountToSell, Play
|
||||
|
||||
vstd::amin(amountToSell, haveToSell); //can't trade more resources than have
|
||||
|
||||
int b1, b2; //base quantities for trade
|
||||
int b1; //base quantities for trade
|
||||
int b2;
|
||||
market->getOffer(toSell, toBuy, b1, b2, EMarketMode::RESOURCE_RESOURCE);
|
||||
int amountToBoy = amountToSell / b1; //how many base quantities we trade
|
||||
|
||||
@ -3083,7 +3088,8 @@ bool CGameHandler::sellCreatures(ui32 count, const IMarket *market, const CGHero
|
||||
COMPLAIN_RET("Not enough creatures in army!");
|
||||
}
|
||||
|
||||
int b1, b2; //base quantities for trade
|
||||
int b1; //base quantities for trade
|
||||
int b2;
|
||||
market->getOffer(s.type->getId(), resourceID, b1, b2, EMarketMode::CREATURE_RESOURCE);
|
||||
int units = count / b1; //how many base quantities we trade
|
||||
|
||||
@ -3380,7 +3386,8 @@ bool CGameHandler::isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2)
|
||||
if (id1 == id2)
|
||||
return true;
|
||||
|
||||
const CGObjectInstance *o1 = getObj(id1), *o2 = getObj(id2);
|
||||
const CGObjectInstance *o1 = getObj(id1);
|
||||
const CGObjectInstance *o2 = getObj(id2);
|
||||
if (!o1 || !o2)
|
||||
return true; //arranging stacks within an object should be always allowed
|
||||
|
||||
@ -3730,7 +3737,8 @@ bool CGameHandler::sacrificeCreatures(const IMarket * market, const CGHeroInstan
|
||||
|
||||
changeStackCount(StackLocation(hero, slot[i]), -(TQuantity)count[i]);
|
||||
|
||||
int dump, exp;
|
||||
int dump;
|
||||
int exp;
|
||||
market->getOffer(crid, 0, dump, exp, EMarketMode::CREATURE_EXP);
|
||||
exp *= count[i];
|
||||
expSum += exp;
|
||||
@ -3772,7 +3780,8 @@ bool CGameHandler::sacrificeArtifact(const IMarket * m, const CGHeroInstance * h
|
||||
}
|
||||
|
||||
si32 typId = art->artType->getId();
|
||||
int dmp, expToGive;
|
||||
int dmp;
|
||||
int expToGive;
|
||||
|
||||
m->getOffer(typId, 0, dmp, expToGive, EMarketMode::ARTIFACT_EXP);
|
||||
|
||||
|
@ -55,7 +55,8 @@ class CVCMIServer : public LobbyInfo
|
||||
std::list<std::unique_ptr<CPackForLobby>> announceQueue;
|
||||
boost::recursive_mutex mx;
|
||||
std::shared_ptr<CApplier<CBaseForServerApply>> applier;
|
||||
std::unique_ptr<boost::thread> announceLobbyThread, remoteConnectionsThread;
|
||||
std::unique_ptr<boost::thread> announceLobbyThread;
|
||||
std::unique_ptr<boost::thread> remoteConnectionsThread;
|
||||
std::atomic<EServerState> state;
|
||||
|
||||
public:
|
||||
|
@ -45,7 +45,8 @@ TEST(BattleHexTest, getNeighbouringTiles)
|
||||
|
||||
TEST(BattleHexTest, getDistance)
|
||||
{
|
||||
BattleHex firstHex(0,0), secondHex(16,0);
|
||||
BattleHex firstHex(0,0);
|
||||
BattleHex secondHex(16,0);
|
||||
EXPECT_EQ((int)firstHex.getDistance(firstHex,secondHex), 16);
|
||||
firstHex=0, secondHex=170;
|
||||
EXPECT_EQ((int)firstHex.getDistance(firstHex,secondHex), 10);
|
||||
@ -63,7 +64,8 @@ TEST(BattleHexTest, getDistance)
|
||||
|
||||
TEST(BattleHexTest, mutualPositions)
|
||||
{
|
||||
BattleHex firstHex(0,0), secondHex(16,0);
|
||||
BattleHex firstHex(0,0);
|
||||
BattleHex secondHex(16,0);
|
||||
firstHex=86, secondHex=68;
|
||||
EXPECT_EQ((int)firstHex.mutualPosition(firstHex,secondHex), BattleHex::EDir::TOP_LEFT);
|
||||
secondHex=69;
|
||||
|
@ -114,13 +114,13 @@ TEST_F(ResourceManagerTest, queueOrder)
|
||||
{
|
||||
ASSERT_FALSE(rm->hasTasksLeft());
|
||||
|
||||
TSubgoal buildLow = sptr(StrictMock<BuildThis>()),
|
||||
buildBit = sptr(StrictMock<BuildThis>()),
|
||||
buildMed = sptr(StrictMock<BuildThis>()),
|
||||
buildHigh = sptr(StrictMock<BuildThis>()),
|
||||
buildVeryHigh = sptr(StrictMock<BuildThis>()),
|
||||
buildExtra = sptr(StrictMock<BuildThis>()),
|
||||
buildNotSoExtra = sptr(StrictMock<BuildThis>());
|
||||
TSubgoal buildLow = sptr(StrictMock<BuildThis>());
|
||||
TSubgoal buildBit = sptr(StrictMock<BuildThis>());
|
||||
TSubgoal buildMed = sptr(StrictMock<BuildThis>());
|
||||
TSubgoal buildHigh = sptr(StrictMock<BuildThis>());
|
||||
TSubgoal buildVeryHigh = sptr(StrictMock<BuildThis>());
|
||||
TSubgoal buildExtra = sptr(StrictMock<BuildThis>());
|
||||
TSubgoal buildNotSoExtra = sptr(StrictMock<BuildThis>());
|
||||
|
||||
buildLow->setpriority(0).setbid(1);
|
||||
buildLow->setpriority(1).setbid(2);
|
||||
|
Loading…
Reference in New Issue
Block a user