mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-07 07:10:04 +02:00
Fixes for artifact system - instances are serialized and synchronized. However, still some serializer issue prevents Scroll from working.
This commit is contained in:
parent
b75cf89f86
commit
6cadd47f0d
@ -113,7 +113,7 @@ public:
|
|||||||
void heroVisitCastle(int obj, int heroID){};
|
void heroVisitCastle(int obj, int heroID){};
|
||||||
void stopHeroVisitCastle(int obj, int heroID){};
|
void stopHeroVisitCastle(int obj, int heroID){};
|
||||||
void giveHeroArtifact(int artid, int hid, int position){}; //pos==-1 - first free slot in backpack=0; pos==-2 - default if available or backpack
|
void giveHeroArtifact(int artid, int hid, int position){}; //pos==-1 - first free slot in backpack=0; pos==-2 - default if available or backpack
|
||||||
void giveCustomArtifact(int artid, int hid, int position, int value){};
|
void giveNewArtifact(int hid, int position){};
|
||||||
bool removeArtifact(CArtifact* art, int hid){return false;};
|
bool removeArtifact(CArtifact* art, int hid){return false;};
|
||||||
void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, boost::function<void(BattleResult*)> cb = 0, const CGTownInstance *town = NULL){}; //use hero=NULL for no hero
|
void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, boost::function<void(BattleResult*)> cb = 0, const CGTownInstance *town = NULL){}; //use hero=NULL for no hero
|
||||||
void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, boost::function<void(BattleResult*)> cb = 0, bool creatureBank = false){}; //if any of armies is hero, hero will be used
|
void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, boost::function<void(BattleResult*)> cb = 0, bool creatureBank = false){}; //if any of armies is hero, hero will be used
|
||||||
|
@ -183,7 +183,7 @@ void CArtifact::getParents(TCNodes &out, const CBonusSystemNode *root /*= NULL*/
|
|||||||
|
|
||||||
void CScroll::Init()
|
void CScroll::Init()
|
||||||
{
|
{
|
||||||
bonuses.push_back (Bonus (Bonus::PERMANENT, Bonus::SPELL, Bonus::ARTIFACT, 0, id, spellid, Bonus::INDEPENDENT_MAX));
|
bonuses.push_back (Bonus (Bonus::PERMANENT, Bonus::SPELL, Bonus::ARTIFACT, 1, id, spellid, Bonus::INDEPENDENT_MAX));
|
||||||
//boost::algorithm::replace_first(description, "[spell name]", VLC->spellh->spells[spellid].name);
|
//boost::algorithm::replace_first(description, "[spell name]", VLC->spellh->spells[spellid].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,32 +756,35 @@ void CArtHandler::equipArtifact(std::map<ui16, CArtifact*> &artifWorn, ui16 slot
|
|||||||
{
|
{
|
||||||
unequipArtifact(artifWorn, slotID);
|
unequipArtifact(artifWorn, slotID);
|
||||||
|
|
||||||
const CArtifact &artifact = *newArtifact;
|
if (newArtifact) //false when artifact is NULL -> slot set to empty
|
||||||
|
|
||||||
// Add artifact.
|
|
||||||
artifWorn[slotID] = const_cast<CArtifact*>(newArtifact);
|
|
||||||
|
|
||||||
// Add locks, in reverse order of being removed.
|
|
||||||
if (artifact.constituents != NULL)
|
|
||||||
{
|
{
|
||||||
bool destConsumed = false; // Determines which constituent that will be counted for together with the artifact.
|
const CArtifact &artifact = *newArtifact;
|
||||||
|
|
||||||
BOOST_FOREACH(ui32 constituentID, *artifact.constituents)
|
// Add artifact.
|
||||||
|
artifWorn[slotID] = const_cast<CArtifact*>(newArtifact);
|
||||||
|
|
||||||
|
// Add locks, in reverse order of being removed.
|
||||||
|
if (artifact.constituents != NULL)
|
||||||
{
|
{
|
||||||
const CArtifact &constituent = *artifacts[constituentID];
|
bool destConsumed = false; // Determines which constituent that will be counted for together with the artifact.
|
||||||
|
|
||||||
if (!destConsumed && vstd::contains(constituent.possibleSlots, slotID))
|
BOOST_FOREACH(ui32 constituentID, *artifact.constituents)
|
||||||
{
|
{
|
||||||
destConsumed = true;
|
const CArtifact &constituent = *artifacts[constituentID];
|
||||||
}
|
|
||||||
else
|
if (!destConsumed && vstd::contains(constituent.possibleSlots, slotID))
|
||||||
{
|
|
||||||
BOOST_FOREACH(ui16 slot, constituent.possibleSlots)
|
|
||||||
{
|
{
|
||||||
if (!vstd::contains(artifWorn, slot))
|
destConsumed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOOST_FOREACH(ui16 slot, constituent.possibleSlots)
|
||||||
{
|
{
|
||||||
artifWorn[slot] = VLC->arth->artifacts[145]; //lock
|
if (!vstd::contains(artifWorn, slot))
|
||||||
break;
|
{
|
||||||
|
artifWorn[slot] = VLC->arth->artifacts[145]; //lock
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -588,7 +588,7 @@ DLL_EXPORT void NewObject::applyGs( CGameState *gs )
|
|||||||
}
|
}
|
||||||
DLL_EXPORT void NewArtifact::applyGs( CGameState *gs )
|
DLL_EXPORT void NewArtifact::applyGs( CGameState *gs )
|
||||||
{
|
{
|
||||||
CArtifact * art;
|
IModableArt * art;
|
||||||
|
|
||||||
std::map<ui32,ui8>::iterator itr = VLC->arth->modableArtifacts.find(artid);
|
std::map<ui32,ui8>::iterator itr = VLC->arth->modableArtifacts.find(artid);
|
||||||
switch (itr->second)
|
switch (itr->second)
|
||||||
@ -605,11 +605,11 @@ DLL_EXPORT void NewArtifact::applyGs( CGameState *gs )
|
|||||||
default:
|
default:
|
||||||
tlog1<<"unhandled customizable artifact!\n";
|
tlog1<<"unhandled customizable artifact!\n";
|
||||||
};
|
};
|
||||||
*art = *(VLC->arth->artifacts[artid]); //copy properties
|
*art = *static_cast<IModableArt*>(VLC->arth->artifacts[artid]); //copy properties
|
||||||
static_cast<IModableArt*>(art)->ID = gs->map->artInstances.size();
|
art->ID = gs->map->artInstances.size();
|
||||||
art->SetProperty (value); //init scroll, banner, commander art
|
art->SetProperty (value); //init scroll, banner, commander art
|
||||||
art->Init(); //set bonuses for new instance
|
art->Init(); //set bonuses for new instance
|
||||||
gs->map->artInstances.push_back(static_cast<IModableArt*>(art));
|
gs->map->artInstances.push_back(art);
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_EXPORT void SetAvailableArtifacts::applyGs( CGameState *gs )
|
DLL_EXPORT void SetAvailableArtifacts::applyGs( CGameState *gs )
|
||||||
|
@ -289,7 +289,7 @@ struct DLL_EXPORT Mapa : public CMapHeader
|
|||||||
{
|
{
|
||||||
h & static_cast<CMapHeader&>(*this);
|
h & static_cast<CMapHeader&>(*this);
|
||||||
h & rumors & allowedSpell & allowedAbilities & allowedArtifact & allowedHeroes & events & grailPos;
|
h & rumors & allowedSpell & allowedAbilities & allowedArtifact & allowedHeroes & events & grailPos;
|
||||||
h & monsters & heroesToBeat & artInstances; //hoprfully serialization is now automagical?
|
h & monsters & heroesToBeat & artInstances; //hopefully serialization is now automagical?
|
||||||
|
|
||||||
//TODO: viccondetails
|
//TODO: viccondetails
|
||||||
if(h.saving)
|
if(h.saving)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user