Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ======================================================
- CvBuildingInfo::getPrereqOrBonuses()
- ======================================================
- int CvBuildingInfo::getPrereqOrBonuses(int i) const
- {
- FAssertMsg(i < GC.getNUM_BUILDING_PREREQ_OR_BONUSES(), "Index out of bounds");
- if (m_piPrereqOrBonuses)
- {
- int size = m_piPrereqOrBonuses[0];
- if (i == -1) return size;
- if (i < size) return m_piPrereqOrBonuses[i+1];
- return -1;
- }
- return -1;
- }
- ======================================================
- CvBuildingInfo::getCheckSum()
- ======================================================
- if (m_piPrereqOrBonuses) CheckSumI(iSum, m_piPrereqOrBonuses[0]+1, m_piPrereqOrBonuses);
- ======================================================
- CvBuildingInfo::read()
- ======================================================
- if (pXML->TryMoveToXmlFirstChild(L"PrereqBonuses"))
- {
- iNumChildren = pXML->GetXmlChildrenNumber();
- FAssertMsg((iNumChildren <= GC.getNUM_BUILDING_PREREQ_OR_BONUSES()),"Too many Prereq Or Bonuses for the building.");
- int *tmp = new int[iNumChildren];
- int iTotal = 0;
- if (0 < iNumChildren)
- {
- if (pXML->GetChildXmlVal(szTextVal))
- {
- for (j=0; j<iNumChildren; j++)
- {
- int eInfo = pXML->GetInfoClass(szTextVal);
- if (eInfo != -1) tmp[iTotal++] = eInfo;
- if (!pXML->GetNextXmlVal(szTextVal)) break;
- }
- if (iTotal != 0)
- {
- m_piPrereqOrBonuses = new int[iTotal+1];
- m_piPrereqOrBonuses[0] = iTotal;
- for (j=0; j<iTotal; j++) m_piPrereqOrBonuses[j+1] = tmp[j];
- }
- pXML->MoveToXmlParent();
- }
- }
- else SAFE_DELETE_ARRAY(m_piPrereqOrBonuses);
- pXML->MoveToXmlParent();
- }
- else SAFE_DELETE_ARRAY(m_piPrereqOrBonuses);
- ======================================================
- CvBuildingInfo::CopyNonDefaults()
- ======================================================
- int iTotalTheirs = pClassInfo->getPrereqOrBonuses(-1);
- if (iTotalTheirs != -1)
- {
- int iTotalOurs = 0;
- if (m_piPrereqOrBonuses) iTotalOurs = m_piPrereqOrBonuses[0];
- int* tmp = new int[iTotalTheirs+iTotalOurs+1];
- tmp[0] = iTotalTheirs+iTotalOurs;
- for (int j=0; j<iTotalTheirs; j++)
- tmp[j+1] = pClassInfo->getPrereqOrBonuses(j);
- for (int j=0; j<iTotalOurs; j++)
- tmp[j+iTotalTheirs+1] = m_piPrereqOrBonuses[j+1];
- m_piPrereqOrBonuses = tmp;
- }
- ======================================================
- CvCity::CanConstructInternal()
- This modification applies in four other places:
- CvGameTextMgr::buildBuildingRequiresString(),
- CvPlayer::recalculateResourceConsumption(),
- CvPlayerAI::AI_bonusTrade(), and
- CvPlayerAI::AI_baseBonusVal().
- ======================================================
- for (iI = 0; iI < kBuilding.getPrereqOrBonuses(-1); iI++) // was "iI < GC.getNUM_BUILDING_PREREQ_OR_BONUSES()"
- {
- if (kBuilding.getPrereqOrBonuses(iI) != NO_BONUS)
- {
- bRequiresBonus = true;
- if (hasBonus((BonusTypes)kBuilding.getPrereqOrBonuses(iI)))
- {
- bNeedsBonus = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment