31volatile int init_done = 0;
36static void display_launch_screen_thread(
void) {
40 time_t start_time = time(NULL);
41 bool min_time_elapsed =
false;
44 while (!min_time_elapsed) {
49 time_t current_time = time(NULL);
50 double elapsed_s = difftime(current_time, start_time);
51 long elapsed_ms = (long) (elapsed_s * 1000);
53 min_time_elapsed = (elapsed_ms >= LAUNCH_SCREEN_MIN_DISPLAY_TIME_MS);
78 NULL_PTR_HANDLER_RETURN(
main_memory_pool, FAIL_MEM_POOL_INIT,
"Main",
"Main memory pool is NULL");
88 log_msg(ERROR,
"Main",
"Failed to initialize IO handler");
89 return FAIL_IO_HANDLER_INIT;
94 display_launch_screen_thread();
99 log_msg(ERROR,
"Game",
"Failed to open database");
106 log_msg(ERROR,
"Main",
"Failed to initialize local handler");
107 return FAIL_LOCAL_INIT;
115 log_msg(ERROR,
"Main",
"Failed to initialize main menu");
116 return FAIL_MAIN_MENU_INIT;
119 log_msg(ERROR,
"Main",
"Failed to initialize save menu");
120 return FAIL_SAVE_MENU_INIT;
123 log_msg(ERROR,
"Main",
"Failed to initialize language menu");
124 return FAIL_LANGUAGE_INIT;
128 log_msg(ERROR,
"Main",
"Failed to initialize combat mode");
129 return FAIL_GAME_MODE_INIT;
134 log_msg(ERROR,
"Main",
"Failed to initialize inventory mode");
135 return FAIL_INVENTORY_MODE_INIT;
140 log_msg(ERROR,
"Game",
"Failed to initialize game components");
141 return FAIL_GAME_ENTITY_INIT;
146 log_msg(ERROR,
"Stats",
"Failed to initialize stats components");
147 return FAIL_STATS_MODE_INIT;
179 const int exit_code =
init();
void shutdown_combat_mode()
Shuts down the combat mode and frees allocated memory resources.
int init_combat_mode()
Initialize the combat mode.
Declares combat mode state machine, including menus and combat operations.
memory_pool_t * main_memory_pool
Global memory pool for the application.
Defines common macros, types, and global variables for color schemes and utilities.
#define COMMON_SUCCESS
Common success return value.
int db_open_multiple_access(db_connection_t *db_connection, db_type_t type)
This function is for the opening of the database with multiple access.
void db_close(db_connection_t *db_connection)
This function is for the closing of the database.
void run_game()
Starts the game loop.
Declares core game states, global database connection, and main game control functions.
int free_game_data()
Frees game-related data structures and resources, such as ability tables, characters,...
int init_game_data()
Initializes game data for the application.
Declares functions and globals for initializing, resetting, and freeing game data such as player,...
void create_tables_game_state(const db_connection_t *db_connection)
Create the tables for the game state.
Declares functions to create, save, load, and manage game state data in the SQLite database.
void shutdown_inventory_mode(void)
Shuts down the inventory mode and frees allocated resources.
int init_inventory_mode()
Initialize the inventory mode.
Exposes functions for working with the inventory mode.
int init_io_handler(void)
Initialize the IO handler.
void shutdown_io_handler(void)
Shutdown the IO handler.
Exposes functions for the IO-Handler.
void shutdown_local_handler(void)
Shut down the local language handler by releasing resources and closing the resource file.
int init_local_handler(const local_lang_t lang)
Initialize the local language handler by setting up the language and opening the corresponding resour...
Exposes public functions for the localization handler.
void shutdown_logger(void)
Shuts down the logging system for the application.
void init_logger(void)
Initializes the logging system for the application.
void log_msg(const log_level_t level, const char *module, const char *format,...)
Logs a formatted message with a specified log level and module.
Header file for logging functionality of the game.
int init()
Initializes all necessary parts and subsystems for the game.
void shutdown_game(void)
Frees all allocated resources and performs cleanup tasks for the game.
int main(void)
Main entry point for the application.
Declares application initialization, shutdown, and main entry point.
int init_main_menu()
Initializes resources for the main menu, including memory allocation and observer registration for lo...
void shutdown_main_menu(void)
Shuts down the main menu and frees associated data.
Exposes functions for the main menu.
void init_map_mode(void)
Initializes the map mode.
void shutdown_map_mode(void)
Frees any resources associated with the map mode.
Defines and manages functions for map exploration, player movement, and map interactions in map mode.
memory_pool_t * init_memory_pool(size_t size)
Initialize a memory pool of the given size.
void shutdown_memory_pool(memory_pool_t *pool)
Shuts down the memory pool.
bool render_frame(void)
Render the current frame.
void clear_screen(void)
Clear the screen.
void shutdown_stats_mode()
Shutdown the stats mode.
int init_stats_mode()
Initialize the stats mode.
Exposes functions for outputing to the screen in stats mode.
void draw_welcome_screen(void)
Draw the welcome screen with a message.
void draw_launch_screen(void)
Draw the launch screen with title and animation.
Exposes functions for drawing the laoding screen.