<commit_before>#pragma once
#include <iostream>

#include "augs/unit_tests.h"
#include "augs/global_libraries.h"

#include "augs/filesystem/file.h"
#include "augs/filesystem/directory.h"

#include "augs/math/matrix.h"

#include "augs/misc/imgui_utils.h"
#include "augs/misc/lua_readwrite.h"
#include "augs/misc/machine_entropy.h"

#include "augs/graphics/renderer.h"

#include "augs/window_framework/window.h"
#include "augs/audio/audio_context.h"

#include "game/organization/all_component_includes.h"
#include "game/organization/all_messages_includes.h"

#include "game/transcendental/data_living_one_step.h"
#include "game/transcendental/cosmos.h"

#include "view/viewables/loaded_sounds.h"
#include "view/viewables/atlas_distributions.h"

#include "view/game_gui/game_gui_system.h"

#include "view/audiovisual_state/audiovisual_state.h"
#include "view/rendering_scripts/illuminated_rendering.h"

#include "application/session_profiler.h"
#include "application/config_lua_table.h"

#include "application/gui/settings_gui.h"
#include "application/gui/ingame_menu_gui.h"

#include "application/setups/main_menu_setup.h"
#include "application/setups/test_scene_setup.h"
#include "application/setups/editor_setup.h"

#include "application/main/imgui_pass.h"
#include "application/main/draw_debug_details.h"
#include "application/main/release_flags.h"

#include "cmd_line_params.h"

#include "hypersomnia_version.h"
#include "generated/introspectors.h"

int work(const int argc, const char* const * const argv);

#if PLATFORM_WINDOWS
int __stdcall WinMain(HINSTANCE, HINSTANCE, char*, int) {
	const auto argc = __argc;
	const auto argv = __argv;

#else
int main(const int argc, const char* const * const argv) {
#endif
	const auto exit_code = work(argc, argv);

	{
		const auto logs = program_log::get_current().get_complete(); 

		switch (exit_code) {
			case EXIT_SUCCESS: 
				augs::create_text_file("generated/logs/exit_success_debug_log.txt", logs); 
				break;
			case EXIT_FAILURE: 
				augs::create_text_file("generated/logs/exit_failure_debug_log.txt", logs);
				break;
			default: break;
		}
	}

	return exit_code;
}

/*
	static is used for variables because some are huge, especially setups.
	On the other hand, to preserve the destruction in the order of definition,
	we must make all variables static, otherwise the huge resources marked static
	would get destructed last, possibly causing bugs.

	main will also be called only once.
*/

int work(const int argc, const char* const * const argv) try {
	static const auto params = cmd_line_params(argc, argv);

	static const auto canon_config_path = augs::path_type("config.lua");
	static const auto local_config_path = augs::path_type("config.local.lua");
	
	augs::create_directories("generated/logs/");

	augs::imgui::init(
		"generated/imgui.ini",
		"generated/imgui_log.txt"
	);<commit_msg>opening failure log in text editor on error<commit_after>#pragma once
#include <iostream>

#include "augs/unit_tests.h"
#include "augs/global_libraries.h"

#include "augs/filesystem/file.h"
#include "augs/filesystem/directory.h"

#include "augs/math/matrix.h"

#include "augs/misc/imgui_utils.h"
#include "augs/misc/lua_readwrite.h"
#include "augs/misc/machine_entropy.h"

#include "augs/graphics/renderer.h"

#include "augs/window_framework/window.h"
#include "augs/audio/audio_context.h"

#include "game/organization/all_component_includes.h"
#include "game/organization/all_messages_includes.h"

#include "game/transcendental/data_living_one_step.h"
#include "game/transcendental/cosmos.h"

#include "view/viewables/loaded_sounds.h"
#include "view/viewables/atlas_distributions.h"

#include "view/game_gui/game_gui_system.h"

#include "view/audiovisual_state/audiovisual_state.h"
#include "view/rendering_scripts/illuminated_rendering.h"

#include "application/session_profiler.h"
#include "application/config_lua_table.h"

#include "application/gui/settings_gui.h"
#include "application/gui/ingame_menu_gui.h"

#include "application/setups/main_menu_setup.h"
#include "application/setups/test_scene_setup.h"
#include "application/setups/editor_setup.h"

#include "application/main/imgui_pass.h"
#include "application/main/draw_debug_details.h"
#include "application/main/release_flags.h"

#include "cmd_line_params.h"

#include "hypersomnia_version.h"
#include "generated/introspectors.h"

int work(const int argc, const char* const * const argv);

#if PLATFORM_WINDOWS
int __stdcall WinMain(HINSTANCE, HINSTANCE, char*, int) {
	const auto argc = __argc;
	const auto argv = __argv;

#else
int main(const int argc, const char* const * const argv) {
#endif
	const auto exit_code = work(argc, argv);

	{
		const auto logs = program_log::get_current().get_complete(); 

		switch (exit_code) {
			case EXIT_SUCCESS: 
				augs::create_text_file("generated/logs/exit_success_debug_log.txt", logs); 
				break;
			case EXIT_FAILURE: 
				{
					const auto failure_log_path = augs::path_type("generated/logs/exit_failure_debug_log.txt");
					augs::create_text_file(failure_log_path, logs);
#if PLATFORM_WINDOWS || PLATFORM_LINUX
					system(failure_log_path.string().c_str());
#endif
				}

				break;
			default: break;
		}
	}

	return exit_code;
}

/*
	static is used for variables because some are huge, especially setups.
	On the other hand, to preserve the destruction in the order of definition,
	we must make all variables static, otherwise the huge resources marked static
	would get destructed last, possibly causing bugs.

	main will also be called only once.
*/

int work(const int argc, const char* const * const argv) try {
	static const auto params = cmd_line_params(argc, argv);

	static const auto canon_config_path = augs::path_type("config.lua");
	static const auto local_config_path = augs::path_type("config.local.lua");
	
	augs::create_directories("generated/logs/");

	augs::imgui::init(
		"generated/imgui.ini",
		"generated/imgui_log.txt"
	);
{'fraction_non_alphanumeric': 0.11815415821501014, 'fraction_numerical': 0.0, 'mean_word_length': 5.581757508342603, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5848169', 'n_tokens_mistral': 2143, 'n_tokens_neox': 2061, 'n_words': 438}