Go to the source code of this file.
Macros | |
#define | UTF8PRINTF(OUT, FRM, RESERR) |
Typedefs | |
typedef std::vector< std::string > | Tokens |
Functions | |
Tokens | StrSplit (const std::string &src, const std::string &sep) |
void | stripLineInvisibleChars (std::string &src) |
std::string | secsToTimeString (uint32 timeInSecs, bool shortText=false, bool hoursOnly=false) |
uint32 | TimeStringToSecs (const std::string ×tring) |
std::string | TimeToTimestampStr (time_t t) |
uint32 | secsToTimeBitFields (time_t secs) |
int32 | irand (int32 min, int32 max) |
uint32 | urand (uint32 min, uint32 max) |
uint32 | rand32 () |
float | frand (float min, float max) |
double | rand_norm () |
double | rand_chance () |
bool | roll_chance_f (float chance) |
bool | roll_chance_i (int chance) |
void | ApplyModUInt32Var (uint32 &var, int32 val, bool apply) |
void | ApplyModFloatVar (float &var, float val, bool apply) |
void | ApplyPercentModFloatVar (float &var, float val, bool apply) |
template<class T , class U > | |
T | CalculatePct (T base, U pct) |
template<class T , class U > | |
T | AddPct (T &base, U pct) |
template<class T , class U > | |
T | ApplyPct (T &base, U pct) |
template<class T > | |
T | RoundToInterval (T &num, T floor, T ceil) |
bool | Utf8toWStr (const std::string &utf8str, std::wstring &wstr) |
bool | Utf8toWStr (char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize) |
bool | Utf8toWStr (const std::string &utf8str, wchar_t *wstr, size_t &wsize) |
bool | WStrToUtf8 (std::wstring wstr, std::string &utf8str) |
bool | WStrToUtf8 (wchar_t *wstr, size_t size, std::string &utf8str) |
size_t | utf8length (std::string &utf8str) |
void | utf8truncate (std::string &utf8str, size_t len) |
bool | isBasicLatinCharacter (wchar_t wchar) |
bool | isExtendedLatinCharacter (wchar_t wchar) |
bool | isCyrillicCharacter (wchar_t wchar) |
bool | isEastAsianCharacter (wchar_t wchar) |
bool | isNumeric (wchar_t wchar) |
bool | isNumeric (char c) |
bool | isNumericOrSpace (wchar_t wchar) |
bool | isNumeric (char const *str) |
bool | isBasicLatinString (std::wstring wstr, bool numericOrSpace) |
bool | isExtendedLatinString (std::wstring wstr, bool numericOrSpace) |
bool | isCyrillicString (std::wstring wstr, bool numericOrSpace) |
bool | isEastAsianString (std::wstring wstr, bool numericOrSpace) |
wchar_t | wcharToUpper (wchar_t wchar) |
wchar_t | wcharToUpperOnlyLatin (wchar_t wchar) |
wchar_t | wcharToLower (wchar_t wchar) |
void | wstrToUpper (std::wstring &str) |
void | wstrToLower (std::wstring &str) |
std::wstring | GetMainPartOfName (std::wstring wname, uint32 declension) |
bool | utf8ToConsole (const std::string &utf8str, std::string &conStr) |
bool | consoleToUtf8 (const std::string &conStr, std::string &utf8str) |
bool | Utf8FitTo (const std::string &str, std::wstring search) |
void | hexEncodeByteArray (uint8 *bytes, uint32 arrayLen, std::string &result) |
std::string | ByteArrayToHexStr (uint8 *bytes, uint32 length) |
bool | IsIPAddress (char const *ipaddress) |
uint32 | CreatePIDFile (const std::string &filename) |
template<class C > | |
C::value_type const & | SelectRandomContainerElement (C const &container) |
#define UTF8PRINTF | ( | OUT, | |
FRM, | |||
RESERR | |||
) |
|
inline |
Definition at line 103 of file Util.h.
References CalculatePct().
Referenced by HostileReference::addThreatPercent(), Unit::CalculateMeleeDamage(), Unit::CalculateSpellDamageTaken(), Unit::MeleeDamageBonus(), Creature::RegenerateHealth(), Creature::RegenerateMana(), Battleground::RewardReputationToTeam(), Unit::SpellCriticalBonus(), Unit::SpellDamageBonus(), and Unit::UpdateSpeed().
|
inline |
|
inline |
|
inline |
Definition at line 88 of file Util.h.
Referenced by Unit::ApplyAttackTimePercentMod(), Object::ApplyPercentModFloatValue(), Aura::HandleAuraModScale(), Player::HandleBaseModValue(), Aura::HandleModThreat(), and Unit::HandleStatModifier().
Definition at line 454 of file Util.cpp.
Referenced by WardenMac::Init(), WardenWin::Init(), and wstrToLower().
|
inline |
Definition at line 97 of file Util.h.
Referenced by AddPct(), ApplyPct(), Player::ApplySpellMod(), Unit::CalcAbsorbResist(), Pet::CastPetAura(), Unit::CountPctFromCurHealth(), Unit::CountPctFromMaxHealth(), ThreatManager::doAddThreat(), AuctionEntry::GetAuctionCut(), AuctionEntry::GetAuctionOutBid(), Aura::HandleModPowerCostPCT(), Unit::HandleProcTriggerSpell(), Guardian::UpdateArmor(), Player::UpdateArmor(), Player::UpdateAttackPowerAndDamage(), Player::UpdateManaRegen(), Guardian::UpdateResistances(), and Guardian::UpdateStats().
bool consoleToUtf8 | ( | const std::string & | conStr, |
std::string & | utf8str | ||
) |
uint32 CreatePIDFile | ( | const std::string & | filename | ) |
float frand | ( | float | min, |
float | max | ||
) |
Definition at line 38 of file Util.cpp.
Referenced by FleeingMovementGenerator< T >::_getPoint(), and secsToTimeBitFields().
std::wstring GetMainPartOfName | ( | std::wstring | wname, |
uint32 | declension | ||
) |
Definition at line 341 of file Util.cpp.
References isCyrillicCharacter().
Referenced by ObjectMgr::CheckDeclinedNames(), WorldSession::HandleDeclinedPlayerNameOpcode(), WorldSession::HandlePetRename(), and wstrToLower().
Definition at line 435 of file Util.cpp.
Referenced by AccountMgr::CalculateShaPassHash(), and wstrToLower().
Definition at line 28 of file Util.cpp.
Referenced by Unit::CalculateSpellDamage(), Spell::CheckCast(), WorldSession::DoLootRelease(), Spell::EffectDummy(), Spell::EffectTeleportUnits(), GetItemEnchantMod(), Unit::HandleDummyAuraProc(), Unit::MagicSpellHitResult(), LootTemplate::LootGroup::Roll(), roll_chance_i(), secsToTimeBitFields(), Spell::SpellDamageSchoolDmg(), Player::UpdateSkillPro(), and GameObject::Use().
|
inline |
Definition at line 136 of file Util.h.
Referenced by isBasicLatinString(), isExtendedLatinCharacter(), and wcharToUpperOnlyLatin().
|
inline |
Definition at line 220 of file Util.h.
References isBasicLatinCharacter(), and isNumericOrSpace().
Referenced by isValidString().
|
inline |
Definition at line 166 of file Util.h.
Referenced by GetMainPartOfName(), WorldSession::HandleDeclinedPlayerNameOpcode(), and isCyrillicString().
|
inline |
Definition at line 236 of file Util.h.
References isCyrillicCharacter(), and isNumericOrSpace().
Referenced by isValidString().
|
inline |
|
inline |
Definition at line 244 of file Util.h.
References isEastAsianCharacter(), and isNumericOrSpace().
Referenced by isValidString().
|
inline |
Definition at line 145 of file Util.h.
References isBasicLatinCharacter().
Referenced by isExtendedLatinString().
|
inline |
Definition at line 228 of file Util.h.
References isExtendedLatinCharacter(), and isNumericOrSpace().
Referenced by isValidString().
bool IsIPAddress | ( | char const * | ipaddress | ) |
Definition at line 192 of file Util.cpp.
Referenced by ChatHandler::HandleBanHelper(), ChatHandler::HandleBanInfoIPCommand(), and ChatHandler::HandleUnBanHelper().
|
inline |
Definition at line 196 of file Util.h.
Referenced by ChatHandler::GetDeletedCharacterInfoList(), ChatHandler::HandleCharacterDeletedOldCommand(), ChatHandler::HandleWritePDumpCommand(), isNumeric(), and isNumericOrSpace().
|
inline |
|
inline |
|
inline |
Definition at line 206 of file Util.h.
References isNumeric().
Referenced by isBasicLatinString(), isCyrillicString(), isEastAsianString(), and isExtendedLatinString().
uint32 rand32 | ( | ) |
Definition at line 43 of file Util.cpp.
Referenced by WardenWin::RequestData(), secsToTimeBitFields(), and Spell::SpellDamageSchoolDmg().
double rand_chance | ( | ) |
Definition at line 53 of file Util.cpp.
Referenced by GetItemEnchantMod(), ChatHandler::HandleGMTicketCloseByIdCommand(), LootTemplate::LootGroup::Roll(), roll_chance_f(), PoolGroup< T >::RollOne(), and secsToTimeBitFields().
double rand_norm | ( | ) |
Definition at line 48 of file Util.cpp.
Referenced by RandomMovementGenerator< T >::_setRandomLocation(), Spell::EffectTransmitted(), Unit::GetRandomContactPoint(), WorldObject::GetRandomNearPosition(), WorldObject::GetRandomPoint(), Position::GetSinCos(), Spell::GetSummonPosition(), Weather::ReGenerate(), secsToTimeBitFields(), Spell::SetTargetMap(), and ConfusedMovementGenerator< T >::Update().
|
inline |
Definition at line 61 of file Util.h.
References rand_chance().
Referenced by Player::CastItemCombatSpell(), Unit::DealDamage(), Unit::DealMeleeDamage(), Spell::DoCreateItem(), WorldSession::DoLootRelease(), GetSkillDiscoverySpell(), Unit::HandleDummyAuraProc(), Unit::HandleProcTriggerSpell(), Unit::isSpellBlocked(), Unit::isSpellCrit(), Unit::IsTriggeredAtSpellProcEvent(), Unit::RemoveSpellbyDamageTaken(), LootStoreItem::Roll(), Aura::TriggerSpell(), and Player::UpdateCombatSkills().
|
inline |
Definition at line 67 of file Util.h.
References irand().
Referenced by RandomMovementGenerator< T >::_setRandomLocation(), Unit::CalcAbsorbResist(), Spell::Delayed(), Spell::DelayedChannel(), Spell::DoSpellHitOnUnit(), Spell::EffectDispel(), Spell::EffectDummy(), Spell::EffectResurrect(), Spell::EffectScriptEffect(), Spell::EffectStealBeneficialBuff(), Spell::EffectTeleportUnits(), Player::GetResurrectionSpellId(), Aura::HandleAuraDummy(), Unit::HandleDummyAuraProc(), Unit::HandleOverrideClassScriptAuraProc(), Aura::PeriodicDummyTick(), SmartScript::ProcessAction(), Unit::RollMeleeOutcomeAgainst(), Unit::SpellHitResult(), and Player::Update().
|
inline |
Definition at line 115 of file Util.h.
References Utf8toWStr().
|
inline |
Definition at line 36 of file Util.h.
References frand(), irand(), rand32(), rand_chance(), rand_norm(), and urand().
Referenced by AuctionHouseMgr::SendAuctionSalePendingMail(), and Player::SendInitialPacketsBeforeAddToMap().
Definition at line 109 of file Util.cpp.
References DAY, HOUR, and MINUTE.
Referenced by ChatHandler::HandleBanHelper(), ChatHandler::HandleBanInfoHelper(), ChatHandler::HandleBanInfoIPCommand(), ChatHandler::HandleEventInfoCommand(), ChatHandler::HandleGMTicketGetByIdCommand(), ChatHandler::HandleGMTicketGetByNameCommand(), ChatHandler::HandleGMTicketListClosedCommand(), ChatHandler::HandleGMTicketListCommand(), ChatHandler::HandleGMTicketListOnlineCommand(), WorldSession::HandleMessagechatOpcode(), ChatHandler::HandleNpcInfoCommand(), ChatHandler::HandlePInfoCommand(), ChatHandler::HandleServerInfoCommand(), ChatHandler::HandleTargetObjectCommand(), WorldSession::HandleTextEmoteOpcode(), and World::ShutdownMsg().
C::value_type const& SelectRandomContainerElement | ( | C const & | container | ) |
Definition at line 352 of file Util.h.
References urand().
Referenced by Unit::SelectNearbyTarget(), UnitAI::SelectTarget(), and PoolGroup< Quest >::SpawnObject().
void stripLineInvisibleChars | ( | std::string & | src | ) |
Definition at line 76 of file Util.cpp.
Referenced by WorldSession::processChatmessageFurtherAfterSecurityChecks().
Tokens StrSplit | ( | const std::string & | src, |
const std::string & | sep | ||
) |
Definition at line 58 of file Util.cpp.
Referenced by InstanceSaveManager::_DelHelper(), Object::_LoadIntoDataField(), Player::BuildEnumData(), AHBConfig::IgnoreItemsIds(), Database::Initialize(), DisableMgr::LoadDisables(), Item::LoadFromDB(), Pet::LoadPetFromDB(), PlayerTaxi::LoadTaxiDestinationsFromString(), PlayerTaxi::LoadTaxiMask(), Object::LoadValues(), Player::LoadValuesArrayFromDB(), and RealmList::UpdateRealm().
uint32 TimeStringToSecs | ( | const std::string & | timestring | ) |
Definition at line 132 of file Util.cpp.
References DAY, HOUR, and MINUTE.
Referenced by World::BanAccount(), and ChatHandler::HandleBanHelper().
std::string TimeToTimestampStr | ( | time_t | t | ) |
Definition at line 177 of file Util.cpp.
References snprintf.
Referenced by ChatHandler::HandleCharacterDeletedListHelper(), and ChatHandler::HandleEventInfoCommand().
Definition at line 33 of file Util.cpp.
Referenced by RandomMovementGenerator< T >::_setRandomLocation(), FleeingMovementGenerator< T >::_setTargetLocation(), TargetedMovementGeneratorMedium< T, D >::_setTargetLocation(), BattlegroundAV::AddAVCreature(), AuctionHouseBot::addNewAuctionBuyerBotBid(), AuctionHouseBot::addNewAuctions(), Unit::CalcAbsorbResist(), Unit::CalculateDamage(), BattlegroundAV::ChangeMineOwner(), Spell::CheckCast(), Pet::CheckLearning(), Group::CountTheRoll(), SimpleAI::DamageTaken(), Unit::DealDamage(), Spell::EffectDispel(), Spell::EffectDummy(), Spell::EffectEnergize(), Spell::EffectScriptEffect(), Spell::EffectStealBeneficialBuff(), Spell::EffectTeleportUnits(), Spell::EffectTransmitted(), SimpleAI::EnterCombat(), Loot::generateMoneyLoot(), ObjectMgr::GeneratePetName(), ObjectMgr::GetCreatureModelRandomGender(), Player::GetNextRandomRaidMember(), CreatureInfo::GetRandomValidModelId(), ObjectMgr::GetTaxiMount(), Aura::HandleAuraDummy(), Aura::HandleAuraModShapeshift(), Player::HandleDrowning(), WorldSession::HandlePetActionHelper(), WorldSession::HandlePetCastSpellOpcode(), WorldSession::HandleRandomRollOpcode(), Battleground::HandleTriggerBuff(), ChaseMovementGenerator< T >::Initialize(), FollowMovementGenerator< T >::Initialize(), SimpleAI::KilledUnit(), Player::LoadFromDB(), LootItem::LootItem(), Unit::MagicSpellHitResult(), Unit::MeleeSpellHitResult(), SmartScript::ProcessAction(), CreatureEventAI::ProcessAction(), RAND(), Oregon::RandomResizeList(), SmartScript::RecalcTimer(), Weather::ReGenerate(), EventMap::Repeat(), BattlegroundAV::ResetBGSubclass(), Player::RewardHonor(), Unit::RollMeleeOutcomeAgainst(), PoolGroup< T >::RollOne(), secsToTimeBitFields(), Creature::SelectLevel(), SelectRandomContainerElement(), UnitAI::SelectTargetList(), CreatureTextMgr::SendChat(), Player::SendLoot(), BattlegroundAB::StartingEventOpenDoors(), BattlegroundEY::StartingEventOpenDoors(), ConfusedMovementGenerator< T >::Update(), BattlegroundQueue::Update(), WaypointMovementGenerator< T >::Update(), Creature::Update(), BattlegroundAV::Update(), PetAI::UpdateAI(), SimpleAI::UpdateAI(), CreatureEventAIHolder::UpdateRepeatTimer(), and Player::UpdateSkill().
bool Utf8FitTo | ( | const std::string & | str, |
std::wstring | search | ||
) |
Definition at line 419 of file Util.cpp.
References Utf8toWStr(), and wstrToLower().
Referenced by AuctionHouseObject::BuildListAuctionItems(), ChatHandler::HandleLearnAllRecipesCommand(), ChatHandler::HandleLookupAreaCommand(), ChatHandler::HandleLookupCreatureCommand(), ChatHandler::HandleLookupEventCommand(), ChatHandler::HandleLookupFactionCommand(), ChatHandler::HandleLookupItemCommand(), ChatHandler::HandleLookupItemSetCommand(), ChatHandler::HandleLookupObjectCommand(), ChatHandler::HandleLookupQuestCommand(), ChatHandler::HandleLookupSkillCommand(), ChatHandler::HandleLookupSpellCommand(), ChatHandler::HandleLookupTitleCommand(), WorldSession::HandleWhoOpcode(), and wstrToLower().
size_t utf8length | ( | std::string & | utf8str | ) |
Definition at line 221 of file Util.cpp.
Referenced by AccountMgr::ChangePassword(), AccountMgr::ChangeUsername(), AccountMgr::CreateAccount(), and Utf8toWStr().
bool utf8ToConsole | ( | const std::string & | utf8str, |
std::string & | conStr | ||
) |
Definition at line 387 of file Util.cpp.
References Utf8toWStr().
Referenced by wstrToLower().
bool Utf8toWStr | ( | const std::string & | utf8str, |
std::wstring & | wstr | ||
) |
bool Utf8toWStr | ( | char const * | utf8str, |
size_t | csize, | ||
wchar_t * | wstr, | ||
size_t & | wsize | ||
) |
Definition at line 255 of file Util.cpp.
Referenced by ObjectMgr::AddGameTele(), ObjectMgr::CheckDeclinedNames(), ObjectMgr::DeleteGameTele(), Log::DoLog(), ObjectMgr::GetGameTele(), WorldSession::HandleAuctionListItems(), WorldSession::HandleDeclinedPlayerNameOpcode(), ChatHandler::HandleLearnAllRecipesCommand(), ChatHandler::HandleLookupAreaCommand(), ChatHandler::HandleLookupCreatureCommand(), ChatHandler::HandleLookupEventCommand(), ChatHandler::HandleLookupFactionCommand(), ChatHandler::HandleLookupItemCommand(), ChatHandler::HandleLookupItemSetCommand(), ChatHandler::HandleLookupObjectCommand(), ChatHandler::HandleLookupQuestCommand(), ChatHandler::HandleLookupSkillCommand(), ChatHandler::HandleLookupSpellCommand(), ChatHandler::HandleLookupTeleCommand(), ChatHandler::HandleLookupTitleCommand(), ChatHandler::HandleModifyRepCommand(), WorldSession::HandlePetRename(), WorldSession::HandleWhoOpcode(), ObjectMgr::IsValidCharterName(), ObjectMgr::IsValidName(), ObjectMgr::IsValidPetName(), ObjectMgr::LoadGameTele(), normalizePlayerName(), AccountMgr::normalizeString(), Utf8FitTo(), and utf8ToConsole().
|
inline |
Definition at line 124 of file Util.h.
References utf8length(), Utf8toWStr(), utf8truncate(), and WStrToUtf8().
void utf8truncate | ( | std::string & | utf8str, |
size_t | len | ||
) |
Definition at line 234 of file Util.cpp.
Referenced by PlayerSocial::SetFriendNote(), Guild::SetGuildBankTabText(), and Utf8toWStr().
|
inline |
Definition at line 280 of file Util.h.
Referenced by normalizePlayerName(), and wstrToLower().
|
inline |
Definition at line 252 of file Util.h.
Referenced by normalizePlayerName(), wcharToUpperOnlyLatin(), and wstrToUpper().
|
inline |
Definition at line 275 of file Util.h.
References isBasicLatinCharacter(), and wcharToUpper().
Referenced by AccountMgr::normalizeString().
|
inline |
Definition at line 308 of file Util.h.
References ByteArrayToHexStr(), consoleToUtf8(), GetMainPartOfName(), hexEncodeByteArray(), Utf8FitTo(), utf8ToConsole(), and wcharToLower().
Referenced by ObjectMgr::AddGameTele(), ObjectMgr::DeleteGameTele(), ObjectMgr::GetGameTele(), WorldSession::HandleAuctionListItems(), ChatHandler::HandleLearnAllRecipesCommand(), ChatHandler::HandleLookupAreaCommand(), ChatHandler::HandleLookupCreatureCommand(), ChatHandler::HandleLookupEventCommand(), ChatHandler::HandleLookupFactionCommand(), ChatHandler::HandleLookupItemCommand(), ChatHandler::HandleLookupItemSetCommand(), ChatHandler::HandleLookupObjectCommand(), ChatHandler::HandleLookupQuestCommand(), ChatHandler::HandleLookupSkillCommand(), ChatHandler::HandleLookupSpellCommand(), ChatHandler::HandleLookupTeleCommand(), ChatHandler::HandleLookupTitleCommand(), ChatHandler::HandleModifyRepCommand(), WorldSession::HandleWhoOpcode(), ObjectMgr::LoadGameTele(), and Utf8FitTo().
|
inline |
bool WStrToUtf8 | ( | std::wstring | wstr, |
std::string & | utf8str | ||
) |
bool WStrToUtf8 | ( | wchar_t * | wstr, |
size_t | size, | ||
std::string & | utf8str | ||
) |
Definition at line 299 of file Util.cpp.
Referenced by consoleToUtf8(), normalizePlayerName(), AccountMgr::normalizeString(), and WheatyExceptionReport::WriteStackDetails().