mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Fix game startup
This commit is contained in:
@@ -135,6 +135,13 @@ private:
|
||||
////that const cast is evil because it allows to implicitly overwrite const objects when deserializing
|
||||
typedef typename std::remove_const_t<T> nonConstT;
|
||||
auto & hlp = const_cast<nonConstT &>(data);
|
||||
|
||||
if constexpr(std::is_base_of_v<IGameInfoCallback, std::remove_pointer_t<nonConstT>>)
|
||||
{
|
||||
assert(cb == nullptr);
|
||||
cb = &data;
|
||||
}
|
||||
|
||||
hlp.serialize(*this);
|
||||
}
|
||||
template<typename T, typename std::enable_if_t<std::is_array_v<T>, int> = 0>
|
||||
|
||||
@@ -124,9 +124,9 @@ void CConnection::enterLobbyConnectionMode()
|
||||
serializer->clear();
|
||||
}
|
||||
|
||||
void CConnection::setCallback(IGameInfoCallback * cb)
|
||||
void CConnection::setCallback(IGameInfoCallback & cb)
|
||||
{
|
||||
deserializer->cb = cb;
|
||||
deserializer->cb = &cb;
|
||||
}
|
||||
|
||||
void CConnection::setSerializationVersion(ESerializationVersion version)
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
std::unique_ptr<CPack> retrievePack(const std::vector<std::byte> & data);
|
||||
|
||||
void enterLobbyConnectionMode();
|
||||
void setCallback(IGameInfoCallback * cb);
|
||||
void setCallback(IGameInfoCallback & cb);
|
||||
void setSerializationVersion(ESerializationVersion version);
|
||||
};
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ struct ClassObjectCreator<T, typename std::enable_if_t<std::is_base_of_v<GameCal
|
||||
static T *invoke(IGameInfoCallback *cb)
|
||||
{
|
||||
static_assert(!std::is_abstract_v<T>, "Cannot call new upon abstract classes!");
|
||||
assert(cb != nullptr);
|
||||
return new T(cb);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user