[Bug]: An initiative list with no current entry logs an error on every change

Open Beginner friendly
#6,251 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@dwizard0 is already working on this.

Since Nov 14, 2026.

  • #6252 by @dwizard0 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
game-dev

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
  1. Add a few tokens to the initiative list of a map, without starting a round.
  2. Let the campaign autosave, or start a server with it.
  3. The log has one getTokenInitiative: index = -1 error 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RPTools/maptool

All issues in RPTools/maptool

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.