Not logged inOpenClonk Forum
Up Topic Patch: Fix double MatCount update when using ClearFreeRect

This board is threaded (i.e. has a tree structure). Please use the Reply button of the specific post you are referring to, not just any random button. If you want to reply to the topic in general, use the Post button near the top and bottom of the page.

Post Reply
In Response to Jan
- 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.

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill