Hooks
static bool BeforeCvUnit_canParadrop(const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility, bool& result);static void AfterCvUnit_canParadrop(const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility, bool& result);static bool ReplaceCvUnit_canParadrop(bool (*original)(const CvUnit*, const CvPlot*, bool), const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility);CivRegisterBefore<CivHooks::CvUnit_canParadrop>(host, &BeforeCvUnit_canParadrop);CivRegisterAfter<CivHooks::CvUnit_canParadrop>(host, &AfterCvUnit_canParadrop);CivRegisterReplace<CivHooks::CvUnit_canParadrop>(host, &ReplaceCvUnit_canParadrop);
Code
6511bool CvUnit::canParadrop(const CvPlot* pPlot, bool bOnlyTestVisibility) const6512{6513 VALIDATE_OBJECT6514 if(getDropRange() <= 0)6515 {6516 return false;6517 }65186519 // Things we check when we want to know if the unit can actually drop RIGHT NOW6520 if(!bOnlyTestVisibility)6521 {6522 if(hasMoved())6523 {6524 return false;6525 }65266527 if(isEmbarked())6528 {6529 return false;6530 }65316532 if(pPlot->IsFriendlyTerritory(getOwner()))6533 {6534 // We're in friendly territory, call the event to see if we CAN'T start from here anyway6535#if defined(MOD_EVENTS_PARADROPS)6536 if (MOD_EVENTS_PARADROPS) {6537 if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_CannotParadropFrom, getOwner(), GetID(), pPlot->getX(), pPlot->getY()) == GAMEEVENTRETURN_TRUE) {6538 return false;6539 }6540 } else {6541#endif6542 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();6543 if (pkScriptSystem) 6544 {6545 CvLuaArgsHandle args;6546 args->Push(((int)getOwner()));6547 args->Push(GetID());6548 args->Push(pPlot->getX());6549 args->Push(pPlot->getY());65506551 // Attempt to execute the game events.6552 // Will return false if there are no registered listeners.6553 bool bResult = false;6554 if (LuaSupport::CallTestAll(pkScriptSystem, "CannotParadropFrom", args.get(), bResult))6555 {6556 if (bResult == true)6557 {6558 return false;6559 }6560 }6561 }6562#if defined(MOD_EVENTS_PARADROPS)6563 }6564#endif6565 }6566 else6567 {6568 // We're not in friendly territory, call the event to see if we CAN start from here anyway6569#if defined(MOD_EVENTS_PARADROPS)6570 if (MOD_EVENTS_PARADROPS) {6571 if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_CanParadropFrom, getOwner(), GetID(), pPlot->getX(), pPlot->getY()) == GAMEEVENTRETURN_TRUE) {6572 return true;6573 }6574 } else {6575#endif6576 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();6577 if (pkScriptSystem) {6578 CvLuaArgsHandle args;6579 args->Push(((int)getOwner()));6580 args->Push(GetID());6581 args->Push(pPlot->getX());6582 args->Push(pPlot->getY());65836584 // Attempt to execute the game events.6585 // Will return false if there are no registered listeners.6586 bool bResult = false;6587 if (LuaSupport::CallTestAny(pkScriptSystem, "CanParadropFrom", args.get(), bResult))6588 {6589 if (bResult == true)6590 {6591 return true;6592 }6593 }6594 }6595#if defined(MOD_EVENTS_PARADROPS)6596 }6597#endif65986599 return false;6600 }6601 }66026603 return true;6604}