示例#1
0
TEST(MapGatewayTest, fetchExistingMap_givesMap)
{
  MapGateway gateway;
  gateway.load("data/maps.xml");
  MapPtr map (gateway.fetch(MapId::GameStart));

  ASSERT_TRUE(map != nullptr);
  ASSERT_EQ(map->getId(), MapId::GameStart );
}
示例#2
0
void MapGateway::parseMaps(vector<char>& buf)
{
  xml_document<> doc;
  doc.parse<0>(&buf[0]);

  xml_node<>* maps = doc.first_node("Maps");
  xml_node<>* mapNode = maps ? maps->first_node("Map") : nullptr;

  while(mapNode != nullptr)
  {
    _mapParser.setSource( mapNode );
    MapPtr map = _mapParser.parse();
    if ( map ) _maps[ map->getId() ] = map;

    mapNode = mapNode->next_sibling();
  }
}