Fix issue with getTargetNames who are lowerized

feature/prepare-cross-merge
Nuno 4 years ago committed by kaetemi
parent e0c4bcf4e0
commit bad68017b8
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -55,7 +55,7 @@ CAIAliasTranslator::CAIAliasTranslator()
{
_KeepNames = false;
}
// get the loaded primitives
const CPrimitivesParser::TPrimitivesList & primsList = CPrimitivesParser::getInstance().getPrimitives();
nlinfo("loading bot names and mission names");
@ -86,7 +86,7 @@ CAIAliasTranslator::~CAIAliasTranslator()
_AIGroupNamesToIds.clear();
_HashTableAiId.clear();
_HashTableEntityId.clear();
}// CAIAliasTranslator destructor
//-----------------------------------------------
@ -95,7 +95,7 @@ CAIAliasTranslator::~CAIAliasTranslator()
void CAIAliasTranslator::buildBotTree(const NLLIGO::IPrimitive* prim)
{
// look for bot nodes in the primitives
std::string value,name,aiClass;
std::string value, name, realName, aiClass;
if (prim->getPropertyByName("class",aiClass) )
{
if ( !nlstricmp(aiClass.c_str(),"npc_bot") ||!nlstricmp(aiClass.c_str(),"group_fauna") ||!nlstricmp(aiClass.c_str(),"npc_group") )
@ -117,6 +117,7 @@ void CAIAliasTranslator::buildBotTree(const NLLIGO::IPrimitive* prim)
nlwarning("<CAIAliasTranslator buildBotTree> errors : name='%s' alias='%s' in '%s'",name.c_str(),value.c_str(), buildPrimPath(prim).c_str());
}
realName = name;
NLMISC::strlwr(name);
//remove AI name parameters
string::size_type trash = name.find('$');
@ -128,7 +129,7 @@ void CAIAliasTranslator::buildBotTree(const NLLIGO::IPrimitive* prim)
{
if ( !nlstricmp(aiClass.c_str(),"npc_bot") )
{
_BotIdsToNames.insert( make_pair(id,name) );
_BotIdsToNames.insert( make_pair(id,realName) );
_BotNamesToIds.insert( make_pair(name,id) );
}
else
@ -169,7 +170,7 @@ void CAIAliasTranslator::buildBotTree(const NLLIGO::IPrimitive* prim)
}
}
//this is not a mission node, so lookup recursively in the children
for (uint i=0;i<prim->getNumChildren();++i)
for (uint i=0;i<prim->getNumChildren();++i)
{
const IPrimitive *child;
if ( prim->getChild(child,i) )
@ -211,11 +212,11 @@ void CAIAliasTranslator::buildMissionTree(const NLLIGO::IPrimitive* prim)
{
nlwarning("<CAIAliasTranslator buildMissionTree> The name %s is already assigned, we overwrite it",name.c_str());
}
}
}
//this is not a mission node, so lookup recursively in the children
for (uint i=0;i<prim->getNumChildren();++i)
for (uint i=0;i<prim->getNumChildren();++i)
{
const IPrimitive *child;
if ( prim->getChild(child,i) )
@ -224,16 +225,16 @@ void CAIAliasTranslator::buildMissionTree(const NLLIGO::IPrimitive* prim)
}// CAIAliasTranslator buildMissionTree
void CAIAliasTranslator::sendAliasToIOS() const
void CAIAliasTranslator::sendAliasToIOS() const
{
NLNET::CMessage msg("UPDATE_AIALIAS");
NLNET::CMessage msg("UPDATE_AIALIAS");
enum {Set=0, Add = 1, Delete=2 };
uint32 subcommand = static_cast<uint32>(Set);
msg.serial( subcommand );
typedef CHashMap< uint, std::string > TContainer;
TContainer::const_iterator first(_BotIdsToNames.begin());
TContainer::const_iterator last(_BotIdsToNames.end());
TContainer::const_iterator last(_BotIdsToNames.end());
uint32 size = static_cast<uint32>(_BotIdsToNames.size());
msg.serial(size);
for (; first != last; ++first)
@ -250,7 +251,7 @@ TAIAlias CAIAliasTranslator::getAIAlias(const NLMISC::CEntityId & entityId) cons
{
typedef CHashMap< NLMISC::CEntityId, TAIAlias,NLMISC::CEntityIdHashMapTraits> TContainer;
TContainer::const_iterator it(_HashTableEntityId.find(entityId));
TContainer::const_iterator it(_HashTableEntityId.find(entityId));
if( it != _HashTableEntityId.end() )
return (*it).second;
return Invalid;

@ -54,7 +54,7 @@ public:
/// remove an association
inline void removeAssociation(NLMISC::CEntityId& entityId);
/**
* Get a bot entityId
* \param aiid : the AI id of the bot
@ -65,7 +65,7 @@ public:
/**
* Get a bot AIId
* \param entityId: the entityId of the searched bot
* \return he AI id of the bot
* \return he AI id of the bot
*/
TAIAlias getAIAlias(const NLMISC::CEntityId & entityId) const;
@ -107,7 +107,7 @@ public:
* WARNING : SLOW : use it only for commands / stats ( iteration through a hash_map )
*/
inline const std::string &getMissionNameFromUniqueId(TAIAlias alias) const;
/**
* Get an AI groupalias from its name
* \param botName : name of the group
@ -117,7 +117,7 @@ public:
/**
* Send alias, and eid to ios via mirror.
* Send alias, and eid to ios via mirror.
*/
void sendAliasToIOS() const ;
@ -135,7 +135,7 @@ private:
* \param prim : the primitive to be parsed
*/
void buildMissionTree(const NLLIGO::IPrimitive* prim);
/// Constructor (private because it is a singleton)
CAIAliasTranslator();
@ -148,7 +148,7 @@ private:
/// hash table using AI id as keys
CHashMap< uint, NLMISC::CEntityId > _HashTableAiId;
CHashMap< NLMISC::CEntityId, TAIAlias,NLMISC::CEntityIdHashMapTraits> _HashTableEntityId;
/// map linking bot names to ids
CHashMultiMap< std::string, TAIAlias > _BotNamesToIds;
/// map linking bot ids to names
@ -188,7 +188,7 @@ inline void CAIAliasTranslator::removeNPCAlias(TAIAlias alias)
std::string lwr = NLMISC::strlwr((*it).second);
std::pair< CHashMultiMap< std::string, TAIAlias>::const_iterator, CHashMultiMap< std::string, TAIAlias>::const_iterator > result = _BotNamesToIds.equal_range(lwr);
CHashMultiMap< std::string, TAIAlias>::const_iterator it2 = result.first;
while ( it2 != result.second )
{
if ((*it2).second == alias)
@ -202,17 +202,17 @@ inline void CAIAliasTranslator::removeNPCAlias(TAIAlias alias)
inline void CAIAliasTranslator::removeName(const std::string &name)
{
std::string lwr = NLMISC::strlwr(name);
std::pair< CHashMultiMap< std::string, TAIAlias>::const_iterator, CHashMultiMap< std::string, TAIAlias>::const_iterator > result = _BotNamesToIds.equal_range(lwr);
CHashMultiMap< std::string, TAIAlias>::const_iterator it2 = result.first;
while ( it2 != result.second )
{
CHashMap< uint,std::string >::const_iterator it = _BotIdsToNames.find((*it2).second);
if ( it != _BotIdsToNames.end() )
_BotIdsToNames.erase(it);
if ((*it2).first == lwr)
it2 = _BotNamesToIds.erase(it2);
else
@ -325,7 +325,7 @@ inline void CAIAliasTranslator::updateAssociation(TAIAlias aiid, const NLMISC::C
_HashTableAiId.insert( std::make_pair( (uint)aiid,entityId ) );
_HashTableEntityId.insert( std::make_pair( entityId,aiid ) );
}// CAIAliasTranslator updateAssociation
//-----------------------------------------------
@ -359,7 +359,7 @@ inline const NLMISC::CEntityId& CAIAliasTranslator::getEntityId(TAIAlias aiid) c
if( it != _HashTableAiId.end() )
return (*it).second;
#ifndef FINAL_VERSION
nlerror( "Illegal call to getEntityId on entity with no alias" ); // see
nlerror( "Illegal call to getEntityId on entity with no alias" ); // see
#endif
return NLMISC::CEntityId::Unknown;
}// CAIAliasTranslator getEntityId

@ -91,7 +91,7 @@ class CMissionStepKillFauna : public IMissionStepTemplate
return false;
}
missionData.ChatParams.push_back( make_pair(args[0],STRING_MANAGER::creature_model) );
subStep.Dynamic = "";
subStep.Sheet = CSheetId( args[0] + ".creature");
if ( subStep.Sheet == CSheetId::Unknown )
@ -140,7 +140,7 @@ class CMissionStepKillFauna : public IMissionStepTemplate
{
vector<string> params = _User->getCustomMissionParams(_SubSteps[subStepIndex].Dynamic);
status = _User->getCustomMissionParams(_SubSteps[subStepIndex].Dynamic+"_STATUS");
if (params.size() < 2)
{
@ -175,7 +175,7 @@ class CMissionStepKillFauna : public IMissionStepTemplate
}
////
}
if ( !c )
{
LOGMISSIONSTEPERROR("kill_fauna : invalid creature " + toString(event.TargetEntity.getIndex()));
@ -183,7 +183,7 @@ class CMissionStepKillFauna : public IMissionStepTemplate
}
else if ( faunaSheet == c->getType() )
{
if ( _Place != 0xFFFF )
{
float gooDistance;
@ -214,7 +214,7 @@ class CMissionStepKillFauna : public IMissionStepTemplate
LOGMISSIONSTEPSUCCESS("kill_fauna");
return 1;
}
for ( uint i = 0; i < places.size(); i++ )
{
if ( places[i] && places[i]->getId() == _Place )
@ -283,7 +283,7 @@ class CMissionStepKillFauna : public IMissionStepTemplate
CSheetId faunaSheet = CSheetId::Unknown;
uint32 quantity = 1;
for ( uint i = 0; i < subStepStates.size(); i++ )
{
if( subStepStates[i] != 0 )
@ -295,17 +295,17 @@ class CMissionStepKillFauna : public IMissionStepTemplate
}
else
{
//// Dynamic Mission Args
vector<string> params = _User->getCustomMissionParams(_SubSteps[i].Dynamic);
vector<string> status = _User->getCustomMissionParams(_SubSteps[i].Dynamic+"_STATUS");
if (params.size() > 1)
faunaSheet = CSheetId(params[1]);
if (params.size() > 2)
NLMISC::fromString(params[2], quantity);
if (status.size() > 0) // Use saved step quantity
NLMISC::fromString(status[0], quantity);
@ -322,14 +322,14 @@ class CMissionStepKillFauna : public IMissionStepTemplate
}
////
}
if (faunaSheet != CSheetId::Unknown)
{
nbSubSteps++;
retParams.push_back(STRING_MANAGER::TParam());
retParams.back().Type = STRING_MANAGER::creature_model;
retParams.back().SheetId = faunaSheet;
retParams.push_back(STRING_MANAGER::TParam());
retParams.back().Type = STRING_MANAGER::integer;
retParams.back().Int = quantity;
@ -478,7 +478,7 @@ class CMissionStepKillRace : public IMissionStepTemplate
}
return 0;
}
void getInitState( std::vector<uint32>& ret )
{
ret.clear();
@ -504,7 +504,7 @@ class CMissionStepKillRace : public IMissionStepTemplate
retParams.push_back(STRING_MANAGER::TParam());
retParams.back().Type = STRING_MANAGER::race;
retParams.back().Enum = (uint)_SubSteps[i].Race;
retParams.push_back(STRING_MANAGER::TParam());
retParams.back().Type = STRING_MANAGER::integer;
retParams.back().Int = subStepStates[i];
@ -529,7 +529,7 @@ class CMissionStepKillRace : public IMissionStepTemplate
else
textPtr = &stepText;
}
std::vector< CSubStep > _SubSteps;
uint16 _Place;
@ -567,9 +567,9 @@ class CMissionStepKillNpc : public IMissionStepTemplate
//// Dynamic Mission Args : #dynamic#
if (trim(subs[i]) == "#dynamic#") {
subStep.Dynamic = missionData.Name;
}
}
////
else
else
{
subStep.Alias = CAIAliasTranslator::Invalid;
if ( !CMissionParser::parseBotName(subs[i],subStep.Alias,missionData) )
@ -613,7 +613,7 @@ class CMissionStepKillNpc : public IMissionStepTemplate
}
else
{
//// Dynamic Mission Args
//// Dynamic Mission Args
vector<string> params = user->getCustomMissionParams(_SubSteps[subStepIndex].Dynamic);
if (params.size() < 2) {
LOGMISSIONSTEPERROR("kill_npc : invalid dynamic npc");
@ -623,9 +623,9 @@ class CMissionStepKillNpc : public IMissionStepTemplate
{
webAppUrl = params[0];
string name;
CAIAliasTranslator::getInstance()->getNPCNameFromAlias(c->getAlias(), name);
if ( name == params[1] )
if ( NLMISC::strlwr(name) == NLMISC::strlwr(params[1]) )
{
user->validateDynamicMissionStep(webAppUrl);
LOGMISSIONSTEPSUCCESS("kill_npc");
@ -638,7 +638,7 @@ class CMissionStepKillNpc : public IMissionStepTemplate
}
return 0;
}
void getInitState( std::vector<uint32>& ret )
{
ret.clear();
@ -693,7 +693,7 @@ class CMissionStepKillNpc : public IMissionStepTemplate
}
}
}
// We don't define getInvolvedBot() here, because 1) we don't want an icon on bots to kill,
// and 2) at the moment only one bot can be returned
@ -711,7 +711,7 @@ class CMissionStepKillGroup : public IMissionStepTemplate
{
TAIAlias Alias;
};
virtual bool buildStep( uint32 line, const std::vector< std::string > & script, CMissionGlobalParsingData & globalData, CMissionSpecificParsingData & missionData )
{
_SourceLine = line;
@ -724,7 +724,7 @@ class CMissionStepKillGroup : public IMissionStepTemplate
std::vector< std::string > subs;
NLMISC::splitString( script[1],";", subs );
if ( subs.size() != 1 )
{
MISLOGSYNTAXERROR("<group_name>");
@ -732,7 +732,7 @@ class CMissionStepKillGroup : public IMissionStepTemplate
}
_SubSteps.reserve(1);
{
CMissionParser::removeBlanks( subs[0] );
std::vector< TAIAlias > aliases;
@ -769,7 +769,7 @@ class CMissionStepKillGroup : public IMissionStepTemplate
}
return 0;
}
void getInitState( std::vector<uint32>& ret )
{
ret.clear();
@ -779,7 +779,7 @@ class CMissionStepKillGroup : public IMissionStepTemplate
ret[i] = 1;
}
}
virtual void getTextParams( uint & nbSubSteps, const std::string* & textPtr,TVectorParamCheck& retParams, const std::vector<uint32>& subStepStates)
{
/// overloaded text in script
@ -798,7 +798,7 @@ class CMissionStepKillGroup : public IMissionStepTemplate
{
return true;
}
std::vector< CSubStep > _SubSteps;
std::string Target;
@ -820,7 +820,7 @@ class CMissionStepKillFaction : public IMissionStepTemplate
MISLOGSYNTAXERROR("<faction> <quantity> [: <place>]");
return false;
}
std::vector< std::string > args;
CMissionParser::tokenizeString( script[1]," \t", args );
if ( args.size() != 2 )
@ -921,7 +921,7 @@ class CMissionStepKillFaction : public IMissionStepTemplate
retParams.push_back(STRING_MANAGER::TParam(STRING_MANAGER::faction));
retParams.back().Enum = _Faction;
retParams.push_back(STRING_MANAGER::TParam(STRING_MANAGER::integer, sint32(_Quantity)));
if ( _Place != 0xFFFF )
{
STRING_MANAGER::TParam param;
@ -940,7 +940,7 @@ class CMissionStepKillFaction : public IMissionStepTemplate
}
else
textPtr = &stepText;
}
/// Faction as defined in CStaticFame
@ -1072,7 +1072,7 @@ class CMissionStepKillByName : public IMissionStepTemplate
}
return 0;
}
void getInitState( std::vector<uint32>& ret )
{
ret.clear();
@ -1208,7 +1208,7 @@ class CMissionStepKillPlayer : public IMissionStepTemplate
else
{
sint32 victimFame = CFameInterface::getInstance().getFameIndexed(victim->getId(), _SubSteps[subStepIndex].Clan);
if ( (victimFame > _SubSteps[subStepIndex].MinLevel) &&
if ( (victimFame > _SubSteps[subStepIndex].MinLevel) &&
(victimFame < _SubSteps[subStepIndex].MaxLevel) )
{
if ( _Place != 0xFFFF )
@ -1250,7 +1250,7 @@ class CMissionStepKillPlayer : public IMissionStepTemplate
}
return 0;
}
void getInitState( std::vector<uint32>& ret )
{
@ -1281,7 +1281,7 @@ class CMissionStepKillPlayer : public IMissionStepTemplate
retParams.push_back(STRING_MANAGER::TParam());
retParams.back().Type = STRING_MANAGER::faction;
retParams.back().Enum = _SubSteps[i].Clan;
retParams.push_back(STRING_MANAGER::TParam());
retParams.back().Type = STRING_MANAGER::integer;
retParams.back().Int = _SubSteps[i].MinLevel;

Loading…
Cancel
Save