summaryrefslogtreecommitdiff
path: root/bowshock/include/bow/sav.hxx
blob: 41ae8674362cd7f79cbf739ba4323c09efe7298a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2022-2023 Gabriel Jensen.

#pragma once

#include <bow/bs.hxx>

namespace bow {
	constexpr ::zap::i04 savVer = 0x6u;

	constexpr ::zap::sz savLen = 0x79u+::bow::cmdrNmLen; 

	constexpr ::zap::i8 maxShipId = static_cast<::zap::i8>(::bow::ship::vip);

	/*
		Save format:

		offset: id:         size [bytes]: format:

		0x00    fmtver      8             unsigned
		0x08    cmdrnm      E             UTF-8
		0x16    tm          8             unsigned
		0x1E    sysid       8             unsigned
		0x1F    shiptyp     1             unsigned
		0x27    shipposx    8             binary64
		0x2F    shipposy    8             binary64
		0x37    shipposz    8             binary64
		0x3F    shiprotx    8             binary64
		0x47    shiproty    8             binary64
		0x4F    shiprotz    8             binary64
		0x57    shipposvelx 8             binary64
		0x5F    shipposvely 8             binary64
		0x67    shipposvelz 8             binary64
		0x6F    shiprotvelx 8             binary64
		0x77    shiprotvely 8             binary64
		0x7F    shiprotvelz 8             binary64
	*/

	struct savDat {
		::zap::i04 fmtVer;
		char       cmdrNm[::bow::cmdrNmLen];
		::zap::i04 tm;
		::zap::i04 sysId;
		::zap::i8  shipTyp;
		double     shipPosX;
		double     shipPosY;
		double     shipPosZ;
		double     shipRotX;
		double     shipRotY;
		double     shipRotZ;
		double     shipPosVelX;
		double     shipPosVelY;
		double     shipPosVelZ;
		double     shipRotVelX;
		double     shipRotVelY;
		double     shipRotVelZ;
	};

	void decSav(::bow::savDat & buf,::zap::i8 const *     dat) noexcept;
	void encSav(::zap::i8 *     buf,::bow::savDat const & dat) noexcept;

	void newSav(::bow::plDat & dat) noexcept;

	void cont(  ::bow::plDat & dat,char const * fil) noexcept;
	void genDat(::bow::plDat & dat)                  noexcept;

	void sav(char const * fil,::bow::plDat const & dat) noexcept;
}