-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfiledefinitions.h
82 lines (69 loc) · 1.38 KB
/
filedefinitions.h
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#pragma once
/*
* The codes in file formats should have no d3d9 components.
*/
#include "general_headers.h"
#include "log.h"
enum class file_type : uint32_t
{
shp = 0,
vxl = 1,
tmp = 2,
pal = 3,
vpl = 4,
hva = 5,
};
enum class normal_type :byte
{
tiberian_sun = 2,
red_alert = 4,
};
struct color
{
byte r{ 0 }, g{ 0 }, b{ 0 };
};
struct vxlmatrix
{
union {
struct {
float _11, _12, _13, _14;
float _21, _22, _23, _24;
float _31, _32, _33, _34;
};
float _data[3][4];
};
};
class game_file
{
public:
game_file() = default;
virtual ~game_file() = default;
virtual bool load(const std::string& filename) = 0;
virtual bool load(const void* data) = 0;
virtual bool is_loaded() const = 0;
virtual void purge() = 0;
virtual file_type type() const = 0;
};
std::filesystem::path get_exe_path();
std::shared_ptr<char> read_whole_file(const std::string& filename);
/*
{
if (!std::filesystem::exists(filename))
{
logger::writelog("File does not exist.");
return nullptr;
}
const size_t filesize = std::filesystem::file_size(filename);
std::fstream file(filename, std::ios::binary);
if (!file || !filesize)
{
return nullptr;
}
std::shared_ptr<char> data(new char[filesize]);
if (!data)
{
return nullptr;
}
file.read(data.get(), filesize);
return data;
}*/