Skip to content

Commit

Permalink
Revert some data changes
Browse files Browse the repository at this point in the history
  • Loading branch information
twist84 committed Dec 16, 2024
1 parent 7f81371 commit 5d4257e
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 148 deletions.
97 changes: 0 additions & 97 deletions game/source/memory/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,103 +4,6 @@

HOOK_DECLARE(0x0055B6D0, datum_try_and_get);

template<typename t_datum_type>
c_data_iterator<t_datum_type>::c_data_iterator() :
m_datum(),
iterator()
{
}

template<typename t_datum_type>
void c_data_iterator<t_datum_type>::begin(s_data_array* data)
{
data_iterator_begin(&iterator, data);
}

template<typename t_datum_type>
void c_data_iterator<t_datum_type>::begin(s_data_array const* data)
{
data_iterator_begin(&iterator, data);
}

template<typename t_datum_type>
short c_data_iterator<t_datum_type>::get_absolute_index() const
{
return DATUM_INDEX_TO_ABSOLUTE_INDEX(iterator.absolute_index);
}

template<typename t_datum_type>
long c_data_iterator<t_datum_type>::get_index() const
{
return iterator.index;
}

template<typename t_datum_type>
t_datum_type* c_data_iterator<t_datum_type>::get_datum() const
{
return m_datum;
}

template<typename t_datum_type>
bool c_data_iterator<t_datum_type>::next()
{
m_datum = (t_datum_type*)data_iterator_next(&iterator);
return m_datum != nullptr;
}

template<typename t_datum_type>
c_data_iterator_with_byte_flags<t_datum_type>::c_data_iterator_with_byte_flags() :
m_datum(),
m_flag_offset(),
m_flag_mask(),
m_flag_value(),
iterator()
{
}

template<typename t_datum_type>
void c_data_iterator_with_byte_flags<t_datum_type>::begin(s_data_array* data, long flag_offset, byte flag_mask, byte flag_value)
{
iterator.m_flag_offset = flag_offset;
iterator.m_flag_mask = flag_mask;
iterator.m_flag_value = flag_value;
data_iterator_begin(&iterator, data);
}

template<typename t_datum_type>
void c_data_iterator_with_byte_flags<t_datum_type>::begin(s_data_array const* data, long flag_offset, byte flag_mask, byte flag_value)
{
iterator.m_flag_offset = flag_offset;
iterator.m_flag_mask = flag_mask;
iterator.m_flag_value = flag_value;
data_iterator_begin(&iterator, data);
}

template<typename t_datum_type>
short c_data_iterator_with_byte_flags<t_datum_type>::get_absolute_index() const
{
return DATUM_INDEX_TO_ABSOLUTE_INDEX(iterator.absolute_index);
}

template<typename t_datum_type>
long c_data_iterator_with_byte_flags<t_datum_type>::get_index() const
{
return iterator.index;
}

template<typename t_datum_type>
t_datum_type* c_data_iterator_with_byte_flags<t_datum_type>::get_datum() const
{
return m_datum;
}

template<typename t_datum_type>
bool c_data_iterator_with_byte_flags<t_datum_type>::next()
{
m_datum = (t_datum_type*)data_iterator_next(&iterator);
return m_datum != nullptr;
}

long __cdecl data_allocation_size(long maximum_count, long size, long alignment_bits)
{
return INVOKE(0x0055AAB0, data_allocation_size, maximum_count, size, alignment_bits);
Expand Down
169 changes: 118 additions & 51 deletions game/source/memory/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ struct s_data_array
};
static_assert(sizeof(s_data_array) == 0x54);

struct s_data_iterator
{
s_data_array* data;
long index;
long absolute_index;
};
static_assert(sizeof(s_data_iterator) == 0xC);

template <typename t_datum_type>
struct c_smart_data_array
{
Expand Down Expand Up @@ -167,57 +175,6 @@ struct c_wrapped_data_array
};
static_assert(sizeof(c_wrapped_data_array<s_datum_header>) == sizeof(s_data_array*));

struct s_data_iterator
{
s_data_array* data;
long index;
long absolute_index;
};
static_assert(sizeof(s_data_iterator) == 0xC);

template<typename t_datum_type>
struct c_data_iterator
{
static_assert(std::is_same<t_datum_type, void>::value || std::is_base_of<s_datum_header, t_datum_type>::value);

public:
c_data_iterator();
void begin(s_data_array* data);
void begin(s_data_array const* data);
short get_absolute_index() const;
long get_index() const;
t_datum_type* get_datum() const;
bool next();

//protected:
t_datum_type* m_datum;
s_data_iterator iterator;
};
static_assert(sizeof(c_data_iterator<void>) == 0x10);

template<typename t_datum_type>
struct c_data_iterator_with_byte_flags
{
static_assert(std::is_same<t_datum_type, void>::value || std::is_base_of<s_datum_header, t_datum_type>::value);

public:
c_data_iterator_with_byte_flags();
void begin(s_data_array* data, long flag_offset, byte flag_mask, byte flag_value);
void begin(s_data_array const* data, long flag_offset, byte flag_mask, byte flag_value);
short get_absolute_index() const;
long get_index() const;
t_datum_type* get_datum() const;
bool next();

//protected:
t_datum_type* m_datum;
long m_flag_offset;
byte m_flag_mask;
byte m_flag_value;
s_data_iterator iterator;
};
static_assert(sizeof(c_data_iterator_with_byte_flags<void>) == 0x18);

extern long __cdecl data_allocation_size(long maximum_count, long size, long alignment_bits);
extern void __cdecl data_connect(s_data_array* data, long count, void* datums);
extern void __cdecl data_copy(s_data_array const* src, s_data_array* dst);
Expand Down Expand Up @@ -260,3 +217,113 @@ extern void* __cdecl datum_get_absolute(s_data_array* data, long index);
extern void* __cdecl datum_try_and_get_absolute(s_data_array const* data, long index);
extern void* __cdecl datum_try_and_get_unsafe(s_data_array const* data, long index);

template<typename t_datum_type>
struct c_data_iterator
{
static_assert(std::is_same<t_datum_type, void>::value || std::is_base_of<s_datum_header, t_datum_type>::value);

public:
c_data_iterator() :
m_datum(),
iterator()
{
}

void begin(s_data_array* data)
{
data_iterator_begin(&iterator, data);
}

void begin(s_data_array const* data)
{
data_iterator_begin(&iterator, data);
}

short get_absolute_index() const
{
return DATUM_INDEX_TO_ABSOLUTE_INDEX(iterator.absolute_index);
}

long get_index() const
{
return iterator.index;
}

t_datum_type* get_datum() const
{
return m_datum;
}

bool next()
{
m_datum = (t_datum_type*)data_iterator_next(&iterator);
return m_datum != nullptr;
}

//protected:
t_datum_type* m_datum;
s_data_iterator iterator;
};
static_assert(sizeof(c_data_iterator<void>) == 0x10);

template<typename t_datum_type>
struct c_data_iterator_with_byte_flags
{
static_assert(std::is_same<t_datum_type, void>::value || std::is_base_of<s_datum_header, t_datum_type>::value);

public:
c_data_iterator_with_byte_flags() :
m_datum(),
m_flag_offset(),
m_flag_mask(),
m_flag_value(),
iterator()
{
}

void begin(s_data_array* data, long flag_offset, byte flag_mask, byte flag_value)
{
iterator.m_flag_offset = flag_offset;
iterator.m_flag_mask = flag_mask;
iterator.m_flag_value = flag_value;
data_iterator_begin(&iterator, data);
}

void begin(s_data_array const* data, long flag_offset, byte flag_mask, byte flag_value)
{
iterator.m_flag_offset = flag_offset;
iterator.m_flag_mask = flag_mask;
iterator.m_flag_value = flag_value;
data_iterator_begin(&iterator, data);
}

short get_absolute_index() const
{
return DATUM_INDEX_TO_ABSOLUTE_INDEX(iterator.absolute_index);
}

long get_index() const
{
return iterator.index;
}

t_datum_type* get_datum() const
{
return m_datum;
}

bool next()
{
m_datum = (t_datum_type*)data_iterator_next(&iterator);
return m_datum != nullptr;
}

//protected:
t_datum_type* m_datum;
long m_flag_offset;
byte m_flag_mask;
byte m_flag_value;
s_data_iterator iterator;
};
static_assert(sizeof(c_data_iterator_with_byte_flags<void>) == 0x18);

0 comments on commit 5d4257e

Please sign in to comment.