int wait_game_start() { int cont; t_lemipc *game; cont = 1; printf("Waiting for another team\n"); while (cont) { if ((game = get_game()) == NULL) return (my_puterr("Can't retrieve shared game\n")); if (sem_lock()) return (my_puterr("Can't lock semaphore\n")); cont = should_continue_wait(game); if (sem_unlock()) return (my_puterr("Can't unlock semaphore\n")); release_game(game); } printf("Lets do this !!\n"); return (0); }
// Entry point into the application int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int nCmdShow) { g_app_instance = hInstance; //use the factory to create our objects. IGame * game = get_game(); IWindow * window = get_game_window( game ); g_input = get_game_input(); window->Run(); // Run the application // Cleanup our objects. release_game_input(&g_input); release_game_window( &window ); release_game( &game ); return 0; }
/** * The main function is where the program starts execution. */ Sint32 main (Sint32 args_count, char **arguments) { #if defined(POWERMANGA_LOG_ENABLED) LOG_LEVELS log_level = LOG_NOTHING; #endif /* GP2X or PSP port */ #ifdef POWERMANGA_HANDHELD_CONSOLE /* Use atexit() to call the return-to-menu function, * in case of crashes, etc. */ atexit (returnToMenu); #endif /* allocate memory table */ #if defined (USE_MALLOC_WRAPPER) if (!memory_init (22000)) { exit (0); } #endif #if defined(POWERMANGA_LOG_ENABLED) log_initialize (LOG_INFO); #endif /* load config file */ if (!configfile_load ()) { #if defined (USE_MALLOC_WRAPPER) memory_releases_all (); #endif exit (0); } #ifdef _WIN32_WCE power_conf->verbose = 1; display_windows_ce_infos (); #endif if (configfile_scan_arguments (args_count, arguments)) { #if defined(POWERMANGA_LOG_ENABLED) switch (power_conf->verbose) { case 1: log_level = LOG_WARNING; break; case 2: log_level = LOG_DEBUG; break; default: log_level = LOG_ERROR; break; } log_set_level (log_level); #endif #if defined(POWERMANGA_HANDHELD_CONSOLE) || defined(_WIN32_WCE) /* We require a 320x200 output size to fit on * the GP2X or PSP's display */ power_conf->scale_x = 1; power_conf->resolution = 320; power_conf->fullscreen = 1; pixel_size = 1; #endif if (power_conf->extract_to_png) { power_conf->scale_x = 1; power_conf->resolution = 320; power_conf->fullscreen = 0; power_conf->nosound = TRUE; pixel_size = 1; } if (power_conf->resolution == 320) { vmode = 0; } else { if (power_conf->scale_x > 1) { vmode = 2; } else { vmode = 1; } } initialize_and_run (); } release_game (); #if defined(POWERMANGA_LOG_ENABLED) log_close (); #endif /* releases all memory allocated */ #if defined (USE_MALLOC_WRAPPER) memory_releases_all (); #endif /* launch html donation page before leaving */ #if !defined(_WIN32_WCE) && defined(_WIN32) ShellExecute (0, "open", ".\\html\\ar01s06s02.html", 0, 0, SW_SHOWNORMAL); #endif return 0; }