本文整理汇总了C++中WorldSession::LogoutPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldSession::LogoutPlayer方法的具体用法?C++ WorldSession::LogoutPlayer怎么用?C++ WorldSession::LogoutPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldSession
的用法示例。
在下文中一共展示了WorldSession::LogoutPlayer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KickPlayer
void ObjectAccessor::KickPlayer(ObjectGuid guid)
{
if (Player* p = HashMapHolder<Player>::Find(guid))
{
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
}
}
示例2: LogoutPlayerBot
void PlayerbotMgr::LogoutPlayerBot(uint64 guid)
{
Player* bot = GetPlayerBot(guid);
if (bot)
{
WorldSession * botWorldSessionPtr = bot->GetSession();
botWorldSessionPtr->LogoutPlayer(true);
delete botWorldSessionPtr;
}
}
示例3: LogoutPlayerBot
// Playerbot mod: logs out a Playerbot.
void PlayerbotMgr::LogoutPlayerBot(ObjectGuid guid)
{
Player* bot = GetPlayerBot(guid);
if (bot)
{
WorldSession* botWorldSessionPtr = bot->GetSession();
m_playerBots.erase(guid); // deletes bot player ptr inside this WorldSession PlayerBotMap
botWorldSessionPtr->LogoutPlayer(true); // this will delete the bot Player object and PlayerbotAI object
delete botWorldSessionPtr; // finally delete the bot's WorldSession
}
}
示例4: DeleteAccount
AccountOpResult DeleteAccount(uint32 accountId)
{
// Check if accounts exists
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_ID);
stmt->setUInt32(0, accountId);
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (!result)
return AOR_NAME_NOT_EXIST;
// Obtain accounts characters
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID);
stmt->setUInt32(0, accountId);
result = CharacterDatabase.Query(stmt);
if (result)
{
do
{
uint32 guidLow = (*result)[0].GetUInt32();
uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
// Kick if player is online
if (Player* p = ObjectAccessor::FindPlayer(guid))
{
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
}
Player::DeleteFromDB(guid, accountId, false); // no need to update realm characters
} while (result->NextRow());
}
// table realm specific but common for all characters of account for realm
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_TUTORIALS);
stmt->setUInt32(0, accountId);
CharacterDatabase.Execute(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_DATA);
stmt->setUInt32(0, accountId);
CharacterDatabase.Execute(stmt);
SQLTransaction trans = LoginDatabase.BeginTransaction();
trans->PAppend("DELETE FROM account WHERE id='%d'", accountId);
trans->PAppend("DELETE FROM account_access WHERE id ='%d'", accountId);
trans->PAppend("DELETE FROM realmcharacters WHERE acctid='%d'", accountId);
LoginDatabase.CommitTransaction(trans);
return AOR_OK;
}
示例5: DestroySession
void ClusterInterface::DestroySession(uint32 sid)
{
WorldSession * s = _sessions[sid];
_sessions[sid] = 0;
if(s)
{
/* todo: replace this with an event so we don't remove from the wrong thread */
if(s->GetPlayer())
s->LogoutPlayer(true);
delete s->GetSocket();
delete s;
}
}
示例6: LogoutPlayerBot
// PlayerBot mod: logs out a Playerbot.
void WorldSession::LogoutPlayerBot(uint64 guid, bool Save)
{
Player *pPlayerBot = GetPlayerBot(guid);
if(pPlayerBot) //log out any playerbots I have
{
//if (pPlayerBot->IsMounted()) pPlayerBot->GetPlayerbotAI()->GetClassAI()->Unmount();
WorldSession *pPlayerBotWorldSession = pPlayerBot->m_session;
m_playerBots.erase(guid); //deletes bot player ptr inside this WorldSession PlayerBotMap
pPlayerBotWorldSession->LogoutPlayer(Save); //logs out the player
delete pPlayerBotWorldSession; //finally delete the bot's WorldSession
}
}
示例7: DeleteAccount
AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
{
QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account_settings WHERE id = '%d'", accid);
if (!result)
return AOR_NAME_NOT_EXIST; // account doesn't exist
delete result;
result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE account = '%d'",accid);
if (result)
{
do
{
Field *fields = result->Fetch();
uint32 guidlo = fields[0].GetUInt32();
uint64 guid = MAKE_NEW_GUID(guidlo, 0, HIGHGUID_PLAYER);
// kick if player currently
if (Player* p = ObjectAccessor::GetObjectInWorld(guid, (Player*)NULL))
{
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
}
Player::DeleteFromDB(guid, accid, false); // no need to update realm characters
} while (result->NextRow());
delete result;
}
// table realm specific but common for all characters of account for realm
CharacterDatabase.PExecute("DELETE FROM character_tutorial WHERE account = '%u'",accid);
CharacterDatabase.PExecute("DELETE FROM account_data WHERE account = '%u'",accid);
loginDatabase.BeginTransaction();
bool res =
loginDatabase.PExecute("DELETE FROM account_settings WHERE id = '%d'", accid) &&
loginDatabase.PExecute("DELETE FROM account_access WHERE id = '%d'", accid) &&
loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid = '%d'", accid);
loginDatabase.CommitTransaction();
if (!res)
return AOR_DB_INTERNAL_ERROR; // unexpected error;
return AOR_OK;
}
示例8: DeleteAccount
AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
{
QueryResult result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid);
if (!result)
return AOR_NAME_NOT_EXIST; // account doesn't exist
// existed characters list
result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE account='%d'", accid);
if (result)
{
do
{
Field* fields = result->Fetch();
uint32 guidlo = fields[0].GetUInt32();
uint64 guid = MAKE_NEW_GUID(guidlo, 0, HIGHGUID_PLAYER);
// kick if player currently
if (Player* p = ObjectAccessor::FindPlayer(guid))
{
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
}
Player::DeleteFromDB(guid, accid, false); // no need to update realm characters
} while (result->NextRow());
}
// table realm specific but common for all characters of account for realm
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_TUTORIALS);
stmt->setUInt32(0, accid);
CharacterDatabase.Execute(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_DATA);
stmt->setUInt32(0, accid);
CharacterDatabase.Execute(stmt);
SQLTransaction trans = LoginDatabase.BeginTransaction();
trans->PAppend("DELETE FROM account WHERE id='%d'", accid);
trans->PAppend("DELETE FROM account_access WHERE id ='%d'", accid);
trans->PAppend("DELETE FROM realmcharacters WHERE acctid='%d'", accid);
LoginDatabase.CommitTransaction(trans);
return AOR_OK;
}
示例9: KickPlayer
void World::KickPlayer(char* playerName)
{
SessionMap::iterator itr, next;
WorldSession *playerToKick = 0;
int y = 0;
while (!playerName[y] == 0)
{
if ((playerName[y] >= 'a') && (playerName[y] <= 'z'))
playerName[y] -= 'a' - 'A';
y++;
}
for (itr = m_sessions.begin(); itr != m_sessions.end(); itr = next)
{
next = itr;
next++;
if(!itr->second)
continue;
Player *player = itr->second->GetPlayer();
if(!player)
continue;
if( player->IsInWorld() )
{
char *tmpPlayerName = new char[strlen(player->GetName()) + 1];
strcpy(tmpPlayerName, player->GetName());
y = 0;
while (!tmpPlayerName[y] == 0)
{
if ((tmpPlayerName[y] >= 'a') && (tmpPlayerName[y] <= 'z'))
tmpPlayerName[y] -= 'a' - 'A';
y++;
}
if (strcmp(playerName, tmpPlayerName) == 0)
playerToKick = itr->second;
delete[] tmpPlayerName;
}
}
if (playerToKick)
{
playerToKick->LogoutPlayer(true);
}
}
示例10: DeleteAccount
AccountOpResult AccountMgr::DeleteAccount(uint32 accountId) {
QueryResult result = LoginDatabase.PQuery(
"SELECT 1 FROM account WHERE id='%d'", accountId);
if (!result)
return AOR_NAME_NOT_EXIST; // account doesn't exist
// existed characters list
result = CharacterDatabase.PQuery(
"SELECT guid FROM characters WHERE account='%d'", accountId);
if (result) {
do {
uint32 guidLow = (*result)[0].GetUInt32();
uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
// kick if player is online
if (Player* p = ObjectAccessor::FindPlayer(guid)) {
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
}
Player::DeleteFromDB(guid, accountId, false); // no need to update realm characters
} while (result->NextRow());
}
// table realm specific but common for all characters of account for realm
CharacterDatabase.PExecute(
"DELETE FROM character_tutorial WHERE account = '%u'", accountId);
CharacterDatabase.PExecute("DELETE FROM account_data WHERE account = '%u'",
accountId);
SQLTransaction trans = LoginDatabase.BeginTransaction();
trans->PAppend("DELETE FROM account WHERE id = '%d'", accountId);
trans->PAppend("DELETE FROM account_access WHERE id = '%d'", accountId);
trans->PAppend("DELETE FROM realmcharacters WHERE acctid = '%d'",
accountId);
LoginDatabase.CommitTransaction(trans);
return AOR_OK;
}
示例11: DeleteAccount
int AccountMgr::DeleteAccount(uint32 accid)
{
QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid);
if(!result)
return 1; // account doesn't exist
delete result;
result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE account='%d'",accid);
if (result)
{
do
{
Field *fields = result->Fetch();
uint32 guidlo = fields[0].GetUInt32();
uint64 guid = MAKE_GUID(guidlo, HIGHGUID_PLAYER);
// kick if player currently
if(Player* p = objmgr.GetPlayer(guid))
{
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
}
Player::DeleteFromDB(guid, accid, false); // no need to update realm characters
} while (result->NextRow());
delete result;
}
loginDatabase.BeginTransaction();
bool res = loginDatabase.PExecute("DELETE FROM account WHERE id='%d'", accid) &&
loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid='%d'", accid);
loginDatabase.CommitTransaction();
if(!res)
return -1; // unexpected error;
return 0;
}
示例12: DeleteAccount
AccountOpResult AccountMgr::DeleteAccount(uint32 accountId)
{
// Check if accounts exists
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_ID);
stmt->setUInt32(0, accountId);
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (!result)
return AccountOpResult::AOR_NAME_NOT_EXIST;
// Obtain accounts characters
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID);
stmt->setUInt32(0, accountId);
result = CharacterDatabase.Query(stmt);
if (result)
{
do
{
ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>((*result)[0].GetUInt64());
// Kick if player is online
if (Player* p = ObjectAccessor::FindConnectedPlayer(guid))
{
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
}
Player::DeleteFromDB(guid, accountId, false); // no need to update realm characters
} while (result->NextRow());
}
// table realm specific but common for all characters of account for realm
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_TUTORIALS);
stmt->setUInt32(0, accountId);
CharacterDatabase.Execute(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_DATA);
stmt->setUInt32(0, accountId);
CharacterDatabase.Execute(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_BAN);
stmt->setUInt32(0, accountId);
CharacterDatabase.Execute(stmt);
SQLTransaction trans = LoginDatabase.BeginTransaction();
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT);
stmt->setUInt32(0, accountId);
trans->Append(stmt);
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS);
stmt->setUInt32(0, accountId);
trans->Append(stmt);
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS);
stmt->setUInt32(0, accountId);
trans->Append(stmt);
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_BANNED);
stmt->setUInt32(0, accountId);
trans->Append(stmt);
LoginDatabase.CommitTransaction(trans);
return AccountOpResult::AOR_OK;
}
示例13: InformationRetreiveCallback
void WorldSocket::InformationRetreiveCallback(WorldPacket & recvData, uint32 requestid)
{
if(requestid != mRequestID)
return;
uint32 error;
recvData >> error;
if(error != 0 || pAuthenticationPacket == NULL)
{
// something happened wrong @ the logon server
OutPacket(SMSG_AUTH_RESPONSE, 1, "\x0D");
return;
}
// Extract account information from the packet.
string AccountName;
const string * ForcedPermissions;
uint32 AccountID;
string GMFlags;
uint8 AccountFlags;
string lang = "enUS";
uint32 i;
recvData >> AccountID >> AccountName >> GMFlags >> AccountFlags;
ForcedPermissions = sLogonCommHandler.GetForcedPermissions(AccountName);
if( ForcedPermissions != NULL )
GMFlags.assign(ForcedPermissions->c_str());
DEBUG_LOG( "WorldSocket","Received information packet from logon: `%s` ID %u (request %u)", AccountName.c_str(), AccountID, mRequestID);
// sLog.outColor(TNORMAL, "\n");
mRequestID = 0;
//Pull the session key.
recvData.read(K, 40);
_crypt.Init(K);
BigNumber BNK;
BNK.SetBinary(K, 40);
/*
uint8 key[20];
const uint8 SeedKeyLen = 16;
uint8 SeedKey[SeedKeyLen] = { 0x38, 0xA7, 0x83, 0x15, 0xF8, 0x92, 0x25, 0x30, 0x71, 0x98, 0x67, 0xB1, 0x8C, 0x4, 0xE2, 0xAA };
AutheticationPacketKey::GenerateKey(SeedKeyLen, (uint8*)SeedKey, key, K);
// Initialize crypto.
_crypt.SetKey(key, 20);
*/
//checking if player is already connected
//disconnect current player and login this one(blizzlike)
if(recvData.rpos() != recvData.wpos())
recvData.read((uint8*)lang.data(), 4);
WorldSession *session = NULL;
session = sWorld.FindSession( AccountID );
if( session != NULL )
{
if(session->_player != NULL && session->_player->GetMapMgr() == NULL)
{
DEBUG_LOG("WorldSocket","_player found without m_mapmgr during logon, trying to remove him [player %s, map %d, instance %d].", session->_player->GetName(), session->_player->GetMapId(), session->_player->GetInstanceID() );
if(objmgr.GetPlayer(session->_player->GetLowGUID()))
objmgr.RemovePlayer(session->_player);
session->LogoutPlayer(false);
}
// AUTH_FAILED = 0x0D
session->Disconnect();
// clear the logout timer so he times out straight away
session->SetLogoutTimer(1);
// we must send authentication failed here.
// the stupid newb can relog his client.
// otherwise accounts dupe up and disasters happen.
OutPacket(SMSG_AUTH_RESPONSE, 1, "\x15");
return;
}
Sha1Hash sha;
uint8 digest[20];
pAuthenticationPacket->read(digest, 20);
uint32 t = 0;
if( m_fullAccountName == NULL ) // should never happen !
sha.UpdateData(AccountName);
else
{
sha.UpdateData(*m_fullAccountName);
// this is unused now. we may as well free up the memory.
delete m_fullAccountName;
m_fullAccountName = NULL;
}
sha.UpdateData((uint8 *)&t, 4);
//.........这里部分代码省略.........