Skip to content

Commit e5b9793

Browse files
committed
ViSH: explicitly register script handlers for FishThread
1 parent ef10392 commit e5b9793

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

code/components/scripthookv/component.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"rage:scripting:five",
77
"rage:input:five",
88
"rage:graphics:five",
9-
"citizen:resources:core"
9+
"citizen:resources:core",
10+
"gta:mission-cleanup:five"
1011
],
1112
"provides": []
1213
}

code/components/scripthookv/src/VishCompat.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include "StdInc.h"
99
#include <scrEngine.h>
10+
#include <ScriptHandlerMgr.h>
11+
1012
#include "ICoreGameInit.h"
1113
#include <InputHook.h>
1214
#include <IteratorView.h>
@@ -112,13 +114,24 @@ class FishThread : public GtaThread
112114

113115
bool m_initedNet;
114116

117+
bool m_hasScriptHandler;
118+
115119
public:
116120
virtual void DoRun() override
117121
{
122+
if (!m_hasScriptHandler)
123+
{
124+
CGameScriptHandlerMgr::GetInstance()->AttachScript(this);
125+
126+
m_hasScriptHandler = true;
127+
}
128+
118129
if (!m_initedNet)
119130
{
120131
// make this a network script
121132
NativeInvoke::Invoke<0x1CA59E306ECB80A5, int>(32, false, -1);
133+
134+
m_initedNet = true;
122135
}
123136

124137
std::vector<std::shared_ptr<FishScript>> thisIterScripts(m_scripts);
@@ -129,6 +142,8 @@ class FishThread : public GtaThread
129142
}
130143
}
131144

145+
virtual void Kill() override;
146+
132147
virtual rage::eThreadState Reset(uint32_t scriptHash, void* pArgs, uint32_t argCount) override;
133148

134149
void AddScript(void(*fn)());
@@ -161,6 +176,11 @@ rage::eThreadState FishThread::Reset(uint32_t scriptHash, void* pArgs, uint32_t
161176
return GtaThread::Reset(scriptHash, pArgs, argCount);
162177
}
163178

179+
void FishThread::Kill()
180+
{
181+
m_hasScriptHandler = false;
182+
}
183+
164184
void FishThread::AddScript(void(*fn)())
165185
{
166186
m_scripts.push_back(std::make_shared<FishScript>(fn));

0 commit comments

Comments
 (0)