Added Version::DEVELOPMENT_BUILD to check for development build

dev
Tomasz Kapuściński 2023-08-09 16:40:18 +02:00
parent beb29333d5
commit 550193e570
6 changed files with 38 additions and 24 deletions

View File

@ -43,9 +43,9 @@
#include <windows.h> #include <windows.h>
#endif #endif
#include <filesystem>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <boost/filesystem.hpp>
/** /**
\mainpage \mainpage
@ -116,12 +116,17 @@ int main(int argc, char *argv[])
// Add file output to the logger // Add file output to the logger
std::string logFileName; std::string logFileName;
#if DEV_BUILD
if constexpr (Version::DEVELOPMENT_BUILD)
{
logFileName = "log.txt"; logFileName = "log.txt";
#else }
boost::filesystem::create_directories(systemUtils->GetSaveDir()); else
{
std::filesystem::create_directories(systemUtils->GetSaveDir());
logFileName = systemUtils->GetSaveDir() + "/log.txt"; logFileName = systemUtils->GetSaveDir() + "/log.txt";
#endif }
FILE* logFile = fopen(logFileName.c_str(), "w"); FILE* logFile = fopen(logFileName.c_str(), "w");
if (logFile) if (logFile)
logger.AddOutput(logFile); logger.AddOutput(logFile);

View File

@ -15,6 +15,12 @@ else()
set(OFFICIAL_COLOBOT_BUILD "false") set(OFFICIAL_COLOBOT_BUILD "false")
endif() endif()
if(DEV_BUILD)
set(DEVELOPMENT_COLOBOT_BUILD "true")
else()
set(DEVELOPMENT_COLOBOT_BUILD "false")
endif()
# Configure file # Configure file
configure_file(common/config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/common/config.h") configure_file(common/config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/common/config.h")
configure_file(common/version.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/common/version.h") configure_file(common/version.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/common/version.h")

View File

@ -19,16 +19,15 @@
#include "common/logger.h" #include "common/logger.h"
#include "common/version.h"
#include <stdio.h> #include <stdio.h>
CLogger::CLogger() CLogger::CLogger()
{ {
#if DEV_BUILD m_logLevel = Version::DEVELOPMENT_BUILD
m_logLevel = LOG_DEBUG; ? LOG_DEBUG
#else : LOG_INFO;
m_logLevel = LOG_INFO;
#endif
} }
CLogger::~CLogger() CLogger::~CLogger()

View File

@ -5,6 +5,7 @@
namespace Version namespace Version
{ {
static inline constexpr bool OFFICIAL_BUILD = @OFFICIAL_COLOBOT_BUILD@; static inline constexpr bool OFFICIAL_BUILD = @OFFICIAL_COLOBOT_BUILD@;
static inline constexpr bool DEVELOPMENT_BUILD = @DEVELOPMENT_COLOBOT_BUILD@;
static inline constexpr int BUILD_NUMBER = @BUILD_NUMBER@; static inline constexpr int BUILD_NUMBER = @BUILD_NUMBER@;
static inline constexpr std::string_view FULL_NAME = "Colobot: Gold Edition @COLOBOT_VERSION_FULL@"; static inline constexpr std::string_view FULL_NAME = "Colobot: Gold Edition @COLOBOT_VERSION_FULL@";

View File

@ -31,6 +31,7 @@
#include "common/config_file.h" #include "common/config_file.h"
#include "common/image.h" #include "common/image.h"
#include "common/logger.h" #include "common/logger.h"
#include "common/version.h"
#include "graphics/core/light.h" #include "graphics/core/light.h"
#include "graphics/core/material.h" #include "graphics/core/material.h"
@ -277,9 +278,8 @@ void CGL33Device::BeginScene()
void CGL33Device::EndScene() void CGL33Device::EndScene()
{ {
#ifdef DEV_BUILD if constexpr (Version::DEVELOPMENT_BUILD)
CheckGLErrors(); CheckGLErrors();
#endif
} }
void CGL33Device::Clear() void CGL33Device::Clear()

View File

@ -31,6 +31,7 @@
#include "common/restext.h" #include "common/restext.h"
#include "common/settings.h" #include "common/settings.h"
#include "common/stringutils.h" #include "common/stringutils.h"
#include "common/version.h"
#include "common/resources/inputstream.h" #include "common/resources/inputstream.h"
#include "common/resources/outputstream.h" #include "common/resources/outputstream.h"
@ -217,11 +218,7 @@ CRobotMain::CRobotMain()
m_teamNames.clear(); m_teamNames.clear();
#if DEV_BUILD m_cheatAllMission = Version::DEVELOPMENT_BUILD; // for development
m_cheatAllMission = true; // for development
#else
m_cheatAllMission = false;
#endif
m_cheatRadar = false; m_cheatRadar = false;
m_fixScene = false; m_fixScene = false;
@ -3425,10 +3422,13 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
float objectProgress = static_cast<float>(rankObj) / static_cast<float>(numObjects); float objectProgress = static_cast<float>(rankObj) / static_cast<float>(numObjects);
std::string details = StrUtils::ToString<int>(rankObj+1)+" / "+StrUtils::ToString<int>(numObjects); std::string details = StrUtils::ToString<int>(rankObj+1)+" / "+StrUtils::ToString<int>(numObjects);
#if DEV_BUILD
// Object categories may spoil the level a bit, so hide them in release builds // Object categories may spoil the level a bit, so hide them in release builds
details += ": "+CLevelParserParam::FromObjectType(params.type); if constexpr (Version::DEVELOPMENT_BUILD)
#endif {
details += ": " + CLevelParserParam::FromObjectType(params.type);
}
m_ui->GetLoadingScreen()->SetProgress(0.25f+objectProgress*0.75f, RT_LOADING_OBJECTS, details); m_ui->GetLoadingScreen()->SetProgress(0.25f+objectProgress*0.75f, RT_LOADING_OBJECTS, details);
try try
@ -4843,10 +4843,13 @@ CObject* CRobotMain::IOReadObject(CLevelParserLine *line, const std::string& pro
params.id = line->GetParam("id")->AsInt(); params.id = line->GetParam("id")->AsInt();
std::string details = objCounterText; std::string details = objCounterText;
#if DEV_BUILD
// Object categories may spoil the level a bit, so hide them in release builds // Object categories may spoil the level a bit, so hide them in release builds
details += ": "+CLevelParserParam::FromObjectType(params.type); if constexpr (Version::DEVELOPMENT_BUILD)
#endif {
details += ": " + CLevelParserParam::FromObjectType(params.type);
}
m_ui->GetLoadingScreen()->SetProgress(0.25f+objectProgress*0.7f, RT_LOADING_OBJECTS_SAVED, details); m_ui->GetLoadingScreen()->SetProgress(0.25f+objectProgress*0.7f, RT_LOADING_OBJECTS_SAVED, details);
CObject* obj = m_objMan->CreateObject(params); CObject* obj = m_objMan->CreateObject(params);