aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/Geocache.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/Geocache.java')
-rw-r--r--main/src/cgeo/geocaching/Geocache.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java
index c2edf44..033196c 100644
--- a/main/src/cgeo/geocaching/Geocache.java
+++ b/main/src/cgeo/geocaching/Geocache.java
@@ -1207,7 +1207,9 @@ public class Geocache implements IWaypoint {
waypoint.setGeocode(geocode);
if (waypoint.getId() < 0) { // this is a new waypoint
- assignUniquePrefix(waypoint);
+ if (StringUtils.isBlank(waypoint.getPrefix())) {
+ assignUniquePrefix(waypoint);
+ }
waypoints.add(waypoint);
if (waypoint.isFinalWithCoords()) {
finalDefined = true;
@@ -1242,13 +1244,14 @@ public class Geocache implements IWaypoint {
}
for (int i = OWN_WP_PREFIX_OFFSET; i < 100; i++) {
- final String prefixCandidate = StringUtils.leftPad(String.valueOf(i), 2, '0');
+ final String prefixCandidate = String.valueOf(i);
if (!assignedPrefixes.contains(prefixCandidate)) {
waypoint.setPrefix(prefixCandidate);
- break;
+ return;
}
}
+ throw new IllegalStateException("too many waypoints, unable to assign unique prefix");
}
public boolean hasWaypoints() {