dungeons-of-moria / umoria

Moria: a roguelike Dungeon Crawler game | Umoria Source Code
https://umoria.org
GNU General Public License v3.0
343 stars 71 forks source link

Elf mage gets an object instead of food when using spell MCA in V5.7.3 64 bit #3

Closed aladdin1404 closed 7 years ago

aladdin1404 commented 7 years ago

This spell works ok in 5.7.0

mrcook commented 7 years ago

Thanks aladdin1404, this bug turns out to be an important lesson in just how much Umoria uses global state.

Here's a short description of the issue (functions given as they are currently named):

In the create_food() function (spells.cpp), I take a copy of the treasureID for the current dungeon tile, but in the original code it was just a reference to that treasureID. This becomes a bug because the dungeonPlaceRandomObjectAt() function changes the treasure id on that tile, and it's that new treasureID that should be used on the next line when the inventoryItemCopyTo() function is called, but I'm still using the old copied value.

I will need to make a good scan through all the code to see if there are similar issues to this. If so, there are probably not too many, but still, I will need to take care on this.

Once I've finished with my current refactoring task I'll fix this bug and make a new release.

Many thanks for your time to make report this. It's greatly appreciated.

mrcook commented 7 years ago

Bug fixed with commit 18d2b17