mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* hero recruited in the town with Mage Guild will get spells (if has spellbook)
* fixed casting spells * resolved some "taking address of temporary" warnings * fixed removing killed Hero
This commit is contained in:
parent
74be845594
commit
0cf1b2588d
@ -55,7 +55,8 @@ template <ui16 N> bool isType(CPack *pack)
|
||||
|
||||
bool CCallback::moveHero(const CGHeroInstance *h, int3 dst) const
|
||||
{
|
||||
*cl->serv << &MoveHero(dst,h->id);
|
||||
MoveHero pack(dst,h->id);
|
||||
*cl->serv << &pack;
|
||||
|
||||
{//wait till there is server answer
|
||||
boost::unique_lock<boost::mutex> lock(*mess.mx);
|
||||
@ -75,12 +76,15 @@ bool CCallback::moveHero(const CGHeroInstance *h, int3 dst) const
|
||||
}
|
||||
void CCallback::selectionMade(int selection, int asker)
|
||||
{
|
||||
*cl->serv << &QueryReply(asker,selection);
|
||||
QueryReply pack(asker,selection);
|
||||
*cl->serv << &pack;
|
||||
}
|
||||
void CCallback::recruitCreatures(const CGObjectInstance *obj, ui32 ID, ui32 amount)
|
||||
{
|
||||
if(player!=obj->tempOwner) return;
|
||||
*cl->serv << &RecruitCreatures(obj->id,ID,amount);
|
||||
|
||||
RecruitCreatures pack(obj->id,ID,amount);
|
||||
*cl->serv << &pack;
|
||||
}
|
||||
|
||||
|
||||
@ -88,18 +92,22 @@ bool CCallback::dismissCreature(const CArmedInstance *obj, int stackPos)
|
||||
{
|
||||
if(((player>=0) && obj->tempOwner != player) || obj->army.slots.size()<2)
|
||||
return false;
|
||||
*cl->serv << &DisbandCreature(stackPos,obj->id);
|
||||
|
||||
DisbandCreature pack(stackPos,obj->id);
|
||||
*cl->serv << &pack;
|
||||
return true;
|
||||
}
|
||||
bool CCallback::upgradeCreature(const CArmedInstance *obj, int stackPos, int newID)
|
||||
{
|
||||
*cl->serv << &UpgradeCreature(stackPos,obj->id,newID);
|
||||
UpgradeCreature pack(stackPos,obj->id,newID);
|
||||
*cl->serv << &pack;
|
||||
return false;
|
||||
}
|
||||
void CCallback::endTurn()
|
||||
{
|
||||
tlog5 << "Player "<<(unsigned)player<<" end his turn."<<std::endl;
|
||||
*cl->serv << &EndTurn(); //report that we ended turn
|
||||
tlog5 << "Player " << (unsigned)player << " end his turn." << std::endl;
|
||||
EndTurn pack;
|
||||
*cl->serv << &pack; //report that we ended turn
|
||||
}
|
||||
UpgradeInfo CCallback::getUpgradeInfo(const CArmedInstance *obj, int stackPos) const
|
||||
{
|
||||
@ -329,7 +337,9 @@ int CCallback::swapCreatures(const CGObjectInstance *s1, const CGObjectInstance
|
||||
{
|
||||
if(s1->tempOwner != player || s2->tempOwner != player)
|
||||
return -1;
|
||||
*cl->serv << &ArrangeStacks(1,p1,p2,s1->id,s2->id,0);
|
||||
|
||||
ArrangeStacks pack(1,p1,p2,s1->id,s2->id,0);
|
||||
*cl->serv << &pack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -339,7 +349,8 @@ int CCallback::mergeStacks(const CGObjectInstance *s1, const CGObjectInstance *s
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
*cl->serv << &ArrangeStacks(2,p1,p2,s1->id,s2->id,0);
|
||||
ArrangeStacks pack(2,p1,p2,s1->id,s2->id,0);
|
||||
*cl->serv << &pack;
|
||||
return 0;
|
||||
}
|
||||
int CCallback::splitStack(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2, int val)
|
||||
@ -348,14 +359,17 @@ int CCallback::splitStack(const CGObjectInstance *s1, const CGObjectInstance *s2
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
*cl->serv << &ArrangeStacks(3,p1,p2,s1->id,s2->id,val);
|
||||
ArrangeStacks pack(3,p1,p2,s1->id,s2->id,val);
|
||||
*cl->serv << &pack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CCallback::dismissHero(const CGHeroInstance *hero)
|
||||
{
|
||||
if(player!=hero->tempOwner) return false;
|
||||
*cl->serv << &DismissHero(hero->id);
|
||||
|
||||
DismissHero pack(hero->id);
|
||||
*cl->serv << &pack;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -384,7 +398,8 @@ bool CCallback::buildBuilding(const CGTownInstance *town, si32 buildingID)
|
||||
if(b->resources[i] > gs->players[player].resources[i])
|
||||
return false; //lack of resources
|
||||
|
||||
*cl->serv << &BuildStructure(town->id,buildingID);
|
||||
BuildStructure pack(town->id,buildingID);
|
||||
*cl->serv << &pack;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -424,7 +439,8 @@ CStack* CCallback::battleGetStackByID(int ID)
|
||||
|
||||
int CCallback::battleMakeAction(BattleAction* action)
|
||||
{
|
||||
*cl->serv << &MakeAction(*action);
|
||||
MakeCustomAction mca(*action);
|
||||
*cl->serv << &mca;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -547,13 +563,17 @@ bool CCallback::battleCanShoot(int ID, int dest)
|
||||
void CCallback::swapGarrisonHero( const CGTownInstance *town )
|
||||
{
|
||||
if(town->tempOwner != player) return;
|
||||
*cl->serv << &GarrisonHeroSwap(town->id);
|
||||
|
||||
GarrisonHeroSwap pack(town->id);
|
||||
*cl->serv << &pack;
|
||||
}
|
||||
|
||||
void CCallback::buyArtifact(const CGHeroInstance *hero, int aid)
|
||||
{
|
||||
if(hero->tempOwner != player) return;
|
||||
*cl->serv << &BuyArtifact(hero->id,aid);
|
||||
|
||||
BuyArtifact pack(hero->id,aid);
|
||||
*cl->serv << &pack;
|
||||
}
|
||||
|
||||
std::vector < const CGObjectInstance * > CCallback::getBlockingObjs( int3 pos ) const
|
||||
@ -622,13 +642,15 @@ void CCallback::trade( int mode, int id1, int id2, int val1 )
|
||||
{
|
||||
int p1, p2;
|
||||
getMarketOffer(id1,id2,p1,p2,mode);
|
||||
*cl->serv << &TradeOnMarketplace(player,mode,id1,id2,val1);
|
||||
TradeOnMarketplace pack(player,mode,id1,id2,val1);
|
||||
*cl->serv << &pack;
|
||||
}
|
||||
|
||||
void CCallback::setFormation(const CGHeroInstance * hero, bool tight)
|
||||
{
|
||||
const_cast<CGHeroInstance*>(hero)->army.formation = tight;
|
||||
*cl->serv << &SetFormation(hero->id,tight);
|
||||
SetFormation pack(hero->id,tight);
|
||||
*cl->serv << &pack;
|
||||
}
|
||||
|
||||
void CCallback::setSelection(const CArmedInstance * obj)
|
||||
@ -646,7 +668,8 @@ void CCallback::recruitHero(const CGTownInstance *town, const CGHeroInstance *he
|
||||
{
|
||||
if(gs->players[player].availableHeroes[i] == hero)
|
||||
{
|
||||
*cl->serv << &HireHero(i,town->id);
|
||||
HireHero pack(i,town->id);
|
||||
*cl->serv << &pack;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1749,7 +1749,7 @@ void CPlayerInterface::heroKilled(const CGHeroInstance* hero)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
graphics->heroWins.erase(hero->ID);
|
||||
adventureInt->heroList.updateHList();
|
||||
adventureInt->heroList.updateHList(hero);
|
||||
}
|
||||
void CPlayerInterface::heroCreated(const CGHeroInstance * hero)
|
||||
{
|
||||
@ -2290,7 +2290,9 @@ void CPlayerInterface::battleSpellCasted(SpellCasted *sc)
|
||||
}
|
||||
void CPlayerInterface::battleStackAttacked(BattleStackAttacked * bsa)
|
||||
{
|
||||
tlog5 << "CPlayerInterface::battleStackAttacked - locking...";
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
tlog5 << "done!\n";
|
||||
if(bsa->isEffect())
|
||||
{
|
||||
battleInt->displayEffect(bsa->effect, cb->battleGetStackByID(bsa->stackAttacked)->position);
|
||||
@ -2302,7 +2304,9 @@ void CPlayerInterface::battleStackAttacked(BattleStackAttacked * bsa)
|
||||
}
|
||||
void CPlayerInterface::battleAttack(BattleAttack *ba)
|
||||
{
|
||||
tlog5 << "CPlayerInterface::battleAttack - locking...";
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
tlog5 << "done!\n";
|
||||
if(ba->bsa.lucky()) //lucky hit
|
||||
{
|
||||
CStack *stack = cb->battleGetStackByID(ba->stackAttacking);
|
||||
@ -2793,10 +2797,25 @@ void CHeroList::hover (bool on)
|
||||
void CHeroList::keyPressed (const SDL_KeyboardEvent & key)
|
||||
{
|
||||
}
|
||||
void CHeroList::updateHList()
|
||||
void CHeroList::updateHList(const CGHeroInstance *toRemove)
|
||||
{
|
||||
items.clear();
|
||||
genList();
|
||||
if(toRemove) //remove specific hero
|
||||
{
|
||||
for (std::vector<std::pair<const CGHeroInstance*, CPath *> >::iterator i=items.begin(); i != items.end(); i++)
|
||||
{
|
||||
if(i->first == toRemove)
|
||||
{
|
||||
delete i->second;
|
||||
items.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
items.clear();
|
||||
genList();
|
||||
}
|
||||
if(selected>=items.size())
|
||||
select(items.size()-1);
|
||||
if(items.size()==0)
|
||||
@ -4274,6 +4293,7 @@ CTavernWindow::CTavernWindow(const CGHeroInstance *H1, const CGHeroInstance *H2,
|
||||
else
|
||||
selected = -1;
|
||||
bg = BitmapHandler::loadBitmap("TPTAVERN.bmp");
|
||||
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
|
||||
graphics->blueToPlayersAdv(bg,LOCPLINT->playerID);
|
||||
printAtMiddle(CGI->generaltexth->jktexts[37],200,35,GEOR16,tytulowy,bg);
|
||||
printAtMiddle("2500",320,328,GEOR13,zwykly,bg);
|
||||
|
@ -577,7 +577,7 @@ public:
|
||||
void clickRight(boost::logic::tribool down);
|
||||
void hover (bool on);
|
||||
void keyPressed (const SDL_KeyboardEvent & key);
|
||||
void updateHList();
|
||||
void updateHList(const CGHeroInstance *toRemove=NULL); //removes specific hero from the list or recreates it
|
||||
void updateMove(const CGHeroInstance* which); //draws move points bar
|
||||
void redrawAllOne(int which);
|
||||
void draw();
|
||||
|
@ -1,4 +1,4 @@
|
||||
0.7 -> 0.71 (as for r765)
|
||||
0.7 -> 0.71 (as for r769)
|
||||
GENERAL:
|
||||
* fixed scrolling behind window problem (now it's possible to scroll with CTRL + arrows)
|
||||
* morale/luck system and corresponding sec. skills supported
|
||||
|
@ -1027,7 +1027,7 @@ struct MakeAction : public CPackForServer
|
||||
struct MakeCustomAction : public CPackForServer
|
||||
{
|
||||
MakeCustomAction(){};
|
||||
MakeCustomAction(const BattleAction &BA):ba(ba){};
|
||||
MakeCustomAction(const BattleAction &BA):ba(BA){};
|
||||
BattleAction ba;
|
||||
|
||||
void applyGh(CGameHandler *gh);
|
||||
|
@ -1926,6 +1926,8 @@ void CGameHandler::hireHero( ui32 tid, ui8 hid )
|
||||
sr.resid = 6;
|
||||
sr.val = gs->getPlayer(t->tempOwner)->resources[6] - 2500;
|
||||
sendAndApply(&sr);
|
||||
|
||||
giveSpells(t,nh);
|
||||
}
|
||||
|
||||
void CGameHandler::queryReply( ui32 qid, ui32 answer )
|
||||
|
Loading…
Reference in New Issue
Block a user