- Should GeneralizedLocation in universe/Pathfinder.cpp accept std::shared_ptr by value? It doesn't looks like it takes ownership on this parameter.
- GeneralizedLocation outputs simple error to log if object is very wrong but actually it foreshadows segfaults. When I fixed segfault I also fix this error. Should GeneralizedLocation throw exception instead of logging error?
- m_existing maps aren't specialized by type but appropriate main objects' maps are. Is it intended?
- m_existing maps don't require to own objects because those objects are owned by appropriate main objects' maps. What if use std::weak_ptr?
- I suppose in possible to change boost::remove_const<T>::type to std::remove_const<T>::type as the game uses c++11.
Some questing about UniverseObject usage
Moderator: Committer
Some questing about UniverseObject usage
When I worked on https://github.com/freeorion/freeorion/issues/1897 I got some question about code to discuss:
Gentoo Linux x64, gcc-11.2, boost-1.78.0
Ubuntu Server 22.04 x64, gcc-12, boost-1.74.0
Welcome to the slow multiplayer game at freeorion-lt.dedyn.io.Version 2024-04-14.ad50e93.
Donations're welcome:BTC:bc1q007qldm6eppqcukewtfkfcj0naut9njj7audnm
Ubuntu Server 22.04 x64, gcc-12, boost-1.74.0
Welcome to the slow multiplayer game at freeorion-lt.dedyn.io.Version 2024-04-14.ad50e93.
Donations're welcome:BTC:bc1q007qldm6eppqcukewtfkfcj0naut9njj7audnm
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Some questing about UniverseObject usage
Could pass by const reference.
Probably. The main typed object maps are used to look up objects of a particular type and return a pointer of that type. The existing object lists aren't used like that so don't need to store more specialized UniverseObject pointers. That might be a circular rationale, though if they don't need to be specialized, then should they be?m_existing maps aren't specialized by type but appropriate main objects' maps are. Is it intended?
Seems like unnecessary overhead to convert the pointers. Aren't the sets maintained simultaneously anyway?m_existing maps don't require to own objects because those objects are owned by appropriate main objects' maps. What if use std::weak_ptr?
Sounds reasonable.change boost::remove_const<T>::type to std::remove_const<T>::type as the game uses c++11.