Compare commits

..
Author SHA1 Message Date
admin 8d8baf8175 Use pre-increment in hex map helper tests 2026-06-23 13:13:07 -07:00
13 changed files with 21 additions and 21 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);
}
@@ -34,7 +34,7 @@ class ExtinguishFireCommandTests : public ::testing::Test {
fbb.ForceDefaults(true);
auto actorOff = AddGenericUnit(0, 0, Coords(3, 2));
vector<Unit> unitsVec{actorOff};
auto unitsVec = vector<Unit>{actorOff};
auto unitsOff = fbb.CreateVectorOfSortedStructs(&unitsVec);
auto mapOff = AddHexMap(fbb, BASIC_MAP_FB);
@@ -26,7 +26,7 @@ class FearCommandTest : public ::testing::Test {
auto actorOff = AddGenericUnit(5, 0, position);
auto victimOff = AddGenericUnit(4, 1, target);
vector<Unit> unitsVec{actorOff, victimOff};
auto unitsVec = vector<Unit>{actorOff, victimOff};
auto unitsOff = fbb.CreateVectorOfSortedStructs(&unitsVec);
auto mapOff = AddBasicMap(fbb);
@@ -19,7 +19,7 @@ class FortifyCommandTest : public ::testing::Test {
fbb.ForceDefaults(true);
auto engOff = AddGenericUnit(5, 0, Coords(2, 2));
vector<Unit> unitsVec{engOff};
auto unitsVec = vector<Unit>{engOff};
auto unitsOff = fbb.CreateVectorOfSortedStructs(&unitsVec);
GameStateBuilder gsb(fbb);
@@ -35,7 +35,7 @@ class FreezeWaterCommandTest : public ::testing::Test {
auto undeadOff = AddGenericUndead(4, 1, target);
vector<Unit> unitsVec{mageOff, undeadOff};
auto unitsVec = vector<Unit>{mageOff, undeadOff};
auto unitsOff = fbb.CreateVectorOfSortedStructs(&unitsVec);
GameStateBuilder gsb(fbb);
@@ -28,7 +28,7 @@ class HideCommandTests : public ::testing::Test {
auto rangerOff = AddGenericUnit(rangerPid, 0, position);
auto anotherOff = AddGenericUnit(anotherPid, 1, Coords(5, 5));
vector<Unit> unitsVec{rangerOff, anotherOff};
auto unitsVec = vector<Unit>{rangerOff, anotherOff};
auto unitsOff = fbb.CreateVectorOfSortedStructs(&unitsVec);
GameStateBuilder gsb(fbb);
@@ -20,7 +20,7 @@ class MeteorCancelCommandTest : public ::testing::Test {
fbb.ForceDefaults(true);
auto casterOff = AddGenericUnit(5, 0, Coords(5, 5));
vector<Unit> unitsVec{casterOff};
auto unitsVec = vector<Unit>{casterOff};
auto unitsOff = fbb.CreateVectorOfSortedStructs(&unitsVec);
GameStateBuilder gsb(fbb);
@@ -22,7 +22,7 @@ class MeteorStartCommandTest : public ::testing::Test {
fbb.ForceDefaults(true);
auto casterOff = AddGenericUnit(5, 0, Coords(5, 5));
vector<Unit> unitsVec{casterOff};
auto unitsVec = vector<Unit>{casterOff};
auto unitsOff = fbb.CreateVectorOfSortedStructs(&unitsVec);
GameStateBuilder gsb(fbb);
@@ -23,7 +23,7 @@ class MeteorTargetCommandTest : public ::testing::Test {
auto casterOff = AddGenericUnit(5, 0, Coords(5, 5));
vector<Unit> unitsVec{casterOff};
auto unitsVec = vector<Unit>{casterOff};
auto unitsOff = fbb.CreateVectorOfSortedStructs(&unitsVec);
GameStateBuilder gsb(fbb);
@@ -26,7 +26,7 @@ class RepairCommandTest : public ::testing::Test {
auto engOff = AddGenericUnit(1, 0, Coords(2, 2));
vector<Unit> unitsVec{engOff};
auto unitsVec = vector<Unit>{engOff};
auto unitsOff = fbb.CreateVectorOfSortedStructs(&unitsVec);
auto mapOff = AddBasicMap(fbb);
@@ -29,7 +29,7 @@ class StartFireCommandTests : public ::testing::Test {
fbb.ForceDefaults(true);
actor = AddGenericUnit(0, 0, Coords(2, 3));
std::vector<Unit> unitsVec{actor};
auto unitsVec = std::vector<Unit>{actor};
auto unitsOffset = fbb.CreateVectorOfSortedStructs(&unitsVec);
auto hexMap = AddHexMap(fbb, BASIC_MAP_FB);
@@ -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());