Aussie_Lurker
Deity
Well, the percentage thing was just an accident on my part-hope to fix that when I get a few minutes spare .
Aussie.
Aussie.
I can call the same function multiple times from mulitiple places, and it won't cause any kind of cross-ref errors, cause the system takes care of nesting the called function within the root function... yeesh, I can be thicke.
I would suspect that when declaring it in the *.h files, all that is REALLY important is what kind of variable is used in that spot.
m_piPrereqOrTechs(NULL),
m_piPrereqAndTechs(NULL),
[COLOR="DarkOrange"]m_piFutureYieldArray(NULL);[/COLOR]
m_pbCommerceFlexible(NULL),
m_pbTerrainTrade(NULL)
int CvTechInfo::getPrereqAndTechs(int i) const
{
return m_piPrereqAndTechs ? m_piPrereqAndTechs[i] : -1;
}
[COLOR="darkorange"]int CvTechInfo::getFutureYieldArray(int i) const
{
return m_piFutureYieldArray ? m_piFutureYieldArray[i] : -1;
}[/COLOR]
bool CvTechInfo::isCommerceFlexible(int i) const
SAFE_DELETE_ARRAY(m_piPrereqAndTechs);
m_piPrereqAndTechs = new int[GC.getNUM_AND_TECH_PREREQS()];
stream->Read(GC.getNUM_AND_TECH_PREREQS(), m_piPrereqAndTechs);
[COLOR="darkorange"] SAFE_DELETE_ARRAY(m_piFutureYieldArray);
m_piFutureYieldArray = new int[GC.getNUM_AND_TECH_PREREQS()];
stream->Read(GC.getNUM_AND_TECH_PREREQS(), m_piFutureYieldArray);[/COLOR]
SAFE_DELETE_ARRAY(m_pbCommerceFlexible);
stream->Write(GC.getNUM_AND_TECH_PREREQS(), m_piPrereqAndTechs);
[COLOR="darkorange"] stream->Write(GC.getNUM_AND_TECH_PREREQS(), m_piFutureYieldArray);[/COLOR]
stream->Write(NUM_COMMERCE_TYPES, m_pbCommerceFlexible);
else
{
pXML->InitList(&m_pbCommerceFlexible, NUM_COMMERCE_TYPES);
}
[COLOR="darkorange"]
pXML->SetVariableListTagPair(&m_piFutureYieldArray, "FutureYields", sizeof(GC.getDomainInfo((DomainTypes)0)), NUM_DOMAIN_TYPES);[/COLOR]
pXML->SetVariableListTagPair(&m_piDomainExtraMoves, "DomainExtraMoves", sizeof(GC.getDomainInfo((DomainTypes)0)), NUM_DOMAIN_TYPES);
You can what??? I would've thought that a recursive function would cause an endless loop...
def factorial(n):
if n <= 1:
# 1! and 0! are both 1, anything negative just gets 1 too
return 1
else:
return n * factorial(n - 1)
Specifically I'm confused about the last three entries. I'm not all sure about them.
int CvTechInfo::getFutureYieldArray() const
{
return m_piFutureYieldArray;
}
int CvTechInfo::getFutureYield(int i) const
{
FAssertMsg(i < NUM_YIELD_TYPES, "Index out of bounds");
FAssertMsg(i > -1, "Index out of bounds");
return m_piFutureYieldArray ? m_piFutureYieldArray[eIndex] : -1;
}
SAFE_DELETE_ARRAY(m_piFutureYieldArray);
m_piFutureYieldArray = new int[NUM_YIELD_TYPES];
stream->Read(NUM_YIELD_TYPES, m_piFutureYieldArray);
stream->Write(NUM_YIELD_TYPES, m_piFutureYieldArray);
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(), "FutureYields"))
{
pXML->SetYields(&m_piFutureYieldArray);
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
else
{
pXML->InitList(&m_piFutureYieldArray, NUM_YIELD_TYPES);
}
Here is my code from CGTM.cpp:CvGameTextMgr.cpp|4942|error C2660: 'CvTechInfo::getYieldChange' : function does not take 0 arguments|
setYieldChangeHelp(szBuffer, L"", L"", gDLL->getText("TXT_KEY_TECH_FUTURE_YIELD_CHANGE").GetCString(), GC.getTechInfo(eTech).getYieldChange(), false, true);
I down' have to fiddle with anything else in the SDK to have the extra Yields output show in the Raw Yields display, I can do it through Python.
m_aiYieldChange = new int[NUM_YIELD_TYPES];
...
SAFE_DELETE_ARRAY(m_aiYieldChange );
...
m_aiYieldChange[iI] = 0;
...
int CvPlayer::getYieldChange(YieldTypes eIndex) const
{
FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");
FAssertMsg(eIndex < NUM_YIELD_TYPES, "eIndex is expected to be within maximum bounds (invalid Index)");
return m_aiYieldChange[eIndex];
}
void CvPlayer::changeYieldChange(YieldTypes eIndex, int iChange)
{
FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");
FAssertMsg(eIndex < NUM_YIELD_TYPES, "eIndex is expected to be within maximum bounds (invalid Index)");
if (iChange != 0)
{
m_aiYieldChange[eIndex] = (m_aiYieldChange[eIndex] + iChange);
CvCity* pLoopCity;
int iLoop;
for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
{
pLoopCity->changeBaseYieldRate(eIndex, iChange);
pLoopCity->AI_setAssignWorkDirty(true);
}
invalidateYieldRankCache(eIndex);
}
}
...
pStream->Read(NUM_YIELD_TYPES, m_aiYieldChange);
...
pStream->Write(NUM_YIELD_TYPES, m_aiYieldChange);
New question: I tried compiling, and received this error from CGTM.cpp:
. . . GC.getTechInfo(eTech).getYieldChange[B][COLOR="YellowGreen"]Array[/COLOR][/B](), . . .
As for the error code, I don't actually have any declarations of getYieldChangeArray.
int CvTechInfo::getYieldChange(int i) const
{
return m_piYieldChange
}
int CvTechInfo::getYieldChange[B][COLOR="YellowGreen"]Array[/COLOR][/B]([s][COLOR="Red"]int i[/COLOR][/s]) const
{
return m_piYieldChange
}
int getYieldChangeArray const;
int getYieldChangeArray[COLOR="Red"];[/COLOR] const
for this line:CvGameTextMgr.cpp|4942|error C2064: term does not evaluate to a function taking 0 arguments|
setYieldChangeHelp(szBuffer, L"", L"", gDLL->getText("TXT_KEY_TECH_FUTURE_YIELD_CHANGE").GetCString(), GC.getTechInfo(eTech).getYieldChangeArray(), false, true);
My bad. I posted the code in post 108, but it's named CvTechInfo::getFutureYieldArray() there. You made an error when putting it into CvInfos.cpp:
Code:int CvTechInfo::getYieldChange(int i) const { return m_piYieldChange }
This should read
Code:int CvTechInfo::getYieldChange[B][COLOR="YellowGreen"]Array[/COLOR][/B]([s][COLOR="Red"]int i[/COLOR][/s]) const { return m_piYieldChange }
int[COLOR="DeepSkyBlue"]*[/COLOR] CvTechInfo::getYieldChangeArray() const
{
return m_piYieldChange[COLOR="#00bfff"];[/COLOR]
}
OK EF, made the change to void CvPlayer::changeYieldChange in CvPLayer.cpp (everything else you listed in that codeset in post #115 was as-is), and changed the line in CGTM to say getYieldChangeArray. Also, I completed the change you proposed from post #117.
But, I'm a bit confused. Do I really have to have just one of my variables actually named "Array"? Is that really necessary to the program? Doesn't it just see a text string, and only know what to do with that based on what code I write around it, not the contents of the string itself? And, there's the fact that now, the only thing calling getYieldChangeArray is CGTM.
Also, when I tried compiling, I received two errors. The first, would not allow me to proceed until I had changedin CvInfos.h toCode:int getYieldChangeArray const;
I don't know why I would need to move the ";" to before the const, but that's what CodeBlocks wanted.Code:int getYieldChangeArray[COLOR="Red"];[/COLOR] const
Once that was done, I got this error: for this line:Code:setYieldChangeHelp(szBuffer, L"", L"", gDLL->getText("TXT_KEY_TECH_FUTURE_YIELD_CHANGE").GetCString(), GC.getTechInfo(eTech).getYieldChangeArray(), false, true);
... help...?
int getYieldChangeArray const;
int getYieldChangeArray[COLOR="#00bfff"]()[/COLOR] const;
setYieldChangeHelp(szBuffer, L"", L"", gDLL->getText("TXT_KEY_TECH_FUTURE_YIELD_CHANGE").GetCString(), GC.getTechInfo(eTech).getYieldChangeArray(), false, true);
CvGameTextMgr.cpp|4942|error C2664: 'CvGameTextMgr::setYieldChangeHelp' : cannot convert parameter 5 from 'int' to 'const int *'|