Bazaar developer reference

CvMinorCivQuest::DoCancelQuest()

Defined in
CvMinorCivAI.cpp, line 1719
Class
CvMinorCivQuest
Hook name
CivHooks::CvMinorCivQuest_DoCancelQuest
Lua events
GameEvents.QuestSendNotification

Hooks

static bool BeforeCvMinorCivQuest_DoCancelQuest(CvMinorCivQuest* self, bool& result);static void AfterCvMinorCivQuest_DoCancelQuest(CvMinorCivQuest* self, bool& result);static bool ReplaceCvMinorCivQuest_DoCancelQuest(bool (*original)(CvMinorCivQuest*), CvMinorCivQuest* self);CivRegisterBefore<CivHooks::CvMinorCivQuest_DoCancelQuest>(host, &BeforeCvMinorCivQuest_DoCancelQuest);CivRegisterAfter<CivHooks::CvMinorCivQuest_DoCancelQuest>(host, &AfterCvMinorCivQuest_DoCancelQuest);CivRegisterReplace<CivHooks::CvMinorCivQuest_DoCancelQuest>(host, &ReplaceCvMinorCivQuest_DoCancelQuest);

Code

1718// Do any cleanup and notifications for when a quest is cancelled (ex. becomes obsolete)1719bool CvMinorCivQuest::DoCancelQuest()1720{1721	if (IsHandled())1722		return false;17231724	SetHandled(true); // We are handling the end of the quest, and this should only happen once17251726	CvPlayer* pMinor = &GET_PLAYER(m_eMinor);17271728	// Why is the quest cancelled?  Will affect which notification message we send1729	bool bRevoked = IsRevoked();1730	bool bExpired = IsExpired();17311732	Localization::String strMessage;1733	Localization::String strSummary;1734	CivsList veNamesToShow;17351736	// If quest was revoked due to bullying, notification is handled elsewhere (to allow condensing)1737	if(bRevoked)1738	{1739	}1740	// If quest expired "naturally", send a notification particular to the expiration conditions of the quest1741	else if(bExpired)1742	{1743#if defined(MOD_EVENTS_QUESTS)1744		if (UseEvents() && !IsInternal()) {1745			if (m_pQuestInfo->isContest()) {1746				veNamesToShow = GetContestLeaders();1747			}17481749			if (!m_pQuestInfo->getCancelMessage().IsEmpty() && !m_pQuestInfo->getCancelSummary().IsEmpty()) {1750				strMessage = Localization::Lookup(m_pQuestInfo->getCancelMessage().c_str());1751				strSummary = Localization::Lookup(m_pQuestInfo->getCancelSummary().c_str());1752			} else {1753				CvString sNames = "";1754				if (veNamesToShow.size() > 0) {1755					sNames = GET_PLAYER(GetMinor()).GetMinorCivAI()->GetNamesListAsString(veNamesToShow);1756				}17571758				if (GET_PLAYER(m_eAssignedPlayer).GetNotifications()) {1759					GAMEEVENTINVOKE_HOOK(GAMEEVENT_QuestSendNotification, m_eAssignedPlayer, m_eMinor, m_eType, GetStartTurn(), GetEndTurn(), m_iData1, m_iData2, false, false, sNames.c_str());1760				}17611762				return true;1763			}1764		} else {1765#endif1766		// City-state wanted us to clear a camp1767		if(m_eType == MINOR_CIV_QUEST_KILL_CAMP)1768		{1769			strMessage = Localization::Lookup("TXT_KEY_NTFN_QUEST_ENDED_KILL_CAMP");1770			strSummary = Localization::Lookup("TXT_KEY_NTFN_QUEST_ENDED_KILL_CAMP_S");1771		}1772		// CONSTRUCT A WONDER1773		else if(m_eType == MINOR_CIV_QUEST_CONSTRUCT_WONDER)1774		{1775			BuildingTypes eWonder = (BuildingTypes) GetPrimaryData();1776			CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eWonder);1777			CvAssertMsg(pkBuildingInfo, "Building info not expected to be FALSE! Please send Anton your save file and version.");1778			if(!pkBuildingInfo) 1779				return false;17801781			const char* strBuildingName = pkBuildingInfo->GetDescriptionKey();17821783			strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_QUEST_ENDED_CONSTRUCT_WONDER");1784			strMessage << strBuildingName;1785			strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_QUEST_ENDED_CONSTRUCT_WONDER");1786			strSummary << strBuildingName;1787		}17881789		// KILL ANOTHER CITY STATE1790		else if(m_eType == MINOR_CIV_QUEST_KILL_CITY_STATE)1791		{1792			PlayerTypes eTargetCityState = (PlayerTypes) GetPrimaryData();17931794			const char* strTargetNameKey = GET_PLAYER(eTargetCityState).getNameKey();17951796			strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_QUEST_ENDED_KILL_CITY_STATE");1797			strMessage << strTargetNameKey;1798			strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_QUEST_ENDED_KILL_CITY_STATE");1799			strSummary << strTargetNameKey;1800		}18011802		// Contest Culture1803		else if(m_eType == MINOR_CIV_QUEST_CONTEST_CULTURE)1804		{1805			strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_QUEST_ENDED_CONTEST_CULTURE");1806			strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_QUEST_ENDED_CONTEST_CULTURE");1807			veNamesToShow = GetContestLeaders();1808		}18091810		// Contest Faith1811		else if(m_eType == MINOR_CIV_QUEST_CONTEST_FAITH)1812		{1813			strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_QUEST_ENDED_CONTEST_FAITH");1814			strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_QUEST_ENDED_CONTEST_FAITH");1815			veNamesToShow = GetContestLeaders();1816		}18171818		// Contest Techs1819		else if(m_eType == MINOR_CIV_QUEST_CONTEST_TECHS)1820		{1821			strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_QUEST_ENDED_CONTEST_TECHS");1822			strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_QUEST_ENDED_CONTEST_TECHS");1823			veNamesToShow = GetContestLeaders();1824		}18251826		// General "Quest Expired" catch statement1827		else1828		{1829			strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_QUEST_ENDED_OTHER");1830			strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_QUEST_ENDED_OTHER");1831		}1832#if defined(MOD_EVENTS_QUESTS)1833		}1834#endif18351836		strMessage << pMinor->getNameKey();1837		strSummary << pMinor->getNameKey();18381839		CvString sMessage = strMessage.toUTF8();1840		CvString sSummary = strSummary.toUTF8();18411842		// This quest involved multiple winners, so grab their names for the notification1843		if(veNamesToShow.size() > 0)1844		{1845			sMessage = sMessage + pMinor->GetMinorCivAI()->GetNamesListAsString(veNamesToShow);1846		}18471848		pMinor->GetMinorCivAI()->AddQuestNotification(sMessage, sSummary, m_eAssignedPlayer);1849	}18501851	return true;1852}

Calls

Called by