From 512ca2bb847da96a902149697c8f3dab9ac5913c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Mla=C4=8Dak?= Date: Fri, 24 Nov 2023 05:01:29 +0100 Subject: [PATCH] Added count of steps function. --- README.md | 4 ++-- ws/crochess/src/crochess.c | 2 +- ws/libcrochess/src/cc_path.c | 17 +++++++++++++++++ ws/libcrochess/src/cc_version.c | 2 +- ws/tests/src/tests.c | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5fad9b07b..f9ea5ddd9 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ converted to UTC for easier comparison. **Application** and **library versions** can be seen in an application, using `version` command. \ The latest versions are: -Application: 0.0.1.425:857+20231124.034927 \ -Library: 0.0.1.425:857+20231124.034927 +Application: 0.0.1.426:858+20231124.040129 \ +Library: 0.0.1.426:858+20231124.040129 Versioning used is [Natural Versioning 1.2](https://croatian-chess.blogspot.com/p/natver.html), with meta data containing the same format as the book version. diff --git a/ws/crochess/src/crochess.c b/ws/crochess/src/crochess.c index 403fc8252..dfde0e137 100644 --- a/ws/crochess/src/crochess.c +++ b/ws/crochess/src/crochess.c @@ -26,7 +26,7 @@ #include "crochess.h" -char const CROCHESS_VERSION[] = "0.0.1.425:857+20231124.034927"; // source-new-crochess-version-major-minor-feature-commit+meta~breaks-place-marker +char const CROCHESS_VERSION[] = "0.0.1.426:858+20231124.040129"; // source-new-crochess-version-major-minor-feature-commit+meta~breaks-place-marker #ifdef __WITH_LINE_NOISE__ char const CROCHESS_HISTORY_FILE_NAME[] = "history_crochess.txt"; diff --git a/ws/libcrochess/src/cc_path.c b/ws/libcrochess/src/cc_path.c index 50c0e85f2..da5fbfe6a 100644 --- a/ws/libcrochess/src/cc_path.c +++ b/ws/libcrochess/src/cc_path.c @@ -329,6 +329,23 @@ static bool cc_path_weak_get_next_route( CcPathNode * restrict path_node, return false; } +static size_t cc_path_weak_count_of_steps( CcPathWeak * restrict path_weak ) { + if ( !path_weak ) return 0; + if ( !cc_path_weak_check_if_valid( path_weak ) ) return 0; + + size_t count = 0; + CcPathWeak * pw = path_weak; + + CC_REWIND( pw ); + + while ( pw ) { + count += cc_ppt_link_len( pw->node__w->path ); + pw = pw->next; + } + + return count; +} + // // Auxilary functions. diff --git a/ws/libcrochess/src/cc_version.c b/ws/libcrochess/src/cc_version.c index 9cf55fa17..531d9f687 100644 --- a/ws/libcrochess/src/cc_version.c +++ b/ws/libcrochess/src/cc_version.c @@ -11,4 +11,4 @@ */ -char const CC_LIB_VERSION[] = "0.0.1.425:857+20231124.034927"; // source-new-libcrochess-version-major-minor-feature-commit+meta~breaks-place-marker +char const CC_LIB_VERSION[] = "0.0.1.426:858+20231124.040129"; // source-new-libcrochess-version-major-minor-feature-commit+meta~breaks-place-marker diff --git a/ws/tests/src/tests.c b/ws/tests/src/tests.c index 0de85b5ab..7877d574f 100644 --- a/ws/tests/src/tests.c +++ b/ws/tests/src/tests.c @@ -34,7 +34,7 @@ #include "tests.h" -char const CROCHESS_TESTS_VERSION[] = "0.0.1.425:857+20231124.034927"; // source-new-crochess-tests-version-major-minor-feature-commit+meta~breaks-place-marker +char const CROCHESS_TESTS_VERSION[] = "0.0.1.426:858+20231124.040129"; // source-new-crochess-tests-version-major-minor-feature-commit+meta~breaks-place-marker #ifdef __WITH_LINE_NOISE__ char const CROCHESS_TESTS_HISTORY_FILE_NAME[] = "history_tests.txt";