Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b551e70

Browse files
committed
prospector: Avoid crashing due to invalid vein materials
Fixes #1276, ref #1277
1 parent 759ba5c commit b551e70

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

docs/Plugins.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ probe
129129
Can be used to determine tile properties like temperature.
130130

131131
.. _prospect:
132+
.. _prospector:
132133

133134
prospect
134135
========

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
4343

4444
## Fixes
4545
- `tweak` max-wheelbarrow: fixed conflict with building renaming
46+
- `prospector`: fixed crash due to invalid vein materials
4647

4748
## Misc Improvements
4849
- `adv-rumors`: bound to Ctrl-A

plugins/prospector.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,21 @@ void printVeins(color_ostream &con, MatMap &mat_map,
177177
MatMap gems;
178178
MatMap rest;
179179

180-
for (MatMap::const_iterator it = mat_map.begin(); it != mat_map.end(); ++it)
180+
for (const auto &kv : mat_map)
181181
{
182-
df::inorganic_raw *gloss = world->raws.inorganics[it->first];
182+
df::inorganic_raw *gloss = vector_get(world->raws.inorganics, kv.first);
183+
if (!gloss)
184+
{
185+
con.printerr("invalid material gloss: %hi\n", kv.first);
186+
continue;
187+
}
183188

184189
if (gloss->material.isGem())
185-
gems[it->first] = it->second;
190+
gems[kv.first] = kv.second;
186191
else if (gloss->isOre())
187-
ores[it->first] = it->second;
192+
ores[kv.first] = kv.second;
188193
else
189-
rest[it->first] = it->second;
194+
rest[kv.first] = kv.second;
190195
}
191196

192197
con << "Ores:" << std::endl;

0 commit comments

Comments
 (0)