Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/helpers/ArrayData.h
- This file was added.
#ifndef ARRAYDATA | |||||
#define ARRAYDATA | |||||
Silier: copyright | |||||
#include "simulation2/serialization/SerializeTemplates.h" | |||||
#include <limits> | |||||
void Simulation_SetNumberOfPlayersReadOnly(bool readOnly); | |||||
size_t Simulation_GetNumberOfPlayers(); | |||||
void Simulation_SetNumberOfPlayers(size_t number); | |||||
template <size_t extra> | |||||
class ArrayData | |||||
{ | |||||
public: | |||||
ArrayData(); | |||||
ArrayData(u64 value); | |||||
ArrayData(std::vector<u8> vector); | |||||
Done Inline ActionsI would be careful using u64 as we still compile with 32 bit compiler, that means storing that value in 2 registers instead just one what makes reading and writing slower. (just a note, did not check if we can do something about it to not use u64) Silier: I would be careful using u64 as we still compile with 32 bit compiler, that means storing that… | |||||
Done Inline Actionsok nani: ok | |||||
static size_t size(); | |||||
constexpr static u64 maxValue(){ return std::numeric_limits<u64>::max(); } | |||||
u8 get(size_t i) const; | |||||
void set(size_t i, u8 v); | |||||
Done Inline Actionsminus one \n Silier: minus one \n | |||||
void fill(u64 value); | |||||
void fillZeros(); | |||||
void fillOnes(); | |||||
bool isZero() const; | |||||
bool andExpandedMask(const ArrayData<extra>& second, u64 expandedMask) const; | |||||
void setBitwiseOr(const ArrayData<extra>& second); | |||||
bool isEqual(const ArrayData<extra>& second) const; | |||||
Done Inline ActionsArrayData<extra>& Silier: `ArrayData<extra>& ` | |||||
Done Inline ActionsArrayData<extra>& Silier: `ArrayData<extra>& ` | |||||
bool operator==(const ArrayData<extra>& second) const; | |||||
Done Inline ActionsArrayData<extra>& Silier: `ArrayData<extra>& ` | |||||
template <size_t extra_> | |||||
friend struct SerializeArrayData; | |||||
private: | |||||
size_t sizeInternal() const; | |||||
u8 getInternal(size_t i) const; | |||||
void setInternal(size_t i, u16 v); | |||||
int index(int i) const; | |||||
u64 m_data; | |||||
}; | |||||
template <size_t extra_> | |||||
struct SerializeArrayData | |||||
{ | |||||
void operator()(ISerializer& serialize, const char* name, ArrayData<extra_>& value); | |||||
void operator()(IDeserializer& deserialize, const char* name, ArrayData<extra_>& value); | |||||
}; | |||||
using PlayersData = ArrayData<0>; | |||||
using OwnersData = ArrayData<2>; | |||||
Not Done Inline ActionsIs there a convention for this? players_data_t? Dunno just wondering Stan: Is there a convention for this?
players_data_t? Dunno just wondering | |||||
using SerializePlayersData = SerializeArrayData<0>; | |||||
using SerializeOwnersData = SerializeArrayData<2>; | |||||
#endif // ARRAYDATA |
Wildfire Games · Phabricator
copyright