mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 11:12:29 +00:00
feat(sound): Small script related improvements
* chore(build): rename src/util/Log.* to SysMessage.* * chore(ui): implement SetNonSpaceWrap() for error messages * chore(ui): move Video Script methods into CGVideoOptions class * chore(script): temporary fix GetNumOutputDrivers to eliminate loading errors * feat(sound): add SI2 Log methods * chore(sound): add SI2 CVars * chore(ui): implement Script_PlayGlueMusic * chore(sound): update SI2::Init() * fix: resolve compilation errors in variadic macros SI2_ERR and SI2_LOG --------- Co-authored-by: Tristan Cormier <cormiert2@outlook.com>
This commit is contained in:
parent
8596860120
commit
32cfe08d0b
21 changed files with 366 additions and 73 deletions
71
src/sound/SI2Log.cpp
Normal file
71
src/sound/SI2Log.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#include "sound/SI2.hpp"
|
||||
#include <storm/Error.hpp>
|
||||
#include <bc/os/File.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
uint32_t SI2::sm_logFlags = SLOG_FLAG_DEFAULT;
|
||||
HSLOG SI2::sm_log = nullptr;
|
||||
|
||||
int32_t SI2::Log_Init() {
|
||||
OsCreateDirectory("Logs", 0);
|
||||
SLogCreate("Logs\\Sound.log", sm_logFlags, &sm_log);
|
||||
sm_logFlags |= SLOG_FLAG_APPEND;
|
||||
// return OsDeleteFile((Blizzard::File*)"Logs\\SESound.log");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SI2::Log_Write(const char* format, ...) {
|
||||
STORM_ASSERT(format);
|
||||
|
||||
char output[512] = { 0 };
|
||||
if (format[0]) {
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
vsnprintf(output, sizeof(output), format, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
Log_Write(__LINE__, __FILE__, FMOD_OK, output);
|
||||
}
|
||||
|
||||
void SI2::Log_Write(uint32_t line, const char* filename, FMOD_RESULT errcode, const char* format, ...) {
|
||||
static uint32_t s_nNumErrors = 0;
|
||||
|
||||
if (s_nNumErrors > 200) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_nNumErrors == 200) {
|
||||
SLogWrite(sm_log, " -######## TOO MANY ERRORS. NO FURTHER ERRORS WILL BE LOGGED.");
|
||||
SLogFlush(sm_log);
|
||||
s_nNumErrors++;
|
||||
return;
|
||||
}
|
||||
|
||||
STORM_ASSERT(format);
|
||||
|
||||
char output[512] = { 0 };
|
||||
if (format[0]) {
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
vsnprintf(output, sizeof(output), format, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
if (errcode == FMOD_OK) {
|
||||
SLogWrite(sm_log, output);
|
||||
SLogFlush(sm_log);
|
||||
}
|
||||
|
||||
if (errcode == FMOD_ERR_HTTP_PROXY_AUTH) {
|
||||
return;
|
||||
}
|
||||
|
||||
SLogWrite(sm_log, " -######## FMOD ERROR! (err %d) %s", errcode, FMOD_ErrorString(errcode));
|
||||
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