I'm adding a feature to allow obsolete units to rush construction of their upgrades, using the same xml tags as the Great Engineer. the new code is in CvUnit::canHurry and it works:
the mission button displays properly and is greyed-out in the proper cases but I cannot get the text tooltip to follow. here is the code from CvDLLWidgetData:
arseActionHelp:
my first problem was using GC.getInfoTypeForString("UNIT_ENGINEER"). it compiled but caused an unidentified C++ exception when the unit was selected.
I tried another version using the "if (pSelectedUnit->canHurry(pMissionPlot, true))" statement as the deciding factor:
but it seemed to answer that "canHurry" call incorrectly:
the button says no but the text says yes
can anyone help?
Spoiler :
Code:
bool CvUnit::canHurry(const CvPlot* pPlot, bool bTestVisible) const
{
if (isDelayedDeath())
{
return false;
}
CvCity* pCity;
if (getHurryProduction(pPlot) == 0)
{
return false;
}
pCity = pPlot->getPlotCity();
if (pCity == NULL)
{
return false;
}
if (pCity->getProductionTurnsLeft() == 1)
{
return false;
}
if (!bTestVisible)
{
if (getUnitType() == GC.getInfoTypeForString("UNIT_ENGINEER"))
{
if (!(pCity->isProductionBuilding()))
{
return false;
}
}
[COLOR="Red"]// srpt unit retrain[/COLOR]
else
{
if (!(pCity->isProductionUnit()))
{
return false;
}
UnitTypes eProductionUnit = pCity->getProductionUnit();
if (eProductionUnit != NULL)
{
bool bUpgrade = canUpgrade(eProductionUnit, true);
if (!(bUpgrade))
{
return false;
}
}
}
[COLOR="Red"]//srpt end[/COLOR]
}
return true;
}
the mission button displays properly and is greyed-out in the proper cases but I cannot get the text tooltip to follow. here is the code from CvDLLWidgetData:

Spoiler :
Code:
else if (GC.getActionInfo(widgetDataStruct.m_iData1).getMissionType() == MISSION_HURRY)
{
if (pMissionCity != NULL)
{
if (!(pMissionCity->isProductionBuilding()))
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_ACTION_BUILDING_HURRY"));
}
else
{
pSelectedUnitNode = gDLL->getInterfaceIFace()->headSelectionListNode();
while (pSelectedUnitNode != NULL)
{
pSelectedUnit = ::getUnit(pSelectedUnitNode->m_data);
if (pSelectedUnit->canHurry(pMissionPlot, true))
{
const wchar* pcKey = NULL;
if (NO_PROJECT != pMissionCity->getProductionProject())
{
pcKey = GC.getProjectInfo(pMissionCity->getProductionProject()).getTextKeyWide();
}
else if (NO_BUILDING != pMissionCity->getProductionBuilding())
{
pcKey = GC.getBuildingInfo(pMissionCity->getProductionBuilding()).getTextKeyWide();
}
else if (NO_UNIT != pMissionCity->getProductionUnit())
{
pcKey = GC.getUnitInfo(pMissionCity->getProductionUnit()).getTextKeyWide();
}
if (NULL != pcKey && pSelectedUnit->getHurryProduction(pMissionPlot) >= pMissionCity->productionLeft())
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_ACTION_FINISH_CONSTRUCTION", pcKey));
}
else
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_ACTION_EXTRA_CONSTRUCTION", pSelectedUnit->getHurryProduction(pMissionPlot), pcKey));
}
break;
}
pSelectedUnitNode = gDLL->getInterfaceIFace()->nextSelectionListNode(pSelectedUnitNode);
}
}
}
}
my first problem was using GC.getInfoTypeForString("UNIT_ENGINEER"). it compiled but caused an unidentified C++ exception when the unit was selected.
I tried another version using the "if (pSelectedUnit->canHurry(pMissionPlot, true))" statement as the deciding factor:
Spoiler :
Code:
else if (GC.getActionInfo(widgetDataStruct.m_iData1).getMissionType() == MISSION_HURRY)
{
if (pMissionCity != NULL)
{
pSelectedUnitNode = gDLL->getInterfaceIFace()->headSelectionListNode();
while (pSelectedUnitNode != NULL)
{
pSelectedUnit = ::getUnit(pSelectedUnitNode->m_data);
[COLOR="Red"]if (pSelectedUnit->canHurry(pMissionPlot, true))[/COLOR]
{
const wchar* pcKey = NULL;
if (NO_PROJECT != pMissionCity->getProductionProject())
{
pcKey = GC.getProjectInfo(pMissionCity->getProductionProject()).getTextKeyWide();
}
else if (NO_BUILDING != pMissionCity->getProductionBuilding())
{
pcKey = GC.getBuildingInfo(pMissionCity->getProductionBuilding()).getTextKeyWide();
}
else if (NO_UNIT != pMissionCity->getProductionUnit())
{
pcKey = GC.getUnitInfo(pMissionCity->getProductionUnit()).getTextKeyWide();
}
if (NULL != pcKey && pSelectedUnit->getHurryProduction(pMissionPlot) >= pMissionCity->productionLeft())
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_ACTION_FINISH_CONSTRUCTION", pcKey));
}
[COLOR="Red"]else[/COLOR]
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_ACTION_EXTRA_CONSTRUCTION", pSelectedUnit->getHurryProduction(pMissionPlot), pcKey));
}
}
else
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_ACTION_BUILDING_HURRY"));
}
break;
pSelectedUnitNode = gDLL->getInterfaceIFace()->nextSelectionListNode(pSelectedUnitNode);
}
}
}
but it seemed to answer that "canHurry" call incorrectly:
the button says no but the text says yes
can anyone help?