Skip to content

Commit

Permalink
r11440
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarix committed Nov 26, 2024
2 parents ee2051d + fb1d6e0 commit 9d0bb40
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/makeobj.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
install: base-devel mingw-w64-i686-toolchain mingw-w64-i686-gcc mingw-w64-i686-libpng

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: build
shell: msys2 {0}
Expand Down
32 changes: 32 additions & 0 deletions cmake/SimutransRevision.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,38 @@ if (SIMUTRANS_WC_REVISION)
# reduces needless rebuilds
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different revision.h.txt "${SOURCE_DIR}/src/simutrans/revision.h")

# gather informations to update flatpak and Android creation files
STRING(STRIP ${SIMUTRANS_WC_REVISION} SIMUTRANS_WC_REVISION)

file(READ "${SOURCE_DIR}/src/simutrans/simversion.h" FILE_CONTENT)
string(REGEX MATCH "#define SIM_VERSION_MAJOR[ ]+([0-9]*)" _ ${FILE_CONTENT})
set(ver_major ${CMAKE_MATCH_1})
string(REGEX MATCH "#define SIM_VERSION_MINOR[ ]+([0-9]*)" _ ${FILE_CONTENT})
set(ver_minor ${CMAKE_MATCH_1})
string(REGEX MATCH "#define SIM_VERSION_PATCH[ ]+([0-9]*)" _ ${FILE_CONTENT})
set(ver_patch ${CMAKE_MATCH_1})
string(REGEX MATCH "#define[ ]+SIM_VERSION_BUILD[ ]+SIM_BUILD_RELEASE[\r\n]+" RELEASE_FLAG ${FILE_CONTENT})

string(TIMESTAMP TODAY "%Y-%m-%d")

# finally, update flatpak xml
file(READ "${SOURCE_DIR}/src/linux/com.simutrans.Simutrans.metainfo.xml" FILE_CONTENT)
if(RELEASE_FLAG STREQUAL "")
string(REGEX REPLACE "<release .*/>" "<release version=\"${ver_major}.${ver_minor}.${ver_patch} nightly\" date=\"${TODAY}\" revision=\"${SIMUTRANS_WC_REVISION}\"/>" FILE_CONTENT "${FILE_CONTENT}" )
else ()
string(REGEX REPLACE "<release .*/>" "<release version=\"${ver_major}.${ver_minor}.${ver_patch}\" date=\"${TODAY}\" revision=\"${SIMUTRANS_WC_REVISION}\"/>" FILE_CONTENT "${FILE_CONTENT}" )
endif ()
file(WRITE "${SOURCE_DIR}/src/linux/com.simutrans.Simutrans.metainfo.xml" "${FILE_CONTENT}")

# and Android files
file(READ "${SOURCE_DIR}/src/android/AndroidAppSettings.cfg" FILE_CONTENT)
if(RELEASE_FLAG STREQUAL "")
string(REGEX REPLACE "AppVersionName=\"[0-9.]+-[A-z]+[a-z]+\"" "AppVersionName=\"${ver_major}.${ver_minor}.${ver_patch}-Nightly\"" FILE_CONTENT "${FILE_CONTENT}" )
else ()
string(REGEX REPLACE "AppVersionName=\"[0-9.]+-[A-z]+[a-z]+\"" "AppVersionName=\"${ver_major}.${ver_minor}.${ver_patch}-Release\"" FILE_CONTENT "${FILE_CONTENT}" )
endif ()
file(WRITE "${SOURCE_DIR}/src/android/AndroidAppSettings.cfg" "${FILE_CONTENT}")

else ()
message(WARNING "Could not find revision information because this repository "
"is neither a Subversion nor a Git repository. Revision information "
Expand Down
2 changes: 1 addition & 1 deletion revision.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define REVISION 11438
#define REVISION 11440
2 changes: 1 addition & 1 deletion src/simutrans/revision.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define REVISION 11438
#define REVISION 11440
15 changes: 15 additions & 0 deletions tests/tests/test_city.nut
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ function test_city_add_by_public_player()
ASSERT_EQUAL(command_x(tool_add_city).work(player_x(1), coord3d(7, 8, 0)), null)

ASSERT_TRUE(tile_x(7, 8, 0).find_object(mo_building) != null)
ASSERT_TRUE(tile_x(6, 9, 0).get_way(wt_road) != null)
ASSERT_TRUE(tile_x(7, 9, 0).get_way(wt_road) != null)
ASSERT_TRUE(tile_x(8, 9, 0).get_way(wt_road) != null)
}

// clean up
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(7, 8, 0)), null)
// street
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(6, 9, 0)), null)
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(7, 9, 0)), null)
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(8, 9, 0)), null)
RESET_ALL_PLAYER_FUNDS()
}

Expand All @@ -49,7 +54,10 @@ function test_city_add_on_existing_townhall()

// clean up
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(7, 8, 0)), null)
// street
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(6, 9, 0)), null)
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(7, 9, 0)), null)
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(8, 9, 0)), null)
RESET_ALL_PLAYER_FUNDS()
}

Expand All @@ -61,11 +69,14 @@ function test_city_add_near_map_border()

ASSERT_TRUE(tile_x(0, 14, 0).find_object(mo_building) != null)
ASSERT_TRUE(tile_x(0, 15, 0).get_way(wt_road) != null)
ASSERT_TRUE(tile_x(1, 15, 0).get_way(wt_road) != null)
}

// clean up
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(0, 14, 0)), null)
// street
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(0, 15, 0)), null)
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(1, 15, 0)), null)
RESET_ALL_PLAYER_FUNDS()
}

Expand Down Expand Up @@ -143,6 +154,10 @@ function test_city_change_size_to_minimum()

// clean up
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(1, 1, 0)), null)
// street
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(0, 2, 0)), null)
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(1, 2, 0)), null)
ASSERT_EQUAL(command_x(tool_remover).work(player_x(1), coord3d(2, 2, 0)), null)

RESET_ALL_PLAYER_FUNDS()
}

0 comments on commit 9d0bb40

Please sign in to comment.