Flawed label structure

All and any discussion and development of the Mudlet Mapper.
Post Reply
User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Flawed label structure

Post by chris »

After looking more into labels, I realized the code is flawed. The label id corresponds to the size of the array of labels an area has. So for instance, we make 3 labels, each with the id of 1,2,3.

Now we delete label 1, given 2 label ids:2,3.

The next call to create a label will do this: it will return the next label id as 2, the size of the array, and thus overwrite the old label 2 with the new label 2. Additionally, since this is a QMap which has a unique key->value, this will prevent any new labels from being added to the area.

Conveniently, this fixes this:
Code: [show] | [select all] lua
while (mapLabels[area].contains(labelID))
            labelID++;

Post Reply