Lost Ark SDK  1.148.153.0
LA_Basic.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 // Lost Ark (1.148.153.0) SDK
4 
5 #ifdef _MSC_VER
6  #pragma pack(push, 0x4)
7 #endif
8 
9 #include <unordered_set>
10 #include <string>
11 
12 namespace SDK
13 {
14 template<typename Fn>
15 inline Fn GetVFunction(const void *instance, std::size_t index)
16 {
17  auto vtable = *reinterpret_cast<const void***>(const_cast<void*>(instance));
18  return reinterpret_cast<Fn>(vtable[index]);
19 }
20 
21 template<class T>
22 class TArray
23 {
24  friend class FString;
25 
26 public:
27  inline TArray()
28  {
29  Data = nullptr;
30  Count = Max = 0;
31  };
32 
33  inline size_t Num() const
34  {
35  return Count;
36  };
37 
38  inline T& operator[](size_t i)
39  {
40  return Data[i];
41  };
42 
43  inline const T& operator[](size_t i) const
44  {
45  return Data[i];
46  };
47 
48  inline bool IsValidIndex(size_t i) const
49  {
50  return i < Num();
51  }
52 
53  inline T& GetByIndex(size_t i)
54  {
55  return Data[i];
56  }
57 
58  inline const T& GetByIndex(size_t i) const
59  {
60  return Data[i];
61  }
62 
63 private:
64  T* Data;
65  int32_t Count;
66  int32_t Max;
67 };
68 
69 class FString : public TArray<wchar_t>
70 {
71 public:
72  inline FString()
73  {
74  }
75 
76  FString(const wchar_t* other)
77  {
78  Max = Count = *other ? std::wcslen(other) + 1 : 0;
79 
80  if (Count)
81  {
82  Data = const_cast<wchar_t*>(other);
83  }
84  };
85 
86  inline bool IsValid() const
87  {
88  return Data != nullptr;
89  }
90 
91  inline const wchar_t* c_str() const
92  {
93  return Data;
94  }
95 
96  std::string ToString() const
97  {
98  const auto length = std::wcslen(Data);
99 
100  std::string str(length, '\0');
101 
102  std::use_facet<std::ctype<wchar_t>>(std::locale()).narrow(Data, Data + length, '?', &str[0]);
103 
104  return str;
105  }
106 };
107 
108 template<class TEnum>
110 {
111 public:
112  inline TEnumAsByte()
113  {
114  }
115 
116  inline TEnumAsByte(TEnum _value)
117  : value(static_cast<uint8_t>(_value))
118  {
119  }
120 
121  explicit inline TEnumAsByte(int32_t _value)
122  : value(static_cast<uint8_t>(_value))
123  {
124  }
125 
126  explicit inline TEnumAsByte(uint8_t _value)
127  : value(_value)
128  {
129  }
130 
131  inline operator TEnum() const
132  {
133  return (TEnum)value;
134  }
135 
136  inline TEnum GetValue() const
137  {
138  return (TEnum)value;
139  }
140 
141 private:
142  uint8_t value;
143 };
144 
146 {
147 public:
148  char UnknownData00[0x14]; //0x000A
149  char name[0x14]; //0x0014
150 
151  std::string GetName() const
152  {
153  return name;
154  }
155 };
156 
157 struct FName
158 {
159  int32_t Index;
160  int32_t Number;
161 
162  inline FName()
163  : Index(0),
164  Number(0)
165  {
166  };
167 
168  inline FName(int32_t i)
169  : Index(i),
170  Number(0)
171  {
172  };
173 
174  FName(const char* nameToFind)
175  : Index(0),
176  Number(0)
177  {
178  static std::unordered_set<size_t> cache;
179 
180  for (auto i : cache)
181  {
182  if (GetGlobalNames()[i]->GetName() == nameToFind)
183  {
184  Index = i;
185 
186  return;
187  }
188  }
189 
190  for (auto i = 0u; i < GetGlobalNames().Num(); ++i)
191  {
192  if (GetGlobalNames()[i] != nullptr)
193  {
194  if (GetGlobalNames()[i]->GetName() == nameToFind)
195  {
196  cache.insert(i);
197 
198  Index = i;
199 
200  return;
201  }
202  }
203  }
204  };
205 
206  static TArray<FNameEntry*>* GNames;
208  {
209  return *GNames;
210  };
211 
212  inline std::string GetName() const
213  {
214  return GetGlobalNames()[Index]->GetName();
215  };
216 
217  inline bool operator==(const FName& other) const
218  {
219  return Index == other.Index;
220  };
221 };
222 
223 class UObject;
224 
226 {
227 private:
230 
231 public:
232  inline UObject* GetObject() const
233  {
234  return ObjectPointer;
235  }
236 
238  {
239  return ObjectPointer;
240  }
241 
242  inline void* GetInterface() const
243  {
244  return ObjectPointer != nullptr ? InterfacePointer : nullptr;
245  }
246 };
247 
248 template<class InterfaceType>
250 {
251 public:
252  inline InterfaceType* operator->() const
253  {
254  return (InterfaceType*)GetInterface();
255  }
256 
257  inline InterfaceType& operator*() const
258  {
259  return *((InterfaceType*)GetInterface());
260  }
261 
262  inline operator bool() const
263  {
264  return GetInterface() != nullptr;
265  }
266 };
267 
269 {
270  class UObject* Object;
272 };
273 }
274 
275 #ifdef _MSC_VER
276  #pragma pack(pop)
277 #endif
SDK::TArray::Max
int32_t Max
Definition: LA_Basic.hpp:66
SDK::FName::Number
int32_t Number
Definition: LA_Basic.hpp:160
SDK::FNameEntry::name
char name[0x14]
Definition: LA_Basic.hpp:149
SDK::FScriptInterface
Definition: LA_Basic.hpp:225
SDK::TArray::IsValidIndex
bool IsValidIndex(size_t i) const
Definition: LA_Basic.hpp:48
SDK::TEnumAsByte::TEnumAsByte
TEnumAsByte(int32_t _value)
Definition: LA_Basic.hpp:121
SDK::FScriptInterface::GetObjectRef
UObject *& GetObjectRef()
Definition: LA_Basic.hpp:237
SDK::FScriptInterface::InterfacePointer
void * InterfacePointer
Definition: LA_Basic.hpp:229
SDK::FString
Definition: LA_Basic.hpp:69
SDK::TArray::GetByIndex
T & GetByIndex(size_t i)
Definition: LA_Basic.hpp:53
SDK::FName::GNames
static TArray< FNameEntry * > * GNames
Definition: LA_Basic.hpp:204
SDK::GetVFunction
Fn GetVFunction(const void *instance, std::size_t index)
Definition: LA_Basic.hpp:15
SDK::FString::IsValid
bool IsValid() const
Definition: LA_Basic.hpp:86
SDK::FString::ToString
std::string ToString() const
Definition: LA_Basic.hpp:96
SDK::TArray::TArray
TArray()
Definition: LA_Basic.hpp:27
SDK::TScriptInterface::operator*
InterfaceType & operator*() const
Definition: LA_Basic.hpp:257
SDK::TArray::operator[]
const T & operator[](size_t i) const
Definition: LA_Basic.hpp:43
SDK::TArray::Count
int32_t Count
Definition: LA_Basic.hpp:65
SDK::TArray::GetByIndex
const T & GetByIndex(size_t i) const
Definition: LA_Basic.hpp:58
SDK::FName::FName
FName(int32_t i)
Definition: LA_Basic.hpp:168
SDK::TScriptInterface
Definition: LA_Basic.hpp:249
SDK::FName::operator==
bool operator==(const FName &other) const
Definition: LA_Basic.hpp:217
SDK::FString::FString
FString(const wchar_t *other)
Definition: LA_Basic.hpp:76
SDK::FScriptDelegate::FunctionName
struct FName FunctionName
Definition: LA_Basic.hpp:271
SDK::FName::FName
FName()
Definition: LA_Basic.hpp:162
SDK::FName::Index
int32_t Index
Definition: LA_Basic.hpp:159
SDK::FName
Definition: LA_Basic.hpp:157
SDK::FScriptDelegate
Definition: LA_Basic.hpp:268
SDK::FName::GetGlobalNames
static TArray< FNameEntry * > & GetGlobalNames()
Definition: LA_Basic.hpp:207
SDK::FName::FName
FName(const char *nameToFind)
Definition: LA_Basic.hpp:174
SDK::FNameEntry::GetName
std::string GetName() const
Definition: LA_Basic.hpp:151
SDK::FNameEntry::UnknownData00
char UnknownData00[0x14]
Definition: LA_Basic.hpp:148
SDK::TScriptInterface::operator->
InterfaceType * operator->() const
Definition: LA_Basic.hpp:252
SDK
Definition: LA_AkAudio_classes.hpp:11
SDK::TEnumAsByte::GetValue
TEnum GetValue() const
Definition: LA_Basic.hpp:136
SDK::FScriptDelegate::Object
class UObject * Object
Definition: LA_Basic.hpp:270
SDK::UObject
Definition: LA_Core_classes.hpp:19
SDK::FScriptInterface::ObjectPointer
UObject * ObjectPointer
Definition: LA_Basic.hpp:228
SDK::FString::FString
FString()
Definition: LA_Basic.hpp:72
SDK::FScriptInterface::GetObject
UObject * GetObject() const
Definition: LA_Basic.hpp:232
SDK::FScriptInterface::GetInterface
void * GetInterface() const
Definition: LA_Basic.hpp:242
SDK::FNameEntry
Definition: LA_Basic.hpp:145
SDK::TArray::Data
T * Data
Definition: LA_Basic.hpp:64
SDK::FString::c_str
const wchar_t * c_str() const
Definition: LA_Basic.hpp:91
SDK::TArray
Definition: LA_Basic.hpp:22
SDK::TEnumAsByte::TEnumAsByte
TEnumAsByte(TEnum _value)
Definition: LA_Basic.hpp:116
SDK::TEnumAsByte::TEnumAsByte
TEnumAsByte()
Definition: LA_Basic.hpp:112
SDK::FName::GetName
std::string GetName() const
Definition: LA_Basic.hpp:212
SDK::TArray::operator[]
T & operator[](size_t i)
Definition: LA_Basic.hpp:38
SDK::TEnumAsByte::value
uint8_t value
Definition: LA_Basic.hpp:142
SDK::TArray::Num
size_t Num() const
Definition: LA_Basic.hpp:33
SDK::TEnumAsByte::TEnumAsByte
TEnumAsByte(uint8_t _value)
Definition: LA_Basic.hpp:126
SDK::TEnumAsByte
Definition: LA_Basic.hpp:109