diff --git a/client/CCastleInterface.cpp b/client/CCastleInterface.cpp index bda5b7884..1b913aede 100644 --- a/client/CCastleInterface.cpp +++ b/client/CCastleInterface.cpp @@ -149,13 +149,16 @@ void CBuildingRect::clickRight (tribool down) return; if((CSDL_Ext::SDL_GetPixel(area,LOCPLINT->current->motion.x-pos.x,LOCPLINT->current->motion.y-pos.y) != 0)) //na polu { + CBuilding *bld = CGI->buildh->buildings[str->townID][str->ID]; + assert(bld); + CInfoPopup *vinya = new CInfoPopup(); vinya->free = true; vinya->bitmap = CMessage::drawBoxTextBitmapSub (LOCPLINT->playerID, - CGI->buildh->buildings[str->townID][str->ID]->Description(), + bld->Description(), LOCPLINT->castleInt->bicons->ourImages[str->ID].bitmap, - CGI->buildh->buildings[str->townID][str->ID]->Name()); + bld->Name()); vinya->pos.x = screen->w/2 - vinya->bitmap->w/2; vinya->pos.y = screen->h/2 - vinya->bitmap->h/2; LOCPLINT->pushInt(vinya); @@ -551,11 +554,11 @@ void CCastleInterface::buildingClicked(int building) } case 5: //tavern { - std::vector h = LOCPLINT->cb->getAvailableHeroes(town); - CTavernWindow *tv = new CTavernWindow(h[0],h[1],"GOSSIP TEST"); - LOCPLINT->pushInt(tv); + enterTavern(); + break; } + //TODO: case 6: //shipyard case 7: case 8: case 9: //fort/citadel/castle { CFortScreen *fs = new CFortScreen(this); @@ -573,7 +576,7 @@ void CCastleInterface::buildingClicked(int building) } case 15: //resource silo { - LOCPLINT->showInfoDialog(CGI->buildh->buildings[town->subID][15]->description,std::vector(), soundBase::sound_todo); + LOCPLINT->showInfoDialog(CGI->buildh->buildings[town->subID][15]->Description(),std::vector(), soundBase::sound_todo); break; } case 16: //blacksmith @@ -595,6 +598,29 @@ void CCastleInterface::buildingClicked(int building) LOCPLINT->pushInt(new CBlacksmithDialog(possible,CArtHandler::convertMachineID(aid,false),aid,hero->id)); break; } + //TODO: case 17: //special 1 + //TODO: case 18: //basic horde 1 + //TODO: case 19: //upg horde 1 + //TODO: case 20: //ship at shipyard + //TODO: case 21: //special 2 + case 22: //special 3 + { + switch(town->subID) + { + case 0: //brotherhood of sword + enterTavern(); + break; + + default: + tlog4<<"This building isn't handled...\n"; + break; + } + break; + } + //TODO: case 23: //special 4 + //TODO: case 24: //basic horde 2 + //TODO: case 25: //upg horde 2 + //TODO: case 26: //grail default: tlog4<<"This building isn't handled...\n"; } @@ -907,6 +933,14 @@ void CCastleInterface::enterMageGuild() { LOCPLINT->pushInt(new CMageGuildScreen(this)); } + +void CCastleInterface::enterTavern() +{ + std::vector h = LOCPLINT->cb->getAvailableHeroes(town); + CTavernWindow *tv = new CTavernWindow(h[0],h[1],"GOSSIP TEST"); + LOCPLINT->pushInt(tv); +} + void CHallInterface::CBuildingBox::hover(bool on) { Hoverable::hover(on); @@ -1083,6 +1117,7 @@ void CHallInterface::close() void CHallInterface::show(SDL_Surface * to) { blitAt(bg,pos,to); + LOCPLINT->castleInt->statusbar->show(to); resdatabar->show(to); exit->show(to); for(int i=0; i<5; i++) diff --git a/client/CCastleInterface.h b/client/CCastleInterface.h index cf0d0b4bb..0b649c01c 100644 --- a/client/CCastleInterface.h +++ b/client/CCastleInterface.h @@ -101,6 +101,7 @@ public: void show(SDL_Surface * to); void showAll(SDL_Surface * to); void buildingClicked(int building); + void enterTavern(); void enterMageGuild(); CRecruitmentWindow * showRecruitmentWindow(int building); void enterHall(); diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index ab5be830d..d0536a617 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -630,6 +630,13 @@ CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free) pos.h = bitmap->h; pos.w = bitmap->w; } + +CInfoPopup::CInfoPopup(SDL_Surface *Bitmap, bool Free) +{ + free=Free; + bitmap=Bitmap; +} + void CInfoPopup::close() { if(free) @@ -975,7 +982,7 @@ void CStatusBar::print(const std::string & text) if(LOCPLINT->cingconsole->enteredText == "" || text == LOCPLINT->cingconsole->enteredText) //for appropriate support for in-game console { current=text; - show(screen); + show(LOCPLINT->topInt()==LOCPLINT->adventureInt ? screen : screen2); //if there are now windows opened, update statusbar on screen, else to cache surface } } @@ -1418,6 +1425,7 @@ void CTownList::mouseMoved (const SDL_MouseMotionEvent & sEvent) void CTownList::clickLeft(tribool down) { + SDL_Surface *dst = (LOCPLINT->topInt()==LOCPLINT->adventureInt ? screen : screen2); if (down) { /***************************ARROWS*****************************************/ @@ -1425,7 +1433,7 @@ void CTownList::clickLeft(tribool down) { if(from>0) { - blitAt(arrup->ourImages[1].bitmap,arrupp.x,arrupp.y); + blitAt(arrup->ourImages[1].bitmap,arrupp.x,arrupp.y,dst); pressed = true; } return; @@ -1434,7 +1442,7 @@ void CTownList::clickLeft(tribool down) { if(items.size()-from > SIZE) { - blitAt(arrdo->ourImages[1].bitmap,arrdop.x,arrdop.y); + blitAt(arrdo->ourImages[1].bitmap,arrdop.x,arrdop.y,dst); pressed = false; } return; @@ -1460,7 +1468,7 @@ void CTownList::clickLeft(tribool down) return; if (pressed) //up { - blitAt(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y); + blitAt(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y,dst); pressed = indeterminate; if (!down) { @@ -1468,12 +1476,12 @@ void CTownList::clickLeft(tribool down) if (from<0) from=0; - draw(screen2); + draw(dst); } } else if (!pressed) //down { - blitAt(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y); + blitAt(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y,dst); pressed = indeterminate; if (!down) { @@ -1481,7 +1489,7 @@ void CTownList::clickLeft(tribool down) //if (from + + + + @@ -371,11 +379,11 @@ > @@ -385,7 +393,7 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > + + + + generaltexth->buildings[tid][bid].second; tlog2 << "Warning: Cannot find description text for building " << bid << "for " << tid << "town.\n"; return ""; +} + +CBuilding::CBuilding( int TID, int BID ) +{ + tid = TID; + bid = BID; } \ No newline at end of file diff --git a/hch/CBuildingHandler.h b/hch/CBuildingHandler.h index 8f3299d0b..1ac9b5a12 100644 --- a/hch/CBuildingHandler.h +++ b/hch/CBuildingHandler.h @@ -18,8 +18,8 @@ class DLL_EXPORT CBuilding //a typical building encountered in every castle ;] { public: - int tid, bid; //town ID and structure ID - std::vector resources; + si32 tid, bid; //town ID and structure ID + std::vector resources; std::string name; std::string description; @@ -30,6 +30,7 @@ public: { h & tid & bid & resources & name & description; } + CBuilding(int TID = -1, int BID = -1); }; class DLL_EXPORT CBuildingHandler diff --git a/hch/CGeneralTextHandler.cpp b/hch/CGeneralTextHandler.cpp index 0263f4ff4..375a55093 100644 --- a/hch/CGeneralTextHandler.cpp +++ b/hch/CGeneralTextHandler.cpp @@ -160,6 +160,18 @@ void CGeneralTextHandler::load() } } + //remove prceeding / trailing whitespaces nad quoation marks from buildings descriptions + for(std::map > >::iterator i = buildings.begin(); i != buildings.end(); i++) + { + for(std::map >::iterator j = i->second.begin(); j != i->second.end(); j++) + { + std::string &str = j->second.second; + boost::algorithm::trim(str); + if(str[0] == '"' && str[str.size()-1] == '"') + str = str.substr(1,str.size()-2); + } + } + buf = bitmaph->getTextFile("TCOMMAND.TXT"); itr=0; while(itr::const_iterator i = artifWorn.begin(); i != artifWorn.end(); i++) + if(i->second == aid) + return i->first; + return -1; +} + int CGTownInstance::getSightRadious() const //returns sight distance { return 5; diff --git a/hch/CObjectHandler.h b/hch/CObjectHandler.h index 8280c28a7..2d33fe470 100644 --- a/hch/CObjectHandler.h +++ b/hch/CObjectHandler.h @@ -260,6 +260,7 @@ public: int maxMovePoints(bool onLand) const; ui32 getArtAtPos(ui16 pos) const; //-1 - no artifact const CArtifact * getArt(int pos) const; + si32 getArtPos(int aid) const; //looks for equipped artifact with given ID and returns its slot ID or -1 if none(if more than one such artifact lower ID is returned) int getSpellSecLevel(int spell) const; //returns level of secondary ability (fire, water, earth, air magic) known to this hero and applicable to given spell; -1 if error static int3 convertPosition(int3 src, bool toh3m); //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest double getHeroStrength() const; diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 3a911b6ba..b90f1d7c9 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -316,11 +316,31 @@ DLL_EXPORT void SetHeroArtifacts::applyGs( CGameState *gs ) if(!vstd::contains(h->artifWorn,i->first) || h->artifWorn[i->first] != i->second) equiped.push_back(i->second); + BOOST_FOREACH(ui32 id, equiped) + { + //if hero already had equipped at least one artifact of that type, don't give any new bonuses + if(h->getArtPos(id) >= 0) + continue; + + CArtifact &art = VLC->arth->artifacts[id]; + for(std::list::iterator i = art.bonuses.begin(); i != art.bonuses.end(); i++) + { + gained.push_back(&*i); + h->bonuses.push_back(*i); + } + } + + //update hero data h->artifacts = artifacts; h->artifWorn = artifWorn; + //remove bonus from unequipped artifact BOOST_FOREACH(ui32 id, unequiped) { + //if hero still has equipped at least one artifact of that type, don't remove bonuses + if(h->getArtPos(id) >= 0) + continue; + while(1) { std::list::iterator hlp = std::find_if(h->bonuses.begin(),h->bonuses.end(),boost::bind(HeroBonus::IsFrom,_1,HeroBonus::ARTIFACT,id)); @@ -335,16 +355,6 @@ DLL_EXPORT void SetHeroArtifacts::applyGs( CGameState *gs ) } } } - - BOOST_FOREACH(ui32 id, equiped) - { - CArtifact &art = VLC->arth->artifacts[id]; - for(std::list::iterator i = art.bonuses.begin(); i != art.bonuses.end(); i++) - { - gained.push_back(&*i); - h->bonuses.push_back(*i); - } - } } DLL_EXPORT void SetHeroArtifacts::setArtAtPos(ui16 pos, int art) diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp index 610c1deba..4f7129ab1 100644 --- a/lib/VCMI_Lib.cpp +++ b/lib/VCMI_Lib.cpp @@ -42,7 +42,10 @@ DLL_EXPORT void initDLL(CConsoleHandler *Console, std::ostream *Logfile) console = Console; logfile = Logfile; VLC = new LibClasses; - VLC->init(); + try + { + VLC->init(); + } HANDLE_EXCEPTION } DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode) diff --git a/lib/VCMI_lib.vcproj b/lib/VCMI_lib.vcproj index d5d6f34ce..aa4b8c7dc 100644 --- a/lib/VCMI_lib.vcproj +++ b/lib/VCMI_lib.vcproj @@ -282,10 +282,6 @@ RelativePath="..\hch\CDefObjInfoHandler.cpp" > - - @@ -318,10 +314,6 @@ RelativePath=".\IGameCallback.cpp" > - - @@ -369,7 +361,7 @@ > + + + + diff --git a/mapHandler.cpp b/mapHandler.cpp index c7a2a1e71..9a7495c51 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "mapHandler.h" -#include "SDL_Extensions.h" -#include "CGameInfo.h" +#include "client/SDL_Extensions.h" +#include "client/CGameInfo.h" #include #include "hch/CLodHandler.h" #include "hch/CDefObjInfoHandler.h"