mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-29 13:15:42 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea3252db90 |
@@ -46,12 +46,12 @@ auto ConvertVictoryCondition(const net::eagle0::shardok::common::VictoryConditio
|
||||
|
||||
auto FromPlayerInfoProto(flatbuffers::FlatBufferBuilder& fbb, const PlayerInfoProto& piProto)
|
||||
-> flatbuffers::Offset<net::eagle0::shardok::storage::fb::PlayerInfo> {
|
||||
auto alliesVec = std::vector<AlliedPlayer>();
|
||||
std::vector<AlliedPlayer> alliesVec;
|
||||
alliesVec.reserve(piProto.allies_size());
|
||||
for (const auto& apProto : piProto.allies()) { alliesVec.emplace_back(apProto.player_id()); }
|
||||
const auto alliesOffset = fbb.CreateVectorOfStructs(alliesVec);
|
||||
|
||||
auto vcVec = std::vector<int8_t>();
|
||||
std::vector<int8_t> vcVec;
|
||||
const int victoryConditionCount = piProto.victory_conditions_size();
|
||||
vcVec.reserve(victoryConditionCount);
|
||||
for (int i = 0; i < victoryConditionCount; i++) {
|
||||
@@ -142,7 +142,7 @@ auto SetupInitialGameState(
|
||||
&endGameCondition);
|
||||
auto gameIdOffset = fbb.CreateString(gameId);
|
||||
|
||||
auto playerInfoVec = std::vector<Offset<PlayerInfo>>();
|
||||
std::vector<Offset<PlayerInfo>> playerInfoVec;
|
||||
playerInfoVec.reserve(playerInfoProtos.size());
|
||||
for (const auto& piProto : playerInfoProtos) {
|
||||
playerInfoVec.push_back(FromPlayerInfoProto(fbb, piProto));
|
||||
@@ -162,7 +162,7 @@ auto SetupInitialGameState(
|
||||
// Add slack units: 3 per necromancer, minimum 5 for general use
|
||||
const int slackUnits = std::max(5, necromancerCount * 3);
|
||||
|
||||
auto unitsVec = std::vector<Unit>();
|
||||
std::vector<Unit> unitsVec;
|
||||
unitsVec.reserve(units.size() + slackUnits);
|
||||
for (const auto& unit : units) {
|
||||
Unit modifiedUnit = unit;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user