The discount calculation is wrong in glest 2.0.1: instead of restoring original unit's used resource, it restores the new unit's (which makes the new unit free)
Below is the patch
--- /home/aqd/apps/glest/g/source/glest_game/type_instances/unit.cpp 2007-09-17 07:34:26.000000000 +0800
+++ source/glest_game/type_instances/unit.cpp 2007-09-16 19:47:05.000000000 +0800
@@ -798,6 +798,7 @@
bool Unit::morph(const MorphCommandType *mct){
const UnitType *morphUnitType= mct->getMorphUnit();
+ const UnitType *origUnitType= type;
if(map->isFreeCellsOrHasUnit(pos, morphUnitType->getSize(), currField, this)){
map->clearUnitCells(this, pos);
@@ -805,9 +806,12 @@
hp+= morphUnitType->getMaxHp() - type->getMaxHp();
type= morphUnitType;
level= NULL;
+ if(getType()->getField(fAir)) currField=fAir;
+ if(getType()->getField(fLand)) currField=fLand;
computeTotalUpgrade();
+ ep= type->getTotalMaxEp(&totalUpgrade);
map->putUnitCells(this, pos);
- faction->applyDiscount(morphUnitType, mct->getDiscount());
+ faction->applyDiscount(origUnitType, mct->getDiscount());
return true;
}
else{