summaryrefslogtreecommitdiff
path: root/bowshock/include/bow/sav.hxx
blob: 6a3d130b3fa836c6b50aaa3a8f60868741813889 (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 ::zp::i04 savVer = 0x6u;

	constexpr ::zp::siz savLen = 0x79u+::bow::cmdrNmLen;

	constexpr ::zp::i8 maxShipId = static_cast<::zp::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 {
		::zp::i04 fmtVer;
		char       cmdrNm[::bow::cmdrNmLen];
		::zp::i04 tm;
		::zp::i04 sysId;
		::zp::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,::zp::i8 const *     dat) noexcept;
	void encSav(::zp::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;
}