mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
* partially done building bonus (campaigns)
* ERMU -> picture name mapping by Ivan (thanks)
This commit is contained in:
@@ -36,6 +36,9 @@
|
||||
#include <cstdlib>
|
||||
#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; g<sInfo.playerInfos.size(); ++g)
|
||||
{
|
||||
if (sInfo.playerInfos[g].human)
|
||||
{
|
||||
faction = sInfo.playerInfos[g].castle;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
assert(faction != -1);
|
||||
|
||||
static const std::string fracInfixes[F_NUMBER] = {"CS", "R", "T", "I", "N", "D", "s", "F", "E"};
|
||||
|
||||
//TODO; find appropriate faction number
|
||||
int faction = 0;
|
||||
std::string bldgBitmapName = "BO" + fracInfixes[faction] + bldgBitmaps[faction][bonDescs[i].info1] + ".BMP";
|
||||
std::string bldgBitmapName = CGI->buildh->ERMUtoPicture[faction][CBuildingHandler::campToERMU(bonDescs[i].info1, faction)];
|
||||
surfToDuplicate = BitmapHandler::loadBitmap(bldgBitmapName);
|
||||
|
||||
freeDuplicatedSurface = true;
|
||||
|
@@ -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)
|
||||
|
@@ -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 <set>
|
||||
@@ -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
|
||||
|
44
config/ERMU_to_picture.txt
Normal file
44
config/ERMU_to_picture.txt
Normal file
@@ -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
|
@@ -6,6 +6,9 @@
|
||||
#include "../lib/VCMI_Lib.h"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <assert.h>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
|
||||
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<ARRAY_COUNT(ERMUtoPicture); ++b)
|
||||
{
|
||||
std::string buf;
|
||||
etp >> 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<int> 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<int> 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
|
||||
}
|
||||
|
||||
|
@@ -38,13 +38,15 @@ class DLL_EXPORT CBuildingHandler
|
||||
public:
|
||||
std::map<int, std::map<int, CBuilding*> > buildings; ///< first int is the castle ID, second the building ID (in ERM-U format)
|
||||
std::map<int, std::pair<std::string,std::vector< std::vector< std::vector<int> > > > > hall; //map<castle ID, pair<hall bg name, std::vector< std::vector<building id> >[5]> - external vector is the vector of buildings in the row, internal is the list of buildings for the specific slot
|
||||
std::map<int, std::string> 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 <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & buildings & hall;
|
||||
h & buildings & hall & ERMUtoPicture;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1385,6 +1385,16 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
}
|
||||
//std::cout<<"\tRandomizing objects: "<<th.getDif()<<std::endl;
|
||||
|
||||
/*********creating players entries in gs****************************************/
|
||||
for (unsigned int i=0; i<scenarioOps->playerInfos.size();i++)
|
||||
{
|
||||
std::pair<int,PlayerState> 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;i<PLAYER_LIMIT;i++)
|
||||
{
|
||||
@@ -1428,15 +1438,6 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
||||
}
|
||||
}
|
||||
|
||||
/*********creating players entries in gs****************************************/
|
||||
for (unsigned int i=0; i<scenarioOps->playerInfos.size();i++)
|
||||
{
|
||||
std::pair<int,PlayerState> 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<int> 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; g<map->towns.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<ui8, PlayerState>::iterator k=players.begin(); k!=players.end(); ++k)
|
||||
{
|
||||
if(k->first==-1 || k->first==255)
|
||||
|
Reference in New Issue
Block a user