Skip to content

Commit ee85bce

Browse files
Merge pull request #153 from Longwater1234/dev
Update protobuf library
2 parents 2e9ec6d + 8fb4555 commit ee85bce

File tree

17 files changed

+3639
-1970
lines changed

17 files changed

+3639
-1970
lines changed

BUILDING.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
## On Windows
44

5-
1. Just open this project folder in Visual Studio 2019 (or newer), with CMake extension installed.
6-
2. From top toolbar, change mode to **Release**, and click **Build** > **Build All**.
7-
3. Done. That's it. Your game .EXE will be in `{project_dir}/out/Release/bin`
8-
4. If the game fails to start, make sure `openal32.dll` is present in **same folder** with your .EXE. If not, copy it from SFML directory `${SFML_HOME}/bin/openal32.dll`
5+
1. Just open this project directly in Visual Studio 2022 (or newer), with native CMake extension installed.
6+
2. Wait as Visual Studio auto-configures this project for you.
7+
3. Next, from top toolbar, change mode to **'Release'**, and click **Build** > **Build All**.
8+
4. Done. That's it! Your game `.exe` will be inside `{project_dir}/out/Release/bin/`. Enjoy!
99

1010
## On MacOS & Linux
1111

12-
1. Open this project directory in your terminal.
12+
1. Open this project directory in your Terminal.
1313
2. Ensure CMake 3.20 or higher is installed. Verify with `cmake --version`
14-
3. Once installed, run the following commands:
14+
3. Next, copy and run the following commands:
1515

1616
```bash
1717
mkdir build
@@ -21,20 +21,17 @@ cmake --build . --config Release --target all
2121

2222
```
2323

24-
4. Your executable (`.app` bundle for MacOS) and binary for Linux will be found in `{project_dir}/build/bin`
24+
4. Done. Your optimized game executable (`.app` on MacOS) will be found inside `{project_dir}/build/bin/`
25+
5. Alternatively, if you have CLion IDE, you can skip ALL steps above, and use it to build in "Release" mode.
2526

26-
## Using CMake GUI (all destkop platforms)
27+
## Using CMake GUI (all desktop platforms)
2728

28-
- Download CMake GUI installer for your OS from the official site. (supported on all desktop OS)
29-
- On MacOS, after installing the GUI, add Cmake CLI to path, run the following command:
30-
```bash
31-
sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install
32-
```
33-
- Refer to the screenshot below:
34-
![cmake_screenshot](cmake/cmake_gui_screenshot.png)
29+
- Download latest stable [CMake GUI installer](https://cmake.org/download/) from official site
30+
- Open CMake GUI, refer to the screenshot below:
31+
![cmake_screenshot](cmake/cmake_gui_screenshot.png)
3532

36-
- Set "Source Folder" (1) to this project root. Then set "Build Folder" (2) to a NEW _relative_ folder `/build` or `/out`. See image above. Then (3) click "**Configure**",
37-
- In the next screen, Choose **Unix Makefiles** if on Linux; choose **XCode** if on Mac. Choose **Visual Studio** if on Windows. Then click OK to save.
38-
- Make sure CMAKE_BUILD_TYPE is **Release**.
39-
- Click Configure once again, then **Generate**.
40-
- Finally, on Windows and MacOS, click **Open Project** for building in respective IDE. On Linux desktop, open build folder, then run `make all` in Terminal.
33+
- Set "Source Folder" (1) to this project root dir. Then, set "Build Folder" (2) to a NEW _relative_ folder `/build` or `/out`.
34+
- Ensure "CMAKE_BUILD_TYPE" is **Release** (see image above, blue highlight). Ignore other settings. Then (3) click "**Configure**".
35+
- In the popup window, choose generator **'Unix Makefiles'** if on Linux; choose **'XCode'** if on MacOS. Choose **'Visual Studio'** if on Windows. Then click OK to save.
36+
- Click **'Configure'** once again, then **'Generate'**.
37+
- Finally, on Windows or MacOS, click **Open Project** for building in respective IDE. On Linux desktop, open build folder, then run `make all` in Terminal.

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
77

88
set(CMAKE_CXX_STANDARD 17)
99
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
10-
if(NOT APPLE)
10+
if (NOT APPLE)
1111
set(SFML_STATIC_LIBRARIES TRUE)
1212
endif()
1313

@@ -43,14 +43,14 @@ target_link_libraries(SpaceCheckers PRIVATE sfml-graphics sfml-window sfml-syste
4343
include_directories(${SFML_HOME}/include)
4444

4545
# show warnings (depending on C++ compiler)
46-
if(MSVC)
46+
if (MSVC)
4747
target_compile_options(SpaceCheckers PRIVATE /W4 /sdl /Qvec-report:1)
4848
else()
49-
target_compile_options(SpaceCheckers PRIVATE -Wall -Werror=overflow)
49+
target_compile_options(SpaceCheckers PRIVATE -Wall -Werror=constant-conversion)
5050
endif()
51-
51+
5252
# COPY resources folder to destination
53-
if(NOT APPLE)
53+
if (NOT APPLE)
5454
add_custom_command(
5555
TARGET SpaceCheckers
5656
POST_BUILD

LICENSE

Lines changed: 674 additions & 21 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
# space - checkers
22

33
Offline & Online Multiplayer Checkers game in C++ built with SFML 2.6, imGui, Protobuf and ixWebsockets. With very minimal dependencies
4-
and a simple build process. All dependencies are auto-downloaded (as `.tar.gz`) and built for you using [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake).
4+
and a simple build process. All dependencies are auto-downloaded (compressed as `.tar.gz`) and built for you using [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake).
55

6-
This game can connect to both Private and Public game servers. The Server project for this game is on a separate git repo, [available here](#).
7-
The only dependency you need pre-installed on your OS is SFML 2.6.x (or newer).
6+
This game can connect to both Private and Public game servers. The Server project for this game is on a separate Git repo, [available here](https://github.com/Longwater1234/checkers-backend) which you can self-host! The only dependency you need pre-installed on your OS is SFML 2.6.x (or newer).
87

98
### Main Libraries Used
109

1110
- SFML 2.6
1211
- imGui-SFML
1312
- ixWebsockets
1413
- spdlog
15-
- Google Protobuf 27.2 (Used entirely during gameplay)
14+
- Google Protobuf v30.1 (Used entirely during gameplay)
1615
- simdjson (Used once, for parsing list of public servers)
1716

1817
## Requirements for Building
@@ -27,20 +26,25 @@ The only dependency you need pre-installed on your OS is SFML 2.6.x (or newer).
2726
- MS Visual Studio 2022 or newer (NOT vscode), with "**Desktop C++ Development**" bundle.
2827
- Please download "Visual C++ 64bit" edition of SFML; ignore others.
2928
- Move your unzipped `SFML-2.6.x` folder to its own home, example: `C:/SFML/SFML-2.6.1`.
30-
- Edit **line 16** in [CMakeLists.txt](CMakeLists.txt), to set value `SFML_HOME` to folder path you moved SFML into (see
31-
previous step)
29+
- Edit **line 16** in [CMakeLists.txt](CMakeLists.txt), to set value `SFML_HOME` to folder path you moved SFML into (seeprevious step)
3230

33-
### For MacOS
31+
### For macOS (x64 & arm64)
3432

35-
- Please install SFML 2.6 as **Frameworks**, not as "dylibs", as shown in [official macOS guide](https://www.sfml-dev.org/tutorials/2.6/start-osx.php).
33+
- Please install SFML 2.6 as **Frameworks**, not as "dylibs", as shown in [official SFML guide](https://www.sfml-dev.org/tutorials/2.6/start-osx.php).
3634
- XCode 14 or newer from AppStore (with MacOS SDK)
3735
- Apple Developer tools. After Xcode is installed, run this in your Terminal:
3836

3937
```bash
4038
sudo xcode-select --install
4139
```
4240

43-
### For Linux Destkop
41+
- After installing the CMake GUI, add its accompanying CLI to PATH by simply run the following command:
42+
43+
```bash
44+
sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install
45+
```
46+
47+
### For Linux Desktop
4448

4549
- Latest display drivers
4650
- Use your OS package manager (`apt` or `yum`) to install SFML 2.6 or newer.
@@ -52,12 +56,12 @@ The only dependency you need pre-installed on your OS is SFML 2.6.x (or newer).
5256
sudo apt install libssl-dev
5357
```
5458

55-
- Luckily, Windows and macOS **come with their native SSL libs built-in**, so nothing more to do :-)
59+
- Luckily, Windows and macOS come with their **native SSL libs pre-installed**, so nothing more to do 😁
5660

5761
## Building Instructions
5862

59-
Please see [BUILDING.md](BUILDING.md) for detailed instructions. For macOS-specific build guide with XCode, please [see this doc](cmake/README.md)
63+
Please see [BUILDING.md](BUILDING.md) for detailed instructions. For macOS-specific guide with XCode, please [cmake/README.md](cmake/README.md)
6064

6165
### License
6266

63-
[MIT License](LICENSE) © 2024, Davis T.
67+
[GPL v3](LICENSE) © 2024, Davis T.

TODO.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1+
# TODO list
12

2-
## GAME LOGS
3+
- [ ] (Online mode) Display countdown timer (40 s), waiting for player's move. Reset it when they make a move.
4+
- [ ] Record and list all previous moves and captures (for current match), in a scroll window.
35

4-
### first game
6+
### (Extras) Standard CJK font paths
57

6-
- start time: 19:31:12
7-
- end time: 19:35:17
8-
9-
### Standard CJK font paths
10-
11-
- Windows: `C:/Windows/Fonts/ARIALUNI.TTF.ttf`
8+
- Windows 10/11: `C:/Windows/Fonts/msyc.ttc`
129
- MacOS: `/System/Library/Fonts/PingFang.ttc`
13-
- How to load cjk font in imgui
10+
- How to load CJK font in imGui:
1411

1512
```cpp
1613
ImFont* font = io.Fonts->AddFontFromFileTTF("/path/to/font.ext", 18.0f, nullptr, io.Fonts->GetGlyphRangesChineseFull());
17-
```
14+
```

cmake/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
## What's 'macbundle.cmake' for?
22

3-
This contains CMake script to build MacOS GUI `.app` bundle. It embeds the icon to the app bundle. It also copies all static assets into the bundle at build time.
3+
This contains CMake script to build MacOS GUI `.app` bundle. It embeds the icon to the app bundle. It also copies all static assets (resources) into the bundle at build time.
44

5-
If you installed SFML as "Frameworks", you will need to tell XCode to copy them into the bundle before Building. Follow these steps:
5+
**IMPORTANT**: If you installed SFML as "Frameworks" (recommended), you will need to manually instruct XCode to embed them into the bundle at Build time. Otherwise, the game won't work on other similar MacOS devices!
66

7-
- From top toolbar inside Xcode, click **Product** > **Add New Build Phase** > choose **Copy Files**. See official [Apple guide](https://developer.apple.com/documentation/xcode/customizing-the-build-phases-of-a-target)
8-
- Click the `+` (add button). A new window will pop up.
9-
- Now select all SFML frameworks listed: `sfml-graphics.framework` `sflml-window.framework` etc. You should also add `Foundation` framework.
10-
- Finally, you will need to find `freetype.framework`. Click **Other Locations**, find it inside `/Library/Frameworks`.
7+
Kindly follow these steps:
118

12-
Now you can build your project. Choose **Product** from top toolbar, click **Build**.
9+
- Use CMake to generate "XCode Project". Refer to [BUILDING.md](../BUILDING.md). Open the project.
10+
- From top toolbar inside Xcode, click **Product** > **Add New Build Phase** > choose **Copy Files**. See official [Apple guide](https://developer.apple.com/documentation/xcode/customizing-the-build-phases-of-a-target)
11+
- Click the `+` (add button) to begin. A new window will pop up.
12+
- Now select all SFML frameworks listed: `sfml-graphics.framework`, `sflml-window.framework` etc.
13+
- Finally, you will need to add `freetype.framework`. Click **Other Locations**, find it inside `/Library/Frameworks`. Click "Copy as reference folder". Click OK
14+
- Now you can build your project. From top toolbar, Click **Product** > **Build**.

dependencies/protobuf.cmake

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
# Get abseil 20240116.2
1+
# Get abseil 20250127
22
CPMAddPackage(
33
NAME abseil
4-
URL "https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.2.tar.gz"
5-
VERSION 20240116.2
4+
URL "https://github.com/abseil/abseil-cpp/archive/refs/tags/20250127.0.tar.gz"
5+
VERSION 220250127
66
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
77
OPTIONS "ABSL_ENABLE_INSTALL ON" "ABSL_PROPAGATE_CXX_STD ON"
88
)
99

10-
# Get protobuf 27.2
10+
# Get protobuf 30.1
1111
CPMAddPackage(
1212
NAME protobuf
13-
URL "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v27.2.tar.gz"
14-
VERSION 27.2
13+
URL "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v30.1.tar.gz"
14+
VERSION 30.1
1515
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
16-
OPTIONS "protobuf_BUILD_TESTS OFF" "protobuf_INSTALL OFF" "protobuf_BUILD_LIBPROTOC ON"
17-
"protobuf_BUILD_PROTOC_BINARIES OFF" "protobuf_WITH_ZLIB ON" "protobuf_MSVC_STATIC_RUNTIME OFF"
16+
OPTIONS "protobuf_BUILD_TESTS OFF" "protobuf_INSTALL OFF" "protobuf_BUILD_PROTOBUF_BINARIES ON"
17+
"protobuf_BUILD_LIBUPB OFF" "protobuf_WITH_ZLIB OFF" "protobuf_BUILD_PROTOC_BINARIES OFF"
18+
"protobuf_MSVC_STATIC_RUNTIME OFF"
1819
)

dependencies/zlib.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# zlib v1.3.0 (zlib License)
1+
# zlib v1.3.1 (zlib License)
22

33
CPMAddPackage(
44
NAME zlib

lint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
# Define the source directory
4+
SRC_DIR="src"
5+
6+
clang-format $(find $SRC_DIR -type f -name "*.cpp" -o -name "*.hpp") -i --verbose
7+
echo "Formatting completed."

src/Piece.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ inline bool Piece::moveCapture(const sf::Vector2f &destPos)
243243
return false;
244244
}
245245

246-
this->move(sf::Vector2f{deltaX, deltaY}); // means "move by (x,y) amout"
246+
this->move(sf::Vector2f{deltaX, deltaY}); // means "move by (x,y) amount"
247247
this->myCircle.setPosition(this->getPosition());
248248
if ((this->pieceType == PieceType::Red && destPos.y == 0) ||
249249
(this->pieceType == PieceType::Black && destPos.y == 7 * chk::SIZE_CELL))

0 commit comments

Comments
 (0)