diff --git a/lib/Connection.h b/lib/Connection.h index 58767abd6..390490953 100644 --- a/lib/Connection.h +++ b/lib/Connection.h @@ -368,10 +368,11 @@ public: { /* if(id < 0) return NULL;*/ + si32 idAsNumber = idToNumber(id); assert(oInfo.vector); - assert(oInfo.vector->size() > id); - return const_cast((*oInfo.vector)[id].get()); + assert(oInfo.vector->size() > idAsNumber); + return const_cast((*oInfo.vector)[idAsNumber].get()); } template @@ -431,12 +432,30 @@ struct VectorizedIDType //else if mpl::eval_if, mpl::identity, + //else if + mpl::eval_if, + mpl::identity, + //else if + mpl::eval_if, + mpl::identity, //else mpl::identity - > - >::type type; + > > > >::type type; }; + +template +si32 idToNumber(const T &t, typename boost::enable_if >::type * dummy = 0) +{ + return t; +} + +template +si32 idToNumber(const BaseForID &t) +{ + return t.getNum(); +} + template struct VariantVisitorSaver : boost::static_visitor<> { @@ -586,9 +605,9 @@ public: typedef typename VectorizedIDType::type IDType; if(const auto *info = getVectorisedTypeInfo()) { - si32 id = getIdFromVectorItem(*info, data); + IDType id = getIdFromVectorItem(*info, data); *this << id; - if(id != -1) //vector id is enough + if(id != IDType(-1)) //vector id is enough return; } } @@ -961,11 +980,11 @@ public: typedef typename VectorizedIDType::type IDType; if(const auto *info = getVectorisedTypeInfo()) { - si32 id; + IDType id; *this >> id; - if(id != -1) + if(id != IDType(-1)) { - data = static_cast(getVectorItemFromId(*info, IDType(id))); + data = static_cast(getVectorItemFromId(*info, id)); return; } } diff --git a/lib/GameConstants.cpp b/lib/GameConstants.cpp index 5e92fa8a9..90d9974ca 100644 --- a/lib/GameConstants.cpp +++ b/lib/GameConstants.cpp @@ -89,5 +89,5 @@ CSpell * SpellID::toSpell() const return VLC->spellh->spells[*this]; } -template std::ostream & operator << (std::ostream & os, BaseForID id); -template std::ostream & operator << (std::ostream & os, BaseForID id); +//template std::ostream & operator << (std::ostream & os, BaseForID id); +//template std::ostream & operator << (std::ostream & os, BaseForID id); diff --git a/lib/GameConstants.h b/lib/GameConstants.h index 472952e25..1e4e824fb 100644 --- a/lib/GameConstants.h +++ b/lib/GameConstants.h @@ -223,10 +223,10 @@ class ObjectInstanceID : public BaseForID friend class CNonConstInfoCallback; }; -#ifndef INSTANTIATE_BASE_FOR_ID_HERE -extern template std::ostream & operator << (std::ostream & os, BaseForID id); -extern template std::ostream & operator << (std::ostream & os, BaseForID id); -#endif +// #ifndef INSTANTIATE_BASE_FOR_ID_HERE +// extern template std::ostream & operator << (std::ostream & os, BaseForID id); +// extern template std::ostream & operator << (std::ostream & os, BaseForID id); +// #endif // Enum declarations namespace PrimarySkill