CommonLibVR
Loading...
Searching...
No Matches
SkyrimVM.h
Go to the documentation of this file.
1#pragma once
2
3#include "RE/B/BSAtomic.h"
4#include "RE/B/BSTEvent.h"
5#include "RE/B/BSTFreeList.h"
6#include "RE/B/BSTHashMap.h"
8#include "RE/B/BSTSingleton.h"
11#include "RE/D/DelayFunctor.h"
12#include "RE/F/FragmentSystem.h"
13#include "RE/H/HandlePolicy.h"
14#include "RE/I/IFreezeQuery.h"
16#include "RE/L/Logger.h"
17#ifdef SKYRIMVR
19#endif
20#include "RE/P/Profiler.h"
21#include "RE/S/SavePatcher.h"
25
26namespace RE
27{
28 namespace BSScript
29 {
30 class IFunctionArguments;
31 class IVirtualMachine;
32 class IVMDebugInterface;
33 class IVMSaveLoadInterface;
34 struct StatsEvent;
35 }
36
37 struct PositionPlayerEvent;
38 struct TESActivateEvent;
39 struct TESActiveEffectApplyRemoveEvent;
40 struct TESActorLocationChangeEvent;
41 struct TESBookReadEvent;
42 struct TESCellAttachDetachEvent;
43 struct TESCellFullyLoadedEvent;
44 struct TESCombatEvent;
45 struct TESContainerChangedEvent;
46 struct TESDeathEvent;
47 struct TESDestructionStageChangedEvent;
48 struct TESEnterBleedoutEvent;
49 struct TESEquipEvent;
50 struct TESFastTravelEndEvent;
51 struct TESFormDeleteEvent;
52 struct TESFurnitureEvent;
53 struct TESGrabReleaseEvent;
54 struct TESHitEvent;
55 struct TESInitScriptEvent;
56 struct TESLoadGameEvent;
57 struct TESLockChangedEvent;
58 struct TESMagicEffectApplyEvent;
59 struct TESMagicWardHitEvent;
60 struct TESMoveAttachDetachEvent;
61 struct TESObjectLoadedEvent;
62 struct TESObjectREFRTranslationEvent;
63 struct TESOpenCloseEvent;
64 struct TESPackageEvent;
65 struct TESPerkEntryRunEvent;
66 struct TESPlayerBowShotEvent;
67 struct TESQuestInitEvent;
68 struct TESQuestStageEvent;
69 struct TESResetEvent;
70 struct TESResolveNPCTemplatesEvent;
71 struct TESSceneActionEvent;
72 struct TESSceneEvent;
73 struct TESScenePhaseEvent;
74 struct TESSellEvent;
75 struct TESSleepStartEvent;
76 struct TESSleepStopEvent;
77 struct TESSpellCastEvent;
78 struct TESSwitchRaceCompleteEvent;
79 struct TESTopicInfoEvent;
80 struct TESTrackedStatsEvent;
81 struct TESTrapHitEvent;
82 struct TESTriggerEnterEvent;
83 struct TESTriggerEvent;
84 struct TESTriggerLeaveEvent;
85 struct TESUniqueIDChangeEvent;
86
87 class SkyrimVM :
88 public BSTSingletonSDM<SkyrimVM>, // 01A0
89 public BSScript::IFreezeQuery, // 0000
91 public BSTEventSink<TESActivateEvent>, // 0010
92 public BSTEventSink<TESActiveEffectApplyRemoveEvent>, // 0018
93 public BSTEventSink<TESActorLocationChangeEvent>, // 0020
94 public BSTEventSink<TESBookReadEvent>, // 0028
95 public BSTEventSink<TESCellAttachDetachEvent>, // 0030
96 public BSTEventSink<TESCellFullyLoadedEvent>, // 0038
97 public BSTEventSink<TESCombatEvent>, // 0040
98 public BSTEventSink<TESContainerChangedEvent>, // 0048
99 public BSTEventSink<TESDeathEvent>, // 0050
100 public BSTEventSink<TESDestructionStageChangedEvent>, // 0058
101 public BSTEventSink<TESEnterBleedoutEvent>, // 0060
102 public BSTEventSink<TESEquipEvent>, // 0068
103 public BSTEventSink<TESFormDeleteEvent>, // 0070
104 public BSTEventSink<TESFurnitureEvent>, // 0078
105 public BSTEventSink<TESGrabReleaseEvent>, // 0080
106 public BSTEventSink<TESHitEvent>, // 0088
107 public BSTEventSink<TESInitScriptEvent>, // 0090
108 public BSTEventSink<TESLoadGameEvent>, // 0098
109 public BSTEventSink<TESLockChangedEvent>, // 00A0
110 public BSTEventSink<TESMagicEffectApplyEvent>, // 00A8
111 public BSTEventSink<TESMagicWardHitEvent>, // 00B0
112 public BSTEventSink<TESMoveAttachDetachEvent>, // 00B8
113 public BSTEventSink<TESObjectLoadedEvent>, // 00C0
114 public BSTEventSink<TESObjectREFRTranslationEvent>, // 00C8
115 public BSTEventSink<TESOpenCloseEvent>, // 00D0
116 public BSTEventSink<TESPackageEvent>, // 00D8
117 public BSTEventSink<TESPerkEntryRunEvent>, // 00E0
118 public BSTEventSink<TESQuestInitEvent>, // 00E8
119 public BSTEventSink<TESQuestStageEvent>, // 00F0
120 public BSTEventSink<TESResetEvent>, // 00F8
121 public BSTEventSink<TESResolveNPCTemplatesEvent>, // 0100
122 public BSTEventSink<TESSceneEvent>, // 0108
123 public BSTEventSink<TESSceneActionEvent>, // 0110
124 public BSTEventSink<TESScenePhaseEvent>, // 0118
125 public BSTEventSink<TESSellEvent>, // 0120
126 public BSTEventSink<TESSleepStartEvent>, // 0128
127 public BSTEventSink<TESSleepStopEvent>, // 0130
128 public BSTEventSink<TESSpellCastEvent>, // 0138
129 public BSTEventSink<TESTopicInfoEvent>, // 0140
130 public BSTEventSink<TESTrackedStatsEvent>, // 0148
131 public BSTEventSink<TESTrapHitEvent>, // 0150
132 public BSTEventSink<TESTriggerEvent>, // 0158
133 public BSTEventSink<TESTriggerEnterEvent>, // 0160
134 public BSTEventSink<TESTriggerLeaveEvent>, // 0168
135 public BSTEventSink<TESUniqueIDChangeEvent>, // 0170
136 public BSTEventSink<TESSwitchRaceCompleteEvent>, // 0178
137 public BSTEventSink<TESPlayerBowShotEvent>, // 0180
138#ifndef SKYRIMVR
139 public BSTEventSink<TESFastTravelEndEvent>, // 0188
140 public BSTEventSink<PositionPlayerEvent>, // 0190
141 public BSTEventSink<BSScript::StatsEvent>, // 0198
142#else
143 public BSTEventSink<PositionPlayerEvent>, // 0188
144 public BSTEventSink<BSScript::StatsEvent>, // 0190
145 public BSTEventSink<MenuOpenCloseEvent>, // 0198
146#endif
147 public BSTEventSource<BSScript::StatsEvent> // 01A8
148 {
149 public:
150 inline static constexpr auto RTTI = RTTI_SkyrimVM;
151 inline static constexpr auto VTABLE = VTABLE_SkyrimVM;
152
154 {
155 public:
156 enum class UpdateType : bool
157 {
158 kRepeat = 0, // RegisterForUpdate/RegisterForUpdateGameTime
159 kNoRepeat = 1, // RegisterForSingleUpdate/RegisterForSingleUpdateGameTime
160 };
161
162 // members
164 std::uint16_t pad06; // 06
165 std::uint32_t timeToSendEvent; // 08 - updateTime + currentVMMenuMode/currentVMDaysPassed
166 std::uint32_t updateTime; // 0C
168 };
169 static_assert(sizeof(UpdateDataEvent) == 0x18);
170
172 {
173 public:
174 // members
175 std::uint32_t pad04; // 04
178 };
179 static_assert(sizeof(MenuOpenClose) == 0x18);
180
181 struct WaitCall
182 {
183 public:
184 // members
185 std::uint32_t timeToSendEvent; // 00 - Same as UpdateDataEvent, updateTime is discarded
186 VMStackID stackID; // 04 - used for vm->ReturnFromLatent()
188 };
189 static_assert(sizeof(WaitCall) == 0x10);
190
192 {
193 public:
194 enum class LOSEventType
195 {
196 kGain = 0,
197 kLost,
198 kBoth,
199 };
200
201 enum class PreviousLOS
202 {
203 kLOS = 1,
204 kNoLOS = 2
205 };
206
207 // members
208 std::uint32_t pad04; // 04
213 PreviousLOS lastLOSCheckResult; // 1C - (2 - (akViewer::HasLOS(akTarget) != 0))
214 };
215 static_assert(sizeof(LOSDataEvent) == 0x20);
216
223 static_assert(sizeof(InventoryEventFilterLists) == 0x68);
224
226 {
227 virtual bool matchesFilter(VMHandle handle) = 0;
228 };
229
230 ~SkyrimVM() override; // 00
231
233
237
238 // members
251 mutable BSSpinLock frozenLock; // 0678
252 std::uint32_t isFrozen; // 0680
254 std::uint32_t currentVMTime; // 068C
255 std::uint32_t currentVMMenuModeTime; // 0690
256 std::uint32_t currentVMGameTime; // 0694
257 std::uint32_t currentVMDaysPassed; // 0698 - Calender.GetDaysPassed() * 1000
259 std::uint32_t pad06A4; // 06A4
260 BSTArray<WaitCall> queuedWaitCalls; // 06A8 - Utility.Wait() calls
261 BSTArray<WaitCall> queuedWaitMenuModeCalls; // 06C0 - Utility.WaitMenuMode() calls
262 BSTArray<WaitCall> queuedWaitGameCalls; // 06D8 - Utility.WaitGameTime() calls
265 std::uint32_t currentLOSEventCheckIndex; // 0710
267 std::uint32_t pad071C; // 071C
270 std::uint32_t unk0750; // 0750
271#ifdef SKYRIMVR
272 mutable BSSpinLock registeredMenuEventsLock; // 0754
273 std::uint32_t pad075C; // 075C
274 BSTArray<BSTSmartPointer<MenuOpenClose>> registeredMenuEvents; // 0760 - RegisterForMenuOpenClose
276#else
278 std::uint32_t pad075C; // 075C
279#endif
280 BSTSet<VMHandle> registeredSleepEvents; // 0780 - RegisterForSleep
282 BSTSet<VMHandle> registeredStatsEvents; // 0818 - RegisterForTrackedStats
297 mutable BSSpinLock userLogMapLock; // 8918
300 std::uint32_t currentVMOverstressTime; // 8958
301 std::uint32_t lastVMStackDumpTime; // 895C
304 private:
306 };
307#ifndef SKYRIMVR
308 static_assert(sizeof(SkyrimVM) == 0x8978);
309#else
310 static_assert(sizeof(SkyrimVM) == 0x8998);
311#endif
312}
#define KEEP_FOR_RE()
Definition PCH.h:517
Definition CompiledScriptLoader.h:15
Definition IFreezeQuery.h:8
Definition IFunctionArguments.h:12
Definition IStackCallbackSaveInterface.h:8
Definition IVMDebugInterface.h:8
Definition IVMSaveLoadInterface.h:47
Definition IVirtualMachine.h:40
Definition SimpleAllocMemoryPagePolicy.h:11
Definition BSAtomic.h:92
Definition BSTArray.h:378
Definition BSTMessageQueue.h:63
Definition BSTEvent.h:143
Definition BSTEvent.h:19
Definition BSTHashMap.h:21
Definition BSTSmartPointer.h:37
Definition BSTFreeList.h:28
Definition FragmentSystem.h:11
Definition HandlePolicy.h:11
Definition Logger.h:11
Definition SkyrimScriptObjectBindPolicy.h:11
Definition Profiler.h:12
Definition SavePatcher.h:10
Definition SkyrimVM.h:148
BSTArray< BSTSmartPointer< UpdateDataEvent > > queuedOnUpdateEvents
Definition SkyrimVM.h:268
BSTCommonLLMessageQueue< BSTSmartPointer< SkyrimScript::DelayFunctor > > postRenderFunctorQueue2
Definition SkyrimVM.h:290
bool QueuePostRenderCall(const BSTSmartPointer< SkyrimScript::DelayFunctor > &a_functor)
std::uint32_t currentVMGameTime
Definition SkyrimVM.h:256
BSTSet< VMHandle > registeredSleepEvents
Definition SkyrimVM.h:280
BSScript::CompiledScriptLoader scriptLoader
Definition SkyrimVM.h:243
void RelayEvent(VMHandle handle, BSFixedString *event, BSScript::IFunctionArguments *args, ISendEventFilter *optionalFilter)
SkyrimScript::Logger logger
Definition SkyrimVM.h:244
BSSpinLock frozenLock
Definition SkyrimVM.h:251
std::uint32_t lastVMStackDumpTime
Definition SkyrimVM.h:301
BSTCommonLLMessageQueue< BSTSmartPointer< SkyrimScript::DelayFunctor > > renderSafeFunctorQueue2
Definition SkyrimVM.h:286
SkyrimScript::ObjectBindPolicy objectBindPolicy
Definition SkyrimVM.h:246
~SkyrimVM() override
BSTHashMap< const char *, SkyrimScript::Logger * > userLogMap
Definition SkyrimVM.h:298
BSTStaticFreeList< BSTSmartPointer< SkyrimScript::DelayFunctor >, 512 > postRenderFunctorPool2
Definition SkyrimVM.h:289
std::uint32_t currentVMOverstressTime
Definition SkyrimVM.h:300
BSSpinLock currentVMTimeLock
Definition SkyrimVM.h:253
BSSpinLock InventoryEventFilterMapLock
Definition SkyrimVM.h:302
BSTArray< WaitCall > queuedWaitGameCalls
Definition SkyrimVM.h:262
BSScript::IVMDebugInterface * debugInterface
Definition SkyrimVM.h:241
BSTArray< WaitCall > queuedWaitMenuModeCalls
Definition SkyrimVM.h:261
BSTCommonLLMessageQueue< BSTSmartPointer< SkyrimScript::DelayFunctor > > * postRenderQueueToReadFrom
Definition SkyrimVM.h:295
SkyrimScript::FragmentSystem fragmentSystem
Definition SkyrimVM.h:248
BSSpinLock renderSafeQueueLock
Definition SkyrimVM.h:291
std::uint32_t isFrozen
Definition SkyrimVM.h:252
SkyrimScript::HandlePolicy handlePolicy
Definition SkyrimVM.h:245
BSTStaticFreeList< BSTSmartPointer< SkyrimScript::DelayFunctor >, 512 > renderSafeFunctorPool1
Definition SkyrimVM.h:283
std::uint32_t currentVMMenuModeTime
Definition SkyrimVM.h:255
BSTArray< WaitCall > queuedWaitCalls
Definition SkyrimVM.h:260
std::uint32_t pad075C
Definition SkyrimVM.h:278
BSScript::SimpleAllocMemoryPagePolicy memoryPagePolicy
Definition SkyrimVM.h:242
BSTSmartPointer< SkyrimScript::Store > scriptStore
Definition SkyrimVM.h:247
BSTArray< BSTSmartPointer< UpdateDataEvent > > queuedOnUpdateGameEvents
Definition SkyrimVM.h:269
BSTCommonLLMessageQueue< BSTSmartPointer< SkyrimScript::DelayFunctor > > * renderSafeQueueToWriteTo
Definition SkyrimVM.h:293
BSTCommonLLMessageQueue< BSTSmartPointer< SkyrimScript::DelayFunctor > > renderSafeFunctorQueue1
Definition SkyrimVM.h:284
BSTSmartPointer< BSScript::IVirtualMachine > impl
Definition SkyrimVM.h:239
std::uint32_t currentVMDaysPassed
Definition SkyrimVM.h:257
static constexpr auto RTTI
Definition SkyrimVM.h:150
BSSpinLock userLogMapLock
Definition SkyrimVM.h:297
BSTStaticFreeList< BSTSmartPointer< SkyrimScript::DelayFunctor >, 512 > renderSafeFunctorPool2
Definition SkyrimVM.h:285
std::uint32_t pad06A4
Definition SkyrimVM.h:259
BSTHashMap< VMHandle, InventoryEventFilterLists * > InventoryEventFilterMap
Definition SkyrimVM.h:303
BSTArray< BSTSmartPointer< LOSDataEvent > > queuedLOSEventChecks
Definition SkyrimVM.h:264
BSSpinLock queuedWaitEventLock
Definition SkyrimVM.h:258
BSSpinLock currentVMOverstressTimeLock
Definition SkyrimVM.h:299
static constexpr auto VTABLE
Definition SkyrimVM.h:151
BSSpinLock queuedLOSEventCheckLock
Definition SkyrimVM.h:263
std::uint32_t unk0750
Definition SkyrimVM.h:270
std::uint32_t currentLOSEventCheckIndex
Definition SkyrimVM.h:265
BSTCommonLLMessageQueue< BSTSmartPointer< SkyrimScript::DelayFunctor > > postRenderFunctorQueue1
Definition SkyrimVM.h:288
BSSpinLock queuedOnUpdateEventLock
Definition SkyrimVM.h:266
BSTStaticFreeList< BSTSmartPointer< SkyrimScript::DelayFunctor >, 512 > postRenderFunctorPool1
Definition SkyrimVM.h:287
BSTSet< VMHandle > registeredStatsEvents
Definition SkyrimVM.h:282
BSSpinLock registeredSleepEventsLock
Definition SkyrimVM.h:277
BSSpinLock postRenderQueueLock
Definition SkyrimVM.h:294
std::uint32_t currentVMTime
Definition SkyrimVM.h:254
SkyrimScript::Profiler profiler
Definition SkyrimVM.h:249
void SendAndRelayEvent(VMHandle handle, BSFixedString *event, BSScript::IFunctionArguments *args, ISendEventFilter *optionalFilter)
BSTCommonLLMessageQueue< BSTSmartPointer< SkyrimScript::DelayFunctor > > * postRenderQueueToWriteTo
Definition SkyrimVM.h:296
static SkyrimVM * GetSingleton()
std::uint32_t pad071C
Definition SkyrimVM.h:267
BSTCommonLLMessageQueue< BSTSmartPointer< SkyrimScript::DelayFunctor > > * renderSafeQueueToReadFrom
Definition SkyrimVM.h:292
BSSpinLock registeredStatsEventsLock
Definition SkyrimVM.h:281
BSScript::IVMSaveLoadInterface * saveLoadInterface
Definition SkyrimVM.h:240
SkyrimScript::SavePatcher savePatcher
Definition SkyrimVM.h:250
Definition AbsorbEffect.h:6
std::uint32_t FormID
Definition BSCoreTypes.h:5
constexpr REL::ID RTTI_SkyrimVM(static_cast< std::uint64_t >(689129))
std::uint32_t VMStackID
Definition BSCoreTypes.h:8
std::uint64_t VMHandle
Definition BSCoreTypes.h:7
constexpr std::array< REL::ID, 52 > VTABLE_SkyrimVM
Definition Offsets_VTABLE.h:12754
Definition BSIntrusiveRefCounted.h:8
Definition BSTSingleton.h:50
Definition SkyrimVM.h:226
virtual bool matchesFilter(VMHandle handle)=0
BSTSet< FormID > itemListsForFiltering
Definition SkyrimVM.h:221
BSTSet< FormID > itemsForFiltering
Definition SkyrimVM.h:220
Definition SkyrimVM.h:192
FormID akTargetFormID
Definition SkyrimVM.h:211
LOSEventType losEventType
Definition SkyrimVM.h:212
FormID akViewerFormID
Definition SkyrimVM.h:210
PreviousLOS lastLOSCheckResult
Definition SkyrimVM.h:213
VMHandle handle
Definition SkyrimVM.h:209
std::uint32_t pad04
Definition SkyrimVM.h:208
PreviousLOS
Definition SkyrimVM.h:202
LOSEventType
Definition SkyrimVM.h:195
Definition SkyrimVM.h:172
VMHandle handle
Definition SkyrimVM.h:176
BSFixedString menuName
Definition SkyrimVM.h:177
std::uint32_t pad04
Definition SkyrimVM.h:175
Definition SkyrimVM.h:154
std::uint32_t timeToSendEvent
Definition SkyrimVM.h:165
UpdateType
Definition SkyrimVM.h:157
VMHandle handle
Definition SkyrimVM.h:167
std::uint32_t updateTime
Definition SkyrimVM.h:166
UpdateType updateType
Definition SkyrimVM.h:163
std::uint16_t pad06
Definition SkyrimVM.h:164
Definition SkyrimVM.h:182
VMStackID stackID
Definition SkyrimVM.h:186
BSScript::IVirtualMachine * vm
Definition SkyrimVM.h:187
std::uint32_t timeToSendEvent
Definition SkyrimVM.h:185