1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Remove all remaining implicit conversion in lib

This commit is contained in:
Ivan Savenko 2023-11-08 17:49:08 +02:00
parent 96c81be68e
commit 6cb1f6ff11
11 changed files with 35 additions and 31 deletions

View File

@ -632,7 +632,7 @@ void CMarketplaceWindow::artifactsChanged(bool Left)
if(mode != EMarketMode::RESOURCE_ARTIFACT)
return;
std::vector<int> available = market->availableItemsIds(mode);
std::vector<TradeItemBuy> available = market->availableItemsIds(mode);
std::set<std::shared_ptr<CTradeableItem>> toRemove;
for(auto item : items[0])
if(!vstd::contains(available, item->id))

View File

@ -1156,7 +1156,7 @@ CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket
clerkSpeech = std::make_shared<CTextBox>(speechStr, Rect(24, 129, 413, 70), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
title = std::make_shared<CLabel>(231, 26, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, titleStr);
std::vector<int> goods = market->availableItemsIds(EMarketMode::RESOURCE_SKILL);
std::vector<TradeItemBuy> goods = market->availableItemsIds(EMarketMode::RESOURCE_SKILL);
for(int i=0; i<goods.size(); i++)//prepare clickable items
items.push_back(std::make_shared<CItem>(this, goods[i], 54+i*104, 234));

View File

@ -778,8 +778,10 @@ void CGameState::initTowns()
campaign->initTowns();
CGTownInstance::universitySkills.clear();
for ( int i=0; i<4; i++)
CGTownInstance::universitySkills.push_back(14+i);//skills for university
CGTownInstance::universitySkills.push_back(SecondarySkill(SecondarySkill::FIRE_MAGIC));
CGTownInstance::universitySkills.push_back(SecondarySkill(SecondarySkill::AIR_MAGIC));
CGTownInstance::universitySkills.push_back(SecondarySkill(SecondarySkill::WATER_MAGIC));
CGTownInstance::universitySkills.push_back(SecondarySkill(SecondarySkill::EARTH_MAGIC));
for (auto & elem : map->towns)
{

View File

@ -261,7 +261,7 @@ void MarketInstanceConstructor::randomizeObject(CGMarket * object, CRandomGenera
if(auto * university = dynamic_cast<CGUniversity *>(object))
{
for(auto skill : JsonRandom::loadSecondaries(predefinedOffer, rng, emptyVariables))
university->skills.push_back(skill.first.getNum());
university->skills.push_back(skill.first);
}
}

View File

@ -48,18 +48,18 @@ int CGMarket::availableUnits(EMarketMode mode, int marketItemSerial) const
return -1;
}
std::vector<int> CGMarket::availableItemsIds(EMarketMode mode) const
std::vector<TradeItemBuy> CGMarket::availableItemsIds(EMarketMode mode) const
{
if(allowsTrade(mode))
return IMarket::availableItemsIds(mode);
return std::vector<int>();
return std::vector<TradeItemBuy>();
}
CGMarket::CGMarket()
{
}
std::vector<int> CGBlackMarket::availableItemsIds(EMarketMode mode) const
std::vector<TradeItemBuy> CGBlackMarket::availableItemsIds(EMarketMode mode) const
{
switch(mode)
{
@ -67,16 +67,16 @@ std::vector<int> CGBlackMarket::availableItemsIds(EMarketMode mode) const
return IMarket::availableItemsIds(mode);
case EMarketMode::RESOURCE_ARTIFACT:
{
std::vector<int> ret;
std::vector<TradeItemBuy> ret;
for(const CArtifact *a : artifacts)
if(a)
ret.push_back(a->getId());
else
ret.push_back(-1);
ret.push_back(ArtifactID{});
return ret;
}
default:
return std::vector<int>();
return std::vector<TradeItemBuy>();
}
}
@ -96,7 +96,7 @@ void CGBlackMarket::newTurn(CRandomGenerator & rand) const
cb->sendAndApply(&saa);
}
std::vector<int> CGUniversity::availableItemsIds(EMarketMode mode) const
std::vector<TradeItemBuy> CGUniversity::availableItemsIds(EMarketMode mode) const
{
switch (mode)
{
@ -104,7 +104,7 @@ std::vector<int> CGUniversity::availableItemsIds(EMarketMode mode) const
return skills;
default:
return std::vector<int>();
return std::vector<TradeItemBuy>();
}
}

View File

@ -34,7 +34,7 @@ public:
int getMarketEfficiency() const override;
bool allowsTrade(EMarketMode mode) const override;
int availableUnits(EMarketMode mode, int marketItemSerial) const override; //-1 if unlimited
std::vector<int> availableItemsIds(EMarketMode mode) const override;
std::vector<TradeItemBuy> availableItemsIds(EMarketMode mode) const override;
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -52,7 +52,7 @@ public:
std::vector<const CArtifact *> artifacts; //available artifacts
void newTurn(CRandomGenerator & rand) const override; //reset artifacts for black market every month
std::vector<int> availableItemsIds(EMarketMode mode) const override;
std::vector<TradeItemBuy> availableItemsIds(EMarketMode mode) const override;
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -64,9 +64,9 @@ public:
class DLL_LINKAGE CGUniversity : public CGMarket
{
public:
std::vector<int> skills; //available skills
std::vector<TradeItemBuy> skills; //available skills
std::vector<int> availableItemsIds(EMarketMode mode) const override;
std::vector<TradeItemBuy> availableItemsIds(EMarketMode mode) const override;
void onHeroVisit(const CGHeroInstance * h) const override; //open window
template <typename Handler> void serialize(Handler &h, const int version)

View File

@ -34,7 +34,7 @@
VCMI_LIB_NAMESPACE_BEGIN
std::vector<const CArtifact *> CGTownInstance::merchantArtifacts;
std::vector<int> CGTownInstance::universitySkills;
std::vector<TradeItemBuy> CGTownInstance::universitySkills;
int CGTownInstance::getSightRadius() const //returns sight distance
@ -765,16 +765,16 @@ bool CGTownInstance::allowsTrade(EMarketMode mode) const
}
}
std::vector<int> CGTownInstance::availableItemsIds(EMarketMode mode) const
std::vector<TradeItemBuy> CGTownInstance::availableItemsIds(EMarketMode mode) const
{
if(mode == EMarketMode::RESOURCE_ARTIFACT)
{
std::vector<int> ret;
std::vector<TradeItemBuy> ret;
for(const CArtifact *a : merchantArtifacts)
if(a)
ret.push_back(a->getId());
else
ret.push_back(-1);
ret.push_back(ArtifactID{});
return ret;
}
else if ( mode == EMarketMode::RESOURCE_SKILL )

View File

@ -68,7 +68,7 @@ public:
//////////////////////////////////////////////////////////////////////////
static std::vector<const CArtifact *> merchantArtifacts; //vector of artifacts available at Artifact merchant, NULLs possible (for making empty space when artifact is bought)
static std::vector<int> universitySkills;//skills for university of magic
static std::vector<TradeItemBuy> universitySkills;//skills for university of magic
template <typename Handler> void serialize(Handler &h, const int version)
{
@ -150,7 +150,7 @@ public:
const IObjectInterface * getObject() const override;
int getMarketEfficiency() const override; //=market count
bool allowsTrade(EMarketMode mode) const override;
std::vector<int> availableItemsIds(EMarketMode mode) const override;
std::vector<TradeItemBuy> availableItemsIds(EMarketMode mode) const override;
void updateAppearance();

View File

@ -140,16 +140,16 @@ int IMarket::availableUnits(EMarketMode mode, int marketItemSerial) const
}
}
std::vector<int> IMarket::availableItemsIds(EMarketMode mode) const
std::vector<TradeItemBuy> IMarket::availableItemsIds(EMarketMode mode) const
{
std::vector<int> ret;
std::vector<TradeItemBuy> ret;
switch(mode)
{
case EMarketMode::RESOURCE_RESOURCE:
case EMarketMode::ARTIFACT_RESOURCE:
case EMarketMode::CREATURE_RESOURCE:
for (int i = 0; i < 7; i++)
ret.push_back(i);
for (auto res : GameResID::ALL_RESOURCES())
ret.push_back(res);
}
return ret;
}

View File

@ -9,7 +9,8 @@
*/
#pragma once
#include "../GameConstants.h"
#include "../networkPacks/TradeItem.h"
#include "../constants/Enumerations.h"
VCMI_LIB_NAMESPACE_BEGIN
@ -24,7 +25,7 @@ public:
virtual int getMarketEfficiency() const = 0;
virtual bool allowsTrade(EMarketMode mode) const;
virtual int availableUnits(EMarketMode mode, int marketItemSerial) const; //-1 if unlimited
virtual std::vector<int> availableItemsIds(EMarketMode mode) const;
virtual std::vector<TradeItemBuy> availableItemsIds(EMarketMode mode) const;
bool getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const; //val1 - how many units of id1 player has to give to receive val2 units
std::vector<EMarketMode> availableModes() const;

View File

@ -79,8 +79,9 @@ void CCastleEvent::serializeJson(JsonSerializeFormat & handler)
a.syncSize(temp);
for(int i = 0; i < temp.size(); ++i)
{
a.serializeInt(i, temp[i].getNum());
buildings.insert(temp[i]);
int buildingID = temp[i].getNum();
a.serializeInt(i, buildingID);
buildings.insert(buildingID);
}
}