[openjk] 29/130: Implement reading and writing of two-dimension arrays

Simon McVittie smcv at debian.org
Fri Oct 28 11:09:14 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 cc7cc6cd4de08353446af3e55f9cff607ba17007
Author: bibendovsky <bibendovsky at hotmail.com>
Date:   Sat Jul 9 18:28:07 2016 +0300

    Implement reading and writing of two-dimension arrays
---
 shared/qcommon/ojk_saved_game.h     | 32 ++++++++++++++++++++++++++++++--
 shared/qcommon/ojk_saved_game_fwd.h | 11 +++++++++++
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/shared/qcommon/ojk_saved_game.h b/shared/qcommon/ojk_saved_game.h
index 7df50d2..4635736 100644
--- a/shared/qcommon/ojk_saved_game.h
+++ b/shared/qcommon/ojk_saved_game.h
@@ -172,7 +172,11 @@ void SavedGame::read(
                     typename std::conditional<
                         std::rank<TDst>::value == 1,
                         Array1dTag,
-                        void
+                        typename std::conditional<
+                            std::rank<TDst>::value == 2,
+                            Array2dTag,
+                            void
+                        >::type
                     >::type
                 >::type
             >::type
@@ -264,6 +268,16 @@ void SavedGame::read(
         TCount);
 }
 
+template<typename TSrc, typename TDst, int TCount1, int TCount2>
+void SavedGame::read(
+    TDst(&dst_values)[TCount1][TCount2],
+    Array2dTag)
+{
+    read<TSrc>(
+        &dst_values[0][0],
+        TCount1 * TCount2);
+}
+
 // read
 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
@@ -399,7 +413,11 @@ void SavedGame::write(
                 typename std::conditional<
                     std::rank<TSrc>::value == 1,
                     Array1dTag,
-                    void
+                    typename std::conditional<
+                        std::rank<TSrc>::value == 2,
+                        Array2dTag,
+                        void
+                    >::type
                 >::type
             >::type
         >::type
@@ -466,6 +484,16 @@ void SavedGame::write(
         TCount);
 }
 
+template<typename TDst, typename TSrc, int TCount1, int TCount2>
+void SavedGame::write(
+    const TSrc(&src_values)[TCount1][TCount2],
+    Array2dTag)
+{
+    write<TDst>(
+        &src_values[0][0],
+        TCount1 * TCount2);
+}
+
 // write
 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
diff --git a/shared/qcommon/ojk_saved_game_fwd.h b/shared/qcommon/ojk_saved_game_fwd.h
index db2b818..feef931 100644
--- a/shared/qcommon/ojk_saved_game_fwd.h
+++ b/shared/qcommon/ojk_saved_game_fwd.h
@@ -135,6 +135,7 @@ private:
     class PointerTag { public: };
     class ClassTag { public: };
     class Array1dTag { public: };
+    class Array2dTag { public: };
     class InplaceTag { public: };
     class CastTag { public: };
 
@@ -225,6 +226,11 @@ private:
         TDst (&dst_values)[TCount],
         Array1dTag);
 
+    template<typename TSrc, typename TDst, int TCount1, int TCount2>
+    void read(
+        TDst(&dst_values)[TCount1][TCount2],
+        Array2dTag);
+
 
     template<typename TSrc, typename TDst>
     void read(
@@ -259,6 +265,11 @@ private:
         const TSrc (&src_values)[TCount],
         Array1dTag);
 
+    template<typename TDst, typename TSrc, int TCount1, int TCount2>
+    void write(
+        const TSrc(&src_values)[TCount1][TCount2],
+        Array2dTag);
+
 
     template<typename TDst, typename TSrc>
     void write(

-- 
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