mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-29 02:35:45 +00:00
Include starting_position_index in UnknownUnit view (#4584)
The starting_position_index field was not being included in the UnitView for hidden/unplaced enemy units, causing GameStateGuesser to default it to -1. This caused crashes in PlayerSetupCommandFactory when the AI tried to generate setup commands for attacker units. starting_position_index is public information (defenders know which direction attackers will spawn from), so it should always be visible. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,13 @@ using net::eagle0::shardok::api::UnitView;
|
||||
using net::eagle0::shardok::common::CommandType;
|
||||
using std::vector;
|
||||
|
||||
auto UnknownUnit(UnitId uid, PlayerId pid, BattalionTypeId bt, int size, bool hidden) -> UnitView;
|
||||
auto UnknownUnit(
|
||||
UnitId uid,
|
||||
PlayerId pid,
|
||||
BattalionTypeId bt,
|
||||
int size,
|
||||
bool hidden,
|
||||
int8_t startingPositionIndex) -> UnitView;
|
||||
|
||||
[[nodiscard]] auto UnitFilteredForPlayer(
|
||||
const SettingsGetter &settings,
|
||||
@@ -36,7 +42,8 @@ auto UnknownUnit(UnitId uid, PlayerId pid, BattalionTypeId bt, int size, bool hi
|
||||
unit->player_id(),
|
||||
unit->battalion().type(),
|
||||
unit->battalion().size(),
|
||||
true);
|
||||
true,
|
||||
unit->starting_position_index());
|
||||
}
|
||||
if (IsUnplaced(unit->location()) && !visibleToAsker) {
|
||||
return UnknownUnit(
|
||||
@@ -44,7 +51,8 @@ auto UnknownUnit(UnitId uid, PlayerId pid, BattalionTypeId bt, int size, bool hi
|
||||
unit->player_id(),
|
||||
unit->battalion().type(),
|
||||
unit->battalion().size(),
|
||||
false);
|
||||
false,
|
||||
unit->starting_position_index());
|
||||
}
|
||||
|
||||
UnitView filtered{};
|
||||
@@ -142,7 +150,8 @@ auto UnknownUnit(
|
||||
const PlayerId pid,
|
||||
BattalionTypeId bt,
|
||||
const int size,
|
||||
const bool hidden) -> UnitView {
|
||||
const bool hidden,
|
||||
const int8_t startingPositionIndex) -> UnitView {
|
||||
UnitView uv;
|
||||
uv.set_unit_id(uid);
|
||||
uv.set_player_id(pid);
|
||||
@@ -154,6 +163,11 @@ auto UnknownUnit(
|
||||
uv.mutable_battalion()->set_size(size);
|
||||
uv.set_hidden(hidden);
|
||||
|
||||
// starting_position_index is public info - defenders know attacker spawn directions
|
||||
if (startingPositionIndex != -1) {
|
||||
uv.mutable_starting_position_index()->set_value(startingPositionIndex);
|
||||
}
|
||||
|
||||
uv.set_my_knowledge(0);
|
||||
|
||||
return uv;
|
||||
|
||||
Reference in New Issue
Block a user