1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Most of the stuff I've commited today makes no sense, proper solution is trivial.

This commit is contained in:
DjWarmonger
2011-07-17 18:11:03 +00:00
parent e4c5de3d0f
commit ef954b8a4f
2 changed files with 18 additions and 37 deletions

View File

@@ -201,8 +201,8 @@ void CGameHandler::levelUpHero(int ID)
if (hero->battle)
tlog1<<"Battle found\n";
if (hero->exp < VLC->heroh->reqExp(hero->level+1))
{// no more level-ups
afterBattleCallback(0);
{// no more level-ups, call end battle
afterBattleCallback();
return;
}
@@ -267,8 +267,6 @@ void CGameHandler::levelUpHero(int ID)
hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(basicAndAdv)); //upgrade existing
}
if (hero->exp >= VLC->heroh->reqExp(hero->level+2)) // more level-ups
{
if(hlu.skills.size() > 1) //apply and ask for secondary skill
{
boost::function<void(ui32)> callback = boost::function<void(ui32)>(boost::bind(callWith<ui16>,hlu.skills,boost::function<void(ui16)>(boost::bind(&CGameHandler::levelUpHero,this,ID,_1)),_1));
@@ -285,25 +283,6 @@ void CGameHandler::levelUpHero(int ID)
levelUpHero(ID);
}
}
else //call function after battle was finished and all exp given
{
boost::function<void(ui32)> callback = boost::function<void(ui32)>(boost::bind(callWith<ui16>,hlu.skills,boost::function<void(ui16)>(boost::bind(&CGameHandler::afterBattleCallback,this,_1)),_1));
if(hlu.skills.size() > 1) //apply and ask for secondary skill
{
applyAndAsk(&hlu, hero->tempOwner, callback); //call levelUpHero when client responds
}
else if(hlu.skills.size() == 1) //apply, give only possible skill and send info
{
applyAndAsk(&hlu, hero->tempOwner, callback); //call levelUpHero when client responds
levelUpHero(ID, hlu.skills.back());
}
else //apply and send info
{
applyAndAsk(&hlu, hero->tempOwner, callback); //call levelUpHero when client responds
levelUpHero(ID);
}
}
}
void CGameHandler::changePrimSkill(int ID, int which, si64 val, bool abs)
{
@@ -457,6 +436,8 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
changePrimSkill(hero1->id,4,battleResult.data->exp[0]);
if(battleResult.data->exp[1] && hero2)
changePrimSkill(hero2->id,4,battleResult.data->exp[1]);
if (!(hero1 || hero2)) //possible?
afterBattleCallback(); //clear stuff for sanity
}
sendAndApply(&resultsApplied);
@@ -518,7 +499,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
}
}
void CGameHandler::afterBattleCallback(int ID) //object interaction after leveling up is done
void CGameHandler::afterBattleCallback() //object interaction after leveling up is done
{
if(battleEndCallback && *battleEndCallback)
{

View File

@@ -184,7 +184,7 @@ public:
void vistiCastleObjects (const CGTownInstance *t, const CGHeroInstance *h);
void levelUpHero(int ID, int skill);//handle client respond and send one more request if needed
void levelUpHero(int ID);//initial call - check if hero have remaining levelups & handle them
void afterBattleCallback(int ID); // called after level-ups are finished, ID is just temporarily for compatibility
void afterBattleCallback(); // called after level-ups are finished, ID is just temporarily for compatibility
//////////////////////////////////////////////////////////////////////////
void commitPackage(CPackForClient *pack) OVERRIDE;