static void check_Physfs(void) { const PHYSFS_ArchiveInfo **i; bool zipfound = false; PHYSFS_Version compiled; PHYSFS_Version linked; PHYSFS_VERSION(&compiled); PHYSFS_getLinkedVersion(&linked); debug(LOG_WZ, "Compiled against PhysFS version: %d.%d.%d", compiled.major, compiled.minor, compiled.patch); debug(LOG_WZ, "Linked against PhysFS version: %d.%d.%d", linked.major, linked.minor, linked.patch); if (linked.major < 2) { debug(LOG_FATAL, "At least version 2 of PhysicsFS required!"); exit(-1); } for (i = PHYSFS_supportedArchiveTypes(); *i != NULL; i++) { debug(LOG_WZ, "[**] Supported archive(s): [%s], which is [%s].", (*i)->extension, (*i)->description); if (!strncasecmp("zip", (*i)->extension, 3) && !zipfound) { zipfound = true; } } if (!zipfound) { debug(LOG_FATAL, "Your Physfs wasn't compiled with zip support. Please recompile Physfs with zip support. Exiting program."); exit(-1); } }
util::VersionInfo Application::initPhysFS(const std::string& arg0) { PHYSFS_Version ver; PHYSFS_init(arg0.c_str()); PHYSFS_addToSearchPath(PHYSFS_getBaseDir(),0); PHYSFS_getLinkedVersion(&ver); return util::VersionInfo(ver.major, ver.minor, ver.patch); }
/**Prints the current version of PhysFS.*/ void Filesystem::Version( void ){ PHYSFS_Version compiled, linked; PHYSFS_VERSION(&compiled); PHYSFS_getLinkedVersion(&linked); LogMsg(INFO," Compiled against PhysicsFS version %d.%d.%d,\n" " and linked against %d.%d.%d.\n\n", (int) compiled.major, (int) compiled.minor, (int) compiled.patch, (int) linked.major, (int) linked.minor, (int) linked.patch); }
static void output_versions(void) { PHYSFS_Version compiled; PHYSFS_Version linked; PHYSFS_VERSION(&compiled); PHYSFS_getLinkedVersion(&linked); printf("test_physfs version %d.%d.%d.\n" " Compiled against PhysicsFS version %d.%d.%d,\n" " and linked against %d.%d.%d.\n\n", TEST_VERSION_MAJOR, TEST_VERSION_MINOR, TEST_VERSION_PATCH, (int) compiled.major, (int) compiled.minor, (int) compiled.patch, (int) linked.major, (int) linked.minor, (int) linked.patch); } /* output_versions */
/*! * Initialize the PhysicsFS library. */ static void initialize_PhysicsFS(const char* argv_0) { PHYSFS_Version compiled; PHYSFS_Version linked; PHYSFS_init(argv_0); PHYSFS_VERSION(&compiled); PHYSFS_getLinkedVersion(&linked); debug(LOG_WZ, "Compiled against PhysFS version: %d.%d.%d", compiled.major, compiled.minor, compiled.patch); debug(LOG_WZ, "Linked against PhysFS version: %d.%d.%d", linked.major, linked.minor, linked.patch); }
int main(int argc, char* argv[]) { PHYSFS_init(NULL); { PHYSFS_Version compiled; PHYSFS_Version linked; PHYSFS_VERSION(&compiled); PHYSFS_getLinkedVersion(&linked); printf("We compiled against PhysFS version %d.%d.%d ...\n", compiled.major, compiled.minor, compiled.patch); printf("But we linked against PhysFS version %d.%d.%d.\n", linked.major, linked.minor, linked.patch); } { const PHYSFS_ArchiveInfo** i; for(i = PHYSFS_supportedArchiveTypes(); *i != NULL; i++) { printf("Supported archive: [%s], which is [%s].\n", (*i)->extension, (*i)->description); } } { char **cds = PHYSFS_getCdRomDirs(); char **i; for (i = cds; *i != NULL; i++) printf("cdrom dir [%s] is available.\n", *i); PHYSFS_freeList(cds); } { char **i; for (i = PHYSFS_getSearchPath(); *i != NULL; i++) printf("[%s] is in the search path.\n", *i); PHYSFS_freeList(i); } PHYSFS_deinit(); }
static void check_Physfs(void) { const PHYSFS_ArchiveInfo **i; bool zipfound = false; PHYSFS_Version compiled; PHYSFS_Version linked; PHYSFS_VERSION(&compiled); PHYSFS_getLinkedVersion(&linked); debug(LOG_WZ, "Compiled against PhysFS version: %d.%d.%d", compiled.major, compiled.minor, compiled.patch); debug(LOG_WZ, "Linked against PhysFS version: %d.%d.%d", linked.major, linked.minor, linked.patch); if (linked.major < 2) { debug(LOG_FATAL, "At least version 2 of PhysicsFS required!"); exit(-1); } if (linked.major == 2 && linked.minor == 0 && linked.patch == 2) { debug(LOG_ERROR, "You have PhysicsFS 2.0.2, which is buggy. You may experience random errors/crashes due to spuriously missing files."); debug(LOG_ERROR, "Please upgrade/downgrade PhysicsFS to a different version, such as 2.0.3 or 2.0.1."); } for (i = PHYSFS_supportedArchiveTypes(); *i != NULL; i++) { debug(LOG_WZ, "[**] Supported archive(s): [%s], which is [%s].", (*i)->extension, (*i)->description); if (!strncasecmp("zip", (*i)->extension, 3) && !zipfound) { zipfound = true; } } if (!zipfound) { debug(LOG_FATAL, "Your Physfs wasn't compiled with zip support. Please recompile Physfs with zip support. Exiting program."); exit(-1); } }
Version getLinkedVersion() { Version version; PHYSFS_getLinkedVersion(&version); return version; }
static int main(int argc, char *argv[]) { if (!PHYSFSX_init(argc, argv)) return 1; con_init(); // Initialise the console setbuf(stdout, NULL); // unbuffered output via printf #ifdef _WIN32 freopen( "CON", "w", stdout ); freopen( "CON", "w", stderr ); #endif if (CGameArg.SysShowCmdHelp) { print_commandline_help(); return(0); } printf("\nType '%s -help' for a list of command-line options.\n\n", PROGNAME); PHYSFSX_listSearchPathContent(); if (!PHYSFSX_checkSupportedArchiveTypes()) return(0); #if defined(DXX_BUILD_DESCENT_I) if (! PHYSFSX_contfile_init("descent.hog", 1)) #define DXX_NAME_NUMBER "1" #define DXX_HOGFILE_NAMES "descent.hog" #elif defined(DXX_BUILD_DESCENT_II) if (! PHYSFSX_contfile_init("descent2.hog", 1) && ! PHYSFSX_contfile_init("d2demo.hog", 1)) #define DXX_NAME_NUMBER "2" #define DXX_HOGFILE_NAMES "descent2.hog or d2demo.hog" #endif { #if defined(__unix__) && !defined(__APPLE__) #define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY \ "\t$HOME/.d" DXX_NAME_NUMBER "x-rebirth\n" \ "\t" SHAREPATH "\n" #else #define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY \ "\tDirectory containing D" DXX_NAME_NUMBER "X\n" #endif #if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh) #define DXX_HOGFILE_APPLICATION_BUNDLE \ "\tIn 'Resources' inside the application bundle\n" #else #define DXX_HOGFILE_APPLICATION_BUNDLE "" #endif #define DXX_MISSING_HOGFILE_ERROR_TEXT \ "Could not find a valid hog file (" DXX_HOGFILE_NAMES ")\nPossible locations are:\n" \ DXX_HOGFILE_PROGRAM_DATA_DIRECTORY \ "\tIn a subdirectory called 'Data'\n" \ DXX_HOGFILE_APPLICATION_BUNDLE \ "Or use the -hogdir option to specify an alternate location." UserError(DXX_MISSING_HOGFILE_ERROR_TEXT); } #if defined(DXX_BUILD_DESCENT_I) switch (PHYSFSX_fsize("descent.hog")) { case D1_MAC_SHARE_MISSION_HOGSIZE: case D1_MAC_MISSION_HOGSIZE: MacHog = 1; // used for fonts and the Automap break; } #endif load_text(); //print out the banner title #if defined(DXX_BUILD_DESCENT_I) con_printf(CON_NORMAL, "%s %s", DESCENT_VERSION, g_descent_build_datetime); // D1X version con_puts(CON_NORMAL, "This is a MODIFIED version of Descent, based on " BASED_VERSION "."); con_printf(CON_NORMAL, "%s\n%s",TXT_COPYRIGHT,TXT_TRADEMARK); con_puts(CON_NORMAL, "Copyright (C) 2005-2013 Christian Beckhaeuser, 2013-2017 Kp"); #elif defined(DXX_BUILD_DESCENT_II) con_printf(CON_NORMAL, "%s%s %s", DESCENT_VERSION, PHYSFSX_exists(MISSION_DIR "d2x.hog",1) ? " Vertigo Enhanced" : "", g_descent_build_datetime); // D2X version con_puts(CON_NORMAL, "This is a MODIFIED version of Descent 2, based on " BASED_VERSION "."); con_printf(CON_NORMAL, "%s\n%s",TXT_COPYRIGHT,TXT_TRADEMARK); con_puts(CON_NORMAL, "Copyright (C) 1999 Peter Hawkins, 2002 Bradley Bell, 2005-2013 Christian Beckhaeuser, 2013-2017 Kp"); #endif if (CGameArg.DbgVerbose) { { PHYSFS_Version vc, vl; PHYSFS_VERSION(&vc); PHYSFS_getLinkedVersion(&vl); con_printf(CON_VERBOSE, "D" DXX_NAME_NUMBER "X-Rebirth built with PhysFS %u.%u.%u; loaded with PhysFS %u.%u.%u", vc.major, vc.minor, vc.patch, vl.major, vl.minor, vl.patch); } { SDL_version vc; SDL_VERSION(&vc); #if SDL_MAJOR_VERSION == 1 const auto vl = SDL_Linked_Version(); #else SDL_version vlv; const auto vl = &vlv; SDL_GetVersion(vl); #endif con_printf(CON_VERBOSE, "D" DXX_NAME_NUMBER "X-Rebirth built with libSDL %u.%u.%u; loaded with libSDL %u.%u.%u", vc.major, vc.minor, vc.patch, vl->major, vl->minor, vl->patch); } #if DXX_USE_SDLMIXER { SDL_version vc; SDL_MIXER_VERSION(&vc); const auto vl = Mix_Linked_Version(); con_printf(CON_VERBOSE, "D" DXX_NAME_NUMBER "X-Rebirth built with SDL_mixer %u.%u.%u; loaded with SDL_mixer %u.%u.%u", vc.major, vc.minor, vc.patch, vl->major, vl->minor, vl->patch); } #endif con_puts(CON_VERBOSE, TXT_VERBOSE_1); } ReadConfigFile(); PHYSFSX_addArchiveContent(); arch_init(); #if !DXX_USE_OGL select_tmap(CGameArg.DbgTexMap); #if defined(DXX_BUILD_DESCENT_II) Lighting_on = 1; #endif #endif con_puts(CON_VERBOSE, "Going into graphics mode..."); gr_set_mode(Game_screen_mode); // Load the palette stuff. Returns non-zero if error. con_puts(CON_DEBUG, "Initializing palette system..."); #if defined(DXX_BUILD_DESCENT_I) gr_use_palette_table( "PALETTE.256" ); #elif defined(DXX_BUILD_DESCENT_II) gr_use_palette_table(D2_DEFAULT_PALETTE ); #endif con_puts(CON_DEBUG, "Initializing font system..."); gamefont_init(); // must load after palette data loaded. #if defined(DXX_BUILD_DESCENT_II) con_puts(CON_DEBUG, "Initializing movie libraries..."); init_movies(); //init movie libraries #endif show_titles(); set_screen_mode(SCREEN_MENU); #ifdef DEBUG_MEMORY_ALLOCATIONS /* Memdebug runs before global destructors, so it incorrectly * reports as leaked any allocations that would be freed by a global * destructor. This local will force the newmenu globals to be * reset before memdebug scans, which prevents memdebug falsely * reporting them as leaked. * * External tools, such as Valgrind, know to run global destructors * before checking for leaks, so this hack is only necessary when * memdebug is used. */ struct hack_free_global_backgrounds { ~hack_free_global_backgrounds() { newmenu_free_background(); } }; hack_free_global_backgrounds hack_free_global_background; #endif con_puts(CON_DEBUG, "Doing gamedata_init..."); gamedata_init(); #if defined(DXX_BUILD_DESCENT_II) #if DXX_USE_EDITOR if (GameArg.EdiSaveHoardData) { save_hoard_data(); exit(1); } #endif #endif if (CGameArg.DbgNoRun) return(0); con_puts(CON_DEBUG, "Initializing texture caching system..."); texmerge_init(); // 10 cache bitmaps #if defined(DXX_BUILD_DESCENT_II) piggy_init_pigfile("groupa.pig"); //get correct pigfile #endif con_puts(CON_DEBUG, "Running game..."); init_game(); get_local_player().callsign = {}; #if defined(DXX_BUILD_DESCENT_I) key_flush(); #elif defined(DXX_BUILD_DESCENT_II) // If built with editor, option to auto-load a level and quit game // to write certain data. #ifdef EDITOR if (!GameArg.EdiAutoLoad.empty()) { Players[0u].callsign = "dummy"; } else #endif #endif { if (!CGameArg.SysPilot.empty()) { char filename[sizeof(PLAYER_DIRECTORY_TEXT) + CALLSIGN_LEN + 4]; /* Step over the literal PLAYER_DIRECTORY_TEXT when it is * present. Point at &filename[0] when * PLAYER_DIRECTORY_TEXT is absent. */ const auto b = &filename[-CGameArg.SysUsePlayersDir]; snprintf(filename, sizeof(filename), PLAYER_DIRECTORY_STRING("%.12s"), CGameArg.SysPilot.c_str()); /* The pilot name is never used after this. Clear it to * free the allocated memory, if any. */ CGameArg.SysPilot.clear(); auto p = b; for (const auto &facet = std::use_facet<std::ctype<char>>(std::locale::classic()); char &c = *p; ++p) { c = facet.tolower(static_cast<uint8_t>(c)); } auto j = p - filename; if (j < sizeof(filename) - 4 && (j <= 4 || strcmp(&filename[j - 4], ".plr"))) // if player hasn't specified .plr extension in argument, add it { strcpy(&filename[j], ".plr"); j += 4; } if(PHYSFSX_exists(filename,0)) { get_local_player().callsign.copy(b, std::distance(b, &filename[j - 4])); read_player_file(); WriteConfigFile(); } } } #if defined(DXX_BUILD_DESCENT_II) #if DXX_USE_EDITOR if (!GameArg.EdiAutoLoad.empty()) { /* Any number >= FILENAME_LEN works */ Level_names[0].copy_if(GameArg.EdiAutoLoad.c_str(), GameArg.EdiAutoLoad.size()); LoadLevel(1, 1); } else #endif #endif { Game_mode = GM_GAME_OVER; DoMenu(); } while (window_get_front()) // Send events to windows and the default handler event_process(); // Tidy up - avoids a crash on exit { window *wind; show_menus(); while ((wind = window_get_front())) window_close(wind); } WriteConfigFile(); show_order_form(); con_puts(CON_DEBUG, "Cleanup..."); close_game(); texmerge_close(); gamedata_close(); gamefont_close(); Current_mission.reset(); PHYSFSX_removeArchiveContent(); return(0); //presumably successful exit }