From af4f4a1de64663a97c96b9ec47fe61a63c8c56c2 Mon Sep 17 00:00:00 2001 From: Nuno Date: Tue, 6 Apr 2021 01:23:16 +0200 Subject: [PATCH] Merge branch 'fixes' --- ryzom/server/src/ai_service/ai_instance.cpp | 2 +- .../server/src/ai_service/ai_profile_npc.cpp | 26 ++++++++++--------- ryzom/server/src/ai_service/nf_grp_npc.cpp | 2 +- .../server/src/ai_service/state_instance.cpp | 20 ++++++++++---- .../player_manager/character.cpp | 15 ++++++++++- 5 files changed, 45 insertions(+), 20 deletions(-) diff --git a/ryzom/server/src/ai_service/ai_instance.cpp b/ryzom/server/src/ai_service/ai_instance.cpp index a4caf11fe..275c93b5a 100644 --- a/ryzom/server/src/ai_service/ai_instance.cpp +++ b/ryzom/server/src/ai_service/ai_instance.cpp @@ -705,7 +705,7 @@ CGroupNpc* CAIInstance::eventCreateNpcGroup(uint nbBots, NLMISC::CSheetId const& grp->clrBotsAreNamedFlag(); - addGroupInfo(grp, name, grp->getAlias()); + //addGroupInfo(grp, name, grp->getAlias()); { diff --git a/ryzom/server/src/ai_service/ai_profile_npc.cpp b/ryzom/server/src/ai_service/ai_profile_npc.cpp index 50805a7a9..6591df00a 100644 --- a/ryzom/server/src/ai_service/ai_profile_npc.cpp +++ b/ryzom/server/src/ai_service/ai_profile_npc.cpp @@ -3926,21 +3926,23 @@ void CGrpProfileFaction::checkTargetsAround() const uint32 playerRadius=assistPlayers||attackPlayers?thisGrpNpc._AggroRange:0; const uint32 botRadius=assistBots||attackBots?thisGrpNpc._AggroRange:0; - CCont::iterator itBot=_Grp->bots().begin(); - uint32 cellValue = 0; - CBot* bot = *itBot; - if (bot) + + for (CCont::iterator itBot=_Grp->bots().begin(), itEnd=_Grp->bots().end(); itBot!=itEnd; ++itBot) { - CSpawnBot* spawnBot = bot->getSpawnObj(); - if (spawnBot) + uint32 cellValue = 0; + CBot* bot = *itBot; + if (bot) { - CMirrorPropValueRO cell( TheDataset, spawnBot->dataSetRow(), DSPropertyCELL ); - cellValue = cell(); - } else - nlinfo("BOT NOT SPAWN TO GET CELL"); + CSpawnBot* spawnBot = bot->getSpawnObj(); + if (spawnBot) + { + CMirrorPropValueRO cell( TheDataset, spawnBot->dataSetRow(), DSPropertyCELL ); + cellValue = cell(); + Vision.updateBotsAndPlayers(thisGrpNpc.getAIInstance(), centerPos, playerRadius, botRadius, cellValue); + break; + } + } } - - Vision.updateBotsAndPlayers(thisGrpNpc.getAIInstance(), centerPos, playerRadius, botRadius, cellValue); } // Assist players diff --git a/ryzom/server/src/ai_service/nf_grp_npc.cpp b/ryzom/server/src/ai_service/nf_grp_npc.cpp index d921bcb17..01525043d 100644 --- a/ryzom/server/src/ai_service/nf_grp_npc.cpp +++ b/ryzom/server/src/ai_service/nf_grp_npc.cpp @@ -2777,7 +2777,7 @@ arg0: is the custom table id (a name) arg1: is the script with syntax : :,:,... @code -()addUserModel("toto", ":,:,..."); +()addCustomLoot("toto", ":,:,..."); @endcode */ diff --git a/ryzom/server/src/ai_service/state_instance.cpp b/ryzom/server/src/ai_service/state_instance.cpp index 3d4b78e65..3b902319f 100644 --- a/ryzom/server/src/ai_service/state_instance.cpp +++ b/ryzom/server/src/ai_service/state_instance.cpp @@ -194,11 +194,21 @@ IScriptContext* CStateInstance::findContext(NLMISC::TStringId const strId) nlassert(this->getGroup()); #endif std::vector grps; - this->getGroup()->getAIInstance()->findGroup(grps, CStringMapper::unmap(strId)); - if (grps.size() >= 1) - return grps.back()->getPersistentStateInstance(); - else - return NULL; + getGroup()->getAIInstance()->findGroup(grps, CStringMapper::unmap(strId)); + + FOREACH(grpIt, std::vector, grps) { + CGroup *grp = *grpIt; + if (grp) { + if (!grp->isSpawned()) + continue; + + CStateInstance *stateInstance = grp->getPersistentStateInstance(); + if (stateInstance) + return stateInstance; + } + } + + return NULL; } std::string CStateInstance::getContextName() diff --git a/ryzom/server/src/entities_game_service/player_manager/character.cpp b/ryzom/server/src/entities_game_service/player_manager/character.cpp index e4461a45f..4ec6e0143 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -14273,7 +14273,6 @@ bool CCharacter::autoFillExchangeView() CMission* currentMission = NULL; CGameItemPtr invItem; uint stepCounter, candidateCounter, totalItemsInBag, itemsSeenCount; - CActiveStepPD activeStep; CMissionTemplate* missionTemplate; std::map::iterator stepIterator; std::vector validateSteps; @@ -14308,6 +14307,20 @@ bool CCharacter::autoFillExchangeView() break; validateSteps = missionTemplate->Steps[*itSet - 1]->getSubSteps(); + + // get gift step from mission + const CActiveStepPD *botGiftStep = currentMission->getSteps(*itSet); + if (botGiftStep) + { + // fill in remaining quantities + for(uint i = 0; i < validateSteps.size(); ++i) + { + const CActiveStepStatePD *gift = botGiftStep->getStates(i+1); + if (gift != NULL) + validateSteps[i].Quantity = gift->getState(); + } + } + // the exchange temp inventory thingy has only 8 slots, so very benign failures to put items into it // are possible. Hence merely breaking (doing no further work) as opposed to aborting work done, // and still returning "true". (exchangeWorked == false does not necessarily represent a failure of the whole