aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2015-03-16 10:41:46 +0100
committerSamuel Tardieu <sam@rfc1149.net>2015-03-16 10:42:04 +0100
commit115ead693d71025fac61d9390fed00fe150b96b1 (patch)
treec2e09986be54cb09afc58ca09cb0c70235c495b7 /main
parent80a350ebc20c861f630dcfb211a6f6d54800ea34 (diff)
downloadcgeo-115ead693d71025fac61d9390fed00fe150b96b1.zip
cgeo-115ead693d71025fac61d9390fed00fe150b96b1.tar.gz
cgeo-115ead693d71025fac61d9390fed00fe150b96b1.tar.bz2
fix #4686: waypoint texts might get mixed up
Diffstat (limited to 'main')
-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 67af107..ccec153 100644
--- a/main/src/cgeo/geocaching/Geocache.java
+++ b/main/src/cgeo/geocaching/Geocache.java
@@ -1206,7 +1206,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;
@@ -1241,13 +1243,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() {