diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index 77cf7b07d..1a3860584 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -36,6 +36,9 @@ #include #include "CMessage.h" #include "../hch/CSpellHandler.h" /*for campaign bonuses*/ +#include "../hch/CArtHandler.h" /*for campaign bonuses*/ +#include "../hch/CBuildingHandler.h" /*for campaign bonuses*/ + /* * CPreGame.cpp, part of VCMI engine * @@ -2472,22 +2475,19 @@ void CBonusSelection::updateBonusSelection() break; case 2: //building { - static const std::string bldgBitmaps [1][39] = { - { //TODO: finish it; HAL1 means "it's a placeholder" - "HAL2", "HAL3", "HAL4", "CAS1", "CAS2", "CAS3", "TAV1", "BLAK", "MRK1", "MRK2", "HAL1", - "MAG1", "MAG2", "MAG3", "MAG4", "MAG5", "DOCK", "HOLY", "LITE", "CV1S", "TAV2", "HAL1" - "PIK1", "CRS1", "GR1", "SWD1", "MON1", "CV1", "ANG1", - "PIK2", "CRS2", "GR2", "SWD2", "MON2", "CV2", "ANG2", - "HAL1", "HAL1", "HAL1", "HAL1" + int faction = -1; + for (int g=0; gbuildh->ERMUtoPicture[faction][CBuildingHandler::campToERMU(bonDescs[i].info1, faction)]; surfToDuplicate = BitmapHandler::loadBitmap(bldgBitmapName); freeDuplicatedSurface = true; diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index 7e0917898..fc29a0579 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -4866,7 +4866,7 @@ void CArtPlace::showAll(SDL_Surface *to) } } -bool CArtPlace::fitsHere(const CArtifact * art) +bool CArtPlace::fitsHere(const CArtifact * art) const { // You can place 'no artifact' anywhere. if(!art) @@ -4884,6 +4884,11 @@ CArtPlace::~CArtPlace() deactivate(); } +bool CArtPlace::locked() const +{ + return ourArt && ourArt->id == 145; +} + void HoverableArea::hover (bool on) { if (on) diff --git a/client/GUIClasses.h b/client/GUIClasses.h index 75627c0fa..8c58a62b4 100644 --- a/client/GUIClasses.h +++ b/client/GUIClasses.h @@ -2,8 +2,6 @@ #define __GUICLASSES_H__ #include "../global.h" -#include "../hch/CArtHandler.h" -#include "SDL_framerate.h" #include "GUIBase.h" #include "FunctionList.h" #include @@ -27,6 +25,8 @@ * */ +class CBonusSystemNode; +class CArtifact; class CDefEssential; class AdventureMapButton; class CHighlightableButtonsGroup; @@ -836,7 +836,7 @@ class MoraleLuckBox : public LRClickableAreaWTextComp public: bool morale; //true if morale, false if luck - void set(const CBonusSystemNode*hero); + void set(const CBonusSystemNode* hero); void showAll(SDL_Surface * to); MoraleLuckBox(bool Morale); @@ -913,17 +913,12 @@ public: void activate(); void deactivate(); void showAll(SDL_Surface * to); - bool fitsHere (const CArtifact * art); //returns true if given artifact can be placed here + bool fitsHere (const CArtifact * art) const; //returns true if given artifact can be placed here bool locked () const; void userSelectedNo (); ~CArtPlace(); //d-tor }; -inline bool CArtPlace::locked () const -{ - return ourArt && ourArt->id == 145; -} - class CArtifactsOfHero : public CIntObject { CGHeroInstance * curHero; //local copy of hero on which we operate diff --git a/config/ERMU_to_picture.txt b/config/ERMU_to_picture.txt new file mode 100644 index 000000000..019742214 --- /dev/null +++ b/config/ERMU_to_picture.txt @@ -0,0 +1,44 @@ +BoCsMag1.pcx BoRMag1.pcx BoTGld1.pcx BoIMag1.pcx BoNmage1.pcx BoDmage1.pcx BoSmage1.pcx BoFmage1.pcx BoEgld1.pcx +BoCsMag2.pcx BoRMag2.pcx BoTGld2.pcx BoIMag2.pcx BoNmage2.pcx BoDmage2.pcx BoSmage2.pcx BoFmage2.pcx BoEgld2.pcx +BoCsMag3.pcx BoRMag3.pcx BoTGld3.pcx BoIMag3.pcx BoNmage3.pcx BoDmage3.pcx BoSmage3.pcx BoFmage3.pcx BoEgld3.pcx +BoCsMag4.pcx BoRMag4.pcx BoTGld4.pcx BoIMag4.pcx BoNmage4.pcx BoDmage4.pcx BoSmage4.pcx BoFmage4.pcx BoEgld4.pcx +BoCsMag5.pcx BoRMag5.pcx BoTGld5.pcx BoIMag5.pcx BoNmage5.pcx BoDmage5.pcx BoSmage5.pcx BoFmage5.pcx BoEgld5.pcx +BoCsTav1.pcx BoRTav.pcx BoTTav.pcx BoITav.pcx BoNtav.pcx BoDtav.pcx BoStav1.pcx BoFtav.pcx BoEtav.pcx +BoCsDock.pcx %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% BoFship.pcx BoEship.pcx +BoCsCas1.pcx BoRCas1.pcx BoTCas1.pcx BoICas1.pcx BoNcast1.pcx BoDcas1.pcx BoScas1.pcx BoFcast1.pcx BoEcast1.pcx +BoCsCas2.pcx BoRCas2.pcx BoTCas2.pcx BoICas2.pcx BoNcast2.pcx BoDcas2.pcx BoScas2.pcx BoFcast2.pcx BoEcast2.pcx +BoCsCas3.pcx BoRCas3.pcx BoTCas3.pcx BoICas3.pcx BoNcast3.pcx BoDcas3.pcx BoScas3.pcx BoFcast3.pcx BoEcast3.pcx +BoCsHal1.pcx BoRHal1.pcx BoTHal1.pcx BoIHal1.pcx BoNhall1.pcx BoDhall1.pcx BoShall1.pcx BoFhall1.pcx BoEhall1.pcx +BoCsHal2.pcx BoRHal2.pcx BoTHal2.pcx BoIHal2.pcx BoNhall2.pcx BoDhall2.pcx BoShall2.pcx BoFhall2.pcx BoEhall2.pcx +BoCsHal3.pcx BoRHal3.pcx BoTHal3.pcx BoIHal3.pcx BoNhall3.pcx BoDhall3.pcx BoShall3.pcx BoFhall3.pcx BoEhall3.pcx +BoCsHal4.pcx BoRHal4.pcx BoTHal4.pcx BoIHal4.pcx BoNhall4.pcx BoDhall4.pcx BoShall4.pcx BoFhall4.pcx BoEhall4.pcx +BoCsMrk1.pcx BoRMrk1.pcx BoTMark.pcx BoIMrk1.pcx BoNmark1.pcx BoDmark1.pcx BoSmrk1.pcx BoFmark1.pcx BoEmark1.pcx +BoCsMrk2.pcx BoRMrk2.pcx BoTMarkS.pcx BoIMrk2.pcx BoNmark2.pcx BoDmark2.pcx BoSmrk2.pcx BoFmark2.pcx BoEmarkS.pcx +BoCsBlak.pcx BoRAid.pcx BoTBlack.pcx BoIBlak.pcx BoNsmith.pcx BoDsmith.pcx BoSblak1.pcx BoFapoth.pcx BoEblack.pcx +BoCsLite.pcx BoRGar1.pcx BoTMarkA.pcx %no_pic_here% BoNshrod.pcx BoDmarkA.pcx BoSescap.pcx BoFcage.pcx BoEmarkA.pcx +BoCsGr1H.pcx BoRDwf1h.pcx BoTGa1H.pcx BoIImpH.pcx BoNskelH.pcx BoDtrogH.pcx BoSgob1h.pcx BoFgno1h.pcx BoDhrd1.pcx +BoCsGr2H.pcx BoRDwf2h.pcx BoTGa2h.pcx BoIImp2H.pcx %no_pic_here% %no_pic_here% BoSgob2h.pcx BoFgno2h.pcx BoDhrd2.pcx +%no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% +BoCsCv2S.pcx BoRGar2.pcx BoTCasW.pcx BoICasB.pcx BoNnecro.pcx BoDvort.pcx BoSmrk1c.pcx BoFcastD.pcx BoEuniv.pcx +BoCsTav2.pcx BoRDwf1t.pcx BoTGldL.pcx BoICasG.pcx BoNskelT.pcx BoDport.pcx BoSblak2.pcx BoFcastA.pcx %no_pic_here% +%no_pic_here% %no_pic_here% BoTGldW.pcx BoIMagO.pcx %no_pic_here% BoDacad.pcx BoSvahal.pcx %no_pic_here% %no_pic_here% +%no_pic_here% BoRTre1h.pcx %no_pic_here% BoIHndH.pcx %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% +%no_pic_here% BoRTre2h.pcx %no_pic_here% BoIHnd2H.pcx %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% +BoCsHoly.pcx BoRHoly.pcx BoTHoly.pcx BoIHoly.pcx BoNholyG.pcx BoDholy.pcx BoSholy.pcx BoFgrail.pcx BoEgrail.pcx +%no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% +%no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% +%no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% %no_pic_here% +BoCsPik1.pcx BoRCen1.pcx BoTGrem1.pcx BoIImp1.pcx BoNskel1.pcx BoDtrog1.pcx BoSgob1.pcx BoFgnol1.pcx BoEdn_0.pcx +BoCsCrs1.pcx BoRDwf1.pcx BoTGar1.pcx BoIGog1.pcx BoNzomb1.pcx BoDharp1.pcx BoSwolf1.pcx BoFlizr1.pcx BoEdn_1.pcx +BoCsGr1.pcx BoRElf1.pcx BoTGolm1.pcx BoIHnd1.pcx BoNwigh1.pcx BoDbeh1.pcx BoSorc1.pcx BoFfly1.pcx BoEdn_2.pcx +BoCsSwd1.pcx BoRPeg1.pcx BoTMag1.pcx BoIDmn1.pcx BoNvamp1.pcx BoDmedu1.pcx BoSogre1.pcx BoFbas1.pcx BoEdn_3.pcx +BoCsMon1.pcx BoRTre1.pcx BoTGen1.pcx BoIPit1.pcx BoNlich1.pcx BoDmino1.pcx BoSroc1.pcx BoFgorg1.pcx BoEdn_4.pcx +BoCsCv1.pcx BoRUni1.pcx BoTNaga1.pcx BoIEfr1.pcx BoNbkni1.pcx BoDmant1.pcx BoScyc1.pcx BoFwyvr1.pcx BoEdn_5.pcx +BoCsAng1.pcx BoRDra1.pcx BoTTit1.pcx BoIDvl1.pcx BoNbone1.pcx BoDdrag1.pcx BoSbeh1.pcx BoFhydr1.pcx BoEdn_6.pcx +BoCsPik2.pcx BoRCen2.pcx BoTGrem2.pcx BoIImp2.pcx BoNskel2.pcx BoDtrog2.pcx BoSgob2.pcx BoFgnol2.pcx BoEup_0.pcx +BoCsCrs2.pcx BoRDwf2.pcx BoTGar2.pcx BoIGog2.pcx BoNzomb2.pcx BoDharp2.pcx BoSwolf2.pcx BoFlizr2.pcx BoEup_1.pcx +BoCsGr2.pcx BoRElf2.pcx BoTGolm2.pcx BoIHnd2.pcx BoNwigh2.pcx BoDbeh2.pcx BoSorc2.pcx BoFfly2.pcx BoEup_2.pcx +BoCsSwd2.pcx BoRPeg2.pcx BoTMag2.pcx BoIDmn2.pcx BoNvamp2.pcx BoDmedu2.pcx BoSogre2.pcx BoFbas2.pcx BoEup_3.pcx +BoCsMon2.pcx BoRTre2.pcx BoTGen2.pcx BoIPit2.pcx BoNlich2.pcx BoDmino2.pcx BoSroc2.pcx BoFgorg2.pcx BoEup_4.pcx +BoCsCv2.pcx BoRUni2.pcx BoTNaga2.pcx BoIEfr2.pcx BoNbkni2.pcx BoDmant2.pcx BoScyc2.pcx BoFwyvr2.pcx BoEup_5.pcx +BoCsAng2.pcx BoRDra2.pcx BoTTit2.pcx BoIDvl2.pcx BoNbone2.pcx BoDdrag2.pcx BoSbeh2.pcx BoFhydr2.pcx BoEup_6.pcx \ No newline at end of file diff --git a/hch/CBuildingHandler.cpp b/hch/CBuildingHandler.cpp index 761f5c04b..eb5c26da8 100644 --- a/hch/CBuildingHandler.cpp +++ b/hch/CBuildingHandler.cpp @@ -6,6 +6,9 @@ #include "../lib/VCMI_Lib.h" #include #include +#include +#include + extern CLodHandler * bitmaph; /* @@ -141,6 +144,24 @@ void CBuildingHandler::loadBuildings() } } + //loading ERMU to picture + std::ifstream etp("config/ERMU_to_picture.txt"); + + assert(etp.is_open()); + + for(int g=0; g<44; ++g) + { + for (int b=0; b> buf; + ERMUtoPicture[b][g] = buf; + } + } + + etp.close(); + + } CBuildingHandler::~CBuildingHandler() @@ -177,3 +198,49 @@ CBuilding::CBuilding( int TID, int BID ) tid = TID; bid = BID; } + +int CBuildingHandler::campToERMU(int camp, int townType) +{ + using namespace boost::assign; + static const std::vector campToERMU = list_of(11)(12)(13)(7)(8)(9)(5)(16)(14)(15)(-1)(0)(1)(2)(3)(4) + (6)(26)(17)(21)(22)(23) + ; //creature generators with banks - handled separately + if (camp < campToERMU.size()) + { + return campToERMU[camp]; + } + + static const std::vector hordeLvlsPerTType[F_NUMBER] = {list_of(2), list_of(1), list_of(1)(4), list_of(0)(2), + list_of(0), list_of(0), list_of(0), list_of(0), list_of(0)}; + + int curPos = campToERMU.size(); + for (int i=0; i<7; ++i) + { + if(camp == curPos) //non-upgraded + return 30 + i; + curPos++; + if(camp == curPos) //upgraded + return 37 + i; + curPos++; + //horde building + if (vstd::contains(hordeLvlsPerTType[townType], i)) + { + if (camp == curPos) + { + if (hordeLvlsPerTType[townType][0] == i) + { + return 18; //or 19 - TODO + } + else + { + return 24; //or 25 - TODO + } + } + curPos++; + } + + } + assert(0); + return -1; //not found +} + diff --git a/hch/CBuildingHandler.h b/hch/CBuildingHandler.h index c970c3fbf..0ffe47217 100644 --- a/hch/CBuildingHandler.h +++ b/hch/CBuildingHandler.h @@ -38,13 +38,15 @@ class DLL_EXPORT CBuildingHandler public: std::map > buildings; ///< first int is the castle ID, second the building ID (in ERM-U format) std::map > > > > hall; //map >[5]> - external vector is the vector of buildings in the row, internal is the list of buildings for the specific slot + std::map ERMUtoPicture[F_NUMBER]; //maps building ID to it's picture's name for each town type void loadBuildings(); //main loader ~CBuildingHandler(); //d-tor + static int CBuildingHandler::campToERMU(int camp, int townType); template void serialize(Handler &h, const int version) { - h & buildings & hall; + h & buildings & hall & ERMUtoPicture; } }; diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index 2815851ad..9b4e015ff 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -1385,6 +1385,16 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) } //std::cout<<"\tRandomizing objects: "<playerInfos.size();i++) + { + std::pair ins(scenarioOps->playerInfos[i].color,PlayerState()); + ins.second.color=ins.first; + ins.second.serial=i; + ins.second.human = scenarioOps->playerInfos[i].human; + players.insert(ins); + } + /*********give starting hero****************************************/ for(int i=0;iplayerInfos.size();i++) - { - std::pair ins(scenarioOps->playerInfos[i].color,PlayerState()); - ins.second.color=ins.first; - ins.second.serial=i; - ins.second.human = scenarioOps->playerInfos[i].human; - players.insert(ins); - } /******************RESOURCES****************************************************/ std::vector startresAI, startresHuman; std::ifstream tis(DATA_DIR "/config/startres.txt"); @@ -1755,6 +1756,32 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed ) getPlayer(vti->getOwner())->towns.push_back(vti); } + //campaign bonuses for towns + if (si->mode == 2) + { + CScenarioTravel::STravelBonus chosenBonus = + campaign->camp->scenarios[si->whichMapInCampaign].travelOptions.bonusesToChoose[si->choosenCampaignBonus]; + + if (chosenBonus.type == 2) + { + for (int g=0; gtowns.size(); ++g) + { + PlayerState * owner = getPlayer(map->towns[g]->getOwner()); + PlayerInfo & pi = map->players[owner->color]; + + + if (owner->human && //human-owned + map->towns[g]->pos == pi.posOfMainTown) + { + map->towns[g]->builtBuildings.insert( + CBuildingHandler::campToERMU(chosenBonus.info1, map->towns[g]->alignment)); + break; + } + } + } + + } + for(std::map::iterator k=players.begin(); k!=players.end(); ++k) { if(k->first==-1 || k->first==255)