[openjk] 14/130: Implement method create

Simon McVittie smcv at debian.org
Fri Oct 28 11:09:12 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository openjk.

commit 83c056dacd2ad85bd15f63af6e53ed751263243a
Author: bibendovsky <bibendovsky at NOSTROMO>
Date:   Sun Jul 3 22:31:00 2016 +0300

    Implement method create
---
 shared/qcommon/ojk_sg_archive.cpp | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/shared/qcommon/ojk_sg_archive.cpp b/shared/qcommon/ojk_sg_archive.cpp
index b266490..0e6a07b 100644
--- a/shared/qcommon/ojk_sg_archive.cpp
+++ b/shared/qcommon/ojk_sg_archive.cpp
@@ -85,8 +85,40 @@ bool Archive::create(
     ArchiveMode archive_mode,
     const std::string& base_file_name)
 {
-    throw ArchiveException(
-        "Not implemented.");
+    validate_archive_mode(
+        archive_mode);
+
+    remove(
+        base_file_name);
+
+    auto path = generate_path(
+        base_file_name);
+
+    file_handle_ = ::FS_FOpenFileWrite(
+        path.c_str());
+
+    if (file_handle_ == 0) {
+        auto error_message = get_failed_to_open_message(
+            archive_mode,
+            path,
+            false);
+
+        ::Com_Printf(
+            "%s\n",
+            error_message.c_str());
+
+        return false;
+    }
+
+    archive_mode_ = archive_mode;
+
+    int sg_version = iSAVEGAME_VERSION;
+
+    write_chunk<int32_t>(
+        INT_ID('_', 'V', 'E', 'R'),
+        sg_version);
+
+    return true;
 }
 
 void Archive::close()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git



More information about the Pkg-games-commits mailing list