diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index abba789..2f3021c 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,5 +1,11 @@ cmake_minimum_required( VERSION 2.8.7 ) +# Set version information +set( TTRTS_VERSION_MAJOR 0 ) +set( TTRTS_VERSION_MINOR 0 ) +set( TTRTS_VERSION_PATCH 1 ) +set( TTRTS_VERSION_STRING "${TTRTS_VERSION_MAJOR}.${TTRTS_VERSION_MINOR}.${TTRTS_VERSION_PATCH}") + # Use c++1y (14) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++1y" ) @@ -9,10 +15,20 @@ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-reorder" ) # Turn off reorder warnings as they're kind of irrelevant set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder" ) +# This shouldn't be needed, but it looks like IDE's like clion can forget to set -g for Debug if( CMAKE_BUILD_TYPE MATCHES "Debug" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g" ) endif() +# Add definitions for the version number +add_definitions( + -DTTRTS_VERSION_MAJOR=${TTRTS_VERSION_MAJOR} + -DTTRTS_VERSION_MINOR=${TTRTS_VERSION_MINOR} + -DTTRTS_VERSION_PATCH=${TTRTS_VERSION_PATCH} + -DTTRTS_VERSION_STRING=\"${DTTRTS_VERSION_STRING}\" +) + + # Subprojects add_subdirectory( ttrts ) add_subdirectory( game ) diff --git a/source/game/game.h b/source/game/game.h index 5e68b42..4662776 100644 --- a/source/game/game.h +++ b/source/game/game.h @@ -5,7 +5,7 @@ #include "gametypes.h" #include "order.h" -#define GAME_HEADER_FORMATTER "===== %s =====\nSIZE:[%u,%u]\nTURN:%u" +#define GAME_HEADER_FORMATTER "NAME:%s\nSIZE:[%u,%u]\nTURN:%u" #define GAME_HEADER_DELIMITER "~~~~\n" // Type for order and unit pairs diff --git a/source/ttrts/CMakeLists.txt b/source/ttrts/CMakeLists.txt index 2a49815..d7aa9da 100644 --- a/source/ttrts/CMakeLists.txt +++ b/source/ttrts/CMakeLists.txt @@ -8,8 +8,8 @@ include_directories( ../game ) -# Add the sources -set( SOURCES +# Add the sources +set( SOURCES main.cpp ) @@ -22,8 +22,8 @@ target_link_libraries( ${PROJECT_NAME} game ) install( TARGETS ${PROJECT_NAME} DESTINATION bin ) # Run the gen_usage script to generate our usage header -add_custom_target( +add_custom_target( gen_ttrts_usage cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_SOURCE_DIR}/scripts/gen_usage.sh "${CMAKE_CURRENT_BINARY_DIR}/usage.h" ) -add_dependencies(${PROJECT_NAME} gen_ttrts_usage) +add_dependencies(${PROJECT_NAME} gen_ttrts_usage) \ No newline at end of file diff --git a/source/ttrts/README.md b/source/ttrts/README.md index 2579dc5..a6d197a 100644 --- a/source/ttrts/README.md +++ b/source/ttrts/README.md @@ -29,18 +29,20 @@ ## OPTIONS MAPFILE - File to read in the initial game state from -------------------------------------------------------------------------------- +-------------------------------------------------------------- ## GAMESTATE FILE FORMAT ### Name Turn_{TURN_NUMBER}.txt ### Contents - ===== {GAME_NAME} ===== + ===== ttrts v{MAJOR}.{MINOR}.{PATCH} ===== + NAME:{GAMENAME} SIZE:[{X},{Y}] TURN:{TURN_NUMBER} + ... {any extra properties could go here} ~~~~ UNIT:{ID} tm:{TEAM} vs:{VIS} dr:{DIR(NESW)} ps:[{X},{Y}] - ... + ... {continue for all units} ## ORDER FILE FORMAT ### Name diff --git a/source/ttrts/main.cpp b/source/ttrts/main.cpp index 7ecc424..e783116 100644 --- a/source/ttrts/main.cpp +++ b/source/ttrts/main.cpp @@ -6,6 +6,7 @@ #include #include "game.h" +#include "version.h" static const char* sk_usage = #include "usage.h" @@ -40,6 +41,13 @@ bool OutputGameStateFile(CTTRTSGame &game, std::string &gameDir) // Output the turn description std::string turnDescriptor = game.GetStateAsString(); + + // Append the version number + turnDescriptor = std::string("==== ttrts v") + + sk_ttrts_version_string + + std::string(" ====") + + turnDescriptor; + turnFile<