Skip to content

Commit

Permalink
Added INVOKE_CLASS_MEMBER
Browse files Browse the repository at this point in the history
  • Loading branch information
theTwister authored and theTwister committed Sep 11, 2023
1 parent 7fad368 commit 2aee86a
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 95 deletions.
6 changes: 3 additions & 3 deletions game/source/cache/cache_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ dword __cdecl compute_realtime_checksum(char* a1, int a2)
return INVOKE(0x00502300, compute_realtime_checksum, a1, a2);
}

void __cdecl cache_file_load_reports(s_cache_file_reports* reports, s_cache_file_header* header)
void __thiscall s_cache_file_reports::load(s_cache_file_header* header)
{
DECLFUNC(0x00502500, void, __thiscall, s_cache_file_reports*, s_cache_file_header*)(reports, header);
INVOKE_CLASS_MEMBER(0x00502500, s_cache_file_reports::load, header);
}

void __cdecl cache_file_tags_load_resource_gestalt_resource_offsets_from_disk(c_wrapped_array<long>* resource_offsets)
Expand Down Expand Up @@ -816,7 +816,7 @@ bool __cdecl scenario_tags_load(char const* scenario_path)

cache_file_load_tags_section();

cache_file_load_reports(&g_cache_file_globals.reports, &g_cache_file_globals.header);
g_cache_file_globals.reports.load(&g_cache_file_globals.header);
cache_file_tags_load_allocate();

dword total_instance_size = sizeof(cache_file_tag_instance*) * g_cache_file_globals.tag_total_count;
Expand Down
6 changes: 4 additions & 2 deletions game/source/cache/cache_files.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ struct s_file_reference_persist
tag signture;
word_flags flags;
short location;
char path[108];
c_static_string<108> path;
dword handle;
long position;
};
static_assert(sizeof(s_file_reference_persist) == 0x7C);

struct s_cache_file_report
{
char __unknown0[32];
c_static_string<32> __string0;
dword hash[5];
s_file_reference_persist file_reference;
dword __unknownB0[20];
Expand All @@ -188,6 +188,8 @@ static_assert(sizeof(s_cache_file_report) == 0x114);

struct s_cache_file_reports
{
void __thiscall load(s_cache_file_header* header);

long count;
s_cache_file_report* elements;
};
Expand Down
2 changes: 1 addition & 1 deletion game/source/camera/debug_director.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ e_camera_mode k_debug_camera_modes[] = { _camera_mode_flying, _camera_mode_follo
void c_debug_director::constructor(long user_index)
{
changed_camera();
DECLFUNC(0x007260D0, void, __thiscall, c_director*, long)(this, user_index);
INVOKE_CLASS_MEMBER(0x007260D0, c_debug_director::constructor, user_index);
}

void c_debug_director::changed_camera()
Expand Down
5 changes: 5 additions & 0 deletions game/source/cseries/cseries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "math/integer_math.hpp"
#include "math/matrix_math.hpp"
#include "math/real_math.hpp"
#include "memory/member_to_static.hpp"

#include <stdarg.h>
#include <type_traits>
Expand All @@ -19,6 +20,10 @@
#define DECLFUNC(ADDR, R, CC, ...) reinterpret_cast<R(CC*)(__VA_ARGS__)>(ADDR)
#define INVOKE(ADDR, TYPE, ...) reinterpret_cast<decltype(TYPE)*>(ADDR)(__VA_ARGS__)

// give the full function name including class
#define INVOKE_CLASS_MEMBER(ADDR, NAME, ...) (this->*static_to_member_t<decltype(&NAME)>{ .address = ADDR }.function)(__VA_ARGS__)


#define OFFSETOF(s,m) __builtin_offsetof(s,m)
#define NUMBEROF(_array) (sizeof(_array) / sizeof(_array[0]))
#define IN_RANGE_INCLUSIVE(value, begin, end) (((value) >= (begin)) && ((value) <= (end)))
Expand Down
14 changes: 7 additions & 7 deletions game/source/memory/bitstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,32 +441,32 @@ void __cdecl c_bitstream::write_secure_address(char const* name, s_transport_sec
DECLFUNC(0x0055A410, void, __thiscall, c_bitstream const*, char const*, s_transport_secure_address const*)(this, name, address);
}

void __cdecl c_bitstream::write_string(char const* name, char const* _string, long max_string_size)
void __cdecl c_bitstream::write_string(char const* name, char const* string, long max_string_size)
{
ASSERT(writing());
ASSERT(_string);
ASSERT(string);
ASSERT(max_string_size > 0);
//ASSERT(strnlen(_string, max_string_size) < max_string_size);

DECLFUNC(0x0055A430, void, __thiscall, c_bitstream const*, char const*, char const*, long)(this, name, _string, max_string_size);
DECLFUNC(0x0055A430, void, __thiscall, c_bitstream const*, char const*, char const*, long)(this, name, string, max_string_size);
}

void __cdecl c_bitstream::write_string_utf8(char const* name, utf8 const* char_string, long max_string_size)
{
ASSERT(writing());
ASSERT(char_string);
ASSERT(max_string_size > 0);
//ASSERT(strnlen(char_string, max_string_size) < max_string_size);
ASSERT(csstrnlen(char_string, max_string_size) < max_string_size);

DECLFUNC(0x0055A650, void, __thiscall, c_bitstream const*, char const*, utf8 const*, long)(this, name, char_string, max_string_size);
}

void __cdecl c_bitstream::write_string_wchar(char const* name, wchar_t const* _string, long max_string_size)
void __cdecl c_bitstream::write_string_wchar(char const* name, wchar_t const* string, long max_string_size)
{
ASSERT(writing());
ASSERT(_string);
ASSERT(string);
ASSERT(max_string_size > 0);

DECLFUNC(0x0055A6D0, void, __thiscall, c_bitstream const*, char const*, wchar_t const*, long)(this, name, _string, max_string_size);
DECLFUNC(0x0055A6D0, void, __thiscall, c_bitstream const*, char const*, wchar_t const*, long)(this, name, string, max_string_size);
}

6 changes: 3 additions & 3 deletions game/source/memory/bitstream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ struct c_bitstream
void __cdecl write_quantized_real(char const* name, real* value, real min_value, real max_value, long size_in_bits, bool exact_midpoint, bool exact_endpoints);
void __cdecl write_qword_internal(qword value, long size_in_bits);
void __cdecl write_secure_address(char const* name, s_transport_secure_address const* address);
void __cdecl write_string(char const* name, char const* _string, long max_string_size);
void __cdecl write_string_utf8(char const* name, utf8 const* _string, long max_string_size);
void __cdecl write_string_wchar(char const* name, wchar_t const* _string, long max_string_size);
void __cdecl write_string(char const* name, char const* string, long max_string_size);
void __cdecl write_string_utf8(char const* name, utf8 const* char_string, long max_string_size);
void __cdecl write_string_wchar(char const* name, wchar_t const* string, long max_string_size);

template<typename t_enum, long size_in_bits>
void __cdecl write_enum(char const* name, t_enum value)
Expand Down
6 changes: 3 additions & 3 deletions game/source/memory/hashtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ c_hash::~c_hash()

dword __cdecl c_hash::add_byte(byte byte_to_add)
{
return DECLFUNC(0x00967EA0, dword, __thiscall, c_hash*, byte)(this, byte_to_add);
return INVOKE_CLASS_MEMBER(0x00967EA0, c_hash::add_byte, byte_to_add);

//ASSERT((m_polynomial_index >= 0) && (m_polynomial_index < k_hash_polynomial_count));
//
Expand All @@ -32,7 +32,7 @@ dword __cdecl c_hash::add_byte(byte byte_to_add)

dword __cdecl c_hash::add_data_range(void const* data, long data_size)
{
return DECLFUNC(0x00967EE0, dword, __thiscall, c_hash*, void const*, long)(this, data, data_size);
return INVOKE_CLASS_MEMBER(0x00967EE0, c_hash::add_data_range, data, data_size);

//for (long i = 0; i < data_size; i++)
// add_byte(static_cast<byte const*>(data)[i]);
Expand All @@ -42,7 +42,7 @@ dword __cdecl c_hash::add_data_range(void const* data, long data_size)

dword __cdecl c_hash::get_hash() const
{
return DECLFUNC(0x00967F30, dword, __thiscall, c_hash const*)(this);
return INVOKE_CLASS_MEMBER(0x00967F30, c_hash::get_hash);

//return m_hash;
}
Expand Down
10 changes: 5 additions & 5 deletions game/source/memory/read_write_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ c_read_write_lock::~c_read_write_lock()

void __cdecl c_read_write_lock::read_lock()
{
DECLFUNC(0x006EF4D0, void, __thiscall, c_read_write_lock*)(this);
INVOKE_CLASS_MEMBER(0x006EF4D0, c_read_write_lock::read_lock);
}

void __cdecl c_read_write_lock::read_unlock()
{
DECLFUNC(0x006EF4E0, void, __thiscall, c_read_write_lock*)(this);
INVOKE_CLASS_MEMBER(0x006EF4E0, c_read_write_lock::read_unlock);
}


void __cdecl c_read_write_lock::setup(long critcal_section_index, long semaphore_index)
{
DECLFUNC(0x006EF4F0, void, __thiscall, c_read_write_lock*, long, long)(this, critcal_section_index, semaphore_index);
INVOKE_CLASS_MEMBER(0x006EF4F0, c_read_write_lock::setup, critcal_section_index, semaphore_index);
}

void __cdecl c_read_write_lock::write_lock()
{
DECLFUNC(0x006EF530, void, __thiscall, c_read_write_lock*)(this);
INVOKE_CLASS_MEMBER(0x006EF530, c_read_write_lock::write_lock);
}

void __cdecl c_read_write_lock::write_unlock()
{
DECLFUNC(0x006EF570, void, __thiscall, c_read_write_lock*)(this);
INVOKE_CLASS_MEMBER(0x006EF570, c_read_write_lock::write_unlock);
}

2 changes: 1 addition & 1 deletion game/source/networking/delivery/network_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void __cdecl c_network_channel::close(e_network_channel_closure_reason closure_r

void __cdecl c_network_channel::open(transport_address const* remote_address, bool send_connect_packets, long channel_identifier)
{
DECLFUNC(0x004603B0, void, __thiscall, c_network_channel*, transport_address const*, bool, long)(this, remote_address, send_connect_packets, channel_identifier);
INVOKE_CLASS_MEMBER(0x004603B0, c_network_channel::open, remote_address, send_connect_packets, channel_identifier);

//ASSERT(remote_address && transport_address_valid(remote_address));
//ASSERT(allocated());
Expand Down
4 changes: 2 additions & 2 deletions game/source/networking/delivery/network_link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bool __cdecl c_network_link::create_endpoints()

bool c_network_link::decode_packet(long data_buffer_size, byte const* data_buffer, s_link_packet* packet) const
{
return DECLFUNC(0x0043B820, bool, __thiscall, c_network_link const*, long, byte const*, s_link_packet*)(this, data_buffer_size, data_buffer, packet);
return INVOKE_CLASS_MEMBER(0x0043B820, c_network_link::decode_packet, data_buffer_size, data_buffer, packet);
}

void __cdecl c_network_link::destroy_endpoints()
Expand Down Expand Up @@ -143,5 +143,5 @@ void __cdecl c_network_link::send_out_of_band(c_bitstream const* game_data, tran
ASSERT(game_data);
ASSERT(address);

DECLFUNC(0x0043C250, void, __thiscall, c_network_link*, c_bitstream const*, transport_address const*, long*)(this, game_data, address, out_size_on_wire);
INVOKE_CLASS_MEMBER(0x0043C250, c_network_link::send_out_of_band, game_data, address, out_size_on_wire);
}
2 changes: 1 addition & 1 deletion game/source/networking/logic/network_recruiting_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ REFERENCE_DECLARE(0x0228E6E0, s_network_recruiting_search_globals, g_recruiting_

void __cdecl c_recruiting_seeker::update()
{
DECLFUNC(0x004E6E20, void, __thiscall, c_recruiting_seeker*)(this);
INVOKE_CLASS_MEMBER(0x004E6E20, c_recruiting_seeker::update);
}

bool __cdecl network_recruiting_search_begin(long controller_index,long squad_search_flags,long maximum_session_count, s_available_session* session_storage)
Expand Down
Loading

0 comments on commit 2aee86a

Please sign in to comment.