[C++] map_cell.structure_type is missing


#1

I don’t know why but there are features missing in the C++ Starter Bot.

Here is a small fix from me, but it does not handle all cases. Maybe someone has a better function to determin something like this.

// 0 = no structure
// 1 = own shipyard
// 2 = other shipyard
// 3 = own dropoff
// 4 = other dropoff
int getStructureType(const std::shared_ptr<Player> &me, 
    const std::vector<std::shared_ptr<Player>> &players, 
    const std::unique_ptr<GameMap> &map, 
    const Position &pos)
{
	if (!map->cells[pos.y][pos.x].has_structure)
		return 0;

	if (me->shipyard->position == pos)
		return 1;

	for (auto player_ptr : players)
	{
		if (player_ptr->id == me->id)
			continue;

		if (player_ptr->shipyard->position == pos)
			return 2;
	}

	log::log("some dropoff but I was to lazy to programm, 
        because it should have been in the starter API");
	return 5;
}

#2

It’s true that this is awkward in C++, however you can do it right now by checking if entity ID is -1, then it’s a shipyard. All the other structures are dropoffs. So functionality is there, just undocumented.


#3

Oh, thanks. I didn’t know that. But undocumented is not much better than not available. :wink:


#4

Yep. Added comments to the kit. Thanks for feedback!