mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Fixes for previous rev.
This commit is contained in:
@@ -368,10 +368,11 @@ public:
|
|||||||
{
|
{
|
||||||
/* if(id < 0)
|
/* if(id < 0)
|
||||||
return NULL;*/
|
return NULL;*/
|
||||||
|
si32 idAsNumber = idToNumber(id);
|
||||||
|
|
||||||
assert(oInfo.vector);
|
assert(oInfo.vector);
|
||||||
assert(oInfo.vector->size() > id);
|
assert(oInfo.vector->size() > idAsNumber);
|
||||||
return const_cast<T*>((*oInfo.vector)[id].get());
|
return const_cast<T*>((*oInfo.vector)[idAsNumber].get());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
@@ -431,12 +432,30 @@ struct VectorizedIDType
|
|||||||
//else if
|
//else if
|
||||||
mpl::eval_if<boost::is_same<CCreature,U>,
|
mpl::eval_if<boost::is_same<CCreature,U>,
|
||||||
mpl::identity<CreatureID>,
|
mpl::identity<CreatureID>,
|
||||||
|
//else if
|
||||||
|
mpl::eval_if<boost::is_same<CArtifactInstance,U>,
|
||||||
|
mpl::identity<ArtifactInstanceID>,
|
||||||
|
//else if
|
||||||
|
mpl::eval_if<boost::is_base_of<CGObjectInstance,U>,
|
||||||
|
mpl::identity<ObjectInstanceID>,
|
||||||
//else
|
//else
|
||||||
mpl::identity<si32>
|
mpl::identity<si32>
|
||||||
>
|
> > > >::type type;
|
||||||
>::type type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
si32 idToNumber(const T &t, typename boost::enable_if<boost::is_convertible<T,si32> >::type * dummy = 0)
|
||||||
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
si32 idToNumber(const BaseForID<T> &t)
|
||||||
|
{
|
||||||
|
return t.getNum();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Handler>
|
template <typename Handler>
|
||||||
struct VariantVisitorSaver : boost::static_visitor<>
|
struct VariantVisitorSaver : boost::static_visitor<>
|
||||||
{
|
{
|
||||||
@@ -586,9 +605,9 @@ public:
|
|||||||
typedef typename VectorizedIDType<TObjectType>::type IDType;
|
typedef typename VectorizedIDType<TObjectType>::type IDType;
|
||||||
if(const auto *info = getVectorisedTypeInfo<VType, IDType>())
|
if(const auto *info = getVectorisedTypeInfo<VType, IDType>())
|
||||||
{
|
{
|
||||||
si32 id = getIdFromVectorItem<VType>(*info, data);
|
IDType id = getIdFromVectorItem<VType>(*info, data);
|
||||||
*this << id;
|
*this << id;
|
||||||
if(id != -1) //vector id is enough
|
if(id != IDType(-1)) //vector id is enough
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -961,11 +980,11 @@ public:
|
|||||||
typedef typename VectorizedIDType<TObjectType>::type IDType;
|
typedef typename VectorizedIDType<TObjectType>::type IDType;
|
||||||
if(const auto *info = getVectorisedTypeInfo<VType, IDType>())
|
if(const auto *info = getVectorisedTypeInfo<VType, IDType>())
|
||||||
{
|
{
|
||||||
si32 id;
|
IDType id;
|
||||||
*this >> id;
|
*this >> id;
|
||||||
if(id != -1)
|
if(id != IDType(-1))
|
||||||
{
|
{
|
||||||
data = static_cast<T>(getVectorItemFromId<VType, IDType>(*info, IDType(id)));
|
data = static_cast<T>(getVectorItemFromId<VType, IDType>(*info, id));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -89,5 +89,5 @@ CSpell * SpellID::toSpell() const
|
|||||||
return VLC->spellh->spells[*this];
|
return VLC->spellh->spells[*this];
|
||||||
}
|
}
|
||||||
|
|
||||||
template std::ostream & operator << <ArtifactInstanceID>(std::ostream & os, BaseForID<ArtifactInstanceID> id);
|
//template std::ostream & operator << <ArtifactInstanceID>(std::ostream & os, BaseForID<ArtifactInstanceID> id);
|
||||||
template std::ostream & operator << <ObjectInstanceID>(std::ostream & os, BaseForID<ObjectInstanceID> id);
|
//template std::ostream & operator << <ObjectInstanceID>(std::ostream & os, BaseForID<ObjectInstanceID> id);
|
||||||
|
@@ -223,10 +223,10 @@ class ObjectInstanceID : public BaseForID<ObjectInstanceID>
|
|||||||
friend class CNonConstInfoCallback;
|
friend class CNonConstInfoCallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef INSTANTIATE_BASE_FOR_ID_HERE
|
// #ifndef INSTANTIATE_BASE_FOR_ID_HERE
|
||||||
extern template std::ostream & operator << <ArtifactInstanceID>(std::ostream & os, BaseForID<ArtifactInstanceID> id);
|
// extern template std::ostream & operator << <ArtifactInstanceID>(std::ostream & os, BaseForID<ArtifactInstanceID> id);
|
||||||
extern template std::ostream & operator << <ObjectInstanceID>(std::ostream & os, BaseForID<ObjectInstanceID> id);
|
// extern template std::ostream & operator << <ObjectInstanceID>(std::ostream & os, BaseForID<ObjectInstanceID> id);
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
// Enum declarations
|
// Enum declarations
|
||||||
namespace PrimarySkill
|
namespace PrimarySkill
|
||||||
|
Reference in New Issue
Block a user