[openjk] 03/130: Make forward declaration header

Simon McVittie smcv at debian.org
Fri Oct 28 11:09:10 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 8a647f20060cc0a30048218494cd95da4ac3a7f1
Author: bibendovsky <bibendovsky at NOSTROMO>
Date:   Wed Jun 22 22:05:35 2016 +0300

    Make forward declaration header
---
 code/CMakeLists.txt                     |   2 +
 code/cgame/FxScheduler.cpp              |   2 +-
 code/cgame/cg_main.cpp                  |   2 +
 code/game/CMakeLists.txt                |   2 +
 code/game/G_Timer.cpp                   |   1 +
 code/game/Q3_Interface.cpp              |   1 +
 code/game/g_main.cpp                    |   2 +
 code/game/g_objectives.cpp              |   1 +
 code/game/g_roff.cpp                    |   2 +
 code/game/g_savegame.cpp                |   1 +
 code/icarus/IcarusImplementation.cpp    |   1 +
 code/qcommon/cm_load.cpp                |   1 +
 code/qcommon/q_shared.h                 |   2 +-
 code/rd-vanilla/CMakeLists.txt          |   2 +
 code/rd-vanilla/G2_misc.cpp             |   1 +
 code/server/sv_savegame.cpp             |   2 +
 codeJK2/cgame/cg_main.cpp               |   2 +
 codeJK2/game/CMakeLists.txt             |   2 +
 codeJK2/game/G_Timer.cpp                |   1 +
 codeJK2/game/Q3_Registers.cpp           |   1 +
 codeJK2/game/g_main.cpp                 |   1 +
 codeJK2/game/g_objectives.cpp           |   1 +
 codeJK2/game/g_roff.cpp                 |   2 +
 codeJK2/game/g_savegame.cpp             |   1 +
 codeJK2/icarus/Instance.cpp             |   1 +
 codeJK2/icarus/Sequence.cpp             |   1 +
 codeJK2/icarus/Sequencer.cpp            |   1 +
 codeJK2/icarus/TaskManager.cpp          |   1 +
 shared/qcommon/ojk_sg_wrappers.h        |  72 ++++---------------
 shared/qcommon/ojk_sg_wrappers_fwd.h    | 122 ++++++++++++++++++++++++++++++++
 shared/qcommon/ojk_sg_wrappers_shared.h |  65 +++++++++++++++++
 31 files changed, 239 insertions(+), 60 deletions(-)

diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt
index 6bda133..c3f94c1 100644
--- a/code/CMakeLists.txt
+++ b/code/CMakeLists.txt
@@ -175,6 +175,8 @@ if(BuildSPEngine OR BuildJK2SPEngine)
 		"${SPDir}/qcommon/MiniHeap.h"
 
 		"${SharedDir}/qcommon/ojk_sg_wrappers.h"
+		"${SharedDir}/qcommon/ojk_sg_wrappers_fwd.h"
+		"${SharedDir}/qcommon/ojk_sg_wrappers_shared.h"
 
 		${SharedCommonFiles}
 		)
diff --git a/code/cgame/FxScheduler.cpp b/code/cgame/FxScheduler.cpp
index ae8800b..62040c3 100644
--- a/code/cgame/FxScheduler.cpp
+++ b/code/cgame/FxScheduler.cpp
@@ -41,7 +41,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 #include "qcommon/safe/string.h"
 #include <cmath>
-
+#include "qcommon/ojk_sg_wrappers.h"
 
 CFxScheduler	theFxScheduler;
 
diff --git a/code/cgame/cg_main.cpp b/code/cgame/cg_main.cpp
index b9646d5..649ddf4 100644
--- a/code/cgame/cg_main.cpp
+++ b/code/cgame/cg_main.cpp
@@ -28,6 +28,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "g_local.h"
 
 #include "../qcommon/sstring.h"
+#include "qcommon/ojk_sg_wrappers.h"
+
 //NOTENOTE: Be sure to change the mirrored code in g_shared.h
 typedef	std::map< sstring_t, unsigned char  >	namePrecache_m;
 extern namePrecache_m	*as_preCacheMap;
diff --git a/code/game/CMakeLists.txt b/code/game/CMakeLists.txt
index 99d081d..6190bc9 100644
--- a/code/game/CMakeLists.txt
+++ b/code/game/CMakeLists.txt
@@ -261,6 +261,8 @@ set(SPGameCommonFiles
 	"${SPDir}/qcommon/q_shared.cpp"
 	"${SPDir}/qcommon/q_shared.h"
 	"${SharedDir}/qcommon/ojk_sg_wrappers.h"
+	"${SharedDir}/qcommon/ojk_sg_wrappers_fwd.h"
+	"${SharedDir}/qcommon/ojk_sg_wrappers_shared.h"
 	
 	${SharedCommonFiles}
 	)
diff --git a/code/game/G_Timer.cpp b/code/game/G_Timer.cpp
index 0835dde..c469fc1 100644
--- a/code/game/G_Timer.cpp
+++ b/code/game/G_Timer.cpp
@@ -22,6 +22,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 #include "g_local.h"
 #include "../Rufl/hstring.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 #define MAX_GTIMERS	16384
 
diff --git a/code/game/Q3_Interface.cpp b/code/game/Q3_Interface.cpp
index bb4e71d..ea4d7fc 100644
--- a/code/game/Q3_Interface.cpp
+++ b/code/game/Q3_Interface.cpp
@@ -40,6 +40,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "wp_saber.h"
 #include "g_vehicles.h"
 #include "g_navigator.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 extern	cvar_t	*com_buildScript;
 
diff --git a/code/game/g_main.cpp b/code/game/g_main.cpp
index 8b4154f..4b94b70 100644
--- a/code/game/g_main.cpp
+++ b/code/game/g_main.cpp
@@ -36,6 +36,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "../ghoul2/ghoul2_gore.h"
 //rww - RAGDOLL_END
 
+#include "qcommon/ojk_sg_wrappers.h"
+
 extern void WP_SaberLoadParms( void );
 extern qboolean G_PlayerSpawned( void );
 
diff --git a/code/game/g_objectives.cpp b/code/game/g_objectives.cpp
index 9805cbc..6843a32 100644
--- a/code/game/g_objectives.cpp
+++ b/code/game/g_objectives.cpp
@@ -29,6 +29,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #define	G_OBJECTIVES_CPP
 
 #include "objectives.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 qboolean	missionInfo_Updated;
 
diff --git a/code/game/g_roff.cpp b/code/game/g_roff.cpp
index 588dce0..321b3df 100644
--- a/code/game/g_roff.cpp
+++ b/code/game/g_roff.cpp
@@ -25,6 +25,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "Q3_Interface.h"
 #include "../cgame/cg_local.h"
 #include "g_functions.h"
+#include "qcommon/ojk_sg_wrappers.h"
+
 // The list of precached ROFFs
 roff_list_t	roffs[MAX_ROFFS];
 int			num_roffs = 0;
diff --git a/code/game/g_savegame.cpp b/code/game/g_savegame.cpp
index ea612f9..31b796d 100644
--- a/code/game/g_savegame.cpp
+++ b/code/game/g_savegame.cpp
@@ -30,6 +30,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "objectives.h"
 #include "../cgame/cg_camera.h"
 #include "../qcommon/sstring.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 extern void OBJ_LoadTacticalInfo(void);
 
diff --git a/code/icarus/IcarusImplementation.cpp b/code/icarus/IcarusImplementation.cpp
index 71b4394..6308115 100644
--- a/code/icarus/IcarusImplementation.cpp
+++ b/code/icarus/IcarusImplementation.cpp
@@ -33,6 +33,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 #include "../qcommon/q_shared.h"
 #include "../qcommon/qcommon.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 #define STL_ITERATE( a, b )		for ( a = b.begin(); a != b.end(); ++a )
 #define STL_INSERT( a, b )		a.insert( a.end(), b );
diff --git a/code/qcommon/cm_load.cpp b/code/qcommon/cm_load.cpp
index a1ff55f..d3f4c81 100644
--- a/code/qcommon/cm_load.cpp
+++ b/code/qcommon/cm_load.cpp
@@ -24,6 +24,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 // cmodel.c -- model loading
 
 #include "cm_local.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 #ifdef BSPC
 void SetPlaneSignbits (cplane_t *out) {
diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h
index a5b790d..0373d5f 100644
--- a/code/qcommon/q_shared.h
+++ b/code/qcommon/q_shared.h
@@ -160,7 +160,7 @@ float FloatSwap( const float *f );
 
 
 #include "qcommon/q_platform.h"
-#include "qcommon/ojk_sg_wrappers.h"
+#include "qcommon/ojk_sg_wrappers_fwd.h"
 
 
 // ================================================================
diff --git a/code/rd-vanilla/CMakeLists.txt b/code/rd-vanilla/CMakeLists.txt
index da89b3f..449e2e4 100644
--- a/code/rd-vanilla/CMakeLists.txt
+++ b/code/rd-vanilla/CMakeLists.txt
@@ -79,6 +79,8 @@ if(BuildSPRdVanilla OR BuildJK2SPRdVanilla)
 		"${SPDir}/qcommon/q_shared.cpp"
 		"${SPDir}/qcommon/q_shared.h"
 		"${SharedDir}/qcommon/ojk_sg_wrappers.h"
+		"${SharedDir}/qcommon/ojk_sg_wrappers_fwd.h"
+		"${SharedDir}/qcommon/ojk_sg_wrappers_shared.h"
 		
 		${SharedCommonFiles}
 		)
diff --git a/code/rd-vanilla/G2_misc.cpp b/code/rd-vanilla/G2_misc.cpp
index 548fa18..d0a1a95 100644
--- a/code/rd-vanilla/G2_misc.cpp
+++ b/code/rd-vanilla/G2_misc.cpp
@@ -50,6 +50,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 #ifdef _G2_GORE
 #include "../ghoul2/ghoul2_gore.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 #define GORE_TAG_UPPER (256)
 #define GORE_TAG_MASK (~255)
diff --git a/code/server/sv_savegame.cpp b/code/server/sv_savegame.cpp
index 99a3a06..2c01d39 100644
--- a/code/server/sv_savegame.cpp
+++ b/code/server/sv_savegame.cpp
@@ -37,6 +37,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 #include <map>
 
+#include "qcommon/ojk_sg_wrappers.h"
+
 static char	saveGameComment[iSG_COMMENT_SIZE];
 
 //#define SG_PROFILE	// enable for debug save stats if you want
diff --git a/codeJK2/cgame/cg_main.cpp b/codeJK2/cgame/cg_main.cpp
index 50f1840..f8f1ff1 100644
--- a/codeJK2/cgame/cg_main.cpp
+++ b/codeJK2/cgame/cg_main.cpp
@@ -28,6 +28,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "../../code/client/vmachine.h"
 
 #include "../../code/qcommon/sstring.h"
+#include "qcommon/ojk_sg_wrappers.h"
+
 //NOTENOTE: Be sure to change the mirrored code in g_shared.h
 typedef std::map< sstring_t, unsigned char, std::less<sstring_t>, std::allocator< unsigned char >  >	namePrecache_m;
 extern namePrecache_m	*as_preCacheMap;
diff --git a/codeJK2/game/CMakeLists.txt b/codeJK2/game/CMakeLists.txt
index a73dd0d..6abe3ee 100644
--- a/codeJK2/game/CMakeLists.txt
+++ b/codeJK2/game/CMakeLists.txt
@@ -233,6 +233,8 @@ set(JK2SPGameCommonFiles
 	"${SPDir}/qcommon/q_shared.h"
 	"${SPDir}/qcommon/strippublic.h"
 	"${SharedDir}/qcommon/ojk_sg_wrappers.h"
+	"${SharedDir}/qcommon/ojk_sg_wrappers_fwd.h"
+	"${SharedDir}/qcommon/ojk_sg_wrappers_shared.h"
 
 	${SharedCommonFiles}
 	)
diff --git a/codeJK2/game/G_Timer.cpp b/codeJK2/game/G_Timer.cpp
index ab1ed3c..737861e 100644
--- a/codeJK2/game/G_Timer.cpp
+++ b/codeJK2/game/G_Timer.cpp
@@ -23,6 +23,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 #include "g_local.h"
 #include "../../code/Rufl/hstring.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 #define MAX_GTIMERS	16384
 
diff --git a/codeJK2/game/Q3_Registers.cpp b/codeJK2/game/Q3_Registers.cpp
index 2264971..74a19b2 100644
--- a/codeJK2/game/Q3_Registers.cpp
+++ b/codeJK2/game/Q3_Registers.cpp
@@ -24,6 +24,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 #include "g_local.h"
 #include "Q3_Registers.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 extern	void	Q3_DebugPrint( int level, const char *format, ... );
 
diff --git a/codeJK2/game/g_main.cpp b/codeJK2/game/g_main.cpp
index 17c1a17..4fb5a70 100644
--- a/codeJK2/game/g_main.cpp
+++ b/codeJK2/game/g_main.cpp
@@ -35,6 +35,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "objectives.h"
 #include "../cgame/cg_local.h"	// yeah I know this is naughty, but we're shipping soon...
 #include "time.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 extern CNavigator		navigator;
 
diff --git a/codeJK2/game/g_objectives.cpp b/codeJK2/game/g_objectives.cpp
index e66a339..a0488ae 100644
--- a/codeJK2/game/g_objectives.cpp
+++ b/codeJK2/game/g_objectives.cpp
@@ -31,6 +31,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #define	G_OBJECTIVES_CPP
 
 #include "objectives.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 qboolean	missionInfo_Updated;
 
diff --git a/codeJK2/game/g_roff.cpp b/codeJK2/game/g_roff.cpp
index eb7ea81..409785b 100644
--- a/codeJK2/game/g_roff.cpp
+++ b/codeJK2/game/g_roff.cpp
@@ -25,6 +25,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "g_local.h"
 #include "g_roff.h"
 #include "g_icarus.h"
+#include "qcommon/ojk_sg_wrappers.h"
+
 // The list of precached ROFFs
 roff_list_t	roffs[MAX_ROFFS];
 int			num_roffs = 0;
diff --git a/codeJK2/game/g_savegame.cpp b/codeJK2/game/g_savegame.cpp
index bc3028c..54a0d7e 100644
--- a/codeJK2/game/g_savegame.cpp
+++ b/codeJK2/game/g_savegame.cpp
@@ -33,6 +33,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "../cgame/cg_camera.h"
 #include "g_icarus.h"
 #include "../../code/qcommon/sstring.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 extern void OBJ_LoadTacticalInfo(void);
 
diff --git a/codeJK2/icarus/Instance.cpp b/codeJK2/icarus/Instance.cpp
index 299f774..d675291 100644
--- a/codeJK2/icarus/Instance.cpp
+++ b/codeJK2/icarus/Instance.cpp
@@ -29,6 +29,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "instance.h"
 
 #include <assert.h>
+#include "qcommon/ojk_sg_wrappers.h"
 
 // Instance
 
diff --git a/codeJK2/icarus/Sequence.cpp b/codeJK2/icarus/Sequence.cpp
index 012ff25..a619397 100644
--- a/codeJK2/icarus/Sequence.cpp
+++ b/codeJK2/icarus/Sequence.cpp
@@ -28,6 +28,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "icarus.h"
 
 #include <assert.h>
+#include "qcommon/ojk_sg_wrappers.h"
 
 CSequence::CSequence( void )
 {
diff --git a/codeJK2/icarus/Sequencer.cpp b/codeJK2/icarus/Sequencer.cpp
index 0d80d5f..b100329 100644
--- a/codeJK2/icarus/Sequencer.cpp
+++ b/codeJK2/icarus/Sequencer.cpp
@@ -30,6 +30,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 #include "g_shared.h"
 
 #include "assert.h"
+#include "qcommon/ojk_sg_wrappers.h"
 
 // Sequencer 
 
diff --git a/codeJK2/icarus/TaskManager.cpp b/codeJK2/icarus/TaskManager.cpp
index f51b492..2cf235a 100644
--- a/codeJK2/icarus/TaskManager.cpp
+++ b/codeJK2/icarus/TaskManager.cpp
@@ -31,6 +31,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 
 #include <assert.h>
+#include "qcommon/ojk_sg_wrappers.h"
 
 #define ICARUS_VALIDATE(a) if ( a == false ) return TASK_FAILED;
 
diff --git a/shared/qcommon/ojk_sg_wrappers.h b/shared/qcommon/ojk_sg_wrappers.h
index bb08838..e735487 100644
--- a/shared/qcommon/ojk_sg_wrappers.h
+++ b/shared/qcommon/ojk_sg_wrappers.h
@@ -11,66 +11,9 @@
 
 
 #include <algorithm>
-#include <array>
 #include <functional>
-#include <stdexcept>
 #include <type_traits>
-#include <vector>
-
-
-using SgReadFunc = std::function<int (
-    unsigned int chunk_id,
-    void* value_storage,
-    int value_size,
-    void** allocated_value)>;
-
-using SgWriteFunc = std::function<int (
-    unsigned int chunk_id,
-    const void* value_storage,
-    int value_size)>;
-
-
-template<typename T, std::size_t TCount>
-using SgArray = std::array<T, TCount>;
-
-template<typename T, std::size_t TCount1, std::size_t TCount2>
-using SgArray2d = SgArray<SgArray<T, TCount2>, TCount1>;
-
-using SgVec3 = SgArray<float, 3>;
-using SgVec4 = SgArray<float, 4>;
-
-using SgBuffer = std::vector<uint8_t>;
-
-
-class SgException :
-    public std::runtime_error
-{
-public:
-    explicit SgException(
-        const std::string& what_arg) :
-            std::runtime_error(what_arg)
-    {
-    }
-
-    explicit SgException(
-        const char* what_arg) :
-            std::runtime_error(what_arg)
-    {
-    }
-
-    virtual ~SgException()
-    {
-    }
-}; // SgException
-
-
-inline SgBuffer& sg_get_buffer(
-    int new_size)
-{
-    static SgBuffer buffer;
-    buffer.resize(new_size);
-    return buffer;
-}
+#include "ojk_sg_wrappers_shared.h"
 
 
 namespace detail {
@@ -447,6 +390,13 @@ public:
 namespace detail {
 
 
+using SgReadFunc = std::function<int (
+    unsigned int chunk_id,
+    void* value_storage,
+    int value_size,
+    void** allocated_value)>;
+
+
 template<typename TFunc>
 inline SgReadFunc sg_get_read_func(
     TFunc& func,
@@ -571,6 +521,12 @@ inline SgReadFunc sg_get_read_func(
 namespace detail {
 
 
+using SgWriteFunc = std::function<int (
+    unsigned int chunk_id,
+    const void* value_storage,
+    int value_size)>;
+
+
 template<typename TFunc>
 inline SgWriteFunc sg_get_write_func(
     TFunc& func,
diff --git a/shared/qcommon/ojk_sg_wrappers_fwd.h b/shared/qcommon/ojk_sg_wrappers_fwd.h
new file mode 100644
index 0000000..04e3876
--- /dev/null
+++ b/shared/qcommon/ojk_sg_wrappers_fwd.h
@@ -0,0 +1,122 @@
+//
+// Forward declarartions of saved game wrappers.
+//
+
+
+#ifndef OJK_SG_WRAPPERS_FWD_INCLUDED
+#define OJK_SG_WRAPPERS_FWD_INCLUDED
+
+
+#include "ojk_sg_wrappers_shared.h"
+
+
+#ifdef __cplusplus
+
+
+// Exports a value or a fixed-array of values from a
+// native type to a saved game one.
+template<typename TSrc, typename TDst>
+void sg_export(
+    const TSrc& src,
+    TDst& dst);
+
+// Imports a value or a fixed-szie array of values from a
+// saved game type to a native one.
+template<typename TSrc, typename TDst>
+void sg_import(
+    const TSrc& src,
+    TDst& dst);
+
+// Reads a value or a fixed-size array of values from a
+// saved game without conversion.
+template<typename TDst, typename TInstance>
+int sg_read_no_cast(
+    TInstance&& instance,
+    unsigned int chunk_id,
+    TDst& dst_value);
+
+// Reads a specified number of values from a
+// saved game without conversion.
+template<typename TDst, typename TInstance>
+int sg_read_no_cast(
+    TInstance&& instance,
+    unsigned int chunk_id,
+    TDst& dst_value,
+    int dst_count);
+
+// Reads a value or a fixed-array of values from a
+// saved game with conversion.
+template<typename TSrc, typename TDst, typename TInstance>
+int sg_read(
+    TInstance&& instance,
+    unsigned int chunk_id,
+    TDst& dst_value);
+
+// Reads a spesified number of values from a
+// saved game with conversion.
+template<typename TSrc, typename TDst, typename TInstance>
+int sg_read(
+    TInstance&& instance,
+    unsigned int chunk_id,
+    TDst& dst_value,
+    int dst_count);
+
+// Skips a specified number of bytes in a saved game.
+template<typename TInstance>
+int sg_read_skip(
+    TInstance&& instance,
+    unsigned int chunk_id,
+    int count);
+
+// Skips a specified number (by a type size) of bytes in a saved game.
+template<typename TSkip, typename TInstance>
+int sg_read_skip(
+    TInstance&& instance,
+    unsigned int chunk_id);
+
+// Reads a data from a saved game into an automatically allocated block.
+template<typename TInstance, typename TValue>
+int sg_read_allocate(
+    TInstance&& instance,
+    unsigned int chunk_id,
+    TValue*& value);
+
+// Writes a value or a fixed-size array of values into a
+// saved game without conversion.
+template<typename TSrc, typename TInstance>
+int sg_write_no_cast(
+    TInstance&& instance,
+    unsigned int chunk_id,
+    const TSrc& src_value);
+
+// Writes a specified number of values into a
+// saved game without conversion.
+template<typename TSrc, typename TInstance>
+int sg_write_no_cast(
+    TInstance&& instance,
+    unsigned int chunk_id,
+    TSrc&& src_value,
+    int src_count);
+
+// Writes a value or a fixed-array of values into a
+// saved game with conversion.
+template<typename TDst, typename TSrc, typename TInstance>
+int sg_write(
+    TInstance&& instance,
+    unsigned int chunk_id,
+    const TSrc& src_value);
+
+// Reads a spesified number of values from a
+// saved game with conversion.
+template<typename TDst, typename TSrc, typename TInstance>
+int sg_write(
+    TInstance&& instance,
+    unsigned int chunk_id,
+    const TSrc& src_value,
+    int src_count);
+
+
+#endif // __cplusplus
+
+
+#endif // OJK_SG_WRAPPERS_FWD_INCLUDED
diff --git a/shared/qcommon/ojk_sg_wrappers_shared.h b/shared/qcommon/ojk_sg_wrappers_shared.h
new file mode 100644
index 0000000..195fc3c
--- /dev/null
+++ b/shared/qcommon/ojk_sg_wrappers_shared.h
@@ -0,0 +1,65 @@
+//
+// Shared staff of saved game wrappers.
+//
+
+
+#ifndef OJK_SG_WRAPPERS_SHARED_INCLUDED
+#define OJK_SG_WRAPPERS_SHARED_INCLUDED
+
+
+#ifdef __cplusplus
+
+
+#include <cstddef>
+#include <array>
+#include <stdexcept>
+#include <vector>
+
+
+template<typename T, std::size_t TCount>
+using SgArray = std::array<T, TCount>;
+
+template<typename T, std::size_t TCount1, std::size_t TCount2>
+using SgArray2d = SgArray<SgArray<T, TCount2>, TCount1>;
+
+using SgVec3 = SgArray<float, 3>;
+using SgVec4 = SgArray<float, 4>;
+
+using SgBuffer = std::vector<uint8_t>;
+
+
+class SgException :
+    public std::runtime_error
+{
+public:
+    explicit SgException(
+        const std::string& what_arg) :
+            std::runtime_error(what_arg)
+    {
+    }
+
+    explicit SgException(
+        const char* what_arg) :
+            std::runtime_error(what_arg)
+    {
+    }
+
+    virtual ~SgException()
+    {
+    }
+}; // SgException
+
+
+inline SgBuffer& sg_get_buffer(
+    int new_size)
+{
+    static SgBuffer buffer;
+    buffer.resize(new_size);
+    return buffer;
+}
+
+
+#endif // __cplusplus
+
+
+#endif // OJK_SG_WRAPPERS_SHARED_INCLUDED

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