mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 12:25:59 +03:00
refactor(thunderbrew): use static size members instead of null-termination to delimit FrameScript_Method arrays
This commit is contained in:
parent
32cfe08d0b
commit
2fb754a83a
@ -32,14 +32,14 @@ FrameScript_Method CGVideoOptions::s_ScriptFunctions[] = {
|
|||||||
{ "GetRefreshRates", &Script_GetRefreshRates },
|
{ "GetRefreshRates", &Script_GetRefreshRates },
|
||||||
{ "GetCurrentMultisampleFormat", &Script_GetCurrentMultisampleFormat },
|
{ "GetCurrentMultisampleFormat", &Script_GetCurrentMultisampleFormat },
|
||||||
{ "GetMultisampleFormats", &Script_GetMultisampleFormats },
|
{ "GetMultisampleFormats", &Script_GetMultisampleFormats },
|
||||||
{ "IsStereoVideoAvailable", &Script_IsStereoVideoAvailable },
|
{ "IsStereoVideoAvailable", &Script_IsStereoVideoAvailable }
|
||||||
{ nullptr, nullptr }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
size_t CGVideoOptions::s_NumScriptFunctions = sizeof(CGVideoOptions::s_ScriptFunctions) / sizeof(FrameScript_Method);
|
||||||
|
|
||||||
void CGVideoOptions::RegisterScriptFunctions() {
|
void CGVideoOptions::RegisterScriptFunctions() {
|
||||||
FrameScript_Method* item = s_ScriptFunctions;
|
for (int32_t i = 0; i < CGVideoOptions::s_NumScriptFunctions; i++) {
|
||||||
while (item->name) {
|
auto item = &s_ScriptFunctions[i];
|
||||||
FrameScript_RegisterFunction(item->name, item->method);
|
FrameScript_RegisterFunction(item->name, item->method);
|
||||||
item++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ class CGVideoOptions {
|
|||||||
public:
|
public:
|
||||||
// Static variables
|
// Static variables
|
||||||
static FrameScript_Method s_ScriptFunctions[];
|
static FrameScript_Method s_ScriptFunctions[];
|
||||||
|
static size_t CGVideoOptions::s_NumScriptFunctions;
|
||||||
|
|
||||||
// Static functions
|
// Static functions
|
||||||
static void RegisterScriptFunctions();
|
static void RegisterScriptFunctions();
|
||||||
|
|||||||
@ -1268,8 +1268,6 @@ void CGxDeviceGLSDL::SceneClear(uint32_t mask, CImVector color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CGxDeviceGLSDL::ScenePresent() {
|
void CGxDeviceGLSDL::ScenePresent() {
|
||||||
this->m_GLSDLWindow.DispatchEvents();
|
|
||||||
|
|
||||||
if (this->m_context) {
|
if (this->m_context) {
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ int32_t GLMipmap::GetDepthBits() {
|
|||||||
return this->m_DepthBits;
|
return this->m_DepthBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLMipmap::Attach(GLFramebuffer* framebuffer, GLenum attachPoint, int32_t a4) {
|
void GLMipmap::Attach(GLFramebuffer* framebuffer, GLenum attachPoint, int32_t level) {
|
||||||
if (!this->m_AttachPoints) {
|
if (!this->m_AttachPoints) {
|
||||||
this->m_AttachPoints = new std::vector<GLAttachPoint>();
|
this->m_AttachPoints = new std::vector<GLAttachPoint>();
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ void GLMipmap::Attach(GLFramebuffer* framebuffer, GLenum attachPoint, int32_t a4
|
|||||||
GL_TEXTURE_3D,
|
GL_TEXTURE_3D,
|
||||||
this->m_Texture->m_TextureID,
|
this->m_Texture->m_TextureID,
|
||||||
this->m_Level,
|
this->m_Level,
|
||||||
a4
|
level
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
glFramebufferTexture2DEXT(
|
glFramebufferTexture2DEXT(
|
||||||
@ -67,7 +67,7 @@ void GLMipmap::Attach(GLFramebuffer* framebuffer, GLenum attachPoint, int32_t a4
|
|||||||
|
|
||||||
auto& attach = attachPoints[framebufferID];
|
auto& attach = attachPoints[framebufferID];
|
||||||
attach.framebuffer = framebuffer;
|
attach.framebuffer = framebuffer;
|
||||||
attach.zOffset = a4;
|
attach.zOffset = level;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(attach.point != GL_DEPTH_ATTACHMENT || attachPoint != GL_STENCIL_ATTACHMENT)
|
(attach.point != GL_DEPTH_ATTACHMENT || attachPoint != GL_STENCIL_ATTACHMENT)
|
||||||
|
|||||||
@ -18,17 +18,14 @@ void F_CALL FMOD_Free(void* ptr, FMOD_MEMORY_TYPE type, const char* sourcestr) {
|
|||||||
SMemFree(ptr, sourcestr, 0, 0);
|
SMemFree(ptr, sourcestr, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SI2::RegisterScriptFunctions() {
|
void SI2::RegisterScriptFunctions() {
|
||||||
FrameScript_Method* item = s_ScriptFunctions;
|
for (int32_t i = 0; i < s_NumScriptFunctions; i++) {
|
||||||
while (item->name) {
|
auto item = &s_ScriptFunctions[i];
|
||||||
FrameScript_RegisterFunction(item->name, item->method);
|
FrameScript_RegisterFunction(item->name, item->method);
|
||||||
item++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t SI2::Init(int32_t flag) {
|
int32_t SI2::Init(int32_t flag) {
|
||||||
|
|
||||||
Log_Init();
|
Log_Init();
|
||||||
SI2_LOG("=> Version %s (%s) %s", "1.0.0", "00000", "Feb 25 2024");
|
SI2_LOG("=> Version %s (%s) %s", "1.0.0", "00000", "Feb 25 2024");
|
||||||
SI2_LOG(" ");
|
SI2_LOG(" ");
|
||||||
|
|||||||
@ -16,6 +16,7 @@ class SI2 {
|
|||||||
public:
|
public:
|
||||||
// Static variables
|
// Static variables
|
||||||
static FrameScript_Method s_ScriptFunctions[];
|
static FrameScript_Method s_ScriptFunctions[];
|
||||||
|
static size_t s_NumScriptFunctions;
|
||||||
static uint32_t sm_logFlags;
|
static uint32_t sm_logFlags;
|
||||||
static HSLOG sm_log;
|
static HSLOG sm_log;
|
||||||
static FMOD::System* sm_pGameSystem;
|
static FMOD::System* sm_pGameSystem;
|
||||||
|
|||||||
@ -122,6 +122,7 @@ FrameScript_Method SI2::s_ScriptFunctions[] = {
|
|||||||
{ "VoiceChat_IsRecordingLoopbackSound", &Script_VoiceChat_IsRecordingLoopbackSound },
|
{ "VoiceChat_IsRecordingLoopbackSound", &Script_VoiceChat_IsRecordingLoopbackSound },
|
||||||
{ "VoiceChat_IsPlayingLoopbackSound", &Script_VoiceChat_IsPlayingLoopbackSound },
|
{ "VoiceChat_IsPlayingLoopbackSound", &Script_VoiceChat_IsPlayingLoopbackSound },
|
||||||
{ "VoiceChat_GetCurrentMicrophoneSignalLevel", &Script_VoiceChat_GetCurrentMicrophoneSignalLevel },
|
{ "VoiceChat_GetCurrentMicrophoneSignalLevel", &Script_VoiceChat_GetCurrentMicrophoneSignalLevel },
|
||||||
{ "VoiceChat_ActivatePrimaryCaptureCallback", &Script_VoiceChat_ActivatePrimaryCaptureCallback },
|
{ "VoiceChat_ActivatePrimaryCaptureCallback", &Script_VoiceChat_ActivatePrimaryCaptureCallback }
|
||||||
{ nullptr, nullptr }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
size_t SI2::s_NumScriptFunctions = sizeof(SI2::s_ScriptFunctions) / sizeof(FrameScript_Method);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user