libER 0.1.4.2
ELDEN RING API library
Loading...
Searching...
No Matches
fd4_task.hpp
Go to the documentation of this file.
1
8#pragma once
9
11#include <detail/preprocessor.hpp>
12#include <fd4/component.hpp>
14#include <fd4/time.hpp>
16#include <memory/from_deque.hpp>
17#include <memory/from_map.hpp>
18#include <memory/from_set.hpp>
21
22#include <utility>
23
32#define CS_TASK_GROUP_ID(INDEX) \
33 (INDEX ^ LIBER_BIT_FLAG(28) ^ LIBER_BIT_FLAG(31))
34
35namespace from {
36// Forward declaration
37namespace CS {
38class CSTask;
39
40// CSTaskGroupId
41using cstgi = unsigned int;
42
43// All task groups:
45} // namespace CS
46
47namespace FD4 {
61 float get_dt() const noexcept {
62 return this->delta_time.time;
63 }
64
70 CS::CSTaskGroup get_task_group() const noexcept {
71 return static_cast<CS::CSTaskGroup>(
72 CS_TASK_GROUP_ID(this->task_group_id));
73 }
74
84 int get_seed() const noexcept {
85 return this->seed;
86 }
87
88private:
89 FD4Time delta_time;
90 CS::cstgi task_group_id;
91 int seed;
92};
93
103public:
104 FD4_RUNTIME_CLASS(FD4TaskBase);
105
106 LIBERAPI virtual ~FD4TaskBase();
107
113 virtual void execute(FD4TaskData* data) = 0;
114
115private:
116 void* liber_unknown = nullptr;
117};
118
120
121// The base step interface.
122// Only its FD4TaskBase instantiation is implemented
123template <class Impl>
124class FD4StepTemplateInterface;
125
126// TODO: methods
127template <>
128class FD4StepTemplateInterface<FD4TaskBase> : public FD4TaskBase {
129public:
130 FD4_RUNTIME_CLASS(FD4StepTemplateInterface);
131
132 virtual void step_execute(FD4TaskData*) = 0;
133 virtual bool is_step_init() = 0;
134 virtual int get_step_index() = 0;
135
136private:
137 virtual bool liber_unknown() = 0;
138 virtual bool liber_unknown() = 0;
139 virtual bool liber_unknown() = 0;
140 virtual bool liber_unknown() = 0;
141 virtual bool liber_unknown() = 0;
142 virtual bool liber_unknown() = 0;
143 virtual bool liber_unknown() = 0;
144 virtual bool liber_unknown() = 0;
145 virtual bool liber_unknown() = 0;
146 virtual bool liber_unknown() = 0;
147};
148
149// TODO:
150// Unnamed (no RTTI) structure
151// Has a virtual destructor
152struct _unk_tree {
153 virtual ~_unk_tree() = default;
154 from::set<void*> _tree;
155 from::allocator<void> liber_unknown;
156 from::allocator<void> liber_unknown;
157};
158
159// Base step layout.
160// Common base class for all steppers
161template <class Impl>
162class FD4StepTemplateBase : public FD4StepTemplateInterface<FD4TaskBase> {
163public:
164 FD4_RUNTIME_CLASS(FD4StepTemplateBase);
165
166private:
167 virtual bool unk_tree_op11() = 0;
168 virtual bool unk_tree_op12() = 0;
169 virtual bool unk_tree_op13() = 0;
170
171 using steps_type = std::pair<void (*)(Impl*), const char*>;
172
173 steps_type* steps;
174 _unk_tree _tree;
175 void* liber_unknown = nullptr;
176 bool liber_unknown = false;
177 from::allocator<void> liber_unknown;
178 void* liber_unknown = nullptr;
179 bool liber_unknown = false;
180 bool liber_unknown = false;
181 from::wstring unk_wstr;
182 bool liber_unknown = true;
183 const wchar_t* state = L"NotExecuting";
184 bool liber_unknown = false;
185 int liber_unknown = 0;
186};
187
188// Internal FD4TaskManager strucures
189struct task_entry_group {
190 LIBER_CLASS(task_entry_group);
191
192 struct task_entry {
193 virtual ~task_entry() = default;
194 FD4TaskBase* task;
195 void* liber_unknown;
196 CS::cstgi group_id;
197 };
198
199 struct task_state {
200 FD4TaskBase* task;
201 void* liber_unknown;
202 int liber_unknown;
203 bool active;
204 };
205
206 virtual ~task_entry_group() = default;
210 int flags[2];
211 CS::cstgi group_id;
212 DLKR::DLPlainAdaptiveMutex mutex;
213 void* debug_menu_item; // FD4::FD4DebugMenuItem
214 void* liber_unknown;
215};
216
218
219// TODO: expose more functionality
225public:
226 FD4_SINGLETON_CLASS(FD4TaskManager);
227
228 virtual ~FD4TaskManager() = 0;
229
230private:
231 from::allocator<void> liber_unknown;
232 struct {
233 void* liber_unknown;
235 from::vector<liber::dummy> liber_unknown;
236 }* liber_unknown[3];
237 void* liber_unknown;
238 void* liber_unknown;
239 bool liber_unknown;
240 bool liber_unknown;
241 CS::CSTask* cs_task;
242 struct {
243 void* liber_unknown;
244 from::allocator<void> liber_unknown;
246 from::vector<task_entry_group> liber_unknown;
247 }* liber_unknown;
248 void* liber_unknown;
249};
250
251LIBER_ASSERTS_TEMPLATE_BEGIN(FD4StepTemplateBase, void);
252LIBER_ASSERT_SIZE(0xB0);
253LIBER_ASSERT_OFFS(0x10, steps);
254LIBER_ASSERT_OFFS(0x18, _tree);
255LIBER_ASSERT_OFFS(0x70, unk_wstr);
256LIBER_ASSERT_OFFS(0xA0, state);
257LIBER_ASSERTS_END;
258
259LIBER_ASSERTS_BEGIN(task_entry_group);
260LIBER_ASSERT_SIZE(0xD0);
261LIBER_ASSERT_OFFS(0x08, entries);
262LIBER_ASSERT_OFFS(0x28, states);
263LIBER_ASSERT_OFFS(0x48, queue);
264LIBER_ASSERT_OFFS(0x80, group_id);
265LIBER_ASSERTS_END;
266
267LIBER_ASSERTS_BEGIN(FD4TaskManager);
268LIBER_ASSERT_SIZE(0x58);
269LIBER_ASSERT_OFFS(0x40, cs_task);
270LIBER_ASSERTS_END;
271} // namespace FD4
272} // namespace from
The main namespace CS task interface.
Definition task.hpp:242
A wrapper around a Windows Critical Section.
Definition kernel_runtime.hpp:34
The base task interface.
Definition fd4_task.hpp:102
virtual void execute(FD4TaskData *data)=0
Virtual method that is called when the task is executed.
Singleton responsible for managing all tasks.
Definition fd4_task.hpp:224
The main libER stand-in for ER allocator proxies.
Definition from_allocator.hpp:308
FD4ComponentBase implementation.
#define CS_TASK_GROUP_ID(INDEX)
Convert a task group id into a task group index, or back.
Definition fd4_task.hpp:32
ELDEN RING allocation interface and from::allocator.
from::deque based on std::deque
std::deque< T, from::allocator< T > > deque
std::deque with from::allocator.
Definition from_deque.hpp:23
from::map based on std::map
std::map< K, V, Pred, from::allocator< std::pair< const K, V > > > map
std::map with from::allocator.
Definition from_map.hpp:24
from::set based on std::set
std::set< T, Pred, from::allocator< T > > set
std::set with from::allocator.
Definition from_set.hpp:23
from::basic_string based on std::basic_string
from::basic_string< wchar_t, std::char_traits< wchar_t > > wstring
std::wstring with from::allocator.
Definition from_string.hpp:41
from::vector based on std::vector
std::vector< T, from::allocator< T > > vector
std::vector with from::allocator.
Definition from_vector.hpp:23
Dantelion2 kernel object management and synchronization.
FD4_SINGLETON_CLASS implementation.
Reflection implementation for a given class.
Definition component.hpp:32
The data passed to tasks on execution.
Definition fd4_task.hpp:55
int get_seed() const noexcept
Get the seed.
Definition fd4_task.hpp:84
CS::CSTaskGroup get_task_group() const noexcept
Get the task group.
Definition fd4_task.hpp:70
float get_dt() const noexcept
Get the delta time.
Definition fd4_task.hpp:61
A basic floating point time class.
Definition time.hpp:20
float time
The time.
Definition time.hpp:27
unsigned int cstgi
Typedef of a special unsigned integer type that may represent a task id.
Definition task.hpp:31
All CS::CSTask taskgroups in order.
Namespace FD4 FD4Time.