From b53c01ab920c8da31ad7db2f8f71f195c9bddbc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sun, 1 Jun 2008 13:42:29 +0000 Subject: [PATCH] * fixed estate problems (#57) * fixed blinking mana vortex (#52) * grail increases creature growths --- CCallback.cpp | 24 +++++++++++---------- CCastleInterface.cpp | 48 ++++++++++++++++++++++++++++++++++++------ CCastleInterface.h | 1 + hch/CObjectHandler.cpp | 2 ++ 4 files changed, 57 insertions(+), 18 deletions(-) diff --git a/CCallback.cpp b/CCallback.cpp index bcfb042c3..8f12f4f94 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -245,9 +245,9 @@ void CCallback::selectionMade(int selection, int asker) void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount) { if(amount<=0) return; - if(obj->ID==98) + if(obj->ID==98) //recruiting from town { - int ser=-1; + int ser=-1; //used dwelling level CGTownInstance *t = const_cast(static_cast(obj)); //verify @@ -255,10 +255,10 @@ void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount typedef std::pair Parka; for(std::map::iterator av=t->strInfo.creatures.begin();av!=t->strInfo.creatures.end();av++) { - if( ( found = (ID == t->town->basicCreatures[av->first]) ) - || (found = (ID == t->town->upgradedCreatures[av->first])) ) + if( ( found = (ID == t->town->basicCreatures[av->first]) ) //creature is available among basic cretures + || (found = (ID == t->town->upgradedCreatures[av->first])) )//creature is available among upgraded cretures { - amount = std::min(amount,av->second); + amount = std::min(amount,av->second); //reduce recruited amount up to available amount ser = av->first; break; } @@ -269,17 +269,17 @@ void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount if(amount > CGI->creh->creatures[ID].maxAmount(gs->players[player].resources)) return; //not enough resources - for(int i=0;iplayers[player].resources[i] < (CGI->creh->creatures[ID].cost[i] * amount)) - return; //not enough resources + //for(int i=0;iplayers[player].resources[i] < (CGI->creh->creatures[ID].cost[i] * amount)) + // return; //not enough resources if(amount<=0) return; //recruit - int slot = -1; + int slot = -1; //slot ID std::pair > parb; - for(int i=0;i<7;i++) + for(int i=0;i<7;i++) //TODO: if there is already stack of same creatures it should be used always { if((!t->army.slots[i].first) || (t->army.slots[i].first->idNumber == ID)) //slot is free or there is saem creature { @@ -307,12 +307,13 @@ void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount CGI->playerint[gs->players[player].serial]->garrisonChanged(obj); } + //TODO: recruit from dwellings on the adventure map } bool CCallback::dismissCreature(const CArmedInstance *obj, int stackPos) { - if(obj->tempOwner != player) + if((player>=0) && obj->tempOwner != player) return false; CArmedInstance *ob = const_cast(obj); ob->army.slots.erase(stackPos); @@ -321,6 +322,7 @@ bool CCallback::dismissCreature(const CArmedInstance *obj, int stackPos) } bool CCallback::upgradeCreature(const CArmedInstance *obj, int stackPos, int newID) { + //TODO: write return false; } UpgradeInfo CCallback::getUpgradeInfo(const CArmedInstance *obj, int stackPos) diff --git a/CCastleInterface.cpp b/CCastleInterface.cpp index a46e6c651..3c7de4f6c 100644 --- a/CCastleInterface.cpp +++ b/CCastleInterface.cpp @@ -14,9 +14,19 @@ #include "CCallback.h" extern TTF_Font * GEOR16; CBuildingRect::CBuildingRect(Structure *Str) -:str(Str), moi(false) +:str(Str), moi(false), offset(0) { def = CGI->spriteh->giveDef(Str->defName); + max = def->ourImages.size(); + + if(str->ID == 33 && str->townID == 4) //little 'hack' for estate in necropolis - background color is not always the first color in the palette + { + for(std::vector::iterator i=def->ourImages.begin();i!=def->ourImages.end();i++) + { + SDL_SetColorKey(i->bitmap,SDL_SRCCOLORKEY,*((char*)i->bitmap->pixels)); + } + } + pos.x = str->pos.x; pos.y = str->pos.y; pos.w = def->ourImages[0].bitmap->w; @@ -458,16 +468,16 @@ void CCastleInterface::show(SDL_Surface * to) //blit buildings for(int i=0;idef->ourImages.size())) + int frame = (animval)%(buildings[i]->max - buildings[i]->offset); + if(frame) { blitAt(buildings[i]->def->ourImages[0].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to); - blitAt(buildings[i]->def->ourImages[(animval)%(buildings[i]->def->ourImages.size())].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to); + blitAt(buildings[i]->def->ourImages[frame].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to); } else - blitAt(buildings[i]->def->ourImages[(animval)%(buildings[i]->def->ourImages.size())].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to); - //if(buildings[i]->hovered && buildings[i]->border) - // blitAt(buildings[i]->border,buildings[i]->pos.x,buildings[i]->pos.y); - if(hBuild==buildings[i] && hBuild->border) + blitAt(buildings[i]->def->ourImages[frame].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to); + + if(hBuild==buildings[i] && hBuild->border) //if this this higlighted structure and has border we'll blit it blitAt(hBuild->border,hBuild->pos,to); } @@ -572,6 +582,30 @@ void CCastleInterface::recreateBuildings() break; } std::sort(buildings.begin(),buildings.end(),srthlp); + + //code for Mana Vortex (there are two sets of animation frames - one without mage guild and one with + if((town->subID == 5) && (town->builtBuildings.find(21)!=town->builtBuildings.end())) + { + CBuildingRect *vortex = NULL; + for(int i=0;istr->ID==21) + { + vortex=buildings[i]; + break; + } + } + if(town->builtBuildings.find(4)!=town->builtBuildings.end()) //there is mage Guild level 5 + { + vortex->offset = 10; + vortex->max = vortex->def->ourImages.size(); + } + else + { + vortex->offset = 0; + vortex->max = 10; + } + } } void CCastleInterface::recruit(int ID, int amount) { diff --git a/CCastleInterface.h b/CCastleInterface.h index 73e4d58cb..53ca3efd7 100644 --- a/CCastleInterface.h +++ b/CCastleInterface.h @@ -12,6 +12,7 @@ class CBuildingRect : public Hoverable, public MotionInterested, public Clickabl { public: bool moi; //motion interested is active + int offset, max; //first and last animation frame Structure* str; CDefHandler* def; SDL_Surface* border; diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index 5106bd02f..d73b74b52 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -285,6 +285,8 @@ int CGTownInstance::creatureGrowth(int level) const case 2: ret*=(1.5); break; } + if(builtBuildings.find(26)!=builtBuildings.end()) //grail + ret+=CGI->creh->creatures[town->basicCreatures[level]].growth; if(getHordeLevel(0)==level) if((builtBuildings.find(18)!=builtBuildings.end()) || (builtBuildings.find(19)!=builtBuildings.end())) ret+=CGI->creh->creatures[town->basicCreatures[level]].hordeGrowth;