Skip to content

Commit c644a48

Browse files
authored
Merge pull request #10 from Random-stuff-unlimited/skyvence/chunks
Feature: Optional packet, play packet, configuration packet
2 parents 9464a01 + 835a699 commit c644a48

File tree

114 files changed

+17942
-1703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+17942
-1703
lines changed

.clang-format

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
BasedOnStyle: LLVM
33
IndentWidth: 4 # logical indent level = 1 tab
44
TabWidth: 4 # how wide a tab renders (adjust per team preference)
5-
UseTab: ForIndentation # use tabs for indentation, spaces for alignment
5+
UseTab: Always # use tabs for indentation, spaces for alignment
66
ContinuationIndentWidth: 8
77
BreakBeforeBraces: Attach
8-
ColumnLimit: 100
8+
ColumnLimit: 150
99
AllowShortIfStatementsOnASingleLine: true
1010
AllowShortFunctionsOnASingleLine: true
1111
PointerAlignment: Left
1212
SpaceBeforeParens: ControlStatements
13-
AlignConsecutiveAssignments: Consecutive
14-
AlignConsecutiveDeclarations: None
13+
AlignConsecutiveAssignments: true
14+
AlignConsecutiveDeclarations: true
15+
AlignConsecutiveMacros: true
1516
BinPackArguments: false
1617
BinPackParameters: false
1718
Cpp11BracedListStyle: true

.clangd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CompileFlags:
22
Add:
3-
- "-std=c++17"
3+
- "-std=c++23"
44
- "-Wall"
55
- "-Wextra"
66
- "-Wpedantic"

.github/workflows/format.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# name: clang-format
2+
3+
# on:
4+
# push:
5+
# pull_request:
6+
7+
# jobs:
8+
# clang-format:
9+
# runs-on: ubuntu-latest
10+
# permissions:
11+
# contents: write
12+
13+
# steps:
14+
# - name: Checkout code
15+
# uses: actions/checkout@v4
16+
# with:
17+
# ref: ${{ github.head_ref || github.ref_name }}
18+
# token: ${{ secrets.GITHUB_TOKEN }}
19+
20+
# - name: Install clang-format
21+
# run: |
22+
# sudo apt-get update
23+
# sudo apt-get install -y clang-format
24+
25+
# - name: Run clang-format
26+
# run: |
27+
# find . -name '*.cpp' -o -name '*.h' -o -name '*.c' -o -name '*.hpp' -o -name '*.cc' -o -name '*.cxx' \
28+
# | grep -v "include/lib/json.hpp" \
29+
# | xargs clang-format -i --style=file
30+
31+
# - name: Commit and push changes
32+
# run: |
33+
# git config --local user.email "github-actions[bot]@users.noreply.github.com"
34+
# git config --local user.name "github-actions[bot]"
35+
36+
# if ! git diff --quiet; then
37+
# git add -A
38+
# git commit -m "Apply clang-format [skip ci]"
39+
# git push
40+
# echo "Code formatted and pushed"
41+
# else
42+
# echo "No formatting changes needed"
43+
# fi

.github/workflows/verif-build.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ compile_commands.json
88
.cache
99
.vscode
1010
logs
11+
12+
# Test server directory
13+
test-server
14+
include/external

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "external/data-generator"]
2+
path = external/data-generator
3+
url = https://github.com/Random-stuff-unlimited/data-generator.git

.rules

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1. Do not create markdown documentation.
2+
2. When creating code from scratch you should always make sure the code does work before reitering.
3+
3. When working on complex feature you always should ask for direction on data type the user might need.
4+
4. If you think a library header is needed to go futher stop and ask user. You can recommand a library.
5+
5. If not asked do not modify any code in any way.

Makefile

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ CXX := g++
1818
CXXFLAGS := -std=c++20 -Wall -Wextra -Wpedantic -O2
1919
DEBUG_FLAGS := -g -DDEBUG -O0
2020
RELEASE_FLAGS := -DNDEBUG -O3
21-
INCLUDE_FLAGS := -I$(INCLUDE_DIR)
21+
INCLUDE_FLAGS := -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/data -I$(INCLUDE_DIR)/network -I$(INCLUDE_DIR)/world -I$(INCLUDE_DIR)/lib
2222

2323
# Linker flags (add your libraries here)
2424
LDFLAGS :=
25-
LIBS :=
25+
LIBS := -lz
2626

2727
# ================================ COLOR SETUP ===============================
2828
# ANSI color codes for beautiful output
@@ -82,7 +82,7 @@ else
8282
endif
8383

8484
# ================================= TARGETS ==================================
85-
.PHONY: all clean debug release info help run install uninstall compile_commands
85+
.PHONY: all clean distclean clean-test debug release info help run install uninstall compile_commands
8686

8787
# Default target
8888
all: info $(TARGET)
@@ -129,14 +129,44 @@ $(DEPS_DIR):
129129
# Clean build artifacts
130130
clean:
131131
@printf "$(BOLD)$(BRIGHT_RED)🧹 Cleaning build artifacts...$(RESET)\n"
132+
@find $(BUILD_DIR) -type f -name "*.o" -delete 2>/dev/null || true
133+
@find $(BUILD_DIR) -name "$(TARGET_NAME)" -delete 2>/dev/null || true
134+
@find $(BUILD_DIR) -type d -empty -delete 2>/dev/null || true
135+
@find $(DEPS_DIR) -type f -name "*.d" -delete 2>/dev/null || true
136+
@find $(DEPS_DIR) -type d -empty -delete 2>/dev/null || true
137+
@printf "$(BOLD)$(BRIGHT_GREEN)✨ Clean completed! (Preserved directories and config.json)$(RESET)\n"
138+
139+
# Complete clean - removes everything including directories
140+
distclean:
141+
@printf "$(BOLD)$(BRIGHT_RED)🧹 Complete cleanup (removing all build artifacts and directories)...$(RESET)\n"
132142
@rm -rf $(BUILD_DIR) $(DEPS_DIR)
133-
@printf "$(BOLD)$(BRIGHT_GREEN)✨ Clean completed!$(RESET)\n"
143+
@printf "$(BOLD)$(BRIGHT_GREEN)✨ Complete cleanup finished!$(RESET)\n"
144+
145+
# Clean test-server directory
146+
clean-test:
147+
@printf "$(BOLD)$(BRIGHT_RED)🧹 Cleaning test-server directory...$(RESET)\n"
148+
@rm -rf test-server
149+
@printf "$(BOLD)$(BRIGHT_GREEN)✨ Test-server cleanup finished!$(RESET)\n"
134150

135151
# Run the executable
136152
run: $(TARGET)
153+
@printf "$(BOLD)$(BRIGHT_MAGENTA)🚀 Setting up test-server environment...$(RESET)\n"
154+
@mkdir -p test-server
155+
@printf "$(BOLD)$(BRIGHT_BLUE)📦 Copying executable to test-server...$(RESET)\n"
156+
@cp $(TARGET) test-server/$(TARGET_NAME)
157+
@printf "$(BOLD)$(BRIGHT_BLUE)📦 Copying config.json to test-server...$(RESET)\n"
158+
@cp -f config.json test-server/ 2>/dev/null || printf "$(YELLOW)⚠️ config.json not found, skipping...$(RESET)\n"
159+
@printf "$(BOLD)$(BRIGHT_BLUE)📦 Copying world folder to test-server...$(RESET)\n"
160+
@if [ -d "world" ]; then \
161+
cp -r world test-server/; \
162+
printf "$(BOLD)$(BRIGHT_GREEN)✅ World folder copied successfully!$(RESET)\n"; \
163+
else \
164+
printf "$(YELLOW)⚠️ World folder not found, skipping...$(RESET)\n"; \
165+
fi
166+
@printf "$(BOLD)$(BRIGHT_GREEN)✅ Test environment ready!$(RESET)\n"
137167
@printf "$(BOLD)$(BRIGHT_MAGENTA)🚀 Running $(TARGET_NAME)...$(RESET)\n"
138168
@printf "$(DIM)$(WHITE)" && echo "================================================" && printf "$(RESET)"
139-
@./$(TARGET)
169+
@cd test-server && ./$(TARGET_NAME)
140170
@printf "$(DIM)$(WHITE)" && echo "================================================" && printf "$(RESET)"
141171

142172
# Display project information
@@ -190,8 +220,10 @@ help:
190220
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "all" "Build the project (default: release mode)"
191221
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "debug" "Build in debug mode"
192222
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "release" "Build in release mode"
193-
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "clean" "Remove all build artifacts"
194-
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "run" "Build and run the executable"
223+
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "clean" "Remove build artifacts (preserve dirs)"
224+
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "distclean" "Remove all build artifacts and dirs"
225+
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "clean-test" "Remove test-server directory"
226+
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "run" "Setup test-server and run executable"
195227
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "compile_commands" "Generate compile_commands.json for LSP"
196228
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "install" "Install the executable to system"
197229
@printf "$(BOLD)$(BRIGHT_CYAN)$(RESET) $(BRIGHT_GREEN)%-10s$(RESET) %-39s $(BOLD)$(BRIGHT_CYAN)$(RESET)\n" "uninstall" "Remove the executable from system"

config.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
{
2-
"version": {
3-
"name": "1.21.5",
4-
"protocol": 770
5-
},
6-
"server": {
7-
"ip-address": "127.0.0.1",
8-
"port": 25565,
9-
"motd": "§aServeur Minecraft en C!",
10-
"max-players": 20
11-
}
2+
"version": {
3+
"name": "1.21.5",
4+
"protocol": 770
5+
},
6+
"server": {
7+
"ip-address": "127.0.0.1",
8+
"port": 25565,
9+
"motd": "§aServeur Minecraft en C!",
10+
"max-players": 20
11+
},
12+
"world": {
13+
"name": "world",
14+
"gamemode": "survival",
15+
"difficulty": "normal"
16+
}
1217
}

external/data-generator

Submodule data-generator added at 45d7644

0 commit comments

Comments
 (0)