本文整理汇总了C++中Utf8FitTo函数的典型用法代码示例。如果您正苦于以下问题:C++ Utf8FitTo函数的具体用法?C++ Utf8FitTo怎么用?C++ Utf8FitTo使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Utf8FitTo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wstrToLower
bool ChatHandler::HandleLookupAreaCommand(const char* args)
{
if (!*args)
return false;
std::string namepart = args;
std::wstring wnamepart;
if (!Utf8toWStr (namepart, wnamepart))
return false;
bool found = false;
uint32 count = 0;
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
// converting string that we try to find to lower case
wstrToLower (wnamepart);
// Search in AreaTable.dbc
for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows (); ++areaflag)
{
AreaTableEntry const* areaEntry = sAreaStore.LookupEntry (areaflag);
if (areaEntry)
{
int loc = GetSessionDbcLocale ();
std::string name = areaEntry->area_name[loc];
if (name.empty())
continue;
if (!Utf8FitTo (name, wnamepart))
{
loc = 0;
for (; loc < TOTAL_LOCALES; ++loc)
{
if (loc == GetSessionDbcLocale ())
continue;
name = areaEntry->area_name[loc];
if (name.empty ())
continue;
if (Utf8FitTo (name, wnamepart))
break;
}
}
if (loc < TOTAL_LOCALES)
{
if (maxResults && count++ == maxResults)
{
PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
// send area in "id - [name]" format
std::ostringstream ss;
if (m_session)
ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << ' ' << localeNames[loc]<< "]|h|r";
else
ss << areaEntry->ID << " - " << name << ' ' << localeNames[loc];
SendSysMessage (ss.str ().c_str());
if (!found)
found = true;
}
}
}
if (!found)
SendSysMessage (LANG_COMMAND_NOAREAFOUND);
return true;
}
示例2: BuildListAuctionItems
void WorldSession::BuildListAuctionItems(std::vector<AuctionEntry*> const& auctions, WorldPacket& data, std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin,
uint32 levelmax, uint32 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount, bool isFull)
{
int loc_idx = _player->GetSession()->GetSessionDbLocaleIndex();
for (std::vector<AuctionEntry*>::const_iterator itr = auctions.begin(); itr != auctions.end(); ++itr)
{
AuctionEntry* Aentry = *itr;
if (Aentry->moneyDeliveryTime)
continue;
Item* item = sAuctionMgr.GetAItem(Aentry->itemGuidLow);
if (!item)
continue;
if (isFull)
{
++count;
Aentry->BuildAuctionInfo(data);
}
else
{
ItemPrototype const* proto = item->GetProto();
if (itemClass != 0xffffffff && proto->Class != itemClass)
continue;
if (itemSubClass != 0xffffffff && proto->SubClass != itemSubClass)
continue;
if (inventoryType != 0xffffffff && proto->InventoryType != inventoryType)
continue;
if (quality != 0xffffffff && proto->Quality < quality)
continue;
if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax)))
continue;
if (usable != 0x00)
{
if (_player->CanUseItem(item) != EQUIP_ERR_OK)
continue;
if (proto->Class == ITEM_CLASS_RECIPE)
{
if (SpellEntry const* spell = sSpellStore.LookupEntry(proto->Spells[0].SpellId))
{
SpellEffectEntry const* spellEff = spell->GetSpellEffect(EFFECT_INDEX_0);
if (!spellEff)
continue;
if (_player->HasSpell(spellEff->EffectTriggerSpell))
continue;
}
}
}
std::string name = proto->Name1;
sObjectMgr.GetItemLocaleStrings(proto->ItemId, loc_idx, &name);
if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname))
continue;
if (count < 50 && totalcount >= listfrom)
{
++count;
Aentry->BuildAuctionInfo(data);
}
}
++totalcount;
}
}
示例3: BuildListAuctionItems
void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player,
std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable,
uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality,
uint32& count, uint32& totalcount)
{
int loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr)
{
AuctionEntry *Aentry = itr->second;
Item *item = sAuctionMgr.GetAItem(Aentry->itemGuidLow);
if (!item)
continue;
{
ItemPrototype const *proto = item->GetProto();
if (itemClass != 0xffffffff && proto->Class != itemClass)
continue;
if (itemSubClass != 0xffffffff && proto->SubClass != itemSubClass)
continue;
if (inventoryType != 0xffffffff && proto->InventoryType != inventoryType)
continue;
if (quality != 0xffffffff && proto->Quality < quality)
continue;
if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax)))
continue;
if (usable != 0x00 && player->CanUseItem(item) != EQUIP_ERR_OK)
continue;
if (usable != 0x00 && proto->Class == ITEM_CLASS_RECIPE)
if (SpellEntry const* spell = sSpellStore.LookupEntry(proto->Spells[0].SpellId))
if (player->HasSpell(spell->EffectTriggerSpell[EFFECT_INDEX_0]))
continue;
std::string name = proto->Name1;
if (name.empty())
continue;
// local name
if (loc_idx >= 0)
{
ItemLocale const *il = sObjectMgr.GetItemLocale(proto->ItemId);
if (il)
{
if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
name = il->Name[loc_idx];
}
}
if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname))
continue;
if (count < 50 && totalcount >= listfrom)
{
++count;
Aentry->BuildAuctionInfo(data);
}
}
++totalcount;
}
}
示例4: CHECK_PACKET_SIZE
//.........这里部分代码省略.........
// player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST
if ((itr->second->GetSession()->GetSecurity() > SEC_PLAYER && !gmInWhoList))
continue;
}
// check if target is globally visible for player
if (!(itr->second->IsVisibleGloballyFor(_player)))
continue;
// check if target's level is in level range
uint32 lvl = itr->second->getLevel();
if (lvl < level_min || lvl > level_max)
continue;
// check if class matches classmask
uint32 class_ = itr->second->getClass();
if (!(classmask & (1 << class_)))
continue;
// check if race matches racemask
uint32 race = itr->second->getRace();
if (!(racemask & (1 << race)))
continue;
uint32 pzoneid = itr->second->GetZoneId();
bool z_show = true;
for(uint32 i = 0; i < zones_count; i++)
{
if(zoneids[i] == pzoneid)
{
z_show = true;
break;
}
z_show = false;
}
if (!z_show)
continue;
std::string pname = itr->second->GetName();
std::wstring wpname;
if(!Utf8toWStr(pname,wpname))
continue;
wstrToLower(wpname);
if (!(wplayer_name.empty() || wpname.find(wplayer_name) != std::wstring::npos))
continue;
std::string gname = objmgr.GetGuildNameById(itr->second->GetGuildId());
std::wstring wgname;
if(!Utf8toWStr(gname,wgname))
continue;
wstrToLower(wgname);
if (!(wguild_name.empty() || wgname.find(wguild_name) != std::wstring::npos))
continue;
std::string aname;
if(AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(itr->second->GetZoneId()))
aname = areaEntry->area_name[GetSessionDbcLocale()];
bool s_show = true;
for(uint32 i = 0; i < str_count; i++)
{
if (!str[i].empty())
{
if (wgname.find(str[i]) != std::wstring::npos ||
wpname.find(str[i]) != std::wstring::npos ||
Utf8FitTo(aname, str[i]) )
{
s_show = true;
break;
}
s_show = false;
}
}
if (!s_show)
continue;
data << pname; // player name
data << gname; // guild name
data << uint32( lvl ); // player level
data << uint32( class_ ); // player class
data << uint32( race ); // player race
data << uint8(0); // new 2.4.0
data << uint32( pzoneid ); // player zone id
// 49 is maximum player count sent to client
if ((++clientcount) == 49)
break;
}
data.put( 0, clientcount ); //insert right count
data.put( sizeof(uint32), clientcount ); //insert right count
SendPacket(&data);
sLog.outDebug( "WORLD: Send SMSG_WHO Message" );
}
示例5: BuildListAuctionItems
void WorldSession::BuildListAuctionItems(std::list<AuctionEntry*> &auctions, WorldPacket& data, std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin,
uint32 levelmax, uint32 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount, bool isFull)
{
int loc_idx = _player->GetSession()->GetSessionDbLocaleIndex();
for (std::list<AuctionEntry*>::const_iterator itr = auctions.begin(); itr != auctions.end();++itr)
{
AuctionEntry *Aentry = *itr;
if (Aentry->moneyDeliveryTime)
continue;
Item *item = sAuctionMgr.GetAItem(Aentry->itemGuidLow);
if (!item)
continue;
if (isFull)
{
++count;
Aentry->BuildAuctionInfo(data);
}
else
{
ItemPrototype const *proto = item->GetProto();
if (itemClass != 0xffffffff && proto->Class != itemClass)
continue;
if (itemSubClass != 0xffffffff && proto->SubClass != itemSubClass)
continue;
if (inventoryType != 0xffffffff && proto->InventoryType != inventoryType)
continue;
if (quality != 0xffffffff && proto->Quality < quality)
continue;
if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax)))
continue;
if (usable != 0x00 && _player->CanUseItem(item) != EQUIP_ERR_OK)
continue;
std::string name = proto->Name1;
if (name.empty())
continue;
// local name
if (loc_idx >= 0)
{
ItemLocale const *il = sObjectMgr.GetItemLocale(proto->ItemId);
if (il)
{
if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
name = il->Name[loc_idx];
}
}
if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname))
continue;
if (count < 50 && totalcount >= listfrom)
{
++count;
Aentry->BuildAuctionInfo(data);
}
}
++totalcount;
}
}
示例6: HandleLookupSpellCommand
static bool HandleLookupSpellCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
// can be NULL at console call
Player* target = handler->getSelectedPlayer();
std::string namePart = args;
std::wstring wNamePart;
if (!Utf8toWStr(namePart, wNamePart))
return false;
// converting string that we try to find to lower case
wstrToLower(wNamePart);
bool found = false;
uint32 count = 0;
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
// Search in Spell.dbc
for (uint32 id = 0; id < sSpellMgr->GetSpellInfoStoreSize(); id++)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id);
if (spellInfo)
{
std::string name = spellInfo->SpellName;
if (name.empty())
continue;
if (!Utf8FitTo(name, wNamePart))
continue;
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
bool known = target && target->HasSpell(id);
bool learn = (spellInfo->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL);
SpellInfo const* learnSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[0].TriggerSpell);
uint32 talentCost = GetTalentSpellCost(id);
bool talent = (talentCost > 0);
bool passive = spellInfo->IsPassive();
bool active = target && target->HasAura(id);
// unit32 used to prevent interpreting uint8 as char at output
// find rank of learned spell for learning spell, or talent rank
uint32 rank = talentCost ? talentCost : learn && learnSpellInfo ? learnSpellInfo->GetRank() : spellInfo->GetRank();
// send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
std::ostringstream ss;
if (handler->GetSession())
ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name;
else
ss << id << " - " << name;
// include rank in link name
if (rank)
ss << handler->GetTrinityString(LANG_SPELL_RANK) << rank;
if (handler->GetSession())
ss << "]|h|r";
if (talent)
ss << handler->GetTrinityString(LANG_TALENT);
if (passive)
ss << handler->GetTrinityString(LANG_PASSIVE);
if (learn)
ss << handler->GetTrinityString(LANG_LEARN);
if (known)
ss << handler->GetTrinityString(LANG_KNOWN);
if (active)
ss << handler->GetTrinityString(LANG_ACTIVE);
handler->SendSysMessage(ss.str().c_str());
if (!found)
found = true;
}
}
if (!found)
handler->SendSysMessage(LANG_COMMAND_NOSPELLFOUND);
return true;
}
示例7: HandleLookupObjectCommand
static bool HandleLookupObjectCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
std::string namePart = args;
std::wstring wNamePart;
// converting string that we try to find to lower case
if (!Utf8toWStr(namePart, wNamePart))
return false;
wstrToLower(wNamePart);
bool found = false;
uint32 count = 0;
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
{
uint8 localeIndex = handler->GetSessionDbLocaleIndex();
if (GameObjectLocale const* objectLocalte = sObjectMgr->GetGameObjectLocale(itr->second.entry))
{
if (objectLocalte->Name.size() > localeIndex && !objectLocalte->Name[localeIndex].empty())
{
std::string name = objectLocalte->Name[localeIndex];
if (Utf8FitTo(name, wNamePart))
{
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
if (handler->GetSession())
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, itr->second.entry, itr->second.entry, name.c_str());
else
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->second.entry, name.c_str());
if (!found)
found = true;
continue;
}
}
}
std::string name = itr->second.name;
if (name.empty())
continue;
if (Utf8FitTo(name, wNamePart))
{
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
if (handler->GetSession())
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, itr->second.entry, itr->second.entry, name.c_str());
else
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->second.entry, name.c_str());
if (!found)
found = true;
}
}
if (!found)
handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND);
return true;
}
示例8: BuildListAuctionItems
void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player,
std::wstring const& wsearchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint8 usable,
uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality,
uint32& count, uint32& totalcount)
{
int loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
int locdbc_idx = player->GetSession()->GetSessionDbcLocale();
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
{
AuctionEntry *Aentry = itr->second;
Item *item = sAuctionMgr->GetAItem(Aentry->item_guidlow);
if (!item)
continue;
ItemPrototype const *proto = item->GetProto();
if (itemClass != 0xffffffff && proto->Class != itemClass)
continue;
if (itemSubClass != 0xffffffff && proto->SubClass != itemSubClass)
continue;
if (inventoryType != 0xffffffff && proto->InventoryType != inventoryType)
continue;
if (quality != 0xffffffff && proto->Quality != quality)
continue;
if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax)))
continue;
if (usable != 0x00 && player->CanUseItem(item) != EQUIP_ERR_OK)
continue;
// Allow search by suffix (ie: of the Monkey) or partial name (ie: Monkey)
// No need to do any of this if no search term was entered
if (!wsearchedname.empty())
{
std::string name = proto->Name1;
if (name.empty())
continue;
// local name
if (loc_idx >= 0)
if (ItemLocale const *il = sObjectMgr->GetItemLocale(proto->ItemId))
sObjectMgr->GetLocaleString(il->Name, loc_idx, name);
// DO NOT use GetItemEnchantMod(proto->RandomProperty) as it may return a result
// that matches the search but it may not equal item->GetItemRandomPropertyId()
// used in BuildAuctionInfo() which then causes wrong items to be listed
int32 propRefID = item->GetItemRandomPropertyId();
if (propRefID)
{
// Append the suffix to the name (ie: of the Monkey) if one exists
// These are found in ItemRandomProperties.dbc, not ItemRandomSuffix.dbc
// even though the DBC names seem misleading
const ItemRandomPropertiesEntry *itemRandProp = sItemRandomPropertiesStore.LookupEntry(propRefID);
if (itemRandProp)
{
char* const* temp = itemRandProp->nameSuffix;
//char* temp = itemRandProp->nameSuffix;
// dbc local name
if (temp)
{
if (locdbc_idx >= 0)
{
// Append the suffix (ie: of the Monkey) to the name using localization
name += " ";
name += temp[locdbc_idx];
}
else
{
// Invalid localization? Append the suffix using default enUS
name += " ";
name += temp[LOCALE_enUS];
}
}
}
}
// Perform the search (with or without suffix)
if (!Utf8FitTo(name, wsearchedname))
continue;
}
// Add the item if no search term or if entered search term was found
if (count < 50 && totalcount >= listfrom)
{
++count;
Aentry->BuildAuctionInfo(data);
}
++totalcount;
}
}
示例9: HandleLookupFactionCommand
static bool HandleLookupFactionCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
// Can be NULL at console call
Player* target = handler->getSelectedPlayer();
std::string namePart = args;
std::wstring wNamePart;
if (!Utf8toWStr(namePart, wNamePart))
return false;
// converting string that we try to find to lower case
wstrToLower (wNamePart);
bool found = false;
uint32 count = 0;
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
for (uint32 id = 0; id < sFactionStore.GetNumRows(); ++id)
{
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(id))
{
FactionState const* factionState = target ? target->GetReputationMgr().GetState(factionEntry) : NULL;
std::string name = factionEntry->name;
if (name.empty())
continue;
if (!Utf8FitTo(name, wNamePart))
continue;
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
// send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format
// or "id - [faction] [no reputation]" format
std::ostringstream ss;
if (handler->GetSession())
ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << "]|h|r";
else
ss << id << " - " << name;
if (factionState) // and then target != NULL also
{
uint32 index = target->GetReputationMgr().GetReputationRankStrIndex(factionEntry);
std::string rankName = handler->GetTrinityString(index);
ss << ' ' << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ')';
if (factionState->Flags & FACTION_FLAG_VISIBLE)
ss << handler->GetTrinityString(LANG_FACTION_VISIBLE);
if (factionState->Flags & FACTION_FLAG_AT_WAR)
ss << handler->GetTrinityString(LANG_FACTION_ATWAR);
if (factionState->Flags & FACTION_FLAG_PEACE_FORCED)
ss << handler->GetTrinityString(LANG_FACTION_PEACE_FORCED);
if (factionState->Flags & FACTION_FLAG_HIDDEN)
ss << handler->GetTrinityString(LANG_FACTION_HIDDEN);
if (factionState->Flags & FACTION_FLAG_INVISIBLE_FORCED)
ss << handler->GetTrinityString(LANG_FACTION_INVISIBLE_FORCED);
if (factionState->Flags & FACTION_FLAG_INACTIVE)
ss << handler->GetTrinityString(LANG_FACTION_INACTIVE);
}
else
ss << handler->GetTrinityString(LANG_FACTION_NOREPUTATION);
handler->SendSysMessage(ss.str().c_str());
if (!found)
found = true;
}
}
if (!found)
handler->SendSysMessage(LANG_COMMAND_FACTION_NOTFOUND);
return true;
}
示例10: HandleLookupItemCommand
static bool HandleLookupItemCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
std::string namePart = args;
std::wstring wNamePart;
// converting string that we try to find to lower case
if (!Utf8toWStr(namePart, wNamePart))
return false;
wstrToLower(wNamePart);
bool found = false;
uint32 count = 0;
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
// Search in `item_template`
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
{
int localeIndex = handler->GetSessionDbLocaleIndex();
if (localeIndex >= 0)
{
uint8 ulocaleIndex = uint8(localeIndex);
if (ItemLocale const* il = sObjectMgr->GetItemLocale(itr->second.ItemId))
{
if (il->Name.size() > ulocaleIndex && !il->Name[ulocaleIndex].empty())
{
std::string name = il->Name[ulocaleIndex];
if (Utf8FitTo(name, wNamePart))
{
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
if (handler->GetSession())
handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itr->second.ItemId, itr->second.ItemId, name.c_str());
else
handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itr->second.ItemId, name.c_str());
if (!found)
found = true;
continue;
}
}
}
}
std::string name = itr->second.Name1;
if (name.empty())
continue;
if (Utf8FitTo(name, wNamePart))
{
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
if (handler->GetSession())
handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itr->second.ItemId, itr->second.ItemId, name.c_str());
else
handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itr->second.ItemId, name.c_str());
if (!found)
found = true;
}
}
if (!found)
handler->SendSysMessage(LANG_COMMAND_NOITEMFOUND);
return true;
}
示例11: HandleLookupMapCommand
static bool HandleLookupMapCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
std::string namePart = args;
std::wstring wNamePart;
if (!Utf8toWStr(namePart, wNamePart))
return false;
wstrToLower(wNamePart);
uint32 counter = 0;
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
uint8 locale = handler->GetSession() ? handler->GetSession()->GetSessionDbcLocale() : sWorld->GetDefaultDbcLocale();
// search in Map.dbc
for (uint32 id = 0; id < sMapStore.GetNumRows(); id++)
{
if (MapEntry const* mapInfo = sMapStore.LookupEntry(id))
{
std::string name = mapInfo->name;
if (name.empty())
continue;
if (Utf8FitTo(name, wNamePart) && locale < TOTAL_LOCALES)
{
if (maxResults && counter == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
std::ostringstream ss;
ss << id << " - [" << name << ']';
if (mapInfo->IsContinent())
ss << handler->GetTrinityString(LANG_CONTINENT);
switch (mapInfo->map_type)
{
case MAP_INSTANCE:
ss << handler->GetTrinityString(LANG_INSTANCE);
break;
case MAP_RAID:
ss << handler->GetTrinityString(LANG_RAID);
break;
case MAP_BATTLEGROUND:
ss << handler->GetTrinityString(LANG_BATTLEGROUND);
break;
case MAP_ARENA:
ss << handler->GetTrinityString(LANG_ARENA);
break;
}
handler->SendSysMessage(ss.str().c_str());
++counter;
}
}
}
if (!counter)
handler->SendSysMessage(LANG_COMMAND_NOMAPFOUND);
return true;
}
示例12: CHECK_PACKET_SIZE
//this void is called when player clicks on search button
void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+4+1+1+1+4+4+4+4+1);
std::string searchedname, name;
uint8 levelmin, levelmax, usable, location;
uint32 count, totalcount, listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
uint64 guid;
recv_data >> guid;
recv_data >> listfrom; // start, used for page control listing by 50 elements
recv_data >> searchedname;
// recheck with known string size
CHECK_PACKET_SIZE(recv_data,8+4+(searchedname.size()+1)+1+1+4+4+4+4+1);
recv_data >> levelmin >> levelmax;
recv_data >> auctionSlotID >> auctionMainCategory >> auctionSubCategory;
recv_data >> quality >> usable;
Creature *pCreature = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid,UNIT_NPC_FLAG_AUCTIONEER);
if (!pCreature)
{
sLog.outDebug( "WORLD: HandleAuctionListItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
return;
}
// remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject * mAuctions;
mAuctions = objmgr.GetAuctionsMap( location );
//sLog.outDebug("Auctionhouse search guid: " I64FMTD ", list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", guid, listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
WorldPacket data( SMSG_AUCTION_LIST_RESULT, (4+4+4) );
count = 0;
totalcount = 0;
data << (uint32) 0;
// converting string that we try to find to lower case
std::wstring wsearchedname;
if(!Utf8toWStr(searchedname,wsearchedname))
return;
wstrToLower(wsearchedname);
for (AuctionHouseObject::AuctionEntryMap::iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr)
{
AuctionEntry *Aentry = itr->second;
Item *item = objmgr.GetAItem(Aentry->item_guidlow);
if( item )
{
ItemPrototype const *proto = item->GetProto();
if( proto )
{
if( auctionMainCategory == (0xffffffff) || proto->Class == auctionMainCategory )
{
if( auctionSubCategory == (0xffffffff) || proto->SubClass == auctionSubCategory )
{
if( auctionSlotID == (0xffffffff) || proto->InventoryType == auctionSlotID )
{
if( quality == (0xffffffff) || proto->Quality == quality )
{
if( usable == (0x00) || _player->CanUseItem( item ) == EQUIP_ERR_OK )
{
if( ( levelmin == (0x00) || proto->RequiredLevel >= levelmin ) && ( levelmax == (0x00) || proto->RequiredLevel <= levelmax ) )
{
name = proto->Name1;
// local name
int loc_idx = GetSessionDbLocaleIndex();
if ( loc_idx >= 0 )
{
ItemLocale const *il = objmgr.GetItemLocale(proto->ItemId);
if (il)
{
if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
name = il->Name[loc_idx];
}
}
if(name.empty())
continue;
if( wsearchedname.empty() || Utf8FitTo(name, wsearchedname) )
{
if ((count < 50) && (totalcount >= listfrom))
{
++count;
SendAuctionInfo( data, Aentry);
}
++totalcount;
}
}
}
}
//.........这里部分代码省略.........
示例13: HandleLookupQuestCommand
static bool HandleLookupQuestCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
// can be NULL at console call
Player* target = handler->getSelectedPlayer();
std::string namePart = args;
std::wstring wNamePart;
// converting string that we try to find to lower case
if (!Utf8toWStr(namePart, wNamePart))
return false;
wstrToLower(wNamePart);
bool found = false;
uint32 count = 0;
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
ObjectMgr::QuestMap const& qTemplates = sObjectMgr->GetQuestTemplates();
for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter)
{
Quest* qInfo = iter->second;
int localeIndex = handler->GetSessionDbLocaleIndex();
if (localeIndex >= 0)
{
uint8 ulocaleIndex = uint8(localeIndex);
if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(qInfo->GetQuestId()))
{
if (questLocale->Title.size() > ulocaleIndex && !questLocale->Title[ulocaleIndex].empty())
{
std::string title = questLocale->Title[ulocaleIndex];
if (Utf8FitTo(title, wNamePart))
{
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
char const* statusStr = "";
if (target)
{
QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
switch (status)
{
case QUEST_STATUS_COMPLETE:
statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
break;
case QUEST_STATUS_INCOMPLETE:
statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
break;
case QUEST_STATUS_REWARDED:
statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
break;
default:
break;
}
}
if (handler->GetSession())
handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title.c_str(), statusStr);
else
handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title.c_str(), statusStr);
if (!found)
found = true;
continue;
}
}
}
}
std::string title = qInfo->GetTitle();
if (title.empty())
continue;
if (Utf8FitTo(title, wNamePart))
{
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
char const* statusStr = "";
if (target)
{
QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId());
switch (status)
{
//.........这里部分代码省略.........
示例14: HandleLearnAllRecipesCommand
static bool HandleLearnAllRecipesCommand(ChatHandler* handler, char const* args)
{
// Learns all recipes of specified profession and sets skill to max
// Example: .learn all_recipes enchanting
Player* target = handler->getSelectedPlayer();
if (!target)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
return false;
}
if (!*args)
return false;
std::wstring namePart;
if (!Utf8toWStr(args, namePart))
return false;
// converting string that we try to find to lower case
wstrToLower(namePart);
std::string name;
SkillLineEntry const* targetSkillInfo = NULL;
for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i)
{
SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i);
if (!skillInfo)
continue;
if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION &&
skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) ||
!skillInfo->canLink) // only prof with recipes have set
continue;
int loc = handler->GetSessionDbcLocale();
name = skillInfo->name[loc];
if (name.empty())
continue;
if (!Utf8FitTo(name, namePart))
{
loc = 0;
for (; loc < TOTAL_LOCALES; ++loc)
{
if (loc == handler->GetSessionDbcLocale())
continue;
name = skillInfo->name[loc];
if (name.empty())
continue;
if (Utf8FitTo(name, namePart))
break;
}
}
if (loc < TOTAL_LOCALES)
{
targetSkillInfo = skillInfo;
break;
}
}
if (!targetSkillInfo)
return false;
HandleLearnSkillRecipesHelper(target, targetSkillInfo->id);
uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id);
target->SetSkill(targetSkillInfo->id, target->GetSkillStep(targetSkillInfo->id), maxLevel, maxLevel);
handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str());
return true;
}
示例15: HandleLookupSkillCommand
static bool HandleLookupSkillCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
// can be NULL in console call
Player* target = handler->getSelectedPlayer();
std::string namePart = args;
std::wstring wNamePart;
if (!Utf8toWStr(namePart, wNamePart))
return false;
// converting string that we try to find to lower case
wstrToLower(wNamePart);
bool found = false;
uint32 count = 0;
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
// Search in SkillLine.dbc
for (uint32 id = 0; id < sSkillLineStore.GetNumRows(); id++)
{
SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(id);
if (skillInfo)
{
std::string name = skillInfo->name;
if (name.empty())
continue;
if (!Utf8FitTo(name, wNamePart))
continue;
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
char valStr[50] = "";
char const* knownStr = "";
if (target && target->HasSkill(id))
{
knownStr = handler->GetTrinityString(LANG_KNOWN);
uint32 curValue = target->GetPureSkillValue(id);
uint32 maxValue = target->GetPureMaxSkillValue(id);
uint32 permValue = target->GetSkillPermBonusValue(id);
uint32 tempValue = target->GetSkillTempBonusValue(id);
char const* valFormat = handler->GetTrinityString(LANG_SKILL_VALUES);
snprintf(valStr, 50, valFormat, curValue, maxValue, permValue, tempValue);
}
// send skill in "id - [namedlink locale]" format
if (handler->GetSession())
handler->PSendSysMessage(LANG_SKILL_LIST_CHAT, id, id, name.c_str(), "", knownStr, valStr);
else
handler->PSendSysMessage(LANG_SKILL_LIST_CONSOLE, id, name.c_str(), "", knownStr, valStr);
if (!found)
found = true;
}
}
if (!found)
handler->SendSysMessage(LANG_COMMAND_NOSKILLFOUND);
return true;
}