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:
@@ -201,8 +201,8 @@ void CGameHandler::levelUpHero(int ID)
|
|||||||
if (hero->battle)
|
if (hero->battle)
|
||||||
tlog1<<"Battle found\n";
|
tlog1<<"Battle found\n";
|
||||||
if (hero->exp < VLC->heroh->reqExp(hero->level+1))
|
if (hero->exp < VLC->heroh->reqExp(hero->level+1))
|
||||||
{// no more level-ups
|
{// no more level-ups, call end battle
|
||||||
afterBattleCallback(0);
|
afterBattleCallback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,41 +267,20 @@ void CGameHandler::levelUpHero(int ID)
|
|||||||
hlu.skills.push_back(hero->type->heroClass->chooseSecSkill(basicAndAdv)); //upgrade existing
|
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
|
||||||
{
|
{
|
||||||
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));
|
||||||
{
|
applyAndAsk(&hlu,hero->tempOwner,callback); //call levelUpHero when client responds
|
||||||
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));
|
|
||||||
applyAndAsk(&hlu,hero->tempOwner,callback); //call levelUpHero when client responds
|
|
||||||
}
|
|
||||||
else if(hlu.skills.size() == 1) //apply, give only possible skill and send info
|
|
||||||
{
|
|
||||||
sendAndApply(&hlu);
|
|
||||||
levelUpHero(ID, hlu.skills.back());
|
|
||||||
}
|
|
||||||
else //apply and send info
|
|
||||||
{
|
|
||||||
sendAndApply(&hlu);
|
|
||||||
levelUpHero(ID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else //call function after battle was finished and all exp given
|
else if(hlu.skills.size() == 1) //apply, give only possible skill and send info
|
||||||
{
|
{
|
||||||
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));
|
sendAndApply(&hlu);
|
||||||
if(hlu.skills.size() > 1) //apply and ask for secondary skill
|
levelUpHero(ID, hlu.skills.back());
|
||||||
{
|
}
|
||||||
applyAndAsk(&hlu, hero->tempOwner, callback); //call levelUpHero when client responds
|
else //apply and send info
|
||||||
}
|
{
|
||||||
else if(hlu.skills.size() == 1) //apply, give only possible skill and send info
|
sendAndApply(&hlu);
|
||||||
{
|
levelUpHero(ID);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,6 +436,8 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
|
|||||||
changePrimSkill(hero1->id,4,battleResult.data->exp[0]);
|
changePrimSkill(hero1->id,4,battleResult.data->exp[0]);
|
||||||
if(battleResult.data->exp[1] && hero2)
|
if(battleResult.data->exp[1] && hero2)
|
||||||
changePrimSkill(hero2->id,4,battleResult.data->exp[1]);
|
changePrimSkill(hero2->id,4,battleResult.data->exp[1]);
|
||||||
|
if (!(hero1 || hero2)) //possible?
|
||||||
|
afterBattleCallback(); //clear stuff for sanity
|
||||||
}
|
}
|
||||||
|
|
||||||
sendAndApply(&resultsApplied);
|
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)
|
if(battleEndCallback && *battleEndCallback)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -182,9 +182,9 @@ public:
|
|||||||
void visitObjectOnTile(const TerrainTile &t, const CGHeroInstance * h);
|
void visitObjectOnTile(const TerrainTile &t, const CGHeroInstance * h);
|
||||||
bool teleportHero(si32 hid, si32 dstid, ui8 source, ui8 asker = 255);
|
bool teleportHero(si32 hid, si32 dstid, ui8 source, ui8 asker = 255);
|
||||||
void vistiCastleObjects (const CGTownInstance *t, const CGHeroInstance *h);
|
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, 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 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;
|
void commitPackage(CPackForClient *pack) OVERRIDE;
|
||||||
|
|||||||
Reference in New Issue
Block a user