From 736af28c052bdafde830eda42531bf43a1e9772e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Fri, 23 Nov 2007 22:33:55 +0000 Subject: [PATCH] Working windmill, water wheel, mystical garden (not tested). Info windows. Minor changes. --- CAdvmapInterface.h | 4 +- CCallback.cpp | 39 ++++++++- CCallback.h | 2 + CGameInterface.h | 1 - CLua.cpp | 186 +++++++++++++++++++++++++++++------------ CLua.h | 26 +++--- CMT.cpp | 8 +- CMessage.cpp | 87 ++++++++++++------- CMessage.h | 1 + CPlayerInterface.cpp | 151 ++++++++++++++++++++++++++++++++- CPlayerInterface.h | 62 ++++++++++++-- CPreGame.cpp | Bin 122452 -> 122452 bytes CPreGame.h | 4 +- hch/CHeroHandler.cpp | 1 + hch/CHeroHandler.h | 4 +- hch/CLodHandler.cpp | 1 - hch/CObjectHandler.cpp | 9 +- hch/CObjectHandler.h | 3 +- map.h | 4 +- mapHandler.cpp | 1 + 20 files changed, 472 insertions(+), 122 deletions(-) diff --git a/CAdvmapInterface.h b/CAdvmapInterface.h index 79ef8e659..13c5145c3 100644 --- a/CAdvmapInterface.h +++ b/CAdvmapInterface.h @@ -93,14 +93,14 @@ public: void draw(); }; class CResourceBar - :public ClickableR, public CIntObject + :public ClickableR { SDL_Surface * bg; void clickRight(tribool down); void refresh(); }; class CDataBar - :public ClickableR, public CIntObject + :public ClickableR { SDL_Surface * bg; void clickRight(tribool down); diff --git a/CCallback.cpp b/CCallback.cpp index 143d96d1f..d775e45fd 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -38,6 +38,11 @@ void CCallback::newTurn() { //std::map::iterator i = gs->players.begin() ; gs->day++; + for (int i=0;iobjh->objInstances.size();i++) + { + if (CGI->objh->objInstances[i]->state) + CGI->objh->objInstances[i]->state->newTurn(); + } for ( std::map::iterator i=gs->players.begin() ; i!=gs->players.end();i++) { for (int j=0;j<(*i).second.heroes.size();j++) @@ -373,6 +378,37 @@ int CScriptCallback::getSelectedHero() ret = -1;; return ret; } +int CScriptCallback::getDate(int mode) +{ + int temp; + switch (mode) + { + case 0: + return gs->day; + break; + case 1: + temp = (gs->day)%7; + if (temp) + return temp; + else return 7; + break; + case 2: + temp = ((gs->day-1)/7)+1; + if (!(temp%4)) + return 4; + else + return (temp%4); + break; + case 3: + return ((gs->day-1)/28)+1; + break; + } + return 0; +} +void CScriptCallback::giveResource(int player, int which, int val) +{ + gs->players[player].resources[which]+=val; +} void CLuaCallback::registerFuncs(lua_State * L) { lua_newtable(L); @@ -397,7 +433,8 @@ void CLuaCallback::registerFuncs(lua_State * L) lua_setglobal(L, "vcmi"); -#undef REGISTER_C_FUNC(x) + #undef REGISTER_C_FUNC(x) + } int CLuaCallback::getPos(lua_State * L)//(CGObjectInstance * object); { diff --git a/CCallback.h b/CCallback.h index 9248b49b1..200b12e65 100644 --- a/CCallback.h +++ b/CCallback.h @@ -61,6 +61,8 @@ public: void showInfoDialog(int player, std::string text, std::vector * components); int getHeroOwner(int heroID); int getSelectedHero(); + int getDate(int mode=0); + void giveResource(int player, int which, int val); friend void initGameState(CGameInfo * cgi); }; class CLuaCallback : public CScriptCallback diff --git a/CGameInterface.h b/CGameInterface.h index a598bc291..6f4b858b4 100644 --- a/CGameInterface.h +++ b/CGameInterface.h @@ -5,7 +5,6 @@ BOOST_TRIBOOL_THIRD_STATE(outOfRange) using namespace boost::logic; -class CAdvMapInt; class CCallback; class CGlobalAI; class CGHeroInstance; diff --git a/CLua.cpp b/CLua.cpp index 8f566176d..79994fce6 100644 --- a/CLua.cpp +++ b/CLua.cpp @@ -15,6 +15,8 @@ #include "CCallback.h" #include "hch/CGeneralTextHandler.h" #include +#include "CPlayerInterface.h" +#pragma warning (disable : 4311) bool getGlobalFunc(lua_State * L, std::string fname) { unsigned int hash = lua_calchash(fname.c_str(), fname.size()); @@ -25,7 +27,7 @@ bool getGlobalFunc(lua_State * L, std::string fname) CObjectScript::CObjectScript() { - language == ESLan::UNDEF; + language = ESLan::UNDEF; //std::cout << "Tworze obiekt objectscript "<ID) + { + case 51: + w=0; + ot=80; + break; + case 23: + w=1; + ot=39; + break; + case 61: + w=2; + ot=100; + break; + case 32: + w=3; + ot=59; + break; + } if (!alreadyVisited) { switch (os->ID) @@ -206,36 +229,21 @@ void CVisitableOPH::onNAHeroVisit(CGObjectInstance *os, int heroID, bool already case 61: case 32: { - int w=0, ot=0; - switch(os->ID) - { - case 51: - w=0; - ot=80; - break; - case 23: - w=1; - ot=29; - break; - case 61: - w=2; - ot=100; - break; - case 32: - w=3; - ot=59; - break; - } cb->changePrimSkill(heroID,w,1); std::vector weko; - weko.push_back(new SComponent(SComponent::primskill,1,1)); - cb->showInfoDialog(cb->getHeroOwner(heroID),CGI->objh->advobtxt[ot],&weko); - for (int ii=0; iishowInfoDialog(cb->getHeroOwner(heroID),CGI->objh->advobtxt[ot],&weko); //TODO: maybe we have memory leak with these windows + //for (int ii=0; iishowInfoDialog(cb->getHeroOwner(heroID),CGI->objh->advobtxt[ot],&std::vector()); + } } std::vector CVisitableOPH::yourObjects() @@ -282,6 +290,104 @@ std::string CVisitableOPH::hoverText(CGObjectInstance *os) return CGI->objh->objects[os->defInfo->id].name + add; } +void CVisitableOPW::onNAHeroVisit(CGObjectInstance *os, int heroID, bool alreadyVisited) +{ + int mid; + switch (os->ID) + { + case 55: + mid = 92; + break; + case 112: + mid = 170; + break; + case 109: + mid = 164; + break; + } + if (alreadyVisited) + { + if (os->ID!=112) + mid++; + else + mid--; + cb->showInfoDialog(cb->getHeroOwner(heroID),CGI->objh->advobtxt[mid],&std::vector()); //TODO: maybe we have memory leak with these windows + } + else + { + int type, sub, val; + type = SComponent::resource; + switch (os->ID) + { + case 55: + if (rand()%2) + { + sub = 5; + val = 5; + } + else + { + sub = 6; + val = 500; + } + break; + case 112: + mid = 170; + sub = rand() % 6; + val = (rand() % 4) + 3; + break; + case 109: + mid = 164; + sub = 6; + if(cb->getDate(2)<2) + val = 500; + else + val = 1000; + } + SComponent * com = new SComponent((SComponent::Etype)type,sub,val); + std::vector weko; + weko.push_back(com); + cb->giveResource(cb->getHeroOwner(heroID),sub,val); + cb->showInfoDialog(cb->getHeroOwner(heroID),CGI->objh->advobtxt[mid],&weko); + visited[os] = true; + } +} +void CVisitableOPW::newTurn () +{ + if (cb->getDate(1)==1) + { + for (std::map::iterator i = visited.begin(); i != visited.end(); i++) + { + (*i).second = false; + } + } +} +void CVisitableOPW::newObject(CGObjectInstance *os) +{ + visited.insert(std::pair(os,false)); +} + +void CVisitableOPW::onHeroVisit(CGObjectInstance *os, int heroID) +{ + if(visited[os]) + onNAHeroVisit(os,heroID,true); + else + onNAHeroVisit(os,heroID,false); +} + +std::vector CVisitableOPW::yourObjects() //returns IDs of objects which are handled by script +{ + std::vector ret(3); + ret.push_back(55); //mystical garden + ret.push_back(112); //windmill + ret.push_back(109); //water wheel + return ret; +} + +std::string CVisitableOPW::hoverText(CGObjectInstance *os) +{ + return CGI->objh->objects[os->defInfo->id].name + " " + ( (visited[os]) ? (CGI->generaltexth->allTexts[352]) : (CGI->generaltexth->allTexts[353])) ; +} //std::string SComponent::getSubtitle() //{ @@ -292,30 +398,4 @@ std::string CVisitableOPH::hoverText(CGObjectInstance *os) //} //void SComponent::getDescription(Etype Type, int Subtype) //{ -//} -SComponent::SComponent(Etype Type, int Subtype, int Val) -{ - switch (Type) - { - case primskill: - description = CGI->generaltexth->arraytxt[2+Subtype]; - std::ostringstream oss; - oss << ((Val>0)?("+"):("-")) << Val << " " << CGI->heroh->pskillsn[Subtype]; - subtitle = oss.str(); - break; - } - type = Type; - subtype = Subtype; - val = Val; -} - -SDL_Surface * SComponent::getImg() -{ - switch (type) - { - case primskill: - return CGI->heroh->pskillsb[subtype].ourImages[0].bitmap; - break; - } - return NULL; -} \ No newline at end of file +//} \ No newline at end of file diff --git a/CLua.h b/CLua.h index 8bcf21885..2e9304df1 100644 --- a/CLua.h +++ b/CLua.h @@ -25,6 +25,8 @@ public: virtual void newObject(CGObjectInstance *os){}; virtual void onHeroVisit(CGObjectInstance *os, int heroID){}; virtual std::string hoverText(CGObjectInstance *os){return "";}; + virtual void newTurn (){}; + //TODO: implement functions below: virtual void equipArtefact(int HID, int AID, int slot, bool putOn){}; //putOn==0 means that artifact is taken off @@ -34,7 +36,6 @@ public: //virtual void mouseClick (down,left,screen?, pos??){}; virtual void heroLevelUp (int HID){}; //add possibility of changing available sec. skills - }; class CScript { @@ -100,19 +101,16 @@ class CVisitableOPH : public CCPPObjectScript //once per hero friend void initGameState(CGameInfo * cgi); }; -struct SComponent +class CVisitableOPW : public CCPPObjectScript //once per week { - enum Etype - { - primskill, secskill, resource, creature, artifact - } type; - int subtype; - int val; + CVisitableOPW(CScriptCallback * CB):CCPPObjectScript(CB){}; + std::map visited; + void onNAHeroVisit(CGObjectInstance *os, int heroID, bool alreadyVisited); + void newObject(CGObjectInstance *os); + void onHeroVisit(CGObjectInstance *os, int heroID); + std::vector yourObjects(); //returns IDs of objects which are handled by script + std::string hoverText(CGObjectInstance *os); + void newTurn (); - std::string description; //r-click - std::string subtitle; - - SComponent(Etype Type, int Subtype, int Val); - //SComponent(const & SComponent r); - SDL_Surface * getImg(); + friend void initGameState(CGameInfo * cgi); }; \ No newline at end of file diff --git a/CMT.cpp b/CMT.cpp index c1194baa7..8d693925a 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -218,7 +218,9 @@ void initGameState(CGameInfo * cgi) /****************************C++ OBJECT SCRIPTS************************************************/ std::map scripts; CScriptCallback * csc = new CScriptCallback(); + csc->gs = cgi->state; handleCPPObjS(&scripts,new CVisitableOPH(csc)); + handleCPPObjS(&scripts,new CVisitableOPW(csc)); //created map @@ -330,6 +332,8 @@ int _tmain(int argc, _TCHAR* argv[]) cgi->screenh = new CScreenHandler; cgi->screenh->initScreen(); + THC std::cout<<"Preparing first handlers: "<neutralColor = p;//gray //colors initialized + THC std::cout<<"Preparing players' colours: "<townh = new CTownHandler; cgi->townh->loadNames(); @@ -364,6 +369,7 @@ int _tmain(int argc, _TCHAR* argv[]) cgi->heroh = heroh; cgi->generaltexth = new CGeneralTextHandler; cgi->generaltexth->load(); + THC std::cout<<"Preparing more handlers: "<mush = mush; diff --git a/CMessage.cpp b/CMessage.cpp index bc20af7c6..21a754ac9 100644 --- a/CMessage.cpp +++ b/CMessage.cpp @@ -275,45 +275,76 @@ CInfoWindow * CMessage::genIWindow(std::string text, int player, int charperline { //TODO: support for more than one component CInfoWindow * ret = new CInfoWindow(); - - std::vector * brtext = breakText(text,32,true,true); - std::vector * brdtext = breakText(comps[0]->subtitle,12,true,true); + ret->components = comps; + //for (int i=0;i + std::vector * brtext = breakText(text,charperline,true,true); + std::vector * brdtext; + if (comps.size()) + brdtext = breakText(comps[0]->subtitle,12,true,true); + else + brdtext = NULL; std::vector > * txtg = drawText(brtext); std::pair txts = getMaxSizes(txtg); txts.second = txts.second - + 30 //space to first component - + comps[0]->getImg()->h - + brdtext->size() * 10 //subtitle //!!!!!!!!!!!!!!!!!!!! - + 20 // space between subtitle and button + ok->ourImages[0].bitmap->h //button - + 30; //after button + + 15 //after button + + 20; // space between subtitle and button + if (comps.size()) + txts.second = txts.second + + 30 //space to first component + + comps[0]->getImg()->h + + 5 //img <-> subtitle + + brdtext->size() * 10; //subtitle //!!!!!!!!!!!!!!!!!!!! ret->bitmap = drawBox1(txts.first+70,txts.second+70,0); ret->pos.h=ret->bitmap->h; ret->pos.w=ret->bitmap->w; + int curh = 30; //gorny margines + for (int i=0; isize();i++) + { + int lw=0; + for (int j=0;j<(*txtg)[i].size();j++) + lw+=(*txtg)[i][j]->w; + int pw = ret->bitmap->w/2; + //int pw = Tmar, ph = Lmar; + pw -= lw/2; - //for (int i=0; isize();i++) - //{ - // int lw=0; - // for (int j=0;j<(*txtg)[i].size();j++) - // lw+=(*txtg)[i][j]->w; - // int pw = ret->bitmap->w/2, ph = ret->bitmap->h/2; - // //int pw = Tmar, ph = Lmar; - // pw -= lw/2; - // ph -= (19*txtg->size())/2; + int tw = pw; + for (int j=0;j<(*txtg)[i].size();j++) //blit text + { + //std::stringstream n; + //n <<"temp_"<bitmap,n.str().c_str()); + blitAt((*txtg)[i][j],tw,curh+i*19,ret->bitmap); + tw+=(*txtg)[i][j]->w; + SDL_FreeSurface((*txtg)[i][j]); + } + } + curh += (19 * txtg->size()); //wys. tekstu - // int tw = pw; - // for (int j=0;j<(*txtg)[i].size();j++) - // { - // //std::stringstream n; - // //n <<"temp_"<bitmap); - // //SDL_SaveBMP(ret->bitmap,n.str().c_str()); - // tw+=(*txtg)[i][j]->w; - // SDL_FreeSurface((*txtg)[i][j]); - // } - //} + if (comps.size()) + { + curh += 30; + comps[0]->pos.x = (ret->bitmap->w/2) - ((comps[0]->getImg()->w)/2); + comps[0]->pos.y = curh; + blitAt(comps[0]->getImg(),comps[0]->pos.x,comps[0]->pos.y,ret->bitmap); + curh += comps[0]->getImg()->h + 5; //obrazek + przerwa + for (int i=0; isize();i++) //descr. + { + SDL_Surface * tesu = TTF_RenderText_Blended(GEOR13,(*brdtext)[i].c_str(),zwykly); + blitAt(tesu,((comps[0]->getImg()->w - tesu->w)/2)+comps[0]->pos.x,curh,ret->bitmap); + curh+=tesu->h; + SDL_FreeSurface(tesu); + } + } + curh += 20; //to buttton + + ret->okb.posr.x = (ret->bitmap->w/2) - (ret->okb.imgs[0][0]->w/2); + ret->okb.posr.y = curh; + ret->okb.show(); + curh+=ret->okb.imgs[0][0]->h; return ret; } diff --git a/CMessage.h b/CMessage.h index 6cb8b9ae0..8246d2894 100644 --- a/CMessage.h +++ b/CMessage.h @@ -13,6 +13,7 @@ class CDefHandler; struct SComponent; namespace NMessage { + extern CDefHandler * ok, *cancel; extern std::vector > piecesOfBox; //in colors of all players extern SDL_Surface * background ; } diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index a911b79b2..a01a39b7e 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -14,6 +14,7 @@ #include #include "hch/CHeroHandler.h" #include "SDL_framerate.h" +#include "hch/CGeneralTextHandler.h" using namespace CSDL_Ext; class OCM_HLP_CGIN @@ -24,11 +25,142 @@ public: return (*a.first)<(*b.first); } } ocmptwo_cgin ; +CInfoWindow::CInfoWindow() +:okb(NMessage::ok,NULL,&CInfoWindow::okClicked) +{ + okb.ourObj = this; + okb.delg = this; +} + +void CInfoWindow::okClicked(tribool down) +{ + if (!down) + close(); +} + +void CInfoWindow::close() +{ + for (int i=0;iremoveObjToBlit(this); + //delete this; + LOCPLINT->adventureInt->show(); +} +CInfoWindow::~CInfoWindow() +{ +} +SComponent::SComponent(Etype Type, int Subtype, int Val) +{ + std::ostringstream oss; + switch (Type) + { + case primskill: + description = CGI->generaltexth->arraytxt[2+Subtype]; + oss << ((Val>0)?("+"):("-")) << Val << " " << CGI->heroh->pskillsn[Subtype]; + subtitle = oss.str(); + break; + case resource: + //description = CGI->generaltexth->arraytxt[2+Subtype]; + std::ostringstream oss; + oss << Val; + subtitle = oss.str(); + break; + } + type = Type; + subtype = Subtype; + val = Val; + SDL_Surface * temp = getImg(); + pos.w = temp->w; + pos.h = temp->h; +} + +SDL_Surface * SComponent::getImg() +{ + switch (type) + { + case primskill: + return CGI->heroh->pskillsb->ourImages[subtype].bitmap; + break; + case resource: + return CGI->heroh->resources->ourImages[subtype].bitmap; + break; + } + return NULL; +} + +void SComponent::clickRight (tribool down) +{ + LOCPLINT->adventureInt->handleRightClick(description,down,this); +} +void SComponent::activate() +{ + ClickableR::activate(); +} +void SComponent::deactivate() +{ + ClickableR::deactivate(); +} CSimpleWindow::~CSimpleWindow() { if (bitmap) + { SDL_FreeSurface(bitmap); - bitmap=NULL; + bitmap=NULL; + } +} + +template CSCButton::CSCButton(CDefHandler * img, CIntObject * obj, void(T::*poin)(tribool), T* Delg) +{ + ourObj = obj; + delg = Delg; + func = poin; + imgs.resize(1); + for (int i =0; iourImages.size();i++) + { + imgs[0].push_back(img->ourImages[i].bitmap); + } + pos.w = imgs[0][0]->w; + pos.h = imgs[0][0]->h; + state = 0; +} +template void CSCButton::clickLeft (tribool down) +{ + if (down) + { + state=1; + } + else + { + state=0; + } + show(); + if (delg) + (delg->*func)(down); + pressedL=state; +} +template void CSCButton::activate() +{ + ClickableL::activate(); +} +template void CSCButton::deactivate() +{ + ClickableL::deactivate(); +} + +template void CSCButton::show() +{ + if (delg) + { + blitAt(imgs[curimg][state],posr.x,posr.y,delg->bitmap); + updateRect(&genRect(pos.h,pos.w,posr.x,posr.y),delg->bitmap); + } + else + { + CButtonBase::show(); + } } CButtonBase::CButtonBase() { @@ -1061,7 +1193,20 @@ void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, int adventureInt->infoBar.draw(); return; } -void CPlayerInterface::showInfoDialog(std::string text, std::vector components) +void CPlayerInterface::showInfoDialog(std::string text, std::vector & components) { - ; + adventureInt->hide(); + CInfoWindow * temp = CMessage::genIWindow(text,LOCPLINT->playerID,32,components); + LOCPLINT->objsToBlit.push_back(temp); + temp->pos.x=300-(temp->pos.w/2); + temp->pos.y=300-(temp->pos.h/2); + temp->okb.pos.x = temp->okb.posr.x + temp->pos.x; + temp->okb.pos.y = temp->okb.posr.y + temp->pos.y; + temp->okb.activate(); +} +void CPlayerInterface::removeObjToBlit(CSimpleWindow* obj) +{ + objsToBlit.erase + (std::find(objsToBlit.begin(),objsToBlit.end(),obj)); + //delete obj; } \ No newline at end of file diff --git a/CPlayerInterface.h b/CPlayerInterface.h index 7502a6b2c..c3a2fa016 100644 --- a/CPlayerInterface.h +++ b/CPlayerInterface.h @@ -10,7 +10,7 @@ class CDefHandler; struct HeroMoveDetails; class CDefEssential; class CGHeroInstance; -struct SComponent; +class CAdvMapInt; class CIntObject //interface object { public: @@ -25,19 +25,13 @@ public: CSimpleWindow():bitmap(NULL),owner(NULL){}; virtual ~CSimpleWindow(); }; -class CInfoWindow : public CSimpleWindow //text + comp. + ok button -{ -public: - std::vector components; - CInfoWindow(){}; -}; class CButtonBase : public virtual CIntObject //basic buttton class { public: int type; //advmapbutton=2 bool abs; bool active; - CIntObject * ourObj; + CIntObject * ourObj; // "owner" int state; std::vector< std::vector > imgs; int curimg; @@ -45,6 +39,7 @@ public: virtual void activate()=0; virtual void deactivate()=0; CButtonBase(); + virtual ~CButtonBase(){}; }; class ClickableL : public virtual CIntObject //for left-clicks { @@ -87,6 +82,54 @@ public: virtual void activate()=0; virtual void deactivate()=0; }; + +template class CSCButton: public CButtonBase, public ClickableL //prosty guzik, ktory tylko zmienia obrazek +{ +public: + int3 posr; //position in the bitmap + int state; + T* delg; + void(T::*func)(tribool); + CSCButton(CDefHandler * img, CIntObject * obj, void(T::*poin)(tribool), T* Delg=NULL); + void clickLeft (tribool down); + void activate(); + void deactivate(); + void show(); +}; + +class CInfoWindow : public CSimpleWindow //text + comp. + ok button +{ +public: + CSCButton okb; + std::vector components; + void okClicked(tribool down); + void close(); + CInfoWindow(); + ~CInfoWindow(); +}; + +class SComponent : public ClickableR +{ +public: + enum Etype + { + primskill, secskill, resource, creature, artifact + } type; + int subtype; + int val; + + std::string description; //r-click + std::string subtitle; + + SComponent(Etype Type, int Subtype, int Val); + //SComponent(const & SComponent r); + SDL_Surface * getImg(); + + void clickRight (tribool down); + void activate(); + void deactivate(); +}; + class CPlayerInterface : public CGameInterface { public: @@ -121,7 +164,8 @@ public: void handleEvent(SDL_Event * sEvent); void init(CCallback * CB); int3 repairScreenPos(int3 pos); - void showInfoDialog(std::string text, std::vector components); + void showInfoDialog(std::string text, std::vector & components); + void removeObjToBlit(CSimpleWindow* obj); CPlayerInterface(int Player, int serial); }; \ No newline at end of file diff --git a/CPreGame.cpp b/CPreGame.cpp index d6abc62d8fcc1b535e6c9d6d6b2fdba8dad587a3..20d12a5a0c43db9ed351b7b7ea4108e3fb18eec7 100644 GIT binary patch delta 20 ccmcbzhyBVP_6>HI81HI7-O34FKxHK#3;%G0BGw7$^ZZW diff --git a/CPreGame.h b/CPreGame.h index 8cee6562c..2ce78ce38 100644 --- a/CPreGame.h +++ b/CPreGame.h @@ -91,13 +91,13 @@ public: : Button(Pos,Fun,Imgs,Sel,gr),key(My){ourPoinGroup=gr;}; void select(bool on=true) {(*this).Button::select(on);ourPoinGroup->setYour(this);CPG->printRating();} }; -template class CPoinGroup :public CGroup +template class CPoinGroup :public CGroup { public: int * gdzie; //where (po polsku, bo by było słowo kluczowe :/) void setYour(IntSelBut * your){*gdzie=your->key;}; }; -template class CGroup +template class CGroup { public: Button * selected; diff --git a/hch/CHeroHandler.cpp b/hch/CHeroHandler.cpp index e173fceb6..c39de0d65 100644 --- a/hch/CHeroHandler.cpp +++ b/hch/CHeroHandler.cpp @@ -40,6 +40,7 @@ void CHeroHandler::loadPortraits() } of.close(); pskillsb = CGI->spriteh->giveDef("PSKILL.DEF"); + resources = CGI->spriteh->giveDef("RESOUR82.DEF"); std::string strs = CGI->bitmaph->getTextFile("PRISKILL.TXT"); int itr=0; diff --git a/hch/CHeroHandler.h b/hch/CHeroHandler.h index 4ff1dfc4e..bee82c9f8 100644 --- a/hch/CHeroHandler.h +++ b/hch/CHeroHandler.h @@ -69,7 +69,7 @@ public: unsigned int getTileCost(EterrainType & ttype, Eroad & rdtype, Eriver & rvtype); unsigned int getLowestCreatureSpeed(); unsigned int getAdditiveMoveBonus(); - unsigned float getMultiplicativeMoveBonus(); + float getMultiplicativeMoveBonus(); static int3 convertPosition(int3 src, bool toh3m); //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest int3 getPosition(bool h3m) const; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation' int getSightDistance() const; //returns sight distance of this hero @@ -89,7 +89,7 @@ public: std::vector heroes; //było nodrze std::vector heroClasses; std::vector flags1, flags2, flags3, flags4; //flags blitted on heroes when , - CDefHandler * pskillsb; //82x93 + CDefHandler * pskillsb, *resources; //82x93 std::vector pskillsn; unsigned int level(unsigned int experience); void loadHeroes(); diff --git a/hch/CLodHandler.cpp b/hch/CLodHandler.cpp index cb0796f3d..a4a0497d2 100644 --- a/hch/CLodHandler.cpp +++ b/hch/CLodHandler.cpp @@ -6,7 +6,6 @@ #include #include #include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations - int readNormalNr (int pos, int bytCon, unsigned char * str) { int ret=0; diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index b7d6b6017..9362d9698 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -8,6 +8,7 @@ #include "CDefObjInfoHandler.h" #include "../CLua.h" #include "CHeroHandler.h" +#include void CObjectHandler::loadObjects() { int ID=0; @@ -28,6 +29,8 @@ void CObjectHandler::loadObjects() while (itprintPriority==1 && defInfo->printPriority==0) + if(defInfo->printPriority==1 && cmp.defInfo->printPriority==0) return true; - if(defInfo->printPriority==1 && defInfo->printPriority==0) + if(cmp.defInfo->printPriority==1 && defInfo->printPriority==0) return false; if(this->pos.y); //*state = *right.state; //state = right.state; @@ -291,6 +295,7 @@ CGObjectInstance& CGObjectInstance::operator=(const CGObjectInstance & right) defInfo = right.defInfo; info = right.info; defObjInfoNumber = right.defObjInfoNumber; + blockVisit = right.blockVisit; //state = new CLuaObjectScript(); //*state = *right.state; tempOwner = right.tempOwner; diff --git a/hch/CObjectHandler.h b/hch/CObjectHandler.h index c2284374c..b4a319dd6 100644 --- a/hch/CObjectHandler.h +++ b/hch/CObjectHandler.h @@ -367,6 +367,7 @@ public: int defObjInfoNumber; int tempOwner; //uzywane dla szybkosci, skrypt ma obowiazek aktualizowac te zmienna + bool blockVisit; virtual bool isHero() const; int getOwner() const; @@ -405,7 +406,7 @@ public: unsigned int getTileCost(EterrainType & ttype, Eroad & rdtype, Eriver & rvtype); unsigned int getLowestCreatureSpeed(); unsigned int getAdditiveMoveBonus(); - unsigned float getMultiplicativeMoveBonus(); + float getMultiplicativeMoveBonus(); static int3 convertPosition(int3 src, bool toh3m); //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest int3 getPosition(bool h3m) const; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation' int getSightDistance() const; //returns sight distance of this hero diff --git a/map.h b/map.h index 859c6e137..47cea81d2 100644 --- a/map.h +++ b/map.h @@ -1,6 +1,6 @@ #ifndef MAPD_H #define MAPD_H - +#pragma warning (disable : 4482) #include #include #include "global.h" @@ -174,7 +174,7 @@ public: struct Mapa { Eformat version; // version of map Eformat - bool twoLevel; // if map has underground level + int twoLevel; // if map has underground level int difficulty; // 0 easy - 4 impossible int levelLimit; bool areAnyPLayers; // if there are any playable players on map diff --git a/mapHandler.cpp b/mapHandler.cpp index 85c2e88db..53c161e0d 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -1524,6 +1524,7 @@ std::string CMapHandler::getDefName(int id, int subid) if(CGI->dobjinfo->objs[i].type==id && CGI->dobjinfo->objs[i].subtype==subid) return CGI->dobjinfo->objs[i].defName; } + throw new std::exception("Def not found."); } bool CMapHandler::printObject(CGObjectInstance *obj)