mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 19:22:30 +00:00
chore(build): make Thunderbrew zig-buildable
This commit is contained in:
parent
c6e2947506
commit
20f392cd74
10 changed files with 934 additions and 33 deletions
|
|
@ -3,6 +3,8 @@
|
|||
#include "console/CVar.hpp"
|
||||
#include <storm/Memory.hpp>
|
||||
|
||||
#if defined(WHOA_BUILD_SOUND_FMOD)
|
||||
|
||||
FMOD::System* SI2::sm_pGameSystem = nullptr;
|
||||
FMOD::System* SI2::sm_pChatSystem = nullptr;
|
||||
|
||||
|
|
@ -18,6 +20,8 @@ void F_CALL FMOD_Free(void* ptr, FMOD_MEMORY_TYPE type, const char* sourcestr) {
|
|||
SMemFree(ptr, sourcestr, 0, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void SI2::RegisterScriptFunctions() {
|
||||
for (int32_t i = 0; i < s_NumScriptFunctions; i++) {
|
||||
auto item = &s_ScriptFunctions[i];
|
||||
|
|
@ -32,6 +36,7 @@ int32_t SI2::Init(int32_t flag) {
|
|||
SI2_LOG("=> Setting up Game Sound:");
|
||||
SI2_LOG(" - SESound Engine Init");
|
||||
|
||||
#if defined(WHOA_BUILD_SOUND_FMOD)
|
||||
SI2_LOG(" - FMOD Memory Init");
|
||||
FMOD::Memory_Initialize(nullptr, 0, &FMOD_Alloc, &FMOD_ReAlloc, &FMOD_Free);
|
||||
// sub_877440(&off_B1D5E4);
|
||||
|
|
@ -59,7 +64,7 @@ int32_t SI2::Init(int32_t flag) {
|
|||
}
|
||||
|
||||
sm_pGameSystem->setOutput(FMOD_OUTPUTTYPE_AUTODETECT);
|
||||
|
||||
#endif
|
||||
LABEL_9:
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,16 @@
|
|||
#include <storm/Log.hpp>
|
||||
#include <cstdint>
|
||||
#include <cstdarg>
|
||||
|
||||
#if defined(WHOA_BUILD_SOUND_FMOD)
|
||||
|
||||
#include <fmod.hpp>
|
||||
#include <fmod_errors.h>
|
||||
|
||||
#endif
|
||||
|
||||
#define SI2_ERR(errcode, format, ...) SI2::Log_Write(__LINE__, __FILE__, errcode, format, ##__VA_ARGS__)
|
||||
#define SI2_LOG(format, ...) SI2::Log_Write(__LINE__, __FILE__, FMOD_OK, format, ##__VA_ARGS__)
|
||||
#define SI2_LOG(format, ...) SI2::Log_Write(__LINE__, __FILE__, 0, format, ##__VA_ARGS__)
|
||||
|
||||
class SI2 {
|
||||
public:
|
||||
|
|
@ -19,14 +23,15 @@ class SI2 {
|
|||
static size_t s_NumScriptFunctions;
|
||||
static uint32_t sm_logFlags;
|
||||
static HSLOG sm_log;
|
||||
#if defined(WHOA_BUILD_SOUND_FMOD)
|
||||
static FMOD::System* sm_pGameSystem;
|
||||
static FMOD::System* sm_pChatSystem;
|
||||
|
||||
#endif
|
||||
// Static functions
|
||||
static void RegisterScriptFunctions();
|
||||
static int32_t Log_Init();
|
||||
static void Log_Write(const char* format, ...);
|
||||
static void Log_Write(uint32_t line, const char* filename, FMOD_RESULT errcode, const char* format, ...);
|
||||
static void Log_Write(uint32_t line, const char* filename, int32_t errcode, const char* format, ...);
|
||||
static void RegisterCVars();
|
||||
static int32_t Init(int32_t flag);
|
||||
static void StartGlueMusic(const char* filename);
|
||||
|
|
|
|||
|
|
@ -25,10 +25,11 @@ void SI2::Log_Write(const char* format, ...) {
|
|||
va_end(va);
|
||||
}
|
||||
|
||||
Log_Write(__LINE__, __FILE__, FMOD_OK, output);
|
||||
// Log_Write(__LINE__, __FILE__, FMOD_OK, output);
|
||||
Log_Write(__LINE__, __FILE__, 0, output);
|
||||
}
|
||||
|
||||
void SI2::Log_Write(uint32_t line, const char* filename, FMOD_RESULT errcode, const char* format, ...) {
|
||||
void SI2::Log_Write(uint32_t line, const char* filename, int32_t errcode, const char* format, ...) {
|
||||
static uint32_t s_nNumErrors = 0;
|
||||
|
||||
if (s_nNumErrors > 200) {
|
||||
|
|
@ -52,6 +53,7 @@ void SI2::Log_Write(uint32_t line, const char* filename, FMOD_RESULT errcode, co
|
|||
va_end(va);
|
||||
}
|
||||
|
||||
#if defined(WHOA_BUILD_SOUND_FMOD)
|
||||
if (errcode == FMOD_OK) {
|
||||
SLogWrite(sm_log, output);
|
||||
SLogFlush(sm_log);
|
||||
|
|
@ -62,10 +64,13 @@ void SI2::Log_Write(uint32_t line, const char* filename, FMOD_RESULT errcode, co
|
|||
}
|
||||
|
||||
SLogWrite(sm_log, " -######## FMOD ERROR! (err %d) %s", errcode, FMOD_ErrorString(errcode));
|
||||
#endif
|
||||
|
||||
if (format[0]) {
|
||||
SLogWrite(sm_log, output);
|
||||
}
|
||||
SLogWrite(sm_log, "%s(%d)", filename, line);
|
||||
SLogFlush(sm_log);
|
||||
s_nNumErrors++;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue