Preprocessor purge round 16: DEBUG
This commit is contained in:
parent
f0ffa2eeb1
commit
f7478422a4
@ -331,7 +331,7 @@ conf_data.set('BETA', is_beta ? 'true' : 'false')
|
||||
conf_data.set('INSTALL_CHECK', get_option('install_check') ? 'true' : 'false')
|
||||
conf_data.set('IGNORE_UPDATES', get_option('ignore_updates') ? 'true' : 'false')
|
||||
conf_data.set('MOD_ID', mod_id)
|
||||
conf_data.set('DEBUG', is_debug)
|
||||
conf_data.set('DEBUG', is_debug ? 'true' : 'false')
|
||||
conf_data.set('SNAPSHOT', is_snapshot ? 'true' : 'false')
|
||||
conf_data.set('MOD', is_mod ? 'true' : 'false')
|
||||
conf_data.set('SNAPSHOT_ID', get_option('snapshot_id'))
|
||||
|
@ -2,12 +2,12 @@
|
||||
#include <cstdint>
|
||||
|
||||
// Boolean macros (defined / not defined), would be great to get rid of them all.
|
||||
#mesondefine DEBUG
|
||||
#mesondefine LIN
|
||||
#mesondefine AND
|
||||
#mesondefine WIN
|
||||
#mesondefine MACOSX
|
||||
|
||||
constexpr bool DEBUG = @DEBUG@;
|
||||
constexpr bool X86 = @X86@;
|
||||
constexpr bool BETA = @BETA@;
|
||||
constexpr bool SNAPSHOT = @SNAPSHOT@;
|
||||
|
@ -15,7 +15,8 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef MACOSX
|
||||
# include "common/macosx.h"
|
||||
# include <mach-o/dyld.h>
|
||||
# include <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
#include <SDL.h>
|
||||
|
||||
@ -299,9 +300,10 @@ void EventProcess(SDL_Event event)
|
||||
engine->onMouseClick(event.motion.x, event.motion.y, mouseButton);
|
||||
|
||||
mouseDown = true;
|
||||
#if !defined(NDEBUG) && !defined(DEBUG)
|
||||
SDL_CaptureMouse(SDL_TRUE);
|
||||
#endif
|
||||
if constexpr (!DEBUG)
|
||||
{
|
||||
SDL_CaptureMouse(SDL_TRUE);
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
// if mouse hasn't moved yet, sdl will send 0,0. We don't want that
|
||||
@ -314,9 +316,10 @@ void EventProcess(SDL_Event event)
|
||||
engine->onMouseUnclick(mousex, mousey, mouseButton);
|
||||
|
||||
mouseDown = false;
|
||||
#if !defined(NDEBUG) && !defined(DEBUG)
|
||||
SDL_CaptureMouse(SDL_FALSE);
|
||||
#endif
|
||||
if constexpr (!DEBUG)
|
||||
{
|
||||
SDL_CaptureMouse(SDL_FALSE);
|
||||
}
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
@ -418,9 +421,10 @@ void EngineProcess()
|
||||
showDoubleScreenDialog = false;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
std::cout << "Breaking out of EngineProcess" << std::endl;
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
std::cout << "Breaking out of EngineProcess" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
|
@ -7,7 +7,8 @@
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
#ifdef WIN
|
||||
#include <direct.h>
|
||||
# include <direct.h>
|
||||
# include <crtdbg.h>
|
||||
#endif
|
||||
#include <SDL.h>
|
||||
|
||||
@ -22,10 +23,6 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef MACOSX
|
||||
# ifdef DEBUG
|
||||
# undef DEBUG
|
||||
# define DEBUG 1
|
||||
# endif
|
||||
# include <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
@ -380,9 +377,10 @@ void EventProcess(SDL_Event event)
|
||||
engine->onMouseClick(mousex, mousey, mouseButton);
|
||||
|
||||
mouseDown = true;
|
||||
#if !defined(NDEBUG) && !defined(DEBUG)
|
||||
SDL_CaptureMouse(SDL_TRUE);
|
||||
#endif
|
||||
if constexpr (!DEBUG)
|
||||
{
|
||||
SDL_CaptureMouse(SDL_TRUE);
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
// if mouse hasn't moved yet, sdl will send 0,0. We don't want that
|
||||
@ -395,9 +393,10 @@ void EventProcess(SDL_Event event)
|
||||
engine->onMouseUnclick(mousex, mousey, mouseButton);
|
||||
|
||||
mouseDown = false;
|
||||
#if !defined(NDEBUG) && !defined(DEBUG)
|
||||
SDL_CaptureMouse(SDL_FALSE);
|
||||
#endif
|
||||
if constexpr (!DEBUG)
|
||||
{
|
||||
SDL_CaptureMouse(SDL_FALSE);
|
||||
}
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
@ -527,9 +526,10 @@ void EngineProcess()
|
||||
LargeScreenDialog();
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
std::cout << "Breaking out of EngineProcess" << std::endl;
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
std::cout << "Breaking out of EngineProcess" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void BlueScreen(String detailMessage)
|
||||
@ -605,8 +605,11 @@ int GuessBestScale()
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
#if defined(DEBUG) && defined(_MSC_VER)
|
||||
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
|
||||
#ifdef WIN
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
|
||||
}
|
||||
#endif
|
||||
currentWidth = WINDOWW;
|
||||
currentHeight = WINDOWH;
|
||||
@ -818,8 +821,7 @@ int main(int argc, char * argv[])
|
||||
engine->Begin(WINDOWW, WINDOWH);
|
||||
engine->SetFastQuit(Client::Ref().GetPrefBool("FastQuit", true));
|
||||
|
||||
#if !defined(DEBUG)
|
||||
bool enableBluescreen = !true_arg(arguments["disable-bluescreen"]);
|
||||
bool enableBluescreen = !DEBUG && !true_arg(arguments["disable-bluescreen"]);
|
||||
if (enableBluescreen)
|
||||
{
|
||||
//Get ready to catch any dodgy errors
|
||||
@ -828,7 +830,6 @@ int main(int argc, char * argv[])
|
||||
signal(SIGILL, SigHandler);
|
||||
signal(SIGABRT, SigHandler);
|
||||
}
|
||||
#endif
|
||||
|
||||
if constexpr (X86)
|
||||
{
|
||||
@ -844,9 +845,10 @@ int main(int argc, char * argv[])
|
||||
auto openArg = arguments["open"];
|
||||
if (openArg.has_value())
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cout << "Loading " << openArg.value() << std::endl;
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
std::cout << "Loading " << openArg.value() << std::endl;
|
||||
}
|
||||
if (Platform::FileExists(openArg.value()))
|
||||
{
|
||||
try
|
||||
@ -900,9 +902,10 @@ int main(int argc, char * argv[])
|
||||
|
||||
if (!saveIdPart.size())
|
||||
throw std::runtime_error("No Save ID");
|
||||
#ifdef DEBUG
|
||||
std::cout << "Got Ptsave: id: " << saveIdPart << std::endl;
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
std::cout << "Got Ptsave: id: " << saveIdPart << std::endl;
|
||||
}
|
||||
int saveId = saveIdPart.ToNumber<int>();
|
||||
|
||||
SaveInfo * newSave = Client::Ref().GetSave(saveId, 0);
|
||||
@ -927,7 +930,6 @@ int main(int argc, char * argv[])
|
||||
SaveWindowPosition();
|
||||
};
|
||||
|
||||
#if !defined(DEBUG)
|
||||
if (enableBluescreen)
|
||||
{
|
||||
try
|
||||
@ -940,8 +942,9 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
wrapWithBluescreen(); // the else branch of the if in the #if !defined(DEBUG)
|
||||
{
|
||||
wrapWithBluescreen();
|
||||
}
|
||||
|
||||
ui::Engine::Ref().CloseWindow();
|
||||
delete gameController;
|
||||
|
@ -101,29 +101,28 @@ int update_finish()
|
||||
#ifdef WIN
|
||||
ByteString exeName = Platform::ExecutableName(), updName;
|
||||
int timeout = 5, err;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Update: Current EXE name: %s\n", exeName.c_str());
|
||||
#endif
|
||||
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
printf("Update: Current EXE name: %s\n", exeName.c_str());
|
||||
}
|
||||
updName = exeName;
|
||||
ByteString extension = exeName.substr(exeName.length() - 4);
|
||||
if (extension == ".exe")
|
||||
updName = exeName.substr(0, exeName.length() - 4);
|
||||
updName = updName + "_upd.exe";
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Update: Temp EXE name: %s\n", updName.c_str());
|
||||
#endif
|
||||
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
printf("Update: Temp EXE name: %s\n", updName.c_str());
|
||||
}
|
||||
while (!Platform::RemoveFile(updName))
|
||||
{
|
||||
err = GetLastError();
|
||||
if (err == ERROR_FILE_NOT_FOUND)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Update: Temp file not deleted\n");
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
printf("Update: Temp file not deleted\n");
|
||||
}
|
||||
// Old versions of powder toy name their update files with _update.exe, delete that upgrade file here
|
||||
updName = exeName;
|
||||
ByteString extension = exeName.substr(exeName.length() - 4);
|
||||
@ -137,9 +136,10 @@ int update_finish()
|
||||
timeout--;
|
||||
if (timeout <= 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Update: Delete timeout\n");
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
printf("Update: Delete timeout\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,8 @@
|
||||
#include <fstream>
|
||||
|
||||
#ifdef MACOSX
|
||||
# include "common/macosx.h"
|
||||
# include <mach-o/dyld.h>
|
||||
# include <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
|
||||
#ifdef LIN
|
||||
|
@ -1329,9 +1329,10 @@ void GameSave::readPSv(const std::vector<char> &dataVec)
|
||||
const auto *data = reinterpret_cast<unsigned char *>(&bsonData[0]);
|
||||
dataLength = bsonData.size();
|
||||
|
||||
#ifdef DEBUG
|
||||
std::cout << "Parsing " << dataLength << " bytes of data, version " << ver << std::endl;
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
std::cout << "Parsing " << dataLength << " bytes of data, version " << ver << std::endl;
|
||||
}
|
||||
|
||||
if (dataLength < bw*bh)
|
||||
throw ParseException(ParseException::Corrupt, "Save data corrupt (missing data)");
|
||||
@ -2538,9 +2539,10 @@ std::pair<bool, std::vector<char>> GameSave::serialiseOPS() const
|
||||
}
|
||||
auto compressedSize = int(outputData.size());
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("compressed data: %d\n", compressedSize);
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
printf("compressed data: %d\n", compressedSize);
|
||||
}
|
||||
outputData.resize(compressedSize + 12);
|
||||
|
||||
auto header = (unsigned char *)&outputData[compressedSize];
|
||||
|
@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef DEBUG
|
||||
# undef DEBUG
|
||||
# define DEBUG 1
|
||||
#else
|
||||
# define DEBUG 0
|
||||
#endif
|
||||
#include <mach-o/dyld.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
@ -238,9 +238,10 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
||||
|
||||
return (pixel*)resultImage;
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
std::cout << "Resampling " << sw << "x" << sh << " to " << rw << "x" << rh << std::endl;
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
std::cout << "Resampling " << sw << "x" << sh << " to " << rw << "x" << rh << std::endl;
|
||||
}
|
||||
bool stairstep = false;
|
||||
if(rw < sw || rh < sh)
|
||||
{
|
||||
@ -257,12 +258,13 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
||||
if(((fxint & (fxint-1)) == 0 && fxf < 0.1f) || ((fyint & (fyint-1)) == 0 && fyf < 0.1f))
|
||||
stairstep = true;
|
||||
|
||||
#ifdef DEBUG
|
||||
if(stairstep)
|
||||
std::cout << "Downsampling by " << fx << "x" << fy << " using stairstepping" << std::endl;
|
||||
else
|
||||
std::cout << "Downsampling by " << fx << "x" << fy << " without stairstepping" << std::endl;
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
if(stairstep)
|
||||
std::cout << "Downsampling by " << fx << "x" << fy << " using stairstepping" << std::endl;
|
||||
else
|
||||
std::cout << "Downsampling by " << fx << "x" << fy << " without stairstepping" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int y, x, fxceil, fyceil;
|
||||
|
@ -62,9 +62,10 @@ inline ByteString IntroText()
|
||||
{
|
||||
sb << " NOHTTP";
|
||||
}
|
||||
#ifdef DEBUG
|
||||
sb << " DEBUG";
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
sb << " DEBUG";
|
||||
}
|
||||
if constexpr (ENFORCE_HTTPS)
|
||||
{
|
||||
sb << " HTTPS";
|
||||
|
@ -162,11 +162,10 @@ void PropertyWindow::SetProperty(bool warn)
|
||||
new ErrorMessage("Could not set property", "Invalid particle type");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
std::cout << "Got int value " << v << std::endl;
|
||||
#endif
|
||||
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
std::cout << "Got int value " << v << std::endl;
|
||||
}
|
||||
tool->propValue.Integer = v;
|
||||
break;
|
||||
}
|
||||
@ -187,9 +186,10 @@ void PropertyWindow::SetProperty(bool warn)
|
||||
{
|
||||
v = value.ToNumber<unsigned int>();
|
||||
}
|
||||
#ifdef DEBUG
|
||||
std::cout << "Got uint value " << v << std::endl;
|
||||
#endif
|
||||
if constexpr (DEBUG)
|
||||
{
|
||||
std::cout << "Got uint value " << v << std::endl;
|
||||
}
|
||||
tool->propValue.UInteger = v;
|
||||
break;
|
||||
}
|
||||
|
@ -19,9 +19,7 @@ Window::Window(Point _position, Point _size):
|
||||
cancelButton(NULL),
|
||||
focusedComponent_(NULL),
|
||||
hoverComponent(NULL),
|
||||
#ifdef DEBUG
|
||||
debugMode(false),
|
||||
#endif
|
||||
halt(false),
|
||||
destruct(false),
|
||||
stop(false)
|
||||
@ -197,7 +195,6 @@ void Window::DoDraw()
|
||||
Components[i]->Draw(scrpos);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (debugMode)
|
||||
{
|
||||
if (focusedComponent_==Components[i])
|
||||
@ -209,7 +206,6 @@ void Window::DoDraw()
|
||||
ui::Engine::Ref().g->fillrect(Components[i]->Position.X+Position.X, Components[i]->Position.Y+Position.Y, Components[i]->Size.X, Components[i]->Size.Y, 255, 0, 0, 90);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// the component the mouse is hovering over and the focused component are always drawn last
|
||||
if (hoverComponent && hoverComponent->Visible && hoverComponent->GetParent() == NULL)
|
||||
@ -236,7 +232,6 @@ void Window::DoDraw()
|
||||
focusedComponent_->Draw(scrpos);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (debugMode)
|
||||
{
|
||||
if (focusedComponent_)
|
||||
@ -260,16 +255,13 @@ void Window::DoDraw()
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void Window::DoTick(float dt)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (debugMode)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (DoesTextInput || (focusedComponent_ && focusedComponent_->Visible && focusedComponent_->Enabled && focusedComponent_->DoesTextInput))
|
||||
{
|
||||
@ -311,8 +303,7 @@ void Window::DoTick(float dt)
|
||||
|
||||
void Window::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (key == SDLK_TAB && ctrl)
|
||||
if (DEBUG && key == SDLK_TAB && ctrl)
|
||||
debugMode = !debugMode;
|
||||
if (debugMode)
|
||||
{
|
||||
@ -395,7 +386,6 @@ void Window::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, b
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
//on key press
|
||||
if (focusedComponent_ != NULL)
|
||||
{
|
||||
@ -418,10 +408,8 @@ void Window::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, b
|
||||
|
||||
void Window::DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if(debugMode)
|
||||
return;
|
||||
#endif
|
||||
//on key unpress
|
||||
if (focusedComponent_ != NULL)
|
||||
{
|
||||
@ -437,10 +425,8 @@ void Window::DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl,
|
||||
|
||||
void Window::DoTextInput(String text)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (debugMode)
|
||||
return;
|
||||
#endif
|
||||
//on key unpress
|
||||
if (focusedComponent_ != NULL)
|
||||
{
|
||||
@ -482,10 +468,10 @@ void Window::DoMouseDown(int x_, int y_, unsigned button)
|
||||
if (x >= Components[i]->Position.X && y >= Components[i]->Position.Y && x < Components[i]->Position.X + Components[i]->Size.X && y < Components[i]->Position.Y + Components[i]->Size.Y)
|
||||
{
|
||||
FocusComponent(Components[i]);
|
||||
#ifdef DEBUG
|
||||
if (!debugMode)
|
||||
#endif
|
||||
Components[i]->OnMouseClick(x - Components[i]->Position.X, y - Components[i]->Position.Y, button);
|
||||
if (!DEBUG || !debugMode)
|
||||
{
|
||||
Components[i]->OnMouseClick(x - Components[i]->Position.X, y - Components[i]->Position.Y, button);
|
||||
}
|
||||
clickState = true;
|
||||
break;
|
||||
}
|
||||
@ -495,10 +481,8 @@ void Window::DoMouseDown(int x_, int y_, unsigned button)
|
||||
if (!clickState)
|
||||
FocusComponent(NULL);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debugMode)
|
||||
return;
|
||||
#endif
|
||||
|
||||
//on mouse down
|
||||
for (int i = Components.size() - 1; i > -1 && !halt; --i)
|
||||
@ -522,10 +506,8 @@ void Window::DoMouseMove(int x_, int y_, int dx, int dy)
|
||||
//on mouse move (if true, and inside)
|
||||
int x = x_ - Position.X;
|
||||
int y = y_ - Position.Y;
|
||||
#ifdef DEBUG
|
||||
if (debugMode)
|
||||
return;
|
||||
#endif
|
||||
for (int i = Components.size() - 1; i > -1 && !halt; --i)
|
||||
{
|
||||
if (Components[i]->Enabled && Components[i]->Visible)
|
||||
@ -578,10 +560,8 @@ void Window::DoMouseUp(int x_, int y_, unsigned button)
|
||||
{
|
||||
int x = x_ - Position.X;
|
||||
int y = y_ - Position.Y;
|
||||
#ifdef DEBUG
|
||||
if (debugMode)
|
||||
return;
|
||||
#endif
|
||||
//on mouse unclick
|
||||
for (int i = Components.size() - 1; i >= 0 && !halt; --i)
|
||||
{
|
||||
@ -612,10 +592,8 @@ void Window::DoMouseWheel(int x_, int y_, int d)
|
||||
{
|
||||
int x = x_ - Position.X;
|
||||
int y = y_ - Position.Y;
|
||||
#ifdef DEBUG
|
||||
if (debugMode)
|
||||
return;
|
||||
#endif
|
||||
//on mouse wheel focused
|
||||
for (int i = Components.size() - 1; i >= 0 && !halt; --i)
|
||||
{
|
||||
|
@ -113,9 +113,7 @@ namespace ui
|
||||
Component *hoverComponent;
|
||||
ChromeStyle chrome;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool debugMode;
|
||||
#endif
|
||||
//These controls allow a component to call the destruction of the Window inside an event (called by the Window)
|
||||
void finalise();
|
||||
bool halt;
|
||||
|
Reference in New Issue
Block a user