[Bug]: An initiative list with no current entry logs an error on every change
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
Start in the InitiativeList class, where insertToken, remove, move and sort each call getTokenInitiative(getCurrent()), and in getTokenInitiative itself, which logs any out-of-range index as an error. Reproduce by building a list with entries and no current entry, then copying a map and checking the log. Done when a list with no current entry produces no error log and the other operations still behave the same.
Written by the indexing model from the issue text.
Description
Describe the Bug
InitiativeList logs an error whenever an entry is inserted, removed, moved or the list is sorted while no entry has the initiative:
ERROR ... getTokenInitiative: index = -1, size = 0
Each of those methods saves the current entry first with getTokenInitiative(getCurrent()). With no current entry, getCurrent() is -1, and getTokenInitiative logs any out-of-range index as an error. But no current entry is the normal state of a new or emptied list, and of any list before someone starts a round.
It happens a lot more than adding tokens by hand would suggest, because copying a map rebuilds its initiative list one insertToken at a time. A campaign copy is made for every autosave, and when a server starts, so a map with initiative entries and no current one logs one error per entry each time. My dedicated server logged it 933 times before I worked around it.
Nothing else goes wrong: the methods treat the null as "no current entry" correctly. It's only the log.
To Reproduce
- Add a few tokens to the initiative list of a map, without starting a round.
- Let the campaign autosave, or start a server with it.
- The log has one
getTokenInitiative: index = -1error per entry.
Expected Behaviour
No error. "No entry has the initiative" isn't an error.
MapTool Info
develop (445f76a1d)
Desktop
Ubuntu 24.04 LTS
- Dominant language
- Java
- Stars
- 927
- Forks
- 286
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 94
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RPTools/maptool
-
[Maintenance]: Migrate gradle dependency submission to modern alternativePossibly taken @VelpulaGangavardhan claimed this 18 days ago. Opencode-maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
RPTools/maptool#6156 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
code-maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
RPTools/maptool#5722 · 2 comments ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
finos/fluxnova-bpm-platform#387 ·
Maintainers usually reply within 4 days
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 Under an hour Newbie friendliness 84/100
cpp-best-practices/project_validator#251 ·
Maintainers usually reply within 1 day
-
backend enhancement
Difficulty 2/5 Half a day Newbie friendliness 70/100
damodharg6/payledger#16 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day