• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[vJASS] [PSA] MyBoard (bowser499) minor bug

Status
Not open for further replies.

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,547
Hey y'all,

Just debugged a silly problem in my map, which I was ready to chalk up to 1.31.x problemos.

Myboard (link: [PROTOTYPE] myBoard) has some code that looks like this:

private constant integer MAX_ROW_COUNT = 100
private constant integer MAX_COLUMN_COUNT = 30

...

method setLocalValue takes player whichPlayer, integer col, integer row, string newValue returns nothing
local integer arrIndex = MAX_COLUMN_COUNT*col + row

if GetLocalPlayer() == whichPlayer then
set .curValue[arrIndex] = newValue
endif

call MultiboardSetItemValue(.brdItem[arrIndex],.curValue[arrIndex])
endmethod

You can trivially see that if you set MAX_COLUMN_COUNT to 2, and MAX_ROW_COUNT to 3, then cells (2, 1) and (1, 2) resolve to the same element.

Indeed, the provided default script with 100 and 30 is bugged.

Solution: always use a max colcount that is at least 1 greater than your max rowcount.

THBAPSA
 
Status
Not open for further replies.
Top