change logger
This commit is contained in:
parent
bd2faabe99
commit
14db1066fc
|
@ -84,11 +84,11 @@ void Application::init(const std::vector<std::string>& args)
|
||||||
|
|
||||||
// setup configs write directory
|
// setup configs write directory
|
||||||
if(!g_resources.setupWriteDir(m_appName))
|
if(!g_resources.setupWriteDir(m_appName))
|
||||||
logError("Could not setup write directory");
|
g_logger.error("Could not setup write directory");
|
||||||
|
|
||||||
// load configs
|
// load configs
|
||||||
if(!g_configs.load("/config.otml"))
|
if(!g_configs.load("/config.otml"))
|
||||||
logInfo("Using default configurations.");
|
g_logger.info("Using default configurations.");
|
||||||
|
|
||||||
// setup platform window
|
// setup platform window
|
||||||
g_ui.init();
|
g_ui.init();
|
||||||
|
@ -159,7 +159,7 @@ void Application::terminate()
|
||||||
|
|
||||||
m_foreground = nullptr;
|
m_foreground = nullptr;
|
||||||
|
|
||||||
logInfo("Application ended successfully.");
|
g_logger.info("Application ended successfully.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::run()
|
void Application::run()
|
||||||
|
@ -256,7 +256,7 @@ void Application::run()
|
||||||
|
|
||||||
void Application::exit()
|
void Application::exit()
|
||||||
{
|
{
|
||||||
logInfo("Exiting application..");
|
g_logger.info("Exiting application..");
|
||||||
m_stopping = true;
|
m_stopping = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ bool ConfigManager::load(const std::string& file)
|
||||||
m_confsDoc = confsDoc;
|
m_confsDoc = confsDoc;
|
||||||
return true;
|
return true;
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("Unable to load configuration file: %s", e.what());
|
g_logger.error(stdext::format("Unable to load configuration file: %s", e.what()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ void EventDispatcher::poll()
|
||||||
if(count > 50) {
|
if(count > 50) {
|
||||||
static Timer reportTimer;
|
static Timer reportTimer;
|
||||||
if(reportTimer.running() && reportTimer.ticksElapsed() > 250) {
|
if(reportTimer.running() && reportTimer.ticksElapsed() > 250) {
|
||||||
logError("ATTENTION the event list is not getting empty, this could be caused by some bad code");
|
g_logger.error("ATTENTION the event list is not getting empty, this could be caused by some bad code");
|
||||||
reportTimer.restart();
|
reportTimer.restart();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -39,7 +39,7 @@ FileStream::~FileStream()
|
||||||
void FileStream::cache()
|
void FileStream::cache()
|
||||||
{
|
{
|
||||||
if(!m_fileHandle)
|
if(!m_fileHandle)
|
||||||
logTraceError("no file handle to cache");
|
g_logger.traceError("no file handle to cache");
|
||||||
|
|
||||||
// cache entire file into cache buffer
|
// cache entire file into cache buffer
|
||||||
m_cacheReadPos = PHYSFS_tell(m_fileHandle);
|
m_cacheReadPos = PHYSFS_tell(m_fileHandle);
|
||||||
|
@ -48,7 +48,7 @@ void FileStream::cache()
|
||||||
m_cacheBuffer.resize(size);
|
m_cacheBuffer.resize(size);
|
||||||
int res = PHYSFS_read(m_fileHandle, &m_cacheBuffer[0], size, 1);
|
int res = PHYSFS_read(m_fileHandle, &m_cacheBuffer[0], size, 1);
|
||||||
if(res == -1)
|
if(res == -1)
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
|
|
||||||
PHYSFS_close(m_fileHandle);
|
PHYSFS_close(m_fileHandle);
|
||||||
m_fileHandle = nullptr;
|
m_fileHandle = nullptr;
|
||||||
|
@ -58,7 +58,7 @@ bool FileStream::close()
|
||||||
{
|
{
|
||||||
if(m_fileHandle) {
|
if(m_fileHandle) {
|
||||||
if(PHYSFS_isInit() && PHYSFS_close(m_fileHandle) == 0)
|
if(PHYSFS_isInit() && PHYSFS_close(m_fileHandle) == 0)
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
|
|
||||||
m_fileHandle = nullptr;
|
m_fileHandle = nullptr;
|
||||||
return true;
|
return true;
|
||||||
|
@ -75,7 +75,7 @@ bool FileStream::flush()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(PHYSFS_flush(m_fileHandle) == 0) {
|
if(PHYSFS_flush(m_fileHandle) == 0) {
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -86,7 +86,7 @@ int FileStream::read(void *buffer, int size, int nmemb)
|
||||||
if(m_fileHandle) {
|
if(m_fileHandle) {
|
||||||
int res = PHYSFS_read(m_fileHandle, buffer, size, nmemb);
|
int res = PHYSFS_read(m_fileHandle, buffer, size, nmemb);
|
||||||
if(res == -1) {
|
if(res == -1) {
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -111,7 +111,7 @@ bool FileStream::write(void *buffer, int count)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(PHYSFS_write(m_fileHandle, buffer, 1, count) != count) {
|
if(PHYSFS_write(m_fileHandle, buffer, 1, count) != count) {
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,12 +122,12 @@ bool FileStream::seek(int pos)
|
||||||
{
|
{
|
||||||
if(m_fileHandle) {
|
if(m_fileHandle) {
|
||||||
if(PHYSFS_seek(m_fileHandle, pos) == 0) {
|
if(PHYSFS_seek(m_fileHandle, pos) == 0) {
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(pos > (int)m_cacheBuffer.size() || pos < 0) {
|
if(pos > (int)m_cacheBuffer.size() || pos < 0) {
|
||||||
logTraceError("operation failed on '%s': seek pos cannot be greater than file length", m_name);
|
g_logger.traceError(stdext::format("operation failed on '%s': seek pos cannot be greater than file length", m_name));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_cacheReadPos = pos;
|
m_cacheReadPos = pos;
|
||||||
|
@ -156,10 +156,10 @@ uint8 FileStream::getU8()
|
||||||
uint8 v = 0;
|
uint8 v = 0;
|
||||||
if(m_fileHandle) {
|
if(m_fileHandle) {
|
||||||
if(PHYSFS_read(m_fileHandle, &v, 1, 1) != 1)
|
if(PHYSFS_read(m_fileHandle, &v, 1, 1) != 1)
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
} else {
|
} else {
|
||||||
if(m_cacheReadPos+1 > m_cacheBuffer.size()) {
|
if(m_cacheReadPos+1 > m_cacheBuffer.size()) {
|
||||||
logTraceError("operation failed on '%s': reached file eof", m_name);
|
g_logger.traceError(stdext::format("operation failed on '%s': reached file eof", m_name));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,10 +174,10 @@ uint16 FileStream::getU16()
|
||||||
uint16 v = 0;
|
uint16 v = 0;
|
||||||
if(m_fileHandle) {
|
if(m_fileHandle) {
|
||||||
if(PHYSFS_readULE16(m_fileHandle, &v) == 0)
|
if(PHYSFS_readULE16(m_fileHandle, &v) == 0)
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
} else {
|
} else {
|
||||||
if(m_cacheReadPos+2 > m_cacheBuffer.size()) {
|
if(m_cacheReadPos+2 > m_cacheBuffer.size()) {
|
||||||
logTraceError("operation failed on '%s': reached file eof", m_name);
|
g_logger.traceError(stdext::format("operation failed on '%s': reached file eof", m_name));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,10 +192,10 @@ uint32 FileStream::getU32()
|
||||||
uint32 v = 0;
|
uint32 v = 0;
|
||||||
if(m_fileHandle) {
|
if(m_fileHandle) {
|
||||||
if(PHYSFS_readULE32(m_fileHandle, &v) == 0)
|
if(PHYSFS_readULE32(m_fileHandle, &v) == 0)
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
} else {
|
} else {
|
||||||
if(m_cacheReadPos+4 > m_cacheBuffer.size()) {
|
if(m_cacheReadPos+4 > m_cacheBuffer.size()) {
|
||||||
logTraceError("operation failed on '%s': reached file eof", m_name);
|
g_logger.traceError(stdext::format("operation failed on '%s': reached file eof", m_name));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,10 +210,10 @@ uint64 FileStream::getU64()
|
||||||
uint64 v = 0;
|
uint64 v = 0;
|
||||||
if(m_fileHandle) {
|
if(m_fileHandle) {
|
||||||
if(PHYSFS_readULE64(m_fileHandle, (PHYSFS_uint64*)&v) == 0)
|
if(PHYSFS_readULE64(m_fileHandle, (PHYSFS_uint64*)&v) == 0)
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
} else {
|
} else {
|
||||||
if(m_cacheReadPos+8 > m_cacheBuffer.size()) {
|
if(m_cacheReadPos+8 > m_cacheBuffer.size()) {
|
||||||
logTraceError("operation failed on '%s': reached file eof", m_name);
|
g_logger.traceError(stdext::format("operation failed on '%s': reached file eof", m_name));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,12 +231,12 @@ std::string FileStream::getString()
|
||||||
char buffer[8192];
|
char buffer[8192];
|
||||||
if(m_fileHandle) {
|
if(m_fileHandle) {
|
||||||
if(PHYSFS_read(m_fileHandle, buffer, 1, len) == 0)
|
if(PHYSFS_read(m_fileHandle, buffer, 1, len) == 0)
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
else
|
else
|
||||||
str = std::string(buffer, len);
|
str = std::string(buffer, len);
|
||||||
} else {
|
} else {
|
||||||
if(m_cacheReadPos+len > m_cacheBuffer.size()) {
|
if(m_cacheReadPos+len > m_cacheBuffer.size()) {
|
||||||
logTraceError("operation failed on '%s': reached file eof", m_name);
|
g_logger.traceError(stdext::format("operation failed on '%s': reached file eof", m_name));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ std::string FileStream::getString()
|
||||||
m_cacheReadPos += len;
|
m_cacheReadPos += len;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -252,23 +252,23 @@ std::string FileStream::getString()
|
||||||
void FileStream::addU8(uint8 v)
|
void FileStream::addU8(uint8 v)
|
||||||
{
|
{
|
||||||
if(PHYSFS_write(m_fileHandle, &v, 1, 1) != 1)
|
if(PHYSFS_write(m_fileHandle, &v, 1, 1) != 1)
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileStream::addU16(uint8 v)
|
void FileStream::addU16(uint8 v)
|
||||||
{
|
{
|
||||||
if(PHYSFS_writeULE16(m_fileHandle, v) == 0)
|
if(PHYSFS_writeULE16(m_fileHandle, v) == 0)
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileStream::addU32(uint8 v)
|
void FileStream::addU32(uint8 v)
|
||||||
{
|
{
|
||||||
if(PHYSFS_writeULE32(m_fileHandle, v) == 0)
|
if(PHYSFS_writeULE32(m_fileHandle, v) == 0)
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileStream::addU64(uint8 v)
|
void FileStream::addU64(uint8 v)
|
||||||
{
|
{
|
||||||
if(PHYSFS_writeULE64(m_fileHandle, v) == 0)
|
if(PHYSFS_writeULE64(m_fileHandle, v) == 0)
|
||||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
g_logger.traceError(stdext::format("operation failed on '%s': %s", m_name, PHYSFS_getLastError()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ void Logger::setLogFile(const std::string& file)
|
||||||
{
|
{
|
||||||
m_outFile.open(file.c_str(), std::ios::out | std::ios::app);
|
m_outFile.open(file.c_str(), std::ios::out | std::ios::app);
|
||||||
if(!m_outFile.is_open() || !m_outFile.good()) {
|
if(!m_outFile.is_open() || !m_outFile.good()) {
|
||||||
logError("Unable to save log to '%s'", file);
|
g_logger.error(stdext::format("Unable to save log to '%s'", file));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,12 @@ public:
|
||||||
void log(Fw::LogLevel level, const std::string& message);
|
void log(Fw::LogLevel level, const std::string& message);
|
||||||
void logFunc(Fw::LogLevel level, const std::string& message, std::string prettyFunction);
|
void logFunc(Fw::LogLevel level, const std::string& message, std::string prettyFunction);
|
||||||
|
|
||||||
|
void debug(const std::string& what) { log(Fw::LogDebug, what); }
|
||||||
|
void info(const std::string& what) { log(Fw::LogInfo, what); }
|
||||||
|
void warning(const std::string& what) { log(Fw::LogWarning, what); }
|
||||||
|
void error(const std::string& what) { log(Fw::LogError, what); }
|
||||||
|
void fatal(const std::string& what) { log(Fw::LogError, what); }
|
||||||
|
|
||||||
void fireOldMessages();
|
void fireOldMessages();
|
||||||
void setLogFile(const std::string& file);
|
void setLogFile(const std::string& file);
|
||||||
void setOnLog(const OnLogCallback& onLog) { m_onLog = onLog; }
|
void setOnLog(const OnLogCallback& onLog) { m_onLog = onLog; }
|
||||||
|
@ -56,18 +62,11 @@ private:
|
||||||
|
|
||||||
extern Logger g_logger;
|
extern Logger g_logger;
|
||||||
|
|
||||||
// specialized logging
|
#define trace() logFunc(Fw::LogDebug, "", __PRETTY_FUNCTION__)
|
||||||
#define logDebug(...) g_logger.log(Fw::LogDebug, stdext::format(__VA_ARGS__))
|
#define traceDebug(a) logFunc(Fw::LogDebug, a, __PRETTY_FUNCTION__)
|
||||||
#define logInfo(...) g_logger.log(Fw::LogInfo, stdext::format(__VA_ARGS__))
|
#define traceInfo(a) logFunc(Fw::LogInfo, a, __PRETTY_FUNCTION__)
|
||||||
#define logWarning(...) g_logger.log(Fw::LogWarning, stdext::format(__VA_ARGS__))
|
#define traceWarning(a) logFunc(Fw::LogWarning, a, __PRETTY_FUNCTION__)
|
||||||
#define logError(...) g_logger.log(Fw::LogError, stdext::format(__VA_ARGS__))
|
#define traceError(a) logFunc(Fw::LogError, a, __PRETTY_FUNCTION__)
|
||||||
#define logFatal(...) g_logger.log(Fw::LogFatal, stdext::format(__VA_ARGS__))
|
|
||||||
|
|
||||||
#define logTrace() g_logger.logFunc(Fw::LogDebug, "", __PRETTY_FUNCTION__)
|
|
||||||
#define logTraceDebug(...) g_logger.logFunc(Fw::LogDebug, stdext::format(__VA_ARGS__), __PRETTY_FUNCTION__)
|
|
||||||
#define logTraceInfo(...) g_logger.logFunc(Fw::LogInfo, stdext::format(__VA_ARGS__), __PRETTY_FUNCTION__)
|
|
||||||
#define logTraceWarning(...) g_logger.logFunc(Fw::LogWarning, stdext::format(__VA_ARGS__), __PRETTY_FUNCTION__)
|
|
||||||
#define logTraceError(...) g_logger.logFunc(Fw::LogError, stdext::format(__VA_ARGS__), __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#define logTraceCounter() { \
|
#define logTraceCounter() { \
|
||||||
static int __count = 0; \
|
static int __count = 0; \
|
||||||
|
|
|
@ -39,12 +39,12 @@ bool Module::load()
|
||||||
for(const std::string& depName : m_dependencies) {
|
for(const std::string& depName : m_dependencies) {
|
||||||
ModulePtr dep = g_modules.getModule(depName);
|
ModulePtr dep = g_modules.getModule(depName);
|
||||||
if(!dep) {
|
if(!dep) {
|
||||||
logError("Unable to load module '%s' because dependency '%s' was not found", m_name, depName);
|
g_logger.error(stdext::format("Unable to load module '%s' because dependency '%s' was not found", m_name, depName));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dep->isLoaded() && !dep->load()) {
|
if(!dep->isLoaded() && !dep->load()) {
|
||||||
logError("Unable to load module '%s' because dependency '%s' has failed to load", m_name, depName);
|
g_logger.error(stdext::format("Unable to load module '%s' because dependency '%s' has failed to load", m_name, depName));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,13 +53,13 @@ bool Module::load()
|
||||||
m_loadCallback();
|
m_loadCallback();
|
||||||
|
|
||||||
m_loaded = true;
|
m_loaded = true;
|
||||||
logInfo("Loaded module '%s'", m_name);
|
g_logger.info(stdext::format("Loaded module '%s'", m_name));
|
||||||
g_modules.updateModuleLoadOrder(asModule());
|
g_modules.updateModuleLoadOrder(asModule());
|
||||||
|
|
||||||
for(const std::string& modName : m_loadLaterModules) {
|
for(const std::string& modName : m_loadLaterModules) {
|
||||||
ModulePtr dep = g_modules.getModule(modName);
|
ModulePtr dep = g_modules.getModule(modName);
|
||||||
if(!dep)
|
if(!dep)
|
||||||
logError("Unable to find module '%s' required by '%s'", modName, m_name);
|
g_logger.error(stdext::format("Unable to find module '%s' required by '%s'", modName, m_name));
|
||||||
else if(!dep->isLoaded())
|
else if(!dep->isLoaded())
|
||||||
dep->load();
|
dep->load();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ void Module::unload()
|
||||||
if(m_unloadCallback)
|
if(m_unloadCallback)
|
||||||
m_unloadCallback();
|
m_unloadCallback();
|
||||||
m_loaded = false;
|
m_loaded = false;
|
||||||
logInfo("Unloaded module '%s'", m_name);
|
g_logger.info(stdext::format("Unloaded module '%s'", m_name));
|
||||||
g_modules.updateModuleLoadOrder(asModule());
|
g_modules.updateModuleLoadOrder(asModule());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ void ModuleManager::autoLoadModules(int maxPriority)
|
||||||
break;
|
break;
|
||||||
ModulePtr module = pair.second;
|
ModulePtr module = pair.second;
|
||||||
if(!module->isLoaded() && !module->load())
|
if(!module->isLoaded() && !module->load())
|
||||||
logFatal("A required module has failed to load, cannot continue to run.");
|
g_logger.fatal("A required module has failed to load, cannot continue to run.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,14 +70,14 @@ void ModuleManager::discoverModulesPath()
|
||||||
for(const std::string& dir : possibleModulesDirs) {
|
for(const std::string& dir : possibleModulesDirs) {
|
||||||
// try to add module directory
|
// try to add module directory
|
||||||
if(g_resources.addToSearchPath(dir, false)) {
|
if(g_resources.addToSearchPath(dir, false)) {
|
||||||
logInfo("Using modules directory '%s'", dir.c_str());
|
g_logger.info(stdext::format("Using modules directory '%s'", dir.c_str()));
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!found)
|
if(!found)
|
||||||
logFatal("Could not find modules directory");
|
g_logger.fatal("Could not find modules directory");
|
||||||
|
|
||||||
// search for addons directory
|
// search for addons directory
|
||||||
std::string possibleAddonsDirs[] = { "addons",
|
std::string possibleAddonsDirs[] = { "addons",
|
||||||
|
@ -88,7 +88,7 @@ void ModuleManager::discoverModulesPath()
|
||||||
for(const std::string& dir : possibleAddonsDirs) {
|
for(const std::string& dir : possibleAddonsDirs) {
|
||||||
// try to add module directory
|
// try to add module directory
|
||||||
if(g_resources.addToSearchPath(dir, true)) {
|
if(g_resources.addToSearchPath(dir, true)) {
|
||||||
logInfo("Using addons directory '%s'", dir.c_str());
|
g_logger.info(stdext::format("Using addons directory '%s'", dir.c_str()));
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ ModulePtr ModuleManager::discoverModule(const std::string& moduleFile)
|
||||||
if(push)
|
if(push)
|
||||||
m_modules.push_back(module);
|
m_modules.push_back(module);
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("Unable to discover module from file '%s': %s", moduleFile, e.what());
|
g_logger.error(stdext::format("Unable to discover module from file '%s': %s", moduleFile, e.what()));
|
||||||
}
|
}
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ void ModuleManager::ensureModuleLoaded(const std::string& moduleName)
|
||||||
{
|
{
|
||||||
ModulePtr module = g_modules.getModule(moduleName);
|
ModulePtr module = g_modules.getModule(moduleName);
|
||||||
if(!module || !module->load())
|
if(!module || !module->load())
|
||||||
logFatal("Unable to load '%s' module", moduleName);
|
g_logger.fatal(stdext::format("Unable to load '%s' module", moduleName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleManager::unloadModules()
|
void ModuleManager::unloadModules()
|
||||||
|
|
|
@ -118,7 +118,7 @@ bool ResourceManager::saveFile(const std::string& fileName, const uchar* data, u
|
||||||
PHYSFS_file* file = PHYSFS_openWrite(fileName.c_str());
|
PHYSFS_file* file = PHYSFS_openWrite(fileName.c_str());
|
||||||
if(!file)
|
if(!file)
|
||||||
{
|
{
|
||||||
logError(PHYSFS_getLastError());
|
g_logger.error(PHYSFS_getLastError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ FileStreamPtr ResourceManager::openFile(const std::string& fileName)
|
||||||
std::string fullPath = resolvePath(fileName);
|
std::string fullPath = resolvePath(fileName);
|
||||||
PHYSFS_File* file = PHYSFS_openRead(fullPath.c_str());
|
PHYSFS_File* file = PHYSFS_openRead(fullPath.c_str());
|
||||||
if(!file) {
|
if(!file) {
|
||||||
logTraceError("unable to open file '%s': %s", fullPath, PHYSFS_getLastError());
|
g_logger.error(stdext::format("unable to open file '%s': %s", fullPath, PHYSFS_getLastError()));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return FileStreamPtr(new FileStream(fullPath, file));
|
return FileStreamPtr(new FileStream(fullPath, file));
|
||||||
|
@ -160,7 +160,7 @@ FileStreamPtr ResourceManager::appendFile(const std::string& fileName)
|
||||||
{
|
{
|
||||||
PHYSFS_File* file = PHYSFS_openAppend(fileName.c_str());
|
PHYSFS_File* file = PHYSFS_openAppend(fileName.c_str());
|
||||||
if(!file) {
|
if(!file) {
|
||||||
logTraceError("failed to append file '%s': %s", fileName, PHYSFS_getLastError());
|
g_logger.error(stdext::format("failed to append file '%s': %s", fileName, PHYSFS_getLastError()));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return FileStreamPtr(new FileStream(fileName, file));
|
return FileStreamPtr(new FileStream(fileName, file));
|
||||||
|
@ -170,7 +170,7 @@ FileStreamPtr ResourceManager::createFile(const std::string& fileName)
|
||||||
{
|
{
|
||||||
PHYSFS_File* file = PHYSFS_openWrite(fileName.c_str());
|
PHYSFS_File* file = PHYSFS_openWrite(fileName.c_str());
|
||||||
if(!file) {
|
if(!file) {
|
||||||
logTraceError("failed to create file '%s': %s", fileName, PHYSFS_getLastError());
|
g_logger.error(stdext::format("failed to create file '%s': %s", fileName, PHYSFS_getLastError()));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return FileStreamPtr(new FileStream(fileName, file));
|
return FileStreamPtr(new FileStream(fileName, file));
|
||||||
|
@ -211,7 +211,7 @@ std::string ResourceManager::resolvePath(const std::string& path)
|
||||||
fullPath += path;
|
fullPath += path;
|
||||||
}
|
}
|
||||||
if(!(boost::starts_with(fullPath, "/")))
|
if(!(boost::starts_with(fullPath, "/")))
|
||||||
logTraceWarning("the following file path is not fully resolved: %s", path);
|
g_logger.traceWarning(stdext::format("the following file path is not fully resolved: %s", path));
|
||||||
boost::replace_all(fullPath, "//", "/");
|
boost::replace_all(fullPath, "//", "/");
|
||||||
return fullPath;
|
return fullPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ bool FontManager::importFont(std::string fontFile)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("Unable to load font from file '%s': %s", fontFile, e.what());
|
g_logger.error(stdext::format("Unable to load font from file '%s': %s", fontFile, e.what()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ FontPtr FontManager::getFont(const std::string& fontName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// when not found, fallback to default font
|
// when not found, fallback to default font
|
||||||
logError("font '%s' not found", fontName);
|
g_logger.error(stdext::format("font '%s' not found", fontName));
|
||||||
return getDefaultFont();
|
return getDefaultFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ void FrameBuffer::internalCreate()
|
||||||
if(g_graphics.canUseFBO()) {
|
if(g_graphics.canUseFBO()) {
|
||||||
glGenFramebuffers(1, &m_fbo);
|
glGenFramebuffers(1, &m_fbo);
|
||||||
if(!m_fbo)
|
if(!m_fbo)
|
||||||
logFatal("Unable to create framebuffer object");
|
g_logger.fatal("Unable to create framebuffer object");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ void FrameBuffer::resize(const Size& size)
|
||||||
|
|
||||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
if(status != GL_FRAMEBUFFER_COMPLETE)
|
if(status != GL_FRAMEBUFFER_COMPLETE)
|
||||||
logFatal("Unable to setup framebuffer object");
|
g_logger.fatal("Unable to setup framebuffer object");
|
||||||
internalRelease();
|
internalRelease();
|
||||||
} else {
|
} else {
|
||||||
m_screenBackup = TexturePtr(new Texture(size.width(), size.height()));
|
m_screenBackup = TexturePtr(new Texture(size.width(), size.height()));
|
||||||
|
|
|
@ -45,8 +45,8 @@ Graphics::Graphics()
|
||||||
|
|
||||||
void Graphics::init()
|
void Graphics::init()
|
||||||
{
|
{
|
||||||
logInfo("GPU %s", glGetString(GL_RENDERER));
|
g_logger.info(stdext::format("GPU %s", glGetString(GL_RENDERER)));
|
||||||
logInfo("OpenGL %s", glGetString(GL_VERSION));
|
g_logger.info(stdext::format("OpenGL %s", glGetString(GL_VERSION)));
|
||||||
|
|
||||||
#if OPENGL_ES==2
|
#if OPENGL_ES==2
|
||||||
g_painterOGL2 = new PainterOGL2;
|
g_painterOGL2 = new PainterOGL2;
|
||||||
|
@ -56,7 +56,7 @@ void Graphics::init()
|
||||||
// init GL extensions
|
// init GL extensions
|
||||||
GLenum err = glewInit();
|
GLenum err = glewInit();
|
||||||
if(err != GLEW_OK)
|
if(err != GLEW_OK)
|
||||||
logFatal("Unable to init GLEW: %s", glewGetErrorString(err));
|
g_logger.fatal(stdext::format("Unable to init GLEW: %s", glewGetErrorString(err)));
|
||||||
|
|
||||||
// overwrite framebuffer API if needed
|
// overwrite framebuffer API if needed
|
||||||
if(GLEW_EXT_framebuffer_object && !GLEW_ARB_framebuffer_object) {
|
if(GLEW_EXT_framebuffer_object && !GLEW_ARB_framebuffer_object) {
|
||||||
|
@ -162,7 +162,7 @@ bool Graphics::selectPainterEngine(PainterEngine painterEngine)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!found)
|
if(!found)
|
||||||
logFatal("Neither OpenGL 1.0 nor OpenGL 2.0 painter engine is supported by your platform, "
|
g_logger.fatal("Neither OpenGL 1.0 nor OpenGL 2.0 painter engine is supported by your platform, "
|
||||||
"try updating your graphics drivers or your hardware and then run again.");
|
"try updating your graphics drivers or your hardware and then run again.");
|
||||||
|
|
||||||
// switch painters GL state
|
// switch painters GL state
|
||||||
|
|
|
@ -46,7 +46,7 @@ ImagePtr Image::load(const std::string& file)
|
||||||
// load image file data
|
// load image file data
|
||||||
image = loadPNG(file);
|
image = loadPNG(file);
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("unable to load image '%s': %s", file, e.what());
|
g_logger.error(stdext::format("unable to load image '%s': %s", file, e.what()));
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ bool ParticleEmitter::load(const OTMLNodePtr& node)
|
||||||
m_pColorsStops.push_back(0);
|
m_pColorsStops.push_back(0);
|
||||||
|
|
||||||
if(m_pColors.size() != m_pColorsStops.size()) {
|
if(m_pColors.size() != m_pColorsStops.size()) {
|
||||||
logError("particle colors must be equal to colorstops-1");
|
g_logger.error(stdext::format("particle colors must be equal to colorstops-1"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ bool ParticleManager::load(const std::string& filename)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("could not load particles: %s", e.what());
|
g_logger.error(stdext::format("could not load particles: %s", e.what()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ Shader::Shader(Shader::ShaderType shaderType)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!m_shaderId)
|
if(!m_shaderId)
|
||||||
logFatal("Unable to create GL shader");
|
g_logger.fatal("Unable to create GL shader");
|
||||||
}
|
}
|
||||||
|
|
||||||
Shader::~Shader()
|
Shader::~Shader()
|
||||||
|
|
|
@ -30,7 +30,7 @@ ShaderProgram::ShaderProgram()
|
||||||
m_programId = glCreateProgram();
|
m_programId = glCreateProgram();
|
||||||
m_uniformLocations.fill(-1);
|
m_uniformLocations.fill(-1);
|
||||||
if(!m_programId)
|
if(!m_programId)
|
||||||
logFatal("Unable to create GL shader program");
|
g_logger.fatal("Unable to create GL shader program");
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderProgram::~ShaderProgram()
|
ShaderProgram::~ShaderProgram()
|
||||||
|
@ -48,7 +48,7 @@ bool ShaderProgram::addShader(const ShaderPtr& shader) {
|
||||||
bool ShaderProgram::addShaderFromSourceCode(Shader::ShaderType shaderType, const std::string& sourceCode) {
|
bool ShaderProgram::addShaderFromSourceCode(Shader::ShaderType shaderType, const std::string& sourceCode) {
|
||||||
ShaderPtr shader(new Shader(shaderType));
|
ShaderPtr shader(new Shader(shaderType));
|
||||||
if(!shader->compileSourceCode(sourceCode)) {
|
if(!shader->compileSourceCode(sourceCode)) {
|
||||||
logError("failed to compile shader: %s", shader->log());
|
g_logger.error(stdext::format("failed to compile shader: %s", shader->log()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return addShader(shader);
|
return addShader(shader);
|
||||||
|
@ -57,7 +57,7 @@ bool ShaderProgram::addShaderFromSourceCode(Shader::ShaderType shaderType, const
|
||||||
bool ShaderProgram::addShaderFromSourceFile(Shader::ShaderType shaderType, const std::string& sourceFile) {
|
bool ShaderProgram::addShaderFromSourceFile(Shader::ShaderType shaderType, const std::string& sourceFile) {
|
||||||
ShaderPtr shader(new Shader(shaderType));
|
ShaderPtr shader(new Shader(shaderType));
|
||||||
if(!shader->compileSourceFile(sourceFile)) {
|
if(!shader->compileSourceFile(sourceFile)) {
|
||||||
logError("failed to compile shader: %s", shader->log());
|
g_logger.error(stdext::format("failed to compile shader: %s", shader->log()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return addShader(shader);
|
return addShader(shader);
|
||||||
|
@ -92,7 +92,7 @@ bool ShaderProgram::link()
|
||||||
m_linked = (value != GL_FALSE);
|
m_linked = (value != GL_FALSE);
|
||||||
|
|
||||||
if(!m_linked)
|
if(!m_linked)
|
||||||
logTraceWarning(log());
|
g_logger.traceWarning(log());
|
||||||
return m_linked;
|
return m_linked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,10 +82,10 @@ uint Texture::internalLoadGLTexture(uchar *pixels, int channels, int width, int
|
||||||
|
|
||||||
// checks texture max size
|
// checks texture max size
|
||||||
if(std::max(glSize.width(), glSize.height()) > g_graphics.getMaxTextureSize()) {
|
if(std::max(glSize.width(), glSize.height()) > g_graphics.getMaxTextureSize()) {
|
||||||
logError("loading texture with size %dx%d failed, "
|
g_logger.error(stdext::format("loading texture with size %dx%d failed, "
|
||||||
"the maximum size allowed by the graphics card is %dx%d,"
|
"the maximum size allowed by the graphics card is %dx%d,"
|
||||||
"to prevent crashes the texture will be displayed as a blank texture",
|
"to prevent crashes the texture will be displayed as a blank texture",
|
||||||
width, height, g_graphics.getMaxTextureSize(), g_graphics.getMaxTextureSize());
|
width, height, g_graphics.getMaxTextureSize(), g_graphics.getMaxTextureSize()));
|
||||||
//TODO: make a workaround, could be bilinear scaling the texture
|
//TODO: make a workaround, could be bilinear scaling the texture
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ void Texture::generateMipmaps()
|
||||||
//FIXME: disabled because mipmaps size needs to be in base of 2,
|
//FIXME: disabled because mipmaps size needs to be in base of 2,
|
||||||
// and the current algorithmn does not support that
|
// and the current algorithmn does not support that
|
||||||
//generateSoftwareMipmaps(getPixels());
|
//generateSoftwareMipmaps(getPixels());
|
||||||
logTraceError("non power of 2.");
|
g_logger.traceError("non power of 2.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ TexturePtr TextureManager::getTexture(const std::string& fileName)
|
||||||
g_resources.loadFile(filePath, fin);
|
g_resources.loadFile(filePath, fin);
|
||||||
texture = loadPNG(fin);
|
texture = loadPNG(fin);
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("unable to load texture '%s': %s", fileName, e.what());
|
g_logger.error(stdext::format("unable to load texture '%s': %s", fileName, e.what()));
|
||||||
texture = g_graphics.getEmptyTexture();
|
texture = g_graphics.getEmptyTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -480,7 +480,7 @@ int LuaInterface::protectedCall(int numArgs, int requestedResults)
|
||||||
throw LuaException("attempt to call a non function value", 0);
|
throw LuaException("attempt to call a non function value", 0);
|
||||||
}
|
}
|
||||||
} catch(LuaException &e) {
|
} catch(LuaException &e) {
|
||||||
logError("protected lua call failed: %s", e.what());
|
g_logger.error(stdext::format("protected lua call failed: %s", e.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// pushes nil values if needed
|
// pushes nil values if needed
|
||||||
|
@ -515,7 +515,7 @@ int LuaInterface::luaScriptLoader(lua_State* L)
|
||||||
g_lua.loadScript(fileName);
|
g_lua.loadScript(fileName);
|
||||||
return 1;
|
return 1;
|
||||||
} catch(LuaException& e) {
|
} catch(LuaException& e) {
|
||||||
logError("failed to load script file '%s': %s", fileName, e.what());
|
g_logger.error(stdext::format("failed to load script file '%s': %s", fileName, e.what()));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ int LuaInterface::luaScriptRunner(lua_State* L)
|
||||||
g_lua.call(0, LUA_MULTRET);
|
g_lua.call(0, LUA_MULTRET);
|
||||||
return g_lua.stackSize();
|
return g_lua.stackSize();
|
||||||
} catch(LuaException& e) {
|
} catch(LuaException& e) {
|
||||||
logError("failed to load script file '%s': %s", fileName, e.what());
|
g_logger.error(stdext::format("failed to load script file '%s': %s", fileName, e.what()));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -548,7 +548,7 @@ int LuaInterface::luaScriptsRunner(lua_State* L)
|
||||||
g_lua.loadScript(directory + "/" + fileName);
|
g_lua.loadScript(directory + "/" + fileName);
|
||||||
g_lua.call(0, 0);
|
g_lua.call(0, 0);
|
||||||
} catch(LuaException& e) {
|
} catch(LuaException& e) {
|
||||||
logError("failed to load script file '%s': %s", fileName, e.what());
|
g_logger.error(stdext::format("failed to load script file '%s': %s", fileName, e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -583,7 +583,7 @@ int LuaInterface::luaCppFunctionCallback(lua_State* L)
|
||||||
g_lua.m_cppCallbackDepth--;
|
g_lua.m_cppCallbackDepth--;
|
||||||
assert(numRets == g_lua.stackSize());
|
assert(numRets == g_lua.stackSize());
|
||||||
} catch(LuaException &e) {
|
} catch(LuaException &e) {
|
||||||
logError("lua cpp callback failed: %s", e.what());
|
g_logger.error(stdext::format("lua cpp callback failed: %s", e.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return numRets;
|
return numRets;
|
||||||
|
@ -606,7 +606,7 @@ void LuaInterface::createLuaState()
|
||||||
// creates lua state
|
// creates lua state
|
||||||
L = luaL_newstate();
|
L = luaL_newstate();
|
||||||
if(!L)
|
if(!L)
|
||||||
logFatal("Unable to create lua state");
|
g_logger.fatal("Unable to create lua state");
|
||||||
|
|
||||||
// load lua standard libraries
|
// load lua standard libraries
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
|
@ -779,7 +779,6 @@ void LuaInterface::getStackFunction(int level)
|
||||||
void LuaInterface::getRef(int ref)
|
void LuaInterface::getRef(int ref)
|
||||||
{
|
{
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
|
lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
|
||||||
//logTraceDebug(ref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaInterface::getWeakRef(int weakRef)
|
void LuaInterface::getWeakRef(int weakRef)
|
||||||
|
|
|
@ -205,7 +205,7 @@ bool luavalue_cast(int index, std::function<void(Args...)>& func) {
|
||||||
"did you forget to hold a reference for that function?", 0);
|
"did you forget to hold a reference for that function?", 0);
|
||||||
}
|
}
|
||||||
} catch(LuaException& e) {
|
} catch(LuaException& e) {
|
||||||
logError("lua function callback failed: %s", e.what());
|
g_logger.error(stdext::format("lua function callback failed: %s", e.what()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return true;
|
return true;
|
||||||
|
@ -239,7 +239,7 @@ luavalue_cast(int index, std::function<Ret(Args...)>& func) {
|
||||||
"did you forget to hold a reference for that function?", 0);
|
"did you forget to hold a reference for that function?", 0);
|
||||||
}
|
}
|
||||||
} catch(LuaException& e) {
|
} catch(LuaException& e) {
|
||||||
logError("lua function callback failed: %s", e.what());
|
g_logger.error(stdext::format("lua function callback failed: %s", e.what()));
|
||||||
}
|
}
|
||||||
return Ret();
|
return Ret();
|
||||||
};
|
};
|
||||||
|
|
|
@ -114,26 +114,26 @@ void Protocol::internalRecvData(uint8* buffer, uint16 size)
|
||||||
{
|
{
|
||||||
// process data only if really connected
|
// process data only if really connected
|
||||||
if(!isConnected()) {
|
if(!isConnected()) {
|
||||||
logTraceError("received data while disconnected");
|
g_logger.traceError("received data while disconnected");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_inputMessage->fillBuffer(buffer, size);
|
m_inputMessage->fillBuffer(buffer, size);
|
||||||
|
|
||||||
if(m_checksumEnabled && !m_inputMessage->readChecksum()) {
|
if(m_checksumEnabled && !m_inputMessage->readChecksum()) {
|
||||||
logTraceError("got a network message with invalid checksum");
|
g_logger.traceError("got a network message with invalid checksum");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_xteaEncryptionEnabled) {
|
if(m_xteaEncryptionEnabled) {
|
||||||
if(!xteaDecrypt(m_inputMessage)) {
|
if(!xteaDecrypt(m_inputMessage)) {
|
||||||
logTraceError("failed to decrypt message");
|
g_logger.traceError("failed to decrypt message");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int size = m_inputMessage->getU16();
|
int size = m_inputMessage->getU16();
|
||||||
if(size != m_inputMessage->getUnreadSize()) {
|
if(size != m_inputMessage->getUnreadSize()) {
|
||||||
logTraceError("invalid message size");
|
g_logger.traceError("invalid message size");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ bool Protocol::xteaDecrypt(const InputMessagePtr& inputMessage)
|
||||||
{
|
{
|
||||||
uint16 encryptedSize = inputMessage->getUnreadSize();
|
uint16 encryptedSize = inputMessage->getUnreadSize();
|
||||||
if(encryptedSize % 8 != 0) {
|
if(encryptedSize % 8 != 0) {
|
||||||
logTraceError("invalid encrypted network message");
|
g_logger.traceError("invalid encrypted network message");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ bool Protocol::xteaDecrypt(const InputMessagePtr& inputMessage)
|
||||||
uint16 decryptedSize = inputMessage->getU16() + 2;
|
uint16 decryptedSize = inputMessage->getU16() + 2;
|
||||||
int sizeDelta = decryptedSize - encryptedSize;
|
int sizeDelta = decryptedSize - encryptedSize;
|
||||||
if(sizeDelta > 0 || -sizeDelta > encryptedSize) {
|
if(sizeDelta > 0 || -sizeDelta > encryptedSize) {
|
||||||
logTraceError("invalid decrypted a network message");
|
g_logger.traceError("invalid decrypted a network message");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
void crashHandler(int signum, siginfo_t* info, void* secret)
|
void crashHandler(int signum, siginfo_t* info, void* secret)
|
||||||
{
|
{
|
||||||
logError("Application crashed");
|
g_logger.error("Application crashed");
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << stdext::format("app name: %s\n", g_app->getName());
|
ss << stdext::format("app name: %s\n", g_app->getName());
|
||||||
|
@ -100,7 +100,7 @@ void crashHandler(int signum, siginfo_t* info, void* secret)
|
||||||
free(tracebackBuffer);
|
free(tracebackBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
logInfo(ss.str());
|
g_logger.info(ss.str());
|
||||||
|
|
||||||
std::string fileName = "crash_report.txt";
|
std::string fileName = "crash_report.txt";
|
||||||
std::ofstream fout(fileName.c_str(), std::ios::out | std::ios::app);
|
std::ofstream fout(fileName.c_str(), std::ios::out | std::ios::app);
|
||||||
|
@ -109,9 +109,9 @@ void crashHandler(int signum, siginfo_t* info, void* secret)
|
||||||
fout << ss.str();
|
fout << ss.str();
|
||||||
fout << "\n";
|
fout << "\n";
|
||||||
fout.close();
|
fout.close();
|
||||||
logInfo("Crash report saved to file %s", fileName.c_str());
|
g_logger.info(stdext::format("Crash report saved to file %s", fileName.c_str()));
|
||||||
} else
|
} else
|
||||||
logError("Failed to save crash report!");
|
g_logger.error("Failed to save crash report!");
|
||||||
|
|
||||||
signal(SIGILL, SIG_DFL);
|
signal(SIGILL, SIG_DFL);
|
||||||
signal(SIGSEGV, SIG_DFL);
|
signal(SIGSEGV, SIG_DFL);
|
||||||
|
|
|
@ -124,7 +124,7 @@ LONG CALLBACK ExceptionHandler(LPEXCEPTION_POINTERS e)
|
||||||
SymCleanup(GetCurrentProcess());
|
SymCleanup(GetCurrentProcess());
|
||||||
|
|
||||||
// print in stdout
|
// print in stdout
|
||||||
logInfo(ss.str());
|
g_logger.info(ss.str());
|
||||||
|
|
||||||
// write stacktrace to crash_report.txt
|
// write stacktrace to crash_report.txt
|
||||||
char dir[MAX_PATH];
|
char dir[MAX_PATH];
|
||||||
|
@ -134,9 +134,9 @@ LONG CALLBACK ExceptionHandler(LPEXCEPTION_POINTERS e)
|
||||||
if(fout.is_open() && fout.good()) {
|
if(fout.is_open() && fout.good()) {
|
||||||
fout << ss.str();
|
fout << ss.str();
|
||||||
fout.close();
|
fout.close();
|
||||||
logInfo("Crash report saved to file %s", fileName);
|
g_logger.info("Crash report saved to file %s", fileName);
|
||||||
} else
|
} else
|
||||||
logError("Failed to save crash report!");
|
g_logger.error("Failed to save crash report!");
|
||||||
|
|
||||||
// inform the user
|
// inform the user
|
||||||
std::string msg = stdext::format(
|
std::string msg = stdext::format(
|
||||||
|
|
|
@ -203,15 +203,15 @@ void WIN32Window::terminate()
|
||||||
{
|
{
|
||||||
if(m_glContext) {
|
if(m_glContext) {
|
||||||
if(!wglMakeCurrent(NULL, NULL))
|
if(!wglMakeCurrent(NULL, NULL))
|
||||||
logError("Release of dc and rc failed.");
|
g_logger.error("Release of dc and rc failed.");
|
||||||
if(!wglDeleteContext(m_glContext))
|
if(!wglDeleteContext(m_glContext))
|
||||||
logError("Release rendering context failed.");
|
g_logger.error("Release rendering context failed.");
|
||||||
m_glContext = NULL;
|
m_glContext = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_deviceContext) {
|
if(m_deviceContext) {
|
||||||
if(!ReleaseDC(m_window, m_deviceContext))
|
if(!ReleaseDC(m_window, m_deviceContext))
|
||||||
logError("Release device context failed.");
|
g_logger.error("Release device context failed.");
|
||||||
m_deviceContext = NULL;
|
m_deviceContext = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,13 +222,13 @@ void WIN32Window::terminate()
|
||||||
|
|
||||||
if(m_window) {
|
if(m_window) {
|
||||||
if(!DestroyWindow(m_window))
|
if(!DestroyWindow(m_window))
|
||||||
logError("ERROR: Destroy window failed.");
|
g_logger.error("ERROR: Destroy window failed.");
|
||||||
m_window = NULL;
|
m_window = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_instance) {
|
if(m_instance) {
|
||||||
if(!UnregisterClassA(g_app->getName().c_str(), m_instance))
|
if(!UnregisterClassA(g_app->getName().c_str(), m_instance))
|
||||||
logError("UnregisterClassA failed");
|
g_logger.error("UnregisterClassA failed");
|
||||||
m_instance = NULL;
|
m_instance = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ void WIN32Window::internalRegisterWindowClass()
|
||||||
wc.lpszClassName = g_app->getName().c_str();
|
wc.lpszClassName = g_app->getName().c_str();
|
||||||
|
|
||||||
if(!RegisterClassA(&wc))
|
if(!RegisterClassA(&wc))
|
||||||
logFatal("Failed to register the window class.");
|
g_logger.fatal("Failed to register the window class.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WIN32Window::internalCreateWindow()
|
void WIN32Window::internalCreateWindow()
|
||||||
|
@ -286,13 +286,13 @@ void WIN32Window::internalCreateWindow()
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if(!m_window)
|
if(!m_window)
|
||||||
logFatal("Unable to create window");
|
g_logger.fatal("Unable to create window");
|
||||||
|
|
||||||
ShowWindow(m_window, SW_HIDE);
|
ShowWindow(m_window, SW_HIDE);
|
||||||
|
|
||||||
m_deviceContext = GetDC(m_window);
|
m_deviceContext = GetDC(m_window);
|
||||||
if(!m_deviceContext)
|
if(!m_deviceContext)
|
||||||
logFatal("GetDC failed");
|
g_logger.fatal("GetDC failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WIN32Window::internalChooseGLVisual()
|
void WIN32Window::internalChooseGLVisual()
|
||||||
|
@ -317,20 +317,20 @@ void WIN32Window::internalChooseGLVisual()
|
||||||
|
|
||||||
pixelFormat = ChoosePixelFormat(m_deviceContext, &pfd);
|
pixelFormat = ChoosePixelFormat(m_deviceContext, &pfd);
|
||||||
if(!pixelFormat)
|
if(!pixelFormat)
|
||||||
logFatal("Could not find a suitable pixel format");
|
g_logger.fatal("Could not find a suitable pixel format");
|
||||||
|
|
||||||
pfd.cStencilBits = 8;
|
pfd.cStencilBits = 8;
|
||||||
if(!SetPixelFormat(m_deviceContext, pixelFormat, &pfd))
|
if(!SetPixelFormat(m_deviceContext, pixelFormat, &pfd))
|
||||||
logFatal("Could not set the pixel format");
|
g_logger.fatal("Could not set the pixel format");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WIN32Window::internalCreateGLContext()
|
void WIN32Window::internalCreateGLContext()
|
||||||
{
|
{
|
||||||
if(!(m_glContext = wglCreateContext(m_deviceContext)))
|
if(!(m_glContext = wglCreateContext(m_deviceContext)))
|
||||||
logFatal("Unable to create GL context");
|
g_logger.fatal("Unable to create GL context");
|
||||||
|
|
||||||
if(!wglMakeCurrent(m_deviceContext, m_glContext))
|
if(!wglMakeCurrent(m_deviceContext, m_glContext))
|
||||||
logFatal("Unable to set GLX context on WIN32 window");
|
g_logger.fatal("Unable to set GLX context on WIN32 window");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WIN32Window::isExtensionSupported(const char *ext)
|
bool WIN32Window::isExtensionSupported(const char *ext)
|
||||||
|
@ -679,18 +679,18 @@ void WIN32Window::setMouseCursor(const std::string& file, const Point& hotSpot)
|
||||||
|
|
||||||
apng_data apng;
|
apng_data apng;
|
||||||
if(load_apng(fin, &apng) != 0) {
|
if(load_apng(fin, &apng) != 0) {
|
||||||
logTraceError("unable to load png file %s", file);
|
g_logger.traceError(stdext::format("unable to load png file %s", file));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(apng.bpp != 4) {
|
if(apng.bpp != 4) {
|
||||||
logError("the cursor png must have 4 channels");
|
g_logger.error("the cursor png must have 4 channels");
|
||||||
free_apng(&apng);
|
free_apng(&apng);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(apng.width != 32|| apng.height != 32) {
|
if(apng.width != 32|| apng.height != 32) {
|
||||||
logError("the cursor png must have 32x32 dimension");
|
g_logger.error("the cursor png must have 32x32 dimension");
|
||||||
free_apng(&apng);
|
free_apng(&apng);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -774,7 +774,7 @@ void WIN32Window::setIcon(const std::string& pngIcon)
|
||||||
g_resources.loadFile(pngIcon, fin);
|
g_resources.loadFile(pngIcon, fin);
|
||||||
if(load_apng(fin, &apng) == 0) {
|
if(load_apng(fin, &apng) == 0) {
|
||||||
if(apng.bpp != 4) {
|
if(apng.bpp != 4) {
|
||||||
logError("could not set app icon, icon image must have 4 channels");
|
g_logger.error("could not set app icon, icon image must have 4 channels");
|
||||||
free_apng(&apng);
|
free_apng(&apng);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,7 +807,7 @@ void WIN32Window::setIcon(const std::string& pngIcon)
|
||||||
|
|
||||||
free_apng(&apng);
|
free_apng(&apng);
|
||||||
} else
|
} else
|
||||||
logError("could not load app icon");
|
g_logger.error("could not load app icon");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WIN32Window::setClipboardText(const std::string& text)
|
void WIN32Window::setClipboardText(const std::string& text)
|
||||||
|
|
|
@ -253,7 +253,7 @@ void X11Window::internalOpenDisplay()
|
||||||
{
|
{
|
||||||
m_display = XOpenDisplay(NULL);
|
m_display = XOpenDisplay(NULL);
|
||||||
if(!m_display)
|
if(!m_display)
|
||||||
logFatal("Unable to open X11 display");
|
g_logger.fatal("Unable to open X11 display");
|
||||||
m_screen = DefaultScreen(m_display);
|
m_screen = DefaultScreen(m_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ void X11Window::internalCreateWindow()
|
||||||
m_visible = true;
|
m_visible = true;
|
||||||
|
|
||||||
if(!m_window)
|
if(!m_window)
|
||||||
logFatal("Unable to create X11 window!");
|
g_logger.fatal("Unable to create X11 window!");
|
||||||
|
|
||||||
// ensure window input focus
|
// ensure window input focus
|
||||||
XWMHints hints;
|
XWMHints hints;
|
||||||
|
@ -311,7 +311,7 @@ void X11Window::internalCreateWindow()
|
||||||
XSetWMProtocols(m_display, m_window, &m_wmDelete , 1);
|
XSetWMProtocols(m_display, m_window, &m_wmDelete , 1);
|
||||||
|
|
||||||
if(!internalSetupWindowInput())
|
if(!internalSetupWindowInput())
|
||||||
logWarning("Input of special keys may be messed up, because window input initialization failed");
|
g_logger.warning("Input of special keys may be messed up, because window input initialization failed");
|
||||||
|
|
||||||
internalConnectGLContext();
|
internalConnectGLContext();
|
||||||
}
|
}
|
||||||
|
@ -327,20 +327,20 @@ bool X11Window::internalSetupWindowInput()
|
||||||
|
|
||||||
// create input context (to have better key input handling)
|
// create input context (to have better key input handling)
|
||||||
if(!XSupportsLocale()) {
|
if(!XSupportsLocale()) {
|
||||||
logError("X11 doesn't support the current locale");
|
g_logger.error("X11 doesn't support the current locale");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSetLocaleModifiers("");
|
XSetLocaleModifiers("");
|
||||||
m_xim = XOpenIM(m_display, NULL, NULL, NULL);
|
m_xim = XOpenIM(m_display, NULL, NULL, NULL);
|
||||||
if(!m_xim) {
|
if(!m_xim) {
|
||||||
logError("XOpenIM failed");
|
g_logger.error("XOpenIM failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_xic = XCreateIC(m_xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, m_window, NULL);
|
m_xic = XCreateIC(m_xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, m_window, NULL);
|
||||||
if(!m_xic) {
|
if(!m_xic) {
|
||||||
logError("Unable to create the input context");
|
g_logger.error("Unable to create the input context");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,13 +352,13 @@ void X11Window::internalCheckGL()
|
||||||
#ifdef OPENGL_ES
|
#ifdef OPENGL_ES
|
||||||
m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)m_display);
|
m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)m_display);
|
||||||
if(m_eglDisplay == EGL_NO_DISPLAY)
|
if(m_eglDisplay == EGL_NO_DISPLAY)
|
||||||
logFatal("EGL not supported");
|
g_logger.fatal("EGL not supported");
|
||||||
|
|
||||||
if(!eglInitialize(m_eglDisplay, NULL, NULL))
|
if(!eglInitialize(m_eglDisplay, NULL, NULL))
|
||||||
logFatal("Unable to initialize EGL");
|
g_logger.fatal("Unable to initialize EGL");
|
||||||
#else
|
#else
|
||||||
if(!glXQueryExtension(m_display, NULL, NULL))
|
if(!glXQueryExtension(m_display, NULL, NULL))
|
||||||
logFatal("GLX not supported");
|
g_logger.fatal("GLX not supported");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,10 +377,10 @@ void X11Window::internalChooseGLVisual()
|
||||||
|
|
||||||
EGLint numConfig;
|
EGLint numConfig;
|
||||||
if(!eglChooseConfig(m_eglDisplay, attrList, &m_eglConfig, 1, &numConfig))
|
if(!eglChooseConfig(m_eglDisplay, attrList, &m_eglConfig, 1, &numConfig))
|
||||||
logFatal("Failed to choose EGL config");
|
g_logger.fatal("Failed to choose EGL config");
|
||||||
|
|
||||||
if(numConfig != 1)
|
if(numConfig != 1)
|
||||||
logWarning("Didn't got the exact EGL config");
|
g_logger.warning("Didn't got the exact EGL config");
|
||||||
|
|
||||||
m_rootWindow = DefaultRootWindow(m_display);
|
m_rootWindow = DefaultRootWindow(m_display);
|
||||||
#else
|
#else
|
||||||
|
@ -394,11 +394,11 @@ void X11Window::internalChooseGLVisual()
|
||||||
int nelements;
|
int nelements;
|
||||||
m_fbConfig = glXChooseFBConfig(m_display, m_screen, attrList, &nelements);
|
m_fbConfig = glXChooseFBConfig(m_display, m_screen, attrList, &nelements);
|
||||||
if(!m_fbConfig)
|
if(!m_fbConfig)
|
||||||
logFatal("Couldn't choose RGBA, double buffered fbconfig");
|
g_logger.fatal("Couldn't choose RGBA, double buffered fbconfig");
|
||||||
|
|
||||||
m_visual = glXGetVisualFromFBConfig(m_display, *m_fbConfig);
|
m_visual = glXGetVisualFromFBConfig(m_display, *m_fbConfig);
|
||||||
if(!m_visual)
|
if(!m_visual)
|
||||||
logFatal("Couldn't choose RGBA, double buffered visual");
|
g_logger.fatal("Couldn't choose RGBA, double buffered visual");
|
||||||
|
|
||||||
m_rootWindow = RootWindow(m_display, m_visual->screen);
|
m_rootWindow = RootWindow(m_display, m_visual->screen);
|
||||||
#endif
|
#endif
|
||||||
|
@ -418,15 +418,15 @@ void X11Window::internalCreateGLContext()
|
||||||
|
|
||||||
m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, attrList);
|
m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, attrList);
|
||||||
if(m_eglContext == EGL_NO_CONTEXT )
|
if(m_eglContext == EGL_NO_CONTEXT )
|
||||||
logFatal("Unable to create EGL context: %s", eglGetError());
|
g_logger.fatal("Unable to create EGL context: %s", eglGetError());
|
||||||
#else
|
#else
|
||||||
m_glxContext = glXCreateContext(m_display, m_visual, NULL, True);
|
m_glxContext = glXCreateContext(m_display, m_visual, NULL, True);
|
||||||
|
|
||||||
if(!m_glxContext)
|
if(!m_glxContext)
|
||||||
logFatal("Unable to create GLX context");
|
g_logger.fatal("Unable to create GLX context");
|
||||||
|
|
||||||
if(!glXIsDirect(m_display, m_glxContext))
|
if(!glXIsDirect(m_display, m_glxContext))
|
||||||
logWarning("GL direct rendering is not possible");
|
g_logger.warning("GL direct rendering is not possible");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,12 +459,12 @@ void X11Window::internalConnectGLContext()
|
||||||
#ifdef OPENGL_ES
|
#ifdef OPENGL_ES
|
||||||
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig, m_window, NULL);
|
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig, m_window, NULL);
|
||||||
if(m_eglSurface == EGL_NO_SURFACE)
|
if(m_eglSurface == EGL_NO_SURFACE)
|
||||||
logFatal("Unable to create EGL surface: %s", eglGetError());
|
g_logger.fatal("Unable to create EGL surface: %s", eglGetError());
|
||||||
if(!eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext))
|
if(!eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext))
|
||||||
logFatal("Unable to connect EGL context into X11 window");
|
g_logger.fatal("Unable to connect EGL context into X11 window");
|
||||||
#else
|
#else
|
||||||
if(!glXMakeCurrent(m_display, m_window, m_glxContext))
|
if(!glXMakeCurrent(m_display, m_window, m_glxContext))
|
||||||
logFatal("Unable to set GLX context on X11 window");
|
g_logger.fatal("Unable to set GLX context on X11 window");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +712,7 @@ void X11Window::poll()
|
||||||
break;
|
break;
|
||||||
std::string text = buf;
|
std::string text = buf;
|
||||||
|
|
||||||
//logDebug("char: ", buf[0], " code: ", (int)((uchar)buf[0]));
|
//g_logger.debug("char: ", buf[0], " code: ", (int)((uchar)buf[0]));
|
||||||
|
|
||||||
if(m_onInputEvent && text.length() > 0) {
|
if(m_onInputEvent && text.length() > 0) {
|
||||||
m_inputEvent.reset(Fw::KeyTextInputEvent);
|
m_inputEvent.reset(Fw::KeyTextInputEvent);
|
||||||
|
@ -843,18 +843,18 @@ void X11Window::setMouseCursor(const std::string& file, const Point& hotSpot)
|
||||||
|
|
||||||
apng_data apng;
|
apng_data apng;
|
||||||
if(load_apng(fin, &apng) != 0) {
|
if(load_apng(fin, &apng) != 0) {
|
||||||
logTraceError("unable to load png file %s", file);
|
g_logger.traceError(stdext::format("unable to load png file %s", file));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(apng.bpp != 4) {
|
if(apng.bpp != 4) {
|
||||||
logError("the cursor png must have 4 channels");
|
g_logger.error("the cursor png must have 4 channels");
|
||||||
free_apng(&apng);
|
free_apng(&apng);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(apng.width != 32|| apng.height != 32) {
|
if(apng.width != 32|| apng.height != 32) {
|
||||||
logError("the cursor png must have 32x32 dimension");
|
g_logger.error("the cursor png must have 32x32 dimension");
|
||||||
free_apng(&apng);
|
free_apng(&apng);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -961,12 +961,12 @@ void X11Window::setIcon(const std::string& iconFile)
|
||||||
|
|
||||||
apng_data apng;
|
apng_data apng;
|
||||||
if(load_apng(fin, &apng) != 0) {
|
if(load_apng(fin, &apng) != 0) {
|
||||||
logError("Unable to load window icon");
|
g_logger.error("Unable to load window icon");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(apng.bpp != 4) {
|
if(apng.bpp != 4) {
|
||||||
logError("Could not set window icon, icon image must have 4 channels");
|
g_logger.error("Could not set window icon, icon image must have 4 channels");
|
||||||
free_apng(&apng);
|
free_apng(&apng);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -985,7 +985,7 @@ void X11Window::setIcon(const std::string& iconFile)
|
||||||
|
|
||||||
Atom property = XInternAtom(m_display, "_NET_WM_ICON", 0);
|
Atom property = XInternAtom(m_display, "_NET_WM_ICON", 0);
|
||||||
if(!XChangeProperty(m_display, m_window, property, XA_CARDINAL, 32, PropModeReplace, (const unsigned char*)&iconData[0], iconData.size()))
|
if(!XChangeProperty(m_display, m_window, property, XA_CARDINAL, 32, PropModeReplace, (const unsigned char*)&iconData[0], iconData.size()))
|
||||||
logError("Couldn't set app icon");
|
g_logger.error("Couldn't set app icon");
|
||||||
|
|
||||||
free_apng(&apng);
|
free_apng(&apng);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ bool OggSoundFile::prepareOgg()
|
||||||
|
|
||||||
vorbis_info* vi = ov_info(&m_vorbisFile, -1);
|
vorbis_info* vi = ov_info(&m_vorbisFile, -1);
|
||||||
if(!vi) {
|
if(!vi) {
|
||||||
logError("ogg file not supported: %s", m_file->name());
|
g_logger.error(stdext::format("ogg file not supported: %s", m_file->name()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,14 +40,14 @@ bool SoundBuffer::fillBuffer(const SoundFilePtr& soundFile)
|
||||||
{
|
{
|
||||||
ALenum format = soundFile->getSampleFormat();
|
ALenum format = soundFile->getSampleFormat();
|
||||||
if(format == AL_UNDETERMINED) {
|
if(format == AL_UNDETERMINED) {
|
||||||
logError("unable to determine sample format for '%s'", soundFile->getName());
|
g_logger.error(stdext::format("unable to determine sample format for '%s'", soundFile->getName()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataBuffer<char> samples(soundFile->getSize());
|
DataBuffer<char> samples(soundFile->getSize());
|
||||||
int read = soundFile->read(&samples[0], soundFile->getSize());
|
int read = soundFile->read(&samples[0], soundFile->getSize());
|
||||||
if(read <= 0) {
|
if(read <= 0) {
|
||||||
logError("unable to fill audio buffer data for '%s'", soundFile->getName());
|
g_logger.error(stdext::format("unable to fill audio buffer data for '%s'", soundFile->getName()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ bool SoundBuffer::fillBuffer(ALenum sampleFormat, const DataBuffer<char>& data,
|
||||||
alBufferData(m_bufferId, sampleFormat, &data[0], size, rate);
|
alBufferData(m_bufferId, sampleFormat, &data[0], size, rate);
|
||||||
ALenum err = alGetError();
|
ALenum err = alGetError();
|
||||||
if(err != AL_NO_ERROR) {
|
if(err != AL_NO_ERROR) {
|
||||||
logError("unable to fill audio buffer data: %s", alGetString(err));
|
g_logger.error(stdext::format("unable to fill audio buffer data: %s", alGetString(err)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -33,7 +33,7 @@ SoundFilePtr SoundFile::loadSoundFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
FileStreamPtr file = g_resources.openFile(filename);
|
FileStreamPtr file = g_resources.openFile(filename);
|
||||||
if(!file) {
|
if(!file) {
|
||||||
logTraceError("unable to open %s", filename);
|
g_logger.traceError(stdext::format("unable to open %s", filename));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ SoundFilePtr SoundFile::loadSoundFile(const std::string& filename)
|
||||||
if(oggSoundFile->prepareOgg())
|
if(oggSoundFile->prepareOgg())
|
||||||
soundFile = oggSoundFile;
|
soundFile = oggSoundFile;
|
||||||
} else
|
} else
|
||||||
logError("unknown sound file format %s", filename);
|
g_logger.error(stdext::format("unknown sound file format %s", filename));
|
||||||
|
|
||||||
return soundFile;
|
return soundFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,13 +36,13 @@ void SoundManager::init()
|
||||||
{
|
{
|
||||||
m_device = alcOpenDevice(NULL);
|
m_device = alcOpenDevice(NULL);
|
||||||
if(!m_device) {
|
if(!m_device) {
|
||||||
logError("unable to open audio device");
|
g_logger.error("unable to open audio device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_context = alcCreateContext(m_device, NULL);
|
m_context = alcCreateContext(m_device, NULL);
|
||||||
if(!m_context) {
|
if(!m_context) {
|
||||||
logError("unable to create audio context: %s", alcGetString(m_device, alcGetError(m_device)));
|
g_logger.error(stdext::format("unable to create audio context: %s", alcGetString(m_device, alcGetError(m_device))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
alcMakeContextCurrent(m_context);
|
alcMakeContextCurrent(m_context);
|
||||||
|
@ -136,7 +136,7 @@ void SoundManager::play(const std::string& filename)
|
||||||
|
|
||||||
SoundSourcePtr soundSource = createSoundSource(filename);
|
SoundSourcePtr soundSource = createSoundSource(filename);
|
||||||
if(!soundSource) {
|
if(!soundSource) {
|
||||||
logError("unable to play '%s'", filename);
|
g_logger.error(stdext::format("unable to play '%s'", filename));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ void SoundManager::playMusic(const std::string& filename, float fadetime)
|
||||||
|
|
||||||
m_musicSource = createSoundSource(filename);
|
m_musicSource = createSoundSource(filename);
|
||||||
if(!m_musicSource) {
|
if(!m_musicSource) {
|
||||||
logError("unable to play '%s'", filename);
|
g_logger.error(stdext::format("unable to play '%s'", filename));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ SoundSourcePtr SoundManager::createSoundSource(const std::string& filename)
|
||||||
buffer->fillBuffer(soundFile);
|
buffer->fillBuffer(soundFile);
|
||||||
source->setBuffer(buffer);
|
source->setBuffer(buffer);
|
||||||
m_buffers[filename] = buffer;
|
m_buffers[filename] = buffer;
|
||||||
logWarning("uncached sound '%s' requested to be played", filename);
|
g_logger.warning(stdext::format("uncached sound '%s' requested to be played", filename));
|
||||||
} else {
|
} else {
|
||||||
StreamSoundSourcePtr streamSource(new StreamSoundSource);
|
StreamSoundSourcePtr streamSource(new StreamSoundSource);
|
||||||
streamSource->setSoundFile(soundFile);
|
streamSource->setSoundFile(soundFile);
|
||||||
|
|
|
@ -46,7 +46,7 @@ void StreamSoundSource::setSoundFile(const SoundFilePtr& soundFile)
|
||||||
void StreamSoundSource::play()
|
void StreamSoundSource::play()
|
||||||
{
|
{
|
||||||
if(!m_soundFile) {
|
if(!m_soundFile) {
|
||||||
logError("there is not sound file to play the stream");
|
g_logger.error("there is not sound file to play the stream");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ void StreamSoundSource::update()
|
||||||
if(processed == 0 || !m_looping)
|
if(processed == 0 || !m_looping)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
logTraceError("restarting audio source because of buffer underrun");
|
g_logger.traceError("restarting audio source because of buffer underrun");
|
||||||
play();
|
play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,12 +143,12 @@ bool StreamSoundSource::fillBufferAndQueue(ALuint buffer)
|
||||||
alBufferData(buffer, format, &bufferData[0], bytesRead, m_soundFile->getRate());
|
alBufferData(buffer, format, &bufferData[0], bytesRead, m_soundFile->getRate());
|
||||||
ALenum err = alGetError();
|
ALenum err = alGetError();
|
||||||
if(err != AL_NO_ERROR)
|
if(err != AL_NO_ERROR)
|
||||||
logError("unable to refill audio buffer for '%s': %s", m_soundFile->getName(), alGetString(err));
|
g_logger.error(stdext::format("unable to refill audio buffer for '%s': %s", m_soundFile->getName(), alGetString(err)));
|
||||||
|
|
||||||
alSourceQueueBuffers(m_sourceId, 1, &buffer);
|
alSourceQueueBuffers(m_sourceId, 1, &buffer);
|
||||||
err = alGetError();
|
err = alGetError();
|
||||||
if(err != AL_NO_ERROR)
|
if(err != AL_NO_ERROR)
|
||||||
logError("unable to queue audio buffer for '%s': %s", m_soundFile->getName(), alGetString(err));
|
g_logger.error(stdext::format("unable to queue audio buffer for '%s': %s", m_soundFile->getName(), alGetString(err)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// return false if there aren't more buffers to fill
|
// return false if there aren't more buffers to fill
|
||||||
|
@ -158,12 +158,12 @@ bool StreamSoundSource::fillBufferAndQueue(ALuint buffer)
|
||||||
void StreamSoundSource::downMix(StreamSoundSource::DownMix downMix)
|
void StreamSoundSource::downMix(StreamSoundSource::DownMix downMix)
|
||||||
{
|
{
|
||||||
if(!m_soundFile) {
|
if(!m_soundFile) {
|
||||||
logError("down mix must be set after setting a sound file");
|
g_logger.error("down mix must be set after setting a sound file");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_soundFile->getSampleFormat() != AL_FORMAT_STEREO16) {
|
if(m_soundFile->getSampleFormat() != AL_FORMAT_STEREO16) {
|
||||||
logError("can only downmix 16 bit stereo audio files");
|
g_logger.error("can only downmix 16 bit stereo audio files");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ bool UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anch
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(first == widget) {
|
if(first == widget) {
|
||||||
logError("child '%s' of parent widget '%s' is recursively anchored to itself, please fix this", widget->getId(), parentWidget->getId());
|
g_logger.error(stdext::format("child '%s' of parent widget '%s' is recursively anchored to itself, please fix this", widget->getId(), parentWidget->getId()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef UIFRAMECOUNTER_H
|
|
||||||
#define UIFRAMECOUNTER_H
|
|
||||||
|
|
||||||
#include "uiwidget.h"
|
|
||||||
|
|
||||||
class UIFrameCounter : public UIWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
UIFrameCounter();
|
|
||||||
void drawSelf();
|
|
||||||
|
|
||||||
void setAlign(Fw::AlignmentFlag align) { m_align = align; }
|
|
||||||
Fw::AlignmentFlag getAlign() { return m_align; }
|
|
||||||
int getFrameCount() { return m_frameCount; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Fw::AlignmentFlag m_align;
|
|
||||||
int m_frameCount;
|
|
||||||
ticks_t m_lastFrameTicks;
|
|
||||||
std::string m_fpsText;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -286,7 +286,7 @@ void UIManager::onWidgetDestroy(const UIWidgetPtr& widget)
|
||||||
g_lua.collectGarbage();
|
g_lua.collectGarbage();
|
||||||
for(const UIWidgetPtr& widget : backupList) {
|
for(const UIWidgetPtr& widget : backupList) {
|
||||||
if(widget->getUseCount() != 1)
|
if(widget->getUseCount() != 1)
|
||||||
logWarning("widget '%s' destroyed but still have %d reference(s) left", widget->getId(), widget->getUseCount()-1);
|
g_logger.warning(stdext::format("widget '%s' destroyed but still have %d reference(s) left", widget->getId(), widget->getUseCount()-1));
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -302,7 +302,7 @@ bool UIManager::importStyle(const std::string& file)
|
||||||
importStyleFromOTML(styleNode);
|
importStyleFromOTML(styleNode);
|
||||||
return true;
|
return true;
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("Failed to import UI styles from '%s': %s", file, e.what());
|
g_logger.error(stdext::format("Failed to import UI styles from '%s': %s", file, e.what()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ void UIManager::importStyleFromOTML(const OTMLNodePtr& styleNode)
|
||||||
/*
|
/*
|
||||||
auto it = m_styles.find(name);
|
auto it = m_styles.find(name);
|
||||||
if(it != m_styles.end())
|
if(it != m_styles.end())
|
||||||
logWarning("style '%s' is being redefined", name);
|
g_logger.warning("style '%s' is being redefined", name);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
OTMLNodePtr originalStyle = getStyle(base);
|
OTMLNodePtr originalStyle = getStyle(base);
|
||||||
|
@ -383,7 +383,7 @@ UIWidgetPtr UIManager::loadUI(const std::string& file, const UIWidgetPtr& parent
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("failed to load UI from '%s': %s", file, e.what());
|
g_logger.error(stdext::format("failed to load UI from '%s': %s", file, e.what()));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ UIWidgetPtr UIManager::createWidgetFromStyle(const std::string& styleName, const
|
||||||
try {
|
try {
|
||||||
return createWidgetFromOTML(node, parent);
|
return createWidgetFromOTML(node, parent);
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("failed to create widget from style '%s': %s", styleName, e.what());
|
g_logger.error(stdext::format("failed to create widget from style '%s': %s", styleName, e.what()));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ UIWidget::~UIWidget()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if(!m_destroyed)
|
if(!m_destroyed)
|
||||||
logWarning("widget '%s' was not explicitly destroyed", m_id);
|
g_logger.warning(stdext::format("widget '%s' was not explicitly destroyed", m_id));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,17 +123,17 @@ void UIWidget::drawChildren(const Rect& visibleRect, bool foregroundPane)
|
||||||
void UIWidget::addChild(const UIWidgetPtr& child)
|
void UIWidget::addChild(const UIWidgetPtr& child)
|
||||||
{
|
{
|
||||||
if(!child) {
|
if(!child) {
|
||||||
logWarning("attempt to add a null child into a UIWidget");
|
g_logger.warning("attempt to add a null child into a UIWidget");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(child->isDestroyed()) {
|
if(child->isDestroyed()) {
|
||||||
logWarning("attemp to add a destroyed child into a UIWidget");
|
g_logger.warning("attemp to add a destroyed child into a UIWidget");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasChild(child)) {
|
if(hasChild(child)) {
|
||||||
logWarning("attempt to add a child again into a UIWidget");
|
g_logger.warning("attempt to add a child again into a UIWidget");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,19 +164,19 @@ void UIWidget::addChild(const UIWidgetPtr& child)
|
||||||
void UIWidget::insertChild(int index, const UIWidgetPtr& child)
|
void UIWidget::insertChild(int index, const UIWidgetPtr& child)
|
||||||
{
|
{
|
||||||
if(!child) {
|
if(!child) {
|
||||||
logWarning("attempt to insert a null child into a UIWidget");
|
g_logger.warning("attempt to insert a null child into a UIWidget");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasChild(child)) {
|
if(hasChild(child)) {
|
||||||
logWarning("attempt to insert a child again into a UIWidget");
|
g_logger.warning("attempt to insert a child again into a UIWidget");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
index = index <= 0 ? (m_children.size() + index) : index-1;
|
index = index <= 0 ? (m_children.size() + index) : index-1;
|
||||||
|
|
||||||
if(!(index >= 0 && (uint)index <= m_children.size())) {
|
if(!(index >= 0 && (uint)index <= m_children.size())) {
|
||||||
logTraceError("attemp to insert a child in an invalid index");
|
g_logger.traceError("attemp to insert a child in an invalid index");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ void UIWidget::removeChild(UIWidgetPtr child)
|
||||||
|
|
||||||
g_ui.onWidgetDisappear(child);
|
g_ui.onWidgetDisappear(child);
|
||||||
} else
|
} else
|
||||||
logError("attempt to remove an unknown child from a UIWidget");
|
g_logger.error("attempt to remove an unknown child from a UIWidget");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ void UIWidget::focusChild(const UIWidgetPtr& child, Fw::FocusReason reason)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(child && !hasChild(child)) {
|
if(child && !hasChild(child)) {
|
||||||
logError("attempt to focus an unknown child in a UIWidget");
|
g_logger.error("attempt to focus an unknown child in a UIWidget");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ void UIWidget::lowerChild(UIWidgetPtr child)
|
||||||
// remove and push child again
|
// remove and push child again
|
||||||
auto it = std::find(m_children.begin(), m_children.end(), child);
|
auto it = std::find(m_children.begin(), m_children.end(), child);
|
||||||
if(it == m_children.end()) {
|
if(it == m_children.end()) {
|
||||||
logTraceError("cannot find child");
|
g_logger.traceError("cannot find child");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ void UIWidget::raiseChild(UIWidgetPtr child)
|
||||||
// remove and push child again
|
// remove and push child again
|
||||||
auto it = std::find(m_children.begin(), m_children.end(), child);
|
auto it = std::find(m_children.begin(), m_children.end(), child);
|
||||||
if(it == m_children.end()) {
|
if(it == m_children.end()) {
|
||||||
logTraceError("cannot find child");
|
g_logger.traceError("cannot find child");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_children.erase(it);
|
m_children.erase(it);
|
||||||
|
@ -377,7 +377,7 @@ void UIWidget::moveChildToIndex(const UIWidgetPtr& child, int index)
|
||||||
// remove and push child again
|
// remove and push child again
|
||||||
auto it = std::find(m_children.begin(), m_children.end(), child);
|
auto it = std::find(m_children.begin(), m_children.end(), child);
|
||||||
if(it == m_children.end()) {
|
if(it == m_children.end()) {
|
||||||
logTraceError("cannot find child");
|
g_logger.traceError("cannot find child");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_children.erase(it);
|
m_children.erase(it);
|
||||||
|
@ -394,7 +394,7 @@ void UIWidget::lockChild(const UIWidgetPtr& child)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!hasChild(child)) {
|
if(!hasChild(child)) {
|
||||||
logTraceError("cannot find child");
|
g_logger.traceError("cannot find child");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ void UIWidget::unlockChild(const UIWidgetPtr& child)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!hasChild(child)) {
|
if(!hasChild(child)) {
|
||||||
logTraceError("cannot find child");
|
g_logger.traceError("cannot find child");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,7 +504,7 @@ void UIWidget::applyStyle(const OTMLNodePtr& styleNode)
|
||||||
}
|
}
|
||||||
m_firstOnStyle = false;
|
m_firstOnStyle = false;
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("failed to apply style to widget '%s': %s", m_id, e.what());
|
g_logger.error(stdext::format("failed to apply style to widget '%s': %s", m_id, e.what()));
|
||||||
}
|
}
|
||||||
m_loadingStyle = false;
|
m_loadingStyle = false;
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ void UIWidget::addAnchor(Fw::AnchorEdge anchoredEdge, const std::string& hookedW
|
||||||
if(UIAnchorLayoutPtr anchorLayout = getAnchoredLayout())
|
if(UIAnchorLayoutPtr anchorLayout = getAnchoredLayout())
|
||||||
anchorLayout->addAnchor(asUIWidget(), anchoredEdge, hookedWidgetId, hookedEdge);
|
anchorLayout->addAnchor(asUIWidget(), anchoredEdge, hookedWidgetId, hookedEdge);
|
||||||
else
|
else
|
||||||
logError("cannot add anchors to widget '%s': the parent doesn't use anchors layout", m_id);
|
g_logger.error(stdext::format("cannot add anchors to widget '%s': the parent doesn't use anchors layout", m_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIWidget::removeAnchor(Fw::AnchorEdge anchoredEdge)
|
void UIWidget::removeAnchor(Fw::AnchorEdge anchoredEdge)
|
||||||
|
@ -534,7 +534,7 @@ void UIWidget::centerIn(const std::string& hookedWidgetId)
|
||||||
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorHorizontalCenter, hookedWidgetId, Fw::AnchorHorizontalCenter);
|
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorHorizontalCenter, hookedWidgetId, Fw::AnchorHorizontalCenter);
|
||||||
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorVerticalCenter, hookedWidgetId, Fw::AnchorVerticalCenter);
|
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorVerticalCenter, hookedWidgetId, Fw::AnchorVerticalCenter);
|
||||||
} else
|
} else
|
||||||
logError("cannot add anchors to widget '%s': the parent doesn't use anchors layout", m_id);
|
g_logger.error(stdext::format("cannot add anchors to widget '%s': the parent doesn't use anchors layout", m_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIWidget::fill(const std::string& hookedWidgetId)
|
void UIWidget::fill(const std::string& hookedWidgetId)
|
||||||
|
@ -548,7 +548,7 @@ void UIWidget::fill(const std::string& hookedWidgetId)
|
||||||
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorTop, hookedWidgetId, Fw::AnchorTop);
|
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorTop, hookedWidgetId, Fw::AnchorTop);
|
||||||
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorBottom, hookedWidgetId, Fw::AnchorBottom);
|
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorBottom, hookedWidgetId, Fw::AnchorBottom);
|
||||||
} else
|
} else
|
||||||
logError("cannot add anchors to widget '%s': the parent doesn't use anchors layout", m_id);
|
g_logger.error(stdext::format("cannot add anchors to widget '%s': the parent doesn't use anchors layout", m_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIWidget::breakAnchors()
|
void UIWidget::breakAnchors()
|
||||||
|
@ -714,7 +714,7 @@ void UIWidget::internalDestroy()
|
||||||
void UIWidget::destroy()
|
void UIWidget::destroy()
|
||||||
{
|
{
|
||||||
if(m_destroyed)
|
if(m_destroyed)
|
||||||
logWarning("attempt to destroy widget '%s' two times", m_id);
|
g_logger.warning(stdext::format("attempt to destroy widget '%s' two times", m_id));
|
||||||
|
|
||||||
// hold itself reference
|
// hold itself reference
|
||||||
UIWidgetPtr self = asUIWidget();
|
UIWidgetPtr self = asUIWidget();
|
||||||
|
@ -803,7 +803,7 @@ void UIWidget::setLayout(const UILayoutPtr& layout)
|
||||||
bool UIWidget::setRect(const Rect& rect)
|
bool UIWidget::setRect(const Rect& rect)
|
||||||
{
|
{
|
||||||
if(rect.width() > 8192 || rect.height() > 8192) {
|
if(rect.width() > 8192 || rect.height() > 8192) {
|
||||||
logError("attempt to set huge rect size (%s) for %s", stdext::to_string(rect), m_id);
|
g_logger.error(stdext::format("attempt to set huge rect size (%s) for %s", stdext::to_string(rect), m_id));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// only update if the rect really changed
|
// only update if the rect really changed
|
||||||
|
@ -835,7 +835,7 @@ void UIWidget::setStyle(const std::string& styleName)
|
||||||
{
|
{
|
||||||
OTMLNodePtr styleNode = g_ui.getStyle(styleName);
|
OTMLNodePtr styleNode = g_ui.getStyle(styleName);
|
||||||
if(!styleNode) {
|
if(!styleNode) {
|
||||||
logTraceError("unable to retrieve style '%s': not a defined style", styleName);
|
g_logger.traceError(stdext::format("unable to retrieve style '%s': not a defined style", styleName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
styleNode = styleNode->clone();
|
styleNode = styleNode->clone();
|
||||||
|
|
|
@ -59,7 +59,7 @@ void Container::addItems(const std::vector<ItemPtr>& items)
|
||||||
void Container::updateItem(int slot, const ItemPtr& item)
|
void Container::updateItem(int slot, const ItemPtr& item)
|
||||||
{
|
{
|
||||||
if(slot < 0 || slot >= (int)m_items.size()) {
|
if(slot < 0 || slot >= (int)m_items.size()) {
|
||||||
logTraceError("slot not found");
|
g_logger.traceError("slot not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ void Container::updateItem(int slot, const ItemPtr& item)
|
||||||
void Container::removeItem(int slot)
|
void Container::removeItem(int slot)
|
||||||
{
|
{
|
||||||
if(slot < 0 || slot >= (int)m_items.size()) {
|
if(slot < 0 || slot >= (int)m_items.size()) {
|
||||||
logTraceError("slot not found");
|
g_logger.traceError("slot not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,7 @@ void Game::processCloseContainer(int containerId)
|
||||||
{
|
{
|
||||||
ContainerPtr container = getContainer(containerId);
|
ContainerPtr container = getContainer(containerId);
|
||||||
if(!container) {
|
if(!container) {
|
||||||
logTraceError("container not found");
|
g_logger.traceError("container not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ void Game::processContainerAddItem(int containerId, const ItemPtr& item)
|
||||||
{
|
{
|
||||||
ContainerPtr container = getContainer(containerId);
|
ContainerPtr container = getContainer(containerId);
|
||||||
if(!container) {
|
if(!container) {
|
||||||
logTraceError("container not found");
|
g_logger.traceError("container not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ void Game::processContainerUpdateItem(int containerId, int slot, const ItemPtr&
|
||||||
{
|
{
|
||||||
ContainerPtr container = getContainer(containerId);
|
ContainerPtr container = getContainer(containerId);
|
||||||
if(!container) {
|
if(!container) {
|
||||||
logTraceError("container not found");
|
g_logger.traceError("container not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ void Game::processContainerRemoveItem(int containerId, int slot)
|
||||||
{
|
{
|
||||||
ContainerPtr container = getContainer(containerId);
|
ContainerPtr container = getContainer(containerId);
|
||||||
if(!container) {
|
if(!container) {
|
||||||
logTraceError("container not found");
|
g_logger.traceError("container not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ void Game::processWalkCancel(Otc::Direction direction)
|
||||||
void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName)
|
void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName)
|
||||||
{
|
{
|
||||||
if(m_protocolGame || isOnline()) {
|
if(m_protocolGame || isOnline()) {
|
||||||
logTraceError("unable to login into a world while already online or logging");
|
g_logger.traceError("unable to login into a world while already online or logging");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1002,7 +1002,7 @@ bool Game::checkBotProtection()
|
||||||
// accepts calls comming from a stacktrace containing only C++ functions,
|
// accepts calls comming from a stacktrace containing only C++ functions,
|
||||||
// if the stacktrace contains a lua function, then only accept if the engine is processing an input event
|
// if the stacktrace contains a lua function, then only accept if the engine is processing an input event
|
||||||
if(g_lua.isInCppCallback() && !g_app->isOnInputEvent() && m_denyBotCall) {
|
if(g_lua.isInCppCallback() && !g_app->isOnInputEvent() && m_denyBotCall) {
|
||||||
logError(g_lua.traceback("caught a lua call to a bot protected game function, the call was canceled"));
|
g_logger.error(g_lua.traceback("caught a lua call to a bot protected game function, the call was canceled"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1022,7 +1022,7 @@ bool Game::canPerformGameAction()
|
||||||
void Game::setClientVersion(int clientVersion)
|
void Game::setClientVersion(int clientVersion)
|
||||||
{
|
{
|
||||||
if(isOnline()) {
|
if(isOnline()) {
|
||||||
logError("Unable to change client version while online");
|
g_logger.error("Unable to change client version while online");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ ItemPtr Item::create(int id)
|
||||||
{
|
{
|
||||||
ItemPtr item = ItemPtr(new Item);
|
ItemPtr item = ItemPtr(new Item);
|
||||||
if(id < g_thingsType.getFirstItemId() || id > g_thingsType.getMaxItemid())
|
if(id < g_thingsType.getFirstItemId() || id > g_thingsType.getMaxItemid())
|
||||||
logTraceError("invalid item id %d", id);
|
g_logger.traceError(stdext::format("invalid item id %d", id));
|
||||||
else {
|
else {
|
||||||
item->setId(id);
|
item->setId(id);
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ void Item::draw(const Point& dest, float scaleFactor, bool animate)
|
||||||
void Item::setId(uint32 id)
|
void Item::setId(uint32 id)
|
||||||
{
|
{
|
||||||
if(id < g_thingsType.getFirstItemId() || id > g_thingsType.getMaxItemid()) {
|
if(id < g_thingsType.getFirstItemId() || id > g_thingsType.getMaxItemid()) {
|
||||||
logTraceError("invalid item id %d", id);
|
g_logger.traceError(stdext::format("invalid item id %d", id));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_id = id;
|
m_id = id;
|
||||||
|
|
|
@ -413,7 +413,7 @@ void MapView::updateGeometry(const Size& visibleDimension, const Size& optimized
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tileSize == 0) {
|
if(tileSize == 0) {
|
||||||
logTraceError("reached max zoom out");
|
g_logger.traceError("reached max zoom out");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,12 +478,12 @@ void MapView::setVisibleDimension(const Size& visibleDimension)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(visibleDimension.width() % 2 != 1 || visibleDimension.height() % 2 != 1) {
|
if(visibleDimension.width() % 2 != 1 || visibleDimension.height() % 2 != 1) {
|
||||||
logTraceError("visible dimension must be odd");
|
g_logger.traceError("visible dimension must be odd");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(visibleDimension < Size(3,3)) {
|
if(visibleDimension < Size(3,3)) {
|
||||||
logTraceError("reach max zoom in");
|
g_logger.traceError("reach max zoom in");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ bool SpriteManager::load(const std::string& file)
|
||||||
m_loaded = true;
|
m_loaded = true;
|
||||||
return true;
|
return true;
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("Failed to load sprites from '%s': %s", file, e.what());
|
g_logger.error(stdext::format("Failed to load sprites from '%s': %s", file, e.what()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ ImagePtr SpriteManager::getSpriteImage(int id)
|
||||||
uint16 coloredPixels = m_spritesFile->getU16();
|
uint16 coloredPixels = m_spritesFile->getU16();
|
||||||
|
|
||||||
if(writePos + transparentPixels*4 + coloredPixels*3 >= SPRITE_DATA_SIZE) {
|
if(writePos + transparentPixels*4 + coloredPixels*3 >= SPRITE_DATA_SIZE) {
|
||||||
logWarning("corrupt sprite id %d", id);
|
g_logger.warning(stdext::format("corrupt sprite id %d", id));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ void StaticText::compose()
|
||||||
text += " says:\n";
|
text += " says:\n";
|
||||||
m_color = Color(95, 247, 247);
|
m_color = Color(95, 247, 247);
|
||||||
} else {
|
} else {
|
||||||
logWarning("Unknown speak type: %d", m_messageType);
|
g_logger.warning(stdext::format("Unknown speak type: %d", m_messageType));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint i = 0; i < m_messages.size(); ++i) {
|
for(uint i = 0; i < m_messages.size(); ++i) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ int Thing::getStackpos()
|
||||||
else if(const TilePtr& tile = getTile())
|
else if(const TilePtr& tile = getTile())
|
||||||
return tile->getThingStackpos(asThing());
|
return tile->getThingStackpos(asThing());
|
||||||
else {
|
else {
|
||||||
logTraceError("got a thing with invalid stackpos");
|
g_logger.traceError("got a thing with invalid stackpos");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ bool ThingsType::load(const std::string& file)
|
||||||
{
|
{
|
||||||
FileStreamPtr fin = g_resources.openFile(file);
|
FileStreamPtr fin = g_resources.openFile(file);
|
||||||
if(!fin) {
|
if(!fin) {
|
||||||
logError("unable to open dat file '%s'", file);
|
g_logger.error(stdext::format("unable to open dat file '%s'", file));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ bool ThingsType::load(const std::string& file)
|
||||||
for(int id = 0; id < numThings[i]; ++id) {
|
for(int id = 0; id < numThings[i]; ++id) {
|
||||||
m_things[i][id].m_category = i;
|
m_things[i][id].m_category = i;
|
||||||
if(!parseThingType(fin, m_things[i][id])) {
|
if(!parseThingType(fin, m_things[i][id])) {
|
||||||
logError("corrupt or dat file");
|
g_logger.error("corrupt or dat file");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,7 +475,7 @@ namespace Proto {
|
||||||
case Proto::ServerSpeakBroadcast: return Otc::SpeakBroadcast;
|
case Proto::ServerSpeakBroadcast: return Otc::SpeakBroadcast;
|
||||||
case Proto::ServerSpeakPrivateRedTo: return Otc::SpeakPrivateRed;
|
case Proto::ServerSpeakPrivateRedTo: return Otc::SpeakPrivateRed;
|
||||||
default:
|
default:
|
||||||
logError("unknown protocol speak type %d", type);
|
g_logger.error(stdext::format("unknown protocol speak type %d", type));
|
||||||
return Otc::SpeakSay;
|
return Otc::SpeakSay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -497,7 +497,7 @@ namespace Proto {
|
||||||
case Otc::SpeakMonsterSay: return Proto::ServerSpeakMonsterSay;
|
case Otc::SpeakMonsterSay: return Proto::ServerSpeakMonsterSay;
|
||||||
case Otc::SpeakMonsterYell: return Proto::ServerSpeakMonsterYell;
|
case Otc::SpeakMonsterYell: return Proto::ServerSpeakMonsterYell;
|
||||||
default:
|
default:
|
||||||
logError("unknown protocol speak type desc %d", type);
|
g_logger.error(stdext::format("unknown protocol speak type desc %d", type));
|
||||||
return Proto::ServerSpeakSay;
|
return Proto::ServerSpeakSay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,7 +515,7 @@ namespace Proto {
|
||||||
case Proto::MessageConsoleBlue: return "consoleBlue";
|
case Proto::MessageConsoleBlue: return "consoleBlue";
|
||||||
case Proto::MessageConsoleRed: return "consoleRed";
|
case Proto::MessageConsoleRed: return "consoleRed";
|
||||||
default:
|
default:
|
||||||
logError("unknown protocol text message type %d", type);
|
g_logger.error(stdext::format("unknown protocol text message type %d", type));
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(!m_gameInitialized && opcode > Proto::GameServerFirstGameOpcode)
|
if(!m_gameInitialized && opcode > Proto::GameServerFirstGameOpcode)
|
||||||
logWarning("received a game opcode from the server, but the game is not initialized yet, this is a server side bug");
|
g_logger.warning("received a game opcode from the server, but the game is not initialized yet, this is a server side bug");
|
||||||
|
|
||||||
switch(opcode) {
|
switch(opcode) {
|
||||||
case Proto::GameServerInitGame:
|
case Proto::GameServerInitGame:
|
||||||
|
@ -319,8 +319,8 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg)
|
||||||
prevOpcode = opcode;
|
prevOpcode = opcode;
|
||||||
}
|
}
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("Network exception (%d bytes unread, last opcode is %d, prev opcode is %d): %s",
|
g_logger.error(stdext::format("Network exception (%d bytes unread, last opcode is %d, prev opcode is %d): %s",
|
||||||
msg->getUnreadSize(), opcode, prevOpcode, e.what());
|
msg->getUnreadSize(), opcode, prevOpcode, e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +476,7 @@ void ProtocolGame::parseTileTransformThing(const InputMessagePtr& msg)
|
||||||
ThingPtr thing = getThing(msg);
|
ThingPtr thing = getThing(msg);
|
||||||
if(thing) {
|
if(thing) {
|
||||||
if(!g_map.removeThingByPos(pos, stackPos))
|
if(!g_map.removeThingByPos(pos, stackPos))
|
||||||
logTraceError("could not remove thing");
|
g_logger.traceError("could not remove thing");
|
||||||
g_map.addThing(thing, pos, stackPos);
|
g_map.addThing(thing, pos, stackPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -487,7 +487,7 @@ void ProtocolGame::parseTileRemoveThing(const InputMessagePtr& msg)
|
||||||
int stackPos = msg->getU8();
|
int stackPos = msg->getU8();
|
||||||
|
|
||||||
if(!g_map.removeThingByPos(pos, stackPos))
|
if(!g_map.removeThingByPos(pos, stackPos))
|
||||||
logTraceError("could not remove thing");
|
g_logger.traceError("could not remove thing");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg)
|
void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg)
|
||||||
|
@ -498,19 +498,19 @@ void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg)
|
||||||
|
|
||||||
ThingPtr thing = g_map.getThing(oldPos, oldStackpos);
|
ThingPtr thing = g_map.getThing(oldPos, oldStackpos);
|
||||||
if(!thing) {
|
if(!thing) {
|
||||||
logTraceError("could not get thing");
|
g_logger.traceError("could not get thing");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreaturePtr creature = thing->asCreature();
|
CreaturePtr creature = thing->asCreature();
|
||||||
if(!creature) {
|
if(!creature) {
|
||||||
logTraceError("thing is not a creature");
|
g_logger.traceError("thing is not a creature");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update map tiles
|
// update map tiles
|
||||||
if(!g_map.removeThing(thing))
|
if(!g_map.removeThing(thing))
|
||||||
logTraceError("could not remove thing");
|
g_logger.traceError("could not remove thing");
|
||||||
g_map.addThing(thing, newPos);
|
g_map.addThing(thing, newPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,7 +699,7 @@ void ProtocolGame::parseCreatureMark(const InputMessagePtr& msg)
|
||||||
if(creature)
|
if(creature)
|
||||||
creature->addTimedSquare(color);
|
creature->addTimedSquare(color);
|
||||||
else
|
else
|
||||||
logTraceError("could not get creature");
|
g_logger.traceError("could not get creature");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseTrappers(const InputMessagePtr& msg)
|
void ProtocolGame::parseTrappers(const InputMessagePtr& msg)
|
||||||
|
@ -707,7 +707,7 @@ void ProtocolGame::parseTrappers(const InputMessagePtr& msg)
|
||||||
int numTrappers = msg->getU8();
|
int numTrappers = msg->getU8();
|
||||||
|
|
||||||
if(numTrappers > 8)
|
if(numTrappers > 8)
|
||||||
logTraceError("too many trappers");
|
g_logger.traceError("too many trappers");
|
||||||
|
|
||||||
for(int i=0;i<numTrappers;++i) {
|
for(int i=0;i<numTrappers;++i) {
|
||||||
uint id = msg->getU32();
|
uint id = msg->getU32();
|
||||||
|
@ -715,7 +715,7 @@ void ProtocolGame::parseTrappers(const InputMessagePtr& msg)
|
||||||
if(creature) {
|
if(creature) {
|
||||||
//TODO: set creature as trapper
|
//TODO: set creature as trapper
|
||||||
} else
|
} else
|
||||||
logTraceError("could not get creature");
|
g_logger.traceError("could not get creature");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,7 +728,7 @@ void ProtocolGame::parseCreatureHealth(const InputMessagePtr& msg)
|
||||||
if(creature)
|
if(creature)
|
||||||
creature->setHealthPercent(healthPercent);
|
creature->setHealthPercent(healthPercent);
|
||||||
else
|
else
|
||||||
logTraceError("could not get creature");
|
g_logger.traceError("could not get creature");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseCreatureLight(const InputMessagePtr& msg)
|
void ProtocolGame::parseCreatureLight(const InputMessagePtr& msg)
|
||||||
|
@ -743,7 +743,7 @@ void ProtocolGame::parseCreatureLight(const InputMessagePtr& msg)
|
||||||
if(creature)
|
if(creature)
|
||||||
creature->setLight(light);
|
creature->setLight(light);
|
||||||
else
|
else
|
||||||
logTraceError("could not get creature");
|
g_logger.traceError("could not get creature");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseCreatureOutfit(const InputMessagePtr& msg)
|
void ProtocolGame::parseCreatureOutfit(const InputMessagePtr& msg)
|
||||||
|
@ -755,7 +755,7 @@ void ProtocolGame::parseCreatureOutfit(const InputMessagePtr& msg)
|
||||||
if(creature)
|
if(creature)
|
||||||
creature->setOutfit(outfit);
|
creature->setOutfit(outfit);
|
||||||
else
|
else
|
||||||
logTraceError("could not get creature");
|
g_logger.traceError("could not get creature");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseCreatureSpeed(const InputMessagePtr& msg)
|
void ProtocolGame::parseCreatureSpeed(const InputMessagePtr& msg)
|
||||||
|
@ -767,7 +767,7 @@ void ProtocolGame::parseCreatureSpeed(const InputMessagePtr& msg)
|
||||||
if(creature)
|
if(creature)
|
||||||
creature->setSpeed(speed);
|
creature->setSpeed(speed);
|
||||||
else
|
else
|
||||||
logTraceError("could not get creature");
|
g_logger.traceError("could not get creature");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseCreatureSkulls(const InputMessagePtr& msg)
|
void ProtocolGame::parseCreatureSkulls(const InputMessagePtr& msg)
|
||||||
|
@ -779,7 +779,7 @@ void ProtocolGame::parseCreatureSkulls(const InputMessagePtr& msg)
|
||||||
if(creature)
|
if(creature)
|
||||||
creature->setSkull(skull);
|
creature->setSkull(skull);
|
||||||
else
|
else
|
||||||
logTraceError("could not get creature");
|
g_logger.traceError("could not get creature");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseCreatureShields(const InputMessagePtr& msg)
|
void ProtocolGame::parseCreatureShields(const InputMessagePtr& msg)
|
||||||
|
@ -791,7 +791,7 @@ void ProtocolGame::parseCreatureShields(const InputMessagePtr& msg)
|
||||||
if(creature)
|
if(creature)
|
||||||
creature->setShield(shield);
|
creature->setShield(shield);
|
||||||
else
|
else
|
||||||
logTraceError("could not get creature");
|
g_logger.traceError("could not get creature");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseCreatureUnpass(const InputMessagePtr& msg)
|
void ProtocolGame::parseCreatureUnpass(const InputMessagePtr& msg)
|
||||||
|
@ -803,7 +803,7 @@ void ProtocolGame::parseCreatureUnpass(const InputMessagePtr& msg)
|
||||||
if(creature)
|
if(creature)
|
||||||
creature->setPassable(!unpass);
|
creature->setPassable(!unpass);
|
||||||
else
|
else
|
||||||
logTraceError("could not get creature");
|
g_logger.traceError("could not get creature");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseEditText(const InputMessagePtr& msg)
|
void ProtocolGame::parseEditText(const InputMessagePtr& msg)
|
||||||
|
@ -1238,7 +1238,7 @@ void ProtocolGame::parseExtendedOpcode(const InputMessagePtr& msg)
|
||||||
try {
|
try {
|
||||||
callLuaField("onExtendedOpcode", opcode, buffer);
|
callLuaField("onExtendedOpcode", opcode, buffer);
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logError("Network exception in extended opcode %d: %s", opcode, e.what());
|
g_logger.error(stdext::format("Network exception in extended opcode %d: %s", opcode, e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1304,7 +1304,7 @@ void ProtocolGame::setTileDescription(const InputMessagePtr& msg, Position posit
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(stackPos >= 10)
|
if(stackPos >= 10)
|
||||||
logTraceError("too many things, stackpos=%d, pos=%s", stackPos, stdext::to_string(position));
|
g_logger.traceError(stdext::format("too many things, stackpos=%d, pos=%s", stackPos, stdext::to_string(position)));
|
||||||
|
|
||||||
ThingPtr thing = getThing(msg);
|
ThingPtr thing = getThing(msg);
|
||||||
g_map.addThing(thing, position, -1);
|
g_map.addThing(thing, position, -1);
|
||||||
|
@ -1380,7 +1380,7 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
|
||||||
uint id = msg->getU32();
|
uint id = msg->getU32();
|
||||||
creature = g_map.getCreatureById(id);
|
creature = g_map.getCreatureById(id);
|
||||||
if(!creature)
|
if(!creature)
|
||||||
logTraceError("server said that a creature is known, but it's not");
|
g_logger.traceError("server said that a creature is known, but it's not");
|
||||||
} else {
|
} else {
|
||||||
uint removeId = msg->getU32();
|
uint removeId = msg->getU32();
|
||||||
g_map.removeCreatureById(removeId);
|
g_map.removeCreatureById(removeId);
|
||||||
|
@ -1414,7 +1414,7 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
|
||||||
else if(creatureType == Proto::CreatureTypeNpc)
|
else if(creatureType == Proto::CreatureTypeNpc)
|
||||||
creature = NpcPtr(new Npc);
|
creature = NpcPtr(new Npc);
|
||||||
else
|
else
|
||||||
logTraceError("creature type is invalid");
|
g_logger.traceError("creature type is invalid");
|
||||||
|
|
||||||
if(creature) {
|
if(creature) {
|
||||||
creature->setId(id);
|
creature->setId(id);
|
||||||
|
@ -1467,7 +1467,7 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type)
|
||||||
creature = g_map.getCreatureById(id);
|
creature = g_map.getCreatureById(id);
|
||||||
|
|
||||||
if(!creature)
|
if(!creature)
|
||||||
logTraceError("invalid creature");
|
g_logger.traceError("invalid creature");
|
||||||
|
|
||||||
Otc::Direction direction = (Otc::Direction)msg->getU8();
|
Otc::Direction direction = (Otc::Direction)msg->getU8();
|
||||||
if(creature)
|
if(creature)
|
||||||
|
|
|
@ -40,7 +40,7 @@ void ProtocolGame::sendExtendedOpcode(uint8 opcode, const std::string& buffer)
|
||||||
msg->addString(buffer);
|
msg->addString(buffer);
|
||||||
safeSend(msg);
|
safeSend(msg);
|
||||||
} else {
|
} else {
|
||||||
logError("Unable to send extended opcode %d, extended opcodes are not enabled", opcode);
|
g_logger.error(stdext::format("Unable to send extended opcode %d, extended opcodes are not enabled", opcode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ void ProtocolLogin::onRecv(const InputMessagePtr& msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(stdext::exception& e) {
|
} catch(stdext::exception& e) {
|
||||||
logTraceError(e.what());
|
g_logger.error(stdext::format("Network exception in login protocol: %s", e.what()));
|
||||||
}
|
}
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,15 +72,15 @@ void OTClient::init(const std::vector<std::string>& args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logInfo(
|
g_logger.info(stdext::format(
|
||||||
"%s %s (rev %s) built on %s",
|
"%s %s (rev %s) built on %s",
|
||||||
Otc::AppName,
|
Otc::AppName,
|
||||||
Otc::AppVersion,
|
Otc::AppVersion,
|
||||||
BUILD_REVISION,
|
BUILD_REVISION,
|
||||||
BUILD_DATE);
|
BUILD_DATE));
|
||||||
|
|
||||||
if(startupOptions.length() > 0)
|
if(startupOptions.length() > 0)
|
||||||
logInfo("Startup options: %s", startupOptions);
|
g_logger.info(stdext::format("Startup options: %s", startupOptions));
|
||||||
|
|
||||||
g_logger.setLogFile(stdext::format("%s.txt", Otc::AppCompactName));
|
g_logger.setLogFile(stdext::format("%s.txt", Otc::AppCompactName));
|
||||||
Application::init(args);
|
Application::init(args);
|
||||||
|
@ -104,7 +104,7 @@ void OTClient::init(const std::vector<std::string>& args)
|
||||||
try {
|
try {
|
||||||
g_lua.runScript("/otclientrc.lua");
|
g_lua.runScript("/otclientrc.lua");
|
||||||
} catch(LuaException& e) {
|
} catch(LuaException& e) {
|
||||||
logError("failed to load otclientrc.lua: %s", e.what());
|
g_logger.error(stdext::format("failed to load otclientrc.lua: %s", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue