Skip to content

Commit

Permalink
Finally made generate_event a macro
Browse files Browse the repository at this point in the history
  • Loading branch information
twist84 committed Dec 21, 2024
1 parent 7cdaacc commit 01d0221
Show file tree
Hide file tree
Showing 107 changed files with 498 additions and 501 deletions.
2 changes: 1 addition & 1 deletion game/source/ai/ai_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void __cdecl ai_scripting_erase_all()
//INVOKE(0x0143EBC0, ai_scripting_erase_all);

if (ai_print_scripting)
generate_event(_event_warning, "ai: %s: ai_erase_all", hs_runtime_get_executing_thread_name());
GENERATE_EVENT(_event_warning, "ai: %s: ai_erase_all", hs_runtime_get_executing_thread_name());

ai_erase(NONE, false);
}
Expand Down
14 changes: 7 additions & 7 deletions game/source/cache/cache_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ bool __cdecl scenario_tags_load(char const* scenario_path)
long tag_index = NONE;
bool success = false;

generate_event(_event_message, "cache: scenario load tags, name=%s", scenario_path);
GENERATE_EVENT(_event_message, "cache: scenario load tags, name=%s", scenario_path);

cache_file_invalidate_signature();

Expand Down Expand Up @@ -1262,15 +1262,15 @@ bool __cdecl scenario_tags_load(char const* scenario_path)
success = g_cache_file_globals.tag_cache_base_address != NULL;
if (!success)
{
generate_event(_event_critical, "failed to allocate the physical memory for the tags");
GENERATE_EVENT(_event_critical, "failed to allocate the physical memory for the tags");
}

if (success)
success = cache_file_debug_tag_names_load();

if (!success)
{
generate_event(_event_critical, "failed to load debug tag names");
GENERATE_EVENT(_event_critical, "failed to load debug tag names");
}

if (bool cache_file_global_tags_loaded = cache_file_tags_load_recursive(0))
Expand All @@ -1289,7 +1289,7 @@ bool __cdecl scenario_tags_load(char const* scenario_path)
if (!success)
{
global_preferences_invalidate_maps();
generate_event(_event_critical, "failed to read the tag data section");
GENERATE_EVENT(_event_critical, "failed to read the tag data section");
}

// #TODO: security stuff
Expand Down Expand Up @@ -1348,7 +1348,7 @@ bool __cdecl scenario_tags_load(char const* scenario_path)
//success = string_id_load_strings(&g_cache_file_globals.header);
if (!success)
{
generate_event(_event_error, "networking:failed to load the string ids [%s]", scenario_path);
GENERATE_EVENT(_event_error, "networking:failed to load the string ids [%s]", scenario_path);
}
}

Expand All @@ -1373,7 +1373,7 @@ bool __cdecl scenario_tags_load(char const* scenario_path)

if (!success)
{
generate_event(_event_critical, "failed to load tags for cache file");
GENERATE_EVENT(_event_critical, "failed to load tags for cache file");
cache_file_tags_unload();
cache_file_close();
ASSERT(tag_index == NONE);
Expand All @@ -1396,7 +1396,7 @@ bool __cdecl scenario_tags_load(char const* scenario_path)
success = true;
}

generate_event(_event_message, "cache: scenario load tags, success=%s", success ? "true" : "false");
GENERATE_EVENT(_event_message, "cache: scenario load tags, success=%s", success ? "true" : "false");

return success;
}
Expand Down
4 changes: 2 additions & 2 deletions game/source/cache/cache_files_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ void __cdecl cached_map_files_open_all(bool* success)
{
//INVOKE(0x005ABF00, cached_map_files_open_all, success);

generate_event(_event_message, "cache: open all cache map files");
GENERATE_EVENT(_event_message, "cache: open all cache map files");

if (g_cache_files_are_absolute)
{
Expand Down Expand Up @@ -947,7 +947,7 @@ void __cdecl cached_map_files_open_all(bool* success)
*success = false;
}

generate_event(_event_message, "cache: open all cache map files complete");
GENERATE_EVENT(_event_message, "cache: open all cache map files complete");
}

void __cdecl canonicalize_map_path(char const* path, c_static_string<256>* out_path)
Expand Down
2 changes: 1 addition & 1 deletion game/source/cache/security_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void __cdecl security_get_working_memory(e_secure_memory_region region, void** o

if (g_secure_memory_size < k_secure_memory_size)
{
generate_event(_event_critical, "security: failed to get working memory");
GENERATE_EVENT(_event_critical, "security: failed to get working memory");
*out_working_memory = NULL;
*out_working_memory_size = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion game/source/camera/first_person_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void __thiscall c_first_person_camera::_update(long user_index, real dt, s_obser
long unit_index = player_mapping_get_unit_by_output_user(user_index);
if (m_target_object_index != unit_index)
{
generate_event(_event_error, "camera: first person camera #%d attached to object 0x%08X != user object 0x%08X, this should never happen",
GENERATE_EVENT(_event_error, "camera: first person camera #%d attached to object 0x%08X != user object 0x%08X, this should never happen",
user_index,
m_target_object_index,
unit_index);
Expand Down
6 changes: 3 additions & 3 deletions game/source/cseries/async_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool c_async_buffer_set::allocate_storage(c_allocation_base* allocator, long buf
//
// if (!buffer->data)
// {
// generate_event(_event_critical, "### async_double_bufffer: failed to allocate %d bytes for buffer %d", buffer_size, buffer_index);
// GENERATE_EVENT(_event_critical, "### async_double_bufffer: failed to allocate %d bytes for buffer %d", buffer_size, buffer_index);
// failed_to_allocate_storage = true;
// break;
// }
Expand Down Expand Up @@ -119,7 +119,7 @@ bool c_async_buffer_set::close_file()
// c_synchronized_long done = 0;
// if (async_close_file(m_async_file_handle, _async_category_none, _async_priority_blocking_generic, &done) == NONE)
// {
// generate_event(_event_warning, "async:double_buffer: failed to close file");
// GENERATE_EVENT(_event_warning, "async:double_buffer: failed to close file");
// }
// else
// {
Expand Down Expand Up @@ -167,7 +167,7 @@ void c_async_buffer_set::complete_pending_async_buffer_activity()
// }
// else
// {
// generate_event(_event_warning, "async:double_buffer: fatal error encountered during write (expected byte count 0x%8X != 0x%8X)", buffer->__unknown18, buffer->__unknown14);
// GENERATE_EVENT(_event_warning, "async:double_buffer: fatal error encountered during write (expected byte count 0x%8X != 0x%8X)", buffer->__unknown18, buffer->__unknown14);
// m_fatal_error_occurred = true;
// }
// }
Expand Down
28 changes: 14 additions & 14 deletions game/source/cseries/async_xoverlapped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,14 @@ bool __cdecl overlapped_task_start_internal(c_overlapped_task* task, char const*
}
else
{
generate_event(_event_warning, "xoverlapped: task context string '%s' not added to error-code-injection table, maximum tasks already being tracked!",
GENERATE_EVENT(_event_warning, "xoverlapped: task context string '%s' not added to error-code-injection table, maximum tasks already being tracked!",
task->get_context_string());
}
}
}
else
{
generate_event(_event_warning, "xoverlapped: task context string '%s' is too long to fit into error-code-injection table (maximum %ld characters)",
GENERATE_EVENT(_event_warning, "xoverlapped: task context string '%s' is too long to fit into error-code-injection table (maximum %ld characters)",
task->get_context_string(),
64);
}
Expand All @@ -322,7 +322,7 @@ bool __cdecl overlapped_task_start_internal(c_overlapped_task* task, char const*
}
else
{
generate_event(_event_status, "xoverlapped: overlapped_task_start() failed: maximum tasks already active!");
GENERATE_EVENT(_event_status, "xoverlapped: overlapped_task_start() failed: maximum tasks already active!");
}

return result;
Expand Down Expand Up @@ -508,7 +508,7 @@ void __cdecl task_now_finished(s_task_slot* task_slot, dword return_result, dwor
{
if (g_overlapped_globals.inject_error_context.is_equal(task_slot->task->get_context_string()))
{
generate_event(_event_warning, "xoverlapped: injecting error for task %s",
GENERATE_EVENT(_event_warning, "xoverlapped: injecting error for task %s",
g_overlapped_globals.inject_error_context.get_string());

succeeded = false;
Expand All @@ -524,7 +524,7 @@ void __cdecl task_now_finished(s_task_slot* task_slot, dword return_result, dwor
task_state = _overlapped_task_state_succeeded;
task_slot->task->success(return_result);

generate_event(_event_status, "xoverlapped: task '%s' succeeded. return result= %s",
GENERATE_EVENT(_event_status, "xoverlapped: task '%s' succeeded. return result= %s",
task_slot->task->get_context_string(),
online_error_get_string(return_result).get_string());
}
Expand All @@ -540,14 +540,14 @@ void __cdecl task_now_finished(s_task_slot* task_slot, dword return_result, dwor
overlapped_error == ERROR_CANCELLED ||
overlapped_error == ERROR_FUNCTION_FAILED && overlapped_extended_error == ERROR_CANCELLED)
{
generate_event(_event_message, "xoverlapped: task '%s' was cancelled.",
GENERATE_EVENT(_event_message, "xoverlapped: task '%s' was cancelled.",
task_slot->task->get_context_string());
}
else
{
if (csstrcmp("XStringVerify", task_slot->task->get_context_string()) != 0)
{
generate_event(_event_warning, "xoverlapped: task '%s' failed. calling result= %s, error= %s, extended error= %s, file= '%s', line= '%ld'",
GENERATE_EVENT(_event_warning, "xoverlapped: task '%s' failed. calling result= %s, error= %s, extended error= %s, file= '%s', line= '%ld'",
task_slot->task->get_context_string(),
online_error_get_string(calling_result).get_string(),
online_error_get_string(overlapped_error).get_string(),
Expand Down Expand Up @@ -643,7 +643,7 @@ void overlapped_tasks_log_to_debug_txt(e_event_level event_level)
break;
}

generate_event(event_level, "xoverlapped: #%ld task info: context= '%s', status= '%s', file= '%s', line= '%ld'",
GENERATE_EVENT(event_level, "xoverlapped: #%ld task info: context= '%s', status= '%s', file= '%s', line= '%ld'",
task_index + 1,
task_slot->task->get_context_string(),
status,
Expand All @@ -660,12 +660,12 @@ void overlapped_task_display_task_descriptions()
{
c_async_xoverlapped_scope_lock scope_lock;

generate_event(_event_warning, "xoverlapped: dumping task descriptions [count %d]",
GENERATE_EVENT(_event_warning, "xoverlapped: dumping task descriptions [count %d]",
g_overlapped_globals.description_count);

for (long description_index = 0; description_index < g_overlapped_globals.description_count; description_index++)
{
generate_event(_event_warning, "xoverlapped: %s",
GENERATE_EVENT(_event_warning, "xoverlapped: %s",
g_overlapped_globals.descriptions[description_index].get_string());
}
}
Expand All @@ -686,7 +686,7 @@ void overlapped_task_inject_error(char const* context, bool inject_error)

if (context_matches_description)
{
generate_event(_event_warning, "xoverlapped: setting error injection for %s to %s",
GENERATE_EVENT(_event_warning, "xoverlapped: setting error injection for %s to %s",
context,
inject_error ? "TRUE" : "FALSE");

Expand All @@ -695,7 +695,7 @@ void overlapped_task_inject_error(char const* context, bool inject_error)
}
else
{
generate_event(_event_warning, "xoverlapped: failed to find setting error injection for %s to %s",
GENERATE_EVENT(_event_warning, "xoverlapped: failed to find setting error injection for %s to %s",
context,
inject_error ? "TRUE" : "FALSE");
}
Expand All @@ -717,7 +717,7 @@ void overlapped_task_pause(char const* context, bool pause)

if (context_matches_description)
{
generate_event(_event_warning, "xoverlapped: setting pause for %s to %s",
GENERATE_EVENT(_event_warning, "xoverlapped: setting pause for %s to %s",
context,
pause ? "TRUE" : "FALSE");

Expand All @@ -726,7 +726,7 @@ void overlapped_task_pause(char const* context, bool pause)
}
else
{
generate_event(_event_warning, "xoverlapped: failed to find setting pause for %s to %s",
GENERATE_EVENT(_event_warning, "xoverlapped: failed to find setting pause for %s to %s",
context,
pause ? "TRUE" : "FALSE");
}
Expand Down
12 changes: 6 additions & 6 deletions game/source/cseries/cseries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ void display_assert(char const* statement, char const* file, long line, bool ass

if (assertion_failed && !is_debugger_present())
{
generate_event(_event_critical, "");
GENERATE_EVENT(_event_critical, "");
stack_walk(1);
editor_save_progress();
}

generate_event(_event_critical, "");
GENERATE_EVENT(_event_critical, "");

if (is_debugger_present())
{
generate_event(_event_critical, "%s(%d): %s: %s",
GENERATE_EVENT(_event_critical, "%s(%d): %s: %s",
file,
line,
assertion_failed ? "ASSERT" : "WARNING",
Expand All @@ -98,12 +98,12 @@ void display_assert(char const* statement, char const* file, long line, bool ass
}
else
{
generate_event(_event_critical, "%s",
GENERATE_EVENT(_event_critical, "%s",
version_get_full_string());
crash_info.print("version:\r\n%s\r\n",
version_get_full_string());

generate_event(_event_critical, "%s at %s,#%d",
GENERATE_EVENT(_event_critical, "%s at %s,#%d",
assertion_failed ? "### ASSERTION FAILED: " : "### RUNTIME WARNING: ",
file,
line);
Expand All @@ -114,7 +114,7 @@ void display_assert(char const* statement, char const* file, long line, bool ass

if (statement)
{
generate_event(_event_critical, " %s", statement);
GENERATE_EVENT(_event_critical, " %s", statement);
crash_info.append_print("halt information:\r\n %s\r\n", statement);
}
}
Expand Down
28 changes: 14 additions & 14 deletions game/source/cseries/cseries_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ long event_parse_categories(char const* event_name, long max_categories, long ca
}
else
{
generate_event(_event_error, "network event category #%d '%s' exceeded %d category substrings", category_index, category_substring, max_categories);
GENERATE_EVENT(_event_error, "network event category #%d '%s' exceeded %d category substrings", category_index, category_substring, max_categories);

failed = true;
}
Expand Down Expand Up @@ -704,12 +704,12 @@ void __cdecl events_initialize()
events_initialize_if_possible();

ASSERT(g_events_initialized);
generate_event(_event_message, "lifecycle: events initalize");
GENERATE_EVENT(_event_message, "lifecycle: events initalize");
}

long __cdecl event_interlocked_compare_exchange(c_interlocked_long& value, long ExChange, long Comperand)
long __cdecl event_interlocked_compare_exchange(long volatile* destination, long exchange, long comperand)
{
return value.set_if_equal(ExChange, Comperand);
return (long)_InterlockedCompareExchange(destination, exchange, comperand);
}

c_event::c_event(e_event_level event_level, long event_category_index, dword event_response_suppress_flags) :
Expand Down Expand Up @@ -904,16 +904,16 @@ void event_generate(e_event_level event_level, long category_index, dword event_
event_generated_handle_halt(event_text);
}

//g_event_read_write_lock.read_lock();
//for (long event_listener_index = 0; event_globals.event_listeners.get_count(); event_listener_index++)
//{
// if (TEST_BIT(category->event_listeners, event_listener_index))
// {
// ASSERT(event_globals.event_listeners[event_listener_index]);
// event_globals.event_listeners[event_listener_index]->handle_event(event_level, event_text);
// }
//}
//g_event_read_write_lock.read_unlock();
g_event_read_write_lock.read_lock();
for (long event_listener_index = 0; event_listener_index < event_globals.event_listeners.get_count(); event_listener_index++)
{
if (TEST_BIT(category->event_listeners, event_listener_index))
{
ASSERT(event_globals.event_listeners[event_listener_index]);
event_globals.event_listeners[event_listener_index]->handle_event(event_level, event_text);
}
}
g_event_read_write_lock.read_unlock();

g_event_read_write_lock.write_lock();
event_globals.event_index++;
Expand Down
Loading

0 comments on commit 01d0221

Please sign in to comment.