- added a new commandline command to create data archives for network xfer for techtrees and tilesets:

megaglest --create-data-archives=all
This commit is contained in:
Mark Vejvoda
2013-11-14 06:59:29 +00:00
parent 5db18c76f4
commit a300621415
5 changed files with 197 additions and 9 deletions

View File

@@ -291,6 +291,9 @@ inline string trim (const string & s, const string & t = SPACES) {
string getFullFileArchiveExtractCommand(string fileArchiveExtractCommand,
string fileArchiveExtractCommandParameters, string outputpath, string archivename);
string getFullFileArchiveCompressCommand(string fileArchiveCompressCommand,
string fileArchiveCompressCommandParameters, string archivename, string archivefiles);
bool executeShellCommand(string cmd,int expectedResult=IGNORE_CMD_RESULT_VALUE,ShellCommandOutputCallbackInterface *cb=NULL);
string executable_path(string exeName,bool includeExeNameInPath=false);

View File

@@ -93,6 +93,8 @@ const char *GAME_ARGS[] = {
"--debug-network-packets",
"--enable-new-protocol",
"--create-data-archives",
"--verbose"
};
@@ -171,6 +173,8 @@ enum GAME_ARG_TYPE {
GAME_ARG_DEBUG_NETWORK_PACKETS,
GAME_ARG_ENABLE_NEW_PROTOCOL,
GAME_ARG_CREATE_DATA_ARCHIVES,
GAME_ARG_VERBOSE_MODE,
GAME_ARG_END
@@ -477,6 +481,11 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
printf("\n%s\t\tdisables opengl capability checks (for corrupt or flaky video drivers).",GAME_ARGS[GAME_ARG_DISABLE_OPENGL_CAPS_CHECK]);
printf("\n%s=x\t\t\tcompress selected game data into archives for network sharing.",GAME_ARGS[GAME_ARG_CREATE_DATA_ARCHIVES]);
printf("\n \t\tWhere x is one of the following data items to compress.");
printf("\n \t\ttechtrees, tilesets or all.");
printf("\n \t\texample: %s %s=all",extractFileFromDirectoryPath(argv0).c_str(),GAME_ARGS[GAME_ARG_CREATE_DATA_ARCHIVES]);
printf("\n%s\t\t\tdisplays verbose information in the console.",GAME_ARGS[GAME_ARG_VERBOSE_MODE]);
printf("\n\n");

View File

@@ -2005,6 +2005,30 @@ string getFullFileArchiveExtractCommand(string fileArchiveExtractCommand,
return result;
}
string getFullFileArchiveCompressCommand(string fileArchiveCompressCommand,
string fileArchiveCompressCommandParameters,
string archivename, string archivefiles) {
string parsedArchivename = archivename;
string parsedArchivefiles = archivefiles;
// This is required for execution on win32
#if defined(WIN32)
replaceAll(parsedArchivename, "\\\\", "\\");
replaceAll(parsedArchivename, "/", "\\");
replaceAll(parsedArchivefiles, "\\\\", "\\");
replaceAll(parsedArchivefiles, "/", "\\");
#endif
string result = fileArchiveCompressCommand;
result += " ";
string args = replaceAll(fileArchiveCompressCommandParameters, "{archivename}", parsedArchivename);
args = replaceAll(args, "{archivefiles}", parsedArchivefiles);
result += args;
return result;
}
bool executeShellCommand(string cmd, int expectedResult, ShellCommandOutputCallbackInterface *cb) {
bool result = false;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"About to run [%s]", cmd.c_str());