-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
140 lines (101 loc) · 3.27 KB
/
util.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#pragma once
#include <string>
#include <cstring>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cstdarg> //va_list and stuff
#include <map>
#include <cstdlib>
#include <sys/stat.h>
#include "helpers/dmnt/dmntcht.h"
#include "helpers/debugger/debugger.hpp"
#include <switch.h>
#include <thread>
#include <chrono>
#include "luna.h"
#ifndef UTIL_H
#define UTIL_H
#define MHz *1E6
extern const s64 SaveHeaderSize;
extern const u64 mainSize;
extern const u64 GSavePlayerVillagerAccountOffset;
extern const u64 GSavePlayerVillagerAccountSize;
extern const u64 GAccountTableOffset;
extern const u64 DreamIDOffset;
extern const u64 DreamInfoSize;
extern const u64 playerSize;
extern const u64 playersOffset;
//taken from NHSE
extern const u64 PersonalID;
extern const u64 EventFlagsPlayerOffset;
extern const u64 ItemCollectBitOffset;
extern const u64 ItemRemakeCollectBitOffset;
extern const u64 RecipesOffset;
extern const u64 StorageSizeOffset;
extern const u64 Pocket1SizeOffset;
extern const u64 ExpandBaggageOffset;
extern const u64 houseSize;
extern const u64 houseLvlOffset;
extern const u64 EventFlagOffset;
extern const u64 SaveFgOffset;
extern const u64 SpecialityFruitOffset;
extern const u32 REV_200_MAIN_SIZE;
extern const u32 REV_200_PERSONAL_SIZE;
extern const std::vector<u16> MainmenuRecipes;
extern const std::vector<u16> PrettyGoodToolsRecipesRecipes;
extern const std::vector<u16> BeAChefRecipes;
extern const std::map<u16, u16> TownfruitSmoothiesMap;
extern const std::vector<u64> BID;
extern const std::vector<u64> VersionPointerOffset;
class FileHashRegion
{
public:
u32 HashOffset;
u32 Size;
u32 getBeginOffset() const { return HashOffset + 4; }
u32 getEndOffset() const { return getBeginOffset() + Size; }
FileHashRegion(u32 hashOfs, u32 size) : HashOffset(hashOfs), Size(size)
{}
};
extern const std::vector<FileHashRegion*> REV_200_MAIN;
extern const std::vector<FileHashRegion*> REV_200_PERSONAL;
struct IslandName {
u16 name[0xB];
};
extern int versionindex;
enum class Error {
Success,
GameNotRunning,
GameWrongRevision,
GameNoIsland,
TemplateMissing,
TemplateMissingFiles,
TemplateWrongRevision,
TemplateNotEnoughPlayers,
};
namespace util
{
//returns true if version is valid
bool findVersionIndex(u64 versionBID);
std::string getIslandNameASCII(u64 playerAddr);
std::string getDreamAddrString(u64 mainAddr);
TimeCalendarTime getDreamTime(u64 mainAddr);
IslandName getIslandName(u64 playerAddr);
//removes char from C++ string
void stripChar(char _c, std::string& _s);
std::string getFilename(std::string& path);
u64 FollowPointerMain(u64 pointer, ...);
bool getFlag(unsigned char data[], int bitIndex);
void SetFlag(u8* Data, int bitIndex, u16 value);
void setBitBequalsA(u16 arrA[], int arrlen, unsigned char* B, int bitIndexOffset);
void setBitBequalsA(u16 A, unsigned char* B, int bitIndexOffset);
std::string GetLastTimeSaved(u64 mainAddr);
u32 GetWeatherRandomSeed(u64 mainAddr);
bool isServiceRunning(const char* serviceName);
void overclockSystem(bool enable);
void PrintToNXLink(const char *format, ...);
void PrintToNXLink(std::string message);
void PrintResultToNXLink(Result rc);
}
#endif // UTIL_H