Skip to content

Commit

Permalink
Merge branch 'fix-replay-test' into ai_battle
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Jun 26, 2024
2 parents 979a3a6 + 7ad73df commit c5f9382
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ jobs:
# Use C++ 17 standard (default for gcc-11)
# Use system cmake
# Use system boost
- { compiler: gcc-11, os: ubuntu-22.04, type: Debug, cmake: 3.22.1, boost: 1.74.0 }
- { compiler: clang-14, os: ubuntu-22.04, type: Debug, cmake: 3.22.1, boost: 1.74.0, cxx: 17 }
# Also include a (semi-)optimized build to a) shake out issues there an b) run the replay tests
- { compiler: clang-14, os: ubuntu-22.04, type: Debug, cmake: 3.22.1, boost: 1.74.0, cxx: 17 }
- { compiler: gcc-11, os: ubuntu-22.04, type: Debug, cmake: 3.22.1, boost: 1.74.0 }
- { compiler: gcc-11, os: ubuntu-22.04, type: RelWithDebInfo, cmake: 3.22.1, boost: 1.74.0 }
#
# Latest Compilers
# GCC 12 needs boost 1.82 to compile correctly
Expand Down Expand Up @@ -191,7 +193,7 @@ jobs:
run: echo "TRAVIS_BUILD_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV

- name: Build
run: tools/ci/travisBuild.sh
run: tools/ci/build.sh

- run: tools/ci/collectCoverageData.sh && external/libutil/tools/ci/uploadCoverageData.sh
if: matrix.coverage && success()
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ platform:
- x64

environment:
BOOST_ROOT: C:\Libraries\boost_1_77_0
BOOST_ROOT: C:\Libraries\boost_1_83_0
GENERATOR: Visual Studio 16 2019
RTTR_DISABLE_ASSERT_BREAKPOINT: 1

Expand Down
8 changes: 4 additions & 4 deletions libs/s25main/Replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bool Replay::StopRecording()
{
if(!isRecording_)
return true;
const unsigned replayDataSize = file_.Tell();
const auto replayDataSize = file_.Tell();
isRecording_ = false;
file_.Close();

Expand All @@ -64,18 +64,18 @@ bool Replay::StopRecording()
const auto lastGF = file.ReadUnsignedInt();
RTTR_Assert(lastGF == lastGF_);
compressedReplay.WriteUnsignedInt(lastGF);
file.ReadUnsignedChar(); // Ignore compressed flag
compressedReplay.WriteUnsignedChar(1);
file.ReadUnsignedChar(); // Ignore compressed flag (always zero for the temporary file)

// Read and compress remaining data
const auto uncompressedSize = replayDataSize - file.Tell();
const auto uncompressedSize = replayDataSize - file.Tell(); // Always positive as there is always some game data
data.resize(uncompressedSize);
file.ReadRawData(data.data(), data.size());
data = CompressedData::compress(data);
// If the compressed data turns out to be larger than the uncompressed one, bail out
// This can happen for very short replays
if(data.size() >= uncompressedSize)
return true;
compressedReplay.WriteUnsignedChar(1); // Compressed flag
compressedReplay.WriteUnsignedInt(uncompressedSize);
compressedReplay.WriteUnsignedInt(data.size());
compressedReplay.WriteRawData(data.data(), data.size());
Expand Down
Binary file modified tests/testData/200kGFs.rpl
Binary file not shown.
Binary file modified tests/testData/SeaMap300kGfs.rpl
Binary file not shown.
4 changes: 2 additions & 2 deletions tools/ci/travisBuild.sh → tools/ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export RTTR_DISABLE_ASSERT_BREAKPOINT=1
export UBSAN_OPTIONS=print_stacktrace=1
export AUDIODEV=null # Avoid errors like: ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
export SDL_VIDEODRIVER=dummy # Avoid crash on travis
if ! ctest --output-on-failure -j2; then
if ! ctest --output-on-failure -C "${BUILD_TYPE}" -j2; then
cat CMakeCache.txt
echo "LD:${LD_LIBRARY_PATH:-}"
echo "DYLD:${DYLD_LIBRARY_PATH:-}"
ctest --output-on-failure --rerun-failed --extra-verbose
ctest --output-on-failure -C "${BUILD_TYPE}" --rerun-failed --extra-verbose
fi

0 comments on commit c5f9382

Please sign in to comment.