Compare commits

..
Author SHA1 Message Date
admin 22b762748e Use pre-increment in action point tests 2026-06-23 13:16:19 -07:00
4 changed files with 13 additions and 13 deletions
@@ -132,26 +132,26 @@ void EmplaceHexMap(GameStateW &gameState, const HexMap *hexMap) {
using Coords = net::eagle0::shardok::storage::fb::Coords;
using StartingPositionList = net::eagle0::shardok::storage::fb::StartingPositionList;
for (uint32_t i = 0; i < hexMap->terrain()->size(); ++i) {
for (uint32_t i = 0; i < hexMap->terrain()->size(); i++) {
*const_cast<Terrain *>(destMap->mutable_terrain()->GetMutableObject(i)) =
*hexMap->terrain()->Get(i);
}
for (uint32_t i = 0; i < hexMap->monthly_weather()->size(); ++i) {
for (uint32_t i = 0; i < hexMap->monthly_weather()->size(); i++) {
*const_cast<MonthlyWeather *>(destMap->mutable_monthly_weather()->GetMutableObject(i)) =
*hexMap->monthly_weather()->Get(i);
}
for (uint32_t i = 0; i < hexMap->defender_starting_positions()->positions()->size(); ++i) {
for (uint32_t i = 0; i < hexMap->defender_starting_positions()->positions()->size(); i++) {
*const_cast<Coords *>(destMap->mutable_defender_starting_positions()
->mutable_positions()
->GetMutableObject(i)) =
*hexMap->defender_starting_positions()->positions()->Get(i);
}
for (uint32_t i = 0; i < hexMap->attacker_starting_positions()->size(); ++i) {
for (uint32_t i = 0; i < hexMap->attacker_starting_positions()->size(); i++) {
const auto *asplOrigin = hexMap->attacker_starting_positions()->Get(i);
auto *asplDest = const_cast<StartingPositionList *>(
destMap->mutable_attacker_starting_positions()->GetMutableObject(i));
for (uint32_t j = 0; j < asplOrigin->positions()->size(); ++j) {
for (uint32_t j = 0; j < asplOrigin->positions()->size(); j++) {
*const_cast<Coords *>(asplDest->mutable_positions()->GetMutableObject(j)) =
*asplOrigin->positions()->Get(j);
}
@@ -201,7 +201,7 @@ auto MakeHexMapProto(
}
for (const auto &mw : monthlyWeathers) { *hmp.add_monthly_weather() = mw; }
for (int i = 0; i < 12; ++i) {
for (int i = 0; i < 12; i++) {
auto *mw = hmp.add_monthly_weather();
mw->set_sun_chance(100);
}
@@ -28,11 +28,11 @@ class ActionPointDistancesTest : public ::testing::Test {
// P P P M P P
// const_cast is safe because we own the mutable buffer (map)
for (int i = 6; i < 12; i++) {
for (int i = 6; i < 12; ++i) {
const_cast<Terrain*>(map->mutable_terrain()->GetMutableObject(i))
->mutate_type(net::eagle0::shardok::storage::fb::Terrain_::Type_FOREST);
}
for (int i = 18; i < 24; i++) {
for (int i = 18; i < 24; ++i) {
const_cast<Terrain*>(map->mutable_terrain()->GetMutableObject(i))
->mutate_type(net::eagle0::shardok::storage::fb::Terrain_::Type_RIVER);
}
@@ -100,7 +100,7 @@ TEST_F(GameStateHelpersTests, newBufferFromCopy_setsFields) {
EXPECT_GE(newGs->units()->size(), 6);
// Find our unit with ID 19 (it might not be at index 0 due to reserved slots)
bool foundUnit = false;
for (size_t i = 0; i < newGs->units()->size(); ++i) {
for (size_t i = 0; i < newGs->units()->size(); i++) {
if (newGs->units()->Get(static_cast<unsigned int>(i))->unit_id() == 19) {
foundUnit = true;
EXPECT_EQ(5, newGs->units()->Get(static_cast<unsigned int>(i))->eagle_player_id());
@@ -32,8 +32,8 @@ TEST_F(HexMapHelpersTests, convertProto_setsFields) {
EXPECT_EQ(map.row_count(), fbMapPointer->row_count());
EXPECT_EQ(map.column_count(), fbMapPointer->column_count());
for (int i = 0; i < map.row_count(); ++i) {
for (int j = 0; j < map.column_count(); ++j) {
for (int i = 0; i < map.row_count(); i++) {
for (int j = 0; j < map.column_count(); j++) {
const auto index = i * map.column_count() + j;
EXPECT_EQ(map.terrain(index).type(), fbMapPointer->terrain()->Get(index)->type());
@@ -60,8 +60,8 @@ TEST_F(HexMapHelpersTests, setUpInitialHexMap_freezesWaterInWinter) {
EXPECT_EQ(map.row_count(), fbMapPointer->row_count());
EXPECT_EQ(map.column_count(), fbMapPointer->column_count());
for (int i = 0; i < map.row_count(); ++i) {
for (int j = 0; j < map.column_count(); ++j) {
for (int i = 0; i < map.row_count(); i++) {
for (int j = 0; j < map.column_count(); j++) {
const auto index = i * map.column_count() + j;
EXPECT_EQ(map.terrain(index).type(), fbMapPointer->terrain()->Get(index)->type());