diff --git a/CGameInterface.h b/CGameInterface.h index 3c00e6372..1f6ffd32e 100644 --- a/CGameInterface.h +++ b/CGameInterface.h @@ -76,7 +76,7 @@ public: virtual void heroCreated(const CGHeroInstance*){}; virtual void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector &skills, boost::function &callback)=0; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id virtual void heroInGarrisonChange(const CGTownInstance *town){}; - virtual void heroKilled(const CGHeroInstance*){}; + //virtual void heroKilled(const CGHeroInstance*){}; virtual void heroMoved(const TryMoveHero & details){}; virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val){}; virtual void heroManaPointsChanged(const CGHeroInstance * hero){} //not called at the beginning of turn and after spell casts @@ -93,7 +93,7 @@ public: virtual void tileRevealed(const std::set &pos){}; virtual void newObject(const CGObjectInstance * obj){}; //eg. ship built in shipyard virtual void yourTurn(){}; - virtual void centerView (int3 pos){}; + virtual void centerView (int3 pos, int focusTime){}; virtual void availableCreaturesChanged(const CGDwelling *town){}; virtual void heroBonusChanged(const CGHeroInstance *hero, const HeroBonus &bonus, bool gain){};//if gain hero received bonus, else he lost it virtual void requestRealized(PackageApplied *pa){}; diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp index 65af446ec..86bc940b2 100644 --- a/client/CAdvmapInterface.cpp +++ b/client/CAdvmapInterface.cpp @@ -1463,6 +1463,8 @@ void CAdvMapInt::activate() } screenBuf = screen; LOCPLINT->statusbar = &statusbar; + activateMouseMove(); + kingOverview.activate(); underground.activate(); questlog.activate(); @@ -1483,7 +1485,9 @@ void CAdvMapInt::activate() } void CAdvMapInt::deactivate() { + deactivateMouseMove(); scrollingDir = 0; + CGI->curh->changeGraphic(0,0); kingOverview.deactivate(); underground.deactivate(); diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 597f65515..b304ad924 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1545,9 +1545,20 @@ void CPlayerInterface::newObject( const CGObjectInstance * obj ) } } -void CPlayerInterface::centerView (int3 pos) +void CPlayerInterface::centerView (int3 pos, int focusTime) { LOCPLINT->adventureInt->centerOn (pos); + if(focusTime) + { + bool activeAdv = (GH.topInt() == adventureInt && adventureInt->active); + if(activeAdv) + adventureInt->deactivate(); + + SDL_Delay(focusTime); + + if(activeAdv) + adventureInt->activate(); + } } void CPlayerInterface::objectRemoved( const CGObjectInstance *obj ) diff --git a/client/CPlayerInterface.h b/client/CPlayerInterface.h index b89719b3d..782d48019 100644 --- a/client/CPlayerInterface.h +++ b/client/CPlayerInterface.h @@ -157,7 +157,7 @@ public: void heroBonusChanged(const CGHeroInstance *hero, const HeroBonus &bonus, bool gain);//if gain hero received bonus, else he lost it void requestRealized(PackageApplied *pa); void heroExchangeStarted(si32 hero1, si32 hero2); - void centerView (int3 pos); + void centerView (int3 pos, int focusTime); void objectPropertyChanged(const SetObjectProperty * sop); void objectRemoved(const CGObjectInstance *obj); void serialize(COSer &h, const int version); //saving diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index 0ec6fda8a..779b80ffc 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -552,13 +552,7 @@ void OpenWindow::applyCl(CClient *cl) void CenterView::applyCl(CClient *cl) { - int3 pos = (cl->getObj(id))->pos; - INTERFACE_CALL_IF_PRESENT (player, centerView, pos); -} - -void TakeYourTime::applyCl(CClient *cl) -{ - SDL_Delay(time); + INTERFACE_CALL_IF_PRESENT (player, centerView, pos, focusTime); } void NewObject::applyCl(CClient *cl) diff --git a/hch/CHeroHandler.cpp b/hch/CHeroHandler.cpp index 5717d1f65..99a027dab 100644 --- a/hch/CHeroHandler.cpp +++ b/hch/CHeroHandler.cpp @@ -404,14 +404,14 @@ ui64 CHeroHandler::reqExp(unsigned int level) } else { - ui64 exp = expPerLevel[expPerLevel.size()-1]; - level-=(expPerLevel.size()-1); - while(level>0) - { - --level; - exp*=1.2; - } - return exp; + //ui64 exp = expPerLevel[expPerLevel.size()-1]; + //level-=(expPerLevel.size()-1); + //while(level>0) + //{ + // --level; + // exp*=1.2; + //} + //return exp; return reqExp(level - 1) + (reqExp(level - 1) - reqExp(level - 2)) * 1.2; //inefficient but follows exactly H3 values } } diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index 97721469b..efb673d05 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -39,24 +39,8 @@ DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mod extern CLodHandler * bitmaph; extern boost::rand48 ran; std::map > CGKeys::playerKeyMap; -std::map > CGMagi::eyelist; -std::map > banksInfo; //[index][preset], TODO: load it +std::map > CGMagi::eyelist; -struct BankConfig -{ - BankConfig() {chance = upgradeChance = combatValue = value = rewardDifficulty = easiest = 0; }; - //std::string name; - ui8 chance; - ui8 upgradeChance; - std::vector< std::pair > guards; - ui32 combatValue; - std::map resources; - std::vector< std::pair > creatures; - std::map artifacts; - ui32 value; - ui32 rewardDifficulty; //? - ui16 easiest; //? -}; void IObjectInterface::onHeroVisit(const CGHeroInstance * h) const {}; @@ -92,22 +76,25 @@ bool CPlayersVisited::hasVisited( ui8 player ) const void CObjectHandler::loadObjects() { - tlog5 << "\t\tReading cregens \n"; - cregens.resize(110); //TODO: hardcoded value - change - for(size_t i=0; i < cregens.size(); ++i) { - cregens[i]=-1; + tlog5 << "\t\tReading cregens \n"; + cregens.resize(110); //TODO: hardcoded value - change + for(size_t i=0; i < cregens.size(); ++i) + { + cregens[i]=-1; + } + std::ifstream ifs("config/cregens.txt"); + while(!ifs.eof()) + { + int dw, cr; + ifs >> dw >> cr; + cregens[dw]=cr; + } + tlog5 << "\t\tDone loading objects!\n"; } - std::ifstream ifs("config/cregens.txt"); - while(!ifs.eof()) - { - int dw, cr; - ifs >> dw >> cr; - cregens[dw]=cr; - } - ifs.close(); - ifs.clear(); - tlog5 << "\t\tDone loading objects!\n"; + + std::string banksConfig = bitmaph->getTextFile("ZCRBANK.TXT"); + //TODO: parse to banksInfo } int CGObjectInstance::getOwner() const { @@ -3429,6 +3416,16 @@ void CGOnceVisitable::searchTomb(const CGHeroInstance *h, ui32 accept) const iw.text.addReplacement(MetaString::ART_NAMES, bonusType); cb->giveHeroArtifact(bonusType,h->id,-2); + } + + if(!h->getBonus(HeroBonus::OBJECT,ID)) //we don't have modifier from this object yet + { + //ruin morale + GiveBonus gb; + gb.hid = h->id; + gb.bonus = HeroBonus(HeroBonus::ONE_BATTLE,HeroBonus::MORALE,HeroBonus::OBJECT,-3,id,""); + gb.bdescr.addTxt(MetaString::ARRAY_TXT,104); //Warrior Tomb Visited -3 + cb->giveHeroBonus(&gb); } } } @@ -3458,9 +3455,9 @@ void CBank::reset() int val1 = ran()%100; int chance = 0; - for (ui8 i = 1; i <= banksInfo[index].size(); i++) + for (ui8 i = 1; i <= VLC->objh->banksInfo[index].size(); i++) { - if (val1 < (chance += banksInfo[index][i].chance)) + if (val1 < (chance += VLC->objh->banksInfo[index][i].chance)) cb->setObjProperty (id, 13, i); } artifacts.clear(); @@ -3482,7 +3479,7 @@ void CBank::setPropertyDer (ui8 what, ui32 val) multiplier *= ((float)val)/100; break; case 13: //bank preset - bc = &banksInfo[index][val]; + bc = &VLC->objh->banksInfo[index][val]; break; case 18: //Artifacts { @@ -3752,7 +3749,7 @@ void CGMagi::initObj() if (ID == 27) { blockVisit = true; - eyelist[subID].push_back (*this); + eyelist[subID].push_back(id); } } void CGMagi::onHeroVisit(const CGHeroInstance * h) const @@ -3770,18 +3767,18 @@ void CGMagi::onHeroVisit(const CGHeroInstance * h) const cb->showInfoDialog(&iw); fw.mode = 1; - TakeYourTime tyt; - std::vector::iterator it; - for (it = eyelist[subID].begin() ; it < eyelist[subID].end(); it++) - { - cb->getTilesInRange (fw.tiles, it->pos, 5, h->tempOwner, 1); + std::vector::iterator it; + for (it = eyelist[subID].begin(); it < eyelist[subID].end(); it++) + { + const CGObjectInstance *eye = cb->getObj(*it); + + cb->getTilesInRange (fw.tiles, eye->pos, 5, h->tempOwner, 1); cb->sendAndApply(&fw); - cv.id = it->id; + cv.pos = eye->pos; + cv.focusTime = 2000; cb->sendAndApply(&cv); - tyt.time = 2000; - cb->sendAndApply(&tyt); } - cv.id = h->id; + cv.pos = h->getPosition(false); cb->sendAndApply(&cv); } else if (ID == 27) diff --git a/hch/CObjectHandler.h b/hch/CObjectHandler.h index 68201549c..602b32b1e 100644 --- a/hch/CObjectHandler.h +++ b/hch/CObjectHandler.h @@ -879,24 +879,10 @@ public: void onHeroVisit(const CGHeroInstance * h) const; }; -class DLL_EXPORT CObjectHandler -{ -public: - std::vector cregens; //type 17. dwelling subid -> creature ID - void loadObjects(); - - template void serialize(Handler &h, const int version) - { - h & cregens; - } -}; - - - class DLL_EXPORT CGMagi : public CGObjectInstance { public: - static std::map > eyelist; //[subID][id], supports multiple sets as in H5 + static std::map > eyelist; //[subID][id], supports multiple sets as in H5 void initObj(); void onHeroVisit(const CGHeroInstance * h) const; @@ -906,4 +892,44 @@ public: h & static_cast(*this); } }; + + + +struct BankConfig +{ + BankConfig() {chance = upgradeChance = combatValue = value = rewardDifficulty = easiest = 0; }; + //std::string name; + ui8 chance; + ui8 upgradeChance; + std::vector< std::pair > guards; + ui32 combatValue; + std::map resources; + std::vector< std::pair > creatures; + std::map artifacts; + ui32 value; + ui32 rewardDifficulty; //? + ui16 easiest; //? + + template void serialize(Handler &h, const int version) + { + h & chance & upgradeChance & guards & combatValue & resources & creatures & artifacts + & value & rewardDifficulty & easiest; + } +}; + +class DLL_EXPORT CObjectHandler +{ +public: + std::vector cregens; //type 17. dwelling subid -> creature ID + std::map > banksInfo; //[index][preset], TODO: load it + + void loadObjects(); + + template void serialize(Handler &h, const int version) + { + h & cregens & banksInfo; + } +}; + + #endif // __COBJECTHANDLER_H__ diff --git a/lib/NetPacks.h b/lib/NetPacks.h index c59c62053..d4f6d5e7b 100644 --- a/lib/NetPacks.h +++ b/lib/NetPacks.h @@ -1296,35 +1296,18 @@ struct SetSelection : public CPackForClient, public CPackForServer //514 } }; -struct TakeYourTime : public CPackForClient//515 +struct CenterView : public CPackForClient//515 { - TakeYourTime(){CPackForClient::type = 515;}; - DLL_EXPORT void applyGs(CGameState *gs); + CenterView(){CPackForClient::type = 515;}; void applyCl(CClient *cl); - bool applyGh(CGameHandler *gh); ui8 player; - ui32 time; + int3 pos; + ui32 focusTime; //ms template void serialize(Handler &h, const int version) { - h & time & player; - } -}; - -struct CenterView : public CPackForClient//516 -{ - CenterView(){CPackForClient::type = 516;}; - DLL_EXPORT void applyGs(CGameState *gs); - void applyCl(CClient *cl); - bool applyGh(CGameHandler *gh); - - ui8 player; - si32 id; - - template void serialize(Handler &h, const int version) - { - h & id & player; + h & pos & player & focusTime; } }; diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 103db7e6b..06421082b 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -1004,13 +1004,4 @@ DLL_EXPORT void YourTurn::applyGs( CGameState *gs ) DLL_EXPORT void SetSelection::applyGs( CGameState *gs ) { gs->getPlayer(player)->currentSelection = id; -} - -DLL_EXPORT void CenterView::applyGs( CGameState *gs ) -{ - gs->getPlayer(player)->currentSelection = id; -} - -DLL_EXPORT void TakeYourTime::applyGs( CGameState *gs ) -{ -} +} \ No newline at end of file diff --git a/lib/RegisterTypes.cpp b/lib/RegisterTypes.cpp index cd59d6228..b112d4b6d 100644 --- a/lib/RegisterTypes.cpp +++ b/lib/RegisterTypes.cpp @@ -110,7 +110,6 @@ void registerTypes2(Serializer &s) s.template registerType(); s.template registerType(); s.template registerType(); - s.template registerType(); s.template registerType(); }