Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce chance that quest marker disappears as user zooms in #1462

Merged
merged 5 commits into from Jul 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -385,6 +385,26 @@ public void addQuest(Quest quest, QuestGroup group)
}
*/

private int getQuestPriority(Quest quest){
// priority is decided by
// - primarily by quest type to allow quest prioritization
// - for quests of the same type - influenced by quest id,
// this is done to reduce chance that as user zoom in a quest disappears,
// especially in case where disappearing quest is one that user selected to solve

// main priority part - values fit into Integer, but with as large steps as possible
Integer order = questTypeOrder.get(quest.getType());
if(order == null) order = 0;
int freeValuesForEachQuest = Integer.MAX_VALUE / questTypeOrder.size();
order *= freeValuesForEachQuest;

// quest ID is used to add values unique to each quest to make ordering consistent
// freeValuesForEachQuest is an int, so % freeValuesForEachQuest will fit into int
int hopefullyUniqueValueForQuest = (int) (quest.getId() % freeValuesForEachQuest);

return order + hopefullyUniqueValueForQuest;
}

@UiThread
public void addQuests(Iterable quests, QuestGroup group)
{
Expand All @@ -406,9 +426,6 @@ public void addQuests(Iterable quests, QuestGroup group)

String questIconName = getActivity().getResources().getResourceEntryName(quest.getType().getIcon());

Integer order = questTypeOrder.get(quest.getType());
if(order == null) order = 0;

LatLon[] positions = quest.getMarkerLocations();

for (LatLon pos : positions)
Expand All @@ -434,7 +451,7 @@ public void addQuests(Iterable quests, QuestGroup group)
geoJson.append("\",\"");
geoJson.append("order");
geoJson.append("\":\"");
geoJson.append(order);
geoJson.append(getQuestPriority(quest));
geoJson.append("\"}}");
}
}
Expand Down