diff --git a/binaries/system/readme.txt b/binaries/system/readme.txt index d92c56d925..d6234632ac 100644 --- a/binaries/system/readme.txt +++ b/binaries/system/readme.txt @@ -3,7 +3,7 @@ COMMAND LINE OPTIONS Basic gameplay: -autostart=... load a map instead of showing main menu (see below) -editor launch the Atlas scenario editor --mod NAME start the game using NAME mod +-mod=NAME start the game using NAME mod -quickstart load faster (disables audio and some system info logging) Autostart: @@ -67,6 +67,7 @@ Windows-specific: Archive builder: -archivebuild=PATH system PATH of the base directory containing mod data to be archived/precached + specify all mods it depends on with -mod=NAME -archivebuild-output=PATH system PATH to output of the resulting .zip archive (use with archivebuild) -archivebuild-compress enable deflate compression in the .zip (no zip compression by default since it hurts compression of release packages) diff --git a/source/main.cpp b/source/main.cpp index f8458b3302..db8feca3f5 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2014 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -461,6 +461,13 @@ static void RunGameOrAtlas(int argc, const char* argv[]) zip = mod.Filename().ChangeExtension(L".zip"); CArchiveBuilder builder(mod, paths.Cache()); + + // Add mods provided on the command line + // NOTE: We do not handle mods in the user mod path here + std::vector mods = args.GetMultiple("mod"); + for (size_t i = 0; i < mods.size(); ++i) + builder.AddBaseMod(paths.RData()/"mods"/mods[i]); + builder.Build(zip, args.Has("archivebuild-compress")); CXeromyces::Terminate(); diff --git a/source/ps/ArchiveBuilder.cpp b/source/ps/ArchiveBuilder.cpp index c21f5b44eb..f9525d8124 100644 --- a/source/ps/ArchiveBuilder.cpp +++ b/source/ps/ArchiveBuilder.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2014 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -34,7 +34,7 @@ #include CArchiveBuilder::CArchiveBuilder(const OsPath& mod, const OsPath& tempdir) : - m_TempDir(tempdir) + m_TempDir(tempdir), m_NumBaseMods(0) { m_VFS = CreateVfs(20*MiB); @@ -42,7 +42,8 @@ CArchiveBuilder::CArchiveBuilder(const OsPath& mod, const OsPath& tempdir) : m_VFS->Mount(L"cache/", m_TempDir/"_archivecache"/""); - m_VFS->Mount(L"", mod/"", VFS_MOUNT_MUST_EXIST | VFS_MOUNT_KEEP_DELETED); + // Mount with highest priority so base mods do not overwrite files in this mod + m_VFS->Mount(L"", mod/"", VFS_MOUNT_MUST_EXIST | VFS_MOUNT_KEEP_DELETED, (size_t)-1); // Collect the list of files before loading any base mods vfs::ForEachFile(m_VFS, L"", &CollectFileCB, (uintptr_t)static_cast(this), 0, vfs::DIR_RECURSIVE); @@ -57,7 +58,9 @@ CArchiveBuilder::~CArchiveBuilder() void CArchiveBuilder::AddBaseMod(const OsPath& mod) { - m_VFS->Mount(L"", mod/"", VFS_MOUNT_MUST_EXIST); + // Increase priority for each additional base mod, so that the + // mods are mounted in the same way as when starting the game. + m_VFS->Mount(L"", mod/"", VFS_MOUNT_MUST_EXIST, ++m_NumBaseMods); } void CArchiveBuilder::Build(const OsPath& archive, bool compress) diff --git a/source/ps/ArchiveBuilder.h b/source/ps/ArchiveBuilder.h index e51f9b5aa8..3e578e6345 100644 --- a/source/ps/ArchiveBuilder.h +++ b/source/ps/ArchiveBuilder.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2014 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -43,6 +43,7 @@ public: /** * Add a mod which will be loaded but not archived, to provide * files like textures.xml needed for the conversion. + * Added mods will be mounted with increasing priority. * Typically this will be called with 'public', when packaging * a user's mod. * @param mod path to data/mods/foo directory, containing files for loading @@ -62,6 +63,7 @@ private: PIVFS m_VFS; std::vector m_Files; OsPath m_TempDir; + size_t m_NumBaseMods; }; #endif // INCLUDED_ARCHIVEBUILDER