CvUnit::trade()
- Defined in
- CvUnit.cpp, line 9413
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_trade
Hooks
static bool BeforeCvUnit_trade(CvUnit* self, bool& result);static void AfterCvUnit_trade(CvUnit* self, bool& result);static bool ReplaceCvUnit_trade(bool (*original)(CvUnit*), CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_trade>(host, &BeforeCvUnit_trade);CivRegisterAfter<CivHooks::CvUnit_trade>(host, &AfterCvUnit_trade);CivRegisterReplace<CivHooks::CvUnit_trade>(host, &ReplaceCvUnit_trade);
Code
9413bool CvUnit::trade()9414{9415 VALIDATE_OBJECT94169417 CvPlot* pPlot = plot();94189419 if(!canTrade(pPlot))9420 return false;94219422 int iTradeGold = getTradeGold(pPlot);9423 9424 GET_PLAYER(getOwner()).GetTreasury()->ChangeGold(iTradeGold);94259426 // Improve relations with the Minor9427 PlayerTypes eMinor = pPlot->getOwner();9428 CvAssertMsg(eMinor != NO_PLAYER, "Performing a trade mission and not in city state territory. This is bad. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");9429 int iFriendship = getTradeInfluence(pPlot);94309431 GET_PLAYER(eMinor).GetMinorCivAI()->ChangeFriendshipWithMajor(getOwner(), iFriendship);94329433 if(getOwner() == GC.getGame().getActivePlayer())9434 {9435 DLLUI->AddUnitMessage(0, GetIDInfo(), getOwner(), true, GC.getEVENT_MESSAGE_TIME(), GetLocalizedText("TXT_KEY_MERCHANT_RESULT", iTradeGold, iFriendship));9436 }94379438 if(pPlot->isActiveVisible(false))9439 {9440 auto_ptr<ICvUnit1> pDllUnit(new CvDllUnit(this));9441 gDLL->GameplayUnitActivate(pDllUnit.get());9442 }94439444 if(IsGreatPerson())9445 {9446 CvPlayer& kPlayer = GET_PLAYER(getOwner());9447#if defined(MOD_EVENTS_GREAT_PEOPLE)9448 kPlayer.DoGreatPersonExpended(getUnitType(), this);9449#else9450 kPlayer.DoGreatPersonExpended(getUnitType());9451#endif9452 }94539454 kill(true);94559456 return true;9457}
Calls
- CvDllUnit::CvDllUnit(CvUnit *)
- CvGame::getActivePlayer() const
- CvGlobals::getDLLIFace()
- CvGlobals::GetEngineUserInterface()
- CvGlobals::getEVENT_MESSAGE_TIME()
- CvGlobals::getGame()
- CvMinorCivAI::ChangeFriendshipWithMajor(PlayerTypes, int, bool)
- CvPlayer::DoGreatPersonExpended(UnitTypes, CvUnit *)
- CvPlayer::GetMinorCivAI() const
- CvPlayer::GetTreasury() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlot::getOwner() const
- CvPlot::isActiveVisible(bool) const
CvString::operator const char *- CvTreasury::ChangeGold(int)
- CvUnit::canTrade(const CvPlot *, bool) const
- CvUnit::GetIDInfo() const
- CvUnit::getOwner() const
- CvUnit::getTradeGold(const CvPlot *) const
- CvUnit::getTradeInfluence(const CvPlot *) const
- CvUnit::getUnitType() const
- CvUnit::IsGreatPerson() const
- CvUnit::kill(bool, PlayerTypes)
- CvUnit::plot() const
GetLocalizedTextICvEngineUtility1::GameplayUnitActivateICvUserInterface1::AddUnitMessagestd::auto_ptr::auto_ptrstd::auto_ptr::get