Compare commits

..
Author SHA1 Message Date
admin 731d8a72ad Remove FunctionalRandom asInstanceOf casts 2026-06-20 15:59:58 -07:00
adminandGitHub 6a9e1d7ad7 Remove redundant virtual from retreat command (#7420) 2026-06-20 14:17:46 -07:00
adminandGitHub 84f182d74f Fail iOS build when Addressables runtime data is missing (#7424) 2026-06-20 14:16:26 -07:00
adminandGitHub d08402c502 Remove stale unused casts from Shardok server main (#7417) 2026-06-20 14:11:14 -07:00
adminandGitHub b6a7c38a70 Tidy unused MCTS parameters (#7419) 2026-06-20 14:10:54 -07:00
adminandGitHub 9513c1e404 Remove final test asInstanceOf uses (#7418) 2026-06-20 14:09:33 -07:00
adminandGitHub d67d8b9784 Use inside in attack decision hostile army fixtures (#7415) 2026-06-20 14:04:49 -07:00
adminandGitHub fdc643bac0 Use inside in attack decision allied army fixtures (#7413) 2026-06-20 14:04:36 -07:00
adminandGitHub 9e7890a1a6 Use inside in province events drought fixtures (#7411) 2026-06-20 14:04:23 -07:00
adminandGitHub e9d876e5c9 Use nullptr in server configuration parser (#7416) 2026-06-20 14:03:10 -07:00
adminandGitHub 524c15b824 Use using for remaining C++ aliases (#7414) 2026-06-20 14:02:48 -07:00
adminandGitHub 0891ccb0af Tidy remaining C++ include guards (#7412) 2026-06-20 14:02:22 -07:00
adminandGitHub 179288fa25 Use inside in province events conflict fixtures (#7410) 2026-06-20 13:11:31 -07:00
adminandGitHub 4a8b6df484 Use inside in province events riot condition fixtures (#7409) 2026-06-20 13:07:09 -07:00
adminandGitHub 73b5e1a8cc Use inside for resolve battle flee province change (#7407) 2026-06-20 13:06:08 -07:00
adminandGitHub 8fa012cb73 Tidy unit guard (#7408) 2026-06-20 13:05:21 -07:00
adminandGitHub 8561c606eb Tidy fire utils guard (#7406) 2026-06-20 13:05:06 -07:00
adminandGitHub abed097cad Tidy hex map utils guard (#7405) 2026-06-20 13:04:45 -07:00
adminandGitHub ccd7e6db18 Use inside in resolve battle quest province checks (#7404) 2026-06-20 13:00:40 -07:00
adminandGitHub e6c648c03e Use inside in resolve battle captured hero checks (#7403) 2026-06-20 13:00:21 -07:00
adminandGitHub a4278cb6f2 Use inside in attack decision battalion fixtures (#7402) 2026-06-20 13:00:02 -07:00
adminandGitHub ce9ddc049e Use inside in attack decision status fixtures (#7401) 2026-06-20 12:59:33 -07:00
adminandGitHub 3646fd868a Use inside in province events riot fixtures (#7398) 2026-06-20 12:59:11 -07:00
adminandGitHub 288428c874 Use using for tile modifier alias (#7399) 2026-06-20 12:58:03 -07:00
adminandGitHub 1f30d13454 Tidy zone control guard (#7400) 2026-06-20 12:57:48 -07:00
adminandGitHub 6712a495ff Tidy terrain guard (#7397) 2026-06-20 12:57:25 -07:00
adminandGitHub 8ac26578e3 Use inside in attack decision helper fixtures (#7396) 2026-06-20 12:44:50 -07:00
adminandGitHub 049c7abb81 Use inside in fulfill quests fixtures (#7395) 2026-06-20 12:44:17 -07:00
adminandGitHub 123e0066d7 Use inside in attack command chooser fixtures (#7394) 2026-06-20 12:43:56 -07:00
adminandGitHub 3cff277132 Use inside in seek more leaders fixtures (#7393) 2026-06-20 12:43:33 -07:00
adminandGitHub ebb6a55ef8 Use inside in province move resolution fixture (#7392) 2026-06-20 12:43:05 -07:00
adminandGitHub a2d371fcfc Use inside in manage prisoners availability fixtures (#7390) 2026-06-20 12:42:45 -07:00
adminandGitHub b1d30c4f03 Use inside in captured hero availability fixtures (#7389) 2026-06-20 12:42:21 -07:00
adminandGitHub 67911c12f6 Use inside in break alliance availability test (#7386) 2026-06-20 12:41:58 -07:00
adminandGitHub 25db6649f3 Use inside for new year fixture helpers (#7385) 2026-06-20 12:41:40 -07:00
adminandGitHub 6a5d9df1a4 Use inside for battle flee army assertions (#7383) 2026-06-20 12:41:18 -07:00
adminandGitHub 8254600b5c Tidy hex map direction guard (#7391) 2026-06-20 08:45:01 -07:00
adminandGitHub 8b0d43a5ee Tidy coordinates guard (#7388) 2026-06-20 08:44:45 -07:00
adminandGitHub 99b1827048 Tidy shardok c types guard (#7387) 2026-06-20 08:44:20 -07:00
adminandGitHub 8368f4f762 Tidy shardok action aliases (#7382) 2026-06-20 08:43:49 -07:00
adminandGitHub eda94bd881 Tidy percentile roll odds aliases (#7384) 2026-06-20 08:27:17 -07:00
adminandGitHub 2c8b3e6089 Pattern match attack decision phase filters (#7381) 2026-06-20 08:22:27 -07:00
adminandGitHub d9376ee870 Tidy battalion type helpers (#7380) 2026-06-20 08:21:55 -07:00
adminandGitHub 94473eaac6 Use inside for province event epidemic assertions (#7379) 2026-06-20 08:21:15 -07:00
adminandGitHub ff2caaac1c Use inside for forced turn back province assertions (#7378) 2026-06-20 08:20:51 -07:00
adminandGitHub 2fc7d91b6b Use inside in prisoner exchange test (#7375) 2026-06-20 08:20:27 -07:00
adminandGitHub f74ef641d8 Use inside for defender victory battle assertions (#7377) 2026-06-20 08:19:58 -07:00
adminandGitHub 1aa23d2992 Use inside for food consumption battalion assertions (#7374) 2026-06-20 08:19:01 -07:00
adminandGitHub 2fd86301ce Use inside for new year battalion assertions (#7372) 2026-06-20 08:16:17 -07:00
adminandGitHub 2c2a6a083b Tidy battalion damage helpers (#7376) 2026-06-20 08:15:13 -07:00
adminandGitHub 3462d7e6b3 Tidy sequence random generator header (#7370) 2026-06-20 08:14:45 -07:00
adminandGitHub d9a56d5cc5 Tidy tile modifier integrity bounds (#7373) 2026-06-20 08:14:11 -07:00
adminandGitHub db8a50edab Use inside in defense decision phase test (#7371) 2026-06-20 08:01:50 -07:00
adminandGitHub e815438212 Scope AttackOrientation enum (#7369) 2026-06-20 07:58:42 -07:00
adminandGitHub a31ce39009 Tidy ActionCost value type (#7366) 2026-06-20 07:58:20 -07:00
adminandGitHub 8d8abf0f90 Use inside in attack decision availability test (#7365) 2026-06-20 07:57:56 -07:00
adminandGitHub c9faf440ce Use inside for captured defender battle assertions (#7368) 2026-06-20 07:57:38 -07:00
adminandGitHub 14aec4f6d0 Use inside for outlawed defender battle assertions (#7367) 2026-06-20 07:57:07 -07:00
adminandGitHub 5b11135abb Use inside in captured hero availability test (#7364) 2026-06-20 07:56:25 -07:00
adminandGitHub 3ce4ad3770 Use inside in manage prisoner availability test (#7363) 2026-06-20 07:54:10 -07:00
adminandGitHub 65bc952a5a Use inside in forced turn back test (#7362) 2026-06-20 07:53:54 -07:00
adminandGitHub 01be354271 Use inside for new year province assertions (#7361) 2026-06-20 07:53:31 -07:00
adminandGitHub 2634c7c3c8 Tidy random generator header (#7358) 2026-06-20 07:49:34 -07:00
adminandGitHub 30789f86f6 Tidy Shardok unit helpers (#7355) 2026-06-20 07:49:09 -07:00
adminandGitHub 404028bb59 Always package Windows Addressables runtime data (#7360) 2026-06-20 07:47:26 -07:00
adminandGitHub ea25b9ea79 Use inside for new year hero assertions (#7359) 2026-06-20 07:43:03 -07:00
adminandGitHub 423940ad3b Use inside in send supplies test (#7357) 2026-06-20 07:42:47 -07:00
adminandGitHub 44d8ba6c40 Use inside for province event assertions (#7356) 2026-06-20 07:42:32 -07:00
adminandGitHub 87ea1f1727 Use inside in recon resolution tests (#7354) 2026-06-20 07:41:47 -07:00
adminandGitHub 76c70166ee Scope DamageType enum (#7353) 2026-06-20 07:30:13 -07:00
adminandGitHub 40706f96a3 Use inside for action result test casts (#7351) 2026-06-20 07:28:40 -07:00
adminandGitHub f04bcd61f7 Clean up CombatDamage storage (#7349) 2026-06-20 06:07:28 -07:00
adminandGitHub d415e97672 Use inside for selected Scala test casts (#7350) 2026-06-20 06:05:15 -07:00
adminandGitHub e22a6d987c Add clang-tidy runner script (#7347) 2026-06-19 22:23:03 -07:00
adminandGitHub ba60421024 Tighten Shardok C++ library tests (#7346) 2026-06-19 22:18:25 -07:00
adminandGitHub 0dd7d75878 Improve Shardok C++ safety checks (#7345) 2026-06-19 22:11:02 -07:00
adminandGitHub e77afba638 Increase handle riot give toggle tap targets (#7344) 2026-06-19 21:59:32 -07:00
adminandGitHub 2d69336245 Increase resource control tap targets (#7343) 2026-06-19 21:59:19 -07:00
adminandGitHub 934f3c594e Increase remaining command tap targets (#7342) 2026-06-19 21:59:04 -07:00
adminandGitHub 4cb56f80c6 Increase diplomacy tap targets (#7341) 2026-06-19 18:28:12 -07:00
adminandGitHub 212f19ba40 Increase attack decision tap targets (#7340) 2026-06-19 18:27:17 -07:00
adminandGitHub 9e4f052653 Increase command panel info tap target (#7339) 2026-06-19 18:20:05 -07:00
adminandGitHub afa85afebf Increase prisoner action tap targets (#7338) 2026-06-19 18:19:52 -07:00
adminandGitHub c6514be984 Increase ransom offer button tap targets (#7337) 2026-06-19 16:58:11 -07:00
adminandGitHub 719323d3c7 Restore stale text request invariant (#7336) 2026-06-19 14:20:23 -07:00
adminandGitHub 47fd3733b2 Prune generated text after rewind (#7335)
* Prune text store entries after rewind

* Fix rewind controller test text store expectation
2026-06-19 14:12:12 -07:00
adminandGitHub d7a6241a90 Include Shardok rows in Postgres save exports (#7334) 2026-06-19 13:51:12 -07:00
adminandGitHub ce37e37fb6 Resubmit orphaned outstanding Shardok battles (#7333) 2026-06-19 13:38:54 -07:00
adminandGitHub 536af1f547 Advance saved games after load or rewind (#7332) 2026-06-19 13:26:28 -07:00
adminandGitHub 7c69a9da0e Guard raw rewinds into missing battle state (#7331) 2026-06-19 13:23:38 -07:00
adminandGitHub 548f72e6fc Avoid reflection in raw Postgres history JSON (#7330) 2026-06-19 12:57:26 -07:00
adminandGitHub 1d5aa0c7aa Support raw Postgres history recovery (#7329) 2026-06-19 11:57:34 -07:00
adminandGitHub c00631d6dc Support raw rewind for Postgres saves (#7328) 2026-06-19 11:07:09 -07:00
adminandGitHub f3e6285828 Generate pleas for evacuated secured prisoners (#7327) 2026-06-19 07:47:06 -07:00
adminandGitHub 866c39283d Fix admin saved game transfer for Postgres (#7326) 2026-06-19 07:46:42 -07:00
151 changed files with 3213 additions and 1917 deletions
+26
View File
@@ -22,6 +22,32 @@ common --per_file_copt=src/test/cpp/.*@-Wno-sign-compare
common --per_file_copt=src/test/cpp/.*@-Wno-unknown-warning-option
common --host_cxxopt="--std=c++23"
# C++ sanitizer configs for targeted Shardok safety checks.
# Example: bazel test --config=asan //src/test/cpp/net/eagle0/shardok/library/...
build:asan --compilation_mode=dbg
build:asan --strip=never
build:asan --copt=-fno-omit-frame-pointer
build:asan --copt=-Wno-macro-redefined
build:asan --copt=-fsanitize=address
build:asan --linkopt=-fsanitize=address
test:asan --test_env=ASAN_OPTIONS=detect_leaks=0:strict_init_order=1
build:ubsan --compilation_mode=dbg
build:ubsan --strip=never
build:ubsan --copt=-fno-omit-frame-pointer
build:ubsan --copt=-Wno-macro-redefined
build:ubsan --copt=-fsanitize=undefined
build:ubsan --linkopt=-fsanitize=undefined
test:ubsan --test_env=UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1
build:tsan --compilation_mode=dbg
build:tsan --strip=never
build:tsan --copt=-fno-omit-frame-pointer
build:tsan --copt=-Wno-macro-redefined
build:tsan --copt=-fsanitize=thread
build:tsan --linkopt=-fsanitize=thread
test:tsan --test_env=TSAN_OPTIONS=halt_on_error=1
common --javacopt="-Xlint:-options"
# Prefer protobuf's prebuilt protoc toolchain instead of building protoc from
+32
View File
@@ -0,0 +1,32 @@
Checks: >
-*,
bugprone-*,
performance-*,
readability-*,
modernize-*,
cppcoreguidelines-*,
-bugprone-easily-swappable-parameters,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-type-vararg,
-modernize-use-trailing-return-type,
-readability-convert-member-functions-to-static,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-magic-numbers
WarningsAsErrors: ''
HeaderFilterRegex: 'src/(main|test)/cpp/net/eagle0/(shardok|common)/.*'
FormatStyle: file
CheckOptions:
readability-braces-around-statements.ShortStatementLines: '1'
readability-function-size.LineThreshold: '160'
readability-function-size.StatementThreshold: '80'
readability-function-size.BranchThreshold: '20'
modernize-use-nullptr.NullMacros: 'NULL'
+1 -1
View File
@@ -287,7 +287,7 @@ jobs:
./ci/github_actions/detect_addressables_changes.sh "$BASE_SHA" "${{ github.sha }}"
- name: Build Windows unity
run: ./ci/github_actions/build_unity.sh "${{ env.EAGLE0_BUILD_DIR }}/eagle0WIN" "${{ steps.addressables.outputs.changed }}" "${{ steps.addressables.outputs.changed }}"
run: ./ci/github_actions/build_unity.sh "${{ env.EAGLE0_BUILD_DIR }}/eagle0WIN" true "${{ steps.addressables.outputs.changed }}"
- name: Save build SHA for Bee/ cache invalidation
if: success()
+14
View File
@@ -59,6 +59,20 @@ if [ $UNITY_EXIT_CODE -ne 0 ]; then
exit $UNITY_EXIT_CODE
fi
if [ ! -f "$LOG_PATH" ]; then
echo ""
echo "ERROR: Unity exited successfully but did not write an editor log at $LOG_PATH"
exit 1
fi
if [ ! -f "$BUILD_PATH/Data/Raw/aa/settings.json" ]; then
echo ""
echo "ERROR: iOS player is missing Addressables runtime data at:"
echo " $BUILD_PATH/Data/Raw/aa/settings.json"
echo "Build Addressables before packaging the player so Addressables can initialize at runtime."
exit 1
fi
# Fail the build if any prefab references are broken — this produces a player
# that launches but has null Inspector fields, which is hard to debug.
if grep -q "Missing Prefab" "$LOG_PATH"; then
+8
View File
@@ -57,6 +57,14 @@ if [ ! -f "$LOG_PATH" ]; then
exit 1
fi
if [ ! -f "$BUILD_DIR/eagle0_Data/StreamingAssets/aa/settings.json" ]; then
echo ""
echo "ERROR: Windows player is missing Addressables runtime data at:"
echo " $BUILD_DIR/eagle0_Data/StreamingAssets/aa/settings.json"
echo "Build Addressables before packaging the player so Addressables can initialize at runtime."
exit 1
fi
# Fail the build if any prefab references are broken — this produces a player
# that launches but has null Inspector fields, which is hard to debug.
if grep -q "Missing Prefab" "$LOG_PATH"; then
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# Runs the repository-pinned clang-tidy binary from the workspace root.
#
# Bazel's `run` command executes clang-tidy from its runfiles tree, which makes
# workspace-relative source paths and .clang-tidy discovery fail. This wrapper
# builds the tool and then invokes the produced binary directly.
set -e
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
repo_root="$(git rev-parse --show-toplevel)"
if [ "$#" -eq 0 ]; then
echo "Usage: scripts/run-clang-tidy.sh [clang-tidy args] <files> [-- <compiler args>]"
echo ""
echo "Examples:"
echo " scripts/run-clang-tidy.sh --verify-config"
echo " scripts/run-clang-tidy.sh src/main/cpp/net/eagle0/shardok/library/CombatDamage.hpp -- -I$repo_root -std=c++23"
exit 2
fi
bazel build @llvm_toolchain//:clang-tidy
bazel_bin="$(bazel info bazel-bin)"
clang_tidy="$bazel_bin/external/toolchains_llvm++llvm+llvm_toolchain/clang-tidy"
if [ ! -x "$clang_tidy" ]; then
echo "Unable to find clang-tidy binary at $clang_tidy"
exit 1
fi
"$clang_tidy" --config-file="$repo_root/.clang-tidy" "$@"
@@ -6,8 +6,8 @@
// Copyright © 2017 none. All rights reserved.
//
#ifndef FilesystemUtils_hpp
#define FilesystemUtils_hpp
#ifndef EAGLE0_COMMON_FILESYSTEM_UTILS_HPP
#define EAGLE0_COMMON_FILESYSTEM_UTILS_HPP
#include <string>
#include <vector>
@@ -36,4 +36,4 @@ public:
static auto LoadFromPath(const string& path) -> byte_vector;
};
#endif /* FilesystemUtils_hpp */
#endif // EAGLE0_COMMON_FILESYSTEM_UTILS_HPP
+3 -3
View File
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef MapUtils_hpp
#define MapUtils_hpp
#ifndef EAGLE0_COMMON_MAP_UTILS_HPP
#define EAGLE0_COMMON_MAP_UTILS_HPP
#include <string>
#include <unordered_map>
@@ -19,4 +19,4 @@ auto IntForKey(const std::unordered_map<std::string, std::string>& map, const st
auto BoolForKey(const std::unordered_map<std::string, std::string>& map, const std::string& key)
-> bool;
#endif /* MapUtils_hpp */
#endif // EAGLE0_COMMON_MAP_UTILS_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef ProtobufWarningSuppression_h
#define ProtobufWarningSuppression_h
#ifndef EAGLE0_COMMON_PROTOBUF_WARNING_SUPPRESSION_HPP
#define EAGLE0_COMMON_PROTOBUF_WARNING_SUPPRESSION_HPP
#define SUPPRESS_PROTOBUF_WARNINGS \
_Pragma("GCC diagnostic ignored \"-Wpragmas\"") \
@@ -19,4 +19,4 @@
"GCC diagnostic ignored \"-Wshorten-64-to-32\"") \
_Pragma("GCC diagnostic ignored \"-Wnested-anon-types\"")
#endif /* ProtobufWarningSuppression_h */
#endif // EAGLE0_COMMON_PROTOBUF_WARNING_SUPPRESSION_HPP
@@ -6,11 +6,13 @@
// Copyright (c) 2015 none. All rights reserved.
//
#ifndef __eagle0__ShardokRandomGenerator__
#define __eagle0__ShardokRandomGenerator__
#ifndef EAGLE0_COMMON_RANDOM_GENERATOR_HPP
#define EAGLE0_COMMON_RANDOM_GENERATOR_HPP
#include <cstddef>
#include <memory>
#include <random>
#include <vector>
class RandomGenerator;
@@ -22,6 +24,10 @@ private:
public:
RandomGenerator() = default;
RandomGenerator(const RandomGenerator&) = default;
auto operator=(const RandomGenerator&) -> RandomGenerator& = default;
RandomGenerator(RandomGenerator&&) = default;
auto operator=(RandomGenerator&&) -> RandomGenerator& = default;
virtual ~RandomGenerator() = default;
@@ -35,7 +41,7 @@ public:
template<class T>
auto RandomElement(const std::vector<T>& vec) -> T {
return vec[IntBelow((int)vec.size())];
return vec.at(static_cast<std::size_t>(IntBelow(static_cast<int>(vec.size()))));
}
static auto ChanceOpenEndedPercentileAtOrAbove(double value) -> double;
@@ -56,4 +62,4 @@ public:
auto IntBetween(int min, int max) -> int override; // inclusive, exclusive (min<=return<max)
};
#endif /* defined(__eagle0__ShardokRandomGenerator__) */
#endif // EAGLE0_COMMON_RANDOM_GENERATOR_HPP
@@ -6,10 +6,11 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef SequenceRandomGenerator_h
#define SequenceRandomGenerator_h
#ifndef EAGLE0_COMMON_SEQUENCE_RANDOM_GENERATOR_HPP
#define EAGLE0_COMMON_SEQUENCE_RANDOM_GENERATOR_HPP
#include <memory>
#include <utility>
#include <vector>
#include "src/main/cpp/net/eagle0/common/RandomGenerator.hpp"
@@ -24,22 +25,22 @@
// which produces: initial=2 (triggers open-ended), accumulated=52, final=2-52=-50
class SequenceRandomGenerator : public ::RandomGenerator {
private:
const std::vector<double> sequence;
std::vector<double> sequence;
size_t position = 0;
auto DoubleZeroToOne() -> double override {
const double nextVal = sequence[position];
const double nextVal = sequence.at(position);
position++;
if (position >= sequence.size()) { position = 0; }
return nextVal;
}
public:
explicit SequenceRandomGenerator(std::vector<double> s) : sequence(std::move(s)), position(0) {}
explicit SequenceRandomGenerator(std::vector<double> s) : sequence(std::move(s)) {}
static auto WithSequence(const std::vector<double>& s)
-> std::shared_ptr<SequenceRandomGenerator> {
return std::make_shared<SequenceRandomGenerator>(s);
}
};
#endif /* SequenceRandomGenerator_h */
#endif // EAGLE0_COMMON_SEQUENCE_RANDOM_GENERATOR_HPP
+4 -4
View File
@@ -6,14 +6,14 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef TsvParser_hpp
#define TsvParser_hpp
#ifndef EAGLE0_COMMON_TSV_PARSER_HPP
#define EAGLE0_COMMON_TSV_PARSER_HPP
#include <string>
#include <unordered_map>
#include <vector>
typedef std::unordered_map<std::string, std::string> StringMap;
using StringMap = std::unordered_map<std::string, std::string>;
// Parses a TSV, with the first column becoming map keys and subsequent columns becoming values
// for different maps in the returned vector.
@@ -23,4 +23,4 @@ public:
std::vector<StringMap> ParseColumnEntryTsv(std::string tsv);
};
#endif /* TsvParser_hpp */
#endif // EAGLE0_COMMON_TSV_PARSER_HPP
@@ -6,8 +6,8 @@
// Copyright © 2017 none. All rights reserved.
//
#ifndef byte_vector_h
#define byte_vector_h
#ifndef EAGLE0_COMMON_BYTE_VECTOR_HPP
#define EAGLE0_COMMON_BYTE_VECTOR_HPP
#include <cstdint>
#include <cstring>
@@ -184,4 +184,4 @@ inline auto operator<<(std::ostream& ostr, byte_vector vec) -> std::ostream& {
return ostr;
}
#endif /* byte_vector_h */
#endif // EAGLE0_COMMON_BYTE_VECTOR_HPP
@@ -141,9 +141,8 @@ public:
// Default implementation: no filtering, so filtered index = original index
[[nodiscard]] virtual size_t mapFilteredIndexToOriginal(
size_t filteredIndex,
const MCTSGameState& state) const {
const MCTSGameState& /*state*/) const {
// Default: no filtering, index stays the same
(void)state; // Suppress unused parameter warning
return filteredIndex;
}
@@ -158,4 +157,4 @@ public:
} // namespace mcts
} // namespace shardok
#endif // EAGLE0_MCTS_GAME_ENGINE_HPP
#endif // EAGLE0_MCTS_GAME_ENGINE_HPP
@@ -6,8 +6,8 @@
// and flee vs fight evaluation for final round scenarios
//
#ifndef AIFleeDecisionCalculator_hpp
#define AIFleeDecisionCalculator_hpp
#ifndef EAGLE0_SHARDOK_AI_AI_FLEE_DECISION_CALCULATOR_HPP
#define EAGLE0_SHARDOK_AI_AI_FLEE_DECISION_CALCULATOR_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokEngine.hpp"
@@ -63,4 +63,4 @@ private:
} // namespace shardok
#endif /* AIFleeDecisionCalculator_hpp */
#endif // EAGLE0_SHARDOK_AI_AI_FLEE_DECISION_CALCULATOR_HPP
@@ -6,8 +6,8 @@
// Copyright © 2017 none. All rights reserved.
//
#ifndef ShardokAIClient_hpp
#define ShardokAIClient_hpp
#ifndef EAGLE0_SHARDOK_AI_SHARDOK_AI_CLIENT_HPP
#define EAGLE0_SHARDOK_AI_SHARDOK_AI_CLIENT_HPP
#include <vector>
@@ -95,4 +95,4 @@ public:
};
} // namespace shardok
#endif /* ShardokAIClient_hpp */
#endif // EAGLE0_SHARDOK_AI_SHARDOK_AI_CLIENT_HPP
@@ -6,8 +6,8 @@
// Copyright © 2017 none. All rights reserved.
//
#ifndef ShardokGameController_hpp
#define ShardokGameController_hpp
#ifndef EAGLE0_SHARDOK_CONTROLLER_SHARDOK_GAME_CONTROLLER_HPP
#define EAGLE0_SHARDOK_CONTROLLER_SHARDOK_GAME_CONTROLLER_HPP
#include <atomic>
#include <functional>
@@ -213,4 +213,4 @@ public:
};
} // namespace shardok
#endif /* ShardokGameController_hpp */
#endif // EAGLE0_SHARDOK_CONTROLLER_SHARDOK_GAME_CONTROLLER_HPP
@@ -11,36 +11,44 @@
namespace shardok {
struct ActionCost {
enum ActionCostType : uint8_t {
enum class ActionCostType : uint8_t {
impossible, // This action cannot be performed at any price.
standard, // This is a normal action, that requires and consumes the specified number of
// points.
usesAll // This action requires the minimum points, but consumes anything that is left.
};
static constexpr ActionCostType impossible = ActionCostType::impossible;
static constexpr ActionCostType standard = ActionCostType::standard;
static constexpr ActionCostType usesAll = ActionCostType::usesAll;
ActionCostType type;
ActionPoints points;
ActionCost(const ActionCostType type, const ActionPoints points) : type(type), points(points) {}
constexpr ActionCost(const ActionCostType type, const ActionPoints points) noexcept
: type(type),
points(points) {}
[[nodiscard]] bool IsPossible(const ActionPoints cmpPoints) const {
[[nodiscard]] constexpr auto IsPossible(const ActionPoints cmpPoints) const noexcept -> bool {
return type != impossible && cmpPoints >= points;
}
bool operator==(const ActionCost &rhs) const {
[[nodiscard]] constexpr auto operator==(const ActionCost &rhs) const noexcept -> bool {
return type == rhs.type && points == rhs.points;
}
static inline auto StandardActionCost(const ActionPoints points) -> ActionCost {
[[nodiscard]] static constexpr auto StandardActionCost(const ActionPoints points) noexcept
-> ActionCost {
return ActionCost{ActionCost::standard, points};
}
static inline auto UsesAllActionCost(const ActionPoints points) -> ActionCost {
return ActionCost(ActionCost::usesAll, points);
[[nodiscard]] static constexpr auto UsesAllActionCost(const ActionPoints points) noexcept
-> ActionCost {
return {ActionCost::usesAll, points};
}
};
const ActionCost IMPOSSIBLE_ACTION_COST{ActionCost::impossible, 0};
inline constexpr ActionCost IMPOSSIBLE_ACTION_COST{ActionCost::impossible, 0};
} // namespace shardok
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef AvailableCommandsFactory_hpp
#define AvailableCommandsFactory_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_AVAILABLE_COMMANDS_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_AVAILABLE_COMMANDS_FACTORY_HPP
#include <optional>
#include <vector>
@@ -46,4 +46,4 @@ public:
};
} // namespace shardok
#endif /* AvailableCommandsFactory_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_AVAILABLE_COMMANDS_FACTORY_HPP
@@ -6,8 +6,8 @@
// Copyright (c) 2014 none. All rights reserved.
//
#ifndef __eagle0__BattalionType__
#define __eagle0__BattalionType__
#ifndef EAGLE0_SHARDOK_LIBRARY_BATTALION_TYPE_HPP
#define EAGLE0_SHARDOK_LIBRARY_BATTALION_TYPE_HPP
#include <array>
#include <cstdint>
@@ -111,8 +111,8 @@ struct BattalionType {
if (HasCastle(terrain.modifier())) {
const double castleIntegrity = terrain.modifier().castle().integrity().value();
return (castleIntegrity * damageTakenMultiplierForCastle +
(100.0 - castleIntegrity) * terrainTypeMultiplier) /
return ((castleIntegrity * damageTakenMultiplierForCastle) +
((100.0 - castleIntegrity) * terrainTypeMultiplier)) /
100.0;
}
return terrainTypeMultiplier;
@@ -125,8 +125,8 @@ struct BattalionType {
if (terrain->modifier().castle().present()) {
const double castleIntegrity = terrain->modifier().castle().integrity();
return (castleIntegrity * damageTakenMultiplierForCastle +
(100.0 - castleIntegrity) * terrainTypeMultiplier) /
return ((castleIntegrity * damageTakenMultiplierForCastle) +
((100.0 - castleIntegrity) * terrainTypeMultiplier)) /
100.0;
}
return terrainTypeMultiplier;
@@ -199,7 +199,8 @@ struct BattalionType {
auto terrainCost = GetCostToEnterTerrainType(terrain.type());
if (HasSnow(terrain.modifier())) {
terrainCost.points += int(snowPenalty * terrain.modifier().snow().integrity().value());
terrainCost.points +=
static_cast<int>(snowPenalty * terrain.modifier().snow().integrity().value());
}
return terrainCost;
}
@@ -215,7 +216,9 @@ struct BattalionType {
if (tm.ice().present()) return costToEnterIce;
auto terrainCost = GetCostToEnterTerrainType(terrainType);
if (tm.snow().present()) { terrainCost.points += int(snowPenalty * tm.snow().integrity()); }
if (tm.snow().present()) {
terrainCost.points += static_cast<int>(snowPenalty * tm.snow().integrity());
}
return terrainCost;
}
@@ -256,8 +259,15 @@ struct BattalionType {
const double trainingDifference = chargerTraining - defenderTraining;
const double trainingValue =
trainingDifferenceMultiplierForStunChanceOnCharge * trainingDifference;
OtherFactor trainingFactor = MakeOtherFactor((int16_t)trainingValue, "training difference");
return MakeOdds((int16_t)baseStunChanceOnCharge, 0, 0, 0, {}, {trainingFactor});
OtherFactor trainingFactor =
MakeOtherFactor(static_cast<int16_t>(trainingValue), "training difference");
return MakeOdds(
static_cast<int16_t>(baseStunChanceOnCharge),
0,
0,
0,
{},
{trainingFactor});
}
[[nodiscard]] auto GetDailyFoodCostPerTroop() const -> double {
@@ -268,7 +278,7 @@ struct BattalionType {
-> std::shared_ptr<const BattalionType>;
};
typedef std::shared_ptr<const BattalionType> BattalionTypeSPtr;
using BattalionTypeSPtr = std::shared_ptr<const BattalionType>;
} // namespace shardok
#endif /* defined(__eagle0__BattalionType__) */
#endif // EAGLE0_SHARDOK_LIBRARY_BATTALION_TYPE_HPP
@@ -6,15 +6,20 @@
// Copyright (c) 2014 none. All rights reserved.
//
#ifndef __eagle0__CombatDamage__
#define __eagle0__CombatDamage__
#ifndef EAGLE0_SHARDOK_LIBRARY_COMBAT_DAMAGE_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMBAT_DAMAGE_HPP
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <string>
#include <vector>
namespace shardok {
// Normal and penetrating damage for each kind
enum DamageType {
enum class DamageType : std::uint8_t {
DamageType_slashing = 0,
DamageType_puncturing,
DamageType_stabbing,
@@ -27,6 +32,17 @@ enum DamageType {
NUM_DAMAGE_TYPES
};
inline constexpr DamageType DamageType_slashing = DamageType::DamageType_slashing;
inline constexpr DamageType DamageType_puncturing = DamageType::DamageType_puncturing;
inline constexpr DamageType DamageType_stabbing = DamageType::DamageType_stabbing;
inline constexpr DamageType DamageType_crushing = DamageType::DamageType_crushing;
inline constexpr DamageType DamageType_fire = DamageType::DamageType_fire;
inline constexpr DamageType DamageType_cold = DamageType::DamageType_cold;
inline constexpr DamageType DamageType_lightning = DamageType::DamageType_lightning;
inline constexpr DamageType DamageType_aessence = DamageType::DamageType_aessence;
inline constexpr DamageType DamageType_impact = DamageType::DamageType_impact;
inline constexpr int NUM_DAMAGE_TYPES = static_cast<int>(DamageType::NUM_DAMAGE_TYPES);
static inline bool DamageTypeGetsTerrainDefense(const DamageType type) {
switch (type) {
case DamageType_slashing:
@@ -47,9 +63,21 @@ static inline bool DamageTypeGetsTerrainDefense(const DamageType type) {
}
struct CombatDamage {
const std::vector<double> damageByType;
private:
static constexpr size_t kDamageValueCount = 2 * static_cast<size_t>(NUM_DAMAGE_TYPES);
CombatDamage() : damageByType{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} {};
std::array<double, kDamageValueCount> damageByType{};
[[nodiscard]] static constexpr auto NormalIndex(const DamageType type) -> size_t {
return 2 * static_cast<size_t>(type);
}
[[nodiscard]] static constexpr auto PenetratingIndex(const DamageType type) -> size_t {
return NormalIndex(type) + 1;
}
public:
CombatDamage() = default;
CombatDamage(
const double sl,
const double pu,
@@ -89,37 +117,40 @@ struct CombatDamage {
im,
pim} {}
CombatDamage(const std::vector<double> byType) : damageByType(byType) {}
explicit CombatDamage(const std::vector<double>& byType) {
std::copy_n(
byType.begin(),
std::min(byType.size(), damageByType.size()),
damageByType.begin());
}
CombatDamage(const CombatDamage& toCopy) : damageByType(toCopy.damageByType) {}
public:
double GetNormalDamageOfType(const DamageType type) const { return damageByType[2 * type]; }
double GetPenetratingDamageOfType(const DamageType type) const {
return damageByType[2 * type + 1];
[[nodiscard]] auto GetNormalDamageOfType(const DamageType type) const -> double {
return damageByType.at(NormalIndex(type));
}
[[nodiscard]] auto GetPenetratingDamageOfType(const DamageType type) const -> double {
return damageByType.at(PenetratingIndex(type));
};
bool operator==(const CombatDamage& cmpr) const {
for (size_t type = 0; type < 2 * NUM_DAMAGE_TYPES; type++) {
if (damageByType[type] != cmpr.damageByType[type]) return false;
}
return true;
}
bool operator==(const CombatDamage& cmpr) const { return damageByType == cmpr.damageByType; }
bool operator!=(const CombatDamage& cmpr) const { return !(*this == cmpr); }
bool operator<=(const CombatDamage& cmpr) const {
for (size_t type = 0; type < 2 * NUM_DAMAGE_TYPES; type++) {
if (damageByType[type] > cmpr.damageByType[type]) return false;
}
return true;
return std::ranges::equal(
damageByType,
cmpr.damageByType,
[](const double damage, const double comparedDamage) {
return damage <= comparedDamage;
});
}
bool operator>=(const CombatDamage& cmpr) const {
for (size_t type = 0; type < 2 * NUM_DAMAGE_TYPES; type++) {
if (damageByType[type] < cmpr.damageByType[type]) return false;
}
return true;
return std::ranges::equal(
damageByType,
cmpr.damageByType,
[](const double damage, const double comparedDamage) {
return damage >= comparedDamage;
});
}
bool operator>(const CombatDamage& cmpr) const { return ((*this >= cmpr) && !(*this == cmpr)); }
@@ -212,11 +243,11 @@ public:
.Build();
}
std::string ToString() const {
char buffer[1024];
[[nodiscard]] auto ToString() const -> std::string {
std::array<char, 1024> buffer{};
snprintf(
buffer,
1024,
buffer.data(),
buffer.size(),
"slashing=%f / %f, puncturing=%f / %f, stabbing=%f / %f, crushing=%f / %f, "
"fire=%f / "
"%f, cold=%f / %f, lightning=%f / %f, aessence=%f / %f, impact=%f / %f",
@@ -239,7 +270,7 @@ public:
GetNormalDamageOfType(DamageType_impact),
GetPenetratingDamageOfType(DamageType_impact));
return std::string(buffer);
return {buffer.data()};
}
class Builder {
@@ -265,7 +296,7 @@ public:
double penetrating_impact = 0.0;
public:
Builder() {}
Builder() = default;
Builder& SetSlashing(const double sl) {
slashing = sl;
return *this;
@@ -392,9 +423,8 @@ public:
return *this;
}
CombatDamage Build() {
return CombatDamage(
slashing,
[[nodiscard]] auto Build() const -> CombatDamage {
return {slashing,
puncturing,
stabbing,
crushing,
@@ -411,21 +441,16 @@ public:
penetrating_cold,
penetrating_lightning,
penetrating_aessence,
penetrating_impact);
penetrating_impact};
}
};
Builder ToBuilder() {
[[nodiscard]] auto ToBuilder() const -> Builder {
Builder builder = Builder();
for (int i = 0; i < (int)NUM_DAMAGE_TYPES; i++) {
builder.SetDamageByType(
(DamageType)i,
false,
this->GetNormalDamageOfType((DamageType)i));
builder.SetDamageByType(
(DamageType)i,
true,
this->GetPenetratingDamageOfType((DamageType)i));
for (int i = 0; i < static_cast<int>(NUM_DAMAGE_TYPES); i++) {
const auto type = static_cast<DamageType>(i);
builder.SetDamageByType(type, false, this->GetNormalDamageOfType(type));
builder.SetDamageByType(type, true, this->GetPenetratingDamageOfType(type));
}
return builder;
}
@@ -434,4 +459,4 @@ public:
inline CombatDamage operator*(const double factor, const CombatDamage& dmg) { return dmg * factor; }
} // namespace shardok
#endif /* defined(__eagle0__CombatDamage__) */
#endif // EAGLE0_SHARDOK_LIBRARY_COMBAT_DAMAGE_HPP
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef FireManager_hpp
#define FireManager_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_FIRE_UTILS_HPP
#define EAGLE0_SHARDOK_LIBRARY_FIRE_UTILS_HPP
#include "CombatDamage.hpp"
#include "PercentileRollOdds.hpp"
@@ -51,4 +51,4 @@ auto GetStartFireOdds(
} // namespace shardok
#endif /* FireManager_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_FIRE_UTILS_HPP
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef PercentileRollOdds_hpp
#define PercentileRollOdds_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_PERCENTILE_ROLL_ODDS_HPP
#define EAGLE0_SHARDOK_LIBRARY_PERCENTILE_ROLL_ODDS_HPP
#include <string>
#include <vector>
@@ -18,8 +18,8 @@
#pragma GCC diagnostic pop
namespace shardok {
typedef net::eagle0::shardok::storage::Odds PercentileRollOdds;
typedef net::eagle0::shardok::storage::Odds_OtherFactor OtherFactor;
using PercentileRollOdds = net::eagle0::shardok::storage::Odds;
using OtherFactor = net::eagle0::shardok::storage::Odds_OtherFactor;
double BonusFromStat(double stat);
@@ -50,4 +50,4 @@ bool PercentileRollSucceeds(const PercentileRollOdds &odds, double roll);
int16_t GetSuccessChance(const PercentileRollOdds &odds);
} // namespace shardok
#endif /* PercentileRollOdds_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_PERCENTILE_ROLL_ODDS_HPP
@@ -6,8 +6,8 @@
// Copyright (c) 2014 none. All rights reserved.
//
#ifndef __eagle0__ShardokAction__
#define __eagle0__ShardokAction__
#ifndef EAGLE0_SHARDOK_LIBRARY_SHARDOK_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_SHARDOK_ACTION_HPP
#include <vector>
@@ -69,8 +69,8 @@ public:
class ShardokAction;
typedef std::shared_ptr<ShardokAction> ActionSPtr;
typedef std::vector<ActionSPtr> ActionList;
using ActionSPtr = std::shared_ptr<ShardokAction>;
using ActionList = std::vector<ActionSPtr>;
} // namespace shardok
#endif /* defined(__eagle0__ShardokAction__) */
#endif // EAGLE0_SHARDOK_LIBRARY_SHARDOK_ACTION_HPP
@@ -6,8 +6,8 @@
// Copyright © 2017 none. All rights reserved.
//
#ifndef ShardokCTypes_h
#define ShardokCTypes_h
#ifndef EAGLE0_SHARDOK_LIBRARY_SHARDOK_CTYPES_H
#define EAGLE0_SHARDOK_LIBRARY_SHARDOK_CTYPES_H
#include <cstdint>
#include <string>
@@ -23,9 +23,13 @@ using RoundId = int32_t;
using MapIndex = int8_t;
using ActionPoints = uint8_t;
enum AttackOrientation { front, flank, rear };
enum class AttackOrientation : std::uint8_t { front, flank, rear };
inline constexpr AttackOrientation front = AttackOrientation::front;
inline constexpr AttackOrientation flank = AttackOrientation::flank;
inline constexpr AttackOrientation rear = AttackOrientation::rear;
constexpr PlayerId UNCONTROLLED_PLAYER_ID = 99;
} // namespace shardok
#endif /* ShardokCTypes_h */
#endif // EAGLE0_SHARDOK_LIBRARY_SHARDOK_CTYPES_H
@@ -6,8 +6,8 @@
// Copyright (c) 2015 none. All rights reserved.
//
#ifndef __eagle0__ShardokEngine__
#define __eagle0__ShardokEngine__
#ifndef EAGLE0_SHARDOK_LIBRARY_SHARDOK_ENGINE_HPP
#define EAGLE0_SHARDOK_LIBRARY_SHARDOK_ENGINE_HPP
#include <flatbuffers/flatbuffers.h>
@@ -254,4 +254,4 @@ public:
};
} // namespace shardok
#endif /* defined(__eagle0__ShardokEngine__) */
#endif // EAGLE0_SHARDOK_LIBRARY_SHARDOK_ENGINE_HPP
@@ -6,8 +6,8 @@
// Copyright © 2017 none. All rights reserved.
//
#ifndef ShardokException_h
#define ShardokException_h
#ifndef EAGLE0_SHARDOK_LIBRARY_SHARDOK_EXCEPTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_SHARDOK_EXCEPTION_HPP
#include <exception>
#include <string>
@@ -59,4 +59,4 @@ public:
};
} // namespace shardok
#endif /* ShardokException_h */
#endif // EAGLE0_SHARDOK_LIBRARY_SHARDOK_EXCEPTION_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef FireOutActionFactory_hpp
#define FireOutActionFactory_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_FIRE_OUT_ACTION_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_FIRE_OUT_ACTION_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"
@@ -38,4 +38,4 @@ public:
};
} // namespace shardok
#endif /* FireOutActionFactory_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_FIRE_OUT_ACTION_FACTORY_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef FireSpreadActionFactory_hpp
#define FireSpreadActionFactory_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_FIRE_SPREAD_ACTION_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_FIRE_SPREAD_ACTION_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/Coordinates.hpp"
@@ -41,4 +41,4 @@ public:
};
} // namespace shardok
#endif /* FireSpreadActionFactory_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_FIRE_SPREAD_ACTION_FACTORY_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef MeteorCastActionFactory_hpp
#define MeteorCastActionFactory_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_METEOR_CAST_ACTION_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_METEOR_CAST_ACTION_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"
@@ -25,4 +25,4 @@ public:
};
} // namespace shardok
#endif /* MeteorCastActionFactory_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_METEOR_CAST_ACTION_FACTORY_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef ActionResultApplier_hpp
#define ActionResultApplier_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_RESULT_APPLIER_ACTION_RESULT_APPLIER_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_RESULT_APPLIER_ACTION_RESULT_APPLIER_HPP
#include <flatbuffers/flatbuffers.h>
@@ -33,4 +33,4 @@ auto ApplyResults(
const SettingsGetter& settings) -> GameStateW;
} // namespace shardok
#endif /* ActionResultApplier_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_RESULT_APPLIER_ACTION_RESULT_APPLIER_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef FallIntoWaterAction_hpp
#define FallIntoWaterAction_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_FALL_INTO_WATER_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_FALL_INTO_WATER_ACTION_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"
@@ -57,4 +57,4 @@ public:
};
} // namespace shardok
#endif /* FallIntoWaterAction_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_FALL_INTO_WATER_ACTION_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef FireOutAction_hpp
#define FireOutAction_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_FIRE_OUT_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_FIRE_OUT_ACTION_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/Coordinates.hpp"
@@ -36,4 +36,4 @@ public:
};
} // namespace shardok
#endif /* FireOutAction_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_FIRE_OUT_ACTION_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef FireSpreadAction_hpp
#define FireSpreadAction_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_FIRE_SPREAD_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_FIRE_SPREAD_ACTION_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/Coordinates.hpp"
@@ -37,4 +37,4 @@ public:
};
} // namespace shardok
#endif /* FireSpreadAction_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_FIRE_SPREAD_ACTION_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef MeteorCastAction_hpp
#define MeteorCastAction_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_METEOR_CAST_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_METEOR_CAST_ACTION_HPP
#include <utility>
@@ -71,4 +71,4 @@ public:
};
} // namespace shardok
#endif /* MeteorCastAction_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_METEOR_CAST_ACTION_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef ChargeActionFactory_hpp
#define ChargeActionFactory_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_CHARGE_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_CHARGE_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -45,4 +45,4 @@ public:
};
} // namespace shardok
#endif /* ChargeActionFactory_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_CHARGE_COMMAND_FACTORY_HPP
@@ -3,8 +3,8 @@
// eagle0
//
#ifndef EvacuatePrisonersCommandFactory_hpp
#define EvacuatePrisonersCommandFactory_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_EVACUATE_PRISONERS_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_EVACUATE_PRISONERS_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -22,4 +22,4 @@ public:
} // namespace shardok
#endif /* EvacuatePrisonersCommandFactory_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_EVACUATE_PRISONERS_COMMAND_FACTORY_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef FleeCommandFactory_hpp
#define FleeCommandFactory_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_FLEE_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_FLEE_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -36,4 +36,4 @@ public:
};
} // namespace shardok
#endif /* FleeCommandFactory_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_FLEE_COMMAND_FACTORY_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef HolyWaveActionFactory_hpp
#define HolyWaveActionFactory_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_HOLY_WAVE_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_HOLY_WAVE_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -34,4 +34,4 @@ public:
};
} // namespace shardok
#endif /* HolyWaveActionFactory_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_HOLY_WAVE_COMMAND_FACTORY_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef ReinforceCommandFactory_hpp
#define ReinforceCommandFactory_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_REINFORCE_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_REINFORCE_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -41,4 +41,4 @@ public:
};
} // namespace shardok
#endif /* ReinforceCommandFactory_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_REINFORCE_COMMAND_FACTORY_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef RetreatCommandFactory_hpp
#define RetreatCommandFactory_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_RETREAT_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_RETREAT_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -32,4 +32,4 @@ public:
};
} // namespace shardok
#endif /* RetreatCommandFactory_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_RETREAT_COMMAND_FACTORY_HPP
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef StealthManager_hpp
#define StealthManager_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_AMBUSH_ODDS_AMBUSH_ODDS_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_AMBUSH_ODDS_AMBUSH_ODDS_HPP
#include "src/main/cpp/net/eagle0/shardok/library/PercentileRollOdds.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/Terrain.hpp"
@@ -24,4 +24,4 @@ public:
};
} // namespace shardok
#endif /* StealthManager_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_AMBUSH_ODDS_AMBUSH_ODDS_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef MeleeActionFactory_hpp
#define MeleeActionFactory_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_MELEE_COMMAND_FACTORY_MELEE_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_MELEE_COMMAND_FACTORY_MELEE_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -42,4 +42,4 @@ public:
};
} // namespace shardok
#endif /* MeleeActionFactory_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_MELEE_COMMAND_FACTORY_MELEE_COMMAND_FACTORY_HPP
@@ -6,8 +6,8 @@
// Copyright © 2021 none. All rights reserved.
//
#ifndef GoIntoExileCommand_hpp
#define GoIntoExileCommand_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMANDS_BECOME_OUTLAW_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMANDS_BECOME_OUTLAW_COMMAND_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ActionCost.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
@@ -48,4 +48,4 @@ public:
};
} // namespace shardok
#endif /* GoIntoExileCommand_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMANDS_BECOME_OUTLAW_COMMAND_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef ChargeAction_hpp
#define ChargeAction_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMANDS_CHARGE_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMANDS_CHARGE_COMMAND_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ActionCost.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
@@ -67,4 +67,4 @@ public:
};
} // namespace shardok
#endif /* ChargeAction_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMANDS_CHARGE_COMMAND_HPP
@@ -3,8 +3,8 @@
// eagle0
//
#ifndef EvacuatePrisonersCommand_hpp
#define EvacuatePrisonersCommand_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMANDS_EVACUATE_PRISONERS_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMANDS_EVACUATE_PRISONERS_COMMAND_HPP
#include <vector>
@@ -45,4 +45,4 @@ public:
};
} // namespace shardok
#endif /* EvacuatePrisonersCommand_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMANDS_EVACUATE_PRISONERS_COMMAND_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef FleeCommand_hpp
#define FleeCommand_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMANDS_FLEE_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMANDS_FLEE_COMMAND_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ActionCost.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
@@ -49,4 +49,4 @@ public:
};
} // namespace shardok
#endif /* FleeCommand_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMANDS_FLEE_COMMAND_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef HolyWaveAction_hpp
#define HolyWaveAction_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMANDS_HOLY_WAVE_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMANDS_HOLY_WAVE_COMMAND_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ActionCost.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
@@ -47,4 +47,4 @@ public:
};
} // namespace shardok
#endif /* HolyWaveAction_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMANDS_HOLY_WAVE_COMMAND_HPP
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef MeleeCommand_hpp
#define MeleeCommand_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMANDS_MELEE_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMANDS_MELEE_COMMAND_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ActionCost.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
@@ -65,4 +65,4 @@ public:
};
} // namespace shardok
#endif /* MeleeCommand_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMANDS_MELEE_COMMAND_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef ReinforceCommand_hpp
#define ReinforceCommand_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMANDS_REINFORCE_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMANDS_REINFORCE_COMMAND_HPP
#include <utility>
@@ -65,4 +65,4 @@ public:
};
} // namespace shardok
#endif /* ReinforceCommand_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMANDS_REINFORCE_COMMAND_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef RetreatCommand_hpp
#define RetreatCommand_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMANDS_RETREAT_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMANDS_RETREAT_COMMAND_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ActionCost.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
@@ -27,11 +27,11 @@ public:
RetreatCommand(const ActionCost& cost, PlayerId playerId, UnitId retreatingUnitId);
~RetreatCommand(){};
virtual CommandType GetCommandType() const override {
CommandType GetCommandType() const override {
return net::eagle0::shardok::common::RETREAT_COMMAND;
}
virtual CommandProto GetCommandProto() const override;
CommandProto GetCommandProto() const override;
[[nodiscard]] auto CanBeFollowUp() const -> bool override { return false; }
[[nodiscard]] auto CanDoWithLowMorale() const -> bool override { return true; }
@@ -44,4 +44,4 @@ public:
};
} // namespace shardok
#endif /* RetreatCommand_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMANDS_RETREAT_COMMAND_HPP
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef DuelManager_hpp
#define DuelManager_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMANDS_CHALLENGE_DUEL_COMMAND_DUEL_UTILS_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMANDS_CHALLENGE_DUEL_COMMAND_DUEL_UTILS_HPP
#include "src/main/cpp/net/eagle0/shardok/library/PercentileRollOdds.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"
@@ -25,4 +25,4 @@ PercentileRollOdds GetAcceptOdds(
const Terrain &defenderTerrain);
} // namespace shardok
#endif /* DuelManager_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_COMMANDS_CHALLENGE_DUEL_COMMAND_DUEL_UTILS_HPP
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef Coords_h
#define Coords_h
#ifndef EAGLE0_SHARDOK_LIBRARY_MAP_COORDINATES_HPP
#define EAGLE0_SHARDOK_LIBRARY_MAP_COORDINATES_HPP
#include <sstream>
@@ -62,4 +62,4 @@ struct hash<net::eagle0::shardok::common::Coords> {
};
} // namespace std
#endif /* Coords_h */
#endif // EAGLE0_SHARDOK_LIBRARY_MAP_COORDINATES_HPP
@@ -6,8 +6,8 @@
// Copyright (c) 2014 none. All rights reserved.
//
#ifndef eagle0_ShardokOrientation_h
#define eagle0_ShardokOrientation_h
#ifndef EAGLE0_SHARDOK_LIBRARY_MAP_HEX_MAP_DIRECTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_MAP_HEX_MAP_DIRECTION_HPP
#include "src/main/cpp/net/eagle0/common/ProtobufWarningSuppression.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokException.hpp"
@@ -40,7 +40,7 @@ inline HexMapDirection& operator++(HexMapDirection& dir) {
return dir;
}
typedef struct HexMapDirectionsTo {
struct HexMapDirectionsTo {
HexMapDirection main;
HexMapDirection secondary; // Only valid if exactly on the line
bool usesSecondary;
@@ -48,7 +48,7 @@ typedef struct HexMapDirectionsTo {
bool Matches(const HexMapDirection dir) {
return dir == main || (usesSecondary && dir == secondary);
}
} HexMapDirectionsTo;
};
inline bool operator==(const HexMapDirectionsTo& lhs, const HexMapDirectionsTo& rhs) {
if (lhs.usesSecondary != rhs.usesSecondary) return false;
@@ -58,4 +58,4 @@ inline bool operator==(const HexMapDirectionsTo& lhs, const HexMapDirectionsTo&
}
} // namespace shardok
#endif
#endif // EAGLE0_SHARDOK_LIBRARY_MAP_HEX_MAP_DIRECTION_HPP
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef HexMapTile_hpp
#define HexMapTile_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_MAP_TERRAIN_HPP
#define EAGLE0_SHARDOK_LIBRARY_MAP_TERRAIN_HPP
#include <utility>
@@ -57,4 +57,4 @@ auto MakeHexMapTerrain(
} // namespace shardok
#endif /* HexMapTile_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_MAP_TERRAIN_HPP
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef TileModifiers_hpp
#define TileModifiers_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_MAP_TILE_MODIFIER_HPP
#define EAGLE0_SHARDOK_LIBRARY_MAP_TILE_MODIFIER_HPP
#include <algorithm>
#include <optional>
@@ -63,7 +63,7 @@ static inline TileModifierProto& IncreaseFrozen(TileModifierProto& tm, const dou
// Removes bridge if integrity <= 0.0
static inline TileModifierProto& SetBridge(TileModifierProto& tm, double integrity) {
if (integrity > 100.0) { integrity = 100.0; }
integrity = std::min(integrity, 100.0);
if (integrity > 0.0) {
*tm.mutable_bridge() = MakeSingleModifier(integrity);
} else {
@@ -74,7 +74,7 @@ static inline TileModifierProto& SetBridge(TileModifierProto& tm, double integri
static inline auto SetBridge(net::eagle0::shardok::storage::fb::TileModifier& tm, double integrity)
-> net::eagle0::shardok::storage::fb::TileModifier& {
if (integrity > 100.0) { integrity = 100.0; }
integrity = std::min(integrity, 100.0);
if (integrity > 0.0) {
tm.mutable_bridge().mutate_present(true);
tm.mutable_bridge().mutate_integrity(integrity);
@@ -112,8 +112,7 @@ static inline TileModifierProto WithReducedBridgeIntegrity(
}
static inline TileModifierProto& SetCastle(TileModifierProto& tm, double integrity) {
if (integrity > 100.0) { integrity = 100.0; }
if (integrity < 0.0) { integrity = 0.0; }
integrity = std::clamp(integrity, 0.0, 100.0);
*tm.mutable_castle() = MakeSingleModifier(integrity);
return tm;
}
@@ -121,8 +120,7 @@ static inline TileModifierProto& SetCastle(TileModifierProto& tm, double integri
static inline net::eagle0::shardok::storage::fb::TileModifier& SetCastle(
net::eagle0::shardok::storage::fb::TileModifier& tm,
double integrity) {
if (integrity > 100.0) { integrity = 100.0; }
if (integrity < 0.0) { integrity = 0.0; }
integrity = std::clamp(integrity, 0.0, 100.0);
tm.mutable_castle().mutate_integrity(integrity);
tm.mutable_castle().mutate_present(true);
return tm;
@@ -132,7 +130,7 @@ static inline net::eagle0::shardok::storage::fb::TileModifier& SetCastle(
static inline void ReduceCastleIntegrity(TileModifierProto& tm, const double damage) {
if (HasCastle(tm)) {
double newIntegrity = tm.castle().integrity().value() - damage;
if (newIntegrity < 0.0) newIntegrity = 0.0;
newIntegrity = std::max(newIntegrity, 0.0);
SetCastle(tm, newIntegrity);
}
}
@@ -156,7 +154,7 @@ static inline TileModifierProto WithReducedCastleIntegrity(
const double damage) {
if (HasCastle(tm)) {
double newIntegrity = tm.castle().integrity().value() - damage;
if (newIntegrity < 0.0) newIntegrity = 0.0;
newIntegrity = std::max(newIntegrity, 0.0);
SetCastle(tm, newIntegrity);
}
@@ -165,7 +163,7 @@ static inline TileModifierProto WithReducedCastleIntegrity(
static inline auto SetIce(net::eagle0::shardok::storage::fb::TileModifier& tm, double integrity)
-> net::eagle0::shardok::storage::fb::TileModifier& {
if (integrity > 100.0) { integrity = 100.0; }
integrity = std::min(integrity, 100.0);
if (integrity > 0.0) {
tm.mutable_ice().mutate_present(true);
tm.mutable_ice().mutate_integrity(integrity);
@@ -177,7 +175,7 @@ static inline auto SetIce(net::eagle0::shardok::storage::fb::TileModifier& tm, d
static inline auto SetSnow(net::eagle0::shardok::storage::fb::TileModifier& tm, double integrity)
-> net::eagle0::shardok::storage::fb::TileModifier& {
if (integrity > 100.0) { integrity = 100.0; }
integrity = std::min(integrity, 100.0);
if (integrity > 0.0) {
tm.mutable_snow().mutate_present(true);
tm.mutable_snow().mutate_integrity(integrity);
@@ -197,4 +195,4 @@ static inline auto operator==(const TileModifierProto& lhs, const TileModifierPr
}
} // namespace shardok
#endif /* TileModifiers_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_MAP_TILE_MODIFIER_HPP
@@ -10,7 +10,7 @@
#include "src/main/protobuf/net/eagle0/shardok/common/tile_modifier_with_coords.pb.h"
namespace shardok {
typedef net::eagle0::shardok::common::TileModifierWithCoords TileModifierWithCoords;
using TileModifierWithCoords = net::eagle0::shardok::common::TileModifierWithCoords;
auto MakeTmc(const Coords &coordinates, const TileModifierProto &modifier)
-> TileModifierWithCoords;
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef GameSettings_hpp
#define GameSettings_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_SETTINGS_GAME_SETTINGS_HPP
#define EAGLE0_SHARDOK_LIBRARY_SETTINGS_GAME_SETTINGS_HPP
#include <memory>
#include <vector>
@@ -123,9 +123,9 @@ public:
virtual ~GameSettings() = default;
};
typedef std::shared_ptr<GameSettings> GameSettingsSPtr;
typedef GameSettings::Getter SettingsGetter;
typedef GameSettings::Setter SettingsSetter;
using GameSettingsSPtr = std::shared_ptr<GameSettings>;
using SettingsGetter = GameSettings::Getter;
using SettingsSetter = GameSettings::Setter;
} // namespace shardok
#endif /* GameSettings_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_SETTINGS_GAME_SETTINGS_HPP
@@ -6,8 +6,8 @@
// Copyright 2025 none. All rights reserved.
//
#ifndef TutorialBattleController_hpp
#define TutorialBattleController_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_TUTORIAL_TUTORIAL_BATTLE_CONTROLLER_HPP
#define EAGLE0_SHARDOK_LIBRARY_TUTORIAL_TUTORIAL_BATTLE_CONTROLLER_HPP
#include <optional>
#include <set>
@@ -113,4 +113,4 @@ private:
} // namespace shardok
#endif /* TutorialBattleController_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_TUTORIAL_TUTORIAL_BATTLE_CONTROLLER_HPP
@@ -17,10 +17,7 @@ namespace shardok {
auto MutatingMaybeSetMorale(Battalion *battalion, double newVal, const BattalionTypeSPtr &type)
-> double {
if (type->adjustsMorale) {
if (newVal < 0.0) newVal = 0.0;
else if (newVal > 100.0)
newVal = 100.0;
newVal = std::clamp(newVal, 0.0, 100.0);
battalion->mutate_morale(newVal);
}
@@ -46,17 +43,14 @@ auto MutatingAdjustMorale(
auto MutatingSetMorale(net::eagle0::shardok::storage::fb::Battalion &battalion, double newVal)
-> double {
if (newVal < 0.0) newVal = 0.0;
else if (newVal > 100.0)
newVal = 100.0;
newVal = std::clamp(newVal, 0.0, 100.0);
battalion.mutate_morale(newVal);
return newVal;
}
inline double factorIntoAdjustment(const double factorPercentile, const double swingPercentile) {
return 1.0 + ((factorPercentile - 50.0) * swingPercentile / 100.0) / 100.0;
return 1.0 + (((factorPercentile - 50.0) * swingPercentile / 100.0) / 100.0);
}
int32_t MutatingInternalTakeDamage(
@@ -67,7 +61,7 @@ int32_t MutatingInternalTakeDamage(
double flankingAdjustment,
double moralePerCasualty,
double baseDeadliness,
const BattalionTypeSPtr type);
BattalionTypeSPtr type);
int32_t MutatingTakeDamageFrom(
Battalion *battalion,
@@ -82,9 +76,15 @@ int32_t MutatingTakeDamageFrom(
const BattalionTypeSPtr &fromType) {
const double braveryAdjustment = factorIntoAdjustment(cmdrBravery, recipientType->braverySwing);
double flankingAdjustment = 1.0;
if (direction == flank) flankingAdjustment = recipientType->flankDamageMultiplier;
else if (direction == rear)
flankingAdjustment = recipientType->rearDamageMultiplier;
switch (direction) {
case AttackOrientation::flank:
flankingAdjustment = recipientType->flankDamageMultiplier;
break;
case AttackOrientation::rear:
flankingAdjustment = recipientType->rearDamageMultiplier;
break;
case AttackOrientation::front: break;
}
const int32_t casualties = MutatingInternalTakeDamage(
battalion,
@@ -130,24 +130,24 @@ int32_t MutatingInternalTakeDamage(
double takenDamage = 0.0;
for (int i = 0; i < (int)NUM_DAMAGE_TYPES; i++) {
for (int i = 0; i < NUM_DAMAGE_TYPES; i++) {
const auto damageType = static_cast<DamageType>(i);
const double armamentAdjustment =
1.0 - (type->baseResistanceByType[i] +
(battalion->armament() / 100.0) * type->maxAugmentResistanceByType[i]) /
100.0;
double newDamage = damage.GetNormalDamageOfType((DamageType)i) * braveryAdjustment *
1.0 - ((type->baseResistanceByType[i] +
(battalion->armament() / 100.0) * type->maxAugmentResistanceByType[i]) /
100.0);
double newDamage = damage.GetNormalDamageOfType(damageType) * braveryAdjustment *
flankingAdjustment * armamentAdjustment;
newDamage += damage.GetPenetratingDamageOfType((DamageType)i) * braveryAdjustment *
newDamage += damage.GetPenetratingDamageOfType(damageType) * braveryAdjustment *
flankingAdjustment;
if (DamageTypeGetsTerrainDefense((DamageType)i)) { newDamage *= terrainAdjustment; }
if (DamageTypeGetsTerrainDefense(damageType)) { newDamage *= terrainAdjustment; }
takenDamage += newDamage;
}
int32_t newNumber;
const int32_t casualties = (int32_t)(takenDamage * baseDeadliness);
const auto casualties = static_cast<int32_t>(takenDamage * baseDeadliness);
if (casualties < 0) {
throw ShardokInternalErrorException(
@@ -155,11 +155,7 @@ int32_t MutatingInternalTakeDamage(
" (takenDamage=" + std::to_string(takenDamage) + ")");
}
if (battalion->size() > casualties) {
newNumber = battalion->size() - casualties;
} else {
newNumber = 0;
}
const int32_t newNumber = std::max(0, battalion->size() - casualties);
battalion->mutate_size(newNumber);
@@ -6,8 +6,8 @@
// Copyright (c) 2014 none. All rights reserved.
//
#ifndef __eagle0__Battalion__
#define __eagle0__Battalion__
#ifndef EAGLE0_SHARDOK_LIBRARY_UNIT_BATTALION_HPP
#define EAGLE0_SHARDOK_LIBRARY_UNIT_BATTALION_HPP
#include <memory>
#include <unordered_map>
@@ -63,4 +63,4 @@ auto MutatingTakeEnvironmentalDamage(
} // namespace shardok
#endif /* defined(__eagle0__Battalion__) */
#endif // EAGLE0_SHARDOK_LIBRARY_UNIT_BATTALION_HPP
@@ -6,8 +6,8 @@
// Copyright (c) 2014 none. All rights reserved.
//
#ifndef __eagle0__Hero__
#define __eagle0__Hero__
#ifndef EAGLE0_SHARDOK_LIBRARY_UNIT_HERO_HPP
#define EAGLE0_SHARDOK_LIBRARY_UNIT_HERO_HPP
#include <limits>
#include <optional>
@@ -42,4 +42,4 @@ auto MutatingTakeDamage(
} // namespace shardok
#endif /* defined(__eagle0__Hero__) */
#endif // EAGLE0_SHARDOK_LIBRARY_UNIT_HERO_HPP
@@ -8,6 +8,7 @@
#include "src/main/cpp/net/eagle0/shardok/library/unit/Unit.hpp"
#include <algorithm>
#include <utility>
namespace shardok {
@@ -25,7 +26,7 @@ auto InternalTakeDamageFb(
inline auto factorIntoAdjustment(const double factorPercentile, const double swingPercentile)
-> double {
return 1.0 + (factorPercentile * swingPercentile / 100.0) / 100.0;
return 1.0 + ((factorPercentile * swingPercentile / 100.0) / 100.0);
}
auto MaxActionPoints(const Unit &unit) -> ActionPoints {
@@ -39,31 +40,30 @@ auto MaxActionPoints(const Unit &unit) -> ActionPoints {
}
auto OpponentKnowledge(const Unit &unit, const PlayerId toPlayer) -> int {
if (unit.opponent_knowledge()->size() == 0) return 0;
else if (toPlayer == -1) {
if (unit.opponent_knowledge()->size() == 0) { return 0; }
if (toPlayer == -1) {
// handle observer, with pid -1
int8_t max = 0;
for (int i = 0; i < unit.opponent_knowledge()->size(); i++) {
max = std::max(max, unit.opponent_knowledge()->Get(i));
}
return max;
} else
return unit.opponent_knowledge()->Get(toPlayer);
}
return unit.opponent_knowledge()->Get(toPlayer);
}
auto OpponentKnowledge(const Unit *unit, const PlayerId toPlayer) -> int {
if (unit->opponent_knowledge()->size() == 0) return 0;
else if (toPlayer >= unit->opponent_knowledge()->size())
return 0;
else if (toPlayer == -1) {
if (unit->opponent_knowledge()->size() == 0) { return 0; }
if (toPlayer >= unit->opponent_knowledge()->size()) { return 0; }
if (toPlayer == -1) {
// handle observer, with pid -1
int8_t max = 0;
for (int i = 0; i < unit->opponent_knowledge()->size(); i++) {
max = std::max(max, unit->opponent_knowledge()->Get(i));
}
return max;
} else
return unit->opponent_knowledge()->Get(toPlayer);
}
return unit->opponent_knowledge()->Get(toPlayer);
}
auto MutatingApplyDamageFrom(
@@ -140,7 +140,7 @@ void MutatingSpendActionPoints(Unit *unit, const ActionCost &cost) {
if (unit->has_attached_hero()) {
const double currentVigor = unit->attached_hero().vigor();
const double vigorSpend = -(double)cost.points * ACTION_COST_TO_VIGOR_COST;
const double vigorSpend = -static_cast<double>(cost.points) * ACTION_COST_TO_VIGOR_COST;
const double newVigor = std::max(currentVigor + vigorSpend, 0.0);
unit->mutable_attached_hero().mutate_vigor(newVigor);
@@ -212,8 +212,7 @@ auto InternalTakeDamageFb(
const auto battalion = victim->battalion();
if (heroDamageRatio > 1.0) heroDamageRatio = 1.0;
if (heroDamageRatio < 0.0) heroDamageRatio = 0.0;
heroDamageRatio = std::clamp(heroDamageRatio, 0.0, 1.0);
if (victim->has_attached_hero()) {
const auto hero = victim->attached_hero();
@@ -221,8 +220,9 @@ auto InternalTakeDamageFb(
double vigorHit = 0.0;
for (int i = 0; i < NUM_DAMAGE_TYPES; i++) {
vigorHit += heroDamage.GetNormalDamageOfType(DamageType(i)) * heroMortalityFactor;
vigorHit += heroDamage.GetPenetratingDamageOfType(DamageType(i)) * heroMortalityFactor;
const auto damageType = static_cast<DamageType>(i);
vigorHit += heroDamage.GetNormalDamageOfType(damageType) * heroMortalityFactor;
vigorHit += heroDamage.GetPenetratingDamageOfType(damageType) * heroMortalityFactor;
// TODO: hero should have adjustments for damage types too
}
@@ -236,24 +236,25 @@ auto InternalTakeDamageFb(
double takenDamage = 0.0;
double terrainAdjustment = battalionType->GetDamageTakenMultiplierForTerrain(&terrain);
for (int i = 0; i < (int)NUM_DAMAGE_TYPES; i++) {
for (int i = 0; i < NUM_DAMAGE_TYPES; i++) {
const auto damageType = static_cast<DamageType>(i);
double armamentAdjustment = 1.0 - (battalionType->baseResistanceByType[i] +
(battalion.armament() / 100.0) *
battalionType->maxAugmentResistanceByType[i]) /
100.0;
double newDamage =
(battalionDamage.GetNormalDamageOfType((DamageType)i) * flankingAdjustment *
(battalionDamage.GetNormalDamageOfType(damageType) * flankingAdjustment *
armamentAdjustment);
newDamage += battalionDamage.GetPenetratingDamageOfType((DamageType)i) * flankingAdjustment;
newDamage += battalionDamage.GetPenetratingDamageOfType(damageType) * flankingAdjustment;
if (DamageTypeGetsTerrainDefense((DamageType)i)) { newDamage *= terrainAdjustment; }
if (DamageTypeGetsTerrainDefense(damageType)) { newDamage *= terrainAdjustment; }
takenDamage += newDamage;
}
int32_t newNumber;
auto casualties = (int32_t)(takenDamage * baseDeadliness);
int32_t newNumber = 0;
const auto casualties = static_cast<int32_t>(takenDamage * baseDeadliness);
if (battalion.size() > casualties) {
newNumber = battalion.size() - casualties;
@@ -285,31 +286,26 @@ auto WithTakenDamageFb(
double flankingAdjustment = 1.0;
const BattalionTypeSPtr &type = settings.GetBattalionType(victim->battalion().type());
if (orientation == flank) flankingAdjustment = type->flankDamageMultiplier;
else if (orientation == rear)
if (orientation == flank) {
flankingAdjustment = type->flankDamageMultiplier;
} else if (orientation == rear) {
flankingAdjustment = type->rearDamageMultiplier;
if (shouldReduceForFortified && victim->fortified()) {
return InternalTakeDamageFb(
victim,
amount * settings.Backing().fortify_damage_taken_multiplier(),
settings.GetBattalionType(victim->battalion().type()),
terrain,
heroDamageRatio,
flankingAdjustment,
settings.Backing().hero_mortality_factor(),
settings.Backing().base_deadliness());
} else {
return InternalTakeDamageFb(
victim,
amount,
settings.GetBattalionType(victim->battalion().type()),
terrain,
heroDamageRatio,
flankingAdjustment,
settings.Backing().hero_mortality_factor(),
settings.Backing().base_deadliness());
}
const CombatDamage adjustedAmount =
shouldReduceForFortified && victim->fortified()
? amount * settings.Backing().fortify_damage_taken_multiplier()
: amount;
return InternalTakeDamageFb(
victim,
adjustedAmount,
settings.GetBattalionType(victim->battalion().type()),
terrain,
heroDamageRatio,
flankingAdjustment,
settings.Backing().hero_mortality_factor(),
settings.Backing().base_deadliness());
}
auto ReserveUnitsForPlayer(const Units *units, const PlayerId pid)
@@ -318,8 +314,9 @@ auto ReserveUnitsForPlayer(const Units *units, const PlayerId pid)
std::map<UnitId, const Unit *> reserves{};
for (const Unit *unit : *units) {
if (unit->player_id() == pid &&
unit->status() == net::eagle0::shardok::storage::fb::UnitStatus_RESERVE_UNIT)
unit->status() == net::eagle0::shardok::storage::fb::UnitStatus_RESERVE_UNIT) {
reserves[unit->unit_id()] = unit;
}
}
return reserves;
@@ -332,8 +329,9 @@ auto PlacedUnitsForPlayer(const Units *units, const PlayerId pid)
for (const Unit *unit : *units) {
if (unit->player_id() == pid &&
unit->status() != net::eagle0::shardok::storage::fb::UnitStatus_RESERVE_UNIT &&
unit->status() != net::eagle0::shardok::storage::fb::UnitStatus_PENDING_REINFORCEMENT)
unit->status() != net::eagle0::shardok::storage::fb::UnitStatus_PENDING_REINFORCEMENT) {
placedUnits[unit->unit_id()] = unit;
}
}
return placedUnits;
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef Unit_hpp
#define Unit_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_UNIT_UNIT_HPP
#define EAGLE0_SHARDOK_LIBRARY_UNIT_UNIT_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCTypes.h"
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"
@@ -81,4 +81,4 @@ auto PlacedUnitsForPlayer(const Units *units, PlayerId pid) -> map<UnitId, const
} // namespace shardok
#endif /* Unit_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_UNIT_UNIT_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef MeleeUtils_hpp
#define MeleeUtils_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_UTIL_COMBAT_UTILS_HPP
#define EAGLE0_SHARDOK_LIBRARY_UTIL_COMBAT_UTILS_HPP
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/unit/Unit.hpp"
@@ -87,4 +87,4 @@ public:
};
} // namespace shardok
#endif /* MeleeUtils_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_UTIL_COMBAT_UTILS_HPP
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef HexMapUtils_hpp
#define HexMapUtils_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_UTIL_HEX_MAP_UTILS_HPP
#define EAGLE0_SHARDOK_LIBRARY_UTIL_HEX_MAP_UTILS_HPP
#include <algorithm>
#include <ranges>
@@ -325,4 +325,4 @@ auto IsBelievedEmpty(PlayerId playerId, const Coords &coords, const Units *units
} // namespace shardok
#endif /* HexMapUtils_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_UTIL_HEX_MAP_UTILS_HPP
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef ZoneOfControlCalculator_hpp
#define ZoneOfControlCalculator_hpp
#ifndef EAGLE0_SHARDOK_LIBRARY_UTIL_ZONE_OF_CONTROL_CALCULATOR_HPP
#define EAGLE0_SHARDOK_LIBRARY_UTIL_ZONE_OF_CONTROL_CALCULATOR_HPP
#include "HexMapUtils.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/settings/GameSettings.hpp"
@@ -46,4 +46,4 @@ ExertsZoneOfControl(const SettingsGetter &settings, const Unit *unit, PlayerId t
const Coords &destination) -> AttackOrientation;
} // namespace shardok
#endif /* ZoneOfControlCalculator_hpp */
#endif // EAGLE0_SHARDOK_LIBRARY_UTIL_ZONE_OF_CONTROL_CALCULATOR_HPP
@@ -6,8 +6,8 @@
// Copyright © 2019 none. All rights reserved.
//
#ifndef EagleInterfaceGrpcServer_hpp
#define EagleInterfaceGrpcServer_hpp
#ifndef EAGLE0_SHARDOK_SERVER_EAGLE_INTERFACE_GRPC_SERVER_HPP
#define EAGLE0_SHARDOK_SERVER_EAGLE_INTERFACE_GRPC_SERVER_HPP
#include <memory>
#include <string>
@@ -91,4 +91,4 @@ public:
};
} // namespace shardok
#endif /* EagleInterfaceGrpcServer_hpp */
#endif // EAGLE0_SHARDOK_SERVER_EAGLE_INTERFACE_GRPC_SERVER_HPP
@@ -1,5 +1,5 @@
#ifndef GameOverResponsePopulator_hpp
#define GameOverResponsePopulator_hpp
#ifndef EAGLE0_SHARDOK_SERVER_GAME_OVER_RESPONSE_POPULATOR_HPP
#define EAGLE0_SHARDOK_SERVER_GAME_OVER_RESPONSE_POPULATOR_HPP
#include <string>
#include <vector>
@@ -33,4 +33,4 @@ auto FromInternalStatus(
} // namespace shardok
#endif /* GameOverResponsePopulator_hpp */
#endif // EAGLE0_SHARDOK_SERVER_GAME_OVER_RESPONSE_POPULATOR_HPP
@@ -57,7 +57,7 @@ ServerConfiguration::ServerConfiguration(const string& filePath) {
istr.getline(line, 256);
if (strnlen(line, 256) < 3) continue;
string key = strtok(line, " =");
string value = strtok(NULL, " =");
string value = strtok(nullptr, " =");
configValues[key] = value;
}
@@ -6,8 +6,8 @@
// Copyright © 2018 none. All rights reserved.
//
#ifndef ServerConfiguration_hpp
#define ServerConfiguration_hpp
#ifndef EAGLE0_SHARDOK_SERVER_SERVER_CONFIGURATION_HPP
#define EAGLE0_SHARDOK_SERVER_SERVER_CONFIGURATION_HPP
#include <string>
#include <unordered_map>
@@ -32,4 +32,4 @@ public:
const static string kAuthTokenPath;
};
#endif /* ServerConfiguration_hpp */
#endif // EAGLE0_SHARDOK_SERVER_SERVER_CONFIGURATION_HPP
@@ -9,6 +9,7 @@
#include "ShardokGamesManager.hpp"
#include <memory>
#include <mutex>
#include <shared_mutex>
#include <utility>
@@ -68,7 +69,7 @@ auto ShardokGamesManager::UnlockedCreateFromGameStateBytes(
const byte_vector &gameStateBytes,
int32_t startingHistoryCount,
const string &mapName) -> GameId {
std::shared_lock<std::shared_mutex> lk(runningControllersLock);
std::unique_lock<std::shared_mutex> lk(runningControllersLock);
auto gs = GameStateW::FromByteVector(gameStateBytes);
@@ -90,7 +91,7 @@ auto ShardokGamesManager::UnlockedCreateSpecifiedGame(
const string &serializedRequest,
const std::vector<std::pair<int32_t, std::vector<PlayerId>>> &watcherAllies) -> GameId {
// Check for existing game with this ID and early-exit
std::shared_lock<std::shared_mutex> lk(runningControllersLock);
std::unique_lock<std::shared_mutex> lk(runningControllersLock);
const auto existingGame = runningControllers.find(gameId);
// If it exists, register new handlers and early-exit
@@ -6,8 +6,8 @@
// Copyright © 2017 none. All rights reserved.
//
#ifndef ServerGamesManager_hpp
#define ServerGamesManager_hpp
#ifndef EAGLE0_SHARDOK_SERVER_SHARDOK_GAMES_MANAGER_HPP
#define EAGLE0_SHARDOK_SERVER_SHARDOK_GAMES_MANAGER_HPP
#include <functional>
#include <memory>
@@ -121,4 +121,4 @@ public:
};
} // namespace shardok
#endif /* ServerGamesManager_hpp */
#endif // EAGLE0_SHARDOK_SERVER_SHARDOK_GAMES_MANAGER_HPP
@@ -6,8 +6,8 @@
// Validates Bearer tokens in the 'authorization' metadata header.
//
#ifndef TokenAuthInterceptor_hpp
#define TokenAuthInterceptor_hpp
#ifndef EAGLE0_SHARDOK_SERVER_TOKEN_AUTH_INTERCEPTOR_HPP
#define EAGLE0_SHARDOK_SERVER_TOKEN_AUTH_INTERCEPTOR_HPP
#include <fstream>
#include <iostream>
@@ -116,4 +116,4 @@ inline auto ReadAuthTokenFromFile(const std::string& filePath) -> std::string {
} // namespace shardok
#endif /* TokenAuthInterceptor_hpp */
#endif // EAGLE0_SHARDOK_SERVER_TOKEN_AUTH_INTERCEPTOR_HPP
@@ -68,9 +68,6 @@ void handler(const int sig) {
}
auto main(const int argc, char **argv) -> int {
(void)argc;
(void)argv;
signal(SIGSEGV, handler); // install our handler
FilesystemUtils::SetExecPath(argv[0]);
@@ -252,7 +252,7 @@ RectTransform:
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -10, y: 0}
m_SizeDelta: {x: 32, y: 32}
m_SizeDelta: {x: 44, y: 44}
m_Pivot: {x: 1, y: 0.5}
--- !u!222 &8373916935102330305
CanvasRenderer:
@@ -1162,7 +1162,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 86.59145, y: -127}
m_SizeDelta: {x: 120, y: 26}
m_SizeDelta: {x: 120, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4354027254114168199
CanvasRenderer:
@@ -1272,9 +1272,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 120
m_PreferredHeight: 30
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -3969,7 +3969,7 @@ PrefabInstance:
- target: {fileID: 4374038768321626813, guid: fee9323a39d4d49338c3ef7ef85f6985,
type: 3}
propertyPath: m_SizeDelta.y
value: 25
value: 44
objectReference: {fileID: 0}
- target: {fileID: 4374038768321626813, guid: fee9323a39d4d49338c3ef7ef85f6985,
type: 3}
@@ -4049,7 +4049,7 @@ PrefabInstance:
- target: {fileID: 5648968011886801047, guid: fee9323a39d4d49338c3ef7ef85f6985,
type: 3}
propertyPath: m_SizeDelta.y
value: 25
value: 44
objectReference: {fileID: 0}
- target: {fileID: 5648968011886801047, guid: fee9323a39d4d49338c3ef7ef85f6985,
type: 3}
@@ -4079,7 +4079,7 @@ PrefabInstance:
- target: {fileID: 5678746054507640123, guid: fee9323a39d4d49338c3ef7ef85f6985,
type: 3}
propertyPath: m_SizeDelta.y
value: 25
value: 44
objectReference: {fileID: 0}
- target: {fileID: 5678746054507640123, guid: fee9323a39d4d49338c3ef7ef85f6985,
type: 3}
@@ -4369,7 +4369,7 @@ PrefabInstance:
- target: {fileID: 8728618441403129635, guid: fee9323a39d4d49338c3ef7ef85f6985,
type: 3}
propertyPath: m_SizeDelta.y
value: 25
value: 44
objectReference: {fileID: 0}
- target: {fileID: 8728618441403129635, guid: fee9323a39d4d49338c3ef7ef85f6985,
type: 3}
@@ -2088,7 +2088,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 277.5, y: -17.5}
m_SizeDelta: {x: 225, y: 35}
m_SizeDelta: {x: 225, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &6568002168404457349
MonoBehaviour:
@@ -2152,9 +2152,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 225
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -2896,7 +2896,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 1012.5, y: -17.5}
m_SizeDelta: {x: 225, y: 35}
m_SizeDelta: {x: 225, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2536113809541095963
MonoBehaviour:
@@ -2960,9 +2960,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 225
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -3004,7 +3004,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 767.5, y: -17.5}
m_SizeDelta: {x: 225, y: 35}
m_SizeDelta: {x: 225, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &4949409443685672109
MonoBehaviour:
@@ -3068,9 +3068,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 225
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -3435,7 +3435,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 650, y: -225.5}
m_SizeDelta: {x: 1290, y: 35}
m_SizeDelta: {x: 1290, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5169051346157033462
CanvasRenderer:
@@ -3472,9 +3472,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: -854.3499
m_PreferredHeight: -1
m_PreferredHeight: 44
m_FlexibleWidth: 1
m_FlexibleHeight: 0
m_LayoutPriority: 1
@@ -3931,7 +3931,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 522.5, y: -17.5}
m_SizeDelta: {x: 225, y: 35}
m_SizeDelta: {x: 225, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &4110992760340391202
MonoBehaviour:
@@ -3995,9 +3995,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 225
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -2576,9 +2576,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 225
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -3345,9 +3345,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 225
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -3916,9 +3916,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 200
m_PreferredHeight: 30
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: 0
m_LayoutPriority: 1
@@ -4281,7 +4281,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 95.40441, y: -215}
m_SizeDelta: {x: 150, y: 30}
m_SizeDelta: {x: 150, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8982402502509954525
CanvasRenderer:
@@ -4403,9 +4403,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 150
m_PreferredHeight: 30
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -2086,7 +2086,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 90, y: -134}
m_SizeDelta: {x: 180, y: 35}
m_SizeDelta: {x: 180, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &7501192298675143721
MonoBehaviour:
@@ -2150,9 +2150,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: 0
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 180
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -2639,7 +2639,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 90, y: -89}
m_SizeDelta: {x: 180, y: 35}
m_SizeDelta: {x: 180, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &7174305543327231876
MonoBehaviour:
@@ -2703,9 +2703,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: 0
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 180
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -3057,7 +3057,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 90, y: -44}
m_SizeDelta: {x: 180, y: 35}
m_SizeDelta: {x: 180, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1699620799270868465
MonoBehaviour:
@@ -3121,9 +3121,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: 0
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 180
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -131,7 +131,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 960.1557, y: -16.5}
m_SizeDelta: {x: 198.59923, y: 33}
m_SizeDelta: {x: 198.59923, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &9126053559433354862
MonoBehaviour:
@@ -195,9 +195,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 220
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -280,9 +280,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: -1
m_PreferredHeight: -1
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: 1
m_LayoutPriority: 1
@@ -2102,7 +2102,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 1189.7277, y: -16.5}
m_SizeDelta: {x: 180.54474, y: 33}
m_SizeDelta: {x: 180.54474, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6112751865803778905
CanvasRenderer:
@@ -2212,9 +2212,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 200
m_PreferredHeight: -1
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: 1
m_LayoutPriority: 1
@@ -2498,7 +2498,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 541.01166, y: -16.5}
m_SizeDelta: {x: 162.49026, y: 33}
m_SizeDelta: {x: 162.49026, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &3896912302030604581
MonoBehaviour:
@@ -2562,9 +2562,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 180
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -3536,7 +3536,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 329.1829, y: -16.5}
m_SizeDelta: {x: 221.16731, y: 33}
m_SizeDelta: {x: 221.16731, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1345808385683317494
MonoBehaviour:
@@ -3600,9 +3600,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 245
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -3719,7 +3719,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 741.55646, y: -16.5}
m_SizeDelta: {x: 198.59923, y: 33}
m_SizeDelta: {x: 198.59923, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &8494862080301576888
MonoBehaviour:
@@ -3783,9 +3783,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 220
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -3833,7 +3833,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 640, y: -211.5}
m_SizeDelta: {x: 1280, y: 33}
m_SizeDelta: {x: 1280, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3604403311084700028
CanvasRenderer:
@@ -3870,9 +3870,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: -854.3499
m_PreferredHeight: -1
m_PreferredHeight: 44
m_FlexibleWidth: 1
m_FlexibleHeight: 0
m_LayoutPriority: 1
@@ -4203,7 +4203,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 99.29962, y: -16.5}
m_SizeDelta: {x: 198.59923, y: 33}
m_SizeDelta: {x: 198.59923, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2588932345895194830
MonoBehaviour:
@@ -4267,9 +4267,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 220
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -686,7 +686,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 10, y: -10}
m_AnchoredPosition: {x: 22, y: -22}
m_SizeDelta: {x: 20, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &926632779962815960
@@ -904,7 +904,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: -214.00003, y: -209}
m_SizeDelta: {x: 20, y: 20}
m_SizeDelta: {x: 44, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &8242559266383646029
MonoBehaviour:
@@ -1427,7 +1427,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: -214.00003, y: -158.99998}
m_SizeDelta: {x: 20, y: 20}
m_SizeDelta: {x: 44, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &5011652097361437691
MonoBehaviour:
@@ -1642,7 +1642,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 10, y: -10}
m_AnchoredPosition: {x: 22, y: -22}
m_SizeDelta: {x: 20, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1009416593887454201
@@ -1712,7 +1712,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 324, y: -119}
m_SizeDelta: {x: 24, y: 24}
m_SizeDelta: {x: 44, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6574377907172759685
CanvasRenderer:
@@ -1822,7 +1822,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: -1
m_PreferredHeight: -1
m_FlexibleWidth: -1
@@ -1844,7 +1844,7 @@ MonoBehaviour:
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: 24
m_PreferredHeight: 24
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -2136,7 +2136,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 46, y: -119}
m_SizeDelta: {x: 24, y: 24}
m_SizeDelta: {x: 44, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6996475469755520655
CanvasRenderer:
@@ -2246,7 +2246,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: -1
m_PreferredHeight: -1
m_FlexibleWidth: -1
@@ -2268,7 +2268,7 @@ MonoBehaviour:
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: 24
m_PreferredHeight: 24
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -251,7 +251,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 338.31927, y: -12.923078}
m_SizeDelta: {x: 96.75219, y: 25.846155}
m_SizeDelta: {x: 96.75219, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &7706371227584479729
MonoBehaviour:
@@ -315,9 +315,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 180
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -1137,7 +1137,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 59.126343, y: -12.923078}
m_SizeDelta: {x: 118.25268, y: 25.846155}
m_SizeDelta: {x: 118.25268, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &3005629370892248399
MonoBehaviour:
@@ -1201,9 +1201,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 220
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -2034,7 +2034,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 204.09793, y: -12.923078}
m_SizeDelta: {x: 131.69049, y: 25.846155}
m_SizeDelta: {x: 131.69049, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1248166195846916077
MonoBehaviour:
@@ -2098,9 +2098,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 245
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -3400,7 +3400,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 410.35156, y: -230.07692}
m_SizeDelta: {x: 810.7031, y: 25.846155}
m_SizeDelta: {x: 810.7031, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4496069533907013775
CanvasRenderer:
@@ -4101,7 +4101,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 756.95197, y: -12.923078}
m_SizeDelta: {x: 107.50243, y: 25.846155}
m_SizeDelta: {x: 107.50243, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &50070872754773658
CanvasRenderer:
@@ -4211,9 +4211,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 200
m_PreferredHeight: -1
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: 1
m_LayoutPriority: 1
@@ -4319,7 +4319,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 465.82172, y: -12.923078}
m_SizeDelta: {x: 118.25268, y: 25.846155}
m_SizeDelta: {x: 118.25268, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &6791613139375434283
MonoBehaviour:
@@ -4383,9 +4383,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 220
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -4748,7 +4748,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 604.0744, y: -12.923078}
m_SizeDelta: {x: 118.25268, y: 25.846155}
m_SizeDelta: {x: 118.25268, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &159881109546823439
MonoBehaviour:
@@ -4812,9 +4812,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 220
m_PreferredHeight: 35
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -1411,7 +1411,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 136.27197, y: -200.5}
m_SizeDelta: {x: 150, y: 25}
m_SizeDelta: {x: 150, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8538181288592016588
CanvasRenderer:
@@ -1533,9 +1533,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: 135
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 150
m_PreferredHeight: 25
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: 0
m_LayoutPriority: 1
@@ -1120,7 +1120,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 75, y: -15}
m_SizeDelta: {x: 150, y: 30}
m_SizeDelta: {x: 150, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7054265081857237224
CanvasRenderer:
@@ -1230,9 +1230,9 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 150
m_PreferredHeight: 30
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -324,7 +324,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 215, y: 24}
m_SizeDelta: {x: 250, y: 20}
m_SizeDelta: {x: 250, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1949439835697595086
MonoBehaviour:
@@ -1434,7 +1434,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 194, y: -42}
m_SizeDelta: {x: 160, y: 30}
m_SizeDelta: {x: 160, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7346251710853780603
CanvasRenderer:
@@ -1928,7 +1928,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 77.5, y: -16}
m_SizeDelta: {x: 25, y: 25}
m_SizeDelta: {x: 44, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5162963118205884471
CanvasRenderer:
@@ -2038,7 +2038,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 25
m_PreferredHeight: 25
m_FlexibleWidth: -1
@@ -2060,7 +2060,7 @@ MonoBehaviour:
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: 18
m_PreferredHeight: 18
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: 0
m_LayoutPriority: 1
@@ -2299,7 +2299,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 522.5, y: -16}
m_SizeDelta: {x: 25, y: 25}
m_SizeDelta: {x: 44, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3327516808560080911
CanvasRenderer:
@@ -2409,7 +2409,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 25
m_PreferredHeight: 25
m_FlexibleWidth: -1
@@ -2431,7 +2431,7 @@ MonoBehaviour:
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: 18
m_PreferredHeight: 18
m_PreferredHeight: 44
m_FlexibleWidth: 0
m_FlexibleHeight: 0
m_LayoutPriority: 1
@@ -6826,8 +6826,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 490, y: -267.73685}
m_SizeDelta: {x: 980, y: 20.526316}
m_AnchoredPosition: {x: 490, y: -279.4737}
m_SizeDelta: {x: 980, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &52167055
MonoBehaviour:
@@ -6843,9 +6843,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: -1
m_PreferredHeight: -1
m_PreferredHeight: 44
m_FlexibleWidth: 1
m_FlexibleHeight: 0
m_LayoutPriority: 1
@@ -27729,8 +27729,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 660, y: -10.263158}
m_SizeDelta: {x: 120, y: 20.526316}
m_AnchoredPosition: {x: 660, y: -22}
m_SizeDelta: {x: 120, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &220244842
MonoBehaviour:
@@ -27746,9 +27746,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 120
m_PreferredHeight: 25
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -53444,8 +53444,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 920, y: -10.263158}
m_SizeDelta: {x: 120, y: 20.526316}
m_AnchoredPosition: {x: 920, y: -22}
m_SizeDelta: {x: 120, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &396655493
MonoBehaviour:
@@ -53461,9 +53461,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 120
m_PreferredHeight: 25
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -129615,8 +129615,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 790, y: -10.263158}
m_SizeDelta: {x: 120, y: 20.526316}
m_AnchoredPosition: {x: 790, y: -22}
m_SizeDelta: {x: 120, y: 44}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &909477096
MonoBehaviour:
@@ -129632,9 +129632,9 @@ MonoBehaviour:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.LayoutElement
m_IgnoreLayout: 0
m_MinWidth: -1
m_MinHeight: -1
m_MinHeight: 44
m_PreferredWidth: 120
m_PreferredHeight: 25
m_PreferredHeight: 44
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
@@ -17,7 +17,6 @@ import (
"net"
"net/http"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
@@ -1486,7 +1485,7 @@ func handleGameUpload(w http.ResponseWriter, r *http.Request) {
}
// Validate zip file
zipReader, err := zip.NewReader(bytes.NewReader(zipBytes), int64(len(zipBytes)))
_, err = zip.NewReader(bytes.NewReader(zipBytes), int64(len(zipBytes)))
if err != nil {
log.Printf("Failed to read zip file: %v", err)
http.Error(w, "Invalid zip file", http.StatusBadRequest)
@@ -1576,57 +1575,11 @@ func handleGameUpload(w http.ResponseWriter, r *http.Request) {
log.Printf("Removed existing game %s from memory for replacement", gameIDHex)
}
// Extract to save directory
homeDir, err := os.UserHomeDir()
if err != nil {
log.Printf("Failed to get home directory: %v", err)
http.Error(w, "Failed to get home directory", http.StatusInternalServerError)
return
}
saveDir := filepath.Join(homeDir, "eagle0", "eagle", "save", gameIDHex)
// Create save directory
if err := os.MkdirAll(saveDir, 0755); err != nil {
log.Printf("Failed to create save directory %s: %v", saveDir, err)
http.Error(w, "Failed to create save directory", http.StatusInternalServerError)
return
}
// Unzip to saveDir
for _, f := range zipReader.File {
destPath := filepath.Join(saveDir, f.Name)
// Security check: prevent path traversal
if !strings.HasPrefix(destPath, saveDir) {
log.Printf("Invalid file path in zip: %s", f.Name)
continue
}
outFile, err := os.Create(destPath)
if err != nil {
log.Printf("Failed to create file %s: %v", destPath, err)
continue
}
rc, err := f.Open()
if err != nil {
outFile.Close()
log.Printf("Failed to open zip entry %s: %v", f.Name, err)
continue
}
_, err = io.Copy(outFile, rc)
rc.Close()
outFile.Close()
if err != nil {
log.Printf("Failed to extract %s: %v", f.Name, err)
}
}
// Call gRPC to register the game
// Stream the zip to Eagle so extraction happens beside Eagle's save directory.
importCtx, importCancel := context.WithTimeout(context.Background(), 30*time.Second)
defer importCancel()
resp, err := gameAdminClient.ImportGame(importCtx, &gameadminpb.ImportGameRequest{
GameId: int64(gameIDUint),
})
resp, err := uploadGameSave(importCtx, int64(gameIDUint), forceReplace, zipBytes)
if err != nil {
log.Printf("Failed to import game %s via gRPC: %v", gameIDHex, err)
http.Error(w, fmt.Sprintf("Failed to register game: %v", err), http.StatusInternalServerError)
@@ -1645,6 +1598,30 @@ func handleGameUpload(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, fmt.Sprintf("/games/%s", gameIDHex), http.StatusFound)
}
func uploadGameSave(ctx context.Context, gameID int64, overwriteExisting bool, zipBytes []byte) (*gameadminpb.UploadGameSaveResponse, error) {
stream, err := gameAdminClient.UploadGameSave(ctx)
if err != nil {
return nil, err
}
const chunkSize = 64 * 1024
for offset := 0; offset < len(zipBytes); offset += chunkSize {
end := offset + chunkSize
if end > len(zipBytes) {
end = len(zipBytes)
}
if err := stream.Send(&gameadminpb.UploadGameSaveRequest{
GameId: gameID,
OverwriteExisting: overwriteExisting,
Chunk: zipBytes[offset:end],
}); err != nil {
return nil, err
}
}
return stream.CloseAndRecv()
}
// API handlers (keep JSON endpoints for programmatic access)
func handleGamesAPI(w http.ResponseWriter, r *http.Request) {
@@ -2,7 +2,7 @@
<tr>
<td colspan="6">
<div class="alert warning">Game failed to load: {{.ErrorMsg}}<br>
Showing raw action history (no faction/date info). Rewind uses raw file truncation.</div>
Showing raw action history (no faction/date info). Rewind truncates persisted history directly.</div>
</td>
</tr>
{{end}}
@@ -26,7 +26,7 @@
<button class="btn-rewind"
hx-post="/games/{{$.GameID}}/{{if $.IsRawMode}}raw-rewind{{else}}rewind{{end}}"
hx-vals='{"targetAction": "{{.Index}}"}'
hx-confirm="{{if $.IsRawMode}}Raw rewind game to action {{.Index}}? This truncates persisted files and cannot be undone.{{else}}Rewind game to action {{.Index}}? This will disconnect all clients and cannot be undone.{{end}}"
hx-confirm="{{if $.IsRawMode}}Raw rewind game to action {{.Index}}? This truncates persisted history directly and cannot be undone.{{else}}Rewind game to action {{.Index}}? This will disconnect all clients and cannot be undone.{{end}}"
hx-target="#rewind-result"
hx-swap="innerHTML"
onclick="event.stopPropagation()">
@@ -52,6 +52,9 @@ service GameAdmin {
// Import a game from save files
rpc ImportGame(ImportGameRequest) returns (ImportGameResponse) {}
// Upload and import a zipped game save on the Eagle server
rpc UploadGameSave(stream UploadGameSaveRequest) returns (UploadGameSaveResponse) {}
// Delete a game (optionally including save files)
rpc DeleteGame(DeleteGameRequest) returns (DeleteGameResponse) {}
@@ -340,6 +343,7 @@ message RewindGameResponse {
// ImportGame
message ImportGameRequest {
int64 game_id = 1;
bool overwrite_existing = 2;
}
message ImportGameResponse {
@@ -353,6 +357,17 @@ message ImportGameResponse {
string error_message = 2;
}
message UploadGameSaveRequest {
int64 game_id = 1;
bool overwrite_existing = 2;
bytes chunk = 3;
}
message UploadGameSaveResponse {
ImportGameResponse.Result result = 1;
string error_message = 2;
}
// DeleteGame
message DeleteGameRequest {
int64 game_id = 1;
@@ -1,6 +1,6 @@
package net.eagle0.common
import scala.annotation.{nowarn, tailrec}
import scala.annotation.tailrec
import scala.collection.SeqFactory
case class RandomState[+T](
@@ -160,10 +160,9 @@ abstract class FunctionalRandom {
)(
f: (T, FunctionalRandom) => RandomState[S[U]]
)(using xFactory: FACT): RandomState[S[U]] = {
@nowarn def foldGen(rsU: RandomState[S[U]], t: T): RandomState[S[U]] =
rsU.continue {
case (us: S[U], fr: FunctionalRandom) =>
f(t, fr).map(x => (us ++ x).asInstanceOf[S[U]])
def foldGen(rsU: RandomState[S[U]], t: T): RandomState[S[U]] =
rsU.continue { (us, fr) =>
f(t, fr).map(x => xFactory.from(us ++ x))
}
FunctionalRandom.nextFoldLeft(
seq,
@@ -179,17 +178,16 @@ abstract class FunctionalRandom {
nextFlatMapImpl[T, U, Vector, SeqFactory[Vector]](vec)(f)(using Vector)
private def nextMapImpl[T, U, S[X] <: Seq[X], FACT <: SeqFactory[S]](
seq: Vector[T]
seq: S[T]
)(
f: (T, FunctionalRandom) => RandomState[U]
)(using xFactory: FACT): RandomState[S[U]] = {
@nowarn def foldGen(
def foldGen(
rsU: RandomState[S[U]],
t: T
): RandomState[S[U]] =
rsU.continue {
case (us: S[U], fr: FunctionalRandom) =>
f(t, fr).map(x => (us :+ x).asInstanceOf[S[U]])
rsU.continue { (us, fr) =>
f(t, fr).map(x => xFactory.from(us :+ x))
}
FunctionalRandom.nextFoldLeft(seq, RandomState(xFactory.empty[U], this))(
@@ -71,6 +71,12 @@ trait ClientTextStore {
def withMovedBackToUnrequested(id: ClientTextId): ClientTextStore
/**
* Removes generated text rows created after a rewind target. Anything past the retained action count belongs to
* history that no longer exists, and deterministic request IDs may be reused if the game re-advances.
*/
def withoutTextsAfter(maxHistoryCount: Int): ClientTextStore
/** Adds a pre-existing complete text directly (for pregenerated texts like hero names). */
def withAddedCompleteText(
id: ClientTextId,
@@ -219,6 +219,26 @@ case class ClientTextStoreImpl(
this
}
override def withoutTextsAfter(maxHistoryCount: Int): ClientTextStore = {
val removedIds =
completeTexts.values.filter(_.requestedAfterHistoryCount > maxHistoryCount).map(_.id).toSet ++
incompleteTexts.values.filter(_.requestedAfterHistoryCount > maxHistoryCount).map(_.id).toSet ++
unrequestedTexts.values.filter(_.requestedAfterHistoryCount > maxHistoryCount).map(_.id).toSet
if removedIds.isEmpty then this
else
copy(
completeTexts = completeTexts -- removedIds,
incompleteTexts = incompleteTexts -- removedIds,
unrequestedTexts = unrequestedTexts -- removedIds,
accessibleTo = accessibleTo -- removedIds,
hiddenFromClients = hiddenFromClients -- removedIds,
incompleteTextsAreSaved = false,
accessibleToIsSaved = false,
hiddenFromClientsIsSaved = false
)
}
def withAddedCompleteText(
id: ClientTextId,
text: String,
@@ -426,6 +426,80 @@ class PostgresClientTextStore private[client_text] (
this
}
override def withoutTextsAfter(maxHistoryCount: Int): ClientTextStore = {
val selectSql =
"""SELECT id FROM client_texts
|WHERE requested_after_history_count > ?""".stripMargin
val selectStmt = connection.prepareStatement(selectSql)
val ids = JfrEvents.postgresQuery(
databaseName,
"PostgresClientTextStore.withoutTextsAfter.selectIds",
selectSql
) { event =>
try {
selectStmt.setInt(1, maxHistoryCount)
val rs = selectStmt.executeQuery()
val result = scala.collection.mutable.ArrayBuffer[ClientTextId]()
while rs.next() do result += rs.getString("id")
event.rows = result.size
result.toVector
} finally selectStmt.close()
}
if ids.isEmpty then return this
println(
s"Removing ${ids.size} generated text row(s) after rewound history count $maxHistoryCount: ${ids.mkString(", ")}"
)
var idsArray: java.sql.Array = null
try {
idsArray = connection.createArrayOf("text", ids.toArray)
val deleteVisibilitySql = "DELETE FROM client_text_visibility WHERE text_id = ANY(?)"
val deleteVisibilityStmt = connection.prepareStatement(deleteVisibilitySql)
JfrEvents.postgresQuery(
databaseName,
"PostgresClientTextStore.withoutTextsAfter.deleteVisibility",
deleteVisibilitySql
) { event =>
try {
deleteVisibilityStmt.setArray(1, idsArray)
event.rows = deleteVisibilityStmt.executeUpdate()
} finally deleteVisibilityStmt.close()
}
val deleteHiddenSql = "DELETE FROM client_text_hidden WHERE text_id = ANY(?)"
val deleteHiddenStmt = connection.prepareStatement(deleteHiddenSql)
JfrEvents.postgresQuery(
databaseName,
"PostgresClientTextStore.withoutTextsAfter.deleteHidden",
deleteHiddenSql
) { event =>
try {
deleteHiddenStmt.setArray(1, idsArray)
event.rows = deleteHiddenStmt.executeUpdate()
} finally deleteHiddenStmt.close()
}
val deleteTextsSql = "DELETE FROM client_texts WHERE id = ANY(?)"
val deleteTextsStmt = connection.prepareStatement(deleteTextsSql)
JfrEvents.postgresQuery(
databaseName,
"PostgresClientTextStore.withoutTextsAfter.deleteTexts",
deleteTextsSql
) { event =>
try {
deleteTextsStmt.setArray(1, idsArray)
event.rows = deleteTextsStmt.executeUpdate()
} finally deleteTextsStmt.close()
}
} finally if idsArray != null then idsArray.free()
end try
this
}
override def withAddedCompleteText(
id: ClientTextId,
text: String,
@@ -506,6 +506,49 @@ class SqliteClientTextStore private[client_text] (
this
}
override def withoutTextsAfter(maxHistoryCount: Int): ClientTextStore = {
val idsStmt = connection.prepareStatement(
"""SELECT id FROM texts
|WHERE requested_after_history_count > ?""".stripMargin
)
val ids =
try {
idsStmt.setInt(1, maxHistoryCount)
val rs = idsStmt.executeQuery()
val result = scala.collection.mutable.ArrayBuffer[ClientTextId]()
while rs.next() do result += rs.getString("id")
result.toVector
} finally idsStmt.close()
if ids.isEmpty then return this
println(
s"Removing ${ids.size} generated text row(s) after rewound history count $maxHistoryCount: ${ids.mkString(", ")}"
)
ids.foreach { id =>
val visStmt = connection.prepareStatement("DELETE FROM visibility WHERE text_id = ?")
try {
visStmt.setString(1, id)
visStmt.executeUpdate()
} finally visStmt.close()
val hiddenStmt = connection.prepareStatement("DELETE FROM hidden_texts WHERE text_id = ?")
try {
hiddenStmt.setString(1, id)
hiddenStmt.executeUpdate()
} finally hiddenStmt.close()
val textStmt = connection.prepareStatement("DELETE FROM texts WHERE id = ?")
try {
textStmt.setString(1, id)
textStmt.executeUpdate()
} finally textStmt.close()
}
this
}
override def withAddedCompleteText(
id: ClientTextId,
text: String,
@@ -1478,6 +1478,7 @@ scala_library(
"//src/main/scala/net/eagle0/eagle:eagle_pkg",
"//src/main/scala/net/eagle0/eagle/library:eagle_internal_exception",
"//src/main/scala/net/eagle0/eagle/library/actions/applier:action_result_applier",
"//src/main/scala/net/eagle0/eagle/library/actions/llm_request_generators/captured_hero_helpers:captured_hero_plea_generator",
"//src/main/scala/net/eagle0/eagle/library/actions/util:shattered_army_utils",
"//src/main/scala/net/eagle0/eagle/library/settings:battle_agriculture_devastation_delta",
"//src/main/scala/net/eagle0/eagle/library/settings:battle_economy_devastation_delta",
@@ -2,6 +2,7 @@ package net.eagle0.eagle.library.actions.impl.action
import net.eagle0.eagle.{BattalionId, FactionId, HeroId, ProvinceId, RoundId}
import net.eagle0.eagle.library.actions.applier.{ActionResultApplier, ActionResultWithResultingState}
import net.eagle0.eagle.library.actions.generated_text_request_generators.captured_hero_helpers.CapturedHeroPleaGenerator
import net.eagle0.eagle.library.actions.util.ShatteredArmyUtils
import net.eagle0.eagle.library.settings.{
BattleAgricultureDevastationDelta,
@@ -40,6 +41,10 @@ case class ResolveBattleAction(
startingGameState: GameState,
resolvedBattles: Vector[BattleResolution]
) {
private case class SecuredPrisonerProvinceChange(
provinceChange: ChangedProvinceC,
securingFactionId: FactionId
)
def fleeProvince(hero: HeroT, battle: ShardokBattle): Option[ProvinceId] =
battle.players
@@ -356,7 +361,9 @@ case class ResolveBattleAction(
}
}.toVector
ActionResultC(
val securedPrisonerChanges = securedPrisonerProvinceChanges(battle, battleResolution)
val battleEnded = ActionResultC(
actionResultType = BattleEnded,
resolvedBattle = Some(battle.shardokGameId),
changedHeroes = changedHeroes,
@@ -365,12 +372,28 @@ case class ResolveBattleAction(
batt = battle,
br = battleResolution,
destroyedBattalionIds = destroyedBattalionIds(battleResolution)
) :+ defenderCP(
) ++ securedPrisonerChanges.map(_.provinceChange) :+ defenderCP(
battle = battle,
battleResolution = battleResolution
),
destroyedBattalionIds = destroyedBattalionIds(battleResolution)
) +: winnersFulfilledQuestActionResults(
)
securedPrisonerChanges.foldLeft(battleEnded: ActionResultT) {
case (ar, securedPrisonerChange) =>
securedPrisonerChange.provinceChange.newCapturedHeroes.headOption
.map(capturedHero =>
CapturedHeroPleaGenerator.withPleaForCapturedHero(
gameId = startingState.gameId,
currentRoundId = startingState.currentRoundId,
capturingFactionId = securedPrisonerChange.securingFactionId,
provinceId = securedPrisonerChange.provinceChange.provinceId,
capturedHero = capturedHero,
actionResult = ar
)
)
.getOrElse(ar)
} +: winnersFulfilledQuestActionResults(
startingState = startingState,
battle = battle,
battleResolution = battleResolution
@@ -711,12 +734,12 @@ case class ResolveBattleAction(
shatteredArmy = ma,
battleProvinceId = batt.defenderProvince
)
)).toVector ++ securedPrisonerProvinceChanges(batt, br)
)).toVector
private def securedPrisonerProvinceChanges(
batt: ShardokBattle,
br: BattleResolution
): Vector[ChangedProvinceC] = {
): Vector[SecuredPrisonerProvinceChange] = {
val playersByFaction = batt.players.map(sp => sp.eagleFid -> sp).toMap
val resolvedByFaction = br.resolvedPlayers.map(rsp => rsp.eagleFid -> rsp).toMap
@@ -735,7 +758,7 @@ case class ResolveBattleAction(
factionId -> destinationProvinceIds.head
}
val securedByProvince = for {
val securedByProvinceAndFaction = for {
rsp <- br.resolvedPlayers.toVector
secured <- rsp.units.filter(_.status == UnitStatus.Secured)
securedByFactionId = secured.securedByEagleFactionId.getOrElse(
@@ -759,19 +782,25 @@ case class ResolveBattleAction(
playersByFaction(securedByFactionId).isDefender != playersByFaction(rsp.eagleFid).isDefender,
s"Secured hero ${secured.hero.id} was secured by same-side faction $securedByFactionId"
)
} yield destinationProvinceId -> CapturedHero(
} yield (destinationProvinceId, securedByFactionId) -> CapturedHero(
heroId = secured.hero.id,
recruitmentAttempted = false,
previousFactionId = secured.hero.factionId.get
)
securedByProvince.groupBy { case (provinceId, _) => provinceId }.toVector.sortBy {
case (provinceId, _) => provinceId
securedByProvinceAndFaction.groupBy {
case ((provinceId, securingFactionId), _) =>
(provinceId, securingFactionId)
}.toVector.sortBy {
case ((provinceId, securingFactionId), _) => (provinceId, securingFactionId)
}.map {
case (provinceId, capturedHeroes) =>
ChangedProvinceC(
provinceId = provinceId,
newCapturedHeroes = capturedHeroes.map { case (_, capturedHero) => capturedHero }
case ((provinceId, securingFactionId), capturedHeroes) =>
SecuredPrisonerProvinceChange(
provinceChange = ChangedProvinceC(
provinceId = provinceId,
newCapturedHeroes = capturedHeroes.map { case (_, capturedHero) => capturedHero }
),
securingFactionId = securingFactionId
)
}
}

Some files were not shown because too many files have changed in this diff Show More