1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

* ubuntux's patch (vcmi_fix_res2)

This commit is contained in:
mateuszb 2009-04-22 07:46:27 +00:00
parent 35f63bdc5f
commit e88ba16ffa

View File

@ -2502,11 +2502,13 @@ void CGameHandler::handleTimeEvents()
{ {
if(ev->resources[i]) //if resource is changed, we add it to the dialog if(ev->resources[i]) //if resource is changed, we add it to the dialog
{ {
// If removing too much ressources, adjust the
// amount so the total doesn't become negative.
if (sr.res[i] + ev->resources[i] < 0)
ev->resources[i] = -sr.res[i];
iw.components.push_back(Component(Component::RESOURCE,i,ev->resources[i],0)); iw.components.push_back(Component(Component::RESOURCE,i,ev->resources[i],0));
sr.res[i] += ev->resources[i]; sr.res[i] += ev->resources[i];
// Don't let resources becoming negative
if (sr.res[i] < 0)
sr.res[i] = 0;
} }
} }
if (iw.components.size()) if (iw.components.size())