mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 17:04:55 +00:00
Massive fmtlib refactor
This commit is contained in:
@@ -62,7 +62,7 @@ extern "C" size_t HECL_STARTUP_SZ;
|
||||
static void InstallBlendershell(const SystemChar* path) {
|
||||
FILE* fp = hecl::Fopen(path, _SYS_STR("w"));
|
||||
if (!fp)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("unable to open %s for writing"), path);
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("unable to open {} for writing")), path);
|
||||
fwrite(HECL_BLENDERSHELL, 1, HECL_BLENDERSHELL_SZ, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ static void InstallBlendershell(const SystemChar* path) {
|
||||
static void InstallAddon(const SystemChar* path) {
|
||||
FILE* fp = hecl::Fopen(path, _SYS_STR("wb"));
|
||||
if (!fp)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("Unable to install blender addon at '%s'"), path);
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("Unable to install blender addon at '{}'")), path);
|
||||
fwrite(HECL_ADDON, 1, HECL_ADDON_SZ, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
@@ -109,20 +109,20 @@ uint32_t Connection::_readStr(char* buf, uint32_t bufSz) {
|
||||
uint32_t readLen;
|
||||
int ret = Read(m_readpipe[0], &readLen, 4);
|
||||
if (ret < 4) {
|
||||
BlenderLog.report(logvisor::Error, "Pipe error %d %s", ret, strerror(errno));
|
||||
BlenderLog.report(logvisor::Error, fmt("Pipe error {} {}"), ret, strerror(errno));
|
||||
_blenderDied();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (readLen >= bufSz) {
|
||||
BlenderLog.report(logvisor::Fatal, "Pipe buffer overrun [%d/%d]", readLen, bufSz);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("Pipe buffer overrun [{}/{}]"), readLen, bufSz);
|
||||
*buf = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = Read(m_readpipe[0], buf, readLen);
|
||||
if (ret < 0) {
|
||||
BlenderLog.report(logvisor::Fatal, strerror(errno));
|
||||
BlenderLog.report(logvisor::Fatal, fmt("{}"), strerror(errno));
|
||||
return 0;
|
||||
} else if (readLen >= 9) {
|
||||
if (!memcmp(buf, "EXCEPTION", std::min(readLen, uint32_t(9)))) {
|
||||
@@ -209,10 +209,10 @@ void Connection::_blenderDied() {
|
||||
std::unique_ptr<char[]> buf(new char[len + 1]);
|
||||
memset(buf.get(), 0, len + 1);
|
||||
fread(buf.get(), 1, len, errFp);
|
||||
BlenderLog.report(logvisor::Fatal, "\n%.*s", int(len), buf.get());
|
||||
BlenderLog.report(logvisor::Fatal, fmt("\n{:.{}s}"), buf.get(), len);
|
||||
}
|
||||
}
|
||||
BlenderLog.report(logvisor::Fatal, "Blender Exception");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("Blender Exception"));
|
||||
}
|
||||
|
||||
static std::atomic_bool BlenderFirstInit(false);
|
||||
@@ -229,7 +229,7 @@ static bool RegFileExists(const hecl::SystemChar* path) {
|
||||
Connection::Connection(int verbosityLevel) {
|
||||
#if !WINDOWS_STORE
|
||||
if (hecl::VerbosityLevel >= 1)
|
||||
BlenderLog.report(logvisor::Info, "Establishing BlenderConnection...");
|
||||
BlenderLog.report(logvisor::Info, fmt("Establishing BlenderConnection..."));
|
||||
|
||||
/* Put hecl_blendershell.py in temp dir */
|
||||
const SystemChar* TMPDIR = GetTmpDir();
|
||||
@@ -263,20 +263,20 @@ Connection::Connection(int verbosityLevel) {
|
||||
SECURITY_ATTRIBUTES sattrs = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
|
||||
HANDLE consoleOutReadTmp, consoleOutWrite, consoleErrWrite, consoleOutRead;
|
||||
if (!CreatePipe(&consoleOutReadTmp, &consoleOutWrite, &sattrs, 1024))
|
||||
BlenderLog.report(logvisor::Fatal, "Error with CreatePipe");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("Error with CreatePipe"));
|
||||
|
||||
if (!DuplicateHandle(GetCurrentProcess(), consoleOutWrite, GetCurrentProcess(), &consoleErrWrite, 0, TRUE,
|
||||
DUPLICATE_SAME_ACCESS))
|
||||
BlenderLog.report(logvisor::Fatal, "Error with DuplicateHandle");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("Error with DuplicateHandle"));
|
||||
|
||||
if (!DuplicateHandle(GetCurrentProcess(), consoleOutReadTmp, GetCurrentProcess(),
|
||||
&consoleOutRead, // Address of new handle.
|
||||
0, FALSE, // Make it uninheritable.
|
||||
DUPLICATE_SAME_ACCESS))
|
||||
BlenderLog.report(logvisor::Fatal, "Error with DupliateHandle");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("Error with DupliateHandle"));
|
||||
|
||||
if (!CloseHandle(consoleOutReadTmp))
|
||||
BlenderLog.report(logvisor::Fatal, "Error with CloseHandle");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("Error with CloseHandle"));
|
||||
#else
|
||||
pipe(m_readpipe);
|
||||
pipe(m_writepipe);
|
||||
@@ -359,13 +359,13 @@ Connection::Connection(int verbosityLevel) {
|
||||
if (err == ERROR_BROKEN_PIPE)
|
||||
break; // pipe done - normal exit path.
|
||||
else
|
||||
BlenderLog.report(logvisor::Error, "Error with ReadFile: %08X", err); // Something bad happened.
|
||||
BlenderLog.report(logvisor::Error, fmt("Error with ReadFile: %08X"), err); // Something bad happened.
|
||||
}
|
||||
|
||||
// Display the character read on the screen.
|
||||
auto lk = logvisor::LockLog();
|
||||
if (!WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), lpBuffer, nBytesRead, &nCharsWritten, NULL)) {
|
||||
// BlenderLog.report(logvisor::Error, "Error with WriteConsole: %08X", GetLastError());
|
||||
// BlenderLog.report(logvisor::Error, fmt("Error with WriteConsole: %08X"), GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,21 +390,18 @@ Connection::Connection(int verbosityLevel) {
|
||||
close(devNull);
|
||||
}
|
||||
|
||||
char errbuf[256];
|
||||
char readfds[32];
|
||||
snprintf(readfds, 32, "%d", m_writepipe[0]);
|
||||
char writefds[32];
|
||||
snprintf(writefds, 32, "%d", m_readpipe[1]);
|
||||
char vLevel[32];
|
||||
snprintf(vLevel, 32, "%d", verbosityLevel);
|
||||
std::string errbuf;
|
||||
std::string readfds = fmt::format(fmt("{}"), m_writepipe[0]);
|
||||
std::string writefds = fmt::format(fmt("{}"), m_readpipe[1]);
|
||||
std::string vLevel = fmt::format(fmt("{}"), verbosityLevel);
|
||||
|
||||
/* Try user-specified blender first */
|
||||
if (blenderBin) {
|
||||
execlp(blenderBin, blenderBin, "--background", "-P", blenderShellPath.c_str(), "--", readfds, writefds, vLevel,
|
||||
blenderAddonPath.c_str(), NULL);
|
||||
execlp(blenderBin, blenderBin, "--background", "-P", blenderShellPath.c_str(), "--",
|
||||
readfds.c_str(), writefds.c_str(), vLevel.c_str(), blenderAddonPath.c_str(), NULL);
|
||||
if (errno != ENOENT) {
|
||||
snprintf(errbuf, 256, "NOLAUNCH %s", strerror(errno));
|
||||
_writeStr(errbuf, strlen(errbuf), m_readpipe[1]);
|
||||
errbuf = fmt::format(fmt("NOLAUNCH {}"), strerror(errno));
|
||||
_writeStr(errbuf.c_str(), errbuf.size(), m_readpipe[1]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -418,21 +415,21 @@ Connection::Connection(int verbosityLevel) {
|
||||
steamBlender += "/blender";
|
||||
#endif
|
||||
blenderBin = steamBlender.c_str();
|
||||
execlp(blenderBin, blenderBin, "--background", "-P", blenderShellPath.c_str(), "--", readfds, writefds, vLevel,
|
||||
blenderAddonPath.c_str(), NULL);
|
||||
execlp(blenderBin, blenderBin, "--background", "-P", blenderShellPath.c_str(), "--",
|
||||
readfds.c_str(), writefds.c_str(), vLevel.c_str(), blenderAddonPath.c_str(), NULL);
|
||||
if (errno != ENOENT) {
|
||||
snprintf(errbuf, 256, "NOLAUNCH %s", strerror(errno));
|
||||
_writeStr(errbuf, strlen(errbuf), m_readpipe[1]);
|
||||
errbuf = fmt::format(fmt("NOLAUNCH {}"), strerror(errno));
|
||||
_writeStr(errbuf.c_str(), errbuf.size(), m_readpipe[1]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise default blender */
|
||||
execlp(DEFAULT_BLENDER_BIN, DEFAULT_BLENDER_BIN, "--background", "-P", blenderShellPath.c_str(), "--", readfds,
|
||||
writefds, vLevel, blenderAddonPath.c_str(), NULL);
|
||||
execlp(DEFAULT_BLENDER_BIN, DEFAULT_BLENDER_BIN, "--background", "-P", blenderShellPath.c_str(), "--",
|
||||
readfds.c_str(), writefds.c_str(), vLevel.c_str(), blenderAddonPath.c_str(), NULL);
|
||||
if (errno != ENOENT) {
|
||||
snprintf(errbuf, 256, "NOLAUNCH %s", strerror(errno));
|
||||
_writeStr(errbuf, strlen(errbuf), m_readpipe[1]);
|
||||
errbuf = fmt::format(fmt("NOLAUNCH {}"), strerror(errno));
|
||||
_writeStr(errbuf.c_str(), errbuf.size(), m_readpipe[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -448,10 +445,10 @@ Connection::Connection(int verbosityLevel) {
|
||||
/* Stash error path and unlink existing file */
|
||||
#if _WIN32
|
||||
m_errPath = hecl::SystemString(TMPDIR) +
|
||||
hecl::SysFormat(_SYS_STR("/hecl_%016llX.derp"), (unsigned long long)m_pinfo.dwProcessId);
|
||||
fmt::format(fmt(_SYS_STR("/hecl_{:016X}.derp")), (unsigned long long)m_pinfo.dwProcessId);
|
||||
#else
|
||||
m_errPath =
|
||||
hecl::SystemString(TMPDIR) + hecl::SysFormat(_SYS_STR("/hecl_%016llX.derp"), (unsigned long long)m_blenderProc);
|
||||
hecl::SystemString(TMPDIR) + fmt::format(fmt(_SYS_STR("/hecl_{:016X}.derp")), (unsigned long long)m_blenderProc);
|
||||
#endif
|
||||
hecl::Unlink(m_errPath.c_str());
|
||||
|
||||
@@ -461,24 +458,24 @@ Connection::Connection(int verbosityLevel) {
|
||||
|
||||
if (!strncmp(lineBuf, "NOLAUNCH", 8)) {
|
||||
_closePipe();
|
||||
BlenderLog.report(logvisor::Fatal, "Unable to launch blender: %s", lineBuf + 9);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("Unable to launch blender: {}"), lineBuf + 9);
|
||||
} else if (!strncmp(lineBuf, "NOBLENDER", 9)) {
|
||||
_closePipe();
|
||||
if (blenderBin)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("Unable to find blender at '%s' or '%s'"), blenderBin,
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("Unable to find blender at '{}' or '{}'")), blenderBin,
|
||||
DEFAULT_BLENDER_BIN);
|
||||
else
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("Unable to find blender at '%s'"), DEFAULT_BLENDER_BIN);
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("Unable to find blender at '{}'")), DEFAULT_BLENDER_BIN);
|
||||
} else if (!strcmp(lineBuf, "NOT280")) {
|
||||
_closePipe();
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("Installed blender version must be >= 2.80"));
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("Installed blender version must be >= 2.80")));
|
||||
} else if (!strcmp(lineBuf, "NOADDON")) {
|
||||
_closePipe();
|
||||
if (blenderAddonPath != _SYS_STR("SKIPINSTALL"))
|
||||
InstallAddon(blenderAddonPath.c_str());
|
||||
++installAttempt;
|
||||
if (installAttempt >= 2)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("unable to install blender addon using '%s'"),
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("unable to install blender addon using '{}'")),
|
||||
blenderAddonPath.c_str());
|
||||
continue;
|
||||
} else if (!strcmp(lineBuf, "ADDONINSTALLED")) {
|
||||
@@ -487,14 +484,14 @@ Connection::Connection(int verbosityLevel) {
|
||||
continue;
|
||||
} else if (strcmp(lineBuf, "READY")) {
|
||||
_closePipe();
|
||||
BlenderLog.report(logvisor::Fatal, "read '%s' from blender; expected 'READY'", lineBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("read '{}' from blender; expected 'READY'"), lineBuf);
|
||||
}
|
||||
_writeStr("ACK");
|
||||
|
||||
break;
|
||||
}
|
||||
#else
|
||||
BlenderLog.report(logvisor::Fatal, "BlenderConnection not available on UWP");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("BlenderConnection not available on UWP"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -510,13 +507,13 @@ void Boolean::read(Connection& conn) { conn._readBuf(&val, 1); }
|
||||
|
||||
std::streambuf::int_type PyOutStream::StreamBuf::overflow(int_type ch) {
|
||||
if (!m_parent.m_parent || !m_parent.m_parent->m_lock)
|
||||
BlenderLog.report(logvisor::Fatal, "lock not held for PyOutStream writing");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("lock not held for PyOutStream writing"));
|
||||
if (ch != traits_type::eof() && ch != '\n' && ch != '\0') {
|
||||
m_lineBuf += char_type(ch);
|
||||
return ch;
|
||||
}
|
||||
// printf("FLUSHING %s\n", m_lineBuf.c_str());
|
||||
m_parent.m_parent->_writeStr(m_lineBuf.c_str());
|
||||
m_parent.m_parent->_writeStr(m_lineBuf);
|
||||
char readBuf[16];
|
||||
m_parent.m_parent->_readStr(readBuf, 16);
|
||||
if (strcmp(readBuf, "OK")) {
|
||||
@@ -533,10 +530,10 @@ static const char* BlendTypeStrs[] = {"NONE", "MESH", "CMESH", "ACTOR"
|
||||
|
||||
bool Connection::createBlend(const ProjectPath& path, BlendType type) {
|
||||
if (m_lock) {
|
||||
BlenderLog.report(logvisor::Fatal, "BlenderConnection::createBlend() musn't be called with stream active");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("BlenderConnection::createBlend() musn't be called with stream active"));
|
||||
return false;
|
||||
}
|
||||
_writeStr(("CREATE \""s + path.getAbsolutePathUTF8().data() + "\" " + BlendTypeStrs[int(type)]).c_str());
|
||||
_writeStr(fmt::format(fmt("CREATE \"{}\" {}"), path.getAbsolutePathUTF8(), BlendTypeStrs[int(type)]));
|
||||
char lineBuf[256];
|
||||
_readStr(lineBuf, sizeof(lineBuf));
|
||||
if (!strcmp(lineBuf, "FINISHED")) {
|
||||
@@ -551,12 +548,12 @@ bool Connection::createBlend(const ProjectPath& path, BlendType type) {
|
||||
|
||||
bool Connection::openBlend(const ProjectPath& path, bool force) {
|
||||
if (m_lock) {
|
||||
BlenderLog.report(logvisor::Fatal, "BlenderConnection::openBlend() musn't be called with stream active");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("BlenderConnection::openBlend() musn't be called with stream active"));
|
||||
return false;
|
||||
}
|
||||
if (!force && path == m_loadedBlend)
|
||||
return true;
|
||||
_writeStr(("OPEN \""s + path.getAbsolutePathUTF8().data() + "\"").c_str());
|
||||
_writeStr(fmt::format(fmt("OPEN \"{}\""), path.getAbsolutePathUTF8()));
|
||||
char lineBuf[256];
|
||||
_readStr(lineBuf, sizeof(lineBuf));
|
||||
if (!strcmp(lineBuf, "FINISHED")) {
|
||||
@@ -586,7 +583,7 @@ bool Connection::openBlend(const ProjectPath& path, bool force) {
|
||||
|
||||
bool Connection::saveBlend() {
|
||||
if (m_lock) {
|
||||
BlenderLog.report(logvisor::Fatal, "BlenderConnection::saveBlend() musn't be called with stream active");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("BlenderConnection::saveBlend() musn't be called with stream active"));
|
||||
return false;
|
||||
}
|
||||
_writeStr("SAVE");
|
||||
@@ -600,7 +597,7 @@ bool Connection::saveBlend() {
|
||||
void Connection::deleteBlend() {
|
||||
if (m_loadedBlend) {
|
||||
hecl::Unlink(m_loadedBlend.getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Info, _SYS_STR("Deleted '%s'"), m_loadedBlend.getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Info, fmt(_SYS_STR("Deleted '{}'")), m_loadedBlend.getAbsolutePath());
|
||||
m_loadedBlend = ProjectPath();
|
||||
}
|
||||
}
|
||||
@@ -612,7 +609,7 @@ PyOutStream::PyOutStream(Connection* parent, bool deleteOnError)
|
||||
char readBuf[16];
|
||||
m_parent->_readStr(readBuf, 16);
|
||||
if (strcmp(readBuf, "READY"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to open PyOutStream with blender");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to open PyOutStream with blender"));
|
||||
}
|
||||
|
||||
void PyOutStream::close() {
|
||||
@@ -621,85 +618,62 @@ void PyOutStream::close() {
|
||||
char readBuf[16];
|
||||
m_parent->_readStr(readBuf, 16);
|
||||
if (strcmp(readBuf, "DONE"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to close PyOutStream with blender");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to close PyOutStream with blender"));
|
||||
m_parent->m_pyStreamActive = false;
|
||||
m_parent->m_lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if __GNUC__
|
||||
__attribute__((__format__ (__printf__, 2, 3)))
|
||||
#endif
|
||||
void PyOutStream::format(const char* fmt, ...)
|
||||
{
|
||||
if (!m_parent || !m_parent->m_lock)
|
||||
BlenderLog.report(logvisor::Fatal, "lock not held for PyOutStream::format()");
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
char* result = nullptr;
|
||||
#ifdef _WIN32
|
||||
int length = _vscprintf(fmt, ap);
|
||||
result = (char*)malloc(length);
|
||||
vsnprintf(result, length, fmt, ap);
|
||||
#else
|
||||
int length = vasprintf(&result, fmt, ap);
|
||||
#endif
|
||||
va_end(ap);
|
||||
if (length > 0)
|
||||
this->write(result, length);
|
||||
free(result);
|
||||
}
|
||||
|
||||
void PyOutStream::linkBlend(const char* target, const char* objName, bool link) {
|
||||
format(
|
||||
"if '%s' not in bpy.data.scenes:\n"
|
||||
" with bpy.data.libraries.load('''%s''', link=%s, relative=True) as (data_from, data_to):\n"
|
||||
format(fmt(
|
||||
"if '{}' not in bpy.data.scenes:\n"
|
||||
" with bpy.data.libraries.load('''{}''', link={}, relative=True) as (data_from, data_to):\n"
|
||||
" data_to.scenes = data_from.scenes\n"
|
||||
" obj_scene = None\n"
|
||||
" for scene in data_to.scenes:\n"
|
||||
" if scene.name == '%s':\n"
|
||||
" if scene.name == '{}':\n"
|
||||
" obj_scene = scene\n"
|
||||
" break\n"
|
||||
" if not obj_scene:\n"
|
||||
" raise RuntimeError('''unable to find %s in %s. try deleting it and restart the extract.''')\n"
|
||||
" raise RuntimeError('''unable to find {} in {}. try deleting it and restart the extract.''')\n"
|
||||
" obj = None\n"
|
||||
" for object in obj_scene.objects:\n"
|
||||
" if object.name == obj_scene.name:\n"
|
||||
" obj = object\n"
|
||||
"else:\n"
|
||||
" obj = bpy.data.objects['%s']\n"
|
||||
"\n",
|
||||
" obj = bpy.data.objects['{}']\n"
|
||||
"\n"),
|
||||
objName, target, link ? "True" : "False", objName, objName, target, objName);
|
||||
}
|
||||
|
||||
void PyOutStream::linkBackground(const char* target, const char* sceneName) {
|
||||
if (!sceneName) {
|
||||
format(
|
||||
"with bpy.data.libraries.load('''%s''', link=True, relative=True) as (data_from, data_to):\n"
|
||||
format(fmt(
|
||||
"with bpy.data.libraries.load('''{}''', link=True, relative=True) as (data_from, data_to):\n"
|
||||
" data_to.scenes = data_from.scenes\n"
|
||||
"obj_scene = None\n"
|
||||
"for scene in data_to.scenes:\n"
|
||||
" obj_scene = scene\n"
|
||||
" break\n"
|
||||
"if not obj_scene:\n"
|
||||
" raise RuntimeError('''unable to find %s. try deleting it and restart the extract.''')\n"
|
||||
" raise RuntimeError('''unable to find {}. try deleting it and restart the extract.''')\n"
|
||||
"\n"
|
||||
"bpy.context.scene.background_set = obj_scene\n",
|
||||
"bpy.context.scene.background_set = obj_scene\n"),
|
||||
target, target);
|
||||
} else {
|
||||
format(
|
||||
"if '%s' not in bpy.data.scenes:\n"
|
||||
" with bpy.data.libraries.load('''%s''', link=True, relative=True) as (data_from, data_to):\n"
|
||||
format(fmt(
|
||||
"if '{}' not in bpy.data.scenes:\n"
|
||||
" with bpy.data.libraries.load('''{}''', link=True, relative=True) as (data_from, data_to):\n"
|
||||
" data_to.scenes = data_from.scenes\n"
|
||||
" obj_scene = None\n"
|
||||
" for scene in data_to.scenes:\n"
|
||||
" if scene.name == '%s':\n"
|
||||
" if scene.name == '{}':\n"
|
||||
" obj_scene = scene\n"
|
||||
" break\n"
|
||||
" if not obj_scene:\n"
|
||||
" raise RuntimeError('''unable to find %s in %s. try deleting it and restart the extract.''')\n"
|
||||
" raise RuntimeError('''unable to find {} in {}. try deleting it and restart the extract.''')\n"
|
||||
"\n"
|
||||
"bpy.context.scene.background_set = bpy.data.scenes['%s']\n",
|
||||
"bpy.context.scene.background_set = bpy.data.scenes['{}']\n"),
|
||||
sceneName, target, sceneName, sceneName, target, sceneName);
|
||||
}
|
||||
}
|
||||
@@ -707,16 +681,16 @@ void PyOutStream::linkBackground(const char* target, const char* sceneName) {
|
||||
void PyOutStream::AABBToBMesh(const atVec3f& min, const atVec3f& max) {
|
||||
athena::simd_floats minf(min.simd);
|
||||
athena::simd_floats maxf(max.simd);
|
||||
format(
|
||||
format(fmt(
|
||||
"bm = bmesh.new()\n"
|
||||
"bm.verts.new((%f,%f,%f))\n"
|
||||
"bm.verts.new((%f,%f,%f))\n"
|
||||
"bm.verts.new((%f,%f,%f))\n"
|
||||
"bm.verts.new((%f,%f,%f))\n"
|
||||
"bm.verts.new((%f,%f,%f))\n"
|
||||
"bm.verts.new((%f,%f,%f))\n"
|
||||
"bm.verts.new((%f,%f,%f))\n"
|
||||
"bm.verts.new((%f,%f,%f))\n"
|
||||
"bm.verts.new(({},{},{}))\n"
|
||||
"bm.verts.new(({},{},{}))\n"
|
||||
"bm.verts.new(({},{},{}))\n"
|
||||
"bm.verts.new(({},{},{}))\n"
|
||||
"bm.verts.new(({},{},{}))\n"
|
||||
"bm.verts.new(({},{},{}))\n"
|
||||
"bm.verts.new(({},{},{}))\n"
|
||||
"bm.verts.new(({},{},{}))\n"
|
||||
"bm.verts.ensure_lookup_table()\n"
|
||||
"bm.edges.new((bm.verts[0], bm.verts[1]))\n"
|
||||
"bm.edges.new((bm.verts[0], bm.verts[2]))\n"
|
||||
@@ -729,7 +703,7 @@ void PyOutStream::AABBToBMesh(const atVec3f& min, const atVec3f& max) {
|
||||
"bm.edges.new((bm.verts[5], bm.verts[7]))\n"
|
||||
"bm.edges.new((bm.verts[6], bm.verts[2]))\n"
|
||||
"bm.edges.new((bm.verts[6], bm.verts[4]))\n"
|
||||
"bm.edges.new((bm.verts[6], bm.verts[7]))\n",
|
||||
"bm.edges.new((bm.verts[6], bm.verts[7]))\n"),
|
||||
minf[0], minf[1], minf[2], maxf[0], minf[1], minf[2], minf[0], maxf[1], minf[2], maxf[0], maxf[1], minf[2],
|
||||
minf[0], minf[1], maxf[2], maxf[0], minf[1], maxf[2], minf[0], maxf[1], maxf[2], maxf[0], maxf[1], maxf[2]);
|
||||
}
|
||||
@@ -763,7 +737,7 @@ ANIMOutStream::ANIMOutStream(Connection* parent) : m_parent(parent) {
|
||||
char readBuf[16];
|
||||
m_parent->_readStr(readBuf, 16);
|
||||
if (strcmp(readBuf, "ANIMREADY"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to open ANIMOutStream");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to open ANIMOutStream"));
|
||||
}
|
||||
|
||||
ANIMOutStream::~ANIMOutStream() {
|
||||
@@ -772,12 +746,12 @@ ANIMOutStream::~ANIMOutStream() {
|
||||
char readBuf[16];
|
||||
m_parent->_readStr(readBuf, 16);
|
||||
if (strcmp(readBuf, "ANIMDONE"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to close ANIMOutStream");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to close ANIMOutStream"));
|
||||
}
|
||||
|
||||
void ANIMOutStream::changeCurve(CurveType type, unsigned crvIdx, unsigned keyCount) {
|
||||
if (m_curCount != m_totalCount)
|
||||
BlenderLog.report(logvisor::Fatal, "incomplete ANIMOutStream for change");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("incomplete ANIMOutStream for change"));
|
||||
m_curCount = 0;
|
||||
m_totalCount = keyCount;
|
||||
char tp = char(type);
|
||||
@@ -792,7 +766,7 @@ void ANIMOutStream::changeCurve(CurveType type, unsigned crvIdx, unsigned keyCou
|
||||
|
||||
void ANIMOutStream::write(unsigned frame, float val) {
|
||||
if (!m_inCurve)
|
||||
BlenderLog.report(logvisor::Fatal, "changeCurve not called before write");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("changeCurve not called before write"));
|
||||
if (m_curCount < m_totalCount) {
|
||||
struct {
|
||||
uint32_t frm;
|
||||
@@ -801,7 +775,7 @@ void ANIMOutStream::write(unsigned frame, float val) {
|
||||
m_parent->_writeBuf(reinterpret_cast<const char*>(&key), 8);
|
||||
++m_curCount;
|
||||
} else
|
||||
BlenderLog.report(logvisor::Fatal, "ANIMOutStream keyCount overflow");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("ANIMOutStream keyCount overflow"));
|
||||
}
|
||||
|
||||
Mesh::SkinBind::SkinBind(Connection& conn) {
|
||||
@@ -1495,7 +1469,7 @@ DataStream::DataStream(Connection* parent) : m_parent(parent) {
|
||||
char readBuf[16];
|
||||
m_parent->_readStr(readBuf, 16);
|
||||
if (strcmp(readBuf, "READY"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to open DataStream with blender");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to open DataStream with blender"));
|
||||
}
|
||||
|
||||
void DataStream::close() {
|
||||
@@ -1504,7 +1478,7 @@ void DataStream::close() {
|
||||
char readBuf[16];
|
||||
m_parent->_readStr(readBuf, 16);
|
||||
if (strcmp(readBuf, "DONE"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to close DataStream with blender");
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to close DataStream with blender"));
|
||||
m_parent->m_dataStreamActive = false;
|
||||
m_parent->m_lock = false;
|
||||
}
|
||||
@@ -1540,14 +1514,14 @@ std::vector<std::string> DataStream::getLightList() {
|
||||
|
||||
std::pair<atVec3f, atVec3f> DataStream::getMeshAABB() {
|
||||
if (m_parent->m_loadedType != BlendType::Mesh && m_parent->m_loadedType != BlendType::Actor)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a MESH or ACTOR blend"),
|
||||
m_parent->m_loadedBlend.getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not a MESH or ACTOR blend")),
|
||||
m_parent->m_loadedBlend.getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("MESHAABB");
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable get AABB: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable get AABB: {}"), readBuf);
|
||||
|
||||
Vector3f minPt(*m_parent);
|
||||
Vector3f maxPt(*m_parent);
|
||||
@@ -1561,66 +1535,60 @@ const char* DataStream::MeshOutputModeString(HMDLTopology topology) {
|
||||
|
||||
Mesh DataStream::compileMesh(HMDLTopology topology, int skinSlotCount) {
|
||||
if (m_parent->getBlendType() != BlendType::Mesh)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a MESH blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not a MESH blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("MESHCOMPILE");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to cook mesh: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to cook mesh: {}"), readBuf);
|
||||
|
||||
return Mesh(*m_parent, topology, skinSlotCount);
|
||||
}
|
||||
|
||||
Mesh DataStream::compileMesh(std::string_view name, HMDLTopology topology, int skinSlotCount, bool useLuv) {
|
||||
if (m_parent->getBlendType() != BlendType::Area)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an AREA blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an AREA blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
char req[128];
|
||||
snprintf(req, 128, "MESHCOMPILENAME %s %d", name.data(), int(useLuv));
|
||||
m_parent->_writeStr(req);
|
||||
m_parent->_writeStr(fmt::format(fmt("MESHCOMPILENAME {} {}"), name, int(useLuv)));
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to cook mesh '%s': %s", name.data(), readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to cook mesh '{}': {}"), name, readBuf);
|
||||
|
||||
return Mesh(*m_parent, topology, skinSlotCount, useLuv);
|
||||
}
|
||||
|
||||
ColMesh DataStream::compileColMesh(std::string_view name) {
|
||||
if (m_parent->getBlendType() != BlendType::Area)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an AREA blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an AREA blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
char req[128];
|
||||
snprintf(req, 128, "MESHCOMPILENAMECOLLISION %s", name.data());
|
||||
m_parent->_writeStr(req);
|
||||
m_parent->_writeStr(fmt::format(fmt("MESHCOMPILENAMECOLLISION {}"), name));
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to cook collision mesh '%s': %s", name.data(), readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to cook collision mesh '{}': {}"), name, readBuf);
|
||||
|
||||
return ColMesh(*m_parent);
|
||||
}
|
||||
|
||||
std::vector<ColMesh> DataStream::compileColMeshes() {
|
||||
if (m_parent->getBlendType() != BlendType::ColMesh)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a CMESH blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not a CMESH blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
char req[128];
|
||||
snprintf(req, 128, "MESHCOMPILECOLLISIONALL");
|
||||
m_parent->_writeStr(req);
|
||||
m_parent->_writeStr("MESHCOMPILECOLLISIONALL");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to cook collision meshes: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to cook collision meshes: {}"), readBuf);
|
||||
|
||||
uint32_t meshCount;
|
||||
m_parent->_readBuf(&meshCount, 4);
|
||||
@@ -1636,15 +1604,15 @@ std::vector<ColMesh> DataStream::compileColMeshes() {
|
||||
|
||||
std::vector<Light> DataStream::compileLights() {
|
||||
if (m_parent->getBlendType() != BlendType::Area)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an AREA blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an AREA blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("LIGHTCOMPILEALL");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to gather all lights: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to gather all lights: {}"), readBuf);
|
||||
|
||||
uint32_t lightCount;
|
||||
m_parent->_readBuf(&lightCount, 4);
|
||||
@@ -1660,15 +1628,15 @@ std::vector<Light> DataStream::compileLights() {
|
||||
|
||||
PathMesh DataStream::compilePathMesh() {
|
||||
if (m_parent->getBlendType() != BlendType::PathMesh)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a PATH blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not a PATH blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("MESHCOMPILEPATH");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to path collision mesh: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to path collision mesh: {}"), readBuf);
|
||||
|
||||
return PathMesh(*m_parent);
|
||||
}
|
||||
@@ -1676,17 +1644,15 @@ PathMesh DataStream::compilePathMesh() {
|
||||
std::vector<uint8_t> DataStream::compileGuiFrame(int version) {
|
||||
std::vector<uint8_t> ret;
|
||||
if (m_parent->getBlendType() != BlendType::Frame)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a FRAME blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not a FRAME blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
char req[512];
|
||||
snprintf(req, 512, "FRAMECOMPILE %d", version);
|
||||
m_parent->_writeStr(req);
|
||||
m_parent->_writeStr(fmt::format(fmt("FRAMECOMPILE {}"), version));
|
||||
|
||||
char readBuf[1024];
|
||||
m_parent->_readStr(readBuf, 1024);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to compile frame: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to compile frame: {}"), readBuf);
|
||||
|
||||
while (true) {
|
||||
m_parent->_readStr(readBuf, 1024);
|
||||
@@ -1703,8 +1669,7 @@ std::vector<uint8_t> DataStream::compileGuiFrame(int version) {
|
||||
relative = proj.getProjectRootPath().getProjectRelativeFromAbsolute(absolute.sys_str());
|
||||
hecl::ProjectPath path(proj.getProjectWorkingPath(), relative);
|
||||
|
||||
snprintf(req, 512, "%016" PRIX64, path.hash().val64());
|
||||
m_parent->_writeStr(req);
|
||||
m_parent->_writeStr(fmt::format(fmt("{:016X}"), path.hash().val64()));
|
||||
}
|
||||
|
||||
uint32_t len;
|
||||
@@ -1720,7 +1685,7 @@ std::vector<ProjectPath> DataStream::getTextures() {
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to get textures: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to get textures: {}"), readBuf);
|
||||
|
||||
uint32_t texCount;
|
||||
m_parent->_readBuf(&texCount, 4);
|
||||
@@ -1743,77 +1708,75 @@ std::vector<ProjectPath> DataStream::getTextures() {
|
||||
|
||||
Actor DataStream::compileActor() {
|
||||
if (m_parent->getBlendType() != BlendType::Actor)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an ACTOR blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("ACTORCOMPILE");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to compile actor: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to compile actor: {}"), readBuf);
|
||||
|
||||
return Actor(*m_parent);
|
||||
}
|
||||
|
||||
Actor DataStream::compileActorCharacterOnly() {
|
||||
if (m_parent->getBlendType() != BlendType::Actor)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an ACTOR blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("ACTORCOMPILECHARACTERONLY");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to compile actor: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to compile actor: {}"), readBuf);
|
||||
|
||||
return Actor(*m_parent);
|
||||
}
|
||||
|
||||
Action DataStream::compileActionChannelsOnly(std::string_view name) {
|
||||
if (m_parent->getBlendType() != BlendType::Actor)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an ACTOR blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
char req[128];
|
||||
snprintf(req, 128, "ACTIONCOMPILECHANNELSONLY %s", name.data());
|
||||
m_parent->_writeStr(req);
|
||||
m_parent->_writeStr(fmt::format(fmt("ACTIONCOMPILECHANNELSONLY {}"), name));
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to compile action: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to compile action: {}"), readBuf);
|
||||
|
||||
return Action(*m_parent);
|
||||
}
|
||||
|
||||
World DataStream::compileWorld() {
|
||||
if (m_parent->getBlendType() != BlendType::World)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an WORLD blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an WORLD blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("WORLDCOMPILE");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to compile world: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to compile world: {}"), readBuf);
|
||||
|
||||
return World(*m_parent);
|
||||
}
|
||||
|
||||
std::vector<std::string> DataStream::getArmatureNames() {
|
||||
if (m_parent->getBlendType() != BlendType::Actor)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an ACTOR blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("GETARMATURENAMES");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to get armatures of actor: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to get armatures of actor: {}"), readBuf);
|
||||
|
||||
std::vector<std::string> ret;
|
||||
|
||||
@@ -1834,15 +1797,15 @@ std::vector<std::string> DataStream::getArmatureNames() {
|
||||
|
||||
std::vector<std::string> DataStream::getSubtypeNames() {
|
||||
if (m_parent->getBlendType() != BlendType::Actor)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an ACTOR blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("GETSUBTYPENAMES");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to get subtypes of actor: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to get subtypes of actor: {}"), readBuf);
|
||||
|
||||
std::vector<std::string> ret;
|
||||
|
||||
@@ -1863,15 +1826,15 @@ std::vector<std::string> DataStream::getSubtypeNames() {
|
||||
|
||||
std::vector<std::string> DataStream::getActionNames() {
|
||||
if (m_parent->getBlendType() != BlendType::Actor)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an ACTOR blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("GETACTIONNAMES");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to get actions of actor: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to get actions of actor: {}"), readBuf);
|
||||
|
||||
std::vector<std::string> ret;
|
||||
|
||||
@@ -1892,17 +1855,15 @@ std::vector<std::string> DataStream::getActionNames() {
|
||||
|
||||
std::vector<std::string> DataStream::getSubtypeOverlayNames(std::string_view name) {
|
||||
if (m_parent->getBlendType() != BlendType::Actor)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an ACTOR blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
char req[128];
|
||||
snprintf(req, 128, "GETSUBTYPEOVERLAYNAMES %s", name.data());
|
||||
m_parent->_writeStr(req);
|
||||
m_parent->_writeStr(fmt::format(fmt("GETSUBTYPEOVERLAYNAMES {}"), name));
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to get subtype overlays of actor: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to get subtype overlays of actor: {}"), readBuf);
|
||||
|
||||
std::vector<std::string> ret;
|
||||
|
||||
@@ -1923,15 +1884,15 @@ std::vector<std::string> DataStream::getSubtypeOverlayNames(std::string_view nam
|
||||
|
||||
std::vector<std::string> DataStream::getAttachmentNames() {
|
||||
if (m_parent->getBlendType() != BlendType::Actor)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an ACTOR blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("GETATTACHMENTNAMES");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to get attachments of actor: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to get attachments of actor: {}"), readBuf);
|
||||
|
||||
std::vector<std::string> ret;
|
||||
|
||||
@@ -1955,17 +1916,15 @@ std::unordered_map<std::string, Matrix3f> DataStream::getBoneMatrices(std::strin
|
||||
return {};
|
||||
|
||||
if (m_parent->getBlendType() != BlendType::Actor)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an ACTOR blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an ACTOR blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
char req[128];
|
||||
snprintf(req, 128, "GETBONEMATRICES %s", name.data());
|
||||
m_parent->_writeStr(req);
|
||||
m_parent->_writeStr(fmt::format(fmt("GETBONEMATRICES {}"), name));
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to get matrices of armature: %s", readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to get matrices of armature: {}"), readBuf);
|
||||
|
||||
std::unordered_map<std::string, Matrix3f> ret;
|
||||
|
||||
@@ -2000,19 +1959,17 @@ bool DataStream::renderPvs(std::string_view path, const atVec3f& location) {
|
||||
return false;
|
||||
|
||||
if (m_parent->getBlendType() != BlendType::Area)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an AREA blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an AREA blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
char req[256];
|
||||
athena::simd_floats f(location.simd);
|
||||
snprintf(req, 256, "RENDERPVS %s %f %f %f", path.data(), f[0], f[1], f[2]);
|
||||
m_parent->_writeStr(req);
|
||||
m_parent->_writeStr(fmt::format(fmt("RENDERPVS {} {} {} {}"), path, f[0], f[1], f[2]));
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to render PVS for: %s; %s",
|
||||
m_parent->getBlendPath().getAbsolutePathUTF8().data(), readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to render PVS for: {}; {}"),
|
||||
m_parent->getBlendPath().getAbsolutePathUTF8(), readBuf);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2022,50 +1979,48 @@ bool DataStream::renderPvsLight(std::string_view path, std::string_view lightNam
|
||||
return false;
|
||||
|
||||
if (m_parent->getBlendType() != BlendType::Area)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not an AREA blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not an AREA blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
char req[256];
|
||||
snprintf(req, 256, "RENDERPVSLIGHT %s %s", path.data(), lightName.data());
|
||||
m_parent->_writeStr(req);
|
||||
m_parent->_writeStr(fmt::format(fmt("RENDERPVSLIGHT {} {}"), path, lightName));
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to render PVS light %s for: %s; %s", lightName.data(),
|
||||
m_parent->getBlendPath().getAbsolutePathUTF8().data(), readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to render PVS light {} for: {}; {}"), lightName,
|
||||
m_parent->getBlendPath().getAbsolutePathUTF8(), readBuf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MapArea DataStream::compileMapArea() {
|
||||
if (m_parent->getBlendType() != BlendType::MapArea)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a MAPAREA blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not a MAPAREA blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("MAPAREACOMPILE");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to compile map area: %s; %s",
|
||||
m_parent->getBlendPath().getAbsolutePathUTF8().data(), readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to compile map area: {}; {}"),
|
||||
m_parent->getBlendPath().getAbsolutePathUTF8(), readBuf);
|
||||
|
||||
return {*m_parent};
|
||||
}
|
||||
|
||||
MapUniverse DataStream::compileMapUniverse() {
|
||||
if (m_parent->getBlendType() != BlendType::MapUniverse)
|
||||
BlenderLog.report(logvisor::Fatal, _SYS_STR("%s is not a MAPUNIVERSE blend"),
|
||||
m_parent->getBlendPath().getAbsolutePath().data());
|
||||
BlenderLog.report(logvisor::Fatal, fmt(_SYS_STR("{} is not a MAPUNIVERSE blend")),
|
||||
m_parent->getBlendPath().getAbsolutePath());
|
||||
|
||||
m_parent->_writeStr("MAPUNIVERSECOMPILE");
|
||||
|
||||
char readBuf[256];
|
||||
m_parent->_readStr(readBuf, 256);
|
||||
if (strcmp(readBuf, "OK"))
|
||||
BlenderLog.report(logvisor::Fatal, "unable to compile map universe: %s; %s",
|
||||
m_parent->getBlendPath().getAbsolutePathUTF8().data(), readBuf);
|
||||
BlenderLog.report(logvisor::Fatal, fmt("unable to compile map universe: {}; {}"),
|
||||
m_parent->getBlendPath().getAbsolutePathUTF8(), readBuf);
|
||||
|
||||
return {*m_parent};
|
||||
}
|
||||
@@ -2103,7 +2058,7 @@ void Token::shutdown() {
|
||||
m_conn->quitBlender();
|
||||
m_conn.reset();
|
||||
if (hecl::VerbosityLevel >= 1)
|
||||
BlenderLog.report(logvisor::Info, "Blender Shutdown Successful");
|
||||
BlenderLog.report(logvisor::Info, fmt("Blender Shutdown Successful"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ MeshOptimizer::Vertex::Vertex(Connection& conn) {
|
||||
co.read(conn);
|
||||
Index skin_count(conn);
|
||||
if (skin_count.val > MaxSkinEntries)
|
||||
Log.report(logvisor::Fatal, "Skin entry overflow %u/%u", skin_count.val, MaxSkinEntries);
|
||||
Log.report(logvisor::Fatal, fmt("Skin entry overflow {}/{}"), skin_count.val, MaxSkinEntries);
|
||||
for (uint32_t i = 0; i < skin_count.val; ++i)
|
||||
skin_ents[i] = Mesh::SkinBind(conn);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ MeshOptimizer::Edge::Edge(Connection& conn) {
|
||||
verts[i] = Index(conn).val;
|
||||
Index face_count(conn);
|
||||
if (face_count > MaxLinkFaces)
|
||||
Log.report(logvisor::Fatal, "Face overflow %u/%u", face_count.val, MaxLinkFaces);
|
||||
Log.report(logvisor::Fatal, fmt("Face overflow {}/{}"), face_count.val, MaxLinkFaces);
|
||||
for (uint32_t i = 0; i < face_count.val; ++i)
|
||||
link_faces[i] = Index(conn).val;
|
||||
is_contiguous = Boolean(conn).val;
|
||||
@@ -377,10 +377,10 @@ MeshOptimizer::MeshOptimizer(Connection& conn, const std::vector<Material>& mate
|
||||
: materials(materials), use_luvs(use_luvs) {
|
||||
color_count = Index(conn).val;
|
||||
if (color_count > MaxColorLayers)
|
||||
Log.report(logvisor::Fatal, "Color layer overflow %u/%u", color_count, MaxColorLayers);
|
||||
Log.report(logvisor::Fatal, fmt("Color layer overflow {}/{}"), color_count, MaxColorLayers);
|
||||
uv_count = Index(conn).val;
|
||||
if (uv_count > MaxUVLayers)
|
||||
Log.report(logvisor::Fatal, "UV layer overflow %u/%u", uv_count, MaxUVLayers);
|
||||
Log.report(logvisor::Fatal, fmt("UV layer overflow {}/{}"), uv_count, MaxUVLayers);
|
||||
|
||||
/* Simultaneously load topology objects and build unique mapping indices */
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ bool CVar::fromVec4f(const atVec4f& val) {
|
||||
return false;
|
||||
|
||||
athena::simd_floats f(val.simd);
|
||||
m_value.assign(hecl::Format("%f %f %f %f", f[0], f[1], f[2], f[3]));
|
||||
m_value.assign(fmt::format(fmt("{} {} {} {}"), f[0], f[1], f[2], f[3]));
|
||||
m_flags |= EFlags::Modified;
|
||||
return true;
|
||||
}
|
||||
@@ -243,7 +243,7 @@ bool CVar::fromFloat(float val) {
|
||||
if (isReadOnly() && (com_developer && !com_developer->toBoolean()))
|
||||
return false;
|
||||
|
||||
m_value.assign(hecl::Format("%f", val));
|
||||
m_value.assign(fmt::format(fmt("{}"), val));
|
||||
setModified();
|
||||
return true;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ bool CVar::fromInteger(int val) {
|
||||
if (isReadOnly() && (com_developer && !com_developer->toBoolean()))
|
||||
return false;
|
||||
|
||||
m_value = hecl::Format("%i", val);
|
||||
m_value = fmt::format(fmt("{}"), val);
|
||||
setModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -196,20 +196,20 @@ CVarManager* CVarManager::instance() { return m_instance; }
|
||||
void CVarManager::list(Console* con, const std::vector<std::string>& /*args*/) {
|
||||
for (const auto& cvar : m_cvars) {
|
||||
if (!cvar.second->isHidden())
|
||||
con->report(Console::Level::Info, "%s: %s", cvar.second->name().data(), cvar.second->help().c_str());
|
||||
con->report(Console::Level::Info, fmt("{}: {}"), cvar.second->name(), cvar.second->help());
|
||||
}
|
||||
}
|
||||
|
||||
void CVarManager::setCVar(Console* con, const std::vector<std::string>& args) {
|
||||
if (args.size() < 2) {
|
||||
con->report(Console::Level::Info, "Usage setCvar <cvar> <value>");
|
||||
con->report(Console::Level::Info, fmt("Usage setCvar <cvar> <value>"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string cvName = args[0];
|
||||
athena::utility::tolower(cvName);
|
||||
if (m_cvars.find(cvName) == m_cvars.end()) {
|
||||
con->report(Console::Level::Error, "CVar '%s' does not exist", args[0].c_str());
|
||||
con->report(Console::Level::Error, fmt("CVar '%s' does not exist"), args[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -225,26 +225,26 @@ void CVarManager::setCVar(Console* con, const std::vector<std::string>& args) {
|
||||
return;
|
||||
|
||||
if (!cv->fromLiteralToType(value))
|
||||
con->report(Console::Level::Warning, "Unable to set cvar '%s' to value '%s'", cv->name().data(), value.c_str());
|
||||
con->report(Console::Level::Warning, fmt("Unable to set cvar '%s' to value '%s'"), cv->name().data(), value.c_str());
|
||||
else
|
||||
con->report(Console::Level::Info, "Set '%s' from '%s' to '%s'", cv->name().data(), oldVal.c_str(), value.c_str());
|
||||
con->report(Console::Level::Info, fmt("Set '%s' from '%s' to '%s'"), cv->name().data(), oldVal.c_str(), value.c_str());
|
||||
}
|
||||
|
||||
void CVarManager::getCVar(Console* con, const std::vector<std::string>& args) {
|
||||
if (args.empty()) {
|
||||
con->report(Console::Level::Info, "Usage getCVar <cvar>");
|
||||
con->report(Console::Level::Info, fmt("Usage getCVar <cvar>"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string cvName = args[0];
|
||||
athena::utility::tolower(cvName);
|
||||
if (m_cvars.find(cvName) == m_cvars.end()) {
|
||||
con->report(Console::Level::Error, "CVar '%s' does not exist", args[0].c_str());
|
||||
con->report(Console::Level::Error, fmt("CVar '%s' does not exist"), args[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& cv = m_cvars[cvName];
|
||||
con->report(Console::Level::Info, "'%s' = '%s'", cv->name().data(), cv->value().c_str());
|
||||
con->report(Console::Level::Info, fmt("'%s' = '%s'"), cv->name().data(), cv->value().c_str());
|
||||
}
|
||||
|
||||
void CVarManager::setDeveloperMode(bool v, bool setDeserialized) {
|
||||
|
||||
@@ -59,7 +59,7 @@ static int GetCPUCount() {
|
||||
void ClientProcess::BufferTransaction::run(blender::Token& btok) {
|
||||
athena::io::FileReader r(m_path.getAbsolutePath(), 32 * 1024, false);
|
||||
if (r.hasError()) {
|
||||
CP_Log.report(logvisor::Fatal, _SYS_STR("unable to background-buffer '%s'"), m_path.getAbsolutePath().data());
|
||||
CP_Log.report(logvisor::Fatal, fmt(_SYS_STR("unable to background-buffer '{}'")), m_path.getAbsolutePath());
|
||||
return;
|
||||
}
|
||||
if (m_offset)
|
||||
@@ -89,9 +89,7 @@ ClientProcess::Worker::Worker(ClientProcess& proc, int idx) : m_proc(proc), m_id
|
||||
void ClientProcess::Worker::proc() {
|
||||
ClientProcess::ThreadWorker.reset(this);
|
||||
|
||||
char thrName[64];
|
||||
snprintf(thrName, 64, "HECL Worker %d", m_idx);
|
||||
logvisor::RegisterThreadName(thrName);
|
||||
logvisor::RegisterThreadName(fmt::format(fmt("HECL Worker {}"), m_idx).c_str());
|
||||
|
||||
std::unique_lock<std::mutex> lk(m_proc.m_mutex);
|
||||
while (m_proc.m_running) {
|
||||
@@ -176,25 +174,24 @@ bool ClientProcess::syncCook(const hecl::ProjectPath& path, Database::IDataSpec*
|
||||
if (m_progPrinter) {
|
||||
hecl::SystemString str;
|
||||
if (path.getAuxInfo().empty())
|
||||
str = hecl::SysFormat(_SYS_STR("Cooking %s"), path.getRelativePath().data());
|
||||
str = fmt::format(fmt(_SYS_STR("Cooking {}")), path.getRelativePath());
|
||||
else
|
||||
str = hecl::SysFormat(_SYS_STR("Cooking %s|%s"), path.getRelativePath().data(), path.getAuxInfo().data());
|
||||
str = fmt::format(fmt(_SYS_STR("Cooking {}|{}")), path.getRelativePath(), path.getAuxInfo());
|
||||
m_progPrinter->print(str.c_str(), nullptr, -1.f, hecl::ClientProcess::GetThreadWorkerIdx());
|
||||
m_progPrinter->flush();
|
||||
} else {
|
||||
if (path.getAuxInfo().empty())
|
||||
LogModule.report(logvisor::Info, _SYS_STR("Cooking %s"), path.getRelativePath().data());
|
||||
LogModule.report(logvisor::Info, fmt(_SYS_STR("Cooking {}")), path.getRelativePath());
|
||||
else
|
||||
LogModule.report(logvisor::Info, _SYS_STR("Cooking %s|%s"), path.getRelativePath().data(),
|
||||
path.getAuxInfo().data());
|
||||
LogModule.report(logvisor::Info, fmt(_SYS_STR("Cooking {}|{}")), path.getRelativePath(), path.getAuxInfo());
|
||||
}
|
||||
spec->doCook(path, cooked, false, btok, [](const SystemChar*) {});
|
||||
if (m_progPrinter) {
|
||||
hecl::SystemString str;
|
||||
if (path.getAuxInfo().empty())
|
||||
str = hecl::SysFormat(_SYS_STR("Cooked %s"), path.getRelativePath().data());
|
||||
str = fmt::format(fmt(_SYS_STR("Cooked {}")), path.getRelativePath());
|
||||
else
|
||||
str = hecl::SysFormat(_SYS_STR("Cooked %s|%s"), path.getRelativePath().data(), path.getAuxInfo().data());
|
||||
str = fmt::format(fmt(_SYS_STR("Cooked {}|{}")), path.getRelativePath(), path.getAuxInfo());
|
||||
m_progPrinter->print(str.c_str(), nullptr, -1.f, hecl::ClientProcess::GetThreadWorkerIdx());
|
||||
m_progPrinter->flush();
|
||||
}
|
||||
|
||||
@@ -64,15 +64,15 @@ struct ShaderCompiler<PlatformType::Vulkan> {
|
||||
const char* strings[] = {"#version 330\n", BOO_GLSL_BINDING_HEAD, text.data()};
|
||||
shader.setStrings(strings, 3);
|
||||
if (!shader.parse(&glslang::DefaultTBuiltInResource, 110, false, messages)) {
|
||||
printf("%s\n", text.data());
|
||||
Log.report(logvisor::Fatal, "unable to compile shader\n%s", shader.getInfoLog());
|
||||
fmt::print(fmt("{}\n"), text);
|
||||
Log.report(logvisor::Fatal, fmt("unable to compile shader\n{}"), shader.getInfoLog());
|
||||
return {};
|
||||
}
|
||||
|
||||
glslang::TProgram prog;
|
||||
prog.addShader(&shader);
|
||||
if (!prog.link(messages)) {
|
||||
Log.report(logvisor::Fatal, "unable to link shader program\n%s", prog.getInfoLog());
|
||||
Log.report(logvisor::Fatal, fmt("unable to link shader program\n{}"), prog.getInfoLog());
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ struct ShaderCompiler<PlatformType::D3D11> {
|
||||
if (FAILED(D3DCompilePROC(text.data(), text.size(), "Boo HLSL Source", nullptr, nullptr, "main",
|
||||
D3DShaderTypes[int(S::Enum)], BOO_D3DCOMPILE_FLAG, 0, &blobOut, &errBlob))) {
|
||||
printf("%s\n", text.data());
|
||||
Log.report(logvisor::Fatal, "error compiling shader: %s", errBlob->GetBufferPointer());
|
||||
Log.report(logvisor::Fatal, fmt("error compiling shader: %s"), errBlob->GetBufferPointer());
|
||||
return {};
|
||||
}
|
||||
std::pair<StageBinaryData, size_t> ret(MakeStageBinaryData(blobOut->GetBufferSize()), blobOut->GetBufferSize());
|
||||
@@ -162,8 +162,7 @@ struct ShaderCompiler<PlatformType::Metal> {
|
||||
|
||||
pid_t pid = getpid();
|
||||
const char* tmpdir = getenv("TMPDIR");
|
||||
char libFile[1024];
|
||||
snprintf(libFile, 1024, "%sboo_metal_shader%d.metallib", tmpdir, pid);
|
||||
std::string libFile = fmt::format(fmt("{}boo_metal_shader{}.metallib"), tmpdir, pid);
|
||||
|
||||
/* Pipe source write to compiler */
|
||||
pid_t compilerPid = fork();
|
||||
@@ -197,7 +196,7 @@ struct ShaderCompiler<PlatformType::Metal> {
|
||||
close(compilerIn[1]);
|
||||
|
||||
/* metallib doesn't like outputting to a pipe, so temp file will have to do */
|
||||
execlp("xcrun", "xcrun", "-sdk", "macosx", "metallib", "-", "-o", libFile, NULL);
|
||||
execlp("xcrun", "xcrun", "-sdk", "macosx", "metallib", "-", "-o", libFile.c_str(), NULL);
|
||||
fprintf(stderr, "execlp fail %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
@@ -222,29 +221,29 @@ struct ShaderCompiler<PlatformType::Metal> {
|
||||
while (waitpid(compilerPid, &compilerStat, 0) < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
Log.report(logvisor::Fatal, "waitpid fail %s", strerror(errno));
|
||||
Log.report(logvisor::Fatal, fmt("waitpid fail %s"), strerror(errno));
|
||||
return {};
|
||||
}
|
||||
|
||||
if (WEXITSTATUS(compilerStat)) {
|
||||
Log.report(logvisor::Fatal, "compile fail");
|
||||
Log.report(logvisor::Fatal, fmt("compile fail"));
|
||||
return {};
|
||||
}
|
||||
|
||||
while (waitpid(linkerPid, &linkerStat, 0) < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
Log.report(logvisor::Fatal, "waitpid fail %s", strerror(errno));
|
||||
Log.report(logvisor::Fatal, fmt("waitpid fail %s"), strerror(errno));
|
||||
return {};
|
||||
}
|
||||
|
||||
if (WEXITSTATUS(linkerStat)) {
|
||||
Log.report(logvisor::Fatal, "link fail");
|
||||
Log.report(logvisor::Fatal, fmt("link fail"));
|
||||
return {};
|
||||
}
|
||||
|
||||
/* Copy temp file into buffer with first byte set to indicate binary data */
|
||||
FILE* fin = fopen(libFile, "rb");
|
||||
FILE* fin = fopen(libFile.c_str(), "rb");
|
||||
fseek(fin, 0, SEEK_END);
|
||||
long libLen = ftell(fin);
|
||||
fseek(fin, 0, SEEK_SET);
|
||||
|
||||
@@ -90,7 +90,7 @@ void Console::executeString(const std::string& str) {
|
||||
|
||||
if (isInLiteral) {
|
||||
if ((curLiteral.back() != '\'' && curLiteral.back() != '"') || depth > 1) {
|
||||
report(Level::Warning, "Unterminated string literal");
|
||||
report(Level::Warning, fmt("Unterminated string literal"));
|
||||
return;
|
||||
}
|
||||
args.push_back(curLiteral);
|
||||
@@ -104,12 +104,12 @@ void Console::executeString(const std::string& str) {
|
||||
if (m_commands.find(lowComName) != m_commands.end()) {
|
||||
const SConsoleCommand& cmd = m_commands[lowComName];
|
||||
if (bool(cmd.m_flags & SConsoleCommand::ECommandFlags::Developer) && !com_developer->toBoolean()) {
|
||||
report(Level::Error, "This command can only be executed in developer mode", commandName.c_str());
|
||||
report(Level::Error, fmt("This command can only be executed in developer mode"), commandName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bool(cmd.m_flags & SConsoleCommand::ECommandFlags::Cheat) && !com_enableCheats->toBoolean()) {
|
||||
report(Level::Error, "This command can only be executed with cheats enabled", commandName.c_str());
|
||||
report(Level::Error, fmt("This command can only be executed with cheats enabled"), commandName);
|
||||
return;
|
||||
}
|
||||
m_commands[lowComName].m_func(this, args);
|
||||
@@ -120,31 +120,31 @@ void Console::executeString(const std::string& str) {
|
||||
else
|
||||
m_cvarMgr->getCVar(this, args);
|
||||
} else
|
||||
report(Level::Error, "Command '%s' is not valid!", commandName.c_str());
|
||||
report(Level::Error, fmt("Command '{}' is not valid!"), commandName);
|
||||
}
|
||||
}
|
||||
|
||||
void Console::help(Console* /*con*/, const std::vector<std::string>& args) {
|
||||
if (args.empty()) {
|
||||
report(Level::Info, "Expected usage: help <command>");
|
||||
report(Level::Info, fmt("Expected usage: help <command>"));
|
||||
return;
|
||||
}
|
||||
std::string cmd = args.front();
|
||||
athena::utility::tolower(cmd);
|
||||
auto it = m_commands.find(cmd);
|
||||
if (it == m_commands.end()) {
|
||||
report(Level::Error, "No such command '%s'", args.front().c_str());
|
||||
report(Level::Error, fmt("No such command '{}'"), args.front());
|
||||
return;
|
||||
}
|
||||
|
||||
report(Level::Info, "%s: %s", it->second.m_displayName.c_str(), it->second.m_helpString.c_str());
|
||||
report(Level::Info, fmt("{}: {}"), it->second.m_displayName, it->second.m_helpString);
|
||||
if (!it->second.m_usage.empty())
|
||||
report(Level::Info, "Usage: %s %s", it->second.m_displayName.c_str(), it->second.m_usage.c_str());
|
||||
report(Level::Info, fmt("Usage: {} {}"), it->second.m_displayName, it->second.m_usage);
|
||||
}
|
||||
|
||||
void Console::listCommands(Console* /*con*/, const std::vector<std::string>& /*args*/) {
|
||||
for (const auto& comPair : m_commands)
|
||||
report(Level::Info, "'%s': %s", comPair.second.m_displayName.c_str(), comPair.second.m_helpString.c_str());
|
||||
report(Level::Info, fmt("'{}': {}"), comPair.second.m_displayName, comPair.second.m_helpString);
|
||||
}
|
||||
|
||||
bool Console::commandExists(std::string_view cmd) {
|
||||
@@ -154,23 +154,14 @@ bool Console::commandExists(std::string_view cmd) {
|
||||
return m_commands.find(cmdName) != m_commands.end();
|
||||
}
|
||||
|
||||
void Console::report(Level level, const char* fmt, va_list list) {
|
||||
char tmp[2048];
|
||||
vsnprintf(tmp, 2048, fmt, list);
|
||||
void Console::vreport(Level level, fmt::string_view fmt, fmt::format_args args) {
|
||||
std::string tmp = fmt::vformat(fmt, args);
|
||||
std::vector<std::string> lines = athena::utility::split(tmp, '\n');
|
||||
for (const std::string& line : lines) {
|
||||
std::string v = athena::utility::sprintf("%s", line.c_str());
|
||||
m_log.emplace_back(v, level);
|
||||
}
|
||||
printf("%s\n", tmp);
|
||||
for (const std::string& line : lines)
|
||||
m_log.emplace_back(line, level);
|
||||
fmt::print(fmt("{}\n"), tmp);
|
||||
}
|
||||
|
||||
void Console::report(Level level, const char* fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
report(level, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
void Console::init(boo::IWindow* window) {
|
||||
m_window = window;
|
||||
}
|
||||
@@ -187,7 +178,7 @@ void Console::proc() {
|
||||
}
|
||||
|
||||
if (m_state == State::Opened) {
|
||||
printf("\r%s ", m_commandString.c_str());
|
||||
fmt::print(fmt("\r{} "), m_commandString);
|
||||
fflush(stdout);
|
||||
} else if (m_state == State::Opening)
|
||||
m_state = State::Opened;
|
||||
@@ -290,7 +281,7 @@ void Console::handleSpecialKeyDown(boo::ESpecialKey sp, boo::EModifierKey mod, b
|
||||
break;
|
||||
}
|
||||
case boo::ESpecialKey::Enter: {
|
||||
printf("\n");
|
||||
fmt::print(fmt("\n"));
|
||||
executeString(m_commandString);
|
||||
m_cursorPosition = -1;
|
||||
m_commandHistory.insert(m_commandHistory.begin(), m_commandString);
|
||||
@@ -372,42 +363,39 @@ void Console::handleSpecialKeyDown(boo::ESpecialKey sp, boo::EModifierKey mod, b
|
||||
|
||||
void Console::handleSpecialKeyUp(boo::ESpecialKey /*sp*/, boo::EModifierKey /*mod*/) {}
|
||||
|
||||
void Console::LogVisorAdapter::report(const char* modName, logvisor::Level severity, const char* format, va_list ap) {
|
||||
char tmp[2048];
|
||||
vsnprintf(tmp, 2048, format, ap);
|
||||
void Console::LogVisorAdapter::report(const char* modName, logvisor::Level severity,
|
||||
fmt::string_view format, fmt::format_args args) {
|
||||
auto tmp = fmt::internal::vformat(format, args);
|
||||
std::vector<std::string> lines = athena::utility::split(tmp, '\n');
|
||||
for (const std::string& line : lines) {
|
||||
std::string v = athena::utility::sprintf("[%s] %s", modName, line.c_str());
|
||||
auto v = fmt::format(fmt("[%s] %s"), modName, line.c_str());
|
||||
m_con->m_log.emplace_back(v, Console::Level(severity));
|
||||
}
|
||||
}
|
||||
|
||||
void Console::LogVisorAdapter::report(const char* modName, logvisor::Level severity, const wchar_t* format,
|
||||
va_list ap) {
|
||||
wchar_t tmp[2048];
|
||||
vswprintf(tmp, 2048, format, ap);
|
||||
void Console::LogVisorAdapter::report(const char* modName, logvisor::Level severity,
|
||||
fmt::wstring_view format, fmt::wformat_args args) {
|
||||
auto tmp = fmt::internal::vformat(format, args);
|
||||
std::vector<std::string> lines = athena::utility::split(athena::utility::wideToUtf8(tmp), '\n');
|
||||
for (const std::string& line : lines) {
|
||||
std::string v = athena::utility::sprintf("[%s] %s", modName, line.c_str());
|
||||
auto v = fmt::format(fmt("[%s] %s"), modName, line.c_str());
|
||||
m_con->m_log.emplace_back(v, Console::Level(severity));
|
||||
}
|
||||
}
|
||||
|
||||
void Console::LogVisorAdapter::reportSource(const char* modName, logvisor::Level severity, const char* file,
|
||||
unsigned linenum, const char* format, va_list ap) {
|
||||
char tmp[2048];
|
||||
vsnprintf(tmp, 2048, format, ap);
|
||||
std::string v = athena::utility::sprintf("[%s] %s %s:%i", modName, tmp, file, linenum);
|
||||
unsigned linenum, fmt::string_view format, fmt::format_args args) {
|
||||
auto tmp = fmt::internal::vformat(format, args);
|
||||
auto v = fmt::format(fmt("[%s] %s %s:%i"), modName, tmp, file, linenum);
|
||||
m_con->m_log.emplace_back(v, Console::Level(severity));
|
||||
}
|
||||
|
||||
void Console::LogVisorAdapter::reportSource(const char* modName, logvisor::Level severity, const char* file,
|
||||
unsigned linenum, const wchar_t* format, va_list ap) {
|
||||
wchar_t tmp[2048];
|
||||
vswprintf(tmp, 2048, format, ap);
|
||||
unsigned linenum, fmt::wstring_view format, fmt::wformat_args args) {
|
||||
auto tmp = fmt::internal::vformat(format, args);
|
||||
std::vector<std::string> lines = athena::utility::split(athena::utility::wideToUtf8(tmp), '\n');
|
||||
for (const std::string& line : lines) {
|
||||
std::string v = athena::utility::sprintf("[%s] %s %s:%i", modName, line.c_str(), file, linenum);
|
||||
auto v = fmt::format(fmt("[%s] %s %s:%i"), modName, line.c_str(), file, linenum);
|
||||
m_con->m_log.emplace_back(v, Console::Level(severity));
|
||||
}
|
||||
}
|
||||
@@ -416,16 +404,16 @@ void Console::dumpLog() {
|
||||
for (const auto& l : m_log) {
|
||||
switch (l.second) {
|
||||
case Level::Info:
|
||||
printf("%s\n", l.first.c_str());
|
||||
fmt::print(fmt("{}\n"), l.first);
|
||||
break;
|
||||
case Level::Warning:
|
||||
printf("[Warning] %s\n", l.first.c_str());
|
||||
fmt::print(fmt("[Warning] {}\n"), l.first);
|
||||
break;
|
||||
case Level::Error:
|
||||
printf("[ Error ] %s\n", l.first.c_str());
|
||||
fmt::print(fmt("[ Error ] {}\n"), l.first);
|
||||
break;
|
||||
case Level::Fatal:
|
||||
printf("[ Fatal ] %s\n", l.first.c_str());
|
||||
fmt::print(fmt("[ Fatal ] {}\n"), l.first);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ std::string HumanizeNumber(int64_t quotient, size_t len, const char* suffix, int
|
||||
if (suffix == nullptr)
|
||||
suffix = "";
|
||||
if ((flags & HNFlags::Divisor1000) != HNFlags::None && (flags & HNFlags::IECPrefixes) != HNFlags::None)
|
||||
Log.report(logvisor::Fatal, "invalid flags combo");
|
||||
Log.report(logvisor::Fatal, fmt("invalid flags combo"));
|
||||
|
||||
/* setup parameters */
|
||||
remainder = 0;
|
||||
@@ -109,8 +109,7 @@ std::string HumanizeNumber(int64_t quotient, size_t len, const char* suffix, int
|
||||
|
||||
/* Check if enough room for `x y' + suffix */
|
||||
if (len < baselen)
|
||||
Log.report(logvisor::Fatal, "buffer size %" PRISize "insufficient for minimum size %" PRISize, len, baselen);
|
||||
std::string ret(len, '\0');
|
||||
Log.report(logvisor::Fatal, fmt("buffer size {} insufficient for minimum size {}"), len, baselen);
|
||||
len += 1;
|
||||
|
||||
if ((scale & int(HNScale::AutoScale)) != 0) {
|
||||
@@ -143,12 +142,10 @@ std::string HumanizeNumber(int64_t quotient, size_t len, const char* suffix, int
|
||||
(flags & HNFlags::Decimal) != HNFlags::None) {
|
||||
s1 = (int)quotient + ((remainder * 10 + divisor / 2) / divisor / 10);
|
||||
s2 = ((remainder * 10 + divisor / 2) / divisor) % 10;
|
||||
snprintf(&ret[0], len, "%d%s%d%s%s%s", sign * s1, localeconv()->decimal_point, s2, sep, SCALE2PREFIX(i), suffix);
|
||||
return fmt::format(fmt("{}{}{}{}{}{}"), sign * s1, localeconv()->decimal_point, s2, sep, SCALE2PREFIX(i), suffix);
|
||||
} else
|
||||
snprintf(&ret[0], len, "%" PRId64 "%s%s%s", sign * (quotient + (remainder + divisor / 2) / divisor), sep,
|
||||
SCALE2PREFIX(i), suffix);
|
||||
|
||||
return ret;
|
||||
return fmt::format(fmt("{}{}{}{}"), sign * (quotient + (remainder + divisor / 2) / divisor), sep,
|
||||
SCALE2PREFIX(i), suffix);
|
||||
}
|
||||
|
||||
} // namespace hecl
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#define BOLD "\033[1m"
|
||||
#define NORMAL "\033[0m"
|
||||
#define PREV_LINE "\r\033[%dA"
|
||||
#define PREV_LINE "\r\033[{:d}A"
|
||||
#define HIDE_CURSOR "\033[?25l"
|
||||
#define SHOW_CURSOR "\033[?25h"
|
||||
|
||||
@@ -33,46 +33,46 @@ void MultiProgressPrinter::ThreadStat::print(const TermInfo& tinfo) const {
|
||||
|
||||
if (submessageLen) {
|
||||
if (messageLen > half - submessageLen - 1)
|
||||
hecl::Printf(_SYS_STR(" %.*s... %s "), half - submessageLen - 4, m_message.c_str(), m_submessage.c_str());
|
||||
fmt::print(fmt(_SYS_STR(" {:.{}}... {} ")), m_message, half - submessageLen - 4, m_submessage);
|
||||
else {
|
||||
hecl::Printf(_SYS_STR(" %s"), m_message.c_str());
|
||||
fmt::print(fmt(_SYS_STR(" {}")), m_message);
|
||||
for (int i = half - messageLen - submessageLen - 1; i >= 0; --i)
|
||||
hecl::Printf(_SYS_STR(" "));
|
||||
hecl::Printf(_SYS_STR("%s "), m_submessage.c_str());
|
||||
fmt::print(fmt(_SYS_STR(" ")));
|
||||
fmt::print(fmt(_SYS_STR("{} ")), m_submessage);
|
||||
}
|
||||
} else {
|
||||
if (messageLen > half)
|
||||
hecl::Printf(_SYS_STR(" %.*s... "), half - 3, m_message.c_str());
|
||||
fmt::print(fmt(_SYS_STR(" {:.{}}... ")), m_message, half - 3);
|
||||
else {
|
||||
hecl::Printf(_SYS_STR(" %s"), m_message.c_str());
|
||||
fmt::print(fmt(_SYS_STR(" {}")), m_message);
|
||||
for (int i = half - messageLen; i >= 0; --i)
|
||||
hecl::Printf(_SYS_STR(" "));
|
||||
fmt::print(fmt(_SYS_STR(" ")));
|
||||
}
|
||||
}
|
||||
|
||||
if (blocks) {
|
||||
int rightHalf = tinfo.width - half - 4;
|
||||
int blocks = rightHalf - 7;
|
||||
int filled = blocks * factor;
|
||||
int rem = blocks - filled;
|
||||
int nblocks = rightHalf - 7;
|
||||
int filled = nblocks * factor;
|
||||
int rem = nblocks - filled;
|
||||
|
||||
if (tinfo.xtermColor) {
|
||||
hecl::Printf(_SYS_STR("" BOLD "%3d%% ["), iFactor);
|
||||
fmt::print(fmt(_SYS_STR("" BOLD "{:3d}% [")), iFactor);
|
||||
for (int b = 0; b < filled; ++b)
|
||||
hecl::Printf(_SYS_STR("#"));
|
||||
fmt::print(fmt(_SYS_STR("#")));
|
||||
for (int b = 0; b < rem; ++b)
|
||||
hecl::Printf(_SYS_STR("-"));
|
||||
hecl::Printf(_SYS_STR("]" NORMAL ""));
|
||||
fmt::print(fmt(_SYS_STR("-")));
|
||||
fmt::print(fmt(_SYS_STR("]" NORMAL "")));
|
||||
} else {
|
||||
#if _WIN32
|
||||
SetConsoleTextAttribute(tinfo.console, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
|
||||
#endif
|
||||
hecl::Printf(_SYS_STR("%3d%% ["), iFactor);
|
||||
fmt::print(fmt(_SYS_STR("{:3d}% [")), iFactor);
|
||||
for (int b = 0; b < filled; ++b)
|
||||
hecl::Printf(_SYS_STR("#"));
|
||||
fmt::print(fmt(_SYS_STR("#")));
|
||||
for (int b = 0; b < rem; ++b)
|
||||
hecl::Printf(_SYS_STR("-"));
|
||||
hecl::Printf(_SYS_STR("]"));
|
||||
fmt::print(fmt(_SYS_STR("-")));
|
||||
fmt::print(fmt(_SYS_STR("]")));
|
||||
#if _WIN32
|
||||
SetConsoleTextAttribute(tinfo.console, FOREGROUND_WHITE);
|
||||
#endif
|
||||
@@ -95,24 +95,24 @@ void MultiProgressPrinter::DrawIndeterminateBar() {
|
||||
int rem = blocks - pre - 1;
|
||||
|
||||
if (m_termInfo.xtermColor) {
|
||||
hecl::Printf(_SYS_STR("" BOLD " ["));
|
||||
fmt::print(fmt(_SYS_STR("" BOLD " [")));
|
||||
for (int b = 0; b < pre; ++b)
|
||||
hecl::Printf(_SYS_STR("-"));
|
||||
hecl::Printf(_SYS_STR("#"));
|
||||
fmt::print(fmt(_SYS_STR("-")));
|
||||
fmt::print(fmt(_SYS_STR("#")));
|
||||
for (int b = 0; b < rem; ++b)
|
||||
hecl::Printf(_SYS_STR("-"));
|
||||
hecl::Printf(_SYS_STR("]" NORMAL ""));
|
||||
fmt::print(fmt(_SYS_STR("-")));
|
||||
fmt::print(fmt(_SYS_STR("]" NORMAL "")));
|
||||
} else {
|
||||
#if _WIN32
|
||||
SetConsoleTextAttribute(m_termInfo.console, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
|
||||
#endif
|
||||
hecl::Printf(_SYS_STR(" ["));
|
||||
fmt::print(fmt(_SYS_STR(" [")));
|
||||
for (int b = 0; b < pre; ++b)
|
||||
hecl::Printf(_SYS_STR("-"));
|
||||
hecl::Printf(_SYS_STR("#"));
|
||||
fmt::print(fmt(_SYS_STR("-")));
|
||||
fmt::print(fmt(_SYS_STR("#")));
|
||||
for (int b = 0; b < rem; ++b)
|
||||
hecl::Printf(_SYS_STR("-"));
|
||||
hecl::Printf(_SYS_STR("]"));
|
||||
fmt::print(fmt(_SYS_STR("-")));
|
||||
fmt::print(fmt(_SYS_STR("]")));
|
||||
#if _WIN32
|
||||
SetConsoleTextAttribute(m_termInfo.console, FOREGROUND_WHITE);
|
||||
#endif
|
||||
@@ -122,7 +122,7 @@ void MultiProgressPrinter::DrawIndeterminateBar() {
|
||||
void MultiProgressPrinter::MoveCursorUp(int n) {
|
||||
if (n) {
|
||||
if (m_termInfo.xtermColor) {
|
||||
hecl::Printf(_SYS_STR("" PREV_LINE ""), n);
|
||||
fmt::print(fmt(_SYS_STR("" PREV_LINE "")), n);
|
||||
}
|
||||
#if _WIN32
|
||||
else {
|
||||
@@ -134,7 +134,7 @@ void MultiProgressPrinter::MoveCursorUp(int n) {
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
hecl::Printf(_SYS_STR("\r"));
|
||||
fmt::print(fmt(_SYS_STR("\r")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ void MultiProgressPrinter::DoPrint() {
|
||||
SetConsoleCursorInfo(m_termInfo.console, &cursorInfo);
|
||||
#endif
|
||||
if (m_termInfo.xtermColor)
|
||||
hecl::Printf(_SYS_STR("" HIDE_CURSOR ""));
|
||||
fmt::print(fmt(_SYS_STR("" HIDE_CURSOR "")));
|
||||
|
||||
if (m_dirty) {
|
||||
m_termInfo.width = (hecl::GuiMode ? 120 : std::max(80, hecl::ConsoleWidth(&m_termInfo.truncate)));
|
||||
@@ -163,7 +163,7 @@ void MultiProgressPrinter::DoPrint() {
|
||||
for (const ThreadStat& stat : m_threadStats) {
|
||||
if (stat.m_active) {
|
||||
stat.print(m_termInfo);
|
||||
hecl::Printf(_SYS_STR("\n"));
|
||||
fmt::print(fmt(_SYS_STR("\n")));
|
||||
++m_curThreadLines;
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ void MultiProgressPrinter::DoPrint() {
|
||||
#endif
|
||||
) {
|
||||
DrawIndeterminateBar();
|
||||
hecl::Printf(_SYS_STR("\n"));
|
||||
fmt::print(fmt(_SYS_STR("\n")));
|
||||
++m_curProgLines;
|
||||
} else if (m_mainFactor >= 0.f) {
|
||||
float factor = std::max(0.0f, std::min(1.0f, m_mainFactor));
|
||||
@@ -186,34 +186,34 @@ void MultiProgressPrinter::DoPrint() {
|
||||
int rem = blocks - filled;
|
||||
|
||||
if (m_termInfo.xtermColor) {
|
||||
hecl::Printf(_SYS_STR("" BOLD " %3d%% ["), iFactor);
|
||||
fmt::print(fmt(_SYS_STR("" BOLD " {:3d}% [")), iFactor);
|
||||
for (int b = 0; b < filled; ++b)
|
||||
hecl::Printf(_SYS_STR("#"));
|
||||
fmt::print(fmt(_SYS_STR("#")));
|
||||
for (int b = 0; b < rem; ++b)
|
||||
hecl::Printf(_SYS_STR("-"));
|
||||
hecl::Printf(_SYS_STR("]" NORMAL ""));
|
||||
fmt::print(fmt(_SYS_STR("-")));
|
||||
fmt::print(fmt(_SYS_STR("]" NORMAL "")));
|
||||
} else {
|
||||
#if _WIN32
|
||||
SetConsoleTextAttribute(m_termInfo.console, FOREGROUND_INTENSITY | FOREGROUND_WHITE);
|
||||
#endif
|
||||
hecl::Printf(_SYS_STR(" %3d%% ["), iFactor);
|
||||
fmt::print(fmt(_SYS_STR(" {:3d}% [")), iFactor);
|
||||
for (int b = 0; b < filled; ++b)
|
||||
hecl::Printf(_SYS_STR("#"));
|
||||
fmt::print(fmt(_SYS_STR("#")));
|
||||
for (int b = 0; b < rem; ++b)
|
||||
hecl::Printf(_SYS_STR("-"));
|
||||
hecl::Printf(_SYS_STR("]"));
|
||||
fmt::print(fmt(_SYS_STR("-")));
|
||||
fmt::print(fmt(_SYS_STR("]")));
|
||||
#if _WIN32
|
||||
SetConsoleTextAttribute(m_termInfo.console, FOREGROUND_WHITE);
|
||||
#endif
|
||||
}
|
||||
|
||||
hecl::Printf(_SYS_STR("\n"));
|
||||
fmt::print(fmt(_SYS_STR("\n")));
|
||||
++m_curProgLines;
|
||||
}
|
||||
} else if (m_latestThread != -1) {
|
||||
const ThreadStat& stat = m_threadStats[m_latestThread];
|
||||
stat.print(m_termInfo);
|
||||
hecl::Printf(_SYS_STR("\r"));
|
||||
fmt::print(fmt(_SYS_STR("\r")));
|
||||
}
|
||||
m_dirty = false;
|
||||
} else if (m_mainIndeterminate
|
||||
@@ -225,12 +225,12 @@ void MultiProgressPrinter::DoPrint() {
|
||||
MoveCursorUp(m_curProgLines);
|
||||
m_curProgLines = 0;
|
||||
DrawIndeterminateBar();
|
||||
hecl::Printf(_SYS_STR("\n"));
|
||||
fmt::print(fmt(_SYS_STR("\n")));
|
||||
++m_curProgLines;
|
||||
}
|
||||
|
||||
if (m_termInfo.xtermColor)
|
||||
hecl::Printf(_SYS_STR("" SHOW_CURSOR ""));
|
||||
fmt::print(fmt(_SYS_STR("" SHOW_CURSOR "")));
|
||||
fflush(stdout);
|
||||
|
||||
#if _WIN32
|
||||
@@ -331,7 +331,7 @@ void MultiProgressPrinter::startNewLine() const {
|
||||
m_curThreadLines = 0;
|
||||
m_mainFactor = -1.f;
|
||||
auto logLk = logvisor::LockLog();
|
||||
hecl::Printf(_SYS_STR("\n"));
|
||||
fmt::print(fmt(_SYS_STR("\n")));
|
||||
}
|
||||
|
||||
void MultiProgressPrinter::flush() const {
|
||||
|
||||
@@ -23,7 +23,7 @@ static const hecl::FourCC HECLfcc("HECL");
|
||||
* Project::ConfigFile
|
||||
**********************************************/
|
||||
|
||||
static inline bool CheckNewLineAdvance(std::string::const_iterator& it) {
|
||||
static bool CheckNewLineAdvance(std::string::const_iterator& it) {
|
||||
if (*it == '\n') {
|
||||
it += 1;
|
||||
return true;
|
||||
@@ -84,7 +84,7 @@ void Project::ConfigFile::addLine(std::string_view line) {
|
||||
|
||||
void Project::ConfigFile::removeLine(std::string_view refLine) {
|
||||
if (!m_lockedFile) {
|
||||
LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__, "Project::ConfigFile::lockAndRead not yet called");
|
||||
LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__, fmt("Project::ConfigFile::lockAndRead not yet called"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ void Project::ConfigFile::removeLine(std::string_view refLine) {
|
||||
|
||||
bool Project::ConfigFile::checkForLine(std::string_view refLine) {
|
||||
if (!m_lockedFile) {
|
||||
LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__, "Project::ConfigFile::lockAndRead not yet called");
|
||||
LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__, fmt("Project::ConfigFile::lockAndRead not yet called"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ bool Project::ConfigFile::checkForLine(std::string_view refLine) {
|
||||
|
||||
void Project::ConfigFile::unlockAndDiscard() {
|
||||
if (!m_lockedFile) {
|
||||
LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__, "Project::ConfigFile::lockAndRead not yet called");
|
||||
LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__, fmt("Project::ConfigFile::lockAndRead not yet called"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ void Project::ConfigFile::unlockAndDiscard() {
|
||||
|
||||
bool Project::ConfigFile::unlockAndCommit() {
|
||||
if (!m_lockedFile) {
|
||||
LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__, "Project::ConfigFile::lockAndRead not yet called");
|
||||
LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__, fmt("Project::ConfigFile::lockAndRead not yet called"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -176,13 +176,13 @@ Project::Project(const ProjectRootPath& rootPath)
|
||||
/* Stat for existing project directory (must already exist) */
|
||||
Sstat myStat;
|
||||
if (hecl::Stat(m_rootPath.getAbsolutePath().data(), &myStat)) {
|
||||
LogModule.report(logvisor::Error, _SYS_STR("unable to stat %s"), m_rootPath.getAbsolutePath().data());
|
||||
LogModule.report(logvisor::Error, fmt(_SYS_STR("unable to stat {}")), m_rootPath.getAbsolutePath());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!S_ISDIR(myStat.st_mode)) {
|
||||
LogModule.report(logvisor::Error, _SYS_STR("provided path must be a directory; '%s' isn't"),
|
||||
m_rootPath.getAbsolutePath().data());
|
||||
LogModule.report(logvisor::Error, fmt(_SYS_STR("provided path must be a directory; '{}' isn't")),
|
||||
m_rootPath.getAbsolutePath());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ Project::Project(const ProjectRootPath& rootPath)
|
||||
}
|
||||
fclose(bf);
|
||||
if (beacon.magic != HECLfcc || SBig(beacon.version) != DATA_VERSION) {
|
||||
LogModule.report(logvisor::Fatal, "incompatible project version");
|
||||
LogModule.report(logvisor::Fatal, fmt("incompatible project version"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ const ProjectPath& Project::getProjectCookedPath(const DataSpecEntry& spec) cons
|
||||
for (const ProjectDataSpec& sp : m_compiledSpecs)
|
||||
if (&sp.spec == &spec)
|
||||
return sp.cookedPath;
|
||||
LogModule.report(logvisor::Fatal, "Unable to find spec '%s'", spec.m_name.data());
|
||||
LogModule.report(logvisor::Fatal, fmt("Unable to find spec '{}'"), spec.m_name);
|
||||
return m_cookedRoot;
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ bool Project::packagePath(const ProjectPath& path, const hecl::MultiProgressPrin
|
||||
}
|
||||
|
||||
if (!specEntry)
|
||||
LogModule.report(logvisor::Fatal, "No matching DataSpec");
|
||||
LogModule.report(logvisor::Fatal, fmt("No matching DataSpec"));
|
||||
|
||||
if (!m_lastPackageSpec || m_lastPackageSpec->getDataSpecEntry() != specEntry)
|
||||
m_lastPackageSpec = specEntry->m_factory(*this, DataSpecTool::Package);
|
||||
|
||||
@@ -19,7 +19,7 @@ static SystemString CanonRelPath(SystemStringView path) {
|
||||
else if (!match.compare(_SYS_STR(".."))) {
|
||||
if (comps.empty()) {
|
||||
/* Unable to resolve outside project */
|
||||
LogModule.report(logvisor::Fatal, _SYS_STR("Unable to resolve outside project root in %s"), path.data());
|
||||
LogModule.report(logvisor::Fatal, fmt(_SYS_STR("Unable to resolve outside project root in {}")), path);
|
||||
return _SYS_STR(".");
|
||||
}
|
||||
comps.pop_back();
|
||||
@@ -180,7 +180,7 @@ Time ProjectPath::getModtime() const {
|
||||
return Time(latestTime);
|
||||
}
|
||||
}
|
||||
LogModule.report(logvisor::Fatal, _SYS_STR("invalid path type for computing modtime in '%s'"), m_absPath.c_str());
|
||||
LogModule.report(logvisor::Fatal, fmt(_SYS_STR("invalid path type for computing modtime in '{}'")), m_absPath);
|
||||
return Time();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ FileStoreManager::FileStoreManager(SystemStringView domain) : m_domain(domain) {
|
||||
#if !WINDOWS_STORE
|
||||
WCHAR home[MAX_PATH];
|
||||
if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, home)))
|
||||
Log.report(logvisor::Fatal, _SYS_STR("unable to locate profile for file store"));
|
||||
Log.report(logvisor::Fatal, fmt(_SYS_STR("unable to locate profile for file store")));
|
||||
|
||||
SystemString path(home);
|
||||
#else
|
||||
@@ -34,15 +34,15 @@ FileStoreManager::FileStoreManager(SystemStringView domain) : m_domain(domain) {
|
||||
#else
|
||||
const char* home = getenv("HOME");
|
||||
if (!home)
|
||||
Log.report(logvisor::Fatal, "unable to locate $HOME for file store");
|
||||
Log.report(logvisor::Fatal, fmt("unable to locate $HOME for file store"));
|
||||
std::string path(home);
|
||||
path += "/.heclrun";
|
||||
if (mkdir(path.c_str(), 0755) && errno != EEXIST)
|
||||
Log.report(logvisor::Fatal, "unable to mkdir at %s", path.c_str());
|
||||
Log.report(logvisor::Fatal, fmt("unable to mkdir at {}"), path);
|
||||
path += '/';
|
||||
path += domain.data();
|
||||
if (mkdir(path.c_str(), 0755) && errno != EEXIST)
|
||||
Log.report(logvisor::Fatal, "unable to mkdir at %s", path.c_str());
|
||||
Log.report(logvisor::Fatal, fmt("unable to mkdir at {}"), path);
|
||||
m_storeRoot = path;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ HMDLData::HMDLData(boo::IGraphicsDataFactory::Context& ctx, const void* metaData
|
||||
meta.read(r);
|
||||
}
|
||||
if (meta.magic != 'TACO')
|
||||
HMDL_Log.report(logvisor::Fatal, "invalid HMDL magic");
|
||||
HMDL_Log.report(logvisor::Fatal, fmt("invalid HMDL magic"));
|
||||
|
||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vbo, meta.vertStride, meta.vertCount);
|
||||
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, ibo, 4, meta.indexCount);
|
||||
|
||||
@@ -11,7 +11,7 @@ std::string WideToUTF8(std::wstring_view src) {
|
||||
utf8proc_uint8_t mb[4];
|
||||
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
||||
if (c < 0) {
|
||||
Log.report(logvisor::Warning, "invalid UTF-8 character while encoding");
|
||||
Log.report(logvisor::Warning, fmt("invalid UTF-8 character while encoding"));
|
||||
return retval;
|
||||
}
|
||||
retval.append(reinterpret_cast<char*>(mb), c);
|
||||
@@ -26,7 +26,7 @@ std::string Char16ToUTF8(std::u16string_view src) {
|
||||
utf8proc_uint8_t mb[4];
|
||||
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
||||
if (c < 0) {
|
||||
Log.report(logvisor::Warning, "invalid UTF-8 character while encoding");
|
||||
Log.report(logvisor::Warning, fmt("invalid UTF-8 character while encoding"));
|
||||
return retval;
|
||||
}
|
||||
retval.append(reinterpret_cast<char*>(mb), c);
|
||||
@@ -42,7 +42,7 @@ std::wstring UTF8ToWide(std::string_view src) {
|
||||
utf8proc_int32_t wc;
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
Log.report(logvisor::Warning, "invalid UTF-8 character while decoding");
|
||||
Log.report(logvisor::Warning, fmt("invalid UTF-8 character while decoding"));
|
||||
return retval;
|
||||
}
|
||||
buf += len;
|
||||
@@ -59,7 +59,7 @@ std::u16string UTF8ToChar16(std::string_view src) {
|
||||
utf8proc_int32_t wc;
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
Log.report(logvisor::Warning, "invalid UTF-8 character while decoding");
|
||||
Log.report(logvisor::Warning, fmt("invalid UTF-8 character while decoding"));
|
||||
return retval;
|
||||
}
|
||||
buf += len;
|
||||
|
||||
@@ -26,58 +26,6 @@ bool GuiMode = false;
|
||||
logvisor::Module LogModule("hecl");
|
||||
static const std::string Illegals{"<>?\""};
|
||||
|
||||
#if __GNUC__
|
||||
__attribute__((__format__(__printf__, 1, 2)))
|
||||
#endif
|
||||
SystemString
|
||||
SysFormat(const SystemChar* format, ...) {
|
||||
SystemChar resultBuf[FORMAT_BUF_SZ];
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
#if HECL_UCS2
|
||||
int printSz = vswprintf(resultBuf, FORMAT_BUF_SZ, format, va);
|
||||
#else
|
||||
int printSz = vsnprintf(resultBuf, FORMAT_BUF_SZ, format, va);
|
||||
#endif
|
||||
va_end(va);
|
||||
return SystemString(resultBuf, printSz);
|
||||
}
|
||||
|
||||
#if __GNUC__
|
||||
__attribute__((__format__(__printf__, 1, 2)))
|
||||
#endif
|
||||
std::string
|
||||
Format(const char* format, ...) {
|
||||
char resultBuf[FORMAT_BUF_SZ];
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
int printSz = vsnprintf(resultBuf, FORMAT_BUF_SZ, format, va);
|
||||
va_end(va);
|
||||
return std::string(resultBuf, printSz);
|
||||
}
|
||||
|
||||
std::wstring WideFormat(const wchar_t* format, ...) {
|
||||
wchar_t resultBuf[FORMAT_BUF_SZ];
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
int printSz = vswprintf(resultBuf, FORMAT_BUF_SZ, format, va);
|
||||
va_end(va);
|
||||
return std::wstring(resultBuf, printSz);
|
||||
}
|
||||
|
||||
std::u16string Char16Format(const wchar_t* format, ...) {
|
||||
wchar_t resultBuf[FORMAT_BUF_SZ];
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
size_t printSz = vswprintf(resultBuf, FORMAT_BUF_SZ, format, va);
|
||||
va_end(va);
|
||||
std::u16string res;
|
||||
res.reserve(printSz);
|
||||
for (size_t i = 0; i < printSz; ++i)
|
||||
res.push_back(resultBuf[i]);
|
||||
return res;
|
||||
}
|
||||
|
||||
void SanitizePath(std::string& path) {
|
||||
if (path.empty())
|
||||
return;
|
||||
@@ -146,7 +94,7 @@ SystemString GetcwdStr() {
|
||||
return SystemString(stackBuffer);
|
||||
if (errno != ERANGE) {
|
||||
// It's not ERANGE, so we don't know how to handle it
|
||||
LogModule.report(logvisor::Fatal, "Cannot determine the current path.");
|
||||
LogModule.report(logvisor::Fatal, fmt("Cannot determine the current path."));
|
||||
// Of course you may choose a different error reporting method
|
||||
}
|
||||
// Ok, the stack buffer isn't long enough; fallback to heap allocation
|
||||
@@ -158,11 +106,11 @@ SystemString GetcwdStr() {
|
||||
return SystemString(cwd.get());
|
||||
if (errno != ERANGE) {
|
||||
// It's not ERANGE, so we don't know how to handle it
|
||||
LogModule.report(logvisor::Fatal, "Cannot determine the current path.");
|
||||
LogModule.report(logvisor::Fatal, fmt("Cannot determine the current path."));
|
||||
// Of course you may choose a different error reporting method
|
||||
}
|
||||
}
|
||||
LogModule.report(logvisor::Fatal, "Cannot determine the current path; the path is apparently unreasonably long");
|
||||
LogModule.report(logvisor::Fatal, fmt("Cannot determine the current path; the path is apparently unreasonably long"));
|
||||
return SystemString();
|
||||
}
|
||||
|
||||
@@ -180,7 +128,7 @@ bool ResourceLock::InProgress(const ProjectPath& path) {
|
||||
bool ResourceLock::SetThreadRes(const ProjectPath& path) {
|
||||
std::unique_lock<std::mutex> lk(PathsMutex);
|
||||
if (PathsInProgress.find(std::this_thread::get_id()) != PathsInProgress.cend())
|
||||
LogModule.report(logvisor::Fatal, "multiple resource locks on thread");
|
||||
LogModule.report(logvisor::Fatal, fmt("multiple resource locks on thread"));
|
||||
|
||||
for (const auto& p : PathsInProgress)
|
||||
if (p.second == path)
|
||||
@@ -752,13 +700,13 @@ int RunProcess(const SystemChar* path, const SystemChar* const args[]) {
|
||||
SECURITY_ATTRIBUTES sattrs = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
|
||||
HANDLE consoleOutReadTmp, consoleOutWrite, consoleErrWrite, consoleOutRead;
|
||||
if (!CreatePipe(&consoleOutReadTmp, &consoleOutWrite, &sattrs, 0)) {
|
||||
LogModule.report(logvisor::Fatal, "Error with CreatePipe");
|
||||
LogModule.report(logvisor::Fatal, fmt("Error with CreatePipe"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!DuplicateHandle(GetCurrentProcess(), consoleOutWrite, GetCurrentProcess(), &consoleErrWrite, 0, TRUE,
|
||||
DUPLICATE_SAME_ACCESS)) {
|
||||
LogModule.report(logvisor::Fatal, "Error with DuplicateHandle");
|
||||
LogModule.report(logvisor::Fatal, fmt("Error with DuplicateHandle"));
|
||||
CloseHandle(consoleOutReadTmp);
|
||||
CloseHandle(consoleOutWrite);
|
||||
return -1;
|
||||
@@ -768,7 +716,7 @@ int RunProcess(const SystemChar* path, const SystemChar* const args[]) {
|
||||
&consoleOutRead, // Address of new handle.
|
||||
0, FALSE, // Make it uninheritable.
|
||||
DUPLICATE_SAME_ACCESS)) {
|
||||
LogModule.report(logvisor::Fatal, "Error with DupliateHandle");
|
||||
LogModule.report(logvisor::Fatal, fmt("Error with DupliateHandle"));
|
||||
CloseHandle(consoleOutReadTmp);
|
||||
CloseHandle(consoleOutWrite);
|
||||
CloseHandle(consoleErrWrite);
|
||||
@@ -825,13 +773,13 @@ int RunProcess(const SystemChar* path, const SystemChar* const args[]) {
|
||||
if (err == ERROR_BROKEN_PIPE)
|
||||
break; // pipe done - normal exit path.
|
||||
else
|
||||
LogModule.report(logvisor::Error, "Error with ReadFile: %08X", err); // Something bad happened.
|
||||
LogModule.report(logvisor::Error, fmt("Error with ReadFile: %08X"), err); // Something bad happened.
|
||||
}
|
||||
|
||||
// Display the character read on the screen.
|
||||
auto lk = logvisor::LockLog();
|
||||
if (!WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), lpBuffer, nBytesRead, &nCharsWritten, NULL)) {
|
||||
// LogModule.report(logvisor::Error, "Error with WriteConsole: %08X", GetLastError());
|
||||
// LogModule.report(logvisor::Error, fmt("Error with WriteConsole: %08X"), GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user