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

changes seem to cover almost everything on heroes' artifacts in hero screen

a part of code has been refactored for simpler support by other parts of code
This commit is contained in:
mateuszb
2008-01-30 10:55:43 +00:00
parent b675de7ca5
commit ed0bbcfe11
7 changed files with 554 additions and 419 deletions

View File

@@ -453,6 +453,32 @@ int CCallback::getMySerial()
return gs->players[player].serial;
}
bool CCallback::swapArifacts(const CGHeroInstance * hero1, bool worn1, int pos1, const CGHeroInstance * hero2, bool worn2, int pos2)
{
if(!hero1 || !hero2) //incorrect data
return false;
CGHeroInstance * Uhero1 = const_cast<CGHeroInstance *>(hero1);
CGHeroInstance * Uhero2 = const_cast<CGHeroInstance *>(hero2);
if(worn1 && worn2)
{
std::swap(Uhero1->artifWorn[pos1], Uhero2->artifWorn[pos2]);
}
else if(worn1 && !worn2)
{
std::swap(Uhero1->artifWorn[pos1], Uhero2->artifacts[pos2]);
}
else if(!worn1 && worn2)
{
std::swap(Uhero1->artifacts[pos1], Uhero2->artifWorn[pos2]);
}
else
{
std::swap(Uhero1->artifacts[pos1], Uhero2->artifacts[pos2]);
}
return true;
}
int3 CScriptCallback::getPos(CGObjectInstance * ob)
{