1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

get rid of boost::assign

This commit is contained in:
AlexVinS 2014-10-04 00:34:13 +04:00
parent 66b022f93e
commit 54453aee73
20 changed files with 64 additions and 65 deletions

View File

@ -126,7 +126,6 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
#define BOOST_BIND_NO_PLACEHOLDERS #define BOOST_BIND_NO_PLACEHOLDERS
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/assign.hpp>
#include <boost/cstdint.hpp> #include <boost/cstdint.hpp>
#include <boost/current_function.hpp> #include <boost/current_function.hpp>
#include <boost/crc.hpp> #include <boost/crc.hpp>
@ -676,6 +675,13 @@ namespace vstd
boost::sort(vec); boost::sort(vec);
vec.erase(std::unique(vec.begin(), vec.end()), vec.end()); vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
} }
template <typename T>
void concatenate(std::vector<T> &dest, const std::vector<T> &src)
{
dest.reserve(dest.size() + src.size());
dest.insert(dest.end(), src.begin(), src.end());
}
using boost::math::round; using boost::math::round;
} }

View File

@ -55,7 +55,6 @@
#define ADVOPT (conf.go()->ac) #define ADVOPT (conf.go()->ac)
using namespace boost::logic; using namespace boost::logic;
using namespace boost::assign;
using namespace CSDL_Ext; using namespace CSDL_Ext;
CAdvMapInt *adventureInt; CAdvMapInt *adventureInt;
@ -692,7 +691,7 @@ bool CAdvMapInt::isHeroSleeping(const CGHeroInstance *hero)
void CAdvMapInt::setHeroSleeping(const CGHeroInstance *hero, bool sleep) void CAdvMapInt::setHeroSleeping(const CGHeroInstance *hero, bool sleep)
{ {
if (sleep) if (sleep)
LOCPLINT->sleepingHeroes += hero; LOCPLINT->sleepingHeroes.push_back(hero); //FIXME: should we check for existence?
else else
LOCPLINT->sleepingHeroes -= hero; LOCPLINT->sleepingHeroes -= hero;
updateNextHero(nullptr); updateNextHero(nullptr);

View File

@ -32,8 +32,6 @@
#include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CGHeroInstance.h"
#include "../../lib/mapObjects/CGTownInstance.h" #include "../../lib/mapObjects/CGTownInstance.h"
using namespace boost::assign;
/* /*
* CCastleInterface.cpp, part of VCMI engine * CCastleInterface.cpp, part of VCMI engine
* *
@ -1449,15 +1447,20 @@ CFortScreen::CFortScreen(const CGTownInstance * town):
exit = new CButton(Point(748, 556), "TPMAGE1", CButton::tooltip(text), [&]{ close(); }, SDLK_RETURN); exit = new CButton(Point(748, 556), "TPMAGE1", CButton::tooltip(text), [&]{ close(); }, SDLK_RETURN);
exit->assignedKeys.insert(SDLK_ESCAPE); exit->assignedKeys.insert(SDLK_ESCAPE);
std::vector<Point> positions; std::vector<Point> positions =
positions += Point(10, 22), Point(404, 22), {
Point(10, 155), Point(404,155), Point(10, 22), Point(404, 22),
Point(10, 288), Point(404,288); Point(10, 155), Point(404,155),
Point(10, 288), Point(404,288)
};
if (fortSize == GameConstants::CREATURES_PER_TOWN) if (fortSize == GameConstants::CREATURES_PER_TOWN)
positions += Point(206,421); positions.push_back(Point(206,421));
else else
positions += Point(10, 421), Point(404,421); {
positions.push_back(Point(10, 421));
positions.push_back(Point(404,421));
}
for (ui32 i=0; i<fortSize; i++) for (ui32 i=0; i<fortSize; i++)
{ {
@ -1658,14 +1661,14 @@ CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner,std::string imagem)
exit = new CButton(Point(748, 556), "TPMAGE1.DEF", CButton::tooltip(CGI->generaltexth->allTexts[593]), [&]{ close(); }, SDLK_RETURN); exit = new CButton(Point(748, 556), "TPMAGE1.DEF", CButton::tooltip(CGI->generaltexth->allTexts[593]), [&]{ close(); }, SDLK_RETURN);
exit->assignedKeys.insert(SDLK_ESCAPE); exit->assignedKeys.insert(SDLK_ESCAPE);
std::vector<std::vector<Point> > positions; static const std::vector<std::vector<Point> > positions =
{
positions.resize(5); {Point(222,445), Point(312,445), Point(402,445), Point(520,445), Point(610,445), Point(700,445)},
positions[0] += Point(222,445), Point(312,445), Point(402,445), Point(520,445), Point(610,445), Point(700,445); {Point(48,53), Point(48,147), Point(48,241), Point(48,335), Point(48,429)},
positions[1] += Point(48,53), Point(48,147), Point(48,241), Point(48,335), Point(48,429); {Point(570,82), Point(672,82), Point(570,157), Point(672,157)},
positions[2] += Point(570,82), Point(672,82), Point(570,157), Point(672,157); {Point(183,42), Point(183,148), Point(183,253)},
positions[3] += Point(183,42), Point(183,148), Point(183,253); {Point(491,325), Point(591,325)}
positions[4] += Point(491,325), Point(591,325); };
for(size_t i=0; i<owner->town->town->mageLevel; i++) for(size_t i=0; i<owner->town->town->mageLevel; i++)
{ {

View File

@ -39,7 +39,6 @@
* *
*/ */
using namespace boost::assign;
const TBonusListPtr CHeroWithMaybePickedArtifact::getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= nullptr*/, const std::string &cachingStr /*= ""*/) const const TBonusListPtr CHeroWithMaybePickedArtifact::getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= nullptr*/, const std::string &cachingStr /*= ""*/) const
{ {

View File

@ -471,8 +471,6 @@ std::vector<int> *CTradeWindow::getItemsIds(bool Left)
void CTradeWindow::getPositionsFor(std::vector<Rect> &poss, bool Left, EType type) const void CTradeWindow::getPositionsFor(std::vector<Rect> &poss, bool Left, EType type) const
{ {
using namespace boost::assign;
if(mode == EMarketMode::ARTIFACT_EXP && !Left) if(mode == EMarketMode::ARTIFACT_EXP && !Left)
{ {
//22 boxes, 5 in row, last row: two boxes centered //22 boxes, 5 in row, last row: two boxes centered
@ -484,10 +482,10 @@ void CTradeWindow::getPositionsFor(std::vector<Rect> &poss, bool Left, EType typ
dy = 70; dy = 70;
for (int i = 0; i < 4 ; i++) for (int i = 0; i < 4 ; i++)
for (int j = 0; j < 5 ; j++) for (int j = 0; j < 5 ; j++)
poss += Rect(x + dx*j, y + dy*i, w, h); poss.push_back(Rect(x + dx*j, y + dy*i, w, h));
poss += Rect(x + dx*1.5, y + dy*4, w, h); poss.push_back(Rect(x + dx*1.5, y + dy*4, w, h));
poss += Rect(x + dx*2.5, y + dy*4, w, h); poss.push_back(Rect(x + dx*2.5, y + dy*4, w, h));
} }
else else
{ {
@ -498,10 +496,15 @@ void CTradeWindow::getPositionsFor(std::vector<Rect> &poss, bool Left, EType typ
int h, w, x, y, dx, dy; int h, w, x, y, dx, dy;
int leftToRightOffset; int leftToRightOffset;
getBaseForPositions(type, dx, dy, x, y, h, w, !Left, leftToRightOffset); getBaseForPositions(type, dx, dy, x, y, h, w, !Left, leftToRightOffset);
poss += genRect(h, w, x, y), genRect(h, w, x + dx, y), genRect(h, w, x + 2*dx, y), const std::vector<Rect> tmp =
{
genRect(h, w, x, y), genRect(h, w, x + dx, y), genRect(h, w, x + 2*dx, y),
genRect(h, w, x, y + dy), genRect(h, w, x + dx, y + dy), genRect(h, w, x + 2*dx, y + dy), genRect(h, w, x, y + dy), genRect(h, w, x + dx, y + dy), genRect(h, w, x + 2*dx, y + dy),
genRect(h, w, x + dx, y + 2*dy); genRect(h, w, x + dx, y + 2*dy)
};
vstd::concatenate(poss, tmp);
if(!Left) if(!Left)
{ {

View File

@ -61,7 +61,6 @@
* *
*/ */
using namespace boost::assign;
using namespace CSDL_Ext; using namespace CSDL_Ext;
std::list<CFocusable*> CFocusable::focusables; std::list<CFocusable*> CFocusable::focusables;

View File

@ -23,8 +23,6 @@
#include "mapObjects/CObjectClassesHandler.h" #include "mapObjects/CObjectClassesHandler.h"
using namespace boost::assign;
// Note: list must match entries in ArtTraits.txt // Note: list must match entries in ArtTraits.txt
#define ART_POS_LIST \ #define ART_POS_LIST \
ART_POS(SPELLBOOK) \ ART_POS(SPELLBOOK) \
@ -277,13 +275,23 @@ ArtifactPosition CArtHandler::stringToSlot(std::string slotName)
void CArtHandler::addSlot(CArtifact * art, const std::string & slotID) void CArtHandler::addSlot(CArtifact * art, const std::string & slotID)
{ {
static const std::vector<ArtifactPosition> miscSlots =
{
ArtifactPosition::MISC1, ArtifactPosition::MISC2, ArtifactPosition::MISC3, ArtifactPosition::MISC4, ArtifactPosition::MISC5
};
static const std::vector<ArtifactPosition> ringSlots =
{
ArtifactPosition::LEFT_RING, ArtifactPosition::RIGHT_RING
};
if (slotID == "MISC") if (slotID == "MISC")
{ {
art->possibleSlots[ArtBearer::HERO] += ArtifactPosition::MISC1, ArtifactPosition::MISC2, ArtifactPosition::MISC3, ArtifactPosition::MISC4, ArtifactPosition::MISC5; vstd::concatenate(art->possibleSlots[ArtBearer::HERO], miscSlots);
} }
else if (slotID == "RING") else if (slotID == "RING")
{ {
art->possibleSlots[ArtBearer::HERO] += ArtifactPosition::LEFT_RING, ArtifactPosition::RIGHT_RING; vstd::concatenate(art->possibleSlots[ArtBearer::HERO], ringSlots);
} }
else else
{ {

View File

@ -14,7 +14,6 @@
BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set<BuildingID> builtBuildings ) BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set<BuildingID> builtBuildings )
{ {
using namespace boost::assign;
static const std::vector<BuildingID> campToERMU = static const std::vector<BuildingID> campToERMU =
{ {
BuildingID::TOWN_HALL, BuildingID::CITY_HALL, BuildingID::TOWN_HALL, BuildingID::CITY_HALL,

View File

@ -11,8 +11,6 @@
#include "mapObjects/CObjectClassesHandler.h" #include "mapObjects/CObjectClassesHandler.h"
using namespace boost::assign;
/* /*
* CCreatureHandler.cpp, part of VCMI engine * CCreatureHandler.cpp, part of VCMI engine
* *

View File

@ -26,8 +26,6 @@ namespace SpellConfig
} }
using namespace boost::assign;
namespace SRSLPraserHelpers namespace SRSLPraserHelpers
{ {
static int XYToHex(int x, int y) static int XYToHex(int x, int y)

View File

@ -16,8 +16,6 @@
#include "../CGeneralTextHandler.h" #include "../CGeneralTextHandler.h"
#include "../CGameState.h" #include "../CGameState.h"
using namespace boost::assign;
void CArmedInstance::randomizeArmy(int type) void CArmedInstance::randomizeArmy(int type)
{ {
for (auto & elem : stacks) for (auto & elem : stacks)

View File

@ -19,8 +19,6 @@
#include "../IGameCallback.h" #include "../IGameCallback.h"
#include "../CGameState.h" #include "../CGameState.h"
using namespace boost::assign;
///helpers ///helpers
static std::string & visitedTxt(const bool visited) static std::string & visitedTxt(const bool visited)
{ {

View File

@ -22,8 +22,6 @@
#include "../CGameState.h" #include "../CGameState.h"
#include "../CCreatureHandler.h" #include "../CCreatureHandler.h"
using namespace boost::assign;
///helpers ///helpers
static void showInfoDialog(const PlayerColor playerID, const ui32 txtID, const ui16 soundID) static void showInfoDialog(const PlayerColor playerID, const ui32 txtID, const ui16 soundID)
{ {
@ -1050,9 +1048,10 @@ int CGHeroInstance::getBoatType() const
void CGHeroInstance::getOutOffsets(std::vector<int3> &offsets) const void CGHeroInstance::getOutOffsets(std::vector<int3> &offsets) const
{ {
static int3 dirs[] = { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0), int3(1,1,0),int3(-1,1,0),int3(1,-1,0),int3(-1,-1,0) }; offsets =
for (auto & dir : dirs) {
offsets += dir; int3(0,1,0), int3(0,-1,0), int3(-1,0,0), int3(+1,0,0), int3(1,1,0), int3(-1,1,0), int3(1,-1,0), int3(-1,-1,0)
};
} }
int CGHeroInstance::getSpellCost(const CSpell *sp) const int CGHeroInstance::getSpellCost(const CSpell *sp) const
@ -1162,8 +1161,10 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills()
} }
if (!skillsInfo.magicSchoolCounter) if (!skillsInfo.magicSchoolCounter)
{ {
std::vector<SecondarySkill> ss; std::vector<SecondarySkill> ss =
ss += SecondarySkill::FIRE_MAGIC, SecondarySkill::AIR_MAGIC, SecondarySkill::WATER_MAGIC, SecondarySkill::EARTH_MAGIC; {
SecondarySkill::FIRE_MAGIC, SecondarySkill::AIR_MAGIC, SecondarySkill::WATER_MAGIC, SecondarySkill::EARTH_MAGIC
};
std::shuffle(ss.begin(), ss.end(), skillsInfo.rand.getStdGenerator()); std::shuffle(ss.begin(), ss.end(), skillsInfo.rand.getStdGenerator());

View File

@ -18,8 +18,6 @@
#include "../CCreatureHandler.h" #include "../CCreatureHandler.h"
#include "../CGameState.h" #include "../CGameState.h"
using namespace boost::assign;
///helpers ///helpers
static void openWindow(const OpenWindow::EWindow type, const int id1, const int id2 = -1) static void openWindow(const OpenWindow::EWindow type, const int id1, const int id2 = -1)
{ {

View File

@ -18,8 +18,6 @@
#include "../StartInfo.h" #include "../StartInfo.h"
#include "../IGameCallback.h" #include "../IGameCallback.h"
using namespace boost::assign;
///helpers ///helpers
static void showInfoDialog(const PlayerColor playerID, const ui32 txtID, const ui16 soundID) static void showInfoDialog(const PlayerColor playerID, const ui32 txtID, const ui16 soundID)
{ {

View File

@ -18,8 +18,6 @@
#include "../IGameCallback.h" #include "../IGameCallback.h"
#include "../CGameState.h" #include "../CGameState.h"
using namespace boost::assign;
std::vector<const CArtifact *> CGTownInstance::merchantArtifacts; std::vector<const CArtifact *> CGTownInstance::merchantArtifacts;
std::vector<int> CGTownInstance::universitySkills; std::vector<int> CGTownInstance::universitySkills;
@ -676,7 +674,7 @@ bool CGTownInstance::passableFor(PlayerColor color) const
void CGTownInstance::getOutOffsets( std::vector<int3> &offsets ) const void CGTownInstance::getOutOffsets( std::vector<int3> &offsets ) const
{ {
offsets += int3(-1,2,0), int3(-3,2,0); offsets = {int3(-1,2,0), int3(-3,2,0)};
} }
void CGTownInstance::removeCapitols (PlayerColor owner) const void CGTownInstance::removeCapitols (PlayerColor owner) const

View File

@ -205,7 +205,7 @@ public:
//int3 getSightCenter() const override; //"center" tile from which the sight distance is calculated //int3 getSightCenter() const override; //"center" tile from which the sight distance is calculated
int getSightRadious() const override; //returns sight distance int getSightRadious() const override; //returns sight distance
int getBoatType() const; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral int getBoatType() const; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral
void getOutOffsets(std::vector<int3> &offsets) const; //offsets to obj pos when we boat can be placed void getOutOffsets(std::vector<int3> &offsets) const; //offsets to obj pos when we boat can be placed. Parameter will be cleared
int getMarketEfficiency() const override; //=market count int getMarketEfficiency() const override; //=market count
bool allowsTrade(EMarketMode::EMarketMode mode) const; bool allowsTrade(EMarketMode::EMarketMode mode) const;
std::vector<int> availableItemsIds(EMarketMode::EMarketMode mode) const; std::vector<int> availableItemsIds(EMarketMode::EMarketMode mode) const;

View File

@ -21,8 +21,6 @@
#include "CObjectClassesHandler.h" #include "CObjectClassesHandler.h"
using namespace boost::assign;
IGameCallback * IObjectInterface::cb = nullptr; IGameCallback * IObjectInterface::cb = nullptr;
///helpers ///helpers

View File

@ -20,8 +20,6 @@
#include "../IGameCallback.h" #include "../IGameCallback.h"
#include "../CGameState.h" #include "../CGameState.h"
using namespace boost::assign;
std::map <PlayerColor, std::set <ui8> > CGKeys::playerKeyMap; std::map <PlayerColor, std::set <ui8> > CGKeys::playerKeyMap;
///helpers ///helpers

View File

@ -21,8 +21,6 @@
#include "../IGameCallback.h" #include "../IGameCallback.h"
#include "../CGameState.h" #include "../CGameState.h"
using namespace boost::assign;
std::map<Obj, std::map<int, std::vector<ObjectInstanceID> > > CGTeleport::objs; std::map<Obj, std::map<int, std::vector<ObjectInstanceID> > > CGTeleport::objs;
std::vector<std::pair<ObjectInstanceID, ObjectInstanceID> > CGTeleport::gates; std::vector<std::pair<ObjectInstanceID, ObjectInstanceID> > CGTeleport::gates;
std::map <si32, std::vector<ObjectInstanceID> > CGMagi::eyelist; std::map <si32, std::vector<ObjectInstanceID> > CGMagi::eyelist;
@ -1419,9 +1417,11 @@ void CGShipyard::getOutOffsets( std::vector<int3> &offsets ) const
// H J L K I // H J L K I
// A x S x B // A x S x B
// C E G F D // C E G F D
offsets += int3(-3,0,0), int3(1,0,0), //AB offsets = {
int3(-3,0,0), int3(1,0,0), //AB
int3(-3,1,0), int3(1,1,0), int3(-2,1,0), int3(0,1,0), int3(-1,1,0), //CDEFG int3(-3,1,0), int3(1,1,0), int3(-2,1,0), int3(0,1,0), int3(-1,1,0), //CDEFG
int3(-3,-1,0), int3(1,-1,0), int3(-2,-1,0), int3(0,-1,0), int3(-1,-1,0); //HIJKL int3(-3,-1,0), int3(1,-1,0), int3(-2,-1,0), int3(0,-1,0), int3(-1,-1,0) //HIJKL
};
} }
void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const