From 6bfb1fb588b2dd02065e5fa78feeb9b737fe989c Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Mon, 28 Nov 2016 00:54:33 +0100 Subject: [PATCH] Allow target to work with sheetName and a quiet option HG : Enter commit message. Lines beginning with 'HG:' are removed. --HG-- branch : target_sheet --- .../data/gamedev/interfaces_v3/commands.xml | 6 ++++++ code/ryzom/client/src/entities.cpp | 21 ++++++++++++++++++- code/ryzom/client/src/entities.h | 2 +- .../src/interface_v3/action_handler_game.cpp | 13 ++++++++++-- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml b/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml index 6fdb5d32a..58f41d919 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml @@ -63,9 +63,15 @@ + + + + + + diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp index 516232108..55c7c6772 100644 --- a/code/ryzom/client/src/entities.cpp +++ b/code/ryzom/client/src/entities.cpp @@ -1949,7 +1949,26 @@ CEntityCL *CEntityManager::getEntityByCompressedIndex(TDataSetIndex compressedIn } return NULL; } - +//----------------------------------------------- +// getEntityBySheetName : +// Return an entity based on its sheet name +//----------------------------------------------- +CEntityCL *CEntityManager::getEntityBySheetName (const ucstring &sheet) const +{ + if (!sheet.empty()) + { + uint i; + const CSheetId& sheetRef = NLMISC::CSheetId(sheet.toUtf8()); + const uint count = (uint)_Entities.size(); + for (i=0; isheetId() == sheetRef) + return _Entities[i]; + } + } + return NULL; +} //----------------------------------------------- // managePACSTriggers : // Manage PACS Triggers. diff --git a/code/ryzom/client/src/entities.h b/code/ryzom/client/src/entities.h index f71240b63..7b41f234e 100644 --- a/code/ryzom/client/src/entities.h +++ b/code/ryzom/client/src/entities.h @@ -277,7 +277,7 @@ public: * \param complete : if true, the name must match the full name of the entity. */ CEntityCL *getEntityByName (const ucstring &name, bool caseSensitive, bool complete) const; - + CEntityCL *getEntityBySheetName (const ucstring &sheet) const; /// Get an entity by dataset index. Returns NULL if the entity is not found. CEntityCL *getEntityByCompressedIndex(TDataSetIndex compressedIndex) const; diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 76e664bc0..cac69d64c 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -2418,6 +2418,7 @@ class CAHTarget : public IActionHandler ucstring entityName; entityName.fromUtf8 (getParam (Params, "entity")); bool preferCompleteMatch = (getParam (Params, "prefer_complete_match") != "0"); + bool quiet = (getParam (Params, "quiet") == "true"); if (!entityName.empty()) { @@ -2433,6 +2434,12 @@ class CAHTarget : public IActionHandler // Get the entity with a partial match entity = EntitiesMngr.getEntityByName (entityName, false, false); } + + if (entity == NULL) + { + //Get the entity with a sheetName + entity = EntitiesMngr.getEntityBySheetName(entityName); + } if (entity) { @@ -2457,7 +2464,8 @@ class CAHTarget : public IActionHandler // to avoid campfire selection exploit #316 nldebug("is not prop selectable"); CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->displaySystemInfo(CI18N::get("uiTargetErrorCmd")); + if(!quiet) + pIM->displaySystemInfo(CI18N::get("uiTargetErrorCmd")); return; } @@ -2467,7 +2475,8 @@ class CAHTarget : public IActionHandler else { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->displaySystemInfo(CI18N::get("uiTargetErrorCmd")); + if(!quiet) + pIM->displaySystemInfo(CI18N::get("uiTargetErrorCmd")); } } }