Bugfix for cheating when the harvest command type has changed to a different command. Got this from Silnarm.

This commit is contained in:
Mark Vejvoda 2010-04-06 03:28:20 +00:00
parent ec7e741ad3
commit d38a1f8877
1 changed files with 38 additions and 0 deletions

View File

@ -443,6 +443,8 @@ void UnitUpdater::updateHarvest(Unit *unit){
//if working
SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getTargetPos()));
Resource *r= sc->getResource();
/*
if(r!=NULL){
//if there is a resource, continue working, until loaded
unit->update2();
@ -467,6 +469,42 @@ void UnitUpdater::updateHarvest(Unit *unit){
//if there is no resource, just stop
unit->setCurrSkill(hct->getStopLoadedSkillType());
}
*/
if (r != NULL) {
// Fix from Silnarm to disable cheating - START
if (!hct->canHarvest(r->getType()) || r->getType() != unit->getLoadType()) {
// hct has changed to a different harvest command.
unit->setCurrSkill(hct->getStopLoadedSkillType()); // this is actually the wrong animation
unit->getPath()->clear();
return;
}
// Fix from Silnarm to disable cheating - END
// if there is a resource, continue working, until loaded
unit->update2();
if (unit->getProgress2() >= hct->getHitsPerUnit()) {
if (unit->getLoadCount() < hct->getMaxLoad()) {
unit->setProgress2(0);
unit->setLoadCount(unit->getLoadCount() + 1);
//if resource exausted, then delete it and stop
if (r->decAmount(1)) {
sc->deleteResource();
unit->setCurrSkill(hct->getStopLoadedSkillType());
}
}
if (unit->getLoadCount() >= hct->getMaxLoad()) {
unit->setCurrSkill(hct->getStopLoadedSkillType());
unit->getPath()->clear();
}
}
}
else{
//if there is no resource, just stop
unit->setCurrSkill(hct->getStopLoadedSkillType());
}
}
}