Repository navigation
Conversation
GetUTF8CharBufferFromStringIndex sized its buffer at exactly 3 bytes
per character and passed size - 2 as the toUtf capacity. toUtf stops
once (count - 1) bytes are used, so that was too small to hold the
whole string:
- a 1-character name came back empty (size 3, count 1),
- names of 3-byte characters lost their last character
("中文" became "中"),
- an empty string made an empty vector, so count was size_t(-2) and
toUtf wrote the terminator through its null data() pointer, which
ImGui then read as the label.
Add 3 bytes so the last character always fits and the buffer is never
empty. Checked with a host model of toUtf's loop over "", "A", "Ab",
"Andariel", "é", "中" and "中文": all now convert in full.
The unit spawner only offered a combo box of names, so getting to a given monstats or superuniques row meant scrolling through hundreds of entries, and rows that share a display name (many monsters are just "Fallen" or "Zombie") could not be told apart. - Show "<id>: <name>" in both combo boxes. - Add an id input under each spawner that selects the row directly, clamped to the table's record count. Covers the "SuperUnique monster by id" and "Normal monster by id" items of ThePhrozenKeep#113. The project only builds with 32-bit MSVC, which this machine does not have; the new helpers were compiled with g++ -Wall -Wextra against a stub ImGui::InputInt and checked for the label text and the clamping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small debugger changes, one commit each.
Spawn by id (#113). The unit spawner only had a combo box of names, so reaching a given monstats or superuniques row meant scrolling through hundreds of entries, and rows that share a name (lots of "Fallen", "Zombie", ...) couldn't be told apart.
<id>: <name>.This covers the "SuperUnique monster by id" and "Normal monster by id" items in #113.
Truncated names.
GetUTF8CharBufferFromStringIndexsized its buffer at exactly 3 bytes per character and passedsize - 2totoUtf, which stops oncecount - 1bytes are used. So:中文became中),size_t(-2)andtoUtfwrote its terminator through the nulldata()pointer.The buffer now has 3 extra bytes, enough for the last character and never empty.
I can't build the project here (no 32-bit MSVC), so I checked both parts outside it: the new helpers compile with
g++ -Wall -Wextraagainst a stubImGui::InputIntand give the expected labels and clamping. A host model oftoUtf's loop converts"","A","Ab","Andariel","é","中"and"中文"in full with the new size, and reproduces all three problems with the old one.Refs #113