Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / Patch: Fix double MatCount update when using ClearFreeRect
- - By Jan Date 2019-07-06 10:07
A patch that temporarily removed solid masks when using ClearFreeRect accidentally removed the pixels twice from the MatCount array.

I hereby license the file 0001-Fix-double-MatCount-update-when-usi.patch under the CC-BY license
Parent - - By Caesar [jp] Date 2019-07-20 08:56
I'd like to test the patch but it's the first time I'm hearing about this problem.

Is there a good test case, way to reproduce it, or at least a related bug tracker entry?

(Looking at the patch with my naive eyes makes it seem like the pixels are not removed from the MatCount at all now, but it's hard to tell if you can't see it moving.)
Parent - - By Jan Date 2019-07-21 18:07 Edited 2019-07-21 19:31
- Start Gold Rush
- Run /script GetMaterialCount(Material("Gold"))
- The output is a positive, non-zero integer
- Run /script ClearFreeRect(0, 0, LandscapeWidth(), LandscapeHeight())
- Run /script GetMaterialCount(Material("Gold"))
- The expected output is 0, but the actual output is the same as the output of the first call but with a negative sign

The commit that introduced the bug is https://github.com/openclonk/openclonk/commit/e8a90e7d23735eb7ac09ddd8c466ac987cb1fba6
ClearFreeRect calls _SetPix2 (ClearFreeRect -> ClearPix -> SetPix2 -> _SetPix2) and _SetPix2 updates MatCount. PrepareChange/FinishChange then update MatCount again by calling UpdateMatCnt(), which results in the pixels being removed from MatCount twice.
Parent - By Caesar [jp] Date 2019-07-27 15:26
I should probably test this a bit more thoroughly, but oh well.
https://github.com/openclonk/openclonk/commit/804bbf9fdbe9d0ba92171cb27d4081fb91b9893d
Up Topic Development / Developer's Corner / Patch: Fix double MatCount update when using ClearFreeRect

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill