mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Stack artifacts part 2, not working yet.
This commit is contained in:
parent
b8a5d0d430
commit
2bddf29cbf
@ -134,7 +134,7 @@ bool CCallback::swapArtifacts(const IArtifactSetBase * src, ui16 pos1, const IAr
|
|||||||
const CGHeroInstance * hero1 = dynamic_cast<const CGHeroInstance*>(src);
|
const CGHeroInstance * hero1 = dynamic_cast<const CGHeroInstance*>(src);
|
||||||
const CGHeroInstance * hero2 = dynamic_cast<const CGHeroInstance*>(dest);
|
const CGHeroInstance * hero2 = dynamic_cast<const CGHeroInstance*>(dest);
|
||||||
|
|
||||||
ExchangeArtifacts ea;
|
ExchangeArtifacts ea(0,0,0,0);
|
||||||
|
|
||||||
if (hero1 && hero2)
|
if (hero1 && hero2)
|
||||||
{
|
{
|
||||||
|
@ -251,14 +251,17 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameConstants::STACK_ARTIFACT && type > BATTLE)
|
if (GameConstants::STACK_ARTIFACT)
|
||||||
|
{
|
||||||
|
if (type > BATTLE) //artifact buttons inactive in battle
|
||||||
{
|
{
|
||||||
//SDL_Rect rect = genRect(44,44,465,98);
|
|
||||||
//creatureArtifact = new CArtPlace(NULL);
|
|
||||||
//creatureArtifact->pos = rect;
|
|
||||||
//creatureArtifact->ourOwner = NULL; //hmm?
|
|
||||||
leftArtRoll = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, -1), 437, 98, "hsbtns3.def", SDLK_LEFT);
|
leftArtRoll = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, -1), 437, 98, "hsbtns3.def", SDLK_LEFT);
|
||||||
rightArtRoll = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, +1), 516, 98, "hsbtns5.def", SDLK_RIGHT);
|
rightArtRoll = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, +1), 516, 98, "hsbtns5.def", SDLK_RIGHT);
|
||||||
|
if (heroOwner)
|
||||||
|
passArtToHero = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, 0), 437, 148, "OVBUTN1.DEF", SDLK_HOME);
|
||||||
|
}
|
||||||
|
if (ConstTransitivePtr<CArtifactInstance> art = stack->activeArtifact.artifact)
|
||||||
|
blitAt(graphics->artDefs->ourImages[art->id].bitmap, 466, 161, *bitmap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
creatureArtifact = NULL;
|
creatureArtifact = NULL;
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
CSlider * slider; //Abilities
|
CSlider * slider; //Abilities
|
||||||
CAdventureMapButton *dismiss, *upgrade, *ok;
|
CAdventureMapButton *dismiss, *upgrade, *ok;
|
||||||
CAdventureMapButton * leftArtRoll, * rightArtRoll; //artifact selection
|
CAdventureMapButton * leftArtRoll, * rightArtRoll; //artifact selection
|
||||||
//TODO: Artifact drop
|
CAdventureMapButton * passArtToHero;
|
||||||
|
|
||||||
boost::function<void()> dsm; //dismiss button callback
|
boost::function<void()> dsm; //dismiss button callback
|
||||||
boost::function<void()> Upg; //upgrade button callback
|
boost::function<void()> Upg; //upgrade button callback
|
||||||
|
@ -273,19 +273,18 @@ void CGarrisonSlot::clickLeft(tribool down, bool previousState)
|
|||||||
{
|
{
|
||||||
artSelected = true;
|
artSelected = true;
|
||||||
if (art->canBePutAt(ArtifactLocation(myStack, GameConstants::CREATURE_ART)))
|
if (art->canBePutAt(ArtifactLocation(myStack, GameConstants::CREATURE_ART)))
|
||||||
{
|
{ //equip clicked stack
|
||||||
//TODO : move
|
LOCPLINT->cb->swapArtifacts(aoh->getHero(), aoh->commonInfo->src.slotID, myStack, GameConstants::CREATURE_ART);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!artSelected)
|
if (artSelected || creature)
|
||||||
{
|
|
||||||
if(creature)
|
|
||||||
{
|
{
|
||||||
owner->highlighted = this;
|
owner->highlighted = this;
|
||||||
|
if(creature)
|
||||||
|
{
|
||||||
for(size_t i = 0; i<owner->splitButtons.size(); i++)
|
for(size_t i = 0; i<owner->splitButtons.size(); i++)
|
||||||
owner->splitButtons[i]->block(false);
|
owner->splitButtons[i]->block(false);
|
||||||
}
|
}
|
||||||
@ -5071,7 +5070,8 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact
|
|||||||
|
|
||||||
if(commonInfo->src == src) //artifact was taken from us
|
if(commonInfo->src == src) //artifact was taken from us
|
||||||
{
|
{
|
||||||
assert(commonInfo->dst == dst || dst.slot == dst.hero->artifactsInBackpack.size() + GameConstants::BACKPACK_START);
|
//assert(commonInfo->dst == dst || dst.slot == dst.hero->artifactsInBackpack.size() + GameConstants::BACKPACK_START);
|
||||||
|
//FIXME: assertion fails for stack artifacts
|
||||||
commonInfo->reset();
|
commonInfo->reset();
|
||||||
unmarkSlots();
|
unmarkSlots();
|
||||||
}
|
}
|
||||||
|
@ -216,6 +216,7 @@ void EraseArtifact::applyCl( CClient *cl )
|
|||||||
void MoveArtifact::applyCl( CClient *cl )
|
void MoveArtifact::applyCl( CClient *cl )
|
||||||
{
|
{
|
||||||
INTERFACE_CALL_IF_PRESENT(src.hero->tempOwner, artifactMoved, src, dst);
|
INTERFACE_CALL_IF_PRESENT(src.hero->tempOwner, artifactMoved, src, dst);
|
||||||
|
if (src.hero.get() && dst.hero.get())
|
||||||
if(src.hero->tempOwner != dst.hero->tempOwner)
|
if(src.hero->tempOwner != dst.hero->tempOwner)
|
||||||
INTERFACE_CALL_IF_PRESENT(src.hero->tempOwner, artifactMoved, src, dst);
|
INTERFACE_CALL_IF_PRESENT(src.hero->tempOwner, artifactMoved, src, dst);
|
||||||
}
|
}
|
||||||
|
@ -1277,7 +1277,7 @@ bool CCreatureArtifactInstance::canBePutAt(const ArtifactLocation &al, bool assu
|
|||||||
{
|
{
|
||||||
if (al.stack)
|
if (al.stack)
|
||||||
{
|
{
|
||||||
return true; //all artifacts should fit on creature
|
return al.stack->isPositionFree(al.slot, assumeDestRemoved);
|
||||||
}
|
}
|
||||||
else if(al.slot >= GameConstants::BACKPACK_START)
|
else if(al.slot >= GameConstants::BACKPACK_START)
|
||||||
{ //TODO backpack limit?
|
{ //TODO backpack limit?
|
||||||
@ -1438,10 +1438,9 @@ void CArtifactSet::eraseArtSlot(ui16 slot)
|
|||||||
|
|
||||||
ArtSlotInfo & CCreatureArtifactSet::retreiveNewArtSlot(ui16 slot)
|
ArtSlotInfo & CCreatureArtifactSet::retreiveNewArtSlot(ui16 slot)
|
||||||
{
|
{
|
||||||
assert(slot); //ke?
|
ArtSlotInfo &ret = slot == GameConstants::CREATURE_ART
|
||||||
ArtSlotInfo &ret = slot <= GameConstants::CREATURE_ART
|
|
||||||
? activeArtifact
|
? activeArtifact
|
||||||
: *artifactsInBackpack.insert(artifactsInBackpack.begin() + (slot - 1), ArtSlotInfo());
|
: *artifactsInBackpack.insert(artifactsInBackpack.begin() + (slot - GameConstants::CREATURE_ART), ArtSlotInfo());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1479,9 +1478,6 @@ si32 CCreatureArtifactSet::getArtPos(int aid, bool onlyWorn) const
|
|||||||
if (aid == activeArtifact.artifact->artType->id )
|
if (aid == activeArtifact.artifact->artType->id )
|
||||||
return GameConstants::CREATURE_ART;
|
return GameConstants::CREATURE_ART;
|
||||||
|
|
||||||
if(onlyWorn)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
for(int i = 0; i < artifactsInBackpack.size(); i++)
|
for(int i = 0; i < artifactsInBackpack.size(); i++)
|
||||||
{
|
{
|
||||||
if(artifactsInBackpack[i].artifact->artType->id == aid)
|
if(artifactsInBackpack[i].artifact->artType->id == aid)
|
||||||
@ -1498,7 +1494,7 @@ si32 CCreatureArtifactSet::getArtPos(const CArtifactInstance *art) const
|
|||||||
|
|
||||||
for(int i = 0; i < artifactsInBackpack.size(); i++)
|
for(int i = 0; i < artifactsInBackpack.size(); i++)
|
||||||
if(artifactsInBackpack[i].artifact == art)
|
if(artifactsInBackpack[i].artifact == art)
|
||||||
return GameConstants::BACKPACK_START + i;
|
return i + 1;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ namespace GameConstants
|
|||||||
|
|
||||||
const ui16 BACKPACK_START = 19;
|
const ui16 BACKPACK_START = 19;
|
||||||
const int ID_CATAPULT = 3, ID_LOCK = 145;
|
const int ID_CATAPULT = 3, ID_LOCK = 145;
|
||||||
const ui16 CREATURE_ART = 0;
|
const ui16 CREATURE_ART = 0; //position in CCreatureArtifactSet
|
||||||
|
|
||||||
//game modules
|
//game modules
|
||||||
const bool STACK_EXP = true;
|
const bool STACK_EXP = true;
|
||||||
|
@ -1758,7 +1758,10 @@ struct ExchangeArtifacts : public CPackForServer
|
|||||||
{
|
{
|
||||||
ExchangeArtifacts(){};
|
ExchangeArtifacts(){};
|
||||||
ExchangeArtifacts(si32 H1, si32 H2, ui16 S1, ui16 S2)
|
ExchangeArtifacts(si32 H1, si32 H2, ui16 S1, ui16 S2)
|
||||||
:hid1(H1),hid2(H2),slot1(S1),slot2(S2){};
|
:hid1(H1),hid2(H2),slot1(S1),slot2(S2)
|
||||||
|
{
|
||||||
|
s1 = s2 = StackLocation(NULL,0);
|
||||||
|
};
|
||||||
si32 hid1, hid2;
|
si32 hid1, hid2;
|
||||||
StackLocation s1, s2; //for creature stacks
|
StackLocation s1, s2; //for creature stacks
|
||||||
ui16 slot1, slot2;
|
ui16 slot1, slot2;
|
||||||
|
@ -560,7 +560,10 @@ DLL_LINKAGE CArtifactInstance *ArtifactLocation::getArt()
|
|||||||
|
|
||||||
DLL_LINKAGE const ArtSlotInfo *ArtifactLocation::getSlot() const
|
DLL_LINKAGE const ArtSlotInfo *ArtifactLocation::getSlot() const
|
||||||
{
|
{
|
||||||
|
if (hero)
|
||||||
return hero->getSlot(slot);
|
return hero->getSlot(slot);
|
||||||
|
if (stack)
|
||||||
|
return stack->getSlot(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_LINKAGE void ChangeStackCount::applyGs( CGameState *gs )
|
DLL_LINKAGE void ChangeStackCount::applyGs( CGameState *gs )
|
||||||
|
@ -95,6 +95,8 @@ void registerTypes1(Serializer &s)
|
|||||||
s.template registerType<CArtifactInstance>();
|
s.template registerType<CArtifactInstance>();
|
||||||
s.template registerType<CCombinedArtifactInstance>();
|
s.template registerType<CCombinedArtifactInstance>();
|
||||||
s.template registerType<CCreatureArtifactInstance>();
|
s.template registerType<CCreatureArtifactInstance>();
|
||||||
|
//s.template registerType<ArtifactLocation>();
|
||||||
|
//s.template registerType<StackLocation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Serializer>
|
template<typename Serializer>
|
||||||
|
@ -2571,14 +2571,12 @@ bool CGameHandler::moveArtifact(si32 srcHeroID, si32 destHeroID, ui16 srcSlot, u
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGameHandler::moveArtifact(StackLocation s1, StackLocation s2, ui16 srcSlot, ui16 destSlot)
|
bool CGameHandler::moveArtifact(StackLocation s1, StackLocation s2, ui16 srcSlot, ui16 destSlot)
|
||||||
{
|
{
|
||||||
ArtifactLocation src(s1.getStack(), srcSlot), dst(s2.getStack(), destSlot);
|
ArtifactLocation src(s1.getStack(), srcSlot), dst(s2.getStack(), destSlot);
|
||||||
moveArtifact(src, dst);
|
moveArtifact(src, dst);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGameHandler::moveArtifact(si32 srcHeroID, StackLocation s2, ui16 srcSlot, ui16 destSlot)
|
bool CGameHandler::moveArtifact(si32 srcHeroID, StackLocation s2, ui16 srcSlot, ui16 destSlot)
|
||||||
{
|
{
|
||||||
ArtifactLocation src(getHero(srcHeroID), srcSlot);
|
ArtifactLocation src(getHero(srcHeroID), srcSlot);
|
||||||
@ -2595,7 +2593,6 @@ bool CGameHandler::moveArtifact(StackLocation s1, si32 destHeroID, ui16 srcSlot,
|
|||||||
moveArtifact(src, dst);
|
moveArtifact(src, dst);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameHandler::moveArtifact(const ArtifactLocation &al1, const ArtifactLocation &al2)
|
void CGameHandler::moveArtifact(const ArtifactLocation &al1, const ArtifactLocation &al2)
|
||||||
{
|
{
|
||||||
MoveArtifact ma;
|
MoveArtifact ma;
|
||||||
@ -2604,8 +2601,6 @@ void CGameHandler::moveArtifact(const ArtifactLocation &al1, const ArtifactLocat
|
|||||||
sendAndApply(&ma);
|
sendAndApply(&ma);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assembles or disassembles a combination artifact.
|
* Assembles or disassembles a combination artifact.
|
||||||
* @param heroID ID of hero holding the artifact(s).
|
* @param heroID ID of hero holding the artifact(s).
|
||||||
@ -4356,7 +4351,8 @@ bool CGameHandler::isAllowedExchange( int id1, int id2 )
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
const CGObjectInstance *o1 = getObj(id1), *o2 = getObj(id2);
|
const CGObjectInstance *o1 = getObj(id1), *o2 = getObj(id2);
|
||||||
|
if (o1 && o2)
|
||||||
|
{
|
||||||
if(o1->ID == GameConstants::TOWNI_TYPE)
|
if(o1->ID == GameConstants::TOWNI_TYPE)
|
||||||
{
|
{
|
||||||
const CGTownInstance *t = static_cast<const CGTownInstance*>(o1);
|
const CGTownInstance *t = static_cast<const CGTownInstance*>(o1);
|
||||||
@ -4376,7 +4372,11 @@ bool CGameHandler::isAllowedExchange( int id1, int id2 )
|
|||||||
//(to block moving stacks for free [without visiting] between heroes)
|
//(to block moving stacks for free [without visiting] between heroes)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else //not exchanging between heroes, TODO: more sophisticated logic
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,20 @@ bool GarrisonHeroSwap::applyGh( CGameHandler *gh )
|
|||||||
bool ExchangeArtifacts::applyGh( CGameHandler *gh )
|
bool ExchangeArtifacts::applyGh( CGameHandler *gh )
|
||||||
{
|
{
|
||||||
ERROR_IF_NOT_OWNS(hid1);//second hero can be ally
|
ERROR_IF_NOT_OWNS(hid1);//second hero can be ally
|
||||||
|
if (hid1)
|
||||||
|
{ //TODO: polymorph
|
||||||
|
if (hid2)
|
||||||
return gh->moveArtifact(hid1,hid2,slot1,slot2);
|
return gh->moveArtifact(hid1,hid2,slot1,slot2);
|
||||||
|
else
|
||||||
|
return gh->moveArtifact(hid1,s2,slot1,slot2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (hid2)
|
||||||
|
return gh->moveArtifact(s1,hid2,slot1,slot2);
|
||||||
|
else
|
||||||
|
return gh->moveArtifact(s1,s2,slot1,slot2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssembleArtifacts::applyGh( CGameHandler *gh )
|
bool AssembleArtifacts::applyGh( CGameHandler *gh )
|
||||||
|
Loading…
Reference in New Issue
Block a user