polserver/pol-core/pol/startloc.cpp
turleypol c046da4d5a
Moved target/menu members from char to ClientGameData, simplified memory size estimation (#668)
* moved more members from Character to ClientGameData
reordered a few members to reduce padding
added memsize functions for std containers to simplify code

* few more comments
2024-07-28 10:42:47 +02:00

32 lines
732 B
C++

/** @file
*
* @par History
*/
#include "startloc.h"
#include "../clib/random.h"
#include "../clib/stlutil.h"
namespace Pol
{
namespace Core
{
Pos4d StartingLocation::select_coordinate() const
{
int sidx = Clib::random_int( static_cast<int>( coords.size() - 1 ) );
return Pos4d( coords[sidx], realm );
}
size_t StartingLocation::estimateSize() const
{
size_t size = city.capacity() + desc.capacity() + sizeof( Realms::Realm* ) /*realm*/
+ sizeof( unsigned short ) /*mapid*/
+ sizeof( unsigned long ) /*cliloc_desc*/
+ Clib::memsize( coords );
return size;
}
} // namespace Core
} // namespace Pol