• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

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

Status
Not open for further replies.
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