Skip to content

Commit

Permalink
Const correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
ranisalt committed Nov 6, 2024
1 parent d63140f commit 4d314b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void Container::unserializeItemNode(OTB::iterator& first, const OTB::iterator la
{
Item::unserializeItemNode(first, last, node);

for (auto& itemNode : node.children) {
for (const auto& itemNode : node.children) {
// load container items
if (itemNode.type != tfs::io::map::OTBM_ITEM) [[unlikely]] {
throw std::invalid_argument("Invalid node type");
Expand Down
9 changes: 4 additions & 5 deletions src/iomap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void parseTileArea(const OTB::Node& node, Map& map)
auto first = node.propsBegin;
auto [base_x, base_y, z] = read_coords(first, node.propsEnd);

for (auto& tileNode : node.children) {
for (const auto& tileNode : node.children) {
if (tileNode.type != OTBM_TILE && tileNode.type != OTBM_HOUSETILE) [[unlikely]] {
throw std::invalid_argument(fmt::format("Unknown tile node: {:d}.", static_cast<uint16_t>(node.type)));
}
Expand Down Expand Up @@ -264,7 +264,7 @@ void parseTileArea(const OTB::Node& node, Map& map)

void parseTowns(const OTB::Node& townsNode, Map& map)
{
for (auto& node : townsNode.children) {
for (const auto& node : townsNode.children) {
if (node.type != OTBM_TOWN) [[unlikely]] {
throw std::invalid_argument(fmt::format("Unknown town node: {:d}.", static_cast<uint16_t>(node.type)));
}
Expand All @@ -280,8 +280,7 @@ void parseTowns(const OTB::Node& townsNode, Map& map)

void parseWaypoints(const OTB::Node& waypointsNode, Map& map)
{
PropStream propStream;
for (auto& node : waypointsNode.children) {
for (const auto& node : waypointsNode.children) {
if (node.type != OTBM_WAYPOINT) [[unlikely]] {
throw std::invalid_argument(fmt::format("Unknown waypoint node: {:d}.", static_cast<uint16_t>(node.type)));
}
Expand Down Expand Up @@ -360,7 +359,7 @@ MapAttributes loadMap(Map& map, std::filesystem::path fileName)
houses = fileName.stem().concat("-house.xml");
}

for (auto& node : mapNode.children) {
for (const auto& node : mapNode.children) {
switch (node.type) {
case OTBM_TILE_AREA:
parseTileArea(node, map);
Expand Down

0 comments on commit 4d314b9

Please sign in to comment.