Add prototype gameplay loop with character/battlefield assets and server game APIs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,9 +4,30 @@ project(AIServer LANGUAGES C CXX)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(GAMEPLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../Config/Gameplay/greenfield.json")
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${GAMEPLAY_FILE}")
|
||||
file(READ "${GAMEPLAY_FILE}" GAMEPLAY_JSON)
|
||||
file(SHA256 "${GAMEPLAY_FILE}" GAMEPLAY_HASH)
|
||||
string(SUBSTRING "${GAMEPLAY_HASH}" 0 12 GAMEPLAY_HASH_SHORT)
|
||||
set(GAMEPLAY_VERSION "greenfield-1-${GAMEPLAY_HASH_SHORT}")
|
||||
# MSVC caps a single string literal at 16380 bytes; emit adjacent chunks that concatenate back
|
||||
# to the exact file bytes (splitting at a fixed byte offset never rewrites any character).
|
||||
string(LENGTH "${GAMEPLAY_JSON}" GAMEPLAY_JSON_LENGTH)
|
||||
set(GAMEPLAY_JSON_CHUNKS "")
|
||||
set(GAMEPLAY_JSON_OFFSET 0)
|
||||
while(GAMEPLAY_JSON_OFFSET LESS GAMEPLAY_JSON_LENGTH)
|
||||
string(SUBSTRING "${GAMEPLAY_JSON}" ${GAMEPLAY_JSON_OFFSET} 8000 GAMEPLAY_JSON_PART)
|
||||
string(APPEND GAMEPLAY_JSON_CHUNKS "R\"GAMECONFIG(${GAMEPLAY_JSON_PART})GAMECONFIG\"\n")
|
||||
math(EXPR GAMEPLAY_JSON_OFFSET "${GAMEPLAY_JSON_OFFSET} + 8000")
|
||||
endwhile()
|
||||
configure_file(src/game_config.hpp.in generated/game_config_data.hpp @ONLY)
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
|
||||
add_executable(aiserver
|
||||
src/main.cpp
|
||||
src/db.cpp
|
||||
src/game.cpp
|
||||
src/game_config.cpp
|
||||
src/auth.cpp
|
||||
src/http_ws_server.cpp
|
||||
src/maintenance.cpp
|
||||
@@ -41,3 +62,17 @@ endif()
|
||||
add_custom_command(TARGET aiserver POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:aiserver>/data
|
||||
)
|
||||
|
||||
include(CTest)
|
||||
if(BUILD_TESTING)
|
||||
add_executable(game_tests tests/game_tests.cpp src/db.cpp src/game.cpp src/game_config.cpp third_party/sqlite3.c)
|
||||
target_include_directories(game_tests PRIVATE src third_party)
|
||||
target_compile_definitions(game_tests PRIVATE SQLITE_OMIT_LOAD_EXTENSION SQLITE_THREADSAFE=1 _CRT_SECURE_NO_WARNINGS)
|
||||
target_compile_definitions(game_tests PRIVATE GAME_TEST_FIXTURE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tests/fixtures")
|
||||
if(MSVC)
|
||||
target_compile_options(game_tests PRIVATE /W3 /utf-8)
|
||||
elseif(NOT WIN32)
|
||||
target_link_libraries(game_tests PRIVATE pthread dl)
|
||||
endif()
|
||||
add_test(NAME game_transactions COMMAND game_tests)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user