Skip to content

Commit

Permalink
chore: fix: style: too many changes long ago (linux)
Browse files Browse the repository at this point in the history
  • Loading branch information
popojan committed Dec 3, 2021
1 parent d7af42b commit 95cf5fe
Show file tree
Hide file tree
Showing 19 changed files with 567 additions and 1,049 deletions.
926 changes: 486 additions & 440 deletions CMakeLists.txt

Large diffs are not rendered by default.

42 changes: 0 additions & 42 deletions cmake/FileList.cmake

This file was deleted.

21 changes: 0 additions & 21 deletions cmake/FindGnuGo.cmake

This file was deleted.

27 changes: 11 additions & 16 deletions cmake/FindLibGlyphy.cmake
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
# - Try to find libGlyphy
# Once done this will define
# LIBGLYPHY_FOUND - System has libglyphy
# LIBGLYPHY_INCLUDE_DIRS - The GLyphy include directories
# LIBGLYPHY_LIBRARIES - The libraries needed to use libglyphy
# LIBGLYPHY_DEFINITIONS - Compiler switches required for using libglyphy

find_path(LIBGLYPHY_INCLUDE_DIR NAMES glyphy.h HINTS ${PROJECT_SOURCE_DIR}/deps/glyphy/src)

find_library(LIBGLYPHY_LIBRARY NAMES goban_glyphy.lib libglyphy.a HINTS ${PROJECT_SOURCE_DIR}/deps/glyphy/win32/x64/${CMAKE_BUILD_TYPE})
find_library(LIBGLYPHY_LIBRARY NAMES goban_glyphy.lib libglyphy.a
HINTS ${PROJECT_SOURCE_DIR}/deps/glyphy/win32/x64/${CMAKE_BUILD_TYPE}
HINTS ${PROJECT_BINARY_DIR}/deps/glyphy/build/src/.libs
)

add_library(libglyphy STATIC IMPORTED)

message(${PROJECT_SOURCE_DIR}/deps/glyphy/win32/x64/${CMAKE_BUILD_TYPE})
set(LIBGLYPHY_LIBRARIES
${LIBGLYPHY_LIBRARY}
set_target_properties(libglyphy PROPERTIES
IMPORTED_LOCATION ${LIBGLYPHY_LIBRARY}
)
set(LIBGLYPHY_INCLUDE_DIRS ${LIBGLYPHY_INCLUDE_DIR})

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBGLYPHY_FOUND to TRUE
# if all listed variables are TRUE

find_package_handle_standard_args(LibGlyphy DEFAULT_MSG
LIBGLYPHY_LIBRARY LIBGLYPHY_INCLUDE_DIR)
LIBGLYPHY_LIBRARY LIBGLYPHY_INCLUDE_DIR)

mark_as_advanced(LIBGLYPHY_INCLUDE_DIR LIBGLYPHY_LIBRARY )
mark_as_advanced(LIBGLYPHY_INCLUDE_DIR LIBGLYPHY_LIBRARY)

12 changes: 9 additions & 3 deletions cmake/FindLibRocket.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ find_library(LIBROCKET_CONTROLS_LIBRARY NAMES RocketControls
find_library(LIBROCKET_DEBUGGER_LIBRARY NAMES RocketDebugger
HINTS ${PROJECT_BINARY_DIR}/deps/libRocket/build ${PROJECT_BINARY_DIR}/deps/libRocket/build/${CMAKE_BUILD_TYPE})

add_library(LibRocket_Core STATIC IMPORTED)
add_library(LibRocket_Controls STATIC IMPORTED)
add_library(LibRocket_Debugger STATIC IMPORTED)

set_target_properties(LibRocket_Core PROPERTIES IMPORTED_LOCATION ${LIBROCKET_CORE_LIBRARY})
set_target_properties(LibRocket_Controls PROPERTIES IMPORTED_LOCATION ${LIBROCKET_CONTROLS_LIBRARY})
set_target_properties(LibRocket_Debugger PROPERTIES IMPORTED_LOCATION ${LIBROCKET_DEBUGGER_LIBRARY})

set(LIBROCKET_LIBRARIES
${LIBROCKET_CORE_LIBRARY}
${LIBROCKET_CONTROLS_LIBRARY}
Expand All @@ -24,10 +32,8 @@ set(LIBROCKET_LIBRARIES
set(LIBROCKET_INCLUDE_DIRS ${LIBROCKET_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBROCKET_FOUND to TRUE
# if all listed variables are TRUE

find_package_handle_standard_args(LibRocket DEFAULT_MSG
LIBROCKET_LIBRARIES LIBROCKET_INCLUDE_DIR)

mark_as_advanced(LIBROCKET_INCLUDE_DIR LIBROCKET_LIBRARIES)

2 changes: 1 addition & 1 deletion cmake/FindPortaudio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (PORTAUDIO_LIBRARIES AND PORTAUDIO_INCLUDE_DIRS)
set(PORTAUDIO_FOUND TRUE)
else (PORTAUDIO_LIBRARIES AND PORTAUDIO_INCLUDE_DIRS)
if (NOT WIN32)
include(FindPkgConfig)
#include(FindPkgConfig)
pkg_check_modules(PORTAUDIO2 portaudio-2.0)
endif (NOT WIN32)

Expand Down
2 changes: 1 addition & 1 deletion src/ElementGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

ElementGame::ElementGame(const Rocket::Core::String& tag)
: Rocket::Core::Element(tag), model(this), view(model), engine(model),
control(this, model, view, engine), hasResults(false), calculatingScore(false)
control(this, model, view, engine)
{
engine.loadEngines(config);
engine.addGameObserver(&model);
Expand Down
4 changes: 0 additions & 4 deletions src/ElementGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ class ElementGame : public Rocket::Core::Element,

void OnChildAdd(Rocket::Core::Element* element);

bool needsRepaint() {
return view.needsRepaint();
}
void requestRepaint() {
view.requestRepaint();
}
Expand All @@ -43,7 +40,6 @@ class ElementGame : public Rocket::Core::Element,
GameThread engine;
GobanControl control;
std::mutex mutex;
bool hasResults, calculatingScore;
};

#endif
2 changes: 0 additions & 2 deletions src/EventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
#include "EventManager.h"
#include <Rocket/Core/Context.h>
#include <Rocket/Core/ElementDocument.h>
#include <Rocket/Core/ElementUtilities.h>
#include <Shell.h>
#include "EventHandler.h"
#include <map>
#include <iostream>

// The game's element context (declared in main.cpp).
extern Rocket::Core::Context* context;
Expand Down
2 changes: 1 addition & 1 deletion src/GameRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <memory>
#include "Board.h"

#include "OpenGL.h"
#include "SGF.h"

class GameRecord {
public:
Expand Down
13 changes: 9 additions & 4 deletions src/GameThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,11 @@ bool GameThread::setFixedHandicap(int handicap) {
return success;
}
void GameThread::run() {
std::unique_lock<std::mutex> lock(playerMutex);
model.start();
spdlog::warn("construct thread {}", (bool)model);
thread = new std::thread(&GameThread::gameLoop, this);
while(!hasThreadRunning || !playerToMove);
engineStarted.wait(lock);
}

bool GameThread::isRunning() { return hasThreadRunning;}
Expand Down Expand Up @@ -226,12 +228,15 @@ bool GameThread::undo(Player * engine, bool doubleUndo) {
}

void GameThread::gameLoop() {
hasThreadRunning = true;
interruptRequested = false;
while (model && !interruptRequested) {
Engine* coach = currentCoach();
Engine* kibitz = currentKibitz();
Player* player = currentPlayer();
if(!hasThreadRunning) {
hasThreadRunning = true;
engineStarted.notify_all();
}
std::unique_lock<std::mutex> lock(playerMutex, std::defer_lock);
bool locked = false;
if(coach && player && !interruptRequested) {
Expand Down Expand Up @@ -325,9 +330,9 @@ void GameThread::gameLoop() {
);
}

if(model.over)
if(model.over) {
break;

}

if(success && move != Move::INTERRUPT)
std::this_thread::sleep_for(std::chrono::milliseconds(500));
Expand Down
11 changes: 5 additions & 6 deletions src/GameThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@ class GameThread
void playLocalMove(const Move& move);
void playKibitzMove();

void loadEngines(const std::shared_ptr<Configuration> config);
void loadEngines(std::shared_ptr<Configuration> config);

int activatePlayer(int which, int delta = 1);

int getActivePlayer(int which);

Move getLocalMove(const Position& coord);

void init();
void reset();

void addGameObserver(GameObserver* pobserver) {
Expand All @@ -72,8 +71,8 @@ class GameThread

bool undo(Player * engine, bool doubleUndo);

const std::vector<Engine*> getEngines() { return engines;}
const std::vector<Player*> getPlayers() { return players;}
std::vector<Engine*> getEngines() { return engines;}
std::vector<Player*> getPlayers() { return players;}

private:
std::vector<GameObserver*> gameObservers;
Expand All @@ -82,13 +81,13 @@ class GameThread
std::vector<Player*> players; //all players including engines, humans, spectators
std::thread* thread;
std::mutex mutex2;
volatile bool interruptRequested, hasThreadRunning;
bool interruptRequested, hasThreadRunning;
Player* playerToMove;
std::size_t human, sgf, coach, kibitz;
std::size_t numPlayers;
std::array<std::size_t, 2> activePlayer;
std::mutex playerMutex;

std::condition_variable engineStarted;
int komi;
int boardSize;
int handicap;
Expand Down
7 changes: 4 additions & 3 deletions src/GobanControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "GobanControl.h"

bool GobanControl::newGame(int boardSize) {
engine.interrupt();
engine.interrupt();
engine.reset();
if(engine.clearGame(boardSize, model.state.komi, model.state.handicap)) {
view.animateIntro();
Expand All @@ -34,6 +34,7 @@ void GobanControl::mouseClick(int button, int state, int x, int y) {
else if(!engine.isRunning() && !model.over) {
engine.run();
}
spdlog::debug("engine.isRunning() = {}", engine.isRunning());
if(playNow) {
bool humanMove = engine.humanToMove();
if(model.state.holdsStone || !humanMove) {
Expand Down Expand Up @@ -116,10 +117,10 @@ bool GobanControl::command(const std::string& cmd) {
newGame(model.getBoardSize());
playNow = false;
}
else if(view.board.isEmpty()) {
/*else if(view.board.isEmpty()) {
if(!engine.isRunning())
engine.run();
}
}*/
if(playNow) {
auto move = model.getPassMove();
engine.playLocalMove(move);
Expand Down
4 changes: 2 additions & 2 deletions src/GobanModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class GobanModel: public GameObserver {
Board board;

bool prevPass;
volatile bool over;
volatile bool started;
bool over;
bool started;
GameState state;

GameRecord game; //TODO find usage and create API including SGF generation
Expand Down
4 changes: 2 additions & 2 deletions src/GobanView.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class GobanView: public GameObserver {
glm::vec3 translate, newTranslate;
glm::vec2 resolution;
float lastTime, startTime;
volatile bool animationRunning;
volatile bool calculatingScore = false;
bool animationRunning;
bool calculatingScore = false;
bool isPanning, isZooming, isRotating;
int needsUpdate;
DDG::Camera cam;
Expand Down
18 changes: 0 additions & 18 deletions src/OpenGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,6 @@
#define GOBAN_OPENGL_H

#include <Rocket/Core/Platform.h>

#define SGFCPLUSPLUS_STATIC_DEFINE 1
#include <ISgfcTreeBuilder.h>
#include <SgfcPlusPlusFactory.h>
#include <ISgfcPropertyFactory.h>
#include <ISgfcPropertyValueFactory.h>
#include <ISgfcPropertyValue.h>
#include <SgfcPropertyType.h>
#include <SgfcPlusPlusExport.h>
//#include <SgfcPropertyValueType.h>
#include <ISgfcGoMovePropertyValue.h>
#include <SgfcGameType.h>
#include <ISgfcGame.h>
#include <ISgfcNode.h>
#include <ISgfcDocument.h>
#include <ISgfcDocumentWriter.h>
#include <SgfcConstants.h>

#if defined(ROCKET_PLATFORM_MACOSX)
#elif defined(ROCKET_PLATFORM_LINUX)
#include <glad/glad.h>
Expand Down
25 changes: 25 additions & 0 deletions src/SGF.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Created by jan on 4/18/21.
//

#ifndef GOBAN_SGF_H
#define GOBAN_SGF_H

#undef None

#include <ISgfcTreeBuilder.h>
#include <SgfcPlusPlusFactory.h>
#include <ISgfcPropertyFactory.h>
#include <ISgfcPropertyValueFactory.h>
#include <ISgfcPropertyValue.h>
#include <SgfcPropertyType.h>
#include <SgfcPlusPlusExport.h>
#include <ISgfcGoMovePropertyValue.h>
#include <SgfcGameType.h>
#include <ISgfcGame.h>
#include <ISgfcNode.h>
#include <ISgfcDocument.h>
#include <ISgfcDocumentWriter.h>
#include <SgfcConstants.h>

#endif //GOBAN_SGF_H
Loading

0 comments on commit 95cf5fe

Please sign in to comment.