mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 21:39:41 +00:00
Revive bsatool
This commit is contained in:
parent
17e406e58c
commit
3adf3f5121
8 changed files with 159 additions and 135 deletions
|
@ -29,6 +29,7 @@ option(OGRE_STATIC "Link static build of Ogre and Ogre Plugins into the binarie
|
||||||
option(BOOST_STATIC "Link static build of Boost into the binaries" FALSE)
|
option(BOOST_STATIC "Link static build of Boost into the binaries" FALSE)
|
||||||
|
|
||||||
# Apps and tools
|
# Apps and tools
|
||||||
|
option(BUILD_BSATOOL "build BSA extractor" OFF)
|
||||||
option(BUILD_ESMTOOL "build ESM inspector" ON)
|
option(BUILD_ESMTOOL "build ESM inspector" ON)
|
||||||
option(BUILD_LAUNCHER "build Launcher" ON)
|
option(BUILD_LAUNCHER "build Launcher" ON)
|
||||||
option(BUILD_MWINIIMPORTER "build MWiniImporter" ON)
|
option(BUILD_MWINIIMPORTER "build MWiniImporter" ON)
|
||||||
|
@ -352,7 +353,7 @@ if(DPKG_PROGRAM)
|
||||||
Data files from the original game is required to run it.")
|
Data files from the original game is required to run it.")
|
||||||
SET(CPACK_DEBIAN_PACKAGE_NAME "openmw")
|
SET(CPACK_DEBIAN_PACKAGE_NAME "openmw")
|
||||||
SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}")
|
SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}")
|
||||||
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW esmtool;Esmtool omwlauncher;OMWLauncher mwiniimporter;MWiniImporter")
|
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW bsatool;Bsatool esmtool;Esmtool omwlauncher;OMWLauncher mwiniimporter;MWiniImporter")
|
||||||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)")
|
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)")
|
||||||
|
|
||||||
SET(CPACK_DEBIAN_PACKAGE_SECTION "Games")
|
SET(CPACK_DEBIAN_PACKAGE_SECTION "Games")
|
||||||
|
@ -446,6 +447,10 @@ add_subdirectory (components)
|
||||||
# Apps and tools
|
# Apps and tools
|
||||||
add_subdirectory( apps/openmw )
|
add_subdirectory( apps/openmw )
|
||||||
|
|
||||||
|
if (BUILD_BSATOOL)
|
||||||
|
add_subdirectory( apps/bsatool )
|
||||||
|
endif()
|
||||||
|
|
||||||
if (BUILD_ESMTOOL)
|
if (BUILD_ESMTOOL)
|
||||||
add_subdirectory( apps/esmtool )
|
add_subdirectory( apps/esmtool )
|
||||||
endif()
|
endif()
|
||||||
|
@ -532,6 +537,9 @@ if (WIN32)
|
||||||
set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
||||||
endif (BUILD_LAUNCHER)
|
endif (BUILD_LAUNCHER)
|
||||||
set_target_properties(openmw PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
set_target_properties(openmw PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
||||||
|
if (BUILD_BSATOOL)
|
||||||
|
set_target_properties(bsatool PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
||||||
|
endif (BUILD_BSATOOL)
|
||||||
if (BUILD_ESMTOOL)
|
if (BUILD_ESMTOOL)
|
||||||
set_target_properties(esmtool PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
set_target_properties(esmtool PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
||||||
endif (BUILD_ESMTOOL)
|
endif (BUILD_ESMTOOL)
|
||||||
|
@ -656,6 +664,9 @@ if (NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE)
|
||||||
IF(BUILD_LAUNCHER)
|
IF(BUILD_LAUNCHER)
|
||||||
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/omwlauncher" DESTINATION "${BINDIR}" )
|
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/omwlauncher" DESTINATION "${BINDIR}" )
|
||||||
ENDIF(BUILD_LAUNCHER)
|
ENDIF(BUILD_LAUNCHER)
|
||||||
|
IF(BUILD_BSATOOL)
|
||||||
|
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/bsatool" DESTINATION "${BINDIR}" )
|
||||||
|
ENDIF(BUILD_BSATOOL)
|
||||||
IF(BUILD_ESMTOOL)
|
IF(BUILD_ESMTOOL)
|
||||||
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/esmtool" DESTINATION "${BINDIR}" )
|
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/esmtool" DESTINATION "${BINDIR}" )
|
||||||
ENDIF(BUILD_ESMTOOL)
|
ENDIF(BUILD_ESMTOOL)
|
||||||
|
|
26
apps/bsatool/CMakeLists.txt
Normal file
26
apps/bsatool/CMakeLists.txt
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
set(BSATOOL
|
||||||
|
bsatool.cpp
|
||||||
|
bsatool_cmd.c
|
||||||
|
bsatool_cmd.h
|
||||||
|
)
|
||||||
|
source_group(apps\\bsatool FILES ${BSATOOL})
|
||||||
|
|
||||||
|
# Main executable
|
||||||
|
add_executable(bsatool
|
||||||
|
${BSATOOL}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(bsatool
|
||||||
|
${Boost_LIBRARIES}
|
||||||
|
components
|
||||||
|
)
|
||||||
|
|
||||||
|
#if (APPLE)
|
||||||
|
# find_library(CARBON_FRAMEWORK Carbon)
|
||||||
|
# target_link_libraries(openmw ${CARBON_FRAMEWORK})
|
||||||
|
#endif (APPLE)
|
||||||
|
|
||||||
|
if (BUILD_WITH_CODE_COVERAGE)
|
||||||
|
add_definitions (--coverage)
|
||||||
|
target_link_libraries(bsatool gcov)
|
||||||
|
endif()
|
86
apps/bsatool/bsatool.cpp
Normal file
86
apps/bsatool/bsatool.cpp
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
#include <components/bsa/bsa_file.hpp>
|
||||||
|
|
||||||
|
#include "bsatool_cmd.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <fstream>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
gengetopt_args_info info;
|
||||||
|
|
||||||
|
if(cmdline_parser(argc, argv, &info) != 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if(info.inputs_num != 1)
|
||||||
|
{
|
||||||
|
if(info.inputs_num == 0)
|
||||||
|
std::cout << "ERROR: missing BSA file\n\n";
|
||||||
|
else
|
||||||
|
std::cout << "ERROR: more than one BSA file specified\n\n";
|
||||||
|
cmdline_parser_print_help();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open file
|
||||||
|
Bsa::BSAFile bsa;
|
||||||
|
char *arcname = info.inputs[0];
|
||||||
|
try { bsa.open(arcname); }
|
||||||
|
catch(std::exception &e)
|
||||||
|
{
|
||||||
|
std::cout << "ERROR reading BSA archive '" << arcname
|
||||||
|
<< "'\nDetails:\n" << e.what() << std::endl;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(info.extract_given)
|
||||||
|
{
|
||||||
|
char *file = info.extract_arg;
|
||||||
|
|
||||||
|
if(!bsa.exists(file))
|
||||||
|
{
|
||||||
|
std::cout << "ERROR: file '" << file << "' not found\n";
|
||||||
|
std::cout << "In archive: " << arcname << std::endl;
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the base name of the file
|
||||||
|
int pos = strlen(file);
|
||||||
|
while(pos > 0 && file[pos] != '\\') pos--;
|
||||||
|
char *base = file+pos+1;
|
||||||
|
|
||||||
|
// TODO: We might add full directory name extraction later. We
|
||||||
|
// could also allow automatic conversion from / to \ in
|
||||||
|
// parameter file names.
|
||||||
|
|
||||||
|
// Load the file into a memory buffer
|
||||||
|
Ogre::DataStreamPtr data = bsa.getFile(file);
|
||||||
|
|
||||||
|
// Write the file to disk
|
||||||
|
std::ofstream out(base, std::ios::binary);
|
||||||
|
out.write(data->getAsString().c_str(), data->size());
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// List all files
|
||||||
|
const Bsa::BSAFile::FileList &files = bsa.getList();
|
||||||
|
for(int i=0; i<files.size(); i++)
|
||||||
|
{
|
||||||
|
if(info.long_given)
|
||||||
|
{
|
||||||
|
// Long format
|
||||||
|
std::cout << std::setw(50) << std::left << files[i].name;
|
||||||
|
std::cout << std::setw(8) << std::left << std::dec << files[i].fileSize;
|
||||||
|
std::cout << "@ 0x" << std::hex << files[i].offset << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::cout << files[i].name << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Done!
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -13,8 +13,8 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
#include <cstdlib>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef FIX_UNUSED
|
#ifndef FIX_UNUSED
|
|
@ -13,7 +13,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstdio> /* for FILE */
|
#include <stdio.h> /* for FILE */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
|
@ -1,6 +1,6 @@
|
||||||
GCC=g++
|
GCC=g++
|
||||||
|
|
||||||
all: bsa_file_test bsatool ogre_archive_test
|
all: bsa_file_test ogre_archive_test
|
||||||
|
|
||||||
I_OGRE=$(shell pkg-config --cflags OGRE)
|
I_OGRE=$(shell pkg-config --cflags OGRE)
|
||||||
L_OGRE=$(shell pkg-config --libs OGRE)
|
L_OGRE=$(shell pkg-config --libs OGRE)
|
||||||
|
@ -11,12 +11,5 @@ bsa_file_test: bsa_file_test.cpp ../bsa_file.cpp
|
||||||
ogre_archive_test: ogre_archive_test.cpp ../bsa_file.cpp ../bsa_archive.cpp
|
ogre_archive_test: ogre_archive_test.cpp ../bsa_file.cpp ../bsa_archive.cpp
|
||||||
$(GCC) $^ -o $@ $(I_OGRE) $(L_OGRE)
|
$(GCC) $^ -o $@ $(I_OGRE) $(L_OGRE)
|
||||||
|
|
||||||
bsatool: bsatool.cpp ../bsa_file.cpp bsatool_cmd.c
|
|
||||||
$(GCC) $^ -o $@
|
|
||||||
|
|
||||||
bsatool_cmd.c: bsatool.ggo
|
|
||||||
gengetopt < bsatool.ggo
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm *_test
|
rm *_test
|
||||||
rm bsatool
|
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
#include "../bsa_file.hpp"
|
|
||||||
|
|
||||||
#include "bsatool_cmd.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <fstream>
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
#include "../../mangle/stream/filters/buffer_stream.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace Mangle::Stream;
|
|
||||||
using namespace Bsa;
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
gengetopt_args_info info;
|
|
||||||
|
|
||||||
if(cmdline_parser(argc, argv, &info) != 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if(info.inputs_num != 1)
|
|
||||||
{
|
|
||||||
if(info.inputs_num == 0)
|
|
||||||
cout << "ERROR: missing BSA file\n\n";
|
|
||||||
else
|
|
||||||
cout << "ERROR: more than one BSA file specified\n\n";
|
|
||||||
cmdline_parser_print_help();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open file
|
|
||||||
BSAFile bsa;
|
|
||||||
char *arcname = info.inputs[0];
|
|
||||||
try { bsa.open(arcname); }
|
|
||||||
catch(exception &e)
|
|
||||||
{
|
|
||||||
cout << "ERROR reading BSA archive '" << arcname
|
|
||||||
<< "'\nDetails:\n" << e.what() << endl;
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(info.extract_given)
|
|
||||||
{
|
|
||||||
char *file = info.extract_arg;
|
|
||||||
|
|
||||||
if(!bsa.exists(file))
|
|
||||||
{
|
|
||||||
cout << "ERROR: file '" << file << "' not found\n";
|
|
||||||
cout << "In archive: " << arcname << endl;
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the base name of the file
|
|
||||||
int pos = strlen(file);
|
|
||||||
while(pos > 0 && file[pos] != '\\') pos--;
|
|
||||||
char *base = file+pos+1;
|
|
||||||
|
|
||||||
// TODO: We might add full directory name extraction later. We
|
|
||||||
// could also allow automatic conversion from / to \ in
|
|
||||||
// parameter file names.
|
|
||||||
|
|
||||||
// Load the file into a memory buffer
|
|
||||||
BufferStream data(bsa.getFile(file));
|
|
||||||
|
|
||||||
// Write the file to disk
|
|
||||||
ofstream out(base, ios::binary);
|
|
||||||
out.write((char*)data.getPtr(), data.size());
|
|
||||||
out.close();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// List all files
|
|
||||||
const BSAFile::FileList &files = bsa.getList();
|
|
||||||
for(int i=0; i<files.size(); i++)
|
|
||||||
{
|
|
||||||
if(info.long_given)
|
|
||||||
{
|
|
||||||
// Long format
|
|
||||||
cout << setw(50) << left << files[i].name;
|
|
||||||
cout << setw(8) << left << dec << files[i].fileSize;
|
|
||||||
cout << "@ 0x" << hex << files[i].offset << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
cout << files[i].name << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Done!
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in a new issue