|
Project SkyFire Core
SkyFire 5.4.8 server core API documentation
|
#include "Common.h"#include "Errors.h"#include "Platform/TimeUtils.h"#include "sfmt.h"#include "utf8.h"#include "Util.h"#include <atomic>#include <cstdarg>#include <random>Go to the source code of this file.
Typedefs | |
| typedef wchar_t const *const * | wstrlist |
Functions | |
| bool | consoleToUtf8 (const std::string &conStr, std::string &utf8str) |
| uint32 | CreatePIDFile (const std::string &filename) |
| create PID file | |
| float | frand (float min, float max) |
| std::string | GetAddressString (Skyfire::Net::Address const &addr) |
| Transforms network address into string format "dotted_ip:port". | |
| std::wstring | GetMainPartOfName (std::wstring wname, uint32 declension) |
| bool | IsIPAddress (char const *ipaddress) |
| Check if the string is a valid ip address representation. | |
| bool | IsIPAddrInNetwork (Skyfire::Net::Address const &net, Skyfire::Net::Address const &addr, Skyfire::Net::Address const &subnetMask) |
| Checks if address belongs to the a network with specified submask. | |
| int64 | MoneyStringToMoney (const std::string &moneyString) |
| int32 | rand32 () |
| double | rand_chance (void) |
| double | rand_norm (void) |
| std::string | secsToTimeString (uint64 timeInSecs, bool shortText, bool hoursOnly) |
| static CRandomSFMT & | SfmtRand () |
| void | stripLineInvisibleChars (std::string &str) |
| uint32 | TimeStringToSecs (const std::string ×tring) |
| std::string | TimeToTimestampStr (time_t t) |
| bool | Utf8FitTo (const std::string &str, const std::wstring &search) |
| size_t | utf8length (std::string &utf8str) |
| void | utf8printf (FILE *out, const char *str,...) |
| bool | utf8ToConsole (const std::string &utf8str, std::string &conStr) |
| bool | Utf8toWStr (char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize) |
| bool | Utf8toWStr (const std::string &utf8str, std::wstring &wstr) |
| void | utf8truncate (std::string &utf8str, size_t len) |
| void | vutf8printf (FILE *out, const char *str, va_list *ap) |
| bool | WStrToUtf8 (const std::wstring &wstr, std::string &utf8str) |
| bool | WStrToUtf8 (wchar_t *wstr, size_t size, std::string &utf8str) |
| bool consoleToUtf8 | ( | const std::string & | conStr, |
| std::string & | utf8str ) |
| uint32 CreatePIDFile | ( | const std::string & | filename | ) |
| float frand | ( | float | min, |
| float | max ) |
Definition at line 39 of file Util.cpp.
References ASSERT, and SfmtRand().
Referenced by FleeingMovementGenerator< T >::_getPoint(), SpellEffectInfo::CalcValue(), GetRandPosFromCenterInDist(), spell_item_unusual_compass::spell_item_unusual_compass_SpellScript::HandleDummy(), spell_malygos_random_portal::spell_malygos_random_portal_SpellScript::HandleDummy(), boss_sara::boss_saraAI::JustSummoned(), spell_q12308_escape_from_silverbrook_summon_worgen::spell_q12308_escape_from_silverbrook_summon_worgen_SpellScript::ModDest(), npc_unleashed_ballAI::MoveToNextPoint(), spell_ulduar_stone_grip::spell_ulduar_stone_grip_AuraScript::OnRemoveVehicle(), npc_lake_frog::npc_lake_frogAI::ReceiveEmote(), npc_firework::npc_fireworkAI::Reset(), boss_jormungarAI::Submerge(), boss_malchezaar::boss_malchezaarAI::SummonInfernal(), boss_ancient_stone_keeper::boss_ancient_stone_keeperAI::UpdateAI(), npc_ashtongue_sorcerer::npc_ashtongue_sorcererAI::UpdateAI(), and npc_shu_pool_of_reflection::npc_shu_pool_of_reflectionAI::UpdateAI().
| std::string GetAddressString | ( | Skyfire::Net::Address const & | addr | ) |
Transforms network address into string format "dotted_ip:port".
Definition at line 237 of file Util.cpp.
References Skyfire::Net::Address::GetHost(), and Skyfire::Net::Address::GetPort().
Referenced by AuthSocket::_HandleRealmList().
| std::wstring GetMainPartOfName | ( | std::wstring | wname, |
| uint32 | declension ) |
Definition at line 396 of file Util.cpp.
References isCyrillicCharacter().
Referenced by ObjectMgr::CheckDeclinedNames().
| bool IsIPAddress | ( | char const * | ipaddress | ) |
Check if the string is a valid ip address representation.
Definition at line 229 of file Util.cpp.
References Skyfire::Net::IsIPv4Address().
Referenced by ban_commandscript::HandleBanHelper(), ban_commandscript::HandleBanInfoIPCommand(), and ban_commandscript::HandleUnBanHelper().
| bool IsIPAddrInNetwork | ( | Skyfire::Net::Address const & | net, |
| Skyfire::Net::Address const & | addr, | ||
| Skyfire::Net::Address const & | subnetMask ) |
Checks if address belongs to the a network with specified submask.
Definition at line 244 of file Util.cpp.
References Skyfire::Net::Address::ToIPv4NetworkOrder().
Referenced by AuthSocket::GetAddressForClient().
| int64 MoneyStringToMoney | ( | const std::string & | moneyString | ) |
Definition at line 150 of file Util.cpp.
References Tokenizer::begin(), and Tokenizer::end().
Referenced by modify_commandscript::HandleModifyMoneyCommand().
| int32 rand32 | ( | ) |
Definition at line 45 of file Util.cpp.
References SfmtRand().
Referenced by Player::GetRandomResearchProjectForRace(), and Player::OnArchaeologyFindUsed().
| double rand_chance | ( | void | ) |
Definition at line 55 of file Util.cpp.
References SfmtRand().
Referenced by Spell::EffectInebriate(), GetExplicitDiscoverySpell(), GetItemEnchantMod(), WorldSession::HandleGMResponseResolve(), LootTemplate::LootGroup::Roll(), roll_chance_f(), and PoolGroup< T >::RollOne().
| double rand_norm | ( | void | ) |
Definition at line 50 of file Util.cpp.
References SfmtRand().
Referenced by RandomMovementGenerator< T >::_setRandomLocation(), SpellImplicitTargetInfo::CalcDirectionAngle(), Unit::CalcSpellResistance(), ConfusedMovementGenerator< T >::DoUpdate(), Spell::EffectTransmitted(), Unit::GetRandomContactPoint(), WorldObject::GetRandomNearPosition(), WorldObject::GetRandomPoint(), Position::GetSinCos(), molten_flame::molten_flameAI::InitializeAI(), Weather::ReGenerate(), spell_sindragosa_s_fury::spell_sindragosa_s_fury_SpellScript::SelectDest(), Spell::SelectImplicitCasterDestTargets(), Spell::SelectImplicitDestDestTargets(), Spell::SelectImplicitTargetDestTargets(), spell_omega_stance_spider_effect::spell_omega_stance_spider_effect_SpellScript::SetDestPosition(), boss_sindragosa::boss_sindragosaAI::UpdateAI(), and npc_strangulate_vehicle::npc_strangulate_vehicleAI::UpdateAI().
| std::string secsToTimeString | ( | uint64 | timeInSecs, |
| bool | shortText, | ||
| bool | hoursOnly ) |
Definition at line 127 of file Util.cpp.
References DAY, HOUR, and MINUTE.
Referenced by BugTicket::FormatMessageString(), GmTicket::FormatMessageString(), SuggestTicket::FormatMessageString(), ban_commandscript::HandleBanCharacterCommand(), ban_commandscript::HandleBanHelper(), ban_commandscript::HandleBanInfoCharacterCommand(), ban_commandscript::HandleBanInfoHelper(), ban_commandscript::HandleBanInfoIPCommand(), event_commandscript::HandleEventInfoCommand(), gobject_commandscript::HandleGameObjectTargetCommand(), WorldSession::HandleMessagechatOpcode(), npc_commandscript::HandleNpcInfoCommand(), misc_commandscript::HandlePInfoCommand(), server_commandscript::HandleServerInfoCommand(), server_commandscript::HandleServerUptimeCommand(), WorldSession::HandleTextEmoteOpcode(), GmTicket::SetChatLog(), World::ShutdownMsg(), and Warden::Update().
|
static |
Definition at line 33 of file Util.cpp.
Referenced by frand(), rand32(), rand_chance(), and rand_norm().
| void stripLineInvisibleChars | ( | std::string & | str | ) |
Definition at line 94 of file Util.cpp.
Referenced by WorldSession::HandleMessagechatOpcode().
| uint32 TimeStringToSecs | ( | const std::string & | timestring | ) |
Definition at line 181 of file Util.cpp.
References DAY, HOUR, and MINUTE.
Referenced by World::BanAccount(), World::BanCharacter(), ban_commandscript::HandleBanCharacterCommand(), and ban_commandscript::HandleBanHelper().
| std::string TimeToTimestampStr | ( | time_t | t | ) |
Definition at line 213 of file Util.cpp.
References Skyfire::LocalTime().
Referenced by character_commandscript::HandleCharacterDeletedListHelper(), event_commandscript::HandleEventInfoCommand(), and list_commandscript::HandleListMailCommand().
| bool Utf8FitTo | ( | const std::string & | str, |
| const std::wstring & | search ) |
Definition at line 473 of file Util.cpp.
References Utf8toWStr(), and wstrToLower().
Referenced by AuctionHouseObject::BuildListAuctionItems(), learn_commandscript::HandleLearnAllRecipesCommand(), lookup_commandscript::HandleLookupAreaCommand(), lookup_commandscript::HandleLookupCreatureCommand(), lookup_commandscript::HandleLookupEventCommand(), lookup_commandscript::HandleLookupFactionCommand(), lookup_commandscript::HandleLookupItemCommand(), lookup_commandscript::HandleLookupItemSetCommand(), lookup_commandscript::HandleLookupMapCommand(), lookup_commandscript::HandleLookupObjectCommand(), lookup_commandscript::HandleLookupQuestCommand(), lookup_commandscript::HandleLookupSkillCommand(), lookup_commandscript::HandleLookupSpellCommand(), lookup_commandscript::HandleLookupTaxiNodeCommand(), lookup_commandscript::HandleLookupTitleCommand(), and WorldSession::HandleWhoOpcode().
| size_t utf8length | ( | std::string & | utf8str | ) |
Definition at line 271 of file Util.cpp.
Referenced by AccountMgr::ChangeEmail(), AccountMgr::ChangePassword(), AccountMgr::ChangeRegEmail(), AccountMgr::ChangeUsername(), and AccountMgr::CreateAccount().
| void utf8printf | ( | FILE * | out, |
| const char * | str, | ||
| ... ) |
Definition at line 489 of file Util.cpp.
References vutf8printf().
Referenced by AppenderConsole::_write().
| bool utf8ToConsole | ( | const std::string & | utf8str, |
| std::string & | conStr ) |
Definition at line 441 of file Util.cpp.
References Utf8toWStr().
| bool Utf8toWStr | ( | char const * | utf8str, |
| size_t | csize, | ||
| wchar_t * | wstr, | ||
| size_t & | wsize ) |
Definition at line 305 of file Util.cpp.
Referenced by ObjectMgr::AddGameTele(), ObjectMgr::CheckDeclinedNames(), ObjectMgr::CheckPetName(), ObjectMgr::CheckPlayerName(), ObjectMgr::DeleteGameTele(), ChannelMgr::GetChannel(), ObjectMgr::GetGameTele(), ObjectMgr::GetGameTeleExactName(), ChannelMgr::GetJoinChannel(), WorldSession::HandleAuctionListItems(), learn_commandscript::HandleLearnAllRecipesCommand(), lookup_commandscript::HandleLookupAreaCommand(), lookup_commandscript::HandleLookupCreatureCommand(), lookup_commandscript::HandleLookupEventCommand(), lookup_commandscript::HandleLookupFactionCommand(), lookup_commandscript::HandleLookupItemCommand(), lookup_commandscript::HandleLookupItemSetCommand(), lookup_commandscript::HandleLookupMapCommand(), lookup_commandscript::HandleLookupObjectCommand(), lookup_commandscript::HandleLookupQuestCommand(), lookup_commandscript::HandleLookupSkillCommand(), lookup_commandscript::HandleLookupSpellCommand(), lookup_commandscript::HandleLookupTaxiNodeCommand(), lookup_commandscript::HandleLookupTeleCommand(), lookup_commandscript::HandleLookupTitleCommand(), modify_commandscript::HandleModifyRepCommand(), WorldSession::HandleSetPlayerDeclinedNames(), WorldSession::HandleWhoOpcode(), ObjectMgr::IsReservedName(), ObjectMgr::IsValidCharterName(), ChannelMgr::LeftChannel(), ObjectMgr::LoadGameTele(), ObjectMgr::LoadReservedPlayersNames(), normalizePlayerName(), AccountMgr::normalizeString(), Utf8FitTo(), utf8print(), utf8ToConsole(), and vutf8printf().
| bool Utf8toWStr | ( | const std::string & | utf8str, |
| std::wstring & | wstr ) |
Definition at line 333 of file Util.cpp.
Referenced by Utf8toWStr().
| void utf8truncate | ( | std::string & | utf8str, |
| size_t | len ) |
Definition at line 284 of file Util.cpp.
Referenced by PlayerSocial::SetFriendNote(), and Guild::BankTab::SetText().
| void vutf8printf | ( | FILE * | out, |
| const char * | str, | ||
| va_list * | ap ) |
Definition at line 497 of file Util.cpp.
References Utf8toWStr(), and vsnprintf.
Referenced by utf8printf().
| bool WStrToUtf8 | ( | const std::wstring & | wstr, |
| std::string & | utf8str ) |
| bool WStrToUtf8 | ( | wchar_t * | wstr, |
| size_t | size, | ||
| std::string & | utf8str ) |
Definition at line 348 of file Util.cpp.
Referenced by consoleToUtf8(), normalizePlayerName(), and AccountMgr::normalizeString().