Compare commits

...
Author SHA1 Message Date
admin b08ee2539a Use preincrement in production loops 2026-06-23 12:32:39 -07:00
4 changed files with 5 additions and 5 deletions
@@ -443,7 +443,7 @@ void ShardokEngine::PostPlacementCommands(
reinforcementPositions);
// first make sure they're all valid and there are no duplicates
for (size_t i = 0; i < placementInfos.size(); i++) {
for (size_t i = 0; i < placementInfos.size(); ++i) {
const UnitPlacementInfo &pi = placementInfos[i];
const auto it = std::ranges::find_if(*placementCommands, [pi](const CommandSPtr &cmd) {
@@ -77,7 +77,7 @@ static auto CreateIceClearedMap(const HexMap* map) -> fb::HexMapW {
auto* mutableMap = mapCopy.Get();
auto* terrainVec = mutableMap->mutable_terrain();
for (size_t i = 0; i < terrainVec->size(); i++) {
for (size_t i = 0; i < terrainVec->size(); ++i) {
// Only process tiles with ice
// const_cast is safe here because we own the mutable buffer (mapCopy)
if (auto* terrain = const_cast<Terrain*>(terrainVec->GetMutableObject(i));
@@ -75,7 +75,7 @@ auto EndTurnCommand::InternalExecute(
// Any heroes in fire get burninated
// Decrement stun counters, increment cast state
const auto beforeFireUnitsCount = runningGameState->units()->size();
for (size_t i = 0; i < beforeFireUnitsCount; i++) {
for (size_t i = 0; i < beforeFireUnitsCount; ++i) {
const auto *beforeUnit = runningGameState->units()->Get(static_cast<unsigned int>(i));
if (beforeUnit->status() != net::eagle0::shardok::storage::fb::UnitStatus_NORMAL_UNIT)
continue;
@@ -114,7 +114,7 @@ auto EndTurnCommand::InternalExecute(
endTurnResult.mutable_next_player()->set_value(NextPlayerId(currentState, GetPlayerId()));
const auto unitsAtEndOfRoundCount = runningGameState->units()->size();
for (size_t i = 0; i < unitsAtEndOfRoundCount; i++) {
for (size_t i = 0; i < unitsAtEndOfRoundCount; ++i) {
// Grab the unit fresh because it might have been modified by a previous iteration of the
// loop
const auto *eorUnit = runningGameState->units()->Get(static_cast<unsigned int>(i));
@@ -206,7 +206,7 @@ auto SetUpController(
if (tutorialConfig.enabled()) {
std::vector<PlayerId> allPlayerIds;
allPlayerIds.reserve(playerInfos.size());
for (size_t i = 0; i < playerInfos.size(); i++) {
for (size_t i = 0; i < playerInfos.size(); ++i) {
allPlayerIds.push_back(static_cast<PlayerId>(i));
}