diff --git a/CCastleInterface.cpp b/CCastleInterface.cpp index 005eb602c..5794376ef 100644 --- a/CCastleInterface.cpp +++ b/CCastleInterface.cpp @@ -34,6 +34,16 @@ std::string getBgName(int type) //TODO - co z tym zrobi throw new std::exception("std::string getBgName(int type): invalid type"); } } +class SORTHELP +{ +public: + bool operator () + (const boost::tuples::tuple *a , + const boost::tuples::tuple *b) + { + return (a->get<0>())<(b->get<0>()); + } +} srthlp ; CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate) { @@ -47,6 +57,28 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate) CSDL_Ext::blueToPlayersAdv(townInt,LOCPLINT->playerID); exit = new AdventureMapButton(CGI->townh->tcommands[8],"",&CCastleInterface::close,744,544,"TSBTNS.DEF",this,Activate); exit->bitmapOffset = 4; + + for (std::set::const_iterator i=town->builtBuildings.begin();i!=town->builtBuildings.end();i++) + { + if(CGI->townh->structures.find(town->subID) != CGI->townh->structures.end()) + { + if(CGI->townh->structures[town->subID].find(*i)!=CGI->townh->structures[town->subID].end()) + { + CDefHandler *b = CGI->spriteh->giveDef(CGI->townh->structures[town->subID][*i]->defName); + boost::tuples::tuple *t + = new boost::tuples::tuple + (*i,b,CGI->townh->structures[town->subID][*i],NULL,NULL); + //TODO: obwódki i pola + buildings.push_back(t); + } + else continue; + } + else + break; + } + + std::sort(buildings.begin(),buildings.end(),srthlp); + if(Activate) { activate(); @@ -62,6 +94,20 @@ CCastleInterface::~CCastleInterface() delete fort; delete bigTownPic; delete flag; + + for(int i=0;iget<1>()) + delete (buildings[i]->get<1>()); + //if (buildings[i]->get<2>()) + // delete (buildings[i]->get<2>()); + if (buildings[i]->get<3>()) + SDL_FreeSurface(buildings[i]->get<3>()); + if (buildings[i]->get<4>()) + SDL_FreeSurface(buildings[i]->get<4>()); + delete buildings[i]; + } + } void CCastleInterface::close() { @@ -145,6 +191,12 @@ void CCastleInterface::show() itoa(i->second.second,temp,10); CSDL_Ext::printTo(temp,305+(62*(i->first))+57,387+61,GEOR13,zwykly); } + + //blit buildings + for(int i=0;iget<1>()->ourImages[0].bitmap,buildings[i]->get<2>()->x,buildings[i]->get<2>()->y); + } } void CCastleInterface::activate() diff --git a/CCastleInterface.h b/CCastleInterface.h index 5e53c014e..bf85ee5f2 100644 --- a/CCastleInterface.h +++ b/CCastleInterface.h @@ -2,10 +2,14 @@ #include "global.h" #include "SDL.h" #include "CPlayerInterface.h" +#include "boost/tuple/tuple.hpp" class CGTownInstance; +class CTownHandler; +struct Structure; template class AdventureMapButton; -class CBuildingRect : public MotionInterested, public ClickableL, public ClickableR, public TimeInterested +class CBuildingRect : public MotionInterested, public ClickableL, public ClickableR//, public TimeInterested { + void activate(); void deactivate(); }; @@ -22,6 +26,8 @@ public: AdventureMapButton * exit; + std::vector *> buildings; //building id, building def, structure struct, border, filling + CCastleInterface(const CGTownInstance * Town, bool Activate=true); ~CCastleInterface(); void show(); diff --git a/config/buildings.txt b/config/buildings.txt new file mode 100644 index 000000000..b0a4c8911 --- /dev/null +++ b/config/buildings.txt @@ -0,0 +1,37 @@ +0 16 TBCSBLAK.def 213 251 +0 8 TBCSCAS2.def 478 66 +0 9 TBCSCAS3.def 478 37 +0 7 TBCSCSTL.def 595 66 +0 6 TBCSDOCK.def 478 134 +0 30 TBCSDW_0.def 304 92 +0 31 TBCSDW_1.def 360 130 +0 32 TBCSDW_2.def 363 130 +0 33 TBCSDW_3.def 176 101 +0 34 TBCSDW_4.def 563 211 +0 35 TBCSDW_5.def 174 190 +0 36 TBCSDW_6.def 303 0 +0 21 TBCSEXT0.def 384 193 +0 22 TBCSEXT1.def 0 198 +0 11 TBCSHAL2.def 0 176 +0 12 TBCSHAL3.def 0 164 +0 13 TBCSHAL4.def 0 154 +0 10 TBCSHALL.def 0 209 +0 26 TBCSHOLY.def 456 109 +0 18 TBCSHRD1.def 76 53 +0 19 TBCSHRD2.def 76 35 +0 1 TBCSMAG2.def 706 135 +0 2 TBCSMAG3.def 704 107 +0 3 TBCSMAG4.def 704 76 +0 0 TBCSMAGE.def 707 166 +0 14 TBCSMARK.def 413 264 +0 15 TBCSSILO.def 488 228 +0 17 TBCSSPEC.def 533 71 +0 5 TBCSTVRN.def 0 230 +0 37 TBCSUP_0.def 304 65 +0 38 TBCSUP_1.def 360 115 +0 39 TBCSUP_2.def 76 35 +0 40 TBCSUP_3.def 176 85 +0 41 TBCSUP_4.def 563 173 +0 42 TBCSUP_5.def 160 190 +0 43 TBCSUP_6.def 303 0 +0 20 TBCSBOAT.def 478 134 \ No newline at end of file diff --git a/hch/CAmbarCendamo.cpp b/hch/CAmbarCendamo.cpp index 2d3e8796d..fbf649667 100644 --- a/hch/CAmbarCendamo.cpp +++ b/hch/CAmbarCendamo.cpp @@ -519,6 +519,7 @@ void CAmbarCendamo::deh3m() //{ // vinya->bytes[v] = bufor[i++]; //} + std::transform(vinya->name.begin(),vinya->name.end(),vinya->name.begin(),(int(*)(int))toupper); std::vector::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(), vinya->name); if(pit == CGameInfo::mainObj->dobjinfo->objs.end()) @@ -2229,6 +2230,12 @@ void CAmbarCendamo::deh3m() } } + for(int ww=0; wwobjh->objInstances.size(); ++ww) + { + if (CGI->objh->objInstances[ww]->defObjInfoNumber==-1) + std::cout<objh->objInstances[ww]->ID<<"\t" << CGI->objh->objInstances[ww]->subID<<"\t"<objh->objInstances[ww]->defInfo->name<isVisitable() && defInfo->isVisitable()) return false; - if(defInfo->isOnDefList && !(cmp.defInfo->isOnDefList)) - return true; - if(cmp.defInfo->isOnDefList && !(defInfo->isOnDefList)) - return false; + //if(defInfo->isOnDefList && !(cmp.defInfo->isOnDefList)) + // return true; + //if(cmp.defInfo->isOnDefList && !(defInfo->isOnDefList)) + // return false; if(this->pos.x +#include #include "CGeneralTextHandler.h" CTownHandler::CTownHandler() { @@ -11,6 +11,7 @@ CTownHandler::CTownHandler() CTownHandler::~CTownHandler() { delete smallIcons; + //todo - delete structures info } void CTownHandler::loadNames() { @@ -42,8 +43,21 @@ void CTownHandler::loadNames() std::string tmp; CGeneralTextHandler::loadToIt(tmp, strs, itr, 3); tcommands.push_back(tmp); - } + + + std::ifstream of("config/buildings.txt"); + while(!of.eof()) + { + Structure *vinya = new Structure; + of >> vinya->townID; + of >> vinya->ID; + of >> vinya->defName; + of >> vinya->x; + of >> vinya->y; + structures[vinya->townID][vinya->ID] = vinya; + } + } SDL_Surface * CTownHandler::getPic(int ID, bool fort, bool builded) { diff --git a/hch/CTownHandler.h b/hch/CTownHandler.h index e6d182f5e..47ee4ee68 100644 --- a/hch/CTownHandler.h +++ b/hch/CTownHandler.h @@ -23,6 +23,12 @@ public: int typeID; }; +struct Structure +{ + std::string defName; + int ID, townID, x, y; +}; + class CTownHandler { CDefHandler * smallIcons; @@ -35,6 +41,9 @@ public: SDL_Surface * getPic(int ID, bool fort=true, bool builded=false); //ID=-1 - blank; -2 - border; -3 - random static int getTypeByDefName(std::string name); + std::map > structures; + + std::vector townInstances; };