getCulture(ePlayerX) * (1000 - decayPermille) / 1000 could apparently trigger a buffer overflow if the plot culture is around 2,147,483 even though the value is divided by 1000 again.
Reversing the order of operations to divide by 1000 first fixed this, but introduced another problem if the initial culture is lower than that, so we have to make an if else check. I've set the limit for reversing the order to 1 million.
Be aware I haven't tested the created DLL (it compiles fine) since I don't have a savegame for this version where this problem manifests, only for v43.
I have tested a similarly adjusted code for v43, but there have been significant changes to CvPlot.cpp since then, which are incompatible with each other, so this requires evaluation.
getCulture(ePlayerX) * (1000 - decayPermille) / 1000
could apparently trigger a buffer overflow if the plot culture is around 2,147,483 even though the value is divided by 1000 again. Reversing the order of operations to divide by 1000 first fixed this, but introduced another problem if the initial culture is lower than that, so we have to make an if else check. I've set the limit for reversing the order to 1 million.Be aware I haven't tested the created DLL (it compiles fine) since I don't have a savegame for this version where this problem manifests, only for v43. I have tested a similarly adjusted code for v43, but there have been significant changes to CvPlot.cpp since then, which are incompatible with each other, so this requires evaluation.