Edouard127 / reddit-placebot-2023

A bot for r/place that doesn't use the api
MIT License
87 stars 15 forks source link

Fix pointer problem (fixes #28) #88

Closed DrMaxNix closed 1 year ago

DrMaxNix commented 1 year ago

This hopefully solves the problem with the wrong colors. (fixes #28)

Cause

The function closestColor() uses the variable c to iterate over all available colors. When it found a color that is closer than the previous best, it sets closestColor to a pointer to c. In the end it returns closestColor which still is a pointer to c. Problem is: c has changed by then and always has the value of the last item in the list of colors that was checked.

Edouard127 commented 1 year ago

I you're right then It's a race condition I would opt in for a mutex instead I'm currently tired and I have an headache so I don't think I could do something right now

Edouard127 commented 1 year ago

d5f8dc5 Please test using this commit

thedankeststorm commented 1 year ago

d5f8dc5 Please test using this commit

Not working. It's still placing wrong colors. I'm using 24-bitmap .bmp file saved from Paint app, unsure if that's the cause or not.