Compare commits

..
Author SHA1 Message Date
admin 8d8baf8175 Use pre-increment in hex map helper tests 2026-06-23 13:13:07 -07:00
5 changed files with 17 additions and 17 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);
}
@@ -64,7 +64,7 @@ TEST_F(ExtinguishFireCommandTests, Execute_givesAgilityXp) {
actor->mutable_attached_hero().mutate_agility_xp(11);
actor->mutable_attached_hero().mutate_wisdom_xp(33);
std::vector<double> rolls{0.50};
auto rolls = std::vector<double>{0.50};
const auto generator = std::make_shared<SequenceRandomGenerator>(rolls);
const auto results = ExtinguishFireCommand(
@@ -83,7 +83,7 @@ TEST_F(ExtinguishFireCommandTests, Execute_givesAgilityXp) {
}
TEST_F(ExtinguishFireCommandTests, ExecuteLowRoll_extinguishesFire) {
std::vector<double> rolls{0.25};
auto rolls = std::vector<double>{0.25};
const auto generator = std::make_shared<SequenceRandomGenerator>(rolls);
GetMutableTerrain(hexMap, Coords(3, 3))->mutable_modifier().mutable_fire().mutate_present(true);
@@ -107,7 +107,7 @@ TEST_F(ExtinguishFireCommandTests, ExecuteLowRoll_extinguishesFire) {
}
TEST_F(ExtinguishFireCommandTests, ExecuteHighRoll_doesNotExtinguish) {
std::vector<double> rolls{0.75};
auto rolls = std::vector<double>{0.75};
const auto generator = std::make_shared<SequenceRandomGenerator>(rolls);
GetMutableTerrain(hexMap, Coords(3, 3))->mutable_modifier().mutable_fire().mutate_present(true);
@@ -129,7 +129,7 @@ TEST_F(ExtinguishFireCommandTests, ExecuteHighRoll_doesNotExtinguish) {
TEST_F(ExtinguishFireCommandTests, ExecuteHiddenActor_unhides) {
actor->mutate_hidden(true);
std::vector<double> rolls{0.75};
auto rolls = std::vector<double>{0.75};
const auto generator = std::make_shared<SequenceRandomGenerator>(rolls);
GetMutableTerrain(hexMap, Coords(3, 3))->mutable_modifier().mutable_fire().mutate_present(true);
@@ -58,7 +58,7 @@ public:
};
TEST_F(StartFireCommandTests, ExecuteLowRoll_startsFire) {
std::vector<double> rolls{0.25};
auto rolls = std::vector<double>{0.25};
const auto generator = std::make_shared<SequenceRandomGenerator>(rolls);
const auto results = StartFireCommand(
@@ -81,7 +81,7 @@ TEST_F(StartFireCommandTests, ExecuteLowRoll_startsFire) {
}
TEST_F(StartFireCommandTests, ExecuteHighRoll_doesNotStartFire) {
std::vector<double> rolls{0.75};
auto rolls = std::vector<double>{0.75};
const auto generator = std::make_shared<SequenceRandomGenerator>(rolls);
const auto results = StartFireCommand(
@@ -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());