So you're just trying to fix the bug where they build something (such as a command center) and mine, say, 24 minerals, so instead of converting those 4 mineral chunks to 4, they go to 24?
Well, what I meant was something much more common...
When you build a building, and return a mineral at the same time, it doesn't detect the minerals returned because you actually lost money.
We were trying to fix the same thing when you cancels a building but what you're saying is true and you'll get you 24 minerals because they actually decreased. Well, it is another bug...
1. My system in V2 allows for them to return mins at the same time because it returns them 25 at a time. Therefore, they can return up to 3 chunks at the same time as they cancel something, and the system won't screw up.
But there is another bug in your system:
This way if you get amount of minerals from refund not multiply 25 you'll count rest of them as like they have been harvested
For example if you cancel Zerg Extractor than you'll get 38 (or 37, dont know cause 50*75%=37.5) minerals back, then you'll substract 25 and detect the rest 13 minerals as like they were harvested... And even more, canceling Engeneering Bay (125 minerals) will count as 19 harvested minerals. Then just imagine you tripple them...
One thing that may be worth looking into is the constructing score.
If you could somehow match how many points you got from constructing something, then when the score went up, you could fix your money accordingly.
2. I don't beleive there is a constructing score. There is one post game, but that cannot, like kills, be detected or changed, either way, you could just as easily detect minerals being spent, compare that to how long it takes to do something of the same cost, then forget about it, but that's way too complex.
Dude you're wrong there actually is constructing score which you can detect and change and do with it whenever you like. It is Buildings score. I'm curious when those score are actually added, when you start build, when you finished or during the construction? If the score is added at start (and before or along with minerals substraction) then, first of all, you can fix the bug which Lethal_Illusion mentioned (when you starts building), and if that score is returned in the same amount when you cancel a building then you can fix the second bug... You should not even remember all history of building you just watching for Buildings Score changes. It seems very interesting... But there is another problem, could you cancel multiply buildings at once?
3. You cannot detect half-built buildings, units, or half researched upgrades.
You can detect half built buildings. I'll break the map tomorrow.
It is easy to do since locations are centered on half-built buildings as like they have already been built but they dont detected by Bring condition. It is very similiar to hallucination detection. But this seems to be a little bit complex...
Either way, I think the current system works fine as is. Feel free to try and confuse it.
I am thinking exaclty the same way and asking again is all these worth it?..
Unfortunately Buildings Score is added AFTER the building is finished.
There are two problems with half-built buildings detection.
First of all we have to somehow cycle through them to detect the same second half-built building. And the only solution I see is giving them to the other player which in the best case would make blinking making it hard to cancel the construction and in the worst case you'll need an extra player for each player running this detection in order not to shuffle buildings between players. Of course you can cycle through first player's buildings then trough second's and so on one after another but this would decrease productivity which is very important when detecting minerals.
The second problem is productivity. Each moment the location is on the single building and when you cancel a building you'll have to wait when the location moves to it to detect, but minerals are not waiting. And more buildings are being built at the same time more likely you dont detect building refund (or built on the other hand) in time. Of cource you can use multiplie locations but first it would complicate the issue and second you never know how many buildings the player would be actually building at once.
Thats why I think this method is not appliable in our case.