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 1 commit
Commits
File filter

Filter by extension

Filter by extension

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

protected Long questPriority(Quest quest){
matkoniecz marked this conversation as resolved.
Show resolved Hide resolved
// 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;
Integer freeValuesForEachQuest = Integer.MAX_VALUE / questTypeOrder.size();
matkoniecz marked this conversation as resolved.
Show resolved Hide resolved
order = order * freeValuesForEachQuest;
matkoniecz marked this conversation as resolved.
Show resolved Hide resolved

// quest ID is used to add values unique to each quest to make ordering consistent
long hopefullyUniqueValueForQuest = quest.getId() % freeValuesForEachQuest;
matkoniecz marked this conversation as resolved.
Show resolved Hide resolved

return order + hopefullyUniqueValueForQuest;
}

@UiThread
public void addQuests(Iterable quests, QuestGroup group)
{
Expand All @@ -406,9 +425,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 +450,7 @@ public void addQuests(Iterable quests, QuestGroup group)
geoJson.append("\",\"");
geoJson.append("order");
geoJson.append("\":\"");
geoJson.append(order);
geoJson.append(questPriority(quest));
geoJson.append("\"}}");
}
}
Expand Down