Skip to content

Commit

Permalink
fix static bit storage clearing, fixes weapon super-positions when in…
Browse files Browse the repository at this point in the history
…terpolating
  • Loading branch information
nukeulater committed Dec 25, 2023
1 parent 38c52cc commit d8d42cc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion xlive/Blam/Engine/cseries/cseries.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static_assert(sizeof(real64) == 8);
typedef long datum;
static_assert(sizeof(datum) == 4);

#define SIZEOF_BITS(value) 8 * sizeof(value)
#define SIZEOF_BITS(value) (8 * sizeof(value))
#define CHAR_BITS SIZEOF_BITS(int8)
#define SHORT_BITS SIZEOF_BITS(int16)
#define LONG_BITS SIZEOF_BITS(int32)
Expand Down
38 changes: 22 additions & 16 deletions xlive/Blam/Engine/memory/static_arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ template<typename t_type, typename t_storage_type, size_t k_count>
class c_flags
{
public:
c_flags() : m_storage(0)
c_flags()
: m_storage(0)
{
return;
}

c_flags(t_storage_type raw_bits) : m_storage(raw_bits)
c_flags(t_storage_type raw_bits)
: m_storage(raw_bits)
{
return;
}
Expand Down Expand Up @@ -79,23 +81,26 @@ class c_flags
t_storage_type m_storage;
};

template<size_t k_maximum_count>
template<size_t k_maximum_bit_count>
class c_static_flags_no_init
{
public:
void* clear(void)
void clear(void)
{
return csmemset(this->m_flags, 0, NUMBEROF(m_flags));
csmemset(m_flags, 0, BIT_VECTOR_SIZE_IN_BYTES(k_maximum_bit_count));
return;
}

void* clear_range(int32 count)
void clear_range(int32 count)
{
return csmemset(this->m_flags, 0, BIT_VECTOR_SIZE_IN_BYTES(count));
csmemset(m_flags, 0, BIT_VECTOR_SIZE_IN_BYTES(count));
return;
}

void* fill(int32 count, uint8 value)
void fill(int32 count, uint8 value)
{
return csmemset(this->m_flags, value, BIT_VECTOR_SIZE_IN_BYTES(count));
csmemset(m_flags, value, BIT_VECTOR_SIZE_IN_BYTES(count));
return;
}

const int32* get_bits_direct(void) const
Expand All @@ -110,26 +115,27 @@ class c_static_flags_no_init

void set(int32 index, bool enable)
{
BIT_VECTOR_SET_FLAG(this->m_flags, index, enable);
BIT_VECTOR_SET_FLAG(m_flags, index, enable);
return;
}

void* set_bits_direct_destructive(int32 count, uint8 value)
void set_bits_direct_destructive(int32 count, uint8 value)
{
return csmemcpy(this->m_flags, value, BIT_VECTOR_SIZE_IN_BYTES(count));
csmemcpy(m_flags, value, BIT_VECTOR_SIZE_IN_BYTES(count));
return;
}

bool test(int32 index)
{
return BIT_VECTOR_TEST_FLAG(this->m_flags, index);
return BIT_VECTOR_TEST_FLAG(m_flags, index);
}

protected:
int32 m_flags[k_maximum_count / LONG_BITS];
int32 m_flags[k_maximum_bit_count / LONG_BITS];
};

template<size_t k_maximum_count>
class c_static_flags : public c_static_flags_no_init<k_maximum_count>
template<size_t k_maximum_bit_count>
class c_static_flags : public c_static_flags_no_init<k_maximum_bit_count>
{
public:
c_static_flags(void) = default;
Expand Down
5 changes: 1 addition & 4 deletions xlive/Blam/Engine/objects/objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,7 @@ void __cdecl objects_post_update()

if (object_header->flags.test(_object_header_requires_motion_bit))
object_move(object_header_it.get_current_datum_index());

}
object_initialize_for_interpolation(object_header_it.get_current_datum_index());

}

weapons_fire_barrels();
Expand Down Expand Up @@ -1023,8 +1020,8 @@ void object_new_replace_calls(void)
void object_move_replace_calls(void)
{
PatchCall(Memory::GetAddress(0x137f8f), object_move);
PatchCall(Memory::GetAddress(0x13814b), object_move);
PatchCall(Memory::GetAddress(0x1381b1), object_move);
PatchCall(Memory::GetAddress(0x13814b), object_move);
return;
}

Expand Down

0 comments on commit d8d42cc

Please sign in to comment.