void init() { sigset_t sigmask; sigemptyset(&sigmask); sigaddset(&sigmask, SIGALRM); sigaddset(&sigmask, SIGUSR1); sigprocmask(SIG_BLOCK, &sigmask, NULL); console_print("Emergence Client " VERSION "\n"); SDL_Init(SDL_INIT_AUDIO); init_user(); init_network(); init_timer(); init_openssl(); init_key(); init_download(); init_servers(); create_cvars(); init_console_cvars(); init_render_cvars(); init_map_cvars(); create_control_cvars(); // create_input_cvars(); init_tick_cvars(); init_console(); create_colour_cvars(); struct string_t *string = new_string_string(emergence_home_dir); string_cat_text(string, "/client.config"); if(!exec_config_file(string->text)) { exec_config_file(find_resource("default-controls.config")); } else { char *ver = get_cvar_string("version"); if(*ver == '\0') { struct string_t *command = new_string_text("rm "); string_cat_string(command, emergence_home_dir); string_cat_text(command, "/skins/default.skin*"); console_print("%s\n", command->text); system(command->text); vid_mode = -1; // find a nice mode exec_config_file(find_resource("default-controls.config")); } free(ver); } free_string(string); set_cvar_string("version", VERSION); init_skin(); init_input(); init_control(); init_render(); init_rcon(); init_ping(); create_cvar_command("quit", client_shutdown_char); init_sound(); init_game(); init_alarm(); render_frame(); string = new_string_text("%s%s", emergence_home_dir->text, "/client.autoexec"); if(!exec_config_file(string->text)) exec_config_file(find_resource("default-client.autoexec")); free_string(string); start_server_discovery(); }
//----------------------------------------------------------------------------- // Main... process command line parameters, and then setup our listening // sockets and event loop. int main(int argc, char **argv) { system_data_t sysdata; ///============================================================================ /// Initialization. ///============================================================================ init_sysdata(&sysdata); init_settings(&sysdata); get_options(sysdata.settings, argc, argv); init_maxconns(&sysdata); init_daemon(&sysdata); init_events(&sysdata); init_logging(&sysdata); logger(sysdata.logging, 1, "System starting up"); init_signals(&sysdata); init_buffers(&sysdata); init_servers(&sysdata); init_stats(&sysdata); init_risp(&sysdata); init_nodes(&sysdata); init_msglist(&sysdata); init_queues(&sysdata); init_controllers(&sysdata); ///============================================================================ /// Main Event Loop. ///============================================================================ // enter the event loop. logger(sysdata.logging, 1, "Starting Event Loop"); assert(sysdata.evbase); event_base_loop(sysdata.evbase, 0); logger(sysdata.logging, 1, "Shutdown preparations complete. Shutting down now."); ///============================================================================ /// Shutdown ///============================================================================ cleanup_events(&sysdata); cleanup_controllers(&sysdata); cleanup_queues(&sysdata); cleanup_msglist(&sysdata); cleanup_nodes(&sysdata); cleanup_risp(&sysdata); cleanup_stats(&sysdata); cleanup_servers(&sysdata); cleanup_buffers(&sysdata); cleanup_signals(&sysdata); logger(sysdata.logging, 1, "Shutdown complete.\n"); cleanup_logging(&sysdata); cleanup_daemon(&sysdata); cleanup_maxconns(&sysdata); cleanup_settings(&sysdata); cleanup_sysdata(&sysdata); // good-bye. return 0; }