#include "game.h"
-
+#include <stdarg.h>
using namespace std;
signal(SIGPIPE, Game::HandleBrokenPipe);
+ #ifdef BUILD_GRAPHICS
if (graphicsEnabled && (!Graphics::Initialised()))
Graphics::Initialise("Stratego", theBoard.Width()*32, theBoard.Height()*32);
+ #endif //BUILD_GRAPHICS
if (strcmp(redPath, "human") == 0)
red = new Human_Controller(Piece::RED, graphicsEnabled);
Game::theGame = this;
signal(SIGPIPE, Game::HandleBrokenPipe);
-
+ #ifdef BUILD_GRAPHICS
if (graphicsEnabled && (!Graphics::Initialised()))
Graphics::Initialise("Stratego", theBoard.Width()*32, theBoard.Height()*32);
+ #endif //BUILD_GRAPHICS
input = fopen(fromFile, "r");
TimerThread timer(wait*1000000); //Wait in seconds
timer.Start();
+ #ifdef BUILD_GRAPHICS
if (!graphicsEnabled)
{
while (!timer.Finished());
timer.Stop();
return;
}
-
+ #endif //BUILD_GRAPHICS
while (!timer.Finished())
{
+ #ifdef BUILD_GRAPHICS
SDL_Event event;
while (SDL_PollEvent(&event))
{
break;
}
}
+ #endif //BUILD_GRAPHICS
}
timer.Stop();
if (Game::theGame->printBoard)
Game::theGame->theBoard.PrintPretty(stdout, Piece::BOTH);
+
+ #ifdef BUILD_GRAPHICS
if (Game::theGame->graphicsEnabled && theGame->log == stdout)
{
theGame->logMessage("CLOSE WINDOW TO EXIT\n");
}
}
else
+ #endif //BUILD_GRAPHICS
{
if (theGame->log == stdout)
{
theBoard.PrintPretty(stdout, Piece::BOTH);
fprintf(stdout, "\n");
}
+
+ #ifdef BUILD_GRAPHICS
if (graphicsEnabled && log == stdout)
{
logMessage("CLOSE WINDOW TO EXIT\n");
}
}
else
+ #endif //BUILD_GRAPHICS
{
if (log == stdout)
{
fprintf(stdout, "\n\n");
}
+ #ifdef BUILD_GRAPHICS
if (graphicsEnabled)
theBoard.Draw(toReveal);
+ #endif //BUILD_GRAPHICS
turn = Piece::RED;
logMessage( "%d RED: ", turnCount);
theBoard.PrintPretty(stdout, toReveal);
fprintf(stdout, "\n\n");
}
+
+ #ifdef BUILD_GRAPHICS
if (graphicsEnabled)
theBoard.Draw(toReveal);
+ #endif //BUILD_GRAPHICS