Here is where mineral concentrations are reduced. I haven't looked through what you've done and compared it to what this routine does to see how similar or different they are.
void Planet::Mine(long mines, const Player * miner)
{
if (mines == 0)
return;
long rate;
if (GetOwner() == NULL)
rate = 10;
else
rate = GetOwner()->MineRate();
for (long mineral = 0; mineral < Rules::MaxMinType; ++mineral) {
long conc;
if (mHomeWorld && miner == GetOwner())
conc = max(mMinConc[mineral], Rules::GetConstant("MineralHWMinimum"));
else
conc = mMinConc[mineral];
mContains[mineral] += (conc * mines * rate + 500) / 10 / 100;
mMinMined[mineral] += mines;
long minesper = Rules::GetConstant("MineralDecayFactor") / mMinConc[mineral] / mMinConc[mineral];
if (mMinMined[mineral] > minesper) {
mMinConc[mineral] -= mMinMined[mineral] / minesper;
if (mMinConc[mineral] < Rules::GetConstant("MineralMinimum"))
mMinConc[mineral] = Rules::GetConstant("MineralMinimum");
mMinMined[mineral] %= minesper;
}
}
}