本文整理汇总了C++中KickPlayer函数的典型用法代码示例。如果您正苦于以下问题:C++ KickPlayer函数的具体用法?C++ KickPlayer怎么用?C++ KickPlayer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KickPlayer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: stripLineInvisibleChars
bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg, uint32 lang)
{
if (lang != LANG_ADDON)
{
// strip invisible characters for non-addon messages
if (sWorld.getConfig(CONFIG_BOOL_CHAT_FAKE_MESSAGE_PREVENTING))
stripLineInvisibleChars(msg);
if (sWorld.getConfig(CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_SEVERITY) && GetSecurity() < SEC_MODERATOR
&& !ChatHandler(this).isValidChatMessage(msg.c_str()))
{
sLog.outError("Player %s (GUID: %u) sent a chatmessage with an invalid link: %s", GetPlayer()->GetName(),
GetPlayer()->GetGUIDLow(), msg.c_str());
if (sWorld.getConfig(CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_KICK))
KickPlayer();
return false;
}
}
return true;
}
开发者ID:Archives,项目名称:try,代码行数:21,代码来源:ChatHandler.cpp
示例2: GetPlayerPool
void CNetGame::Packet_VehicleSync(Packet *p)
{
CPlayer * pPlayer = GetPlayerPool()->GetAt((BYTE)p->playerIndex);
RakNet::BitStream bsVehicleSync(p->data, p->length, false);
if(GetGameState() != GAMESTATE_RUNNING) return;
BYTE bytePacketID=0;
INCAR_SYNC_DATA icSync;
bsVehicleSync.Read(bytePacketID);
bsVehicleSync.Read((PCHAR)&icSync,sizeof(INCAR_SYNC_DATA));
if(pPlayer) {
if(icSync.VehicleID == 0xFFFF) {
// Syncing a manually added/bad vehicle
KickPlayer((BYTE)p->playerIndex);
return;
}
pPlayer->StoreInCarFullSyncData(&icSync);
}
}
开发者ID:jovazxc,项目名称:samp,代码行数:22,代码来源:netgame.cpp
示例3: KickPlayer
void WorldSession::HandleLootOpcode(WorldPacket & recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_LOOT");
uint64 guid;
recv_data >> guid;
// Check possible cheat
if (!IS_ITEM_GUID(guid)); //Takoye ne proidyot
else
{
KickPlayer();//Te6e KuK
return;
}
if (!_player->isAlive())
return;
GetPlayer()->SendLoot(guid, LOOT_CORPSE);
// interrupt cast
if (GetPlayer()->IsNonMeleeSpellCasted(false))
GetPlayer()->InterruptNonMeleeSpells(false);
}
开发者ID:artkeep,项目名称:trinity,代码行数:23,代码来源:LootHandler.cpp
示例4: getMSTime
//.........这里部分代码省略.........
// however when we recieve CMSG_CHAR_ENUM we are surely no longer during the logout process.
if (packet->GetOpcode() == CMSG_CHAR_ENUM)
m_playerRecentlyLogout = false;
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle->handler)(*packet);
if (sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE) && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet);
break;
case STATUS_NEVER:
sLog->outError(LOG_FILTER_OPCODES, "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode(), WOW_CLIENT).c_str()
, GetPlayerName(false).c_str());
break;
case STATUS_UNHANDLED:
sLog->outError(LOG_FILTER_OPCODES, "Received not handled opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode(), WOW_CLIENT).c_str()
, GetPlayerName(false).c_str());
break;
}
}
catch(ByteBufferException &)
{
sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
packet->hexlike();
}
nbPacket++;
std::map<uint32, OpcodeInfo>::iterator itr = pktHandle.find(packet->GetOpcode());
if (itr == pktHandle.end())
pktHandle.insert(std::make_pair(packet->GetOpcode(), OpcodeInfo(1, getMSTime() - pktTime)));
else
{
OpcodeInfo& data = (*itr).second;
data.nbPkt += 1;
data.totalTime += getMSTime() - pktTime;
}
if (deletePacket)
delete packet;
#define MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE 250
processedPackets++;
//process only a max amout of packets in 1 Update() call.
//Any leftover will be processed in next update
if (processedPackets > MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE)
break;
}
if (m_Socket && !m_Socket->IsClosed() && _warden)
_warden->Update();
ProcessQueryCallbacks();
//check if we are safe to proceed with logout
//logout procedure should happen only in World::UpdateSessions() method!!!
if (updater.ProcessLogout())
{
time_t currTime = time(NULL);
///- If necessary, log the player out
if (ShouldLogOut(currTime) && !m_playerLoading)
LogoutPlayer(true);
if (m_Socket && GetPlayer() && _warden)
_warden->Update();
///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed())
{
m_Socket->RemoveReference();
m_Socket = NULL;
}
if (!m_Socket)
return false; //Will remove this session from the world session map
}
sessionDiff = getMSTime() - sessionDiff;
if (sessionDiff > 70)
{
std::map<uint32, OpcodeInfo>::iterator itr = pktHandle.find(CMSG_ADD_FRIEND);
if (itr != pktHandle.end())
{
if ((*itr).second.nbPkt > 7)
{
sLog->OutSpecialLog("Account [%u] has been kicked for flood of CMSG_ADD_FRIEND (count : %u)", GetAccountId(), (*itr).second.nbPkt);
KickPlayer();
return false;
}
}
sLog->OutSpecialLog("Session of account [%u] take more than 50 ms to execute (%u ms)", GetAccountId(), sessionDiff);
for (auto itr : pktHandle)
sLog->OutSpecialLog("-----> %u %s (%u ms)", itr.second.nbPkt, GetOpcodeNameForLogging((Opcodes)itr.first, WOW_CLIENT).c_str(), itr.second.totalTime);
}
return true;
}
开发者ID:Expery,项目名称:Core,代码行数:101,代码来源:WorldSession.cpp
示例5: LookupOpcodeName
void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
{
uint32 opcode = recv_data.GetOpcode();
sLog.outDebug("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode);
Unit *mover = _player->m_mover;
Player *plMover = mover->GetTypeId()==TYPEID_PLAYER ? (Player*)mover : NULL;
// ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
if(plMover && plMover->IsBeingTeleported()){
// movement anticheat
plMover->m_anti_JustTeleported = 1;
// end movement anticheat
return;
}
/* extract packet */
MovementInfo movementInfo;
ReadMovementInfo(recv_data, &movementInfo);
/*----------------*/
if(recv_data.size() != recv_data.rpos())
{
sLog.outError("MovementHandler: player %s (guid %d, account %u) sent a packet (opcode %u) that is " SIZEFMTD " bytes larger than it should be. Kicked as cheater.", _player->GetName(), _player->GetGUIDLow(), _player->GetSession()->GetAccountId(), recv_data.GetOpcode(), recv_data.size() - recv_data.rpos());
KickPlayer();
return;
}
if (!MaNGOS::IsValidMapCoord(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o))
return;
/* handle special cases */
if (movementInfo.HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
{
// transports size limited
// (also received at zeppelin leave by some reason with t_* as absolute in continent coordinates, can be safely skipped)
if( movementInfo.t_x > 60 || movementInfo.t_y > 60 || movementInfo.t_x < -60 || movementInfo.t_y < -60 )
return;
if( !MaNGOS::IsValidMapCoord(movementInfo.x+movementInfo.t_x, movementInfo.y + movementInfo.t_y,
movementInfo.z + movementInfo.t_z, movementInfo.o + movementInfo.t_o) )
return;
if (plMover && plMover->m_anti_TransportGUID == 0 && (movementInfo.t_guid !=0))
{
// if we boarded a transport, add us to it
if (plMover && !plMover->m_transport)
{
// elevators also cause the client to send MOVEMENTFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list
for (MapManager::TransportSet::const_iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter)
{
if ((*iter)->GetGUID() == movementInfo.t_guid)
{
plMover->m_transport = (*iter);
(*iter)->AddPassenger(plMover);
break;
}
}
}
//movement anticheat;
//Correct finding GO guid in DB (thanks to GriffonHeart)
GameObject *obj = HashMapHolder<GameObject>::Find(movementInfo.t_guid);
if(obj)
plMover->m_anti_TransportGUID = obj->GetDBTableGUIDLow();
else
plMover->m_anti_TransportGUID = GUID_LOPART(movementInfo.t_guid);
// end movement anticheat
}
} else if (plMover && plMover->m_anti_TransportGUID != 0){
if (plMover && plMover->m_transport) // if we were on a transport, leave
{
plMover->m_transport->RemovePassenger(plMover);
plMover->m_transport = NULL;
}
movementInfo.t_x = 0.0f;
movementInfo.t_y = 0.0f;
movementInfo.t_z = 0.0f;
movementInfo.t_o = 0.0f;
movementInfo.t_time = 0;
movementInfo.t_seat = -1;
plMover->m_anti_TransportGUID = 0;
}
// fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
if (opcode == MSG_MOVE_FALL_LAND && plMover && !plMover->isInFlight())
{
//movement anticheat
plMover->m_anti_JustJumped = 0;
plMover->m_anti_JumpBaseZ = 0;
//end movement anticheat
plMover->HandleFall(movementInfo);
}
if (plMover && (movementInfo.HasMovementFlag(MOVEMENTFLAG_SWIMMING) != plMover->IsInWater()))
{
// now client not include swimming flag in case jumping under water
plMover->SetInWater( !plMover->IsInWater() || plMover->GetBaseMap()->IsUnderWater(movementInfo.x, movementInfo.y, movementInfo.z) );
}
//.........这里部分代码省略.........
开发者ID:m1ke-dormant,项目名称:mangos,代码行数:101,代码来源:MovementHandler.cpp
示例6: assert
void CAntiCheatManager::ProcessFlagActivity(TCheatType type, uint16 channelId, const float *params, int numParams, const char * pDescription, XmlNodeRef additionalXmlData)
{
SCheatType &cheat = m_cheats[type];
XmlNodeRef incidentXML;
float fInfractionsSeverity = 0.0f;
int nMaxConfidence = 0, nMaxInfractionConfidence = 0;
typedef std::vector<const SCheatAction*> TCheatActionPtrList;
TCheatActionPtrList actionsToTake;
EDisconnectionCause kickReason = eDC_Kicked;
for (std::vector<SCheatAction>::iterator itAction = cheat.actions.begin(); itAction != cheat.actions.end(); ++itAction)
{
bool meetsConditions = true;
for (std::vector<SCheatCondition>::const_iterator itCondition = itAction->conditions.begin(); itCondition != itAction->conditions.end(); ++itCondition)
{
assert(itCondition->paramNum <= numParams);
float paramValue = params[itCondition->paramNum-1];
meetsConditions = MeetsCondition(itCondition->op, paramValue, itCondition->value);
if (!meetsConditions)
{
break;
}
}
if (meetsConditions)
{
actionsToTake.push_back(&(*itAction));
if(incidentXML == NULL)
{
incidentXML = CreateIncidentXML(channelId, type, params, numParams, pDescription);
if(additionalXmlData != NULL && incidentXML != NULL)
incidentXML->addChild(additionalXmlData);
}
}
if(itAction->action == eCA_Global_Ban)
{
kickReason = GetBanKickType(channelId);
}
}
bool bDoRemoteLog = false;
for(TCheatActionPtrList::const_iterator itActionPtr = actionsToTake.begin(); itActionPtr != actionsToTake.end(); ++itActionPtr)
{
const SCheatAction * actionPtr = *itActionPtr;
nMaxConfidence = max(actionPtr->confidence, nMaxConfidence);
switch (actionPtr->action)
{
case eCA_Log:
//The presence of this action will cause the incident to be logged, we don't want to add
// any more output as it won't provide any more data
break;
case eCA_Log_Remote:
bDoRemoteLog = true;
break;
case eCA_Infraction:
{
fInfractionsSeverity += actionPtr->severity;
nMaxInfractionConfidence = max(actionPtr->confidence, nMaxInfractionConfidence);
}
break;
case eCA_Kick:
CheatLogAction(incidentXML, eCA_Kick, actionPtr->confidence);
KickPlayer(channelId, kickReason, actionPtr->confidence);
break;
case eCA_Kick_Delayed:
CheatLogAction(incidentXML, eCA_Kick_Delayed, actionPtr->confidence);
KickPlayerDelayed(channelId, kickReason, actionPtr->confidence);
break;
case eCA_Ban:
CheatLogAction(incidentXML, eCA_Ban, actionPtr->confidence);
BanPlayer_Internal(channelId, actionPtr->banTimeout, actionPtr->confidence);
break;
case eCA_Global_Ban:
break;
case eCA_Dev_CheatDetected:
{
#if defined(DEV_CHEAT_HANDLING)
CheatLogAction(incidentXML, eCA_Dev_CheatDetected, actionPtr->confidence);
stack_string paramsString;
CAntiCheatManager::GenerateMessageString(paramsString, params, numParams, pDescription);
paramsString.append(" ");
paramsString.append(s_cheatTypeNames[type]);
HandleDevCheat(channelId, paramsString);
#endif
break;
}
}
}
//.........这里部分代码省略.........
开发者ID:aronarts,项目名称:FireNET,代码行数:101,代码来源:AntiCheatManager.cpp
示例7: LookupOpcodeName
void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData)
{
uint32 opcode = recvData.GetOpcode();
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode);
/* extract packet */
uint64 guid;
uint32 unk1;
float newspeed;
recvData.readPackGUID(guid);
// pussywizard: special check, only player mover allowed here
if (guid != _player->m_mover->GetGUID() || guid != _player->GetGUID())
{
recvData.rfinish(); // prevent warnings spam
return;
}
// continue parse packet
recvData >> unk1; // counter or moveEvent
MovementInfo movementInfo;
movementInfo.guid = guid;
ReadMovementInfo(recvData, &movementInfo);
recvData >> newspeed;
/*----------------*/
// client ACK send one packet for mounted/run case and need skip all except last from its
// in other cases anti-cheat check can be fail in false case
UnitMoveType move_type;
UnitMoveType force_move_type;
static char const* move_type_name[MAX_MOVE_TYPE] = { "Walk", "Run", "RunBack", "Swim", "SwimBack", "TurnRate", "Flight", "FlightBack", "PitchRate" };
switch (opcode)
{
case CMSG_FORCE_WALK_SPEED_CHANGE_ACK: move_type = MOVE_WALK; force_move_type = MOVE_WALK; break;
case CMSG_FORCE_RUN_SPEED_CHANGE_ACK: move_type = MOVE_RUN; force_move_type = MOVE_RUN; break;
case CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK: move_type = MOVE_RUN_BACK; force_move_type = MOVE_RUN_BACK; break;
case CMSG_FORCE_SWIM_SPEED_CHANGE_ACK: move_type = MOVE_SWIM; force_move_type = MOVE_SWIM; break;
case CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK: move_type = MOVE_SWIM_BACK; force_move_type = MOVE_SWIM_BACK; break;
case CMSG_FORCE_TURN_RATE_CHANGE_ACK: move_type = MOVE_TURN_RATE; force_move_type = MOVE_TURN_RATE; break;
case CMSG_FORCE_FLIGHT_SPEED_CHANGE_ACK: move_type = MOVE_FLIGHT; force_move_type = MOVE_FLIGHT; break;
case CMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE_ACK: move_type = MOVE_FLIGHT_BACK; force_move_type = MOVE_FLIGHT_BACK; break;
case CMSG_FORCE_PITCH_RATE_CHANGE_ACK: move_type = MOVE_PITCH_RATE; force_move_type = MOVE_PITCH_RATE; break;
default:
sLog->outError("WorldSession::HandleForceSpeedChangeAck: Unknown move type opcode: %u", opcode);
return;
}
// skip all forced speed changes except last and unexpected
// in run/mounted case used one ACK and it must be skipped.m_forced_speed_changes[MOVE_RUN} store both.
if (_player->m_forced_speed_changes[force_move_type] > 0)
{
--_player->m_forced_speed_changes[force_move_type];
if (_player->m_forced_speed_changes[force_move_type] > 0)
return;
}
if (!_player->GetTransport() && fabs(_player->GetSpeed(move_type) - newspeed) > 0.01f)
{
if (_player->GetSpeed(move_type) > newspeed) // must be greater - just correct
{
sLog->outError("%sSpeedChange player %s is NOT correct (must be %f instead %f), force set to correct value",
move_type_name[move_type], _player->GetName().c_str(), _player->GetSpeed(move_type), newspeed);
_player->SetSpeed(move_type, _player->GetSpeedRate(move_type), true);
}
else // must be lesser - cheating
{
sLog->outBasic("Player %s from account id %u kicked for incorrect speed (must be %f instead %f)",
_player->GetName().c_str(), GetAccountId(), _player->GetSpeed(move_type), newspeed);
KickPlayer();
}
}
}
开发者ID:Keader,项目名称:Sunwell,代码行数:78,代码来源:MovementHandler.cpp
示例8: Player
void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
{
ObjectGuid playerGuid = holder->GetGuid();
Player* pCurrChar = new Player(this);
pCurrChar->GetMotionMaster()->Initialize();
SetPlayer(pCurrChar);
m_playerLoading = true;
SetOnline();
// "GetAccountId()==db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
if (!pCurrChar->LoadFromDB(playerGuid, holder))
{
KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick
delete pCurrChar; // delete it manually
delete holder; // delete all unprocessed queries
m_playerLoading = false;
sLog.outError("HandlePlayerLogin> LoadFromDB failed to load %s, AccountId = %u", pCurrChar->GetGuidStr().c_str(), GetAccountId());
WorldPacket data(SMSG_CHARACTER_LOGIN_FAILED, 1);
data << (uint8)CHAR_LOGIN_NO_CHARACTER;
SendPacket(data, true);
return;
}
WorldPacket data(SMSG_LOGIN_VERIFY_WORLD, 20);
data << pCurrChar->GetMapId();
data << pCurrChar->GetPositionX();
data << pCurrChar->GetPositionY();
data << pCurrChar->GetPositionZ();
data << pCurrChar->GetOrientation();
SendPacket(data);
data.Initialize(SMSG_ACCOUNT_DATA_TIMES, 128);
for (int i = 0; i < 32; ++i)
data << uint32(0);
SendPacket(data);
// Send Spam records
SendExpectedSpamRecords();
SendMotd(pCurrChar);
// QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
QueryResult* resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
if (resultGuild)
{
Field* fields = resultGuild->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32());
delete resultGuild;
}
else if (pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about nonexistent membership
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
if (pCurrChar->GetGuildId() != 0)
{
Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId());
if (guild)
{
data.Initialize(SMSG_GUILD_EVENT, (1 + 1 + guild->GetMOTD().size() + 1));
data << uint8(GE_MOTD);
data << uint8(1);
data << guild->GetMOTD();
SendPacket(data);
DEBUG_LOG("WORLD: Sent guild-motd (SMSG_GUILD_EVENT)");
guild->BroadcastEvent(GE_SIGNED_ON, pCurrChar->GetObjectGuid(), pCurrChar->GetName());
}
else
{
// remove wrong guild data
sLog.outError("Player %s (GUID: %u) marked as member of nonexistent guild (id: %u), removing guild membership for player.", pCurrChar->GetName(), pCurrChar->GetGUIDLow(), pCurrChar->GetGuildId());
pCurrChar->SetInGuild(0);
}
}
if (!pCurrChar->isAlive())
pCurrChar->SendCorpseReclaimDelay(true);
pCurrChar->SendInitialPacketsBeforeAddToMap();
// Show cinematic at the first time that player login
if (!pCurrChar->getCinematic())
{
pCurrChar->setCinematic(1);
if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace()))
pCurrChar->SendCinematicStart(rEntry->CinematicSequence);
}
uint32 miscRequirement = 0;
AreaLockStatus lockStatus = AREA_LOCKSTATUS_OK;
if (AreaTrigger const* at = sObjectMgr.GetMapEntranceTrigger(pCurrChar->GetMapId()))
lockStatus = pCurrChar->GetAreaTriggerLockStatus(at, miscRequirement);
//.........这里部分代码省略.........
开发者ID:cmangos,项目名称:mangos-classic,代码行数:101,代码来源:CharacterHandler.cpp
示例9: while
//.........这里部分代码省略.........
LogUnexpectedOpcode(packet, "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)
m_playerRecentlyLogout = false;
ExecuteOpcode(opHandle, packet);
break;
case STATUS_NEVER:
sLog.outError( "SESSION: received not allowed opcode %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
break;
case STATUS_UNHANDLED:
DEBUG_LOG("SESSION: received not handled opcode %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
break;
default:
sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode());
break;
}
}
catch (ByteBufferException &)
{
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
{
sLog.outDebug("Dumping error causing packet:");
packet->hexlike();
}
if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))
{
DETAIL_LOG("Disconnecting session [account id %u / address %s] for badly formatted packet.",
GetAccountId(), GetRemoteAddress().c_str());
KickPlayer();
}
}
delete packet;
}
// Playerbot mod - Process player bot packets
// The PlayerbotAI class adds to the packet queue to simulate a real player
// since Playerbots are known to the World obj only by its master's WorldSession object
// we need to process all master's bot's packets.
if (GetPlayer() && GetPlayer()->GetPlayerbotMgr()) {
for (PlayerBotMap::const_iterator itr = GetPlayer()->GetPlayerbotMgr()->GetPlayerBotsBegin();
itr != GetPlayer()->GetPlayerbotMgr()->GetPlayerBotsEnd(); ++itr)
{
Player* const botPlayer = itr->second;
WorldSession* const pBotWorldSession = botPlayer->GetSession();
if (botPlayer->IsBeingTeleported())
botPlayer->GetPlayerbotAI()->HandleTeleportAck();
else if (botPlayer->IsInWorld())
{
WorldPacket* packet;
while (pBotWorldSession->_recvQueue.next(packet))
{
OpcodeHandler& opHandle = opcodeTable[packet->GetOpcode()];
(pBotWorldSession->*opHandle.handler)(*packet);
delete packet;
}
}
}
}
if (m_Socket && GetPlayer() && !GetPlayer()->GetPlayerbotAI())
m_Warden.Update();
///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed ())
{
m_Socket->RemoveReference ();
m_Socket = NULL;
}
//check if we are safe to proceed with logout
//logout procedure should happen only in World::UpdateSessions() method!!!
if(updater.ProcessLogout())
{
///- If necessary, log the player out
time_t currTime = time(NULL);
if (!m_Socket || (ShouldLogOut(currTime) && !m_playerLoading))
LogoutPlayer(true);
if (!m_Socket)
return false; //Will remove this session from the world session map
}
return true;
}
开发者ID:Seehub,项目名称:mangos,代码行数:101,代码来源:WorldSession.cpp
示例10: UpdateTimeOutTime
/// Update the WorldSession (triggered by World update)
bool WorldSession::Update(uint32 diff, PacketFilter& updater)
{
/// Update Timeout timer.
UpdateTimeOutTime(diff);
///- Before we process anything:
/// If necessary, kick the player from the character select screen
if (IsConnectionIdle())
m_Socket->CloseSocket();
///- Retrieve packets from the receive queue and call the appropriate handlers
/// not process packets if socket already closed
WorldPacket* packet = NULL;
//! Delete packet after processing by default
bool deletePacket = true;
//! To prevent infinite loop
WorldPacket* firstDelayedPacket = NULL;
//! If _recvQueue.peek() == firstDelayedPacket it means that in this Update call, we've processed all
//! *properly timed* packets, and we're now at the part of the queue where we find
//! delayed packets that were re-enqueued due to improper timing. To prevent an infinite
//! loop caused by re-enqueueing the same packets over and over again, we stop updating this session
//! and continue updating others. The re-enqueued packets will be handled in the next Update call for this session.
uint32 processedPackets = 0;
while (m_Socket && !m_Socket->IsClosed() &&
!_recvQueue.empty() && _recvQueue.peek(true) != firstDelayedPacket &&
_recvQueue.next(packet, updater))
{
if (!AntiDOS.EvaluateOpcode(*packet))
KickPlayer();
OpcodeHandler const* opHandle = clientOpcodeTable[packet->GetOpcode()];
try
{
switch (opHandle->Status)
{
case STATUS_LOGGEDIN:
if (!_player)
{
// skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets
//! If player didn't log out a while ago, it means packets are being sent while the server does not recognize
//! the client to be in world yet. We will re-add the packets to the bottom of the queue and process them later.
if (!m_playerRecentlyLogout)
{
//! Prevent infinite loop
if (!firstDelayedPacket)
firstDelayedPacket = packet;
//! Because checking a bool is faster than reallocating memory
deletePacket = false;
QueuePacket(packet);
//! Log
TC_LOG_DEBUG("network", "Re-enqueueing packet with opcode %s with with status STATUS_LOGGEDIN. "
"Player is currently not in world yet.", GetOpcodeNameForLogging(packet->GetOpcode(), false).c_str());
}
}
else if (_player->IsInWorld())
{
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle->Handler)(*packet);
LogUnprocessedTail(packet);
}
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT:
if (!_player && !m_playerRecentlyLogout && !m_playerLogout) // There's a short delay between _player = null and m_playerRecentlyLogout = true during logout
LogUnexpectedOpcode(packet, "STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT",
"the player has not logged in yet and not recently logout");
else
{
// not expected _player or must checked in packet hanlder
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle->Handler)(*packet);
LogUnprocessedTail(packet);
}
break;
case STATUS_TRANSFER:
if (!_player)
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player has not logged in yet");
else if (_player->IsInWorld())
LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player is still in world");
else
{
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle->Handler)(*packet);
LogUnprocessedTail(packet);
}
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if (m_inQueue)
{
LogUnexpectedOpcode(packet, "STATUS_AUTHED", "the player not pass queue yet");
break;
}
// some auth opcodes can be recieved before STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes
// however when we recieve CMSG_CHAR_ENUM we are surely no longer during the logout process.
if (packet->GetOpcode() == CMSG_CHAR_ENUM)
m_playerRecentlyLogout = false;
//.........这里部分代码省略.........
开发者ID:BHollowell,项目名称:SkyFire_5xx,代码行数:101,代码来源:WorldSession.cpp
示例11: Player
void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
{
uint64 playerGuid = holder->GetGuid();
Player* pCurrChar = new Player(this);
pCurrChar->GetMotionMaster()->Initialize();
// "GetAccountId()==db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
if(!pCurrChar->LoadFromDB(GUID_LOPART(playerGuid), holder))
{
KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick
delete pCurrChar; // delete it manually
delete holder; // delete all unprocessed queries
m_playerLoading = false;
return;
}
SetPlayer(pCurrChar);
pCurrChar->SendDungeonDifficulty(false);
WorldPacket data( SMSG_LOGIN_VERIFY_WORLD, 20 );
data << pCurrChar->GetMapId();
data << pCurrChar->GetPositionX();
data << pCurrChar->GetPositionY();
data << pCurrChar->GetPositionZ();
data << pCurrChar->GetOrientation();
SendPacket(&data);
data.Initialize( SMSG_ACCOUNT_DATA_TIMES, 128 );
for(int i = 0; i < 32; i++)
data << uint32(0);
SendPacket(&data);
data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2); // added in 2.2.0
data << uint8(2); // unknown value
data << uint8(0); // enable(1)/disable(0) voice chat interface in client
SendPacket(&data);
// Send MOTD
{
data.Initialize(SMSG_MOTD, 50); // new in 2.0.1
data << (uint32)0;
uint32 linecount=0;
std::string str_motd = sWorld.GetMotd();
std::string::size_type pos, nextpos;
pos = 0;
while ( (nextpos= str_motd.find('@',pos)) != std::string::npos )
{
if (nextpos != pos)
{
data << str_motd.substr(pos,nextpos-pos);
++linecount;
}
pos = nextpos+1;
}
if (pos<str_motd.length())
{
data << str_motd.substr(pos);
++linecount;
}
data.put(0, linecount);
SendPacket( &data );
DEBUG_LOG( "WORLD: Sent motd (SMSG_MOTD)" );
}
//QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
if(resultGuild)
{
Field *fields = resultGuild->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32());
delete resultGuild;
}
else if(pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
if(pCurrChar->GetGuildId() != 0)
{
Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId());
if(guild)
{
data.Initialize(SMSG_GUILD_EVENT, (2+guild->GetMOTD().size()+1));
data << (uint8)GE_MOTD;
data << (uint8)1;
data << guild->GetMOTD();
SendPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-motd (SMSG_GUILD_EVENT)" );
data.Initialize(SMSG_GUILD_EVENT, (5+10)); // we guess size
//.........这里部分代码省略.........
开发者ID:benzin97,项目名称:mangos,代码行数:101,代码来源:CharacterHandler.cpp
示例12: Player
void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
{
/* Store the player's GUID for later reference */
ObjectGuid playerGuid = holder->GetGuid();
/* Create a new instance of the player object */
Player* pCurrChar = new Player(this);
/* Initialize a motion generator */
pCurrChar->GetMotionMaster()->Initialize();
/* Account ID is validated in LoadFromDB (prevents cheaters logging in to characters not on their account) */
if (!pCurrChar->LoadFromDB(playerGuid, holder)) /// Could not load character from database, cancel login
{
/* Disconnect the game client */
KickPlayer();
/* Remove references to avoid dangling pointers */
delete pCurrChar;
delete holder;
/* Checked in WorldSession::Update */
m_playerLoading = false;
return;
}
/* Validation check completely, assign player to WorldSession::_player for later use */
SetPlayer(pCurrChar);
WorldPacket data(SMSG_LOGIN_VERIFY_WORLD, 20);
data << pCurrChar->GetMapId();
data << pCurrChar->GetPositionX();
data << pCurrChar->GetPositionY();
data << pCurrChar->GetPositionZ();
data << pCurrChar->GetOrientation();
SendPacket(&data);
data.Initialize(SMSG_ACCOUNT_DATA_TIMES, 128);
for (int i = 0; i < 32; ++i)
{ data << uint32(0); }
SendPacket(&data);
/* 1.12.1 does not have SMSG_MOTD, so we send a server message */
/* Used for counting number of newlines in MOTD */
uint32 linecount = 0;
/* The MOTD itself */
std::string str_motd = sWorld.GetMotd();
/* Used for tracking our position within the MOTD while iterating through it */
std::string::size_type pos = 0, nextpos;
/* Find the next occurance of @ in the string
* This is how newlines are represented */
while ((nextpos = str_motd.find('@', pos)) != std::string::npos)
{
/* If these are not equal, it means a '@' was found
* These are used to represent newlines in the string
* It is set by the code above here */
if (nextpos != pos)
{
/* Send the player a system message containing the substring from pos to nextpos - pos */
ChatHandler(pCurrChar).PSendSysMessage(str_motd.substr(pos, nextpos - pos).c_str());
++linecount;
}
pos = nextpos + 1;
}
/* There are no more newlines in our MOTD, so we send whatever is left */
if (pos < str_motd.length())
{
ChatHandler(pCurrChar).PSendSysMessage(str_motd.substr(pos).c_str());
}
DEBUG_LOG("WORLD: Sent motd (SMSG_MOTD)");
/* Attempt to load guild for player */
if (QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD))
{
/* We're in a guild, so set the player's guild data to represent that */
Field* fields = resultGuild->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32());
/* Avoid dangling pointers */
delete resultGuild;
}
/* Player thinks they have a guild, but it isn't in the database. Clear that information */
else if (pCurrChar->GetGuildId())
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
/* Player is in a guild
* TODO: Can we move this code into the block above? Not sure why it's down here */
if (pCurrChar->GetGuildId() != 0)
{
/* Get guild based on what we set the player's guild to above */
Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId());
/* More checks to see if they're in a guild? I'm sure this is redundant */
if (guild)
//.........这里部分代码省略.........
开发者ID:0jpq0,项目名称:server,代码行数:101,代码来源:CharacterHandler.cpp
示例13: guard
/// Update the WorldSession (triggered by World update)
bool WorldSession::Update(PacketFilter& updater)
{
std::lock_guard<std::mutex> guard(m_recvQueueLock);
///- Retrieve packets from the receive queue and call the appropriate handlers
/// not process packets if socket already closed
while (m_Socket && !m_Socket->IsClosed() && !m_recvQueue.empty())
{
auto const packet = std::move(m_recvQueue.front());
m_recvQueue.pop_front();
/*#if 1
sLog.outError( "MOEP: %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
#endif*/
OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()];
try
{
switch (opHandle.status)
{
case STATUS_LOGGEDIN:
if (!_player)
{
// skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets
if (!m_playerRecentlyLogout)
LogUnexpectedOpcode(*packet, "the player has not logged in yet");
}
else if (_player->IsInWorld())
ExecuteOpcode(opHandle, *packet);
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGEDOUT:
if (!_player && !m_playerRecentlyLogout)
{
LogUnexpectedOpcode(*packet, "the player has not logged in yet and not recently logout");
}
else
// not expected _player or must checked in packet hanlder
ExecuteOpcode(opHandle, *packet);
break;
case STATUS_TRANSFER:
if (!_player)
LogUnexpectedOpcode(*packet, "the player has not logged in yet");
else if (_player->IsInWorld())
LogUnexpectedOpcode(*packet, "the player is still in world");
else
ExecuteOpcode(opHandle, *packet);
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
if (m_inQueue)
{
LogUnexpectedOpcode(*packet, "the player not pass queue yet");
break;
}
// single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)
m_playerRecentlyLogout = false;
ExecuteOpcode(opHandle, *packet);
break;
case STATUS_NEVER:
sLog.outError("SESSION: received not allowed opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
case STATUS_UNHANDLED:
DEBUG_LOG("SESSION: received not handled opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
default:
sLog.outError("SESSION: received wrong-status-req opcode %s (0x%.4X)",
packet->GetOpcodeName(),
packet->GetOpcode());
break;
}
}
catch (ByteBufferException&)
{
sLog.outError("WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i.",
packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG))
{
DEBUG_LOG("Dumping error causing packet:");
packet->hexlike();
}
if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET))
{
DETAIL_LOG("Disconnecting session [account id %u / address %s] for badly formatted packet.",
GetAccountId(), GetRemoteAddress().c_str());
KickPlayer();
//.........这里部分代码省略.........
开发者ID:Ozerev,项目名称:mangos-tbc,代码行数:101,代码来源:WorldSession.cpp
|
请发表评论