generated from AfonsoCMSousa/CPP-Template
fix: fixed .env file and parce
This commit is contained in:
parent
43827f8f12
commit
4901c4b523
161
CMakeLists.txt
161
CMakeLists.txt
@ -1,29 +1,57 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
project(CPP_TEMPLATE VERSION 0.1.0 LANGUAGES C CXX)
|
project(CPP_TEMPLATE VERSION 0.1.0 LANGUAGES C CXX)
|
||||||
|
|
||||||
|
# Set C++ standard
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
# Set C standard
|
||||||
|
set(CMAKE_C_STANDARD 17)
|
||||||
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_C_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
# Export compile commands for IDE support (clangd, etc.)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
# Create symlink to compile_commands.json in project root for LSP
|
||||||
|
if(CMAKE_EXPORT_COMPILE_COMMANDS)
|
||||||
|
add_custom_target(symlink_compile_commands ALL
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||||
|
${CMAKE_BINARY_DIR}/compile_commands.json
|
||||||
|
${CMAKE_SOURCE_DIR}/compile_commands.json
|
||||||
|
COMMENT "Creating symlink to compile_commands.json in project root"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Set output directories
|
# Set output directories
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
|
|
||||||
# Add include directories
|
# Build type defaults
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/libraries)
|
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Gather all source files (.cpp, .c)
|
# Options
|
||||||
|
option(ENABLE_SANITIZERS "Enable address and undefined behavior sanitizers" ON)
|
||||||
|
option(ENABLE_STATIC_ANALYSIS "Enable static analysis warnings" ON)
|
||||||
|
set(OUTPUT_NAME "" CACHE STRING "Name of the output executable (defaults to project name)")
|
||||||
|
|
||||||
|
# Gather source files (avoid GLOB_RECURSE - explicitly list files is better practice)
|
||||||
|
# But keeping it for template flexibility
|
||||||
file(GLOB_RECURSE PROJECT_SOURCES
|
file(GLOB_RECURSE PROJECT_SOURCES
|
||||||
${CMAKE_SOURCE_DIR}/include/*.cpp
|
|
||||||
${CMAKE_SOURCE_DIR}/include/*.c
|
|
||||||
${CMAKE_SOURCE_DIR}/libraries/*.cpp
|
|
||||||
${CMAKE_SOURCE_DIR}/libraries/*.c
|
|
||||||
${CMAKE_SOURCE_DIR}/source/*.cpp
|
${CMAKE_SOURCE_DIR}/source/*.cpp
|
||||||
${CMAKE_SOURCE_DIR}/source/*.c
|
${CMAKE_SOURCE_DIR}/source/*.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# Gather all header files (.hpp, .h)
|
file(GLOB_RECURSE LIBRARY_SOURCES
|
||||||
|
${CMAKE_SOURCE_DIR}/libraries/*.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/libraries/*.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Don't glob headers from include/ as sources (they should only be included)
|
||||||
file(GLOB_RECURSE PROJECT_HEADERS
|
file(GLOB_RECURSE PROJECT_HEADERS
|
||||||
${CMAKE_SOURCE_DIR}/include/*.hpp
|
${CMAKE_SOURCE_DIR}/include/*.hpp
|
||||||
${CMAKE_SOURCE_DIR}/include/*.h
|
${CMAKE_SOURCE_DIR}/include/*.h
|
||||||
@ -33,25 +61,51 @@ file(GLOB_RECURSE PROJECT_HEADERS
|
|||||||
${CMAKE_SOURCE_DIR}/source/*.h
|
${CMAKE_SOURCE_DIR}/source/*.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# Allow user to set output program name
|
# Combine all sources
|
||||||
option(OUTPUT_NAME "Name of the output executable" "")
|
set(ALL_SOURCES ${PROJECT_SOURCES} ${LIBRARY_SOURCES})
|
||||||
if(OUTPUT_NAME STREQUAL "")
|
|
||||||
set(EXECUTABLE_NAME ${PROJECT_NAME})
|
# Determine executable name
|
||||||
else()
|
if(OUTPUT_NAME)
|
||||||
set(EXECUTABLE_NAME ${OUTPUT_NAME})
|
set(EXECUTABLE_NAME ${OUTPUT_NAME})
|
||||||
|
else()
|
||||||
|
set(EXECUTABLE_NAME ${PROJECT_NAME})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add executable with all sources
|
# Create executable
|
||||||
add_executable(${EXECUTABLE_NAME}
|
add_executable(${EXECUTABLE_NAME} ${ALL_SOURCES})
|
||||||
${PROJECT_SOURCES}
|
|
||||||
|
# Set target properties
|
||||||
|
set_target_properties(${EXECUTABLE_NAME} PROPERTIES
|
||||||
|
OUTPUT_NAME ${EXECUTABLE_NAME}
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_NAME})
|
# Include directories - use target-specific commands
|
||||||
|
target_include_directories(${EXECUTABLE_NAME} PRIVATE
|
||||||
|
${CMAKE_SOURCE_DIR}/include
|
||||||
|
${CMAKE_SOURCE_DIR}/libraries
|
||||||
|
)
|
||||||
|
|
||||||
# Enable warnings and extra diagnostics
|
# Compiler-specific flags
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_options(${EXECUTABLE_NAME} PRIVATE /W4 /permissive- /analyze)
|
target_compile_options(${EXECUTABLE_NAME} PRIVATE
|
||||||
else()
|
/W4 # Warning level 4
|
||||||
|
/permissive- # Standards conformance
|
||||||
|
/Zc:__cplusplus # Correct __cplusplus macro
|
||||||
|
/Zc:inline # Remove unreferenced COMDAT
|
||||||
|
/WX- # Don't treat warnings as errors by default
|
||||||
|
)
|
||||||
|
|
||||||
|
if(ENABLE_STATIC_ANALYSIS)
|
||||||
|
target_compile_options(${EXECUTABLE_NAME} PRIVATE /analyze)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# MSVC debug flags
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
target_compile_options(${EXECUTABLE_NAME} PRIVATE /Zi /Od)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
else() # GCC/Clang
|
||||||
target_compile_options(${EXECUTABLE_NAME} PRIVATE
|
target_compile_options(${EXECUTABLE_NAME} PRIVATE
|
||||||
-Wall
|
-Wall
|
||||||
-Wextra
|
-Wextra
|
||||||
@ -62,11 +116,72 @@ else()
|
|||||||
-Wuninitialized
|
-Wuninitialized
|
||||||
-Wunused
|
-Wunused
|
||||||
-Werror=return-type
|
-Werror=return-type
|
||||||
-fsanitize=address,undefined
|
-Wcast-align
|
||||||
|
-Wformat=2
|
||||||
|
-Wnull-dereference
|
||||||
|
)
|
||||||
|
|
||||||
|
# Additional warnings for static analysis
|
||||||
|
if(ENABLE_STATIC_ANALYSIS)
|
||||||
|
target_compile_options(${EXECUTABLE_NAME} PRIVATE
|
||||||
|
-Wcast-qual
|
||||||
|
-Wdouble-promotion
|
||||||
|
-Wold-style-cast
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Sanitizers (Debug builds)
|
||||||
|
if(ENABLE_SANITIZERS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
# Check if sanitizers are available
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
check_cxx_compiler_flag("-fsanitize=address" HAS_ASAN)
|
||||||
|
check_cxx_compiler_flag("-fsanitize=undefined" HAS_UBSAN)
|
||||||
|
|
||||||
|
if(HAS_ASAN AND HAS_UBSAN)
|
||||||
|
target_compile_options(${EXECUTABLE_NAME} PRIVATE
|
||||||
|
-fsanitize=address,undefined,leak
|
||||||
|
-fno-omit-frame-pointer
|
||||||
-g
|
-g
|
||||||
)
|
)
|
||||||
target_link_options(${EXECUTABLE_NAME} PRIVATE -fsanitize=address,undefined)
|
target_link_options(${EXECUTABLE_NAME} PRIVATE
|
||||||
|
-fsanitize=address,undefined,leak
|
||||||
|
)
|
||||||
|
message(STATUS "Sanitizers enabled: address, undefined, leak")
|
||||||
|
else()
|
||||||
|
message(WARNING "Sanitizers requested but not available - skipping")
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Optimization flags for Release
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
|
target_compile_options(${EXECUTABLE_NAME} PRIVATE
|
||||||
|
-O3
|
||||||
|
-march=native
|
||||||
|
-DNDEBUG
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Debug flags
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
target_compile_options(${EXECUTABLE_NAME} PRIVATE
|
||||||
|
-O0
|
||||||
|
-g3
|
||||||
|
-ggdb
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Print configuration summary
|
||||||
|
message(STATUS "=== Configuration Summary ===")
|
||||||
|
message(STATUS "Project: ${PROJECT_NAME} v${PROJECT_VERSION}")
|
||||||
|
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
|
||||||
|
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
||||||
|
message(STATUS "C Standard: ${CMAKE_C_STANDARD}")
|
||||||
|
message(STATUS "Executable Name: ${EXECUTABLE_NAME}")
|
||||||
|
message(STATUS "Sanitizers: ${ENABLE_SANITIZERS}")
|
||||||
|
message(STATUS "Static Analysis: ${ENABLE_STATIC_ANALYSIS}")
|
||||||
|
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
|
||||||
|
message(STATUS "============================")
|
||||||
|
|
||||||
# Optionally, enable testing
|
# Optionally, enable testing
|
||||||
# enable_testing()
|
# enable_testing()
|
||||||
|
|||||||
BIN
PlayerTracker
BIN
PlayerTracker
Binary file not shown.
277
build.sh
277
build.sh
@ -1,37 +1,250 @@
|
|||||||
if [ -z "$1" ]; then
|
#!/bin/bash
|
||||||
echo "Error: Invalid Argument"
|
|
||||||
echo "Usage: $0 <executable_name>"
|
# Colors
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
MAGENTA='\033[0;35m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
BOLD='\033[1m'
|
||||||
|
|
||||||
|
# Unicode symbols
|
||||||
|
CHECK="✓"
|
||||||
|
CROSS="✗"
|
||||||
|
ARROW="➜"
|
||||||
|
GEAR="⚙"
|
||||||
|
HAMMER="🔨"
|
||||||
|
ROCKET="🚀"
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
BUILD_TYPE="Debug"
|
||||||
|
CLEAN_BUILD=false
|
||||||
|
VERBOSE=false
|
||||||
|
JOBS=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
|
||||||
|
|
||||||
|
# Print functions
|
||||||
|
print_header() {
|
||||||
|
echo -e "${BOLD}${BLUE}╔════════════════════════════════════════════════════════╗${NC}"
|
||||||
|
echo -e "${BOLD}${BLUE}║${NC} ${HAMMER} ${BOLD}${CYAN} C/C++ Project Builder${NC} ${BOLD}${BLUE}║${NC}"
|
||||||
|
echo -e "${BOLD}${BLUE}╚════════════════════════════════════════════════════════╝${NC}"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
print_separator() {
|
||||||
|
echo -e "${BLUE}────────────────────────────────────────────────────────${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_success() {
|
||||||
|
echo -e "${GREEN}${CHECK}${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_error() {
|
||||||
|
echo -e "${RED}${CROSS}${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_info() {
|
||||||
|
echo -e "${CYAN}${ARROW}${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_step() {
|
||||||
|
echo -e "${YELLOW}${GEAR}${NC} ${BOLD}$1${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
show_progress() {
|
||||||
|
local duration=$1
|
||||||
|
local prefix=$2
|
||||||
|
local size=40
|
||||||
|
already_done() { for ((done=0; done<$elapsed; done++)); do printf "▓"; done }
|
||||||
|
remaining() { for ((remain=$elapsed; remain<$size; remain++)); do printf " "; done }
|
||||||
|
percentage() { printf "| %s%%" $(( (($elapsed)*100)/($size)*100/100 )); }
|
||||||
|
|
||||||
|
for (( elapsed=1; elapsed<=$size; elapsed++ )); do
|
||||||
|
printf "\r${CYAN}${prefix}${NC} [$(already_done)$(remaining)] $(percentage)"
|
||||||
|
sleep $(echo "scale=3; $duration/$size" | bc)
|
||||||
|
done
|
||||||
|
printf "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo -e "${BOLD}Usage:${NC} $0 [OPTIONS] <executable_name>"
|
||||||
|
echo ""
|
||||||
|
echo -e "${BOLD}Options:${NC}"
|
||||||
|
echo -e " -r, --release Build in Release mode (default: Debug)"
|
||||||
|
echo -e " -c, --clean Clean build directory before building"
|
||||||
|
echo -e " -v, --verbose Verbose make output"
|
||||||
|
echo -e " -j, --jobs <N> Number of parallel jobs (default: $JOBS)"
|
||||||
|
echo -e " -h, --help Show this help message"
|
||||||
|
echo ""
|
||||||
|
echo -e "${BOLD}Examples:${NC}"
|
||||||
|
echo -e " $0 myprogram"
|
||||||
|
echo -e " $0 -r -j8 myprogram"
|
||||||
|
echo -e " $0 --clean --release myprogram"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
}
|
||||||
|
|
||||||
if [ ! -d "./build" ]; then
|
# Parse arguments
|
||||||
echo "Creating build directory..."
|
POSITIONAL_ARGS=()
|
||||||
mkdir build
|
while [[ $# -gt 0 ]]; do
|
||||||
fi
|
case $1 in
|
||||||
|
-r|--release)
|
||||||
echo ">>> Building C++ Project <<<"
|
BUILD_TYPE="Release"
|
||||||
cd ./build
|
shift
|
||||||
cmake -DOUTPUT_NAME=$1 ..
|
;;
|
||||||
echo ">>> Compiling... <<<"
|
-c|--clean)
|
||||||
make
|
CLEAN_BUILD=true
|
||||||
if [ $? -ne 0 ]; then
|
shift
|
||||||
echo "Error: Build failed"
|
;;
|
||||||
exit 1
|
-v|--verbose)
|
||||||
fi
|
VERBOSE=true
|
||||||
|
shift
|
||||||
cp ./bin/$1 ../
|
;;
|
||||||
cd ..
|
-j|--jobs)
|
||||||
|
JOBS="$2"
|
||||||
echo ">>> Copying PlayerTracker to AC Servers <<<"
|
shift 2
|
||||||
for server in ../servers/*; do
|
;;
|
||||||
if [ -d "$server/utils" ]; then
|
-h|--help)
|
||||||
target="$server/utils/ACPlayer_tracker"
|
usage
|
||||||
mkdir -p "$target"
|
;;
|
||||||
cp ./PlayerTracker "$target/"
|
*)
|
||||||
echo "Installed PlayerTracker to: $target"
|
POSITIONAL_ARGS+=("$1")
|
||||||
fi
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ">>> Build Complete <<<"
|
set -- "${POSITIONAL_ARGS[@]}"
|
||||||
echo ">>> Executable: $1 <<<"
|
|
||||||
|
|
||||||
|
# Check if executable name is provided
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
print_header
|
||||||
|
print_error "No executable name provided"
|
||||||
|
echo ""
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
EXECUTABLE_NAME=$1
|
||||||
|
|
||||||
|
# Start build process
|
||||||
|
print_header
|
||||||
|
|
||||||
|
# Build configuration info
|
||||||
|
print_info "Build Configuration:"
|
||||||
|
echo -e " ${BOLD}Executable:${NC} $EXECUTABLE_NAME"
|
||||||
|
echo -e " ${BOLD}Build Type:${NC} $BUILD_TYPE"
|
||||||
|
echo -e " ${BOLD}Jobs:${NC} $JOBS"
|
||||||
|
echo -e " ${BOLD}Clean Build:${NC} $CLEAN_BUILD"
|
||||||
|
echo ""
|
||||||
|
print_separator
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Clean build directory if requested
|
||||||
|
if [ "$CLEAN_BUILD" = true ] && [ -d "./build" ]; then
|
||||||
|
print_step "Cleaning build directory..."
|
||||||
|
rm -rf ./build
|
||||||
|
print_success "Build directory cleaned"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create build directory
|
||||||
|
if [ ! -d "./build" ]; then
|
||||||
|
print_step "Creating build directory..."
|
||||||
|
mkdir -p build
|
||||||
|
print_success "Build directory created"
|
||||||
|
else
|
||||||
|
print_info "Using existing build directory"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# CMake configuration
|
||||||
|
print_step "Configuring CMake..."
|
||||||
|
print_separator
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
cd ./build
|
||||||
|
|
||||||
|
CMAKE_CMD="cmake -DOUTPUT_NAME=$EXECUTABLE_NAME -DCMAKE_BUILD_TYPE=$BUILD_TYPE .."
|
||||||
|
|
||||||
|
if [ "$VERBOSE" = true ]; then
|
||||||
|
eval $CMAKE_CMD
|
||||||
|
else
|
||||||
|
eval $CMAKE_CMD > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
print_error "CMake configuration failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_success "CMake configuration complete"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Compilation
|
||||||
|
print_step "Compiling project..."
|
||||||
|
print_separator
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
MAKE_CMD="make -j$JOBS"
|
||||||
|
if [ "$VERBOSE" = true ]; then
|
||||||
|
MAKE_CMD="$MAKE_CMD VERBOSE=1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
START_TIME=$(date +%s)
|
||||||
|
|
||||||
|
if [ "$VERBOSE" = true ]; then
|
||||||
|
eval $MAKE_CMD
|
||||||
|
BUILD_RESULT=$?
|
||||||
|
else
|
||||||
|
eval $MAKE_CMD 2>&1 | tee build.log | while IFS= read -r line; do
|
||||||
|
if echo "$line" | grep -q "\[.*%\]"; then
|
||||||
|
printf "\r${CYAN}${ARROW}${NC} Compiling: %s" "$line"
|
||||||
|
elif echo "$line" | grep -qE "error:|Error|ERROR"; then
|
||||||
|
echo ""
|
||||||
|
print_error "$line"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
BUILD_RESULT=${PIPESTATUS[0]}
|
||||||
|
fi
|
||||||
|
|
||||||
|
END_TIME=$(date +%s)
|
||||||
|
BUILD_TIME=$((END_TIME - START_TIME))
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
if [ $BUILD_RESULT -ne 0 ]; then
|
||||||
|
print_error "Build failed!"
|
||||||
|
echo ""
|
||||||
|
print_info "Check build/build.log for details"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_success "Compilation complete (${BUILD_TIME}s)"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Copy executable
|
||||||
|
print_step "Copying executable to project root..."
|
||||||
|
|
||||||
|
if [ ! -f "./bin/$EXECUTABLE_NAME" ]; then
|
||||||
|
print_error "Executable not found: ./bin/$EXECUTABLE_NAME"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp ./bin/$EXECUTABLE_NAME ../
|
||||||
|
print_success "Executable copied"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Build summary
|
||||||
|
print_separator
|
||||||
|
echo -e "${BOLD}${GREEN}${ROCKET} Build Complete!${NC}"
|
||||||
|
print_separator
|
||||||
|
echo ""
|
||||||
|
echo -e "${BOLD}Summary:${NC}"
|
||||||
|
echo -e " ${BOLD}Executable:${NC} ./$EXECUTABLE_NAME"
|
||||||
|
echo -e " ${BOLD}Build Type:${NC} $BUILD_TYPE"
|
||||||
|
echo -e " ${BOLD}Build Time:${NC} ${BUILD_TIME}s"
|
||||||
|
echo -e " ${BOLD}Binary Location:${NC} ./build/bin/$EXECUTABLE_NAME"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
print_info "Run with: ${BOLD}./$EXECUTABLE_NAME${NC}"
|
||||||
|
echo ""
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
build/compile_commands.json
|
/home/afonsocmsousa/Developer/ac_sevice/ACPlayer_tracker/build/compile_commands.json
|
||||||
@ -80,8 +80,8 @@ typedef enum flag {
|
|||||||
|
|
||||||
typedef struct carAtributes {
|
typedef struct carAtributes {
|
||||||
// Related to ACSP_CAR_INFO
|
// Related to ACSP_CAR_INFO
|
||||||
u_char isConnected; // 1 = connected, 0 = disconnected
|
char isConnected; // 1 = connected, 0 = disconnected
|
||||||
u_char isLoading; // 1 = loading, 0 = not isLoading
|
char isLoading; // 1 = loading, 0 = not isLoading
|
||||||
|
|
||||||
char *car_model;
|
char *car_model;
|
||||||
char *car_skin;
|
char *car_skin;
|
||||||
@ -111,8 +111,8 @@ typedef struct carAtributes {
|
|||||||
|
|
||||||
typedef struct carAtributesAPI {
|
typedef struct carAtributesAPI {
|
||||||
// Related to ACSP_CAR_INFO
|
// Related to ACSP_CAR_INFO
|
||||||
u_char isConnected; // 1 = connected, 0 = disconnected
|
char isConnected; // 1 = connected, 0 = disconnected
|
||||||
u_char isLoading; // 1 = loading, 0 = not isLoading
|
char isLoading; // 1 = loading, 0 = not isLoading
|
||||||
|
|
||||||
char car_model[64];
|
char car_model[64];
|
||||||
char car_skin[64];
|
char car_skin[64];
|
||||||
@ -196,7 +196,7 @@ typedef struct trackAtributesAPI {
|
|||||||
} __attribute__((packed)) trackAtributesAPI;
|
} __attribute__((packed)) trackAtributesAPI;
|
||||||
|
|
||||||
typedef struct api_packet {
|
typedef struct api_packet {
|
||||||
u_char message_type; // ACSP_MessageType
|
char message_type; // ACSP_MessageType
|
||||||
u_int8_t tracker_id;
|
u_int8_t tracker_id;
|
||||||
u_int8_t connected_players;
|
u_int8_t connected_players;
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,8 @@ app_info parce_args(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
throw invalid_argument("No argc provided");
|
throw invalid_argument("No argc provided");
|
||||||
|
} else if (argc != 4) {
|
||||||
|
throw invalid_argument("Invalid number of args provided");
|
||||||
}
|
}
|
||||||
|
|
||||||
__processed_info.app_id = (u_int16_t)atoi(argv[1]);
|
__processed_info.app_id = (u_int16_t)atoi(argv[1]);
|
||||||
@ -24,9 +24,11 @@ int main(int argc, char *argv[]) {
|
|||||||
sock.send();
|
sock.send();
|
||||||
} catch (const runtime_error &e) {
|
} catch (const runtime_error &e) {
|
||||||
cerr << "Error: " << e.what() << endl;
|
cerr << "Error: " << e.what() << endl;
|
||||||
|
cout << "Usage: ./PlayerTracker <app_id> <port_in> <port_out>" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#include "parcer.h"
|
#include "parcer.h"
|
||||||
#include "server_structs.h"
|
#include "server_structs.h"
|
||||||
|
#include <netinet/in.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
int ensure(size_t recv_len, size_t offset, size_t need) {
|
int ensure(size_t recv_len, size_t offset, size_t need) {
|
||||||
return (offset + need <= recv_len);
|
return (offset + need <= recv_len);
|
||||||
@ -47,7 +49,7 @@ int32_t read_int32(const u_int8_t *buf, size_t recv_len, size_t *offset, int *ok
|
|||||||
int32_t v;
|
int32_t v;
|
||||||
memcpy(&v, buf + *offset, sizeof(v));
|
memcpy(&v, buf + *offset, sizeof(v));
|
||||||
*offset += sizeof(v);
|
*offset += sizeof(v);
|
||||||
return (int32_t)ntohl(v);
|
return (int32_t)ntohl((u_int32_t)v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float read_float(const u_int8_t *buf, size_t recv_len, size_t *offset, int *ok) {
|
float read_float(const u_int8_t *buf, size_t recv_len, size_t *offset, int *ok) {
|
||||||
Loading…
x
Reference in New Issue
Block a user