From ae3fa69134383bcd5179255e824990ea7118bc5f Mon Sep 17 00:00:00 2001 From: mateuszb Date: Wed, 17 Jun 2009 16:46:16 +0000 Subject: [PATCH] * next part of exchange window * changed some CDefHandlers to CDefEssential (the second is less memory consuming) * minor changes --- client/CAdvmapInterface.cpp | 2 +- client/CBattleInterface.cpp | 4 +- client/CBitmapHandler.cpp | 2 +- client/CHeroWindow.cpp | 83 ++++++++----------------------------- client/CHeroWindow.h | 2 +- client/CSpellWindow.cpp | 6 +-- client/GUIClasses.cpp | 25 +++++++++++ client/Graphics.cpp | 38 ++++++++--------- client/Graphics.h | 24 +++++------ hch/CBuildingHandler.cpp | 4 +- hch/CDefObjInfoHandler.h | 4 +- hch/CMusicHandler.cpp | 4 +- mapHandler.cpp | 30 ++++++-------- mapHandler.h | 9 ++-- 14 files changed, 105 insertions(+), 132 deletions(-) diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp index dd73ef20a..201430b7a 100644 --- a/client/CAdvmapInterface.cpp +++ b/client/CAdvmapInterface.cpp @@ -1120,7 +1120,7 @@ CDefHandler * CInfoBar::getAnim(int mode) void CInfoBar::blitAnim(int mode)//0 - day, 1 - week { CDefHandler * anim = NULL; - std::stringstream txt; + std::ostringstream txt; anim = getAnim(mode); if(mode) //new week animation { diff --git a/client/CBattleInterface.cpp b/client/CBattleInterface.cpp index aa45dd776..fefb25c6b 100644 --- a/client/CBattleInterface.cpp +++ b/client/CBattleInterface.cpp @@ -584,7 +584,7 @@ void CBattleInterface::show(SDL_Surface * to) } SDL_BlitSurface(amountBG, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[curStackID]->pos.x + xAdd + pos.x, creAnims[curStackID]->pos.y + 260 + pos.y)); //blitting amount - std::stringstream ss; + std::ostringstream ss; ss< >::const_iterator it=br.casualties[step].begin(); it!=br.casualties[step].end(); ++it) { blitAt(graphics->smallImgs[it->first], xPos, yPos, background); - std::stringstream amount; + std::ostringstream amount; amount<second; CSDL_Ext::printAtMiddle(amount.str(), xPos+16, yPos + 42, GEOR13, zwykly, background); xPos += 42; diff --git a/client/CBitmapHandler.cpp b/client/CBitmapHandler.cpp index e1ab573dd..2e50cf465 100644 --- a/client/CBitmapHandler.cpp +++ b/client/CBitmapHandler.cpp @@ -73,7 +73,7 @@ void CPCXConv::convert() unsigned char add; int it=0; - std::stringstream out; + std::ostringstream out; fSize = readNormalNr(it,4,pcx);it+=4; bh.x = readNormalNr(it,4,pcx);it+=4; diff --git a/client/CHeroWindow.cpp b/client/CHeroWindow.cpp index 9bbf7c79b..7c8ca6654 100644 --- a/client/CHeroWindow.cpp +++ b/client/CHeroWindow.cpp @@ -84,7 +84,7 @@ CHeroWindow::CHeroWindow(int playerColor): } - flags = CDefHandler::giveDef("CREST58.DEF"); + flags = CDefHandler::giveDefEss("CREST58.DEF"); //areas portraitArea = new LRClickableAreaWText(); portraitArea->pos.x = pos.x+83; @@ -529,7 +529,7 @@ void CHeroWindow::redrawCurBack() CSDL_Ext::printAtMiddle(curHero->name, 190, 40, GEORXX, tytulowy, curBack); //printing hero's level - std::stringstream secondLine; + std::ostringstream secondLine; secondLine<<"Level "<level<<" "<type->heroClass->name; CSDL_Ext::printAtMiddle(secondLine.str(), 190, 66, TNRB16, zwykly, curBack); @@ -565,21 +565,12 @@ void CHeroWindow::redrawCurBack() delete toPrin; //printing primary skills' amounts - std::stringstream primarySkill1; - primarySkill1<getPrimSkillLevel(0); - CSDL_Ext::printAtMiddle(primarySkill1.str(), 53, 165, TNRB16, zwykly, curBack); - - std::stringstream primarySkill2; - primarySkill2<getPrimSkillLevel(1); - CSDL_Ext::printAtMiddle(primarySkill2.str(), 123, 165, TNRB16, zwykly, curBack); - - std::stringstream primarySkill3; - primarySkill3<getPrimSkillLevel(2); - CSDL_Ext::printAtMiddle(primarySkill3.str(), 193, 165, TNRB16, zwykly, curBack); - - std::stringstream primarySkill4; - primarySkill4<getPrimSkillLevel(3); - CSDL_Ext::printAtMiddle(primarySkill4.str(), 263, 165, TNRB16, zwykly, curBack); + for(int m=0; m<4; ++m) + { + std::ostringstream primarySkill; + primarySkill<getPrimSkillLevel(m); + CSDL_Ext::printAtMiddle(primarySkill.str(), 53 + 70 * m, 165, TNRB16, zwykly, curBack); + } blitAt(graphics->luck42->ourImages[curHero->getCurrentLuck()+3].bitmap, 239, 182, curBack); blitAt(graphics->morale42->ourImages[curHero->getCurrentMorale()+3].bitmap, 181, 182, curBack); @@ -613,53 +604,15 @@ void CHeroWindow::redrawCurBack() } //secondary skills - if(curHero->secSkills.size()>=1) + for(int g=1; g<=8; ++g) { - blitAt(graphics->abils44->ourImages[curHero->secSkills[0].first*3+3+curHero->secSkills[0].second-1].bitmap, 18, 276, curBack); - CSDL_Ext::printAt(CGI->generaltexth->levels[curHero->secSkills[0].second-1], 69, 279, GEOR13, zwykly, curBack); - CSDL_Ext::printAt(CGI->generaltexth->skillName[curHero->secSkills[0].first], 69, 299, GEOR13, zwykly, curBack); - } - if(curHero->secSkills.size()>=2) - { - blitAt(graphics->abils44->ourImages[curHero->secSkills[1].first*3+3+curHero->secSkills[1].second-1].bitmap, 161, 276, curBack); - CSDL_Ext::printAt(CGI->generaltexth->levels[curHero->secSkills[1].second-1], 213, 279, GEOR13, zwykly, curBack); - CSDL_Ext::printAt(CGI->generaltexth->skillName[curHero->secSkills[1].first], 213, 299, GEOR13, zwykly, curBack); - } - if(curHero->secSkills.size()>=3) - { - blitAt(graphics->abils44->ourImages[curHero->secSkills[2].first*3+3+curHero->secSkills[2].second-1].bitmap, 18, 324, curBack); - CSDL_Ext::printAt(CGI->generaltexth->levels[curHero->secSkills[2].second-1], 69, 327, GEOR13, zwykly, curBack); - CSDL_Ext::printAt(CGI->generaltexth->skillName[curHero->secSkills[2].first], 69, 347, GEOR13, zwykly, curBack); - } - if(curHero->secSkills.size()>=4) - { - blitAt(graphics->abils44->ourImages[curHero->secSkills[3].first*3+3+curHero->secSkills[3].second-1].bitmap, 161, 324, curBack); - CSDL_Ext::printAt(CGI->generaltexth->levels[curHero->secSkills[3].second-1], 213, 327, GEOR13, zwykly, curBack); - CSDL_Ext::printAt(CGI->generaltexth->skillName[curHero->secSkills[3].first], 213, 347, GEOR13, zwykly, curBack); - } - if(curHero->secSkills.size()>=5) - { - blitAt(graphics->abils44->ourImages[curHero->secSkills[4].first*3+3+curHero->secSkills[4].second-1].bitmap, 18, 372, curBack); - CSDL_Ext::printAt(CGI->generaltexth->levels[curHero->secSkills[4].second-1], 69, 375, GEOR13, zwykly, curBack); - CSDL_Ext::printAt(CGI->generaltexth->skillName[curHero->secSkills[4].first], 69, 395, GEOR13, zwykly, curBack); - } - if(curHero->secSkills.size()>=6) - { - blitAt(graphics->abils44->ourImages[curHero->secSkills[5].first*3+3+curHero->secSkills[5].second-1].bitmap, 161, 372, curBack); - CSDL_Ext::printAt(CGI->generaltexth->levels[curHero->secSkills[5].second-1], 213, 375, GEOR13, zwykly, curBack); - CSDL_Ext::printAt(CGI->generaltexth->skillName[curHero->secSkills[5].first], 213, 395, GEOR13, zwykly, curBack); - } - if(curHero->secSkills.size()>=7) - { - blitAt(graphics->abils44->ourImages[curHero->secSkills[6].first*3+3+curHero->secSkills[6].second-1].bitmap, 18, 420, curBack); - CSDL_Ext::printAt(CGI->generaltexth->levels[curHero->secSkills[6].second-1], 69, 423, GEOR13, zwykly, curBack); - CSDL_Ext::printAt(CGI->generaltexth->skillName[curHero->secSkills[6].first], 69, 443, GEOR13, zwykly, curBack); - } - if(curHero->secSkills.size()>=8) - { - blitAt(graphics->abils44->ourImages[curHero->secSkills[7].first*3+3+curHero->secSkills[7].second-1].bitmap, 161, 420, curBack); - CSDL_Ext::printAt(CGI->generaltexth->levels[curHero->secSkills[7].second-1], 213, 423, GEOR13, zwykly, curBack); - CSDL_Ext::printAt(CGI->generaltexth->skillName[curHero->secSkills[7].first], 213, 443, GEOR13, zwykly, curBack); + + if(curHero->secSkills.size()>=g) + { + blitAt(graphics->abils44->ourImages[curHero->secSkills[g-1].first*3+3+curHero->secSkills[g-1].second-1].bitmap, g%2 ? 18 : 161, 276 + 48 * ((g-1)/2), curBack); + CSDL_Ext::printAt(CGI->generaltexth->levels[curHero->secSkills[g-1].second-1], g%2 ? 69 : 213, 279 + 48 * ((g-1)/2), GEOR13, zwykly, curBack); + CSDL_Ext::printAt(CGI->generaltexth->skillName[curHero->secSkills[g-1].first], g%2 ? 69 : 213, 299 + 48 * ((g-1)/2), GEOR13, zwykly, curBack); + } } //printing special ability @@ -667,11 +620,11 @@ void CHeroWindow::redrawCurBack() //printing necessery texts CSDL_Ext::printAt(CGI->generaltexth->jktexts[6].substr(1, CGI->generaltexth->jktexts[6].size()-2), 69, 231, GEOR13, tytulowy, curBack); - std::stringstream expstr; + std::ostringstream expstr; expstr<exp; CSDL_Ext::printAt(expstr.str(), 69, 247, GEOR16, zwykly, curBack); CSDL_Ext::printAt(CGI->generaltexth->jktexts[7].substr(1, CGI->generaltexth->jktexts[7].size()-2), 212, 231, GEOR13, tytulowy, curBack); - std::stringstream manastr; + std::ostringstream manastr; manastr << curHero->mana << '/' << curHero->manaLimit(); CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack); } diff --git a/client/CHeroWindow.h b/client/CHeroWindow.h index 927297a15..4091bed0e 100644 --- a/client/CHeroWindow.h +++ b/client/CHeroWindow.h @@ -98,7 +98,7 @@ class CHeroWindow: public CWindowWithGarrison, public virtual CIntObject CStatusBar * ourBar; //heroWindow's statusBar //general graphics - CDefHandler *flags; + CDefEssential *flags; //buttons AdventureMapButton * gar4button; //splitting diff --git a/client/CSpellWindow.cpp b/client/CSpellWindow.cpp index fdce2b6fc..b23dd6f50 100644 --- a/client/CSpellWindow.cpp +++ b/client/CSpellWindow.cpp @@ -213,7 +213,7 @@ CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHer background = BitmapHandler::loadBitmap("SpelBack.bmp"); graphics->blueToPlayersAdv(background, myHero->tempOwner); - std::stringstream mana; + std::ostringstream mana; mana<mana; CSDL_Ext::printAtMiddle(mana.str(), 434, 425, GEOR16, tytulowy, background); @@ -452,7 +452,7 @@ void CSpellWindow::show(SDL_Surface *to) //printing lvl CSDL_Ext::printAtMiddle(CGI->generaltexth->allTexts[171 + CGI->spellh->spells[spellAreas[b]->mySpell].level], spellAreas[b]->pos.x + 39, spellAreas[b]->pos.y + 82, GEORM, zwykly, to); //printing cost - std::stringstream ss; + std::ostringstream ss; ss<generaltexth->allTexts[387]<<": "<spellh->spells[spellAreas[b]->mySpell].costs[bestslvl]; CSDL_Ext::printAtMiddle(ss.str(), spellAreas[b]->pos.x + 39, spellAreas[b]->pos.y + 94, GEORM, zwykly, to); @@ -652,7 +652,7 @@ void CSpellWindow::SpellArea::hover(bool on) { if(on) { - std::stringstream ss; + std::ostringstream ss; ss<spellh->spells[mySpell].name<<" ("<generaltexth->allTexts[171+CGI->spellh->spells[mySpell].level]<<")"; owner->statusBar->print(ss.str()); } diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index e07bd901c..167d82ade 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -3259,6 +3259,31 @@ CExchangeWindow::CExchangeWindow(si32 hero1, si32 hero2) //c-tor { blitAt(skilldef->ourImages[g].bitmap, genRect(32, 32, 385, 19 + 36 * g), bg); } + delete skilldef; + + const CGHeroInstance * curHero = NULL; + for(int b=0; b<2; ++b) + { + //choosing hero + if(b == 0) + curHero = hero1inst; + else if(b == 1) + curHero = hero2inst; + + //printing primary skills' amounts + for(int m=0; m<4; ++m) + { + std::ostringstream primarySkill; + primarySkill<getPrimSkillLevel(m); + CSDL_Ext::printAtMiddle(primarySkill.str(), 353 + 93 * b, 35 + 36 * m, TNRB16, zwykly, bg); + } + + //printing secondary skills + for(int m=0; msecSkills.size(); ++m) + { + blitAt(graphics->abils32->ourImages[curHero->secSkills[m].first * 3 + curHero->secSkills[m].second + 2].bitmap, genRect(32, 32, 32 + 36 * m + 454 * b, 88), bg); + } + } //printing portraits blitAt(graphics->portraitLarge[hero1inst->portrait], 257, 13, bg); diff --git a/client/Graphics.cpp b/client/Graphics.cpp index f92389f92..515a61159 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -190,7 +190,7 @@ void Graphics::initializeBattleGraphics() battleACToDef[ACid] = toAdd; } } - spellEffectsPics = CDefHandler::giveDef("SpellInt.def"); + spellEffectsPics = CDefHandler::giveDefEss("SpellInt.def"); } Graphics::Graphics() { @@ -212,7 +212,7 @@ Graphics::Graphics() tasks += GET_SURFACE(hInfo,"HEROQVBK.bmp"); tasks += GET_SURFACE(tInfo,"TOWNQVBK.bmp"); tasks += GET_SURFACE(heroInGarrison,"TOWNQKGH.bmp"); - tasks += GET_DEF(artDefs,"ARTIFACT.DEF"); + tasks += GET_DEF_ESS(artDefs,"ARTIFACT.DEF"); tasks += GET_DEF_ESS(forts,"ITMCLS.DEF"); tasks += GET_DEF_ESS(luck22,"ILCK22.DEF"); tasks += GET_DEF_ESS(luck30,"ILCK30.DEF"); @@ -224,19 +224,19 @@ Graphics::Graphics() tasks += GET_DEF_ESS(morale82,"IMRL82.DEF"); tasks += GET_DEF_ESS(halls,"ITMTLS.DEF"); tasks += GET_DEF_ESS(bigTownPic,"ITPT.DEF"); - tasks += GET_DEF(pskillsb,"PSKILL.DEF"); - tasks += GET_DEF(pskillsm,"PSKIL42.DEF"); - tasks += GET_DEF(resources,"RESOUR82.DEF"); - tasks += GET_DEF(un44,"UN44.DEF"); - tasks += GET_DEF(smallIcons,"ITPA.DEF"); - tasks += GET_DEF(resources32,"RESOURCE.DEF"); + tasks += GET_DEF_ESS(pskillsb,"PSKILL.DEF"); + tasks += GET_DEF_ESS(pskillsm,"PSKIL42.DEF"); + tasks += GET_DEF_ESS(resources,"RESOUR82.DEF"); + tasks += GET_DEF_ESS(un44,"UN44.DEF"); + tasks += GET_DEF_ESS(smallIcons,"ITPA.DEF"); + tasks += GET_DEF_ESS(resources32,"RESOURCE.DEF"); tasks += GET_DEF(smi,"CPRSMALL.DEF"); tasks += GET_DEF(smi2,"TWCRPORT.DEF"); - tasks += GET_DEF(flags,"CREST58.DEF"); - tasks += GET_DEF(abils32,"SECSK32.DEF"); - tasks += GET_DEF(abils44,"SECSKILL.DEF"); - tasks += GET_DEF(abils82,"SECSK82.DEF"); - tasks += GET_DEF(spellscr,"SPELLSCR.DEF"); + tasks += GET_DEF_ESS(flags,"CREST58.DEF"); + tasks += GET_DEF_ESS(abils32,"SECSK32.DEF"); + tasks += GET_DEF_ESS(abils44,"SECSKILL.DEF"); + tasks += GET_DEF_ESS(abils82,"SECSK82.DEF"); + tasks += GET_DEF_ESS(spellscr,"SPELLSCR.DEF"); std::ifstream ifs("config/cr_bgs.txt"); int id; @@ -300,10 +300,10 @@ void Graphics::loadHeroAnim() std::make_pair(2,14), std::make_pair(3,15); for(size_t i=0; iourImages[ff].bitmap); } - heroAnims[i]->alphaTransformed = true; } } -void Graphics::loadHeroFlags(std::pair Graphics::*, std::vector > &pr, bool mode) +void Graphics::loadHeroFlags(std::pair Graphics::*, std::vector > &pr, bool mode) { for(int i=0;i<8;i++) - (this->*pr.first).push_back(CDefHandler::giveDef(pr.second[i])); + (this->*pr.first).push_back(CDefHandler::giveDefEss(pr.second[i])); std::vector > rotations; //first - group number to be rotated1, second - group number after rotation1 rotations += std::make_pair(6,10), std::make_pair(7,11), std::make_pair(8,12); for(int q=0; q<8; ++q) @@ -413,7 +412,6 @@ void Graphics::loadHeroFlags(std::pair Graphics::*, s SDL_MapRGB((this->*pr.first)[q]->ourImages[ff].bitmap->format, 0, 255, 255) ); } - (this->*pr.first)[q]->alphaTransformed = true; } } @@ -421,7 +419,7 @@ void Graphics::loadHeroFlags() { using namespace boost::assign; timeHandler th; - std::pair Graphics::*, std::vector > pr[4]; + std::pair Graphics::*, std::vector > pr[4]; pr[0].first = &Graphics::flags1; pr[0].second+=("ABF01L.DEF"),("ABF01G.DEF"),("ABF01R.DEF"),("ABF01D.DEF"),("ABF01B.DEF"), ("ABF01P.DEF"),("ABF01W.DEF"),("ABF01K.DEF"); diff --git a/client/Graphics.h b/client/Graphics.h index 284797ff6..f3eb0f796 100644 --- a/client/Graphics.h +++ b/client/Graphics.h @@ -36,16 +36,16 @@ public: *halls, *forts, *bigTownPic; std::map heroWins; //hero_ID => infobox std::map townWins; //town_ID => infobox - CDefHandler * artDefs; //artifacts + CDefEssential * artDefs; //artifacts std::vector portraitSmall; //48x32 px portraits of heroes std::vector portraitLarge; //58x64 px portraits of heroes - std::vector flags1, flags2, flags3, flags4; //flags blitted on heroes when , - CDefHandler * pskillsb, *resources; //82x93 - CDefHandler * pskillsm; //42x42 - CDefHandler * un44; //many things - CDefHandler * smallIcons, *resources32; //resources 32x32 - CDefHandler * flags; - std::vector heroAnims; // [class id: 0 - 17] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing + std::vector flags1, flags2, flags3, flags4; //flags blitted on heroes when , + CDefEssential * pskillsb, *resources; //82x93 + CDefEssential * pskillsm; //42x42 + CDefEssential * un44; //many things + CDefEssential * smallIcons, *resources32; //resources 32x32 + CDefEssential * flags; + std::vector heroAnims; // [class id: 0 - 17] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing //creatures std::map smallImgs; //creature ID -> small 32x32 img of creature; //ID=-2 is for blank (black) img; -1 for the border std::map bigImgs; //creature ID -> big 58x64 img of creature; //ID=-2 is for blank (black) img; -1 for the border @@ -55,18 +55,18 @@ public: std::vector< std::vector< std::string > > battleBacks; //battleBacks[terType] - vector of possible names for certain terrain type std::vector< std::string > battleHeroes; //battleHeroes[hero type] - name of def that has hero animation for battle std::map< int, std::vector < std::string > > battleACToDef; //maps AC format to vector of appropriate def names - CDefHandler * spellEffectsPics; //bitmaps representing spells affecting a stack in battle + CDefEssential * spellEffectsPics; //bitmaps representing spells affecting a stack in battle std::vector guildBgs;// name of bitmaps with imgs for mage guild screen //abilities - CDefHandler * abils32, * abils44, * abils82; + CDefEssential * abils32, * abils44, * abils82; //spells - CDefHandler *spellscr; //spell on the scroll 83x61 + CDefEssential *spellscr; //spell on the scroll 83x61 //functions Graphics(); void initializeBattleGraphics(); void loadPaletteAndColors(); void loadHeroFlags(); - void loadHeroFlags(std::pair Graphics::*, std::vector > &pr, bool mode); + void loadHeroFlags(std::pair Graphics::*, std::vector > &pr, bool mode); void loadHeroAnim(); void loadHeroPortraits(); SDL_Surface * drawHeroInfoWin(const CGHeroInstance * curh); diff --git a/hch/CBuildingHandler.cpp b/hch/CBuildingHandler.cpp index eaa0de40a..09e11b6bc 100644 --- a/hch/CBuildingHandler.cpp +++ b/hch/CBuildingHandler.cpp @@ -27,7 +27,7 @@ static unsigned int readNr(std::string &in, int &it) if(last==in.size()) throw std::string("Cannot read number..."); - std::stringstream ss(in.substr(it,last-it)); + std::istringstream ss(in.substr(it,last-it)); it+=(1+last-it); ss >> last; return last; @@ -127,7 +127,7 @@ void CBuildingHandler::loadBuildings() while(it> last; (hall[tid].second)[j][box].push_back(last); diff --git a/hch/CDefObjInfoHandler.h b/hch/CDefObjInfoHandler.h index 1de927ef8..c7b08a660 100644 --- a/hch/CDefObjInfoHandler.h +++ b/hch/CDefObjInfoHandler.h @@ -14,7 +14,7 @@ * */ -class CDefHandler; +class CDefEssential; class CLodHandler; class DLL_EXPORT CGDefInfo { @@ -30,7 +30,7 @@ public: terrainMenu; //in which menus in map editor object will be showed si32 width, height; //tiles si32 type; //(0- ground, 1- towns, 2-creatures, 3- heroes, 4-artifacts, 5- resources) - CDefHandler * handler; + CDefEssential * handler; si32 printPriority; bool isVisitable(); bool operator<(const CGDefInfo& por) diff --git a/hch/CMusicHandler.cpp b/hch/CMusicHandler.cpp index f29025d45..8cce95c00 100644 --- a/hch/CMusicHandler.cpp +++ b/hch/CMusicHandler.cpp @@ -158,7 +158,7 @@ void CSoundHandler::initCreaturesSounds(std::vector &creatures) { std::string cname="", attack="", defend="", killed="", move="", shoot="", wince="", ext1="", ext2=""; - std::stringstream str(line); + std::istringstream str(line); str >> cname >> attack >> defend >> killed >> move >> shoot >> wince >> ext1 >> ext2; @@ -232,7 +232,7 @@ void CSoundHandler::initSpellsSounds(std::vector &spells) { int spellid; std::string soundfile=""; - std::stringstream str(line); + std::istringstream str(line); str >> spellid >> soundfile; diff --git a/mapHandler.cpp b/mapHandler.cpp index c7db55066..2617b4e5e 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -105,7 +105,6 @@ static void alphaTransformDef(CGDefInfo * defInfo) for(int yy=0;yyhandler->ourImages.size();yy++) { CSDL_Ext::alphaTransform(defInfo->handler->ourImages[yy].bitmap); - defInfo->handler->alphaTransformed = true; } SDL_FreeSurface(alphaTransSurf); } @@ -180,13 +179,13 @@ void CMapHandler::roadsRiverTerrainInit() { //initializing road's and river's DefHandlers - roadDefs.push_back(CDefHandler::giveDef("dirtrd.def")); - roadDefs.push_back(CDefHandler::giveDef("gravrd.def")); - roadDefs.push_back(CDefHandler::giveDef("cobbrd.def")); - staticRiverDefs.push_back(CDefHandler::giveDef("clrrvr.def")); - staticRiverDefs.push_back(CDefHandler::giveDef("icyrvr.def")); - staticRiverDefs.push_back(CDefHandler::giveDef("mudrvr.def")); - staticRiverDefs.push_back(CDefHandler::giveDef("lavrvr.def")); + roadDefs.push_back(CDefHandler::giveDefEss("dirtrd.def")); + roadDefs.push_back(CDefHandler::giveDefEss("gravrd.def")); + roadDefs.push_back(CDefHandler::giveDefEss("cobbrd.def")); + staticRiverDefs.push_back(CDefHandler::giveDefEss("clrrvr.def")); + staticRiverDefs.push_back(CDefHandler::giveDefEss("icyrvr.def")); + staticRiverDefs.push_back(CDefHandler::giveDefEss("mudrvr.def")); + staticRiverDefs.push_back(CDefHandler::giveDefEss("lavrvr.def")); for(size_t g=0; gourImages.size(); ++h) @@ -385,7 +384,7 @@ void CMapHandler::initObjectRects() { continue; } - CDefHandler * curd = map->objects[f]->defInfo->handler; + CDefEssential * curd = map->objects[f]->defInfo->handler; if(curd) { const SDL_Surface *bitmap = curd->ourImages[0].bitmap; @@ -437,7 +436,7 @@ static void processDef (CGDefInfo* def) { if(def->name.size()) { - def->handler = CDefHandler::giveDef(def->name); + def->handler = CDefHandler::giveDefEss(def->name); } else { @@ -457,13 +456,10 @@ static void processDef (CGDefInfo* def) } else if(def->id != HEROI_TYPE && def->id != TOWNI_TYPE) tlog3 << "\t\tMinor warning: lacking def info for " << def->id << " " << def->subid <<" " << def->name << std::endl; - if(!def->handler->alphaTransformed) + + for(size_t yy=0; yy < def->handler->ourImages.size(); ++yy) { - for(size_t yy=0; yy < def->handler->ourImages.size(); ++yy) - { - CSDL_Ext::alphaTransform(def->handler->ourImages[yy].bitmap); - def->handler->alphaTransformed = true; - } + CSDL_Ext::alphaTransform(def->handler->ourImages[yy].bitmap); } } void CMapHandler::initHeroDef(CGHeroInstance * h) @@ -1309,7 +1305,7 @@ bool CMapHandler::printObject(const CGObjectInstance *obj) bool CMapHandler::hideObject(const CGObjectInstance *obj) { - CDefHandler * curd = obj->defInfo->handler; + CDefEssential * curd = obj->defInfo->handler; if(!curd) return false; const SDL_Surface *bitmap = curd->ourImages[0].bitmap; for(int fx=0; fxw/32; ++fx) diff --git a/mapHandler.h b/mapHandler.h index 4656439f9..190f8b3c0 100644 --- a/mapHandler.h +++ b/mapHandler.h @@ -23,6 +23,7 @@ class CDefHandler; struct TerrainTile; struct SDL_Surface; struct SDL_Rect; +class CDefEssential; struct TerrainTile2 { @@ -105,11 +106,11 @@ public: CDefHandler * partialHide; //for For of War std::vector > terrainGraphics; // [terrain id] [view type] [rotation type] - std::vector roadDefs; - std::vector staticRiverDefs; - std::vector defs; + std::vector roadDefs; + std::vector staticRiverDefs; + std::vector defs; - std::map loadedDefs; //pointers to loaded defs (key is filename, uppercase) + std::map loadedDefs; //pointers to loaded defs (key is filename, uppercase) std::vector > > hideBitmap; //specifies number of graphic that should be used to fully hide a tile