本文整理汇总了C++中TRINITY_READ_GUARD函数的典型用法代码示例。如果您正苦于以下问题:C++ TRINITY_READ_GUARD函数的具体用法?C++ TRINITY_READ_GUARD怎么用?C++ TRINITY_READ_GUARD使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TRINITY_READ_GUARD函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TRINITY_READ_GUARD
void ObjectAccessor::SaveAllPlayers()
{
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& m = GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
itr->second->SaveToDB();
}
示例2: TRINITY_READ_GUARD
Player* ObjectAccessor::FindPlayerByName(const char* name)
{
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& m = GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->second->IsInWorld() && strcmp(name, iter->second->GetName()) == 0)
return iter->second;
return NULL;
}
示例3: TRINITY_READ_GUARD
Corpse* ObjectAccessor::GetCorpseForPlayerGUID(uint64 guid)
{
TRINITY_READ_GUARD(ACE_RW_Thread_Mutex, i_corpseLock);
Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid);
if (iter == i_player2corpse.end())
return NULL;
ASSERT(iter->second->GetType() != CORPSE_BONES);
return iter->second;
}
示例4: HandleGMListIngameCommand
static bool HandleGMListIngameCommand(ChatHandler* handler, char const* /*args*/)
{
bool first = true;
bool footer = false;
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
AccountTypes itrSec = itr->second->GetSession()->GetSecurity();
if ((itr->second->IsGameMaster() ||
(itr->second->GetSession()->HasPermission(rbac::RBAC_PERM_COMMANDS_APPEAR_IN_GM_LIST) &&
itrSec <= AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) &&
(!handler->GetSession() || itr->second->IsVisibleGloballyFor(handler->GetSession()->GetPlayer())))
{
if (itr->second->IsSpectator())
continue; // don't show spectators, they're not really gms
if (first)
{
first = false;
footer = true;
handler->SendSysMessage(LANG_GMS_ON_SRV);
handler->SendSysMessage("========================");
}
std::string const& name = itr->second->GetName();
uint8 size = name.size();
uint8 security = itrSec;
uint8 max = ((16 - size) / 2);
uint8 max2 = max;
if ((max + max2 + size) == 16)
max2 = max - 1;
if (handler->GetSession())
handler->PSendSysMessage("| %s GMLevel %u", name.c_str(), security);
else
handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name.c_str(), max2, " ", security);
}
}
if (footer)
handler->SendSysMessage("========================");
if (first)
handler->SendSysMessage(LANG_GMS_NOT_LOGGED);
return true;
}
示例5: HandleResetAllCommand
static bool HandleResetAllCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
std::string caseName = args;
AtLoginFlags atLogin;
// Command specially created as single command to prevent using short case names
if (caseName == "spells")
{
atLogin = AT_LOGIN_RESET_SPELLS;
sWorld->SendWorldText(LANG_RESETALL_SPELLS);
if (!handler->GetSession())
handler->SendSysMessage(LANG_RESETALL_SPELLS);
}
else if (caseName == "talents")
{
atLogin = AtLoginFlags(AT_LOGIN_RESET_TALENTS | AT_LOGIN_RESET_PET_TALENTS);
sWorld->SendWorldText(LANG_RESETALL_TALENTS);
if (!handler->GetSession())
handler->SendSysMessage(LANG_RESETALL_TALENTS);
}
else
{
handler->PSendSysMessage(LANG_RESETALL_UNKNOWN_CASE, args);
handler->SetSentErrorMessage(true);
return false;
}
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ALL_AT_LOGIN_FLAGS);
stmt->setUInt16(0, uint16(atLogin));
CharacterDatabase.Execute(stmt);
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& plist = sObjectAccessor->GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
itr->second->SetAtLoginFlag(atLogin);
return true;
}
示例6: Uninitialize
void Eluna::ReloadEluna()
{
eWorld->SendServerMessage(SERVER_MSG_STRING, "Reloading Eluna...");
Uninitialize();
Initialize();
#ifdef TRINITY
// Re initialize creature AI restoring C++ AI or applying lua AI
{
TRINITY_READ_GUARD(HashMapHolder<Creature>::LockType, *HashMapHolder<Creature>::GetLock());
HashMapHolder<Creature>::MapType const& m = ObjectAccessor::GetCreatures();
for (HashMapHolder<Creature>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
{
iter->second->AIM_Initialize();
}
}
#endif
reload = false;
}
示例7: HandleGMListIngameCommand
static bool HandleGMListIngameCommand(ChatHandler* handler, char const* /*args*/)
{
bool first = true;
bool footer = false;
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
AccountTypes itrSec = itr->second->GetSession()->GetSecurity();
if ((itr->second->isGameMaster() || (!AccountMgr::IsPlayerAccount(itrSec) && itrSec <= AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) &&
(!handler->GetSession() || itr->second->IsVisibleGloballyFor(handler->GetSession()->GetPlayer())))
{
if (first)
{
first = false;
footer = true;
handler->SendSysMessage(LANG_GMS_ON_SRV);
handler->SendSysMessage("========================");
}
char const* name = itr->second->GetName();
uint8 security = itrSec;
if (security == 0)
continue;
uint8 max = ((16 - strlen(name)) / 2);
uint8 max2 = max;
if ((max + max2 + strlen(name)) == 16)
max2 = max - 1;
if (handler->GetSession())
handler->PSendSysMessage("| %s GMLevel %u", name, security);
else
handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security);
}
}
if (footer)
handler->SendSysMessage("========================");
if (first)
handler->SendSysMessage(LANG_GMS_NOT_LOGGED);
return true;
}
示例8: TC_LOG_INFO
void Eluna::StartEluna(bool restart)
{
if (restart)
{
sHookMgr->OnEngineRestart();
TC_LOG_INFO(LOG_FILTER_GENERAL, "Eluna::Restarting Lua Engine");
if (LuaState)
{
// Unregisters and stops all timed events
LuaEventMap::ScriptEventsResetAll();
LuaEventData::RemoveAll();
// Remove bindings
for (std::map<int, std::vector<int> >::iterator itr = ServerEventBindings.begin(); itr != ServerEventBindings.end(); ++itr)
{
for (std::vector<int>::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
luaL_unref(LuaState, LUA_REGISTRYINDEX, (*it));
itr->second.clear();
}
CreatureEventBindings->Clear();
CreatureGossipBindings->Clear();
GameObjectEventBindings->Clear();
GameObjectGossipBindings->Clear();
ItemEventBindings->Clear();
ItemGossipBindings->Clear();
playerGossipBindings->Clear();
lua_close(LuaState);
}
}
else
AddScriptHooks();
LuaState = luaL_newstate();
TC_LOG_INFO(LOG_FILTER_SERVER_LOADING, "Eluna Lua Engine loaded.");
LoadedScripts loadedScripts;
LoadDirectory("scripts", &loadedScripts);
luaL_openlibs(LuaState);
//Register Globals Here
RegisterGlobals(LuaState);
//Register Templates Here
ElunaTemplate<Unit>::Register(LuaState);
ElunaTemplate<GameObject>::Register(LuaState);
ElunaTemplate<Group>::Register(LuaState);
ElunaTemplate<Guild>::Register(LuaState);
ElunaTemplate<QueryResult>::Register(LuaState);
ElunaTemplate<Aura>::Register(LuaState);
ElunaTemplate<WorldPacket>::Register(LuaState);
ElunaTemplate<Item>::Register(LuaState);
ElunaTemplate<Spell>::Register(LuaState);
ElunaTemplate<Quest>::Register(LuaState);
ElunaTemplate<Map>::Register(LuaState);
ElunaTemplate<Corpse>::Register(LuaState);
uint32 count = 0;
char filename[200];
for (std::set<std::string>::const_iterator itr = loadedScripts.luaFiles.begin(); itr != loadedScripts.luaFiles.end(); ++itr)
{
strcpy(filename, itr->c_str());
if (luaL_loadfile(LuaState, filename) != 0)
{
TC_LOG_ERROR(LOG_FILTER_SERVER_LOADING, "Eluna::Error loading `%s`.", itr->c_str());
report(LuaState);
}
else
{
int err = lua_pcall(LuaState, 0, 0, 0);
if (err != 0 && err == LUA_ERRRUN)
{
TC_LOG_ERROR(LOG_FILTER_SERVER_LOADING, "Eluna::Error loading `%s`.", itr->c_str());
report(LuaState);
}
}
++count;
}
if (restart)
{
//! Iterate over every supported source type (creature and gameobject)
//! Not entirely sure how this will affect units in non-loaded grids.
{
TRINITY_READ_GUARD(HashMapHolder<Creature>::LockType, *HashMapHolder<Creature>::GetLock());
HashMapHolder<Creature>::MapType const& m = ObjectAccessor::GetCreatures();
for (HashMapHolder<Creature>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->second->IsInWorld()) // must check?
// if(sEluna->CreatureEventBindings->GetBindMap(iter->second->GetEntry())) // update all AI or just Eluna?
iter->second->AIM_Initialize();
}
}
TC_LOG_INFO(LOG_FILTER_SERVER_LOADING, "Eluna::Loaded %u Lua scripts..", count);
}