Bureaubert's crash http://www.apolyton.net/forums/showt...93#post4346793
Code:
0x0047ffa3 [?GetMinPrerequisites@Advances@@QBEJJJ@Z + 0x6] 0x00480049 [?GetMinPrerequisites@Advances@@QBEJJJ@Z + 0xac] 0x004ce35a [?ChooseType@GoodyHut@@AAE?AW4GOODY@@ABJ@Z + 0x177] 0x004ce5f8 [?OpenGoody@GoodyHut@@QAEXABJABVMapPoint@@@Z + 0x33] 0x00492eb2 [?CheckTerrainEvents@ArmyData@@QAEXXZ + 0x60]
Code:
//----------------------------------------------------------------------------
//
// Name : Advances::GetMinPrerequisites
//
// Description: Get the number of missing steps to get to an advance
//
// Parameters : adv : the advance to get to
// limit : when to stop counting and report it as too advanced
//
// Globals : g_theAdvanceDB
//
// Returns : sint32 : the number of missing prerequisite steps
//
// Remark(s) : - When you already have the advance, the returned value is 0.
// - When you have all prerequisites for the advance, but do not
// have the advance itself, the returned value is 1.
// - When you are missing prerequisites for the advance, the
// returned value is the sum of the recursive application of
// this function to the missing prerequisites.
// - When the limit is reached, the returned value is unspecified,
// but always larger than the limit.
//
//----------------------------------------------------------------------------
sint32 Advances::GetMinPrerequisites(sint32 adv, sint32 limit) const
{
if (m_hasAdvance[adv])
{
return 0;
}
AdvanceRecord const * rec = g_theAdvanceDB->Get(adv);
sint32 totalneeded = 0;
for (sint32 prereq = 0; prereq < rec->GetNumPrerequisites(); ++prereq)
{
if ((rec->GetIndex() != rec->GetPrerequisitesIndex(prereq)) &&
!m_hasAdvance[rec->GetPrerequisitesIndex(prereq)]
)
{
totalneeded +=
GetMinPrerequisites(rec->GetPrerequisitesIndex(prereq), limit - 1);
if (totalneeded > limit)
{
return totalneeded;
}
}
}
return totalneeded + 1;
}
Code:
case GOODY_ADVANCE:
{
Advances const * advances = g_player[owner]->m_advances;
AdvanceType * possible =
new AdvanceType[g_theAdvanceDB->NumRecords()];
size_t nextPossible = 0;
sint32 const maxNovelty = risk.GetMaxAdvanceLeap();
for (AdvanceType i = 0; i < g_theAdvanceDB->NumRecords(); ++i)
{
if (advances->HasAdvance(i))
continue; // known
if (g_theAdvanceDB->Get(i)->GetGoodyHutExcluded())
continue; // EMOD new flag to prevent some unts from appearing
if ((g_theAdvanceDB->Get(i)->GetNumPrerequisites() > 0) &&
(g_theAdvanceDB->Get(i)->GetPrerequisitesIndex(0) == i)
)
continue; // undiscoverable
if (advances->GetMinPrerequisites(i, maxNovelty) <= maxNovelty)
{
possible[nextPossible++] = i;
// else: too advanced
}
if (nextPossible)
{
m_value = possible[(nextPossible * m_value) / k_VALUE_RANGE];
}
else
{
result = GOODY_BOGUS;
}
delete [] possible;
}
break;

Comment