- bugfix, threaded logging was NOT ever enabled because of a timing bug. Now threaded logging is enabled by default.
- Updated debug UI view to show threaded debug buffer count
This commit is contained in:
parent
da1adab808
commit
d997e2af5d
|
@ -1594,7 +1594,10 @@ void Game::render2d(){
|
||||||
str+= "Render FPS: " + intToStr(lastRenderFps) + "[" + intToStr(avgRenderFps) + "]\n";
|
str+= "Render FPS: " + intToStr(lastRenderFps) + "[" + intToStr(avgRenderFps) + "]\n";
|
||||||
str+= "Update FPS: " + intToStr(lastUpdateFps) + "[" + intToStr(avgUpdateFps) + "]\n";
|
str+= "Update FPS: " + intToStr(lastUpdateFps) + "[" + intToStr(avgUpdateFps) + "]\n";
|
||||||
str+= "GameCamera pos: " + floatToStr(gameCamera.getPos().x)+","+floatToStr(gameCamera.getPos().y)+","+floatToStr(gameCamera.getPos().z)+"\n";
|
str+= "GameCamera pos: " + floatToStr(gameCamera.getPos().x)+","+floatToStr(gameCamera.getPos().y)+","+floatToStr(gameCamera.getPos().z)+"\n";
|
||||||
str+= "Time: " + floatToStr(world.getTimeFlow()->getTime(),8)+"\n";
|
str+= "Time: " + floatToStr(world.getTimeFlow()->getTime(),2)+"\n";
|
||||||
|
if(SystemFlags::getThreadedLoggerRunning() == true) {
|
||||||
|
str+= "Log buffer count: " + intToStr(SystemFlags::getLogEntryBufferCount())+"\n";
|
||||||
|
}
|
||||||
str+= "Triangle count: " + intToStr(renderer.getTriangleCount())+"\n";
|
str+= "Triangle count: " + intToStr(renderer.getTriangleCount())+"\n";
|
||||||
str+= "Vertex count: " + intToStr(renderer.getPointCount())+"\n";
|
str+= "Vertex count: " + intToStr(renderer.getPointCount())+"\n";
|
||||||
str+= "Frame count:" + intToStr(world.getFrameCount())+"\n";
|
str+= "Frame count:" + intToStr(world.getFrameCount())+"\n";
|
||||||
|
@ -1648,7 +1651,7 @@ void Game::render2d(){
|
||||||
|
|
||||||
renderer.renderText(factionInfo, coreData.getMenuFontBig(),
|
renderer.renderText(factionInfo, coreData.getMenuFontBig(),
|
||||||
Vec4f(playerColor.x,playerColor.y,playerColor.z,1.0),
|
Vec4f(playerColor.x,playerColor.y,playerColor.z,1.0),
|
||||||
10, metrics.getVirtualH() - mh - 60 - 210 - (i * 16), false);
|
10, metrics.getVirtualH() - mh - 90 - 210 - (i * 16), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(renderer.getAllowRenderUnitTitles() == false) {
|
if(renderer.getAllowRenderUnitTitles() == false) {
|
||||||
|
@ -1694,19 +1697,18 @@ void Game::render2d(){
|
||||||
|
|
||||||
// ==================== misc ====================
|
// ==================== misc ====================
|
||||||
|
|
||||||
void Game::checkWinner(){
|
void Game::checkWinner() {
|
||||||
if(!gameOver){
|
if(gameOver == false) {
|
||||||
if(gameSettings.getDefaultVictoryConditions()){
|
if(gameSettings.getDefaultVictoryConditions()) {
|
||||||
checkWinnerStandard();
|
checkWinnerStandard();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
checkWinnerScripted();
|
checkWinnerScripted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::checkWinnerStandard(){
|
void Game::checkWinnerStandard() {
|
||||||
if(world.getThisFaction()->getType()->getPersonalityType() == fpt_Observer) {
|
if(world.getThisFaction()->getType()->getPersonalityType() == fpt_Observer) {
|
||||||
// lookup int is team #, value is players alive on team
|
// lookup int is team #, value is players alive on team
|
||||||
std::map<int,int> teamsAlive;
|
std::map<int,int> teamsAlive;
|
||||||
|
@ -1854,16 +1856,16 @@ void Game::checkWinnerScripted() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Game::hasBuilding(const Faction *faction){
|
bool Game::hasBuilding(const Faction *faction) {
|
||||||
for(int i=0; i<faction->getUnitCount(); ++i){
|
for(int i=0; i<faction->getUnitCount(); ++i) {
|
||||||
if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)){
|
if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::incSpeed(){
|
void Game::incSpeed() {
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
switch(speed){
|
switch(speed){
|
||||||
case sSlow:
|
case sSlow:
|
||||||
|
@ -1879,7 +1881,7 @@ void Game::incSpeed(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::decSpeed(){
|
void Game::decSpeed() {
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
switch(speed){
|
switch(speed){
|
||||||
case sNormal:
|
case sNormal:
|
||||||
|
@ -1895,20 +1897,20 @@ void Game::decSpeed(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Game::getUpdateLoops(){
|
int Game::getUpdateLoops() {
|
||||||
if(paused){
|
if(paused) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(speed==sFast){
|
else if(speed == sFast) {
|
||||||
return Config::getInstance().getInt("FastSpeedLoops");
|
return Config::getInstance().getInt("FastSpeedLoops");
|
||||||
}
|
}
|
||||||
else if(speed==sSlow){
|
else if(speed == sSlow) {
|
||||||
return updateFps % 2 == 0? 1: 0;
|
return updateFps % 2 == 0? 1: 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::showLoseMessageBox(){
|
void Game::showLoseMessageBox() {
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
|
|
|
@ -622,7 +622,7 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int glestMain(int argc, char** argv) {
|
int glestMain(int argc, char** argv) {
|
||||||
#ifdef SL_LEAK_DUMP
|
#ifdef SL_LEAK_DUMP
|
||||||
AllocRegistry memoryLeaks = AllocRegistry::getInstance();
|
AllocRegistry memoryLeaks = AllocRegistry::getInstance();
|
||||||
#endif
|
#endif
|
||||||
|
@ -778,12 +778,20 @@ int glestMain(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("In MAIN STARTUP A\n");
|
||||||
|
|
||||||
std::auto_ptr<FileCRCPreCacheThread> preCacheThread;
|
std::auto_ptr<FileCRCPreCacheThread> preCacheThread;
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
|
||||||
|
//printf("In MAIN STARTUP B\n");
|
||||||
|
|
||||||
|
SystemFlags::ENABLE_THREADED_LOGGING = config.getBool("ThreadedLogging","true");
|
||||||
|
|
||||||
|
//printf("In MAIN STARTUP C, SystemFlags::ENABLE_THREADED_LOGGING = %d\n",SystemFlags::ENABLE_THREADED_LOGGING);
|
||||||
|
|
||||||
FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str()));
|
FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str()));
|
||||||
Socket::isUPNP = !config.getBool("DisableUPNP","false");
|
Socket::isUPNP = !config.getBool("DisableUPNP","false");
|
||||||
SystemFlags::ENABLE_THREADED_LOGGING = config.getBool("ThreadedLogging","false");
|
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@ public:
|
||||||
LogFileThread();
|
LogFileThread();
|
||||||
virtual void execute();
|
virtual void execute();
|
||||||
void addLogEntry(SystemFlags::DebugType type, string logEntry);
|
void addLogEntry(SystemFlags::DebugType type, string logEntry);
|
||||||
|
std::size_t getLogEntryBufferCount();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,9 @@ public:
|
||||||
static CURL *initHTTP();
|
static CURL *initHTTP();
|
||||||
static void cleanupHTTP(CURL **handle);
|
static void cleanupHTTP(CURL **handle);
|
||||||
|
|
||||||
|
static bool getThreadedLoggerRunning();
|
||||||
|
static std::size_t getLogEntryBufferCount();
|
||||||
|
|
||||||
// Let the macro call into this when require.. NEVER call it automatically.
|
// Let the macro call into this when require.. NEVER call it automatically.
|
||||||
static void handleDebug(DebugType type, const char *fmt, ...);
|
static void handleDebug(DebugType type, const char *fmt, ...);
|
||||||
static void logDebugEntry(DebugType type, string debugEntry, time_t debugTime);
|
static void logDebugEntry(DebugType type, string debugEntry, time_t debugTime);
|
||||||
|
|
|
@ -217,7 +217,7 @@ void LogFileThread::execute() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for(;this->getQuitStatus() == false;) {
|
for(;this->getQuitStatus() == false;) {
|
||||||
if(difftime(time(NULL),lastSaveToDisk) >= 3) {
|
if(difftime(time(NULL),lastSaveToDisk) >= 5) {
|
||||||
lastSaveToDisk = time(NULL);
|
lastSaveToDisk = time(NULL);
|
||||||
saveToDisk();
|
saveToDisk();
|
||||||
}
|
}
|
||||||
|
@ -244,9 +244,16 @@ void LogFileThread::execute() {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] LogFile thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] LogFile thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t LogFileThread::getLogEntryBufferCount() {
|
||||||
|
MutexSafeWrapper safeMutex(&mutexLogList);
|
||||||
|
std::size_t logCount = logList.size();
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
return logCount;
|
||||||
|
}
|
||||||
|
|
||||||
void LogFileThread::saveToDisk() {
|
void LogFileThread::saveToDisk() {
|
||||||
MutexSafeWrapper safeMutex(&mutexLogList);
|
MutexSafeWrapper safeMutex(&mutexLogList);
|
||||||
unsigned int logCount = logList.size();
|
std::size_t logCount = logList.size();
|
||||||
if(logCount > 0) {
|
if(logCount > 0) {
|
||||||
vector<LogFileEntry> tempLogList = logList;
|
vector<LogFileEntry> tempLogList = logList;
|
||||||
safeMutex.ReleaseLock(true);
|
safeMutex.ReleaseLock(true);
|
||||||
|
|
|
@ -61,6 +61,18 @@ static void *myrealloc(void *ptr, size_t size)
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SystemFlags::getThreadedLoggerRunning() {
|
||||||
|
return (threadLogger != NULL && threadLogger->getRunningStatus() == true);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::size_t SystemFlags::getLogEntryBufferCount() {
|
||||||
|
std::size_t ret = 0;
|
||||||
|
if(threadLogger != NULL) {
|
||||||
|
ret = threadLogger->getLogEntryBufferCount();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
size_t SystemFlags::httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
|
size_t SystemFlags::httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
|
||||||
{
|
{
|
||||||
size_t realsize = size * nmemb;
|
size_t realsize = size * nmemb;
|
||||||
|
@ -159,6 +171,8 @@ CURL *SystemFlags::initHTTP() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemFlags::init(bool haveSpecialOutputCommandLineOption) {
|
void SystemFlags::init(bool haveSpecialOutputCommandLineOption) {
|
||||||
|
//printf("SystemFlags::init CALLED, SystemFlags::debugLogFileList.size() = %d\n",SystemFlags::debugLogFileList.size());
|
||||||
|
|
||||||
SystemFlags::haveSpecialOutputCommandLineOption = haveSpecialOutputCommandLineOption;
|
SystemFlags::haveSpecialOutputCommandLineOption = haveSpecialOutputCommandLineOption;
|
||||||
if(SystemFlags::debugLogFileList.size() == 0) {
|
if(SystemFlags::debugLogFileList.size() == 0) {
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem);
|
SystemFlags::debugLogFileList[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem);
|
||||||
|
@ -168,13 +182,14 @@ void SystemFlags::init(bool haveSpecialOutputCommandLineOption) {
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugUnitCommands] = SystemFlags::SystemFlagsType(SystemFlags::debugUnitCommands);
|
SystemFlags::debugLogFileList[SystemFlags::debugUnitCommands] = SystemFlags::SystemFlagsType(SystemFlags::debugUnitCommands);
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugLUA] = SystemFlags::SystemFlagsType(SystemFlags::debugLUA);
|
SystemFlags::debugLogFileList[SystemFlags::debugLUA] = SystemFlags::SystemFlagsType(SystemFlags::debugLUA);
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugError] = SystemFlags::SystemFlagsType(SystemFlags::debugError);
|
SystemFlags::debugLogFileList[SystemFlags::debugError] = SystemFlags::SystemFlagsType(SystemFlags::debugError);
|
||||||
|
|
||||||
if(SystemFlags::ENABLE_THREADED_LOGGING) {
|
|
||||||
threadLogger = new LogFileThread();
|
|
||||||
threadLogger->start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(threadLogger == NULL) {
|
||||||
|
threadLogger = new LogFileThread();
|
||||||
|
threadLogger->start();
|
||||||
|
sleep(5);
|
||||||
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(curl_handle == NULL) {
|
if(curl_handle == NULL) {
|
||||||
|
@ -224,14 +239,12 @@ SystemFlags::~SystemFlags() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemFlags::Close() {
|
void SystemFlags::Close() {
|
||||||
if(SystemFlags::ENABLE_THREADED_LOGGING) {
|
if(threadLogger != NULL) {
|
||||||
if(threadLogger != NULL) {
|
SystemFlags::ENABLE_THREADED_LOGGING = false;
|
||||||
SystemFlags::ENABLE_THREADED_LOGGING = false;
|
threadLogger->signalQuit();
|
||||||
threadLogger->signalQuit();
|
threadLogger->shutdownAndWait();
|
||||||
threadLogger->shutdownAndWait();
|
delete threadLogger;
|
||||||
delete threadLogger;
|
threadLogger = NULL;
|
||||||
threadLogger = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::debugLogFileList.size() > 0) {
|
if(SystemFlags::debugLogFileList.size() > 0) {
|
||||||
|
@ -285,7 +298,8 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
||||||
va_end(argList);
|
va_end(argList);
|
||||||
|
|
||||||
if(SystemFlags::ENABLE_THREADED_LOGGING &&
|
if(SystemFlags::ENABLE_THREADED_LOGGING &&
|
||||||
threadLogger != NULL) {
|
threadLogger != NULL &&
|
||||||
|
threadLogger->getRunningStatus() == true) {
|
||||||
threadLogger->addLogEntry(type, szBuf);
|
threadLogger->addLogEntry(type, szBuf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue